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