Salome HOME
Issue #948 Wrong display after Sketch edition
[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
32   /// \param theConnector a Salome connector object. 
33   /// Used only if the workshop is launched in Salome environment
34    XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop);
35   virtual ~XGUI_WorkshopListener();
36
37   /// Register this class in the events loop for several types of events
38   void initializeEventListening();
39
40   //! Redefinition of Events_Listener method
41   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
42
43 signals:
44   /// Emitted when error in applivation happens
45   void errorOccurred(const QString&);
46
47 protected slots:
48   /// Updates Apply All button state of the feature to the state if the feature has the button
49   /// \param theFeatureId an index of the feature, the action is searched, which state is to be changed
50   /// \param theState an action enable state
51   //void onNestedStateChanged(const std::string& theFeatureId, const bool theState);
52
53 protected:
54   /// Procedure to process postponed events
55   bool event(QEvent * theEvent);
56
57    /// Process event "Add a feature"
58   void addFeature(const std::shared_ptr<Config_FeatureMessage>&);
59
60   /// Process feature update message
61   void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );
62
63   /// Process feature created message
64   void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );
65
66   /// Process feature redisplay message
67   void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );
68
69   /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
70   /// Asks the module whether the object can be displayed
71   /// \param theObj an object
72   /// \param theFirstVisualizedBody an output state whether there are not object displayed in the view
73   /// and the displayed object is a body
74   /// \return true if the object is displayed
75   bool displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody);
76
77   /// Calls the module method of cusomize object for the feature of the current operation
78   /// \return true if the object is modified
79   bool customizeCurrentObject();
80
81   /// Returns the workshop
82   XGUI_Workshop* workshop() const;
83
84 private:
85   ModuleBase_IWorkshop* myWorkshop; // the current workshop
86
87   bool myUpdatePrefs;
88 };
89
90 #endif