From 1899680ddc78dd53adf49af7c24c47de12d653c3 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 16 Dec 2017 15:51:57 +0100 Subject: [PATCH] Sketcher: Extension of constraints to store virtual space affiliation ===================================================================== The constraint class has been extended so that every constraint knows and serializes whether it is in virtual space or in normal real space. --- src/Mod/Sketcher/App/Constraint.cpp | 13 ++++++++++--- src/Mod/Sketcher/App/Constraint.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 0e01009c0c..03c8da664c 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -58,7 +58,8 @@ Constraint::Constraint() LabelDistance(10.f), LabelPosition(0.f), isDriving(true), - InternalAlignmentIndex(-1) + InternalAlignmentIndex(-1), + isInVirtualSpace(false) { // Initialize a random number generator, to avoid Valgrind false positives. static boost::mt19937 ran; @@ -88,6 +89,7 @@ Constraint::Constraint(const Constraint& from) LabelPosition(from.LabelPosition), isDriving(from.isDriving), InternalAlignmentIndex(from.InternalAlignmentIndex), + isInVirtualSpace(from.isInVirtualSpace), tag(from.tag) { } @@ -118,6 +120,7 @@ Constraint *Constraint::copy(void) const temp->LabelPosition = this->LabelPosition; temp->isDriving = this->isDriving; temp->InternalAlignmentIndex = this->InternalAlignmentIndex; + temp->isInVirtualSpace = this->isInVirtualSpace; // Do not copy tag, otherwise it is considered a clone, and a "rename" by the expression engine. return temp; } @@ -183,8 +186,9 @@ void Constraint::Save (Writer &writer) const << "ThirdPos=\"" << (int) ThirdPos << "\" " << "LabelDistance=\"" << LabelDistance << "\" " << "LabelPosition=\"" << LabelPosition << "\" " - << "IsDriving=\"" << (int)isDriving << "\" />" - + << "IsDriving=\"" << (int)isDriving << "\" " + << "IsInVirtualSpace=\"" << (int)isInVirtualSpace << "\" />" + << std::endl; } @@ -224,4 +228,7 @@ void Constraint::Restore(XMLReader &reader) if (reader.hasAttribute("IsDriving")) isDriving = reader.getAttributeAsInteger("IsDriving") ? true : false; + + if (reader.hasAttribute("IsInVirtualSpace")) + isInVirtualSpace = reader.getAttributeAsInteger("IsInVirtualSpace") ? true : false; } diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index a3898c1a9a..1714130e52 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -122,6 +122,7 @@ public: float LabelPosition; bool isDriving; int InternalAlignmentIndex; // Note: for InternalAlignment Type this index indexes equal internal geometry elements (e.g. index of pole in a bspline). It is not a GeoId!! + bool isInVirtualSpace; protected: boost::uuids::uuid tag;