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
72 /// view and the displayed object is a body
73 /// \return true if the object is displayed
74 bool displayObject(ObjectPtr theObj);
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);
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);
92 /// Returns the workshop
93 XGUI_Workshop* workshop() const;
96 ModuleBase_IWorkshop* myWorkshop; // the current workshop