1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef XGUI_WORKSHOP_LISTENER_H
22 #define XGUI_WORKSHOP_LISTENER_H
25 #include <Events_Listener.h>
26 #include <Events_Message.h>
28 #include <ModelAPI_Feature.h>
29 #include <Events_InfoMessage.h>
33 class Config_FeatureMessage;
35 class ModelAPI_ObjectUpdatedMessage;
38 class ModuleBase_IWorkshop;
41 class Events_InfoMessage;
43 /**\class XGUI_WorkshopListener
45 * \brief Class which process the events from the event loop.
47 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
51 /// Constructor. Used only if the workshop is launched in Salome environment
52 /// \param theWorkshop a reference to workshop.
53 XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop);
54 virtual ~XGUI_WorkshopListener();
56 /// Register this class in the events loop for several types of events
57 void initializeEventListening();
59 //! Redefinition of Events_Listener method
60 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
63 /// Emitted when error in applivation happens
64 void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
67 /// Procedure to process postponed events
68 bool event(QEvent * theEvent);
70 /// Process feature update message
71 /// \param theMsg a message with a container of objects
72 void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
74 /// Process feature created message
75 /// \param theMsg a message with a container of objects
76 void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
78 /// Process feature redisplay message
79 /// \param theMsg a message with a container of objects
80 void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
82 /// Process clearing of presentation
83 /// \param theMsg an event message
84 void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
86 /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
87 /// Asks the module whether the object can be displayed
88 /// \param theObj an object
89 /// \param theFirstVisualizedBody an output state whether there are not object displayed in the
90 /// view and the displayed object is a body
91 /// \return true if the object is displayed
92 bool displayObject(ObjectPtr theObj);
94 /// Calls the module method of cusomize object for the feature of the current operation
95 /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
96 /// current operation feature
97 /// \param theObjects a list of objects to find current operation feature
98 /// if forced redisplay is false
99 /// \param theForceRedisplay a flag to customize object even always
100 /// \return true if the object is modified
101 bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
103 /// Returns the workshop
104 XGUI_Workshop* workshop() const;
107 ModuleBase_IWorkshop* myWorkshop; // the current workshop