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 XGUI_Workshop
48 * \brief Class which defines a configuration of the application (Workshop) and launches it.
50 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
55 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
56 virtual ~XGUI_Workshop();
58 //! Starting of the application
59 void startApplication();
61 //! Returns main window (Desktop) of the application
62 XGUI_MainWindow* mainWindow() const
67 //! Returns selection manager object
68 XGUI_SelectionMgr* selector() const { return mySelector; }
71 XGUI_Displayer* displayer() const { return myDisplayer; }
73 //! ! Returns operation manager.
74 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
76 //! ! Returns an actions manager
77 XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
79 //! Returns property panel widget
80 XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
82 //! Returns context menu manager object
83 XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
85 //! Creates and adds a new workbench (menu group) with the given name and returns it
86 XGUI_Workbench* addWorkbench(const QString& theName);
88 //! Redefinition of Events_Listener method
89 virtual void processEvent(const Events_Message* theMessage);
91 //! Returns an object which provides interface to Salome Module (LightApp_Module)
92 XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
94 //! Provides an object which provides interface to Salome Viewer
95 XGUI_SalomeViewer* salomeViewer() const;
97 //! Returns true if the application works as SALOME module
98 bool isSalomeMode() const { return mySalomeConnector != 0; }
100 //! Returns Object browser
101 XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
103 void salomeViewerSelectionChanged();
105 XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
107 /// Returns the module connectory
108 /// \returns the instance of connector
109 XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
111 //! Returns icon name according to feature Id
112 static QString featureIcon(const std::string& theId);
114 //! Activates or deactivates a part
115 //! If PartPtr is Null pointer then PartSet will be activated
116 void activatePart(ResultPartPtr theFeature);
119 void deleteObjects(const QList<ObjectPtr>& theList);
121 //! Show the given features in 3d Viewer
122 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
124 ModuleBase_IModule* module() const { return myModule; }
127 void salomeViewerSelection();
128 void errorOccurred(const QString&);
131 void updateCommandStatus();
132 void updateCommandsOnViewSelection();
141 void onPreferences();
143 void showPropertyPanel();
144 void hidePropertyPanel();
145 void showObjectBrowser();
146 void hideObjectBrowser();
148 void onFeatureTriggered();
149 void changeCurrentDocument(ObjectPtr theObj);
151 void activateLastPart();
154 //Event-loop processing methods:
155 void addFeature(const Config_FeatureMessage*);
156 void connectWithOperation(ModuleBase_Operation* theOperation);
157 void saveDocument(QString theName);
159 void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
160 void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
161 void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
162 void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg);
164 QList<QAction*> getModuleCommands() const;
166 void displayAllResults();
167 void displayDocumentResults(DocumentPtr theDoc);
168 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
171 /// SLOT, that is called after the operation is started. Update workshop state according to
172 /// the started operation, e.g. visualizes the property panel and connect to it.
173 void onOperationStarted();
174 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
175 /// hides the property panel and udpate the command status.
176 /// \param theOpertion a stopped operation
177 void onOperationStopped(ModuleBase_Operation* theOperation);
179 void onContextMenuCommand(const QString& theId, bool isChecked);
181 void onWidgetValuesChanged();
183 void onStartWaiting();
188 void registerValidators() const;
191 ModuleBase_IModule* loadModule(const QString& theModule);
192 bool activateModule();
194 QDockWidget* createObjectBrowser(QWidget* theParent);
195 QDockWidget* createPropertyPanel(QWidget* theParent);
197 // Creates Dock widgets: Object browser and Property panel
198 void createDockWidgets();
200 XGUI_MainWindow* myMainWindow;
201 ModuleBase_IModule* myModule;
202 XGUI_ObjectsBrowser* myObjectBrowser;
203 XGUI_PropertyPanel* myPropertyPanel;
204 XGUI_SelectionMgr* mySelector;
205 XGUI_Displayer* myDisplayer;
206 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
207 XGUI_ActionsMgr* myActionsMgr;
208 XGUI_SalomeConnector* mySalomeConnector;
209 XGUI_ErrorDialog* myErrorDlg;
210 XGUI_ViewerProxy* myViewerProxy;
211 XGUI_ContextMenuMgr* myContextMenuMgr;
212 XGUI_ModuleConnector* myModuleConnector;
214 QString myCurrentDir;
215 static QMap<QString, QString> myIcons;