Salome HOME
updated copyright message
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.h
1 // Copyright (C) 2014-2023  CEA, EDF
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
18 //
19
20 #ifndef XGUI_WORKSHOP_LISTENER_H
21 #define XGUI_WORKSHOP_LISTENER_H
22
23 #include "XGUI.h"
24 #include <Events_Listener.h>
25 #include <Events_Message.h>
26
27 #include <ModelAPI_Feature.h>
28 #include <Events_InfoMessage.h>
29
30 #include <QObject>
31
32 class Config_FeatureMessage;
33
34 class ModelAPI_ObjectUpdatedMessage;
35 class XGUI_Workshop;
36
37 class ModuleBase_IWorkshop;
38
39 class QString;
40 class Events_InfoMessage;
41
42 /**\class XGUI_WorkshopListener
43  * \ingroup GUI
44  * \brief Class which process the events from the event loop.
45  */
46 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
47 {
48   Q_OBJECT
49 public:
50   /// Constructor. Used only if the workshop is launched in Salome environment
51   /// \param theWorkshop a reference to workshop.
52    XGUI_WorkshopListener(XGUI_Workshop* theWorkshop);
53   virtual ~XGUI_WorkshopListener();
54
55   /// Register this class in the events loop for several types of events
56   void initializeEventListening();
57
58   //! Redefinition of Events_Listener method
59   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
60
61 signals:
62   /// Emitted when error in applivation happens
63   void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
64
65 protected:
66   /// Procedure to process postponed events
67   bool event(QEvent * theEvent);
68
69   /// Process feature update message
70   /// \param theMsg a message with a container of objects
71   void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
72
73   /// Process feature created message
74   /// \param theMsg a message with a container of objects
75   void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
76
77   /// Process feature redisplay message
78   /// \param theMsg a message with a container of objects
79   void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
80
81   /// Process clearing of presentation
82   /// \param theMsg an event message
83   void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
84
85   /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
86   /// Asks the module whether the object can be displayed
87   /// \param theObj an object
88   /// \param theFirstVisualizedBody an output state whether there are not object displayed in the
89   /// view and the displayed object is a body
90   /// \return true if the object is displayed
91   bool displayObject(ObjectPtr theObj);
92
93   /// Calls the module method of cusomize object for the feature of the current operation
94   /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
95   /// current operation feature
96   /// \param theObjects a list of objects to find current operation feature
97   ///                   if forced redisplay is false
98   /// \param theForceRedisplay a flag to customize object even always
99   /// \return true if the object is modified
100   bool customizeFeature(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
101
102   /// Returns the workshop
103   XGUI_Workshop* workshop() const;
104
105 private:
106
107   void setDisplayed(ObjectPtr theObject, const bool theIsLoadedScript, bool& theDisplayed);
108
109   XGUI_Workshop* myWorkshop; // the current workshop
110
111   bool myUpdatePrefs;
112 };
113
114 #endif