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 #include "XGUI_ErrorDialog.h"
20 #include <ModelAPI_PluginManager.h>
21 #include <ModelAPI_Feature.h>
22 #include <ModelAPI_Data.h>
23 #include <ModelAPI_AttributeDocRef.h>
25 #include <Events_Loop.h>
26 #include <Events_Error.h>
27 #include <ModuleBase_PropPanelOperation.h>
28 #include <ModuleBase_Operation.h>
29 #include <Config_FeatureMessage.h>
30 #include <Config_PointerMessage.h>
32 #include <QApplication>
33 #include <QFileDialog>
34 #include <QMessageBox>
35 #include <QMdiSubWindow>
36 #include <QPushButton>
37 #include <QDockWidget>
50 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
52 myCurrentFile(QString()),
53 myPartSetModule(NULL),
54 mySalomeConnector(theConnector),
55 myPropertyPanelDock(0),
59 myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
61 // In SALOME viewer is accessible only when module is initialized
62 // and in SALOME mode myDisplayer object has to be created later
63 // So, displayer will be created on demand.
65 mySelector = new XGUI_SelectionMgr(this);
66 connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
67 myOperationMgr = new XGUI_OperationMgr(this);
68 myActionsMgr = new XGUI_ActionsMgr(this);
69 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
71 connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
72 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
73 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
74 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
77 //******************************************************
78 XGUI_Workshop::~XGUI_Workshop(void)
82 //******************************************************
83 void XGUI_Workshop::startApplication()
86 //Initialize event listening
87 Events_Loop* aLoop = Events_Loop::loop();
88 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
89 //TODO(sbh): Implement static method to extract event id [SEID]
90 Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
91 aLoop->registerListener(this, aFeatureId);
92 Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
93 aLoop->registerListener(this, aPartSetId);
97 updateCommandStatus();
100 // Testing of document creation
101 //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
102 //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
103 //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
105 //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
106 //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
107 //aPoint2 = aMgr->rootDocument()->addFeature("Point");
109 //aPart = aMgr->rootDocument()->addFeature("Part");
113 //******************************************************
114 void XGUI_Workshop::initMenu()
116 if (isSalomeMode()) {
117 // Create only Undo, Redo commands
118 salomeConnector()->addEditCommand("UNDO_CMD",
119 tr("Undo"), tr("Undo last command"),
120 QIcon(":pictures/undo.png"),
121 false, this, SLOT(onUndo()),
123 salomeConnector()->addEditCommand("REDO_CMD",
124 tr("Redo"), tr("Redo last command"),
125 QIcon(":pictures/redo.png"),
126 false, this, SLOT(onRedo()),
128 salomeConnector()->addEditMenuSeparator();
131 XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
133 // File commands group
134 XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
136 XGUI_Command* aCommand;
138 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
139 QIcon(":pictures/save.png"), QKeySequence::Save);
140 aCommand->connectTo(this, SLOT(onSave()));
141 //aCommand->disable();
143 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
144 QIcon(":pictures/undo.png"), QKeySequence::Undo);
145 aCommand->connectTo(this, SLOT(onUndo()));
147 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
148 QIcon(":pictures/redo.png"), QKeySequence::Redo);
149 aCommand->connectTo(this, SLOT(onRedo()));
151 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
152 QIcon(":pictures/rebuild.png"));
154 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
155 QIcon(":pictures/save.png"));
156 aCommand->connectTo(this, SLOT(onSaveAs()));
157 //aCommand->disable();
159 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
160 QIcon(":pictures/open.png"), QKeySequence::Open);
161 aCommand->connectTo(this, SLOT(onOpen()));
163 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
164 // QIcon(":pictures/new.png"), QKeySequence::New);
165 //aCommand->connectTo(this, SLOT(onNew()));
167 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
168 QIcon(":pictures/close.png"), QKeySequence::Close);
169 aCommand->connectTo(this, SLOT(onExit()));
173 //******************************************************
174 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
176 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
177 return aMenuBar->addWorkbench(theName);
180 //******************************************************
181 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
183 static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
184 if (theMessage->eventID() == aFeatureId) {
185 const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
186 addFeature(aFeatureMsg);
189 const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
191 ModuleBase_PropPanelOperation* anOperation =
192 (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
194 if (myOperationMgr->startOperation(anOperation)) {
195 if (anOperation->xmlRepresentation().isEmpty()) {
196 anOperation->commit();
197 updateCommandStatus();
202 const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
204 emit errorOccurred(QString::fromLatin1(anAppError->description()));
207 myErrorDlg->activateWindow();
211 qDebug() << "XGUI_Workshop::ProcessEvent: "
212 << "Catch message, but it can not be processed.";
217 //******************************************************
218 void XGUI_Workshop::onOperationStarted()
220 ModuleBase_PropPanelOperation* aOperation =
221 (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
223 if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
224 connectWithOperation(aOperation);
225 QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
226 qDeleteAll(aPropWidget->children());
230 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
231 aFactory.createWidget(aPropWidget);
232 setPropertyPannelTitle(aOperation->description());
236 //******************************************************
237 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
239 ModuleBase_PropPanelOperation* aOperation =
240 (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
242 if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
243 updateCommandStatus();
246 updateCommandStatus();
249 myActionsMgr->restoreCommandState();
257 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
261 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
265 //Find or create Workbench
266 QString aWchName = QString::fromStdString(theMessage->workbenchId());
267 if (isSalomeMode()) {
268 salomeConnector()->addFeature(aWchName,
269 QString::fromStdString(theMessage->id()),
270 QString::fromStdString(theMessage->text()),
271 QString::fromStdString(theMessage->tooltip()),
272 QIcon(theMessage->icon().c_str()),
274 SLOT(onFeatureTriggered()), QKeySequence());
276 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
277 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
279 aPage = addWorkbench(aWchName);
281 //Find or create Group
282 QString aGroupName = QString::fromStdString(theMessage->groupId());
283 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
285 aGroup = aPage->addGroup(aGroupName);
287 bool isUsePropPanel = theMessage->isUseInput();
289 XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
290 QString::fromStdString(theMessage->text()),
291 QString::fromStdString(theMessage->tooltip()),
292 QIcon(theMessage->icon().c_str()),
293 QKeySequence(), isUsePropPanel);
294 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
295 aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
296 myActionsMgr->addCommand(aCommand);
297 myPartSetModule->featureCreated(aCommand);
302 * Makes a signal/slot connections between Property Panel
303 * and given operation. The given operation becomes a
304 * current operation and previous operation if exists
306 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
308 QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
309 connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
310 QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
311 connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
313 QAction* aCommand = 0;
314 if (isSalomeMode()) {
315 aCommand = salomeConnector()->command(theOperation->operationId());
317 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
318 aCommand = aMenu->feature(theOperation->operationId());
320 //Abort operation on uncheck the command
321 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
325 * Saves document with given name.
327 void XGUI_Workshop::saveDocument(QString theName)
329 QApplication::restoreOverrideCursor();
330 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
331 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
332 aDoc->save(theName.toLatin1().constData());
333 QApplication::restoreOverrideCursor();
336 //******************************************************
337 void XGUI_Workshop::onExit()
339 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
340 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
341 if(aDoc->isModified()) {
342 int anAnswer = QMessageBox::question(
343 myMainWindow, tr("Save current file"),
344 tr("The document is modified, save before exit?"),
345 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
346 if(anAnswer == QMessageBox::Save) {
348 } else if (anAnswer == QMessageBox::Cancel) {
355 //******************************************************
356 void XGUI_Workshop::onNew()
358 QApplication::setOverrideCursor(Qt::WaitCursor);
359 if (objectBrowser() == 0) {
361 mySelector->connectViewers();
364 if (!isSalomeMode()) {
365 myMainWindow->showPythonConsole();
366 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
367 aWnd->showMaximized();
368 updateCommandStatus();
370 QApplication::restoreOverrideCursor();
373 //******************************************************
374 void XGUI_Workshop::onOpen()
376 //save current file before close if modified
377 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
378 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
379 if(aDoc->isModified()) {
380 //TODO(sbh): re-launch the app?
381 int anAnswer = QMessageBox::question(
382 myMainWindow, tr("Save current file"),
383 tr("The document is modified, save before opening another?"),
384 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
385 if(anAnswer == QMessageBox::Save) {
387 } else if (anAnswer == QMessageBox::Cancel) {
394 //show file dialog, check if readable and open
395 myCurrentFile = QFileDialog::getOpenFileName(mainWindow());
396 if(myCurrentFile.isEmpty())
398 QFileInfo aFileInfo(myCurrentFile);
399 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
400 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
404 QApplication::setOverrideCursor(Qt::WaitCursor);
405 aDoc->load(myCurrentFile.toLatin1().constData());
406 QApplication::restoreOverrideCursor();
407 updateCommandStatus();
410 //******************************************************
411 void XGUI_Workshop::onSave()
413 if(myCurrentFile.isEmpty()) {
417 saveDocument(myCurrentFile);
418 updateCommandStatus();
421 //******************************************************
422 void XGUI_Workshop::onSaveAs()
424 QString aTemp = myCurrentFile;
425 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
426 if(myCurrentFile.isEmpty()) {
427 myCurrentFile = aTemp;
430 QFileInfo aFileInfo(myCurrentFile);
431 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
432 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
438 //******************************************************
439 void XGUI_Workshop::onUndo()
441 objectBrowser()->setCurrentIndex(QModelIndex());
442 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
443 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
445 updateCommandStatus();
448 //******************************************************
449 void XGUI_Workshop::onRedo()
451 objectBrowser()->setCurrentIndex(QModelIndex());
452 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
453 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
455 updateCommandStatus();
458 //******************************************************
459 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
461 QString libName = library(theModule);
462 if (libName.isEmpty()) {
464 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
469 CREATE_FUNC crtInst = 0;
473 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
477 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
478 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
479 QString aMsg((char*) &lpMsgBuf);
480 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
481 ::LocalFree(lpMsgBuf);
483 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
487 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
488 | FORMAT_MESSAGE_IGNORE_INSERTS,
489 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
490 QString aMsg((char*) &lpMsgBuf);
491 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
492 ::LocalFree(lpMsgBuf);
496 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
498 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
501 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
503 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
507 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
509 if (!err.isEmpty()) {
510 if (mainWindow() && mainWindow()->isVisible())
511 QMessageBox::warning(mainWindow(), tr("Error"), err);
513 qWarning( qPrintable( err ));
518 //******************************************************
519 bool XGUI_Workshop::activateModule()
521 myPartSetModule = loadModule("PartSet");
522 if (!myPartSetModule)
524 myPartSetModule->createFeatures();
528 //******************************************************
529 void XGUI_Workshop::updateCommandStatus()
531 if (isSalomeMode()) // TODO: update commands in SALOME
533 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
535 QList<XGUI_Command*> aCommands = aMenuBar->features();
536 QList<XGUI_Command*>::const_iterator aIt;
538 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
539 if (aMgr->hasRootDocument()) {
540 XGUI_Command* aUndoCmd;
541 XGUI_Command* aRedoCmd;
542 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
543 if ((*aIt)->id() == "UNDO_CMD")
545 else if ((*aIt)->id() == "REDO_CMD")
547 else // Enable all commands
550 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
551 aUndoCmd->setEnabled(aDoc->canUndo());
552 aRedoCmd->setEnabled(aDoc->canRedo());
554 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
555 if ((*aIt)->id() == "NEW_CMD")
557 else if ((*aIt)->id() == "EXIT_CMD")
565 //******************************************************
566 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
568 QDockWidget* aObjDock = new QDockWidget(theParent);
569 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
570 aObjDock->setWindowTitle(tr("Object browser"));
571 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
572 aObjDock->setWidget(myObjectBrowser);
576 //******************************************************
577 QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
579 QDockWidget* aPropPanel = new QDockWidget(theParent);
580 aPropPanel->setWindowTitle(tr("Property Panel"));
581 QAction* aViewAct = aPropPanel->toggleViewAction();
582 aPropPanel->setObjectName(XGUI::PROP_PANEL);
584 QWidget* aContent = new QWidget(aPropPanel);
585 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
586 aMainLay->setContentsMargins(3, 3, 3, 3);
587 aPropPanel->setWidget(aContent);
589 QFrame* aFrm = new QFrame(aContent);
590 aFrm->setFrameStyle(QFrame::Sunken);
591 aFrm->setFrameShape(QFrame::Panel);
592 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
593 aBtnLay->setContentsMargins(0, 0, 0, 0);
594 aMainLay->addWidget(aFrm);
596 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
598 aBtnLay->addWidget(aBtn);
599 aBtnLay->addStretch(1);
600 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
601 aBtn->setObjectName(XGUI::PROP_PANEL_OK);
603 aBtnLay->addWidget(aBtn);
604 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
605 aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
607 aBtnLay->addWidget(aBtn);
609 QWidget* aCustomWidget = new QWidget(aContent);
610 aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
611 aMainLay->addWidget(aCustomWidget);
612 aMainLay->addStretch(1);
617 //******************************************************
618 void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
620 myPropertyPanelDock->setWindowTitle(theTitle);
623 //******************************************************
625 * Creates dock widgets, places them in corresponding area
626 * and tabifies if necessary.
628 void XGUI_Workshop::createDockWidgets()
630 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
632 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
633 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
634 myPropertyPanelDock = createPropertyPanel(aDesktop);
635 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
636 hidePropertyPanel(); //<! Invisible by default
638 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
641 //******************************************************
642 void XGUI_Workshop::showPropertyPanel()
644 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
645 //<! Restore ability to close panel from the window's menu
646 aViewAct->setEnabled(true);
647 myPropertyPanelDock->show();
648 myPropertyPanelDock->raise();
651 //******************************************************
652 void XGUI_Workshop::hidePropertyPanel()
654 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
655 //<! Do not allow to show empty property panel
656 aViewAct->setEnabled(false);
657 myPropertyPanelDock->hide();
660 //******************************************************
661 void XGUI_Workshop::showObjectBrowser()
663 myObjectBrowser->parentWidget()->show();
666 //******************************************************
667 void XGUI_Workshop::hideObjectBrowser()
669 myObjectBrowser->parentWidget()->hide();
672 //******************************************************
673 void XGUI_Workshop::onFeatureTriggered()
675 QAction* aCmd = dynamic_cast<QAction*>(sender());
677 QString aId = salomeConnector()->commandId(aCmd);
679 myPartSetModule->launchOperation(aId);
683 //******************************************************
684 XGUI_Displayer* XGUI_Workshop::displayer() const
686 // In SALOME viewer is accessible only when module is initialized
687 // and in SALOME mode myDisplayer object has to be created later (on demand)
689 XGUI_Workshop* that = (XGUI_Workshop*)this;
690 that->myDisplayer = isSalomeMode() ?
691 new XGUI_Displayer(salomeConnector()->AISContext()):
692 new XGUI_Displayer(myMainWindow->viewer()->AISContext());
697 //******************************************************
698 void XGUI_Workshop::changeCurrentDocument()
700 QFeatureList aFeatures = objectBrowser()->selectedFeatures();
702 // Set current document
703 if (aFeatures.size() > 0) {
704 FeaturePtr aFeature = aFeatures.first();
706 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
707 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
709 aMgr->setCurrentDocument(aDocRef->value());
713 //******************************************************
714 void XGUI_Workshop::salomeViewerSelectionChanged()
716 emit salomeViewerSelection();