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