Tue, 13 Feb 2018 14:56:08 +0200
Removed LDConditionalEdge::becomeEdgeLine
--- a/src/linetypes/conditionaledge.cpp Tue Feb 13 14:22:10 2018 +0200 +++ b/src/linetypes/conditionaledge.cpp Tue Feb 13 14:56:08 2018 +0200 @@ -44,19 +44,7 @@ void LDConditionalEdge::invert() { - // I don't think that a conditional line's control points need to be swapped, do they? Vertex temp = vertex(0); setVertex(0, vertex(1)); setVertex(1, temp); } - -LDEdgeLine* LDConditionalEdge::becomeEdgeLine() -{ - LDEdgeLine* replacement = model()->emplaceReplacement<LDEdgeLine>(this); - - for (int i = 0; i < replacement->numVertices(); ++i) - replacement->setVertex (i, vertex (i)); - - replacement->setColor (color()); - return replacement; -}
--- a/src/linetypes/conditionaledge.h Tue Feb 13 14:22:10 2018 +0200 +++ b/src/linetypes/conditionaledge.h Tue Feb 13 14:56:08 2018 +0200 @@ -36,7 +36,6 @@ virtual void invert() override; int numVertices() const override { return 4; } LDColor defaultColor() const override { return EdgeColor; } - LDEdgeLine* becomeEdgeLine(); QString typeName() const override { return "condline"; } protected:
--- a/src/toolsets/algorithmtoolset.cpp Tue Feb 13 14:22:10 2018 +0200 +++ b/src/toolsets/algorithmtoolset.cpp Tue Feb 13 14:56:08 2018 +0200 @@ -277,15 +277,25 @@ void AlgorithmToolset::demote() { - int num = 0; + int count = 0; + + for (int i = 0; i < currentDocument()->size(); ++i) + { + LDObject* object = currentDocument()->objects()[i]; - for (LDConditionalEdge* line : filterByType<LDConditionalEdge>(selectedObjects())) - { - line->becomeEdgeLine(); - ++num; + if (object->type() == LDObjectType::ConditionalEdge) + { + Vertex v1 = object->vertex(0); + Vertex v2 = object->vertex(1); + LDColor color = object->color(); + currentDocument()->removeAt(i); + LDEdgeLine* edge = currentDocument()->emplaceAt<LDEdgeLine>(i, v1, v2); + edge->setColor(color); + count += 1; + } } - print (tr ("Converted %1 conditional lines"), num); + print (tr ("Converted %1 conditional lines"), count); } bool AlgorithmToolset::isColorUsed (LDColor color)