]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_Events.h
Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / Model / Model_Events.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef Model_Events_H_
21 #define Model_Events_H_
22
23 #include <Model.h>
24 #include <ModelAPI_Events.h>
25
26 #include <memory>
27
28 /// Allovs to create ModelAPI messages
29 class Model_EventCreator : public ModelAPI_EventCreator
30 {
31  public:
32   /// creates created, updated or moved messages and sends to the loop
33   virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
34                            const bool isGroupped = true) const;
35   /// creates deleted message and sends to the loop
36   virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
37                            const std::string& theGroup) const;
38
39   /// creates reordered message and sends to the loop
40   virtual void sendReordered(const std::shared_ptr<ModelAPI_Feature>& theReordered) const;
41
42   /// must be one per application, the constructor for internal usage only
43   Model_EventCreator();
44 };
45
46 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
47 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
48 {
49   std::set<ObjectPtr> myObjects;  ///< which feature is changed
50
51   /// Sender is not important, all information is located in the feature.
52   /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
53   Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent);
54
55   friend class Model_EventCreator;
56  public:
57
58   /// Returns the feature that has been updated
59   virtual const std::set<ObjectPtr>& objects() const;
60
61   //! Creates a new empty group (to store it in the loop before flush)
62   virtual std::shared_ptr<Events_MessageGroup> newEmpty();
63
64   //! Allows to join the given message with the current one
65   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
66 };
67
68 /// Message that feature was deleted (used for Object Browser update)
69 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
70 {
71   std::shared_ptr<ModelAPI_Document> myDoc;  ///< document owner of the feature
72   std::set<std::string> myGroups;  ///< group identifiers that contained the deleted feature
73
74   /// Use ModelAPI for creation of this event.
75   Model_ObjectDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
76                              const std::string& theGroup);
77
78   friend class Model_EventCreator;
79  public:
80   /// Returns the document that has been updated
81   virtual std::shared_ptr<ModelAPI_Document> document() const
82   {
83     return myDoc;
84   }
85
86   /// Returns the group where the objects were deleted
87   virtual const std::set<std::string>& groups() const
88   {
89     return myGroups;
90   }
91
92   /// Returns the new empty message of this type
93   virtual std::shared_ptr<Events_MessageGroup> newEmpty();
94
95   /// Returns the identifier of this message
96   virtual const Events_ID messageId();
97
98   /// Appends to this message the given one
99   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
100 };
101
102 /// Message that feature was deleted (used for Object Browser update)
103 class Model_OrderUpdatedMessage : public ModelAPI_OrderUpdatedMessage
104 {
105   std::shared_ptr<ModelAPI_Feature> myReordered;  ///< the feature that was moved
106
107   /// Use ModelAPI for creation of this event.
108   Model_OrderUpdatedMessage(FeaturePtr theReordered,
109                             const void* theSender = 0);
110
111   friend class Model_EventCreator;
112  public:
113   /// Returns the document that has been updated
114   virtual std::shared_ptr<ModelAPI_Feature> reordered()
115   {
116     return myReordered;
117   }
118
119   /// Returns the identifier of this message
120   virtual const Events_ID messageId();
121 };
122
123 #endif