]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Workshop.h
Salome HOME
d7ace358b60068eb67234ed7c51be05957cf4d79
[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 "XGUI_Constants.h"
6 #include <Events_Listener.h>
7
8 #include <QObject>
9 #include <QMap>
10 #include <QIcon>
11 #include <QKeySequence>
12
13 class XGUI_MainWindow;
14 class XGUI_Command;
15 class XGUI_Module;
16 class XGUI_Workbench;
17 class XGUI_SelectionMgr;
18 class XGUI_Displayer;
19 class XGUI_OperationMgr;
20 class XGUI_SalomeConnector;
21 class XGUI_ObjectsBrowser;
22 class XGUI_ActionsMgr;
23 class XGUI_ErrorDialog;
24 class XGUI_SalomeViewer;
25 class XGUI_ViewerProxy;
26 class XGUI_PropertyPanel;
27 class XGUI_ContextMenuMgr;
28
29 class ModuleBase_Operation;
30
31 class Config_FeatureMessage;
32 class Config_PointerMessage;
33
34 class QWidget;
35 class QDockWidget;
36
37 /**\class XGUI_Workshop
38  * \ingroup GUI
39  * \brief Class which defines a configuration of the application (Workshop) and launches it.
40  */
41 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
42 {
43 Q_OBJECT
44 public:
45
46   XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
47   virtual ~XGUI_Workshop();
48
49   //! Starting of the application
50   void startApplication();
51
52   //! Returns main window (Desktop) of the application
53   XGUI_MainWindow* mainWindow() const
54   {
55     return myMainWindow;
56   }
57
58   //! Returns selection manager object
59   XGUI_SelectionMgr* selector() const { return mySelector; }
60
61   //! Returns displayer
62   XGUI_Displayer* displayer() const { return myDisplayer; }
63
64   //! ! Returns operation manager.
65   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
66
67   //! ! Returns an actions manager
68   XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
69
70   //! Returns property panel widget
71   XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
72
73   //! Returns context menu manager object
74   XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
75
76   //! Creates and adds a new workbench (menu group) with the given name and returns it
77   XGUI_Workbench* addWorkbench(const QString& theName);
78
79   //! Redefinition of Events_Listener method
80   virtual void processEvent(const Events_Message* theMessage);
81
82   //! Returns an object which provides interface to Salome Module (LightApp_Module)
83   XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
84
85   //! Provides an object which provides interface to Salome Viewer
86   XGUI_SalomeViewer* salomeViewer() const;
87
88   //! Returns true if the application works as SALOME module
89   bool isSalomeMode() const { return mySalomeConnector != 0; }
90
91   //! Returns Object browser
92   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
93
94   void salomeViewerSelectionChanged();
95
96   XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
97
98   //! Returns icon name according to feature Id
99   static QString featureIcon(const std::string& theId);
100
101   //! Activates or deactivates a part
102   //! If PartPtr is Null pointer then PartSet will be activated
103   void activatePart(FeaturePtr theFeature);
104
105   //! Delete features
106   void deleteFeatures(QFeatureList theList);
107
108   //! Show the given features in 3d Viewer
109   void showFeatures(QFeatureList theList, bool isVisible);
110
111 signals:
112   void salomeViewerSelection();
113   void errorOccurred(const QString&);
114
115 public slots:
116   void updateCommandStatus();
117
118   void onNew();
119   void onOpen();
120   bool onSave();
121   bool onSaveAs();
122   void onExit();
123   void onUndo();
124   void onRedo();
125
126   void showPropertyPanel();
127   void hidePropertyPanel();
128   void showObjectBrowser();
129   void hideObjectBrowser();
130
131   void onFeatureTriggered();
132   void changeCurrentDocument(FeaturePtr thePart);
133
134   void activateLastPart();
135
136 protected:
137   //Event-loop processing methods:
138   void addFeature(const Config_FeatureMessage*);
139   void connectWithOperation(ModuleBase_Operation* theOperation);
140   void saveDocument(QString theName);
141
142 protected slots:
143   /// SLOT, that is called after the operation is started. Update workshop state according to
144   /// the started operation, e.g. visualizes the property panel and connect to it.
145   void onOperationStarted();
146   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
147   /// hides the property panel and udpate the command status.
148   /// \param theOpertion a stopped operation
149   void onOperationStopped(ModuleBase_Operation* theOperation);
150
151   void onContextMenuCommand(const QString& theId, bool isChecked);
152
153 private:
154   void initMenu();
155
156   XGUI_Module* loadModule(const QString& theModule);
157   bool activateModule();
158
159   QDockWidget* createObjectBrowser(QWidget* theParent);
160   QDockWidget* createPropertyPanel(QWidget* theParent);
161
162   // Creates Dock widgets: Object browser and Property panel
163   void createDockWidgets();
164
165   XGUI_MainWindow* myMainWindow;
166   XGUI_Module* myPartSetModule;
167   XGUI_ObjectsBrowser* myObjectBrowser;
168   XGUI_PropertyPanel* myPropertyPanel;
169   XGUI_SelectionMgr* mySelector;
170   XGUI_Displayer* myDisplayer;
171   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
172   XGUI_ActionsMgr* myActionsMgr;
173   XGUI_SalomeConnector* mySalomeConnector;
174   XGUI_ErrorDialog* myErrorDlg;
175   XGUI_ViewerProxy* myViewerProxy;
176   XGUI_ContextMenuMgr* myContextMenuMgr;
177
178   QString myCurrentDir;
179   static QMap<QString, QString> myIcons;
180
181 };
182
183 #endif