From 81e193864ca010d24d9dd256a19951c37a64fadb Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 7 Apr 2014 16:09:57 +0400 Subject: [PATCH] Feature-changed message --- src/Event/Event_Message.cxx | 5 ----- src/Event/Event_Message.h | 4 +++- src/Model/Model_Document.cxx | 23 ++++++++++++++++++++--- src/Model/Model_Document.h | 19 +++++++++++++++++++ src/ModelAPI/ModelAPI_Document.h | 3 --- src/ModelAPI/ModelAPI_Feature.h | 2 +- 6 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/Event/Event_Message.cxx b/src/Event/Event_Message.cxx index ecf88a1e8..764ed826f 100644 --- a/src/Event/Event_Message.cxx +++ b/src/Event/Event_Message.cxx @@ -3,8 +3,3 @@ // Author: Mikhail PONIKAROV #include - -Event_Message::Event_Message(const Event_ID theID, const void* theSender) - : myEventId(theID), mySender((void*) theSender) -{ -} diff --git a/src/Event/Event_Message.h b/src/Event/Event_Message.h index 6c851815c..e07621af7 100644 --- a/src/Event/Event_Message.h +++ b/src/Event/Event_Message.h @@ -42,7 +42,9 @@ class EVENT_EXPORT Event_Message { public: //! Creates the message - Event_Message(const Event_ID theID, const void* theSender = 0); + Event_Message(const Event_ID theID, const void* theSender = 0) + : myEventId(theID), mySender((void*) theSender) {} + //! do nothing in the destructor yet virtual ~Event_Message() {} //! Returns identifier of the message diff --git a/src/Model/Model_Document.cxx b/src/Model/Model_Document.cxx index 075866f56..7c2077cb9 100644 --- a/src/Model/Model_Document.cxx +++ b/src/Model/Model_Document.cxx @@ -178,9 +178,9 @@ void Model_Document::addFeature(const std::shared_ptr theFeatu TDataStd_Comment::Set(anObjLab, theFeature->getKind().c_str()); // event: model is updated - static Event_ID anEvent = Event_Loop::eventByName(EVENT_MODEL_UPDATED); - Event_Message anUpdateMsg(anEvent, this); - Event_Loop::loop()->send(anUpdateMsg); + static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_UPDATED); + ModelAPI_FeatureUpdatedMessage aMsg(theFeature); + Event_Loop::loop()->send(aMsg); } shared_ptr Model_Document::feature(TDF_Label& theLabel) @@ -278,3 +278,20 @@ void Model_Document::setUniqueName( theFeature->data()->setName(aName); } + + +ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage( + shared_ptr theFeature) + : Event_Message(messageId(), 0), myFeature(theFeature) +{} + +const Event_ID ModelAPI_FeatureUpdatedMessage::messageId() +{ + static Event_ID MY_ID = Event_Loop::eventByName("FeatureUpdated"); + return MY_ID; +} + +shared_ptr ModelAPI_FeatureUpdatedMessage::feature() +{ + return myFeature; +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index a69d969ba..6dd9e4396 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -112,4 +114,21 @@ private: std::vector myGroupsNames; ///< names of added groups to the document }; +/// Event ID that model is updated +static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated"; + +/// Message that feature was changed (used for Object Browser update) +class ModelAPI_FeatureUpdatedMessage : public Event_Message { + std::shared_ptr myFeature; ///< which feature is changed +public: + /// sender is not important, all information is located in the feature + ModelAPI_FeatureUpdatedMessage(std::shared_ptr theFeature); + + /// Returns the ID of this message + static const Event_ID messageId(); + + /// Returns the feature that has been updated + std::shared_ptr feature(); +}; + #endif diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 6002e905c..50209d63e 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -21,9 +21,6 @@ static const std::string CONSTRUCTIONS_GROUP = "Construction"; /// Group of parts static const std::string PARTS_GROUP = "Parts"; -/// Event ID that model is updated -static const char * EVENT_MODEL_UPDATED = "ModelUpdated"; - /**\class Model_Document * \ingroup DataModel * \brief Document for internal data structure of any object storage. Corresponds to the SALOME study. diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 5690933e6..fd19221b0 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -7,6 +7,7 @@ #include "ModelAPI.h" #include "ModelAPI_PluginManager.h" + #include #include @@ -18,7 +19,6 @@ class ModelAPI_Document; * \brief Functionality of the model object: to update result, * to initialize attributes, etc. */ - class MODELAPI_EXPORT ModelAPI_Feature { std::shared_ptr myData; ///< manager of the data model of a feature -- 2.39.2