1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_WORKSHOP_LISTENER_H
4 #define XGUI_WORKSHOP_LISTENER_H
7 #include <Events_Listener.h>
8 #include <Events_Message.h>
10 #include <ModelAPI_Feature.h>
11 #include <Events_InfoMessage.h>
15 class Config_FeatureMessage;
17 class ModelAPI_ObjectUpdatedMessage;
20 class ModuleBase_IWorkshop;
23 class Events_InfoMessage;
25 /**\class XGUI_WorkshopListener
27 * \brief Class which process the events from the event loop.
29 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
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();
38 /// Register this class in the events loop for several types of events
39 void initializeEventListening();
41 //! Redefinition of Events_Listener method
42 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
45 /// Emitted when error in applivation happens
46 void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
49 /// Procedure to process postponed events
50 bool event(QEvent * theEvent);
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);
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);
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);
64 /// Process clearing of presentation
65 /// \param theMsg an event message
66 void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
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 view
72 /// and the displayed object is a body
73 /// \return true if the object is displayed
74 bool displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody);
76 /// Calls the module method of cusomize object for the feature of the current operation
77 /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
78 /// current operation feature
79 /// \param theObjects a list of objects to find current operation feature if forced redisplay is false
80 /// \param theForceRedisplay a flag to customize object even always
81 /// \return true if the object is modified
82 bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
84 /// Returns the workshop
85 XGUI_Workshop* workshop() const;
88 ModuleBase_IWorkshop* myWorkshop; // the current workshop