Salome HOME
Issue #1860: fix end lines with spaces
[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 #include <Events_InfoMessage.h>
12
13 #include <QObject>
14
15 class Config_FeatureMessage;
16
17 class ModelAPI_ObjectUpdatedMessage;
18 class XGUI_Workshop;
19
20 class ModuleBase_IWorkshop;
21
22 class QString;
23 class Events_InfoMessage;
24
25 /**\class XGUI_WorkshopListener
26  * \ingroup GUI
27  * \brief Class which process the events from the event loop.
28  */
29 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
30 {
31   Q_OBJECT
32 public:
33   /// Constructor. Used only if the workshop is launched in Salome environment
34   /// \param theWorkshop a reference to workshop.
35    XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop);
36   virtual ~XGUI_WorkshopListener();
37
38   /// Register this class in the events loop for several types of events
39   void initializeEventListening();
40
41   //! Redefinition of Events_Listener method
42   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
43
44 signals:
45   /// Emitted when error in applivation happens
46   void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
47
48 protected:
49   /// Procedure to process postponed events
50   bool event(QEvent * theEvent);
51
52   /// Process feature update message
53   /// \param theMsg a message with a container of objects
54   void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
55
56   /// Process feature created message
57   /// \param theMsg a message with a container of objects
58   void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
59
60   /// Process feature redisplay message
61   /// \param theMsg a message with a container of objects
62   void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
63
64   /// Process clearing of presentation
65   /// \param theMsg an event message
66   void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
67
68   /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
69   /// Asks the module whether the object can be displayed
70   /// \param theObj an object
71   /// \param theFirstVisualizedBody an output state whether there are not object displayed in the
72   /// view and the displayed object is a body
73   /// \return true if the object is displayed
74   bool displayObject(ObjectPtr theObj);
75
76   /// Answer if the viewer needed to be fit all after the object visualization
77   /// The condition is there is not shown objects and the object is a group or body result
78   /// \param theObject a shown object
79   /// \param theNbOfShownObjects a count of already shown objects in the viewer
80   /// \return true if fit all should be done
81   bool neededFitAll(ObjectPtr theObject, const int theNbOfShownObjects);
82
83   /// Calls the module method of cusomize object for the feature of the current operation
84   /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
85   /// current operation feature
86   /// \param theObjects a list of objects to find current operation feature
87   ///                   if forced redisplay is false
88   /// \param theForceRedisplay a flag to customize object even always
89   /// \return true if the object is modified
90   bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
91
92   /// Returns the workshop
93   XGUI_Workshop* workshop() const;
94
95 private:
96   ModuleBase_IWorkshop* myWorkshop; // the current workshop
97
98   bool myUpdatePrefs;
99 };
100
101 #endif