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>
8 #include <ModelAPI_ResultPart.h>
9 #include <ModelAPI_Document.h>
14 #include <QKeySequence>
17 class XGUI_MainWindow;
20 class XGUI_SelectionMgr;
22 class XGUI_OperationMgr;
23 class XGUI_SalomeConnector;
24 class XGUI_ObjectsBrowser;
25 class XGUI_ActionsMgr;
26 class XGUI_ErrorDialog;
27 class XGUI_SalomeViewer;
28 class XGUI_ViewerProxy;
29 class XGUI_PropertyPanel;
30 class XGUI_ContextMenuMgr;
31 class XGUI_ModuleConnector;
33 class ModuleBase_Operation;
34 class ModuleBase_IModule;
36 class Config_FeatureMessage;
37 class Config_PointerMessage;
42 class ModelAPI_ObjectUpdatedMessage;
43 class ModelAPI_ObjectDeletedMessage;
46 class SUIT_ResourceMgr;
48 /**\class XGUI_Workshop
50 * \brief Class which defines a configuration of the application (Workshop) and launches it.
52 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
57 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
58 virtual ~XGUI_Workshop();
60 //! Starting of the application
61 void startApplication();
63 //! Returns main window (Desktop) of the application
64 XGUI_MainWindow* mainWindow() const
69 //! Returns selection manager object
70 XGUI_SelectionMgr* selector() const { return mySelector; }
73 XGUI_Displayer* displayer() const { return myDisplayer; }
75 //! ! Returns operation manager.
76 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
78 //! ! Returns an actions manager
79 XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
81 //! Returns property panel widget
82 XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
84 //! Returns context menu manager object
85 XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
87 //! Creates and adds a new workbench (menu group) with the given name and returns it
88 XGUI_Workbench* addWorkbench(const QString& theName);
90 //! Redefinition of Events_Listener method
91 virtual void processEvent(const Events_Message* theMessage);
93 //! Returns an object which provides interface to Salome Module (LightApp_Module)
94 XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
96 //! Provides an object which provides interface to Salome Viewer
97 XGUI_SalomeViewer* salomeViewer() const;
99 //! Returns true if the application works as SALOME module
100 bool isSalomeMode() const { return mySalomeConnector != 0; }
102 //! Returns Object browser
103 XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
105 void salomeViewerSelectionChanged();
107 XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
109 /// Returns the module connectory
110 /// \returns the instance of connector
111 XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
113 //! Returns icon name according to feature Id
114 static QString featureIcon(const std::string& theId);
116 static SUIT_ResourceMgr* resourceMgr() { return myResourceMgr; }
118 //! Activates or deactivates a part
119 //! If PartPtr is Null pointer then PartSet will be activated
120 void activatePart(ResultPartPtr theFeature);
123 void deleteObjects(const QList<ObjectPtr>& theList);
125 //! Show the given features in 3d Viewer
126 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
128 ModuleBase_IModule* module() const { return myModule; }
131 void salomeViewerSelection();
132 void errorOccurred(const QString&);
135 void updateCommandStatus();
136 void updateCommandsOnViewSelection();
146 void showPropertyPanel();
147 void hidePropertyPanel();
148 void showObjectBrowser();
149 void hideObjectBrowser();
151 void onFeatureTriggered();
152 void changeCurrentDocument(ObjectPtr theObj);
154 void activateLastPart();
157 //Event-loop processing methods:
158 void addFeature(const Config_FeatureMessage*);
159 void connectWithOperation(ModuleBase_Operation* theOperation);
160 void saveDocument(QString theName);
162 void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
163 void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
164 void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
165 void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg);
167 QList<QAction*> getModuleCommands() const;
169 void displayAllResults();
170 void displayDocumentResults(DocumentPtr theDoc);
171 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
174 /// SLOT, that is called after the operation is started. Update workshop state according to
175 /// the started operation, e.g. visualizes the property panel and connect to it.
176 void onOperationStarted();
177 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
178 /// hides the property panel and udpate the command status.
179 /// \param theOpertion a stopped operation
180 void onOperationStopped(ModuleBase_Operation* theOperation);
182 void onContextMenuCommand(const QString& theId, bool isChecked);
184 void onWidgetValuesChanged();
186 void onStartWaiting();
191 void registerValidators() const;
194 ModuleBase_IModule* loadModule(const QString& theModule);
195 bool activateModule();
197 QDockWidget* createObjectBrowser(QWidget* theParent);
198 QDockWidget* createPropertyPanel(QWidget* theParent);
200 // Creates Dock widgets: Object browser and Property panel
201 void createDockWidgets();
203 XGUI_MainWindow* myMainWindow;
204 ModuleBase_IModule* myModule;
205 XGUI_ObjectsBrowser* myObjectBrowser;
206 XGUI_PropertyPanel* myPropertyPanel;
207 XGUI_SelectionMgr* mySelector;
208 XGUI_Displayer* myDisplayer;
209 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
210 XGUI_ActionsMgr* myActionsMgr;
211 XGUI_SalomeConnector* mySalomeConnector;
212 XGUI_ErrorDialog* myErrorDlg;
213 XGUI_ViewerProxy* myViewerProxy;
214 XGUI_ContextMenuMgr* myContextMenuMgr;
215 XGUI_ModuleConnector* myModuleConnector;
217 QString myCurrentDir;
218 static QMap<QString, QString> myIcons;
220 static SUIT_ResourceMgr* myResourceMgr;