Salome HOME
Make attributes may be defined as not-arguments: if they don't make result updated
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 24 Jul 2014 06:22:52 +0000 (10:22 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 24 Jul 2014 06:22:52 +0000 (10:22 +0400)
src/ConstructionPlugin/point_widget.xml
src/Model/Model_Data.cpp
src/ModelAPI/ModelAPI_Attribute.h

index 35397224fd39560d15d452003f5c72c4e8d6cae4..c39b43ad0d4d6a25373c06488f363b4fdcb7a149 100644 (file)
@@ -1,6 +1,6 @@
 <source>
   <doublevalue id="x" label="X:" max="50" step="1.0" default="0" icon=":pictures/x_point.png" tooltip="Set X">
-    <validator id="between" parameters="a,b"/
+    <!-- validator id="between" parameters="a,b"/ --
   </doublevalue>
   <doublevalue id="y" label="Y:" min="x" default="1" icon=":pictures/y_point.png" tooltip="Set Y"/>
   <doublevalue id="z" label="Z:" min="-20" step="0.1" default="2" icon=":pictures/z_point.png" tooltip="Set Z"/>
index 9cd9d082cedb5969b7e95ba9163409ee48591705..e08e565bd5274c0e02cf9083ea1f91d81535f3de 100644 (file)
@@ -49,10 +49,11 @@ void Model_Data::setName(string theName)
     if (isModified)
       aName->Set(theName.c_str());
   }
-  if (isModified) {
+  // to do not cause the update of the result on name change
+  /*if (isModified) {
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
     ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
-  }
+  }*/
 }
 
 void Model_Data::addAttribute(string theID, string theAttrType)
@@ -224,6 +225,8 @@ list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string
 void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
 {
   theAttr->setInitialized();
-  static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
-  ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+  if (theAttr->isArgument()) {
+    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+    ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+  }
 }
index 55cbb7cfd9c1d8fc82b2c3ee3ccff5980db91c46..7ea04aa8e16e145d5482d6720ea2473daadbf432 100644 (file)
@@ -21,6 +21,7 @@ class ModelAPI_Attribute
   boost::shared_ptr<ModelAPI_Object> myObject;
 protected: // accessible from the attributes
   bool myIsInitialized;
+  bool myIsArgument;
 public:
   
   /// Returns the type of this class of attributes, not static method
@@ -43,9 +44,16 @@ public:
   /// Makes attribute initialized
   MODELAPI_EXPORT void setInitialized() {myIsInitialized = true;}
 
+  /// Set this attribute is argument for result (change of this attribute requires update of result).
+  /// By default it is true.
+  MODELAPI_EXPORT void setIsArgument(const bool theFlag) {myIsArgument = theFlag;}
+
+  /// Returns true if attribute causes the result change
+  MODELAPI_EXPORT bool isArgument() {return myIsArgument;}
+
 protected:
   /// Objects are created for features automatically
-  ModelAPI_Attribute() {myIsInitialized = false;}
+  ModelAPI_Attribute() {myIsInitialized = false; myIsArgument = true;}
 
 };