Salome HOME
Fix for #2389 - sketch points selected that are located not on sketch compound of...
[modules/shaper.git] / src / ModelAPI / ModelAPI_EventReentrantMessage.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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModelAPI_EventReentrantMessage_H_
22 #define ModelAPI_EventReentrantMessage_H_
23
24 #include <Events_Message.h>
25 #include <Events_Loop.h>
26
27 #include <ModelAPI.h>
28
29 #include <memory>
30
31 class ModelAPI_Object;
32 class ModelAPI_Feature;
33 class ModelAPI_Attribute;
34 class GeomAPI_Pnt2d;
35
36 /// Message that style of visualization of parameter is changed.
37 /// It will be shown as expression or value
38 class ModelAPI_EventReentrantMessage : public Events_Message
39 {
40 public:
41   /// Creates an empty message
42   MODELAPI_EXPORT ModelAPI_EventReentrantMessage(const Events_ID theID,
43                                                  const void* theSender);
44   /// The virtual destructor
45   MODELAPI_EXPORT virtual ~ModelAPI_EventReentrantMessage() {}
46   /// Static. Returns EventID of the message.
47   MODELAPI_EXPORT static Events_ID eventId()
48   {
49     static const char * MY_EVENT_REENTRANT_MESSAGE_ID("EventReentrantMessage");
50     return Events_Loop::eventByName(MY_EVENT_REENTRANT_MESSAGE_ID);
51   }
52
53   /// Fills previous feature parameter
54   MODELAPI_EXPORT void setCreatedFeature(const std::shared_ptr<ModelAPI_Feature>& theFeature)
55   { myCreatedFeature = theFeature; }
56
57   /// Returns previous feature parameter
58   MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Feature>& createdFeature() const
59   { return myCreatedFeature; }
60
61   /// Fills selected object parameter
62   /// \theObject a feature or result
63   MODELAPI_EXPORT void setSelectedObject(const std::shared_ptr<ModelAPI_Object>& theObject)
64   { mySelectedObject = theObject; }
65
66   /// Returns selected object parameter
67   MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& selectedObject() const
68   { return mySelectedObject; }
69
70   /// Fills selected attribute parameter
71   /// \theAttribute
72   MODELAPI_EXPORT void setSelectedAttribute
73                                   (const std::shared_ptr<ModelAPI_Attribute>& theAttribute)
74   { mySelectedAttribute = theAttribute; }
75
76   /// Returns selected attribute parameter
77   MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Attribute>& selectedAttribute()
78   { return mySelectedAttribute; }
79
80   /// Fills clicked point
81   /// \thePoint
82   MODELAPI_EXPORT void setClickedPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
83   { myClickedPoint = thePoint; }
84
85   /// Returns clicked point
86   MODELAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt2d>& clickedPoint()
87   { return myClickedPoint; }
88
89 private:
90   std::shared_ptr<ModelAPI_Feature> myCreatedFeature; ///< previous object
91   std::shared_ptr<ModelAPI_Object> mySelectedObject; ///< selected object
92   std::shared_ptr<ModelAPI_Attribute> mySelectedAttribute; ///< selected attribute
93   std::shared_ptr<GeomAPI_Pnt2d> myClickedPoint; ///< clicked point
94 };
95
96 typedef std::shared_ptr<ModelAPI_EventReentrantMessage> ReentrantMessagePtr;
97
98
99 #endif