Salome HOME
Issue #1015: The validate icon must be greyed and inactive instead of red and active
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_WORKSHOP_LISTENER_H
4 #define XGUI_WORKSHOP_LISTENER_H
5
6 #include "XGUI.h"
7 #include <Events_Listener.h>
8 #include <Events_Message.h>
9
10 #include <ModelAPI_Feature.h>
11
12 #include <QObject>
13
14 class Config_FeatureMessage;
15
16 class ModelAPI_ObjectUpdatedMessage;
17 class XGUI_Workshop;
18
19 class ModuleBase_IWorkshop;
20
21 class QString;
22
23 /**\class XGUI_WorkshopListener
24  * \ingroup GUI
25  * \brief Class which process the events from the event loop.
26  */
27 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
28 {
29   Q_OBJECT
30 public:
31   /// Constructor. Used only if the workshop is launched in Salome environment
32   /// \param theWorkshop a reference to workshop. 
33    XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop);
34   virtual ~XGUI_WorkshopListener();
35
36   /// Register this class in the events loop for several types of events
37   void initializeEventListening();
38
39   //! Redefinition of Events_Listener method
40   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
41
42 signals:
43   /// Emitted when error in applivation happens
44   void errorOccurred(const QString&);
45
46 protected:
47   /// Procedure to process postponed events
48   bool event(QEvent * theEvent);
49
50   /// Process feature update message
51   /// \param theMsg a message with a container of objects
52   void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
53
54   /// Process feature created message
55   /// \param theMsg a message with a container of objects
56   void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
57
58   /// Process feature redisplay message
59   /// \param theMsg a message with a container of objects
60   void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
61
62   /// Process clearing of presentation
63   /// \param theMsg an event message
64   void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
65
66   /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
67   /// Asks the module whether the object can be displayed
68   /// \param theObj an object
69   /// \param theFirstVisualizedBody an output state whether there are not object displayed in the view
70   /// and the displayed object is a body
71   /// \return true if the object is displayed
72   bool displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody);
73
74   /// Calls the module method of cusomize object for the feature of the current operation
75   /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
76   /// current operation feature
77   /// \param theObjects a list of objects to find current operation feature if forced redisplay is false
78   /// \param theForceRedisplay a flag to customize object even always
79   /// \return true if the object is modified
80   bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
81
82   /// Returns the workshop
83   XGUI_Workshop* workshop() const;
84
85 private:
86   ModuleBase_IWorkshop* myWorkshop; // the current workshop
87
88   bool myUpdatePrefs;
89 };
90
91 #endif