Salome HOME
ac303fe917c70447cbf642ae7c8556dc3126518d
[modules/shaper.git] / src / XGUI / XGUI_ModuleConnector.h
1 // Copyright (C) 2014-2021  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef XGUI_ModuleConnector_H
21 #define XGUI_ModuleConnector_H
22
23 #include "XGUI.h"
24 #include <ModuleBase_Definitions.h>
25 #include <ModuleBase_IWorkshop.h>
26
27 class XGUI_Workshop;
28 class XGUI_Displayer;
29
30 /**
31  * \ingroup GUI
32  * Implementation of IWorkshop interface which provides access to Workshop services at module level
33  */
34 class XGUI_EXPORT XGUI_ModuleConnector : public ModuleBase_IWorkshop
35 {
36 Q_OBJECT
37  public:
38    /// Constructor
39    /// \param theWorkshop a workshop
40   XGUI_ModuleConnector(XGUI_Workshop* theWorkshop);
41
42   virtual ~XGUI_ModuleConnector();
43
44   //! Returns list of currently selected data objects
45   virtual ModuleBase_ISelection* selection() const;
46
47   //! Returns instance of loaded module
48   virtual ModuleBase_IModule* module() const;
49
50   //! Returns current viewer
51   virtual ModuleBase_IViewer* viewer() const;
52
53   //! Returns property panel
54   virtual ModuleBase_IPropertyPanel* propertyPanel() const;
55
56   //! Returns error manager
57   virtual ModuleBase_IErrorMgr* errorMgr() const;
58
59   /// A selection activate in 3D View handler
60   virtual ModuleBase_ISelectionActivate* selectionActivate() const;
61
62   //! Returns currently active operation
63   virtual ModuleBase_Operation* currentOperation() const;
64
65   //! Returns true if the operation with id theId can be started
66   /// \param theId id of the operation which is going to start
67   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
68   virtual bool canStartOperation(QString theId, bool& isCommitted);
69
70   //! Performs the operation launch
71   //! \param theOperation an operation to be launched
72   virtual void processLaunchOperation(ModuleBase_Operation* theOperation);
73
74   //! Returns started operation by the operation identifier. The operation manager is called.
75   //! \param theId an operation id
76   //! \return an operation instance or NULL
77   virtual ModuleBase_Operation* findStartedOperation(const QString& theId);
78
79   //! Returns true if the operation with id theId can be stopped. The operation manager is called.
80   //! \param theOperation a stopped operation
81   //! \return boolean result
82   virtual bool canStopOperation(ModuleBase_Operation* theOperation);
83
84   //! Commits if possible or aborts the given operation.
85   //! \param theOperation an aborted operation
86   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
87   virtual void stopOperation(ModuleBase_Operation* theOperation,
88                              bool& isCommitted);
89
90   //! Returns AIS object by data object
91   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
92
93   //! Returns data object by AIS
94   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
95
96   //! Returns true if the object is displayed
97   //! \param theObject a data object
98   virtual bool isVisible(const ObjectPtr& theObject) const;
99
100   //! Returns list of currently displayed objects
101   virtual QObjectPtrList displayedObjects() const;
102
103   //! Select features clearing previous selection.
104   //! If the list is empty then selection will be cleared
105   virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
106
107   //! Shows the message in the status bar
108   //! \param theMessage a message
109   virtual void setStatusBarMessage(const QString& theMessage);
110
111    /// Update of commands status
112   virtual void updateCommandStatus();
113
114   /// Returns Information about feature defined in corresponded XML
115   /// \param theId - id of the feature
116   virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theId) const;
117
118   /// Return application main window
119   virtual QMainWindow* desktop() const;
120
121   /// Returns true if SHIFT is pressed
122   /// \return boolean value
123   virtual bool hasSHIFTPressed() const;
124
125   virtual void deactivateCurrentSelector();
126
127   //! Temporary enable or disable viewer update. Returns previous state of updating
128   //! \param isEnabled new state of the viewer update
129   virtual bool enableUpdateViewer(bool isEnabled);
130
131   //! Returns workshop
132   XGUI_Workshop* workshop() const { return myWorkshop; }
133
134   //! The methods applys current defined selection modes to given AIS presentation.
135   //! The AIS presentation has to be already displayed. After activation viewer has to be updated
136   //! \param theAIS the object which has to be activated
137   virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS);
138
139   //! Undo last command
140   virtual void undo();
141
142   //! Set enabled state of cancel button in property panel
143   virtual void setCancelEnabled(bool toEnable);
144
145   //! Returns current state of cancel button
146   virtual bool isCancelEnabled() const;
147
148   //! Show help of a current operation
149   virtual void showHelpPage(const QString& thePage) const;
150
151 private:
152   QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
153
154   /// Reference to workshop
155   XGUI_Workshop* myWorkshop;
156 };
157
158 #endif