1 #ifndef XGUI_WORKSHOP_H
2 #define XGUI_WORKSHOP_H
5 #include "XGUI_Constants.h"
6 #include <Events_Listener.h>
7 #include <ModuleBase_Definitions.h>
12 #include <QKeySequence>
15 class XGUI_MainWindow;
18 class XGUI_SelectionMgr;
20 class XGUI_OperationMgr;
21 class XGUI_SalomeConnector;
22 class XGUI_ObjectsBrowser;
23 class XGUI_ActionsMgr;
24 class XGUI_ErrorDialog;
25 class XGUI_SalomeViewer;
26 class XGUI_ViewerProxy;
27 class XGUI_PropertyPanel;
28 class XGUI_ContextMenuMgr;
29 class XGUI_ModuleConnector;
31 class ModuleBase_Operation;
32 class ModuleBase_IModule;
34 class Config_FeatureMessage;
35 class Config_PointerMessage;
40 class Model_ObjectUpdatedMessage;
43 /**\class XGUI_Workshop
45 * \brief Class which defines a configuration of the application (Workshop) and launches it.
47 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
52 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
53 virtual ~XGUI_Workshop();
55 //! Starting of the application
56 void startApplication();
58 //! Returns main window (Desktop) of the application
59 XGUI_MainWindow* mainWindow() const
64 //! Returns selection manager object
65 XGUI_SelectionMgr* selector() const { return mySelector; }
68 XGUI_Displayer* displayer() const { return myDisplayer; }
70 //! ! Returns operation manager.
71 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
73 //! ! Returns an actions manager
74 XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
76 //! Returns property panel widget
77 XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
79 //! Returns context menu manager object
80 XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
82 //! Creates and adds a new workbench (menu group) with the given name and returns it
83 XGUI_Workbench* addWorkbench(const QString& theName);
85 //! Redefinition of Events_Listener method
86 virtual void processEvent(const Events_Message* theMessage);
88 //! Returns an object which provides interface to Salome Module (LightApp_Module)
89 XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
91 //! Provides an object which provides interface to Salome Viewer
92 XGUI_SalomeViewer* salomeViewer() const;
94 //! Returns true if the application works as SALOME module
95 bool isSalomeMode() const { return mySalomeConnector != 0; }
97 //! Returns Object browser
98 XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
100 void salomeViewerSelectionChanged();
102 XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
104 /// Returns the module connectory
105 /// \returns the instance of connector
106 XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
108 //! Returns icon name according to feature Id
109 static QString featureIcon(const std::string& theId);
111 //! Activates or deactivates a part
112 //! If PartPtr is Null pointer then PartSet will be activated
113 void activatePart(FeaturePtr theFeature);
116 void deleteFeatures(QFeatureList theList);
118 //! Show the given features in 3d Viewer
119 void showFeatures(QFeatureList theList, bool isVisible);
121 ModuleBase_IModule* module() const { return myModule; }
124 void salomeViewerSelection();
125 void errorOccurred(const QString&);
128 void updateCommandStatus();
129 void updateCommandsOnViewSelection();
139 void showPropertyPanel();
140 void hidePropertyPanel();
141 void showObjectBrowser();
142 void hideObjectBrowser();
144 void onFeatureTriggered();
145 void changeCurrentDocument(FeaturePtr thePart);
147 void activateLastPart();
150 //Event-loop processing methods:
151 void addFeature(const Config_FeatureMessage*);
152 void connectWithOperation(ModuleBase_Operation* theOperation);
153 void saveDocument(QString theName);
155 void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg);
156 void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg);
157 void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg);
159 QList<QAction*> getModuleCommands() const;
162 /// SLOT, that is called after the operation is started. Update workshop state according to
163 /// the started operation, e.g. visualizes the property panel and connect to it.
164 void onOperationStarted();
165 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
166 /// hides the property panel and udpate the command status.
167 /// \param theOpertion a stopped operation
168 void onOperationStopped(ModuleBase_Operation* theOperation);
170 void onContextMenuCommand(const QString& theId, bool isChecked);
172 void onWidgetValuesChanged();
177 ModuleBase_IModule* loadModule(const QString& theModule);
178 bool activateModule();
180 QDockWidget* createObjectBrowser(QWidget* theParent);
181 QDockWidget* createPropertyPanel(QWidget* theParent);
183 // Creates Dock widgets: Object browser and Property panel
184 void createDockWidgets();
186 XGUI_MainWindow* myMainWindow;
187 ModuleBase_IModule* myModule;
188 XGUI_ObjectsBrowser* myObjectBrowser;
189 XGUI_PropertyPanel* myPropertyPanel;
190 XGUI_SelectionMgr* mySelector;
191 XGUI_Displayer* myDisplayer;
192 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
193 XGUI_ActionsMgr* myActionsMgr;
194 XGUI_SalomeConnector* mySalomeConnector;
195 XGUI_ErrorDialog* myErrorDlg;
196 XGUI_ViewerProxy* myViewerProxy;
197 XGUI_ContextMenuMgr* myContextMenuMgr;
198 XGUI_ModuleConnector* myModuleConnector;
200 QString myCurrentDir;
201 static QMap<QString, QString> myIcons;