Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / XGUI / XGUI_ModuleConnector.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 email : webmaster.salome@opencascade.com<mailto: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   /// Activate sub-shapes selection (opens local context if it was not opened)
48   /// Types has to be dined according to TopAbs_ShapeEnum
49   virtual void activateSubShapesSelection(const QIntList& theTypes);
50
51   /// Activate objects in the module selection modes(opens local context)
52   virtual void activateModuleSelectionModes();
53
54   /// Deactivate sub-shapes selection (closes local context)
55   virtual void deactivateSubShapesSelection();
56
57   //! Returns instance of loaded module
58   virtual ModuleBase_IModule* module() const;
59
60   //! Returns current viewer
61   virtual ModuleBase_IViewer* viewer() const;
62
63   //! Returns property panel
64   virtual ModuleBase_IPropertyPanel* propertyPanel() const;
65
66   //! Returns error manager
67   virtual ModuleBase_IErrorMgr* errorMgr() const;
68
69   //! Returns currently active operation
70   virtual ModuleBase_Operation* currentOperation() const;
71
72   //! Returns true if the operation with id theId can be started
73   /// \param theId id of the operation which is going to start
74   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
75   virtual bool canStartOperation(QString theId, bool& isCommitted);
76
77   //! Performs the operation launch
78   //! \param theOperation an operation to be launched
79   virtual void processLaunchOperation(ModuleBase_Operation* theOperation);
80
81   //! Returns started operation by the operation identifier. The operation manager is called.
82   //! \param theId an operation id
83   //! \return an operation instance or NULL
84   virtual ModuleBase_Operation* findStartedOperation(const QString& theId);
85
86   //! Returns true if the operation with id theId can be stopped. The operation manager is called.
87   //! \param theOperation a stopped operation
88   //! \return boolean result
89   virtual bool canStopOperation(ModuleBase_Operation* theOperation);
90
91   //! Commits if possible or aborts the given operation.
92   //! \param theOperation an aborted operation
93   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
94   virtual void stopOperation(ModuleBase_Operation* theOperation,
95                              bool& isCommitted);
96
97   //! Returns AIS object by data object
98   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
99
100   //! Returns data object by AIS
101   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) 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
122   //! Returns workshop
123   XGUI_Workshop* workshop() const { return myWorkshop; }
124
125 private:
126   QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
127
128   /// Reference to workshop
129   XGUI_Workshop* myWorkshop;
130 };
131
132 #endif