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