]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Workshop.cpp
Salome HOME
Issue #6 advanced command enable/disable state processing
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
1 #include "XGUI_Module.h"
2 #include "XGUI_Constants.h"
3 #include "XGUI_Command.h"
4 #include "XGUI_MainMenu.h"
5 #include "XGUI_MainWindow.h"
6 #include "XGUI_MenuGroupPanel.h"
7 #include "XGUI_Tools.h"
8 #include "XGUI_Workbench.h"
9 #include "XGUI_Workshop.h"
10 #include "XGUI_Viewer.h"
11 #include "ModuleBase_WidgetFactory.h"
12 #include "XGUI_SelectionMgr.h"
13 #include "XGUI_ObjectsBrowser.h"
14 #include "XGUI_Displayer.h"
15 #include "XGUI_OperationMgr.h"
16 #include "XGUI_SalomeConnector.h"
17 #include "XGUI_ActionsMgr.h"
18
19 #include <ModelAPI_PluginManager.h>
20 #include <ModelAPI_Feature.h>
21 #include <ModelAPI_Data.h>
22 #include <ModelAPI_AttributeDocRef.h>
23
24 #include <Events_Loop.h>
25 #include <ModuleBase_PropPanelOperation.h>
26 #include <ModuleBase_Operation.h>
27 #include <Config_FeatureMessage.h>
28 #include <Config_PointerMessage.h>
29
30 #include <QApplication>
31 #include <QFileDialog>
32 #include <QMessageBox>
33 #include <QMdiSubWindow>
34 #include <QPushButton>
35 #include <QDockWidget>
36 #include <QLayout>
37
38 #ifdef _DEBUG
39 #include <QDebug>
40 #endif
41
42 #ifdef WIN32
43 #include <windows.h>
44 #else
45 #include <dlfcn.h>
46 #endif
47
48 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
49   : QObject(), 
50   myPartSetModule(NULL),
51   mySalomeConnector(theConnector),
52   myPropertyPanelDock(0),
53   myObjectBrowser(0),
54   myDisplayer(0)
55 {
56   myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
57
58   // In SALOME viewer is accessible only when module is initialized
59   // and in SALOME mode myDisplayer object has to be created later
60   // So, displayer will be created on demand.
61
62   mySelector = new XGUI_SelectionMgr(this);
63   myOperationMgr = new XGUI_OperationMgr(this);
64   myActionsMgr = new XGUI_ActionsMgr(this);
65   connect(myOperationMgr, SIGNAL(operationStarted()),  this, SLOT(onOperationStarted()));
66   connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
67           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
68 }
69
70 //******************************************************
71 XGUI_Workshop::~XGUI_Workshop(void)
72 {
73 }
74
75 //******************************************************
76 void XGUI_Workshop::startApplication()
77 {
78   initMenu();
79   //Initialize event listening
80   Events_Loop* aLoop = Events_Loop::loop();
81   //TODO(sbh): Implement static method to extract event id [SEID]
82   Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
83   aLoop->registerListener(this, aFeatureId);
84   Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
85   aLoop->registerListener(this, aPartSetId);
86   activateModule();
87   if (myMainWindow) {
88     myMainWindow->show();
89     updateCommandStatus();
90   }
91   onNew();
92   // Testing of document creation
93   //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
94   //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
95   //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
96   //aPart->execute();
97   //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
98   //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
99   //aPoint2 = aMgr->rootDocument()->addFeature("Point");
100
101   //aPart = aMgr->rootDocument()->addFeature("Part");
102   //aPart->execute();
103 }
104
105 //******************************************************
106 void XGUI_Workshop::initMenu()
107 {
108   if (isSalomeMode()) {
109     // Create only Undo, Redo commands
110     salomeConnector()->addEditCommand("UNDO_CMD", 
111                                       tr("Undo"), tr("Undo last command"),
112                                       QIcon(":pictures/undo.png"), 
113                                       false, this, SLOT(onUndo()),
114                                       QKeySequence::Undo);
115     salomeConnector()->addEditCommand("REDO_CMD", 
116                                       tr("Redo"), tr("Redo last command"),
117                                       QIcon(":pictures/redo.png"), 
118                                       false, this, SLOT(onRedo()),
119                                       QKeySequence::Redo);
120     salomeConnector()->addEditMenuSeparator();
121     return;
122   }
123   XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
124
125   // File commands group
126   XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
127
128   XGUI_Command* aCommand;
129
130   aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
131                                 QIcon(":pictures/save.png"), QKeySequence::Save);
132   aCommand->connectTo(this, SLOT(onSave()));
133   //aCommand->disable();
134
135   aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
136                                 QIcon(":pictures/undo.png"), QKeySequence::Undo);
137   aCommand->connectTo(this, SLOT(onUndo()));
138
139   aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
140                                 QIcon(":pictures/redo.png"), QKeySequence::Redo);
141   aCommand->connectTo(this, SLOT(onRedo()));
142
143   aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
144                                 QIcon(":pictures/rebuild.png"));
145
146   aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
147                                 QIcon(":pictures/save.png"));
148   aCommand->connectTo(this, SLOT(onSaveAs()));
149   //aCommand->disable();
150
151   aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
152                                 QIcon(":pictures/open.png"), QKeySequence::Open);
153   aCommand->connectTo(this, SLOT(onOpen()));
154
155   //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
156   //                              QIcon(":pictures/new.png"), QKeySequence::New);
157   //aCommand->connectTo(this, SLOT(onNew()));
158
159   aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
160                                 QIcon(":pictures/close.png"), QKeySequence::Close);
161   aCommand->connectTo(this, SLOT(onExit()));
162
163 }
164
165 //******************************************************
166 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
167 {
168   XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
169   return aMenuBar->addWorkbench(theName);
170 }
171
172 //******************************************************
173 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
174 {
175   static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
176   if (theMessage->eventID() == aFeatureId) {
177     const Config_FeatureMessage* aFeatureMsg =
178         dynamic_cast<const Config_FeatureMessage*>(theMessage);
179     addFeature(aFeatureMsg);
180     return;
181   }
182   const Config_PointerMessage* aPartSetMsg =
183       dynamic_cast<const Config_PointerMessage*>(theMessage);
184   if (aPartSetMsg) {
185     ModuleBase_PropPanelOperation* anOperation =
186         (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
187
188     if (myOperationMgr->startOperation(anOperation)) {
189       if (anOperation->xmlRepresentation().isEmpty()) {
190         anOperation->commit();
191         updateCommandStatus();
192       }
193     }
194     return;
195   }
196
197 #ifdef _DEBUG
198   qDebug() << "XGUI_Workshop::ProcessEvent: "
199   << "Catch message, but it can not be processed.";
200 #endif
201
202 }
203
204 //******************************************************
205 void XGUI_Workshop::onOperationStarted()
206 {
207   ModuleBase_PropPanelOperation* aOperation =
208         (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
209
210   if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
211     connectWithOperation(aOperation);
212     QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
213     qDeleteAll(aPropWidget->children());
214
215     showPropertyPanel();
216
217     ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
218     aFactory.createWidget(aPropWidget);
219     setPropertyPannelTitle(aOperation->description());
220   }
221 }
222
223 //******************************************************
224 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
225 {
226   ModuleBase_PropPanelOperation* aOperation =
227         (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
228
229   if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
230     updateCommandStatus();
231   } else {
232     hidePropertyPanel();
233     updateCommandStatus();
234
235     if (myMainWindow) {
236       myActionsMgr->restoreCommandState();
237     }
238   }
239 }
240
241 /*
242  *
243  */
244 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
245 {
246   if (!theMessage) {
247 #ifdef _DEBUG
248     qDebug() << "XGUI_Workshop::addFeature: NULL message.";
249 #endif
250     return;
251   }
252   //Find or create Workbench
253   QString aWchName = QString::fromStdString(theMessage->workbenchId());
254   if (isSalomeMode()) {
255     salomeConnector()->addFeature(aWchName,
256                                   QString::fromStdString(theMessage->id()),
257                                   QString::fromStdString(theMessage->text()),
258                                   QString::fromStdString(theMessage->tooltip()),
259                                   QIcon(theMessage->icon().c_str()),
260                                   false, this, 
261                                   SLOT(onFeatureTriggered()), QKeySequence());
262   } else {
263     XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
264     XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
265     if (!aPage) {
266       aPage = addWorkbench(aWchName);
267     }
268     //Find or create Group
269     QString aGroupName = QString::fromStdString(theMessage->groupId());
270     XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
271     if (!aGroup) {
272       aGroup = aPage->addGroup(aGroupName);
273     }
274     bool isUsePropPanel = theMessage->isUseInput();
275     //Create feature...
276     XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
277                                                 QString::fromStdString(theMessage->text()),
278                                                 QString::fromStdString(theMessage->tooltip()),
279                                                 QIcon(theMessage->icon().c_str()),
280                                                 QKeySequence(), isUsePropPanel);
281     myActionsMgr->addCommand(aCommand);
282     myPartSetModule->featureCreated(aCommand);
283   }
284 }
285
286 /*
287  * Makes a signal/slot connections between Property Panel
288  * and given operation. The given operation becomes a
289  * current operation and previous operation if exists
290  */
291 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
292 {
293   QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
294   connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
295   QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
296   connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
297
298   QAction* aCommand = 0;
299   if (isSalomeMode()) {
300     aCommand = salomeConnector()->command(theOperation->operationId());
301   } else {
302     XGUI_MainMenu* aMenu = myMainWindow->menuObject();
303     aCommand = aMenu->feature(theOperation->operationId());
304   }
305   //Abort operation on uncheck the command
306   connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
307 }
308
309 //******************************************************
310 void XGUI_Workshop::onExit()
311 {
312   qApp->exit();
313 }
314
315 //******************************************************
316 void XGUI_Workshop::onNew()
317 {
318   QApplication::setOverrideCursor(Qt::WaitCursor);
319   if (objectBrowser() == 0) {
320     createDockWidgets();
321     mySelector->connectObjectBrowser(objectBrowser());
322   }
323   showObjectBrowser();
324   if (!isSalomeMode()) {
325     myMainWindow->showPythonConsole();
326     QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
327     aWnd->showMaximized();
328     updateCommandStatus();
329   }
330   QApplication::restoreOverrideCursor();
331 }
332
333 //******************************************************
334 void XGUI_Workshop::onOpen()
335 {
336   //QString aFileName = QFileDialog::getOpenFileName(mainWindow());
337   updateCommandStatus();
338 }
339
340 //******************************************************
341 void XGUI_Workshop::onSave()
342 {
343   updateCommandStatus();
344 }
345
346 //******************************************************
347 void XGUI_Workshop::onSaveAs()
348 {
349   //QString aFileName = QFileDialog::getSaveFileName(mainWindow());
350   updateCommandStatus();
351 }
352
353 //******************************************************
354 void XGUI_Workshop::onUndo()
355 {
356   objectBrowser()->setCurrentIndex(QModelIndex());
357   boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
358   boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
359   aDoc->undo();
360   updateCommandStatus();
361 }
362
363 //******************************************************
364 void XGUI_Workshop::onRedo()
365 {
366   objectBrowser()->setCurrentIndex(QModelIndex());
367   boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
368   boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
369   aDoc->redo();
370   updateCommandStatus();
371 }
372
373 //******************************************************
374 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
375 {
376   QString libName = library(theModule);
377   if (libName.isEmpty()) {
378     qWarning(
379     qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
380     return 0;
381   }
382
383   QString err;
384   CREATE_FUNC crtInst = 0;
385
386 #ifdef WIN32
387
388   HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
389   if (!modLib) {
390     LPVOID lpMsgBuf;
391     ::FormatMessage(
392         FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
393         0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
394     QString aMsg((char*) &lpMsgBuf);
395     err = QString("Failed to load  %1. %2").arg(libName).arg(aMsg);
396     ::LocalFree(lpMsgBuf);
397   } else {
398     crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
399     if (!crtInst) {
400       LPVOID lpMsgBuf;
401       ::FormatMessage(
402           FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
403               | FORMAT_MESSAGE_IGNORE_INSERTS,
404           0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
405       QString aMsg((char*) &lpMsgBuf);
406       err = QString("Failed to find  %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
407       ::LocalFree(lpMsgBuf);
408     }
409   }
410 #else
411   void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
412   if ( !modLib )
413   err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
414   else
415   {
416     crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
417     if ( !crtInst )
418     err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
419   }
420 #endif
421
422   XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
423
424   if (!err.isEmpty()) {
425     if (mainWindow() && mainWindow()->isVisible())
426       QMessageBox::warning(mainWindow(), tr("Error"), err);
427     else
428       qWarning( qPrintable( err ));
429   }
430   return aModule;
431 }
432
433 //******************************************************
434 bool XGUI_Workshop::activateModule()
435 {
436   myPartSetModule = loadModule("PartSet");
437   if (!myPartSetModule)
438     return false;
439   myPartSetModule->createFeatures();
440   return true;
441 }
442
443 //******************************************************
444 void XGUI_Workshop::updateCommandStatus()
445 {
446   if (isSalomeMode()) // TODO: update commands in SALOME
447     return;
448   XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
449
450   QList<XGUI_Command*> aCommands = aMenuBar->features();
451   QList<XGUI_Command*>::const_iterator aIt;
452
453   boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
454   if (aMgr->hasRootDocument()) {
455     XGUI_Command* aUndoCmd;
456     XGUI_Command* aRedoCmd;
457     for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
458       if ((*aIt)->id() == "UNDO_CMD")
459         aUndoCmd = (*aIt);
460       else if ((*aIt)->id() == "REDO_CMD")
461         aRedoCmd = (*aIt);
462       else // Enable all commands
463         (*aIt)->enable();
464     }
465     boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
466     aUndoCmd->setEnabled(aDoc->canUndo());
467     aRedoCmd->setEnabled(aDoc->canRedo());
468   } else {
469     for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
470       if ((*aIt)->id() == "NEW_CMD")
471         (*aIt)->enable();
472       else if ((*aIt)->id() == "EXIT_CMD")
473         (*aIt)->enable();
474       else 
475         (*aIt)->disable();
476     }
477   }
478 }
479
480 //******************************************************
481 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
482 {
483   QDockWidget* aObjDock = new QDockWidget(theParent);
484   aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
485   aObjDock->setWindowTitle(tr("Object browser"));
486   myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
487   aObjDock->setWidget(myObjectBrowser);
488   return aObjDock;
489 }
490
491 //******************************************************
492 QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
493 {
494   QDockWidget* aPropPanel = new QDockWidget(theParent);
495   aPropPanel->setWindowTitle(tr("Property Panel"));
496   QAction* aViewAct = aPropPanel->toggleViewAction();
497   aPropPanel->setObjectName(XGUI::PROP_PANEL);
498
499   QWidget* aContent = new QWidget(aPropPanel);
500   QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
501   aMainLay->setContentsMargins(3, 3, 3, 3);
502   aPropPanel->setWidget(aContent);
503
504   QFrame* aFrm = new QFrame(aContent);
505   aFrm->setFrameStyle(QFrame::Sunken);
506   aFrm->setFrameShape(QFrame::Panel);
507   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
508   aBtnLay->setContentsMargins(0, 0, 0, 0);
509   aMainLay->addWidget(aFrm);
510
511   QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
512   aBtn->setFlat(true);
513   aBtnLay->addWidget(aBtn);
514   aBtnLay->addStretch(1);
515   aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
516   aBtn->setObjectName(XGUI::PROP_PANEL_OK);
517   aBtn->setFlat(true);
518   aBtnLay->addWidget(aBtn);
519   aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
520   aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
521   aBtn->setFlat(true);
522   aBtnLay->addWidget(aBtn);
523
524   QWidget* aCustomWidget = new QWidget(aContent);
525   aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
526   aMainLay->addWidget(aCustomWidget);
527   aMainLay->addStretch(1);
528
529   return aPropPanel;
530 }
531
532 //******************************************************
533 void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
534 {
535   myPropertyPanelDock->setWindowTitle(theTitle);
536 }
537
538 //******************************************************
539 /*
540  * Creates dock widgets, places them in corresponding area
541  * and tabifies if necessary.
542  */
543 void XGUI_Workshop::createDockWidgets()
544 {
545   QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
546                                           myMainWindow;
547   QDockWidget* aObjDock = createObjectBrowser(aDesktop);
548   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
549   myPropertyPanelDock = createPropertyPanel(aDesktop);
550   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
551   hidePropertyPanel(); //<! Invisible by default
552   hideObjectBrowser();
553   aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
554 }
555
556 //******************************************************
557 void XGUI_Workshop::showPropertyPanel()
558 {
559   QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
560   //<! Restore ability to close panel from the window's menu
561   aViewAct->setEnabled(true);
562   myPropertyPanelDock->show();
563   myPropertyPanelDock->raise();
564 }
565
566 //******************************************************
567 void XGUI_Workshop::hidePropertyPanel()
568 {
569   QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
570   //<! Do not allow to show empty property panel
571   aViewAct->setEnabled(false);
572   myPropertyPanelDock->hide();
573 }
574
575 //******************************************************
576 void XGUI_Workshop::showObjectBrowser()
577 {
578   myObjectBrowser->parentWidget()->show();
579 }
580
581 //******************************************************
582 void XGUI_Workshop::hideObjectBrowser()
583 {
584   myObjectBrowser->parentWidget()->hide();
585 }
586
587 //******************************************************
588 void XGUI_Workshop::onFeatureTriggered()
589 {
590   QAction* aCmd = dynamic_cast<QAction*>(sender());
591   if (aCmd) {
592     QString aId = salomeConnector()->commandId(aCmd);
593     if (!aId.isNull())
594       myPartSetModule->launchOperation(aId);
595   }
596 }
597
598 //******************************************************
599 XGUI_Displayer* XGUI_Workshop::displayer() const
600 {
601   // In SALOME viewer is accessible only when module is initialized
602   // and in SALOME mode myDisplayer object has to be created later (on demand)
603   if (!myDisplayer) {
604     XGUI_Workshop* that = (XGUI_Workshop*)this;
605     that->myDisplayer = isSalomeMode() ?
606       new XGUI_Displayer(salomeConnector()->AISContext()):
607       new XGUI_Displayer(myMainWindow->viewer()->AISContext());
608   }
609   return myDisplayer;
610 }