]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Immutable property of the attribute added.
authorsbh <sergey.belash@opencascade.com>
Wed, 8 Oct 2014 13:19:16 +0000 (17:19 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 8 Oct 2014 13:19:16 +0000 (17:19 +0400)
src/ModelAPI/ModelAPI_Attribute.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp

index c54b395561b908739737abb7ba47674b92e11f43..cfef5172421791a08ebd6958ca018a3000be1378 100644 (file)
@@ -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;
   }
 
 };
index c6d341d002134e20b5c797013e147e080c3fb4c4..5b2f24a14c2c8de452d76cc21c6ebfef03f8d21b 100644 (file)
@@ -108,11 +108,18 @@ bool ModuleBase_WidgetPoint2D::storeValue() const
   boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       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<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       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());