Salome HOME
Using of SelectionMgr instead of using Viewer directly in Sketcher starting operation
[modules/shaper.git] / src / XGUI / XGUI_Workshop.h
1 #ifndef XGUI_WORKSHOP_H
2 #define XGUI_WORKSHOP_H
3
4 #include "XGUI.h"
5 #include <Events_Listener.h>
6
7 #include <QObject>
8 #include <QMap>
9 #include <QIcon>
10 #include <QKeySequence>
11
12 class XGUI_MainWindow;
13 class XGUI_Command;
14 class XGUI_Module;
15 class XGUI_Workbench;
16 class XGUI_SelectionMgr;
17 class XGUI_Displayer;
18 class XGUI_OperationMgr;
19 class XGUI_SalomeConnector;
20 class XGUI_ObjectsBrowser;
21 class ModuleBase_Operation;
22 class ModuleBase_PropPanelOperation;
23
24 class Config_FeatureMessage;
25 class Config_PointerMessage;
26
27 class QWidget;
28 class QDockWidget;
29
30 /**\class XGUI_Workshop
31  * \ingroup GUI
32  * \brief Class which defines a configuration of the application (Workshop) and launches it.
33  */
34 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
35 {
36 Q_OBJECT
37 public:
38
39   XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
40   virtual ~XGUI_Workshop();
41
42   //! Starting of the application
43   void startApplication();
44
45   //! Returns main window (Desktop) of the application
46   XGUI_MainWindow* mainWindow() const
47   {
48     return myMainWindow;
49   }
50
51   //! Returns selection manager object
52   XGUI_SelectionMgr* selector() const { return mySelector; }
53
54   //! Returns displayer
55   XGUI_Displayer* displayer() const;
56
57   //! ! Returns operation manager.
58   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
59
60   //! Creates and adds a new workbench (menu group) with the given name and returns it
61   XGUI_Workbench* addWorkbench(const QString& theName);
62
63   //! Redefinition of Events_Listener method
64   virtual void processEvent(const Events_Message* theMessage);
65
66   XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
67
68   //! Returns true if the application works as SALOME module
69   bool isSalomeMode() const { return mySalomeConnector != 0; }
70
71   //! Returns Object browser
72   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
73
74   void salomeViewerSelectionChanged();
75
76 signals:
77   void salomeViewerSelection();
78
79 public slots:
80   void updateCommandStatus();
81
82   void onNew();
83   void onOpen();
84   void onSave();
85   void onSaveAs();
86   void onExit();
87   void onUndo();
88   void onRedo();
89
90   void showPropertyPanel();
91   void hidePropertyPanel();
92   void showObjectBrowser();
93   void hideObjectBrowser();
94
95   void onFeatureTriggered();
96
97   void changeCurrentDocument();
98
99 protected:
100   //Event-loop processing methods:
101   void addFeature(const Config_FeatureMessage*);
102   void connectWithOperation(ModuleBase_Operation* theOperation);
103
104 protected slots:
105   /// SLOT, that is called after the operation is started. Update workshop state according to
106   /// the started operation, e.g. visualizes the property panel and connect to it.
107   void onOperationStarted();
108   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
109   /// hides the property panel and udpate the command status.
110   /// \param theOpertion a stopped operation
111   void onOperationStopped(ModuleBase_Operation* theOperation);
112
113 private:
114   void initMenu();
115
116   XGUI_Module* loadModule(const QString& theModule);
117   bool activateModule();
118
119   QDockWidget* createObjectBrowser(QWidget* theParent);
120   QDockWidget* createPropertyPanel(QWidget* theParent);
121
122   // Creates Dock widgets: Object browser and Property panel
123   void createDockWidgets();
124   void setPropertyPannelTitle(const QString& theTitle);
125
126
127   XGUI_MainWindow* myMainWindow;
128   XGUI_Module* myPartSetModule;
129
130   XGUI_ObjectsBrowser* myObjectBrowser;
131   QDockWidget* myPropertyPanelDock;
132
133   XGUI_SelectionMgr* mySelector;
134   XGUI_Displayer* myDisplayer;
135
136   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
137
138   XGUI_SalomeConnector* mySalomeConnector;
139 };
140
141 #endif