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 XGUI_ModuleConnector_H
21 #define XGUI_ModuleConnector_H
24 #include <ModuleBase_Definitions.h>
25 #include <ModuleBase_IWorkshop.h>
32 * Implementation of IWorkshop interface which provides access to Workshop services at module level
34 class XGUI_EXPORT XGUI_ModuleConnector : public ModuleBase_IWorkshop
39 /// \param theWorkshop a workshop
40 XGUI_ModuleConnector(XGUI_Workshop* theWorkshop);
42 virtual ~XGUI_ModuleConnector();
44 //! Returns list of currently selected data objects
45 virtual ModuleBase_ISelection* selection() const;
47 //! Returns instance of loaded module
48 virtual ModuleBase_IModule* module() const;
50 //! Returns current viewer
51 virtual ModuleBase_IViewer* viewer() const;
53 //! Returns property panel
54 virtual ModuleBase_IPropertyPanel* propertyPanel() const;
56 //! Returns error manager
57 virtual ModuleBase_IErrorMgr* errorMgr() const;
59 /// A selection activate in 3D View handler
60 virtual ModuleBase_ISelectionActivate* selectionActivate() const;
62 //! Returns currently active operation
63 virtual ModuleBase_Operation* currentOperation() const;
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);
70 //! Performs the operation launch
71 //! \param theOperation an operation to be launched
72 virtual void processLaunchOperation(ModuleBase_Operation* theOperation);
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);
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);
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,
90 //! Returns AIS object by data object
91 virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
93 //! Returns data object by AIS
94 virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
96 //! Returns true if the object is displayed
97 //! \param theObject a data object
98 virtual bool isVisible(const ObjectPtr& theObject) const;
100 //! Returns list of currently displayed objects
101 virtual QObjectPtrList displayedObjects() const;
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);
107 //! Shows the message in the status bar
108 //! \param theMessage a message
109 virtual void setStatusBarMessage(const QString& theMessage);
111 /// Update of commands status
112 virtual void updateCommandStatus();
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;
118 /// Return application main window
119 virtual QMainWindow* desktop() const;
121 /// Returns true if SHIFT is pressed
122 /// \return boolean value
123 virtual bool hasSHIFTPressed() const;
125 virtual void deactivateCurrentSelector();
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);
132 XGUI_Workshop* workshop() const { return myWorkshop; }
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);
139 //! Undo last command
142 //! Set enabled state of cancel button in property panel
143 virtual void setCancelEnabled(bool toEnable);
145 //! Returns current state of cancel button
146 virtual bool isCancelEnabled() const;
149 QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
151 /// Reference to workshop
152 XGUI_Workshop* myWorkshop;