src/tools/drawtool.cpp

changeset 152
03f8e6d42e13
parent 143
7b62c52835a1
child 153
2f79053c2e9a
--- a/src/tools/drawtool.cpp	Thu Mar 03 21:13:16 2022 +0200
+++ b/src/tools/drawtool.cpp	Fri Mar 04 11:37:50 2022 +0200
@@ -12,8 +12,10 @@
 static const QBrush polygonBrush = {QColor{64, 255, 128, 192}};
 static const QBrush badPolygonBrush = {QColor{255, 96, 96, 192}};
 
-DrawTool::DrawTool(Model *model, QWidget *parent) :
-	BaseTool{model, parent} {}
+DrawTool::DrawTool(Document* document) :
+	BaseTool{document}
+{
+}
 
 QString DrawTool::name() const
 {
@@ -142,17 +144,17 @@
 {
 	if (this->polygon.size() >= 2 and this->polygon.size() <= 4)
 	{
-		Model::EditContext edit = document->editModel();
+		std::unique_ptr<ModelEditor> modelEditor = document->editModel();
 		switch (this->polygon.size())
 		{
 		case 2:
-			edit.append<ldraw::Edge>(vectorToArray<2>(this->polygon), ldraw::EDGE_COLOR);
+			modelEditor->append<ldraw::Edge>(vectorToArray<2>(this->polygon), ldraw::EDGE_COLOR);
 			break;
 		case 3:
-			edit.append<ldraw::Triangle>(vectorToArray<3>(this->polygon), ldraw::MAIN_COLOR);
+			modelEditor->append<ldraw::Triangle>(vectorToArray<3>(this->polygon), ldraw::MAIN_COLOR);
 			break;
 		case 4:
-			edit.append<ldraw::Quadrilateral>(vectorToArray<4>(this->polygon), ldraw::MAIN_COLOR);
+			modelEditor->append<ldraw::Quadrilateral>(vectorToArray<4>(this->polygon), ldraw::MAIN_COLOR);
 			break;
 		}
 	}

mercurial