]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Workshop.h
Salome HOME
IWorkshop interface for Module is created
[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 icon name according to feature Id
100   static QString featureIcon(const std::string& theId);
101
102   //! Activates or deactivates a part
103   //! If PartPtr is Null pointer then PartSet will be activated
104   void activatePart(FeaturePtr theFeature);
105
106   //! Delete features
107   void deleteFeatures(QFeatureList theList);
108
109   //! Show the given features in 3d Viewer
110   void showFeatures(QFeatureList theList, bool isVisible);
111
112 signals:
113   void salomeViewerSelection();
114   void errorOccurred(const QString&);
115
116 public slots:
117   void updateCommandStatus();
118
119   void onNew();
120   void onOpen();
121   bool onSave();
122   bool onSaveAs();
123   void onExit();
124   void onUndo();
125   void onRedo();
126
127   void showPropertyPanel();
128   void hidePropertyPanel();
129   void showObjectBrowser();
130   void hideObjectBrowser();
131
132   void onFeatureTriggered();
133   void changeCurrentDocument(FeaturePtr thePart);
134
135   void activateLastPart();
136
137 protected:
138   //Event-loop processing methods:
139   void addFeature(const Config_FeatureMessage*);
140   void connectWithOperation(ModuleBase_Operation* theOperation);
141   void saveDocument(QString theName);
142
143 protected slots:
144   /// SLOT, that is called after the operation is started. Update workshop state according to
145   /// the started operation, e.g. visualizes the property panel and connect to it.
146   void onOperationStarted();
147   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
148   /// hides the property panel and udpate the command status.
149   /// \param theOpertion a stopped operation
150   void onOperationStopped(ModuleBase_Operation* theOperation);
151
152   void onContextMenuCommand(const QString& theId, bool isChecked);
153
154 private:
155   void initMenu();
156
157   XGUI_Module* loadModule(const QString& theModule);
158   bool activateModule();
159
160   QDockWidget* createObjectBrowser(QWidget* theParent);
161   QDockWidget* createPropertyPanel(QWidget* theParent);
162
163   // Creates Dock widgets: Object browser and Property panel
164   void createDockWidgets();
165
166   XGUI_MainWindow* myMainWindow;
167   XGUI_Module* myPartSetModule;
168   XGUI_ObjectsBrowser* myObjectBrowser;
169   XGUI_PropertyPanel* myPropertyPanel;
170   XGUI_SelectionMgr* mySelector;
171   XGUI_Displayer* myDisplayer;
172   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
173   XGUI_ActionsMgr* myActionsMgr;
174   XGUI_SalomeConnector* mySalomeConnector;
175   XGUI_ErrorDialog* myErrorDlg;
176   XGUI_ViewerProxy* myViewerProxy;
177   XGUI_ContextMenuMgr* myContextMenuMgr;
178   XGUI_ModuleConnector* myModuleConnector;
179
180   QString myCurrentDir;
181   static QMap<QString, QString> myIcons;
182
183 };
184
185 #endif