1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef ModuleBase_IWorkshop_H
21 #define ModuleBase_IWorkshop_H
23 #include "ModuleBase.h"
24 #include "ModuleBase_Definitions.h"
25 #include <ModuleBase_FilterValidated.h>
27 #include <ModelAPI_Object.h>
28 #include <GeomAPI_AISObject.h>
29 #include <Config_FeatureMessage.h>
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_ISelectionActivate;
40 class ModuleBase_ViewerPrs;
45 * Class which provides access to Workshop object services
47 class MODULEBASE_EXPORT ModuleBase_IWorkshop : public QObject
52 /// \param theParent parent object
53 ModuleBase_IWorkshop(QObject* theParent);
55 virtual ~ModuleBase_IWorkshop()
58 /// Return current selection instance
59 virtual ModuleBase_ISelection* selection() const = 0;
61 //! Returns instance of loaded module
62 virtual ModuleBase_IModule* module() const = 0;
64 //! Returns current viewer
65 virtual ModuleBase_IViewer* viewer() const = 0;
67 //! Returns property panel
68 virtual ModuleBase_IPropertyPanel* propertyPanel() const = 0;
70 //! Returns error manager
71 virtual ModuleBase_IErrorMgr* errorMgr() const = 0;
73 /// A filter to process an attribute validators
75 Handle(ModuleBase_FilterValidated) validatorFilter();
77 /// A selection activate in 3D View handler
78 virtual ModuleBase_ISelectionActivate* selectionActivate() const = 0;
80 //! Returns currently active operation
81 virtual ModuleBase_Operation* currentOperation() const = 0;
83 //! Returns true if the operation with id theId can be started
84 virtual bool canStartOperation(QString theId, bool& isCommitted) = 0;
86 //! Performs the operation launch
87 //! \param theOperation an operation to be launched
88 virtual void processLaunchOperation(ModuleBase_Operation* theOperation) = 0;
90 //! Returns started operation by the operation identifier
91 //! \param theId an operation id
92 //! \return an operation instance or NULL
93 virtual ModuleBase_Operation* findStartedOperation(const QString& theId) = 0;
95 //! Returns true if the operation with id theId can be stopped
96 //! \param theOperation a stopped operation
97 //! \return boolean result
98 virtual bool canStopOperation(ModuleBase_Operation* theOperation) = 0;
100 //! Commits if possible or aborts the given operation.
101 //! \param theOperation an aborted operation
102 /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
103 virtual void stopOperation(ModuleBase_Operation* theOperation,
104 bool& isCommitted) = 0;
106 //! Returns AIS object by data object
107 //! \param theObject a data object
108 virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0;
110 //! Returns data object by AIS
111 //! \param theAIS a presentation
112 virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
114 //! Returns true if the object is displayed
115 //! \param theObject a data object
116 virtual bool isVisible(const ObjectPtr& theObject) const = 0;
118 //! Returns list of currently displayed objects
119 virtual QObjectPtrList displayedObjects() const = 0;
121 //! Select features clearing previous selection.
122 //! If the list is empty then selection will be cleared
123 //! \param theValues a list of presentations
124 virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) = 0;
126 //! Shows the message in the status bar
127 //! \param theMessage a message
128 virtual void setStatusBarMessage(const QString& theMessage) = 0;
130 /// Update of commands status
131 virtual void updateCommandStatus() = 0;
133 /// Returns feature info according to given feature ID
134 /// \param theId a feature Id
135 virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theId) const = 0;
137 /// Returns main window of the application
138 virtual QMainWindow* desktop() const = 0;
140 /// Returns true if SHIFT is pressed
141 /// \return boolean value
142 virtual bool hasSHIFTPressed() const = 0;
144 virtual void deactivateCurrentSelector() = 0;
146 //! Temporary enable or disable viewer update. Returns previous state of updating
147 //! \param isEnabled new state of the viewer update
148 virtual bool enableUpdateViewer(bool isEnabled) = 0;
150 //! The methods applys current defined selection modes to given AIS presentation.
151 //! The AIS presentation has to be already displayed. After activation viewer has to be updated
152 //! \param theAIS the object which has to be activated
153 virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS) = 0;
155 //! Undo last command
156 virtual void undo() = 0;
158 //! Set enabled state of cancel button in property panel
159 virtual void setCancelEnabled(bool toEnable) = 0;
161 //! Returns current state of cancel button
162 virtual bool isCancelEnabled() const = 0;
165 /// Signal selection changed.
166 void selectionChanged();
168 /// Signal which is emited after activation of property panel
169 void propertyPanelActivated();
172 /// A filter to process an attribute validators
173 Handle(ModuleBase_FilterValidated) myValidatorFilter;