Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / Model / Model_Events.h
1 // File:        Model_Events.h
2 // Created:     10 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Events_HeaderFile
6 #define Model_Events_HeaderFile
7
8 #include <Model.h>
9 #include <Events_Message.h>
10 #include <Events_Loop.h>
11 #include <boost/shared_ptr.hpp>
12 #include <string>
13 #include <list>
14
15 class ModelAPI_Feature;
16 class ModelAPI_Document;
17
18 /// Event ID that feature is created (comes with Model_FeatureUpdatedMessage)
19 static const char * EVENT_FEATURE_CREATED = "FeatureCreated";
20 /// Event ID that data of feature is updated (comes with Model_FeatureUpdatedMessage)
21 static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
22 /// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage)
23 static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
24 /// Event ID that data of feature is updated (comes with Model_FeaturesMovedMessage)
25 static const char * EVENT_FEATURES_MOVED = "FeaturesMoved";
26
27 /// Message that feature was changed (used for Object Browser update)
28 class Model_FeatureUpdatedMessage : public Events_Message {
29   boost::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
30 public:
31   /// sender is not important, all information is located in the feature
32   Model_FeatureUpdatedMessage(
33     const boost::shared_ptr<ModelAPI_Feature>& theFeature,
34     const Events_ID& theEvent) : Events_Message(theEvent, 0), myFeature(theFeature)
35   {}
36
37   /// Returns the feature that has been updated
38   boost::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
39 };
40
41 /// Message that feature was deleted (used for Object Browser update)
42 class Model_FeatureDeletedMessage : public Events_Message {
43   boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
44   std::string myGroup; ///< group identifier that contained the deleted feature
45 public:
46   /// creates a message by initialization of fields
47   Model_FeatureDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
48     const std::string& theGroup);
49
50   /// Returns the ID of this message (EVENT_FEATURE_DELETED)
51   static const Events_ID messageId();
52
53   /// Returns the feature that has been updated
54   boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
55
56   /// Returns the group where the feature was deleted
57   const std::string& group() const {return myGroup;}
58 };
59
60 /// Message that features were moved (used for the feature preview update)
61 class Model_FeaturesMovedMessage : public Events_Message {
62   std::list<boost::shared_ptr<ModelAPI_Feature> > myFeatures; ///< which features are moved
63 public:
64   /// creates a message by initialization of fields
65   MODEL_EXPORT Model_FeaturesMovedMessage();
66
67   /// Returns the ID of this message (EVENT_FEATURES_MOVED)
68   static const Events_ID messageId();
69
70   /// Sets a list of features
71   MODEL_EXPORT void setFeatures(const std::list<boost::shared_ptr<ModelAPI_Feature> >& theFeatures);
72
73   /// Returns a list of features
74   MODEL_EXPORT const std::list<boost::shared_ptr<ModelAPI_Feature> >& features() const;
75 };
76
77 #endif