1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef Model_Events_H_
21 #define Model_Events_H_
24 #include <ModelAPI_Events.h>
28 /// Allows to create ModelAPI messages
29 class Model_EventCreator : public ModelAPI_EventCreator
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;
36 /// creates created, updated or moved messages with the objects collection and sends to the loop
37 virtual void sendUpdated(const std::list<ObjectPtr>& theObjects, const Events_ID& theEvent,
38 const bool isGroupped = true) const;
39 /// creates deleted message and sends to the loop
40 virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
41 const std::string& theGroup) const;
43 /// creates reordered message and sends to the loop
44 virtual void sendReordered(const std::shared_ptr<ModelAPI_Feature>& theReordered) const;
46 /// must be one per application, the constructor for internal usage only
50 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
51 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
53 std::set<ObjectPtr> myObjects; ///< which feature is changed
55 /// Sender is not important, all information is located in the feature.
56 /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
57 Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent);
59 friend class Model_EventCreator;
62 /// Returns the feature that has been updated
63 virtual const std::set<ObjectPtr>& objects() const;
65 //! Creates a new empty group (to store it in the loop before flush)
66 virtual std::shared_ptr<Events_MessageGroup> newEmpty();
68 //! Allows to join the given message with the current one
69 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
72 /// Message that feature was deleted (used for Object Browser update)
73 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
75 ///< group identifiers that contained the deleted feature and document where they are deleted
76 std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> > myGroups;
78 /// Use ModelAPI for creation of this event.
79 Model_ObjectDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
80 const std::string& theGroup);
82 friend class Model_EventCreator;
84 /// Returns the group where the objects were deleted
85 virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
91 /// Returns the new empty message of this type
92 virtual std::shared_ptr<Events_MessageGroup> newEmpty();
94 /// Returns the identifier of this message
95 virtual const Events_ID messageId();
97 /// Appends to this message the given one
98 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
101 /// Message that feature was deleted (used for Object Browser update)
102 class Model_OrderUpdatedMessage : public ModelAPI_OrderUpdatedMessage
104 std::shared_ptr<ModelAPI_Feature> myReordered; ///< the feature that was moved
106 /// Use ModelAPI for creation of this event.
107 Model_OrderUpdatedMessage(FeaturePtr theReordered,
108 const void* theSender = 0);
110 friend class Model_EventCreator;
112 /// Returns the document that has been updated
113 virtual std::shared_ptr<ModelAPI_Feature> reordered()
118 /// Returns the identifier of this message
119 virtual const Events_ID messageId();