]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Feature-changed message
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 7 Apr 2014 12:09:57 +0000 (16:09 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 7 Apr 2014 12:09:57 +0000 (16:09 +0400)
src/Event/Event_Message.cxx
src/Event/Event_Message.h
src/Model/Model_Document.cxx
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Feature.h

index ecf88a1e89c2085da5409a3c846799b165877ebc..764ed826f66fda4ffd1f935d367fe09b3aad83cb 100644 (file)
@@ -3,8 +3,3 @@
 // Author:     Mikhail PONIKAROV
 
 #include <Event_Message.h>
-
-Event_Message::Event_Message(const Event_ID theID, const void* theSender)
-    : myEventId(theID), mySender((void*) theSender)
-{
-}
index 6c851815c65372c0d3042e2e134a9ea8e2dc45ab..e07621af75f692e7045c558d065d88706bbd7164 100644 (file)
@@ -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
index 075866f567121d1bcb07be0a8586af216cecb0d6..7c2077cb91c95d51c678da3e154a80f661ab96fb 100644 (file)
@@ -178,9 +178,9 @@ void Model_Document::addFeature(const std::shared_ptr<ModelAPI_Feature> 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<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
@@ -278,3 +278,20 @@ void Model_Document::setUniqueName(
 
   theFeature->data()->setName(aName);
 }
+
+
+ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
+  shared_ptr<ModelAPI_Feature> 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_Feature> ModelAPI_FeatureUpdatedMessage::feature()
+{
+  return myFeature;
+}
index a69d969ba0e9d8eb5a2a4d1b4f4a7b73ffe2a1e7..6dd9e4396c0e8b57c06c307739fdecf28cea9682 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <Model.h>
 #include <ModelAPI_Document.h>
+#include <Event_Message.h>
+
 #include <TDocStd_Document.hxx>
 #include <map>
 
@@ -112,4 +114,21 @@ private:
   std::vector<std::string> 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<ModelAPI_Feature> myFeature; ///< which feature is changed
+public:
+  /// sender is not important, all information is located in the feature
+  ModelAPI_FeatureUpdatedMessage(std::shared_ptr<ModelAPI_Feature> theFeature);
+
+  /// Returns the ID of this message
+  static const Event_ID messageId();
+
+  /// Returns the feature that has been updated
+  std::shared_ptr<ModelAPI_Feature> feature();
+};
+
 #endif
index 6002e905cb39ecf2b30ca3e0a9ee2051d421a882..50209d63ebfcbfecb31510da7dcc579b4ad11a11 100644 (file)
@@ -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.
index 5690933e669a24eafd4fd669390a6d146362d45c..fd19221b0b246c4223ec5f9eec5bac5eadb27d8c 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "ModelAPI.h"
 #include "ModelAPI_PluginManager.h"
+
 #include <string>
 #include <memory>
 
@@ -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<ModelAPI_Object> myData; ///< manager of the data model of a feature