From 7cd3dd7dc4d2c701d3eab3cb8e3dc294adcd7e2d Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 22 Jun 2019 06:41:31 +0200 Subject: [PATCH] Sketcher: Extend Constraints to have an activated boolean state --- src/Mod/Sketcher/App/Constraint.cpp | 10 ++++++++-- src/Mod/Sketcher/App/Constraint.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 529eee011c..459448a4ed 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -60,7 +60,8 @@ Constraint::Constraint() LabelPosition(0.f), isDriving(true), InternalAlignmentIndex(-1), - isInVirtualSpace(false) + isInVirtualSpace(false), + isActive(true) { // Initialize a random number generator, to avoid Valgrind false positives. static boost::mt19937 ran; @@ -98,6 +99,7 @@ Constraint *Constraint::copy(void) const temp->isDriving = this->isDriving; temp->InternalAlignmentIndex = this->InternalAlignmentIndex; temp->isInVirtualSpace = this->isInVirtualSpace; + temp->isActive = this->isActive; // Do not copy tag, otherwise it is considered a clone, and a "rename" by the expression engine. return temp; } @@ -165,7 +167,8 @@ void Constraint::Save (Writer &writer) const << "LabelDistance=\"" << LabelDistance << "\" " << "LabelPosition=\"" << LabelPosition << "\" " << "IsDriving=\"" << (int)isDriving << "\" " - << "IsInVirtualSpace=\"" << (int)isInVirtualSpace << "\" />" + << "IsInVirtualSpace=\"" << (int)isInVirtualSpace << "\" " + << "IsActive=\"" << (int)isActive << "\" />" << std::endl; } @@ -209,4 +212,7 @@ void Constraint::Restore(XMLReader &reader) if (reader.hasAttribute("IsInVirtualSpace")) isInVirtualSpace = reader.getAttributeAsInteger("IsInVirtualSpace") ? true : false; + + if (reader.hasAttribute("IsActive")) + isActive = reader.getAttributeAsInteger("IsActive") ? true : false; } diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index cbeda2c22c..ed801958a8 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -143,6 +143,8 @@ public: 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; + bool isActive; + protected: boost::uuids::uuid tag; };