Salome HOME
Merge remote-tracking branch 'origin/cbr/export_to_geom_via_xao'
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef XGUI_WORKSHOP_LISTENER_H
22 #define XGUI_WORKSHOP_LISTENER_H
23
24 #include "XGUI.h"
25 #include <Events_Listener.h>
26 #include <Events_Message.h>
27
28 #include <ModelAPI_Feature.h>
29 #include <Events_InfoMessage.h>
30
31 #include <QObject>
32
33 class Config_FeatureMessage;
34
35 class ModelAPI_ObjectUpdatedMessage;
36 class XGUI_Workshop;
37
38 class ModuleBase_IWorkshop;
39
40 class QString;
41 class Events_InfoMessage;
42
43 /**\class XGUI_WorkshopListener
44  * \ingroup GUI
45  * \brief Class which process the events from the event loop.
46  */
47 class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener
48 {
49   Q_OBJECT
50 public:
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();
55
56   /// Register this class in the events loop for several types of events
57   void initializeEventListening();
58
59   //! Redefinition of Events_Listener method
60   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
61
62 signals:
63   /// Emitted when error in applivation happens
64   void errorOccurred(std::shared_ptr<Events_InfoMessage> theMsg);
65
66 protected:
67   /// Procedure to process postponed events
68   bool event(QEvent * theEvent);
69
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);
73
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);
77
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);
81
82   /// Process clearing of presentation
83   /// \param theMsg an event message
84   void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
85
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);
93
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);
102
103   /// Returns the workshop
104   XGUI_Workshop* workshop() const;
105
106 private:
107   ModuleBase_IWorkshop* myWorkshop; // the current workshop
108
109   bool myUpdatePrefs;
110 };
111
112 #endif