1 // Copyright (C) 2014-2023 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 email : webmaster.salome@opencascade.com
20 #ifndef XGUI_WORKSHOP_LISTENER_H
21 #define XGUI_WORKSHOP_LISTENER_H
24 #include <Events_Listener.h>
25 #include <Events_Message.h>
27 #include <ModelAPI_Feature.h>
28 #include <Events_InfoMessage.h>
32 class Config_FeatureMessage;
34 class ModelAPI_ObjectUpdatedMessage;
37 class ModuleBase_IWorkshop;
40 class Events_InfoMessage;
42 /**\class XGUI_WorkshopListener
44 * \brief Class which process the events from the event loop.
46 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
50 /// Constructor. Used only if the workshop is launched in Salome environment
51 /// \param theWorkshop a reference to workshop.
52 XGUI_WorkshopListener(XGUI_Workshop* theWorkshop);
53 virtual ~XGUI_WorkshopListener();
55 /// Register this class in the events loop for several types of events
56 void initializeEventListening();
58 //! Redefinition of Events_Listener method
59 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
62 /// Emitted when error in applivation happens
63 void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
66 /// Procedure to process postponed events
67 bool event(QEvent * theEvent);
69 /// Process feature update message
70 /// \param theMsg a message with a container of objects
71 void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
73 /// Process feature created message
74 /// \param theMsg a message with a container of objects
75 void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
77 /// Process feature redisplay message
78 /// \param theMsg a message with a container of objects
79 void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
81 /// Process clearing of presentation
82 /// \param theMsg an event message
83 void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
85 /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
86 /// Asks the module whether the object can be displayed
87 /// \param theObj an object
88 /// \param theFirstVisualizedBody an output state whether there are not object displayed in the
89 /// view and the displayed object is a body
90 /// \return true if the object is displayed
91 bool displayObject(ObjectPtr theObj);
93 /// Calls the module method of cusomize object for the feature of the current operation
94 /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
95 /// current operation feature
96 /// \param theObjects a list of objects to find current operation feature
97 /// if forced redisplay is false
98 /// \param theForceRedisplay a flag to customize object even always
99 /// \return true if the object is modified
100 bool customizeFeature(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
102 /// Returns the workshop
103 XGUI_Workshop* workshop() const;
107 void setDisplayed(ObjectPtr theObject, const bool theIsLoadedScript, bool& theDisplayed);
109 XGUI_Workshop* myWorkshop; // the current workshop