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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef XGUI_ModuleConnector_H
22 #define XGUI_ModuleConnector_H
23
24 #include "XGUI.h"
25 #include <ModuleBase_Definitions.h>
26 #include <ModuleBase_IWorkshop.h>
27
28 class XGUI_Workshop;
29 class XGUI_Displayer;
30
31 /**
32  * \ingroup GUI
33  * Implementation of IWorkshop interface which provides access to Workshop services at module level
34  */
35 class XGUI_EXPORT XGUI_ModuleConnector : public ModuleBase_IWorkshop
36 {
37 Q_OBJECT
38  public:
39    /// Constructor
40    /// \param theWorkshop a workshop
41   XGUI_ModuleConnector(XGUI_Workshop* theWorkshop);
42
43   virtual ~XGUI_ModuleConnector();
44
45   //! Returns list of currently selected data objects
46   virtual ModuleBase_ISelection* selection() const;
47
48   /// Activate sub-shapes selection (opens local context if it was not opened)
49   /// Types has to be dined according to TopAbs_ShapeEnum
50   virtual void activateSubShapesSelection(const QIntList& theTypes);
51
52   /// Activate objects in the module selection modes(opens local context)
53   virtual void activateModuleSelectionModes();
54
55   /// Deactivate sub-shapes selection (closes local context)
56   virtual void deactivateSubShapesSelection();
57
58   //! Returns instance of loaded module
59   virtual ModuleBase_IModule* module() const;
60
61   //! Returns current viewer
62   virtual ModuleBase_IViewer* viewer() const;
63
64   //! Returns property panel
65   virtual ModuleBase_IPropertyPanel* propertyPanel() const;
66
67   //! Returns error manager
68   virtual ModuleBase_IErrorMgr* errorMgr() const;
69
70   //! Returns currently active operation
71   virtual ModuleBase_Operation* currentOperation() const;
72
73   //! Returns true if the operation with id theId can be started
74   /// \param theId id of the operation which is going to start
75   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
76   virtual bool canStartOperation(QString theId, bool& isCommitted);
77
78   //! Performs the operation launch
79   //! \param theOperation an operation to be launched
80   virtual void processLaunchOperation(ModuleBase_Operation* theOperation);
81
82   //! Returns started operation by the operation identifier. The operation manager is called.
83   //! \param theId an operation id
84   //! \return an operation instance or NULL
85   virtual ModuleBase_Operation* findStartedOperation(const QString& theId);
86
87   //! Returns true if the operation with id theId can be stopped. The operation manager is called.
88   //! \param theOperation a stopped operation
89   //! \return boolean result
90   virtual bool canStopOperation(ModuleBase_Operation* theOperation);
91
92   //! Commits if possible or aborts the given operation.
93   //! \param theOperation an aborted operation
94   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
95   virtual void stopOperation(ModuleBase_Operation* theOperation,
96                              bool& isCommitted);
97
98   //! Returns AIS object by data object
99   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
100
101   //! Returns data object by AIS
102   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
103
104   //! Select features clearing previous selection.
105   //! If the list is empty then selection will be cleared
106   virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
107
108   //! Shows the message in the status bar
109   //! \param theMessage a message
110   virtual void setStatusBarMessage(const QString& theMessage);
111
112    /// Update of commands status
113   virtual void updateCommandStatus();
114
115   /// Returns Information about feature defined in corresponded XML
116   /// \param theId - id of the feature
117   virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theId) const;
118
119   /// Return application main window
120   virtual QMainWindow* desktop() const;
121
122
123   //! Returns workshop
124   XGUI_Workshop* workshop() const { return myWorkshop; }
125
126 private:
127   QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
128
129   /// Reference to workshop
130   XGUI_Workshop* myWorkshop;
131 };
132
133 #endif