1 // File: ModelAPI_Events.h
2 // Created: 10 Apr 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Events_HeaderFile
6 #define ModelAPI_Events_HeaderFile
9 #include <Events_MessageGroup.h>
10 #include <boost/shared_ptr.hpp>
14 #include "ModelAPI_Feature.h"
16 class ModelAPI_Document;
18 /// Event ID that feature is created (comes with ModelAPI_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 ModelAPI_FeatureUpdatedMessage)
25 static const char * EVENT_FEATURE_MOVED = "FeaturesMoved";
26 /// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage)
27 static const char * EVENT_FEATURE_TO_REDISPLAY = "FeaturesToRedisplay";
29 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
30 class ModelAPI_FeatureUpdatedMessage : public Events_MessageGroup {
32 ModelAPI_FeatureUpdatedMessage(const Events_ID theID, const void* theSender = 0)
33 : Events_MessageGroup(theID, theSender) {}
36 /// Returns the feature that has been updated
37 virtual std::set<FeaturePtr> features() const = 0;
39 //! Creates a new empty group (to store it in the loop before flush)
40 virtual Events_MessageGroup* newEmpty() = 0;
42 //! Allows to join the given message with the current one
43 virtual void Join(Events_MessageGroup& theJoined) = 0;
46 /// Message that feature was deleted (used for Object Browser update)
47 class ModelAPI_FeatureDeletedMessage : public Events_MessageGroup {
49 ModelAPI_FeatureDeletedMessage(const Events_ID theID, const void* theSender = 0)
50 : Events_MessageGroup(theID, theSender) {}
53 /// Returns the feature that has been updated
54 virtual boost::shared_ptr<ModelAPI_Document> document() const = 0;
56 /// Returns the group where the feature was deleted
57 virtual const std::set<std::string >& groups() const = 0;
59 virtual Events_MessageGroup* newEmpty() = 0;
61 virtual const Events_ID messageId() = 0;
63 virtual void Join(Events_MessageGroup& theJoined) = 0;
66 /// Allows to create ModelAPI messages
67 class MODELAPI_EXPORT ModelAPI_EventCreator {
69 /// creates created, updated or moved messages and sends to the loop
70 virtual void sendUpdated(const FeaturePtr& theFeature, const Events_ID& theEvent,
71 const bool isGroupped = true) const = 0;
72 /// creates deleted message and sends to the loop
73 virtual void sendDeleted(
74 const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup) const = 0;
76 /// returns the creator instance
77 static const ModelAPI_EventCreator* get();
79 /// sets the creator instance
80 static void set(const ModelAPI_EventCreator* theCreator);