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 myActionsMgr->addCommand(aCommand);
295 myPartSetModule->featureCreated(aCommand);
300 * Makes a signal/slot connections between Property Panel
301 * and given operation. The given operation becomes a
302 * current operation and previous operation if exists
304 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
306 QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
307 connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
308 QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
309 connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
311 QAction* aCommand = 0;
312 if (isSalomeMode()) {
313 aCommand = salomeConnector()->command(theOperation->operationId());
315 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
316 aCommand = aMenu->feature(theOperation->operationId());
318 //Abort operation on uncheck the command
319 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
323 * Saves document with given name.
325 void XGUI_Workshop::saveDocument(QString theName)
327 QApplication::restoreOverrideCursor();
328 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
329 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
330 aDoc->save(theName.toLatin1().constData());
331 QApplication::restoreOverrideCursor();
334 //******************************************************
335 void XGUI_Workshop::onExit()
337 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
338 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
339 if(aDoc->isModified()) {
340 int anAnswer = QMessageBox::question(
341 myMainWindow, tr("Save current file"),
342 tr("The document is modified, save before exit?"),
343 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
344 if(anAnswer == QMessageBox::Save) {
346 } else if (anAnswer == QMessageBox::Cancel) {
353 //******************************************************
354 void XGUI_Workshop::onNew()
356 QApplication::setOverrideCursor(Qt::WaitCursor);
357 if (objectBrowser() == 0) {
359 mySelector->connectViewers();
362 if (!isSalomeMode()) {
363 myMainWindow->showPythonConsole();
364 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
365 aWnd->showMaximized();
366 updateCommandStatus();
368 QApplication::restoreOverrideCursor();
371 //******************************************************
372 void XGUI_Workshop::onOpen()
374 //save current file before close if modified
375 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
376 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
377 if(aDoc->isModified()) {
378 //TODO(sbh): re-launch the app?
379 int anAnswer = QMessageBox::question(
380 myMainWindow, tr("Save current file"),
381 tr("The document is modified, save before opening another?"),
382 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
383 if(anAnswer == QMessageBox::Save) {
385 } else if (anAnswer == QMessageBox::Cancel) {
392 //show file dialog, check if readable and open
393 myCurrentFile = QFileDialog::getOpenFileName(mainWindow());
394 if(myCurrentFile.isEmpty())
396 QFileInfo aFileInfo(myCurrentFile);
397 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
398 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
402 QApplication::setOverrideCursor(Qt::WaitCursor);
403 aDoc->load(myCurrentFile.toLatin1().constData());
404 QApplication::restoreOverrideCursor();
405 updateCommandStatus();
408 //******************************************************
409 void XGUI_Workshop::onSave()
411 if(myCurrentFile.isEmpty()) {
415 saveDocument(myCurrentFile);
416 updateCommandStatus();
419 //******************************************************
420 void XGUI_Workshop::onSaveAs()
422 QString aTemp = myCurrentFile;
423 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
424 if(myCurrentFile.isEmpty()) {
425 myCurrentFile = aTemp;
428 QFileInfo aFileInfo(myCurrentFile);
429 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
430 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
436 //******************************************************
437 void XGUI_Workshop::onUndo()
439 objectBrowser()->setCurrentIndex(QModelIndex());
440 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
441 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
443 updateCommandStatus();
446 //******************************************************
447 void XGUI_Workshop::onRedo()
449 objectBrowser()->setCurrentIndex(QModelIndex());
450 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
451 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
453 updateCommandStatus();
456 //******************************************************
457 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
459 QString libName = library(theModule);
460 if (libName.isEmpty()) {
462 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
467 CREATE_FUNC crtInst = 0;
471 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
475 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
476 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
477 QString aMsg((char*) &lpMsgBuf);
478 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
479 ::LocalFree(lpMsgBuf);
481 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
485 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
486 | FORMAT_MESSAGE_IGNORE_INSERTS,
487 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
488 QString aMsg((char*) &lpMsgBuf);
489 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
490 ::LocalFree(lpMsgBuf);
494 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
496 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
499 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
501 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
505 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
507 if (!err.isEmpty()) {
508 if (mainWindow() && mainWindow()->isVisible())
509 QMessageBox::warning(mainWindow(), tr("Error"), err);
511 qWarning( qPrintable( err ));
516 //******************************************************
517 bool XGUI_Workshop::activateModule()
519 myPartSetModule = loadModule("PartSet");
520 if (!myPartSetModule)
522 myPartSetModule->createFeatures();
526 //******************************************************
527 void XGUI_Workshop::updateCommandStatus()
529 if (isSalomeMode()) // TODO: update commands in SALOME
531 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
533 QList<XGUI_Command*> aCommands = aMenuBar->features();
534 QList<XGUI_Command*>::const_iterator aIt;
536 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
537 if (aMgr->hasRootDocument()) {
538 XGUI_Command* aUndoCmd;
539 XGUI_Command* aRedoCmd;
540 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
541 if ((*aIt)->id() == "UNDO_CMD")
543 else if ((*aIt)->id() == "REDO_CMD")
545 else // Enable all commands
548 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
549 aUndoCmd->setEnabled(aDoc->canUndo());
550 aRedoCmd->setEnabled(aDoc->canRedo());
552 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
553 if ((*aIt)->id() == "NEW_CMD")
555 else if ((*aIt)->id() == "EXIT_CMD")
563 //******************************************************
564 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
566 QDockWidget* aObjDock = new QDockWidget(theParent);
567 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
568 aObjDock->setWindowTitle(tr("Object browser"));
569 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
570 aObjDock->setWidget(myObjectBrowser);
574 //******************************************************
575 QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
577 QDockWidget* aPropPanel = new QDockWidget(theParent);
578 aPropPanel->setWindowTitle(tr("Property Panel"));
579 QAction* aViewAct = aPropPanel->toggleViewAction();
580 aPropPanel->setObjectName(XGUI::PROP_PANEL);
582 QWidget* aContent = new QWidget(aPropPanel);
583 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
584 aMainLay->setContentsMargins(3, 3, 3, 3);
585 aPropPanel->setWidget(aContent);
587 QFrame* aFrm = new QFrame(aContent);
588 aFrm->setFrameStyle(QFrame::Sunken);
589 aFrm->setFrameShape(QFrame::Panel);
590 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
591 aBtnLay->setContentsMargins(0, 0, 0, 0);
592 aMainLay->addWidget(aFrm);
594 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
596 aBtnLay->addWidget(aBtn);
597 aBtnLay->addStretch(1);
598 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
599 aBtn->setObjectName(XGUI::PROP_PANEL_OK);
601 aBtnLay->addWidget(aBtn);
602 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
603 aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
605 aBtnLay->addWidget(aBtn);
607 QWidget* aCustomWidget = new QWidget(aContent);
608 aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
609 aMainLay->addWidget(aCustomWidget);
610 aMainLay->addStretch(1);
615 //******************************************************
616 void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
618 myPropertyPanelDock->setWindowTitle(theTitle);
621 //******************************************************
623 * Creates dock widgets, places them in corresponding area
624 * and tabifies if necessary.
626 void XGUI_Workshop::createDockWidgets()
628 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
630 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
631 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
632 myPropertyPanelDock = createPropertyPanel(aDesktop);
633 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
634 hidePropertyPanel(); //<! Invisible by default
636 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
639 //******************************************************
640 void XGUI_Workshop::showPropertyPanel()
642 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
643 //<! Restore ability to close panel from the window's menu
644 aViewAct->setEnabled(true);
645 myPropertyPanelDock->show();
646 myPropertyPanelDock->raise();
649 //******************************************************
650 void XGUI_Workshop::hidePropertyPanel()
652 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
653 //<! Do not allow to show empty property panel
654 aViewAct->setEnabled(false);
655 myPropertyPanelDock->hide();
658 //******************************************************
659 void XGUI_Workshop::showObjectBrowser()
661 myObjectBrowser->parentWidget()->show();
664 //******************************************************
665 void XGUI_Workshop::hideObjectBrowser()
667 myObjectBrowser->parentWidget()->hide();
670 //******************************************************
671 void XGUI_Workshop::onFeatureTriggered()
673 QAction* aCmd = dynamic_cast<QAction*>(sender());
675 QString aId = salomeConnector()->commandId(aCmd);
677 myPartSetModule->launchOperation(aId);
681 //******************************************************
682 XGUI_Displayer* XGUI_Workshop::displayer() const
684 // In SALOME viewer is accessible only when module is initialized
685 // and in SALOME mode myDisplayer object has to be created later (on demand)
687 XGUI_Workshop* that = (XGUI_Workshop*)this;
688 that->myDisplayer = isSalomeMode() ?
689 new XGUI_Displayer(salomeConnector()->AISContext()):
690 new XGUI_Displayer(myMainWindow->viewer()->AISContext());
695 //******************************************************
696 void XGUI_Workshop::changeCurrentDocument()
698 QFeatureList aFeatures = objectBrowser()->selectedFeatures();
700 // Set current document
701 if (aFeatures.size() > 0) {
702 FeaturePtr aFeature = aFeatures.first();
704 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
705 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
707 aMgr->setCurrentDocument(aDocRef->value());
711 //******************************************************
712 void XGUI_Workshop::salomeViewerSelectionChanged()
714 emit salomeViewerSelection();