diff -r 1909a0123c72 -r 52e10e8d88cc src/document.cpp --- a/src/document.cpp Tue Jun 07 21:35:29 2022 +0300 +++ b/src/document.cpp Wed Jun 08 19:33:00 2022 +0300 @@ -32,7 +32,6 @@ colorTable{colorTable}, canvas{new Canvas{model, this, documents, colorTable, this}}, model{model}, - documents{documents}, vertexMap{model} { this->setMouseTracking(true); @@ -183,31 +182,40 @@ switch (this->drawState.polygon.size()) { case 2: - this->model->append(Colored{ - LineSegment{ - .p1 = this->drawState.polygon[0], - .p2 = this->drawState.polygon[1], - }, - ldraw::EDGE_COLOR}); + Q_EMIT this->modelAction(AppendToModel{ + .newElement = Colored{ + LineSegment{ + .p1 = this->drawState.polygon[0], + .p2 = this->drawState.polygon[1], + }, + ldraw::EDGE_COLOR, + } + }); break; case 3: - this->model->append(Colored{ - Triangle{ - .p1 = this->drawState.polygon[0], - .p2 = this->drawState.polygon[1], - .p3 = this->drawState.polygon[2], - }, - ldraw::MAIN_COLOR}); + Q_EMIT this->modelAction(AppendToModel{ + .newElement = Colored{ + Triangle{ + .p1 = this->drawState.polygon[0], + .p2 = this->drawState.polygon[1], + .p3 = this->drawState.polygon[2], + }, + ldraw::MAIN_COLOR, + } + }); break; case 4: - this->model->append(Colored{ - Quadrilateral{ - .p1 = this->drawState.polygon[0], - .p2 = this->drawState.polygon[1], - .p3 = this->drawState.polygon[2], - .p4 = this->drawState.polygon[3], - }, - ldraw::MAIN_COLOR}); + Q_EMIT this->modelAction(AppendToModel{ + .newElement = Colored{ + Quadrilateral{ + .p1 = this->drawState.polygon[0], + .p2 = this->drawState.polygon[1], + .p3 = this->drawState.polygon[2], + .p4 = this->drawState.polygon[3], + }, + ldraw::MAIN_COLOR, + } + }); break; } }