1 // Copyright (C) 2014-2017 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<mailto: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 /// 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);
51 /// Activate objects in the module selection modes(opens local context)
52 virtual void activateModuleSelectionModes();
54 /// Deactivate sub-shapes selection (closes local context)
55 virtual void deactivateSubShapesSelection();
57 //! Returns instance of loaded module
58 virtual ModuleBase_IModule* module() const;
60 //! Returns current viewer
61 virtual ModuleBase_IViewer* viewer() const;
63 //! Returns property panel
64 virtual ModuleBase_IPropertyPanel* propertyPanel() const;
66 //! Returns error manager
67 virtual ModuleBase_IErrorMgr* errorMgr() const;
69 //! Returns currently active operation
70 virtual ModuleBase_Operation* currentOperation() const;
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);
77 //! Performs the operation launch
78 //! \param theOperation an operation to be launched
79 virtual void processLaunchOperation(ModuleBase_Operation* theOperation);
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);
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);
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,
97 //! Returns AIS object by data object
98 virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
100 //! Returns data object by AIS
101 virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) 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;
123 XGUI_Workshop* workshop() const { return myWorkshop; }
126 QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
128 /// Reference to workshop
129 XGUI_Workshop* myWorkshop;