Salome HOME
Issue #1664: In the Sketcher, add the function Split a segment. Split feature impleme...
[modules/shaper.git] / src / XGUI / XGUI_ModuleConnector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_ModuleConnector.h
4 // Created:     3 June 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef XGUI_ModuleConnector_H
8 #define XGUI_ModuleConnector_H
9
10 #include "XGUI.h"
11 #include <ModuleBase_Definitions.h>
12 #include <ModuleBase_IWorkshop.h>
13
14 class Handle_AIS_InteractiveContext;
15 class XGUI_Workshop;
16 class XGUI_Displayer;
17
18 /**
19  * \ingroup GUI
20  * Implementation of IWorkshop interface which provides access to Workshop services at module level
21  */
22 class XGUI_EXPORT XGUI_ModuleConnector : public ModuleBase_IWorkshop
23 {
24 Q_OBJECT
25  public:
26    /// Constructor
27    /// \param theWorkshop a workshop
28   XGUI_ModuleConnector(XGUI_Workshop* theWorkshop);
29
30   virtual ~XGUI_ModuleConnector();
31
32   //! Returns list of currently selected data objects
33   virtual ModuleBase_ISelection* selection() const;
34
35   /// Activate sub-shapes selection (opens local context if it was not opened)
36   /// Types has to be dined according to TopAbs_ShapeEnum
37   virtual void activateSubShapesSelection(const QIntList& theTypes);
38
39   /// Activate objects in the module selection modes(opens local context)
40   virtual void activateModuleSelectionModes();
41
42   /// Deactivate sub-shapes selection (closes local context)
43   virtual void deactivateSubShapesSelection();
44
45   //! Returns instance of loaded module
46   virtual ModuleBase_IModule* module() const;
47
48   //! Returns current viewer
49   virtual ModuleBase_IViewer* viewer() const;
50
51   //! Returns property panel
52   virtual ModuleBase_IPropertyPanel* propertyPanel() const;
53
54   //! Returns currently active operation
55   virtual ModuleBase_Operation* currentOperation() const;
56
57   //! Returns true if the operation with id theId can be started
58   virtual bool canStartOperation(QString theId);
59
60   //! Performs the operation launch
61   //! \param theOperation an operation to be launched
62   virtual void processLaunchOperation(ModuleBase_Operation* theOperation);
63
64   //! Returns started operation by the operation identifier. The operation manager is called.
65   //! \param theId an operation id
66   //! \return an operation instance or NULL
67   virtual ModuleBase_Operation* findStartedOperation(const QString& theId);
68
69   //! Returns true if the operation with id theId can be stopped. The operation manager is called.
70   //! \param theOperation a stopped operation
71   //! \return boolean result
72   virtual bool canStopOperation(ModuleBase_Operation* theOperation);
73
74   //! Commits if possible or aborts the given operation.
75   //! \param theOperation an aborted operation
76   virtual void stopOperation(ModuleBase_Operation* theOperation);
77
78   //! Returns AIS object by data object
79   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
80
81   //! Returns data object by AIS
82   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
83
84   //! Select features clearing previous selection. 
85   //! If the list is empty then selection will be cleared
86   virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
87
88   //! Shows the message in the status bar
89   //! \param theMessage a message
90   virtual void setStatusBarMessage(const QString& theMessage);
91
92    /// Update of commands status
93   virtual void updateCommandStatus();
94
95   /// Returns Information about feature defined in corresponded XML
96   /// \param theId - id of the feature
97   virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theId) const;
98
99   /// Return application main window
100   virtual QMainWindow* desktop() const;
101
102
103   //! Returns workshop
104   XGUI_Workshop* workshop() const { return myWorkshop; }
105
106 private:
107   QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
108
109   /// Reference to workshop
110   XGUI_Workshop* myWorkshop;
111 };
112
113 #endif