From 54501278b314fa0a78a2c49d82837b830dcf605c Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 24 Jul 2014 10:22:52 +0400 Subject: [PATCH] Make attributes may be defined as not-arguments: if they don't make result updated --- src/ConstructionPlugin/point_widget.xml | 2 +- src/Model/Model_Data.cpp | 11 +++++++---- src/ModelAPI/ModelAPI_Attribute.h | 10 +++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ConstructionPlugin/point_widget.xml b/src/ConstructionPlugin/point_widget.xml index 35397224f..c39b43ad0 100644 --- a/src/ConstructionPlugin/point_widget.xml +++ b/src/ConstructionPlugin/point_widget.xml @@ -1,6 +1,6 @@ - + diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 9cd9d082c..e08e565bd 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -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 > 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); + } } diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index 55cbb7cfd..7ea04aa8e 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -21,6 +21,7 @@ class ModelAPI_Attribute boost::shared_ptr 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;} }; -- 2.39.2