From 2e864970eb133d1a389a7ba0e42bbd6248497aad Mon Sep 17 00:00:00 2001 From: sbh Date: Wed, 8 Oct 2014 17:19:16 +0400 Subject: [PATCH] Immutable property of the attribute added. --- src/ModelAPI/ModelAPI_Attribute.h | 19 +++++++++++++++++++ src/ModuleBase/ModuleBase_WidgetPoint2D.cpp | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index c54b39556..cfef51724 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -23,6 +23,8 @@ class ModelAPI_Attribute // accessible from the attributes bool myIsInitialized; bool myIsArgument; + bool myIsImmutable; + public: /// Returns the type of this class of attributes, not static method @@ -70,12 +72,29 @@ class ModelAPI_Attribute return myIsArgument; } + /// Immutable argument can not be changed programaticaly (e.g. by constraint) + /// By default it is false. + /// Returns the previous state of the attribute's immutability. + MODELAPI_EXPORT bool setImmutable(const bool theFlag) + { + bool aResult = myIsImmutable; + myIsImmutable = theFlag; + return aResult; + } + + /// Returns true if can not be changed programaticaly + MODELAPI_EXPORT bool isImmutable() + { + return myIsImmutable; + } + protected: /// Objects are created for features automatically ModelAPI_Attribute() { myIsInitialized = false; myIsArgument = true; + myIsImmutable = false; } }; diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index c6d341d00..5b2f24a14 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -108,11 +108,18 @@ bool ModuleBase_WidgetPoint2D::storeValue() const boost::shared_ptr aData = myFeature->data(); boost::shared_ptr aPoint = boost::dynamic_pointer_cast( aData->attribute(attributeID())); - + ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this; bool isBlocked = that->blockSignals(true); + bool isImmutable = aPoint->setImmutable(true); +#ifdef _DEBUG + std::string _attr_name = myAttributeID; + double _X = myXSpin->value(); + double _Y = myYSpin->value(); +#endif aPoint->setValue(myXSpin->value(), myYSpin->value()); updateObject(myFeature); + aPoint->setImmutable(isImmutable); that->blockSignals(isBlocked); return true; @@ -124,6 +131,11 @@ bool ModuleBase_WidgetPoint2D::restoreValue() boost::shared_ptr aPoint = boost::dynamic_pointer_cast( aData->attribute(attributeID())); +#ifdef _DEBUG + std::string _attr_name = myAttributeID; + double _X = aPoint->x(); + double _Y = aPoint->y(); +#endif bool isBlocked = this->blockSignals(true); myXSpin->setValue(aPoint->x()); myYSpin->setValue(aPoint->y()); -- 2.39.2