Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModuleBase / ModuleBase_IWorkshop.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 ModuleBase_IWorkshop_H
21 #define ModuleBase_IWorkshop_H
22
23 #include "ModuleBase.h"
24 #include "ModuleBase_Definitions.h"
25 #include <ModuleBase_FilterValidated.h>
26
27 #include <ModelAPI_Object.h>
28 #include <GeomAPI_AISObject.h>
29 #include <Config_FeatureMessage.h>
30
31 #include <QObject>
32
33 class ModuleBase_IModule;
34 class ModuleBase_ISelection;
35 class ModuleBase_IViewer;
36 class ModuleBase_IPropertyPanel;
37 class ModuleBase_IErrorMgr;
38 class ModuleBase_Operation;
39 class ModuleBase_ViewerPrs;
40 class QMainWindow;
41
42 /**
43  * \ingroup GUI
44  * Class which provides access to Workshop object services
45  */
46 class MODULEBASE_EXPORT ModuleBase_IWorkshop : public QObject
47 {
48 Q_OBJECT
49  public:
50    /// Constructor
51    /// \param theParent parent object
52   ModuleBase_IWorkshop(QObject* theParent);
53
54   virtual ~ModuleBase_IWorkshop()
55   {}
56
57   /// Return current selection instance
58   virtual ModuleBase_ISelection* selection() const = 0;
59
60   /// Activate sub-shapes selection (opens local context)
61   /// Types has to be defined according to TopAbs_ShapeEnum
62   virtual void activateSubShapesSelection(const QIntList& theTypes) = 0;
63
64   /// Activate objects in the module selection modes(opens local context)
65   virtual void activateModuleSelectionModes() = 0;
66
67   /// Deactivate sub-shapes selection (closes local context)
68   virtual void deactivateSubShapesSelection() = 0;
69
70   //! Returns instance of loaded module
71   virtual ModuleBase_IModule* module() const = 0;
72
73   //! Returns current viewer
74   virtual ModuleBase_IViewer* viewer() const = 0;
75
76   //! Returns property panel
77   virtual ModuleBase_IPropertyPanel* propertyPanel() const = 0;
78
79   //! Returns error manager
80   virtual ModuleBase_IErrorMgr* errorMgr() const = 0;
81
82   /// A filter to process an attribute validators
83   /// \return a filter
84   Handle(ModuleBase_FilterValidated) validatorFilter();
85
86   //! Returns currently active operation
87   virtual ModuleBase_Operation* currentOperation() const = 0;
88
89   //! Returns true if the operation with id theId can be started
90   virtual bool canStartOperation(QString theId, bool& isCommitted) = 0;
91
92   //! Performs the operation launch
93   //! \param theOperation an operation to be launched
94   virtual void processLaunchOperation(ModuleBase_Operation* theOperation) = 0;
95
96   //! Returns started operation by the operation identifier
97   //! \param theId an operation id
98   //! \return an operation instance or NULL
99   virtual ModuleBase_Operation* findStartedOperation(const QString& theId) = 0;
100
101   //! Returns true if the operation with id theId can be stopped
102   //! \param theOperation a stopped operation
103   //! \return boolean result
104   virtual bool canStopOperation(ModuleBase_Operation* theOperation) = 0;
105
106   //! Commits if possible or aborts the given operation.
107   //! \param theOperation an aborted operation
108   /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
109   virtual void stopOperation(ModuleBase_Operation* theOperation,
110                              bool& isCommitted) = 0;
111
112   //! Returns AIS object by data object
113   //! \param theObject a data object
114   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0;
115
116   //! Returns data object by AIS
117   //! \param theAIS a presentation
118   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
119
120   //! Select features clearing previous selection.
121   //! If the list is empty then selection will be cleared
122   //! \param theValues a list of presentations
123   virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) = 0;
124
125   //! Shows the message in the status bar
126   //! \param theMessage a message
127   virtual void setStatusBarMessage(const QString& theMessage) = 0;
128
129    /// Update of commands status
130   virtual void updateCommandStatus() = 0;
131
132   /// Returns feature info according to given feature ID
133   /// \param theId a feature Id
134   virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theId) const = 0;
135
136   /// Returns main window of the application
137   virtual QMainWindow* desktop() const = 0;
138
139
140 signals:
141   /// Signal selection changed.
142   void selectionChanged();
143
144   /// Signal which is emited after activation of property panel
145   void propertyPanelActivated();
146
147 protected:
148   /// A filter to process an attribute validators
149   Handle(ModuleBase_FilterValidated) myValidatorFilter;
150 };
151
152 #endif