10 static const QPen polygonPen = {QBrush{Qt::black}, 2.0, Qt::DashLine}; |
10 static const QPen polygonPen = {QBrush{Qt::black}, 2.0, Qt::DashLine}; |
11 static const QPen pointPen = {QBrush{Qt::black}, 2.0}; |
11 static const QPen pointPen = {QBrush{Qt::black}, 2.0}; |
12 static const QBrush polygonBrush = {QColor{64, 255, 128, 192}}; |
12 static const QBrush polygonBrush = {QColor{64, 255, 128, 192}}; |
13 static const QBrush badPolygonBrush = {QColor{255, 96, 96, 192}}; |
13 static const QBrush badPolygonBrush = {QColor{255, 96, 96, 192}}; |
14 |
14 |
15 DrawTool::DrawTool(Model *model, QWidget *parent) : |
15 DrawTool::DrawTool(Document* document) : |
16 BaseTool{model, parent} {} |
16 BaseTool{document} |
|
17 { |
|
18 } |
17 |
19 |
18 QString DrawTool::name() const |
20 QString DrawTool::name() const |
19 { |
21 { |
20 static const QString result = tr("Draw"); |
22 static const QString result = tr("Draw"); |
21 return result; |
23 return result; |
140 |
142 |
141 void DrawTool::closeShape(Document* document) |
143 void DrawTool::closeShape(Document* document) |
142 { |
144 { |
143 if (this->polygon.size() >= 2 and this->polygon.size() <= 4) |
145 if (this->polygon.size() >= 2 and this->polygon.size() <= 4) |
144 { |
146 { |
145 Model::EditContext edit = document->editModel(); |
147 std::unique_ptr<ModelEditor> modelEditor = document->editModel(); |
146 switch (this->polygon.size()) |
148 switch (this->polygon.size()) |
147 { |
149 { |
148 case 2: |
150 case 2: |
149 edit.append<ldraw::Edge>(vectorToArray<2>(this->polygon), ldraw::EDGE_COLOR); |
151 modelEditor->append<ldraw::Edge>(vectorToArray<2>(this->polygon), ldraw::EDGE_COLOR); |
150 break; |
152 break; |
151 case 3: |
153 case 3: |
152 edit.append<ldraw::Triangle>(vectorToArray<3>(this->polygon), ldraw::MAIN_COLOR); |
154 modelEditor->append<ldraw::Triangle>(vectorToArray<3>(this->polygon), ldraw::MAIN_COLOR); |
153 break; |
155 break; |
154 case 4: |
156 case 4: |
155 edit.append<ldraw::Quadrilateral>(vectorToArray<4>(this->polygon), ldraw::MAIN_COLOR); |
157 modelEditor->append<ldraw::Quadrilateral>(vectorToArray<4>(this->polygon), ldraw::MAIN_COLOR); |
156 break; |
158 break; |
157 } |
159 } |
158 } |
160 } |
159 this->polygon.clear(); |
161 this->polygon.clear(); |
160 } |
162 } |