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>
16 class XGUI_MainWindow;
19 class XGUI_SelectionMgr;
21 class XGUI_OperationMgr;
22 class XGUI_SalomeConnector;
23 class XGUI_ObjectsBrowser;
24 class XGUI_ActionsMgr;
25 class XGUI_ErrorDialog;
26 class XGUI_SalomeViewer;
27 class XGUI_ViewerProxy;
28 class XGUI_PropertyPanel;
29 class XGUI_ContextMenuMgr;
30 class XGUI_ModuleConnector;
32 class ModuleBase_Operation;
33 class ModuleBase_IModule;
34 class ModuleBase_IViewer;
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
74 XGUI_Displayer* displayer() const
79 //! ! Returns operation manager.
80 XGUI_OperationMgr* operationMgr() const
82 return myOperationMgr;
85 //! ! Returns an actions manager
86 XGUI_ActionsMgr* actionsMgr() const
92 //! Returns property panel widget
93 XGUI_PropertyPanel* propertyPanel() const
95 return myPropertyPanel;
98 //! Returns context menu manager object
99 XGUI_ContextMenuMgr* contextMenuMgr() const
101 return myContextMenuMgr;
104 //! Creates and adds a new workbench (menu group) with the given name and returns it
105 XGUI_Workbench* addWorkbench(const QString& theName);
107 //! Redefinition of Events_Listener method
108 virtual void processEvent(const boost::shared_ptr<Events_Message>& theMessage);
110 //! Returns an object which provides interface to Salome Module (LightApp_Module)
111 XGUI_SalomeConnector* salomeConnector() const
113 return mySalomeConnector;
116 //! Provides an object which provides interface to Salome Viewer
117 ModuleBase_IViewer* salomeViewer() const;
119 //! Returns true if the application works as SALOME module
120 bool isSalomeMode() const
122 return mySalomeConnector != 0;
125 //! Returns Object browser
126 XGUI_ObjectsBrowser* objectBrowser() const
128 return myObjectBrowser;
131 void salomeViewerSelectionChanged();
133 XGUI_ViewerProxy* viewer() const
135 return myViewerProxy;
138 /// Returns the module connectory
139 /// \returns the instance of connector
140 XGUI_ModuleConnector* moduleConnector() const
142 return myModuleConnector;
145 //! Returns icon name according to feature Id
146 static QString featureIcon(const std::string& theId);
148 //! Activates or deactivates a part
149 //! If PartPtr is Null pointer then PartSet will be activated
150 void activatePart(ResultPartPtr theFeature);
153 void deleteObjects(const QList<ObjectPtr>& theList);
155 //! Show the given features in 3d Viewer
156 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
158 //! Show the given features in 3d Viewer
159 void showOnlyObjects(const QList<ObjectPtr>& theList);
161 void setDisplayMode(const QList<ObjectPtr>& theList, int theMode);
163 ModuleBase_IModule* module() const
168 /// Returns current directory whic contains data files
169 QString currentDataDir() const { return myCurrentDir; }
171 /// Returns current directory whic contains data files
172 void setCurrentDataDir(const QString& theDir) { myCurrentDir = theDir; }
175 * Save the current document into a directory
176 * \param theName - path to the directory
177 * \param theFileNames - returned file names created in this directory
179 void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
182 * If there is an active (uncommited) operation shows a prompt to abort it
183 * and performs abortion if user agreed. Returns true if
184 * - operation aborted successfully
185 * - there is no active operation
187 bool isActiveOperationAborted();
190 void salomeViewerSelection();
191 void errorOccurred(const QString&);
194 void updateCommandStatus();
195 void updateCommandsOnViewSelection();
205 void onPreferences();
207 void showPropertyPanel();
208 void hidePropertyPanel();
209 void showObjectBrowser();
210 void hideObjectBrowser();
212 void onFeatureTriggered();
213 void changeCurrentDocument(ObjectPtr theObj);
215 void activateLastPart();
217 void closeDocument();
220 bool event(QEvent * theEvent);
221 //Event-loop processing methods:
222 void addFeature(const boost::shared_ptr<Config_FeatureMessage>&);
223 void connectWithOperation(ModuleBase_Operation* theOperation);
225 void onFeatureUpdatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
226 void onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
227 void onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
228 void onObjectDeletedMsg(const boost::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg);
230 void validateOperation(const QString& theOperationId);
232 QList<QAction*> getModuleCommands() const;
234 void displayAllResults();
235 void displayDocumentResults(DocumentPtr theDoc);
236 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
239 /// SLOT, that is called after the operation is started. Update workshop state according to
240 /// the started operation, e.g. visualizes the property panel and connect to it.
241 void onOperationStarted();
242 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
243 /// hides the property panel and udpate the command status.
244 /// \param theOpertion a stopped operation
245 void onOperationStopped(ModuleBase_Operation* theOperation);
247 void onContextMenuCommand(const QString& theId, bool isChecked);
249 void onWidgetValuesChanged();
251 void onStartWaiting();
256 void registerValidators() const;
258 ModuleBase_IModule* loadModule(const QString& theModule);
259 bool activateModule();
261 QDockWidget* createObjectBrowser(QWidget* theParent);
262 QDockWidget* createPropertyPanel(QWidget* theParent);
264 // Creates Dock widgets: Object browser and Property panel
265 void createDockWidgets();
267 XGUI_MainWindow* myMainWindow;
268 ModuleBase_IModule* myModule;
269 XGUI_ObjectsBrowser* myObjectBrowser;
270 XGUI_PropertyPanel* myPropertyPanel;
271 XGUI_SelectionMgr* mySelector;
272 XGUI_Displayer* myDisplayer;
273 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
274 XGUI_ActionsMgr* myActionsMgr;
275 XGUI_SalomeConnector* mySalomeConnector;
276 XGUI_ErrorDialog* myErrorDlg;
277 XGUI_ViewerProxy* myViewerProxy;
278 XGUI_ContextMenuMgr* myContextMenuMgr;
279 XGUI_ModuleConnector* myModuleConnector;
281 QString myCurrentDir;
282 static QMap<QString, QString> myIcons;
286 // Flag to check that part document is in process of activating
287 bool myPartActivating;