Salome HOME
No automatic rebuild: only on preview. Update of visualization behavior due to the...
[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_H_
6 #define Model_Events_H_
7
8 #include <Model.h>
9 #include <ModelAPI_Events.h>
10
11 /// Allovs to create ModelAPI messages
12 class Model_EventCreator : public ModelAPI_EventCreator
13 {
14  public:
15   /// creates created, updated or moved messages and sends to the loop
16   virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
17                            const bool isGroupped = true) const;
18   /// creates deleted message and sends to the loop
19   virtual void sendDeleted(const boost::shared_ptr<ModelAPI_Document>& theDoc,
20                            const std::string& theGroup) const;
21
22   /// must be one per application, the constructor for internal usage only
23   Model_EventCreator();
24 };
25
26 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
27 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
28 {
29   std::set<ObjectPtr> myObjects;  ///< which feature is changed
30
31   /// Sender is not important, all information is located in the feature.
32   /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
33   Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent);
34
35   friend class Model_EventCreator;
36  public:
37
38   /// Returns the feature that has been updated
39   virtual const std::set<ObjectPtr>& objects() const;
40
41   //! Creates a new empty group (to store it in the loop before flush)
42   virtual boost::shared_ptr<Events_MessageGroup> newEmpty();
43
44   //! Allows to join the given message with the current one
45   virtual void Join(const boost::shared_ptr<Events_MessageGroup>& theJoined);
46 };
47
48 /// Message that feature was deleted (used for Object Browser update)
49 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
50 {
51   boost::shared_ptr<ModelAPI_Document> myDoc;  ///< document owner of the feature
52   std::set<std::string> myGroups;  ///< group identifiers that contained the deleted feature
53
54   /// Use ModelAPI for creation of this event.
55   Model_ObjectDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
56                              const std::string& theGroup);
57
58   friend class Model_EventCreator;
59  public:
60   /// Returns the feature that has been updated
61   virtual boost::shared_ptr<ModelAPI_Document> document() const
62   {
63     return myDoc;
64   }
65
66   /// Returns the group where the feature was deleted
67   virtual const std::set<std::string>& groups() const
68   {
69     return myGroups;
70   }
71
72   virtual boost::shared_ptr<Events_MessageGroup> newEmpty();
73
74   virtual const Events_ID messageId();
75
76   virtual void Join(const boost::shared_ptr<Events_MessageGroup>& theJoined);
77 };
78
79 #endif