1 // File: Model_Events.h
2 // Created: 10 Apr 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_Events_HeaderFile
6 #define Model_Events_HeaderFile
9 #include <Events_Message.h>
10 #include <Events_Loop.h>
11 #include <boost/shared_ptr.hpp>
15 class ModelAPI_Feature;
16 class ModelAPI_Document;
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";
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
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)
37 /// Returns the feature that has been updated
38 boost::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
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
46 /// creates a message by initialization of fields
47 Model_FeatureDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
48 const std::string& theGroup);
50 /// Returns the ID of this message (EVENT_FEATURE_DELETED)
51 static const Events_ID messageId();
53 /// Returns the feature that has been updated
54 boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
56 /// Returns the group where the feature was deleted
57 const std::string& group() const {return myGroup;}
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
64 /// creates a message by initialization of fields
65 MODEL_EXPORT Model_FeaturesMovedMessage();
67 /// Returns the ID of this message (EVENT_FEATURES_MOVED)
68 static const Events_ID messageId();
70 /// Sets a list of features
71 MODEL_EXPORT void setFeatures(const std::list<boost::shared_ptr<ModelAPI_Feature> >& theFeatures);
73 /// Returns a list of features
74 MODEL_EXPORT const std::list<boost::shared_ptr<ModelAPI_Feature> >& features() const;