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_SalomeViewer.h"
18 #include "XGUI_ActionsMgr.h"
19 #include "XGUI_ErrorDialog.h"
20 #include "XGUI_ViewerProxy.h"
21 #include "XGUI_PropertyPanel.h"
22 #include "XGUI_ContextMenuMgr.h"
24 #include <Model_Events.h>
25 #include <ModelAPI_PluginManager.h>
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_Data.h>
28 #include <ModelAPI_AttributeDocRef.h>
30 #include <Events_Loop.h>
31 #include <Events_Error.h>
32 #include <ModuleBase_Operation.h>
33 #include <ModuleBase_Operation.h>
34 #include <ModuleBase_OperationDescription.h>
35 #include <Config_Common.h>
36 #include <Config_FeatureMessage.h>
37 #include <Config_PointerMessage.h>
38 #include <Config_ModuleReader.h>
40 #include <QApplication>
41 #include <QFileDialog>
42 #include <QMessageBox>
43 #include <QMdiSubWindow>
44 #include <QPushButton>
45 #include <QDockWidget>
59 QMap<QString, QString> XGUI_Workshop::myIcons;
61 QString XGUI_Workshop::featureIcon(const std::string& theId)
63 QString aId(theId.c_str());
64 if (myIcons.contains(aId))
69 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
71 myCurrentFile(QString()),
72 myPartSetModule(NULL),
73 mySalomeConnector(theConnector),
78 myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
80 myDisplayer = new XGUI_Displayer(this);
82 mySelector = new XGUI_SelectionMgr(this);
84 myOperationMgr = new XGUI_OperationMgr(this);
85 myActionsMgr = new XGUI_ActionsMgr(this);
86 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
87 myContextMenuMgr = new XGUI_ContextMenuMgr(this);
88 connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)),
89 this, SLOT(onContextMenuCommand(const QString&, bool)));
91 myViewerProxy = new XGUI_ViewerProxy(this);
93 connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
94 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
95 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
96 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
99 //******************************************************
100 XGUI_Workshop::~XGUI_Workshop(void)
104 //******************************************************
105 void XGUI_Workshop::startApplication()
108 //Initialize event listening
109 Events_Loop* aLoop = Events_Loop::loop();
110 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
111 //TODO(sbh): Implement static method to extract event id [SEID]
112 Events_ID aFeatureId = aLoop->eventByName(EVENT_FEATURE_LOADED);
113 aLoop->registerListener(this, aFeatureId);
114 Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
115 aLoop->registerListener(this, aPartSetId);
116 Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
117 aLoop->registerListener(this, aFeatureUpdatedId);
120 myMainWindow->show();
121 updateCommandStatus();
126 //******************************************************
127 void XGUI_Workshop::initMenu()
129 if (isSalomeMode()) {
130 // Create only Undo, Redo commands
131 salomeConnector()->addEditCommand("UNDO_CMD",
132 tr("Undo"), tr("Undo last command"),
133 QIcon(":pictures/undo.png"),
134 false, this, SLOT(onUndo()),
136 salomeConnector()->addEditCommand("REDO_CMD",
137 tr("Redo"), tr("Redo last command"),
138 QIcon(":pictures/redo.png"),
139 false, this, SLOT(onRedo()),
141 salomeConnector()->addEditMenuSeparator();
144 XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
146 // File commands group
147 XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
149 XGUI_Command* aCommand;
151 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
152 QIcon(":pictures/save.png"), QKeySequence::Save);
153 aCommand->connectTo(this, SLOT(onSave()));
154 //aCommand->disable();
156 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
157 QIcon(":pictures/undo.png"), QKeySequence::Undo);
158 aCommand->connectTo(this, SLOT(onUndo()));
160 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
161 QIcon(":pictures/redo.png"), QKeySequence::Redo);
162 aCommand->connectTo(this, SLOT(onRedo()));
164 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
165 QIcon(":pictures/rebuild.png"));
167 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
168 QIcon(":pictures/save.png"));
169 aCommand->connectTo(this, SLOT(onSaveAs()));
170 //aCommand->disable();
172 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
173 QIcon(":pictures/open.png"), QKeySequence::Open);
174 aCommand->connectTo(this, SLOT(onOpen()));
176 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
177 // QIcon(":pictures/new.png"), QKeySequence::New);
178 //aCommand->connectTo(this, SLOT(onNew()));
180 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
181 QIcon(":pictures/close.png"), QKeySequence::Close);
182 aCommand->connectTo(this, SLOT(onExit()));
184 myContextMenuMgr->createActions();
187 //******************************************************
188 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
190 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
191 return aMenuBar->addWorkbench(theName);
194 //******************************************************
195 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
197 //A message to start feature creation received.
198 static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
199 if (theMessage->eventID() == aFeatureLoadedId) {
200 const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
201 addFeature(aFeatureMsg);
204 //Update property panel on corresponding message. If there is no current operation (no
205 //property panel), or received message has different feature to the current - do nothing.
206 static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);
207 if (theMessage->eventID() == aFeatureUpdatedId && myOperationMgr->hasOperation())
209 const Model_FeatureUpdatedMessage* anUpdateMsg =
210 dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
211 boost::shared_ptr<ModelAPI_Feature> aNewFeature = anUpdateMsg->feature();
212 boost::shared_ptr<ModelAPI_Feature> aCurrentFeature = myOperationMgr->currentOperation()->feature();
213 if(aNewFeature == aCurrentFeature) {
214 myPropertyPanel->updateContentWidget(aCurrentFeature);
217 //An operation passed by message. Start it, process and commit.
218 const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
220 ModuleBase_Operation* anOperation =
221 (ModuleBase_Operation*)(aPartSetMsg->pointer());
223 if (myOperationMgr->startOperation(anOperation)) {
224 myPropertyPanel->updateContentWidget(anOperation->feature());
225 if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
226 anOperation->commit();
227 updateCommandStatus();
232 //Show error dialog if error message received.
233 const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
235 emit errorOccurred(QString::fromLatin1(anAppError->description()));
238 myErrorDlg->activateWindow();
243 //******************************************************
244 void XGUI_Workshop::onOperationStarted()
246 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
248 if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
249 connectWithOperation(aOperation);
253 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
254 QWidget* aContent = myPropertyPanel->contentWidget();
255 qDeleteAll(aContent->children());
256 aFactory.createWidget(aContent);
257 myPropertyPanel->setModelWidgets(aFactory.getModelWidgets());
258 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
262 //******************************************************
263 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
265 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
267 //!< No need for property panel
268 updateCommandStatus();
270 if(myOperationMgr->operationsCount() > 1) {
271 myActionsMgr->updateAction(theOperation->getDescription()->operationId());
274 if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) {
275 myActionsMgr->restoreCommandState();
282 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
286 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
290 // Remember features icons
291 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
293 //Find or create Workbench
294 QString aWchName = QString::fromStdString(theMessage->workbenchId());
295 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
296 bool isUsePropPanel = theMessage->isUseInput();
297 if (isSalomeMode()) {
298 QString aId = QString::fromStdString(theMessage->id());
299 salomeConnector()->addFeature(aWchName,
300 QString::fromStdString(theMessage->id()),
302 QString::fromStdString(theMessage->tooltip()),
303 QIcon(theMessage->icon().c_str()),
304 isUsePropPanel, this,
305 SLOT(onFeatureTriggered()), QKeySequence());
306 myActionsMgr->addCommand(aId, salomeConnector()->command(aId));
307 salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
311 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
312 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
314 aPage = addWorkbench(aWchName);
316 //Find or create Group
317 QString aGroupName = QString::fromStdString(theMessage->groupId());
318 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
320 aGroup = aPage->addGroup(aGroupName);
323 XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
324 QString::fromStdString(theMessage->text()),
325 QString::fromStdString(theMessage->tooltip()),
326 QIcon(theMessage->icon().c_str()),
327 QKeySequence(), isUsePropPanel);
328 aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
329 myActionsMgr->addCommand(aCommand);
330 myPartSetModule->featureCreated(aCommand);
335 * Makes a signal/slot connections between Property Panel
336 * and given operation. The given operation becomes a
337 * current operation and previous operation if exists
339 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
341 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
342 connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
343 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
344 connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
346 QAction* aCommand = 0;
347 if (isSalomeMode()) {
348 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
350 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
351 aCommand = aMenu->feature(theOperation->getDescription()->operationId());
353 //Abort operation on uncheck the command
354 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
358 * Saves document with given name.
360 void XGUI_Workshop::saveDocument(QString theName)
362 QApplication::restoreOverrideCursor();
363 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
364 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
365 aDoc->save(theName.toLatin1().constData());
366 QApplication::restoreOverrideCursor();
369 //******************************************************
370 void XGUI_Workshop::onExit()
372 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
373 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
374 if(aDoc->isModified()) {
375 int anAnswer = QMessageBox::question(
376 myMainWindow, tr("Save current file"),
377 tr("The document is modified, save before exit?"),
378 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
379 if(anAnswer == QMessageBox::Save) {
381 } else if (anAnswer == QMessageBox::Cancel) {
388 //******************************************************
389 void XGUI_Workshop::onNew()
391 QApplication::setOverrideCursor(Qt::WaitCursor);
392 if (objectBrowser() == 0) {
394 mySelector->connectViewers();
396 myViewerProxy->connectToViewer();
398 if (!isSalomeMode()) {
399 myMainWindow->showPythonConsole();
400 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
401 aWnd->showMaximized();
402 updateCommandStatus();
404 QApplication::restoreOverrideCursor();
407 //******************************************************
408 void XGUI_Workshop::onOpen()
410 //save current file before close if modified
411 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
412 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
413 if(aDoc->isModified()) {
414 //TODO(sbh): re-launch the app?
415 int anAnswer = QMessageBox::question(
416 myMainWindow, tr("Save current file"),
417 tr("The document is modified, save before opening another?"),
418 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
419 if(anAnswer == QMessageBox::Save) {
421 } else if (anAnswer == QMessageBox::Cancel) {
428 //show file dialog, check if readable and open
429 myCurrentFile = QFileDialog::getExistingDirectory(mainWindow());
430 if(myCurrentFile.isEmpty())
432 QFileInfo aFileInfo(myCurrentFile);
433 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
434 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
438 QApplication::setOverrideCursor(Qt::WaitCursor);
439 aDoc->load(myCurrentFile.toLatin1().constData());
440 QApplication::restoreOverrideCursor();
441 updateCommandStatus();
444 //******************************************************
445 void XGUI_Workshop::onSave()
447 if(myCurrentFile.isEmpty()) {
451 saveDocument(myCurrentFile);
452 updateCommandStatus();
455 //******************************************************
456 void XGUI_Workshop::onSaveAs()
458 QString aTemp = myCurrentFile;
459 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
460 if(myCurrentFile.isEmpty()) {
461 myCurrentFile = aTemp;
464 QFileInfo aFileInfo(myCurrentFile);
465 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
466 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
472 //******************************************************
473 void XGUI_Workshop::onUndo()
475 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
476 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
477 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
478 if (aDoc->isOperation())
479 operationMgr()->abortOperation();
481 updateCommandStatus();
484 //******************************************************
485 void XGUI_Workshop::onRedo()
487 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
488 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
489 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
491 updateCommandStatus();
494 //******************************************************
495 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
498 QString::fromStdString(library(theModule.toStdString()));
499 if (libName.isEmpty()) {
501 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
506 CREATE_FUNC crtInst = 0;
509 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
513 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
514 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
515 QString aMsg((char*) &lpMsgBuf);
516 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
517 ::LocalFree(lpMsgBuf);
519 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
523 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
524 | FORMAT_MESSAGE_IGNORE_INSERTS,
525 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
526 QString aMsg((char*) &lpMsgBuf);
527 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
528 ::LocalFree(lpMsgBuf);
532 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
534 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
536 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
538 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
543 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
545 if (!err.isEmpty()) {
547 QMessageBox::warning(mainWindow(), tr("Error"), err);
549 qWarning( qPrintable( err ));
555 //******************************************************
556 bool XGUI_Workshop::activateModule()
558 Config_ModuleReader aModuleReader;
559 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
560 myPartSetModule = loadModule(moduleName);
561 if (!myPartSetModule)
563 myPartSetModule->createFeatures();
567 //******************************************************
568 void XGUI_Workshop::updateCommandStatus()
570 if (isSalomeMode()) // TODO: update commands in SALOME
572 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
574 QList<XGUI_Command*> aCommands = aMenuBar->features();
575 QList<XGUI_Command*>::const_iterator aIt;
577 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
578 if (aMgr->hasRootDocument()) {
579 XGUI_Command* aUndoCmd;
580 XGUI_Command* aRedoCmd;
581 foreach(XGUI_Command* aCmd, aCommands) {
582 if (aCmd->id() == "UNDO_CMD")
584 else if (aCmd->id() == "REDO_CMD")
586 else // Enable all commands
589 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
590 aUndoCmd->setEnabled(aDoc->canUndo());
591 aRedoCmd->setEnabled(aDoc->canRedo());
593 foreach(XGUI_Command* aCmd, aCommands) {
594 if (aCmd->id() == "NEW_CMD")
596 else if (aCmd->id() == "EXIT_CMD")
604 //******************************************************
605 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
607 QDockWidget* aObjDock = new QDockWidget(theParent);
608 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
609 aObjDock->setWindowTitle(tr("Object browser"));
610 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
611 connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
612 aObjDock->setWidget(myObjectBrowser);
614 myContextMenuMgr->connectObjectBrowser();
618 //******************************************************
620 * Creates dock widgets, places them in corresponding area
621 * and tabifies if necessary.
623 void XGUI_Workshop::createDockWidgets()
625 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
627 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
628 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
629 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
630 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
631 hidePropertyPanel(); //<! Invisible by default
633 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
636 //******************************************************
637 void XGUI_Workshop::showPropertyPanel()
639 QAction* aViewAct = myPropertyPanel->toggleViewAction();
640 //<! Restore ability to close panel from the window's menu
641 aViewAct->setEnabled(true);
642 myPropertyPanel->show();
643 myPropertyPanel->raise();
646 //******************************************************
647 void XGUI_Workshop::hidePropertyPanel()
649 QAction* aViewAct = myPropertyPanel->toggleViewAction();
650 //<! Do not allow to show empty property panel
651 aViewAct->setEnabled(false);
652 myPropertyPanel->hide();
655 //******************************************************
656 void XGUI_Workshop::showObjectBrowser()
658 myObjectBrowser->parentWidget()->show();
661 //******************************************************
662 void XGUI_Workshop::hideObjectBrowser()
664 myObjectBrowser->parentWidget()->hide();
667 //******************************************************
668 void XGUI_Workshop::onFeatureTriggered()
670 QAction* aCmd = dynamic_cast<QAction*>(sender());
672 QString aId = salomeConnector()->commandId(aCmd);
674 myPartSetModule->launchOperation(aId);
678 //******************************************************
679 void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
681 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
683 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
685 aMgr->setCurrentDocument(aDocRef->value());
687 aMgr->setCurrentDocument(aMgr->rootDocument());
691 //******************************************************
692 void XGUI_Workshop::salomeViewerSelectionChanged()
694 emit salomeViewerSelection();
698 //**************************************************************
699 XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
701 return mySalomeConnector->viewer();
704 //**************************************************************
705 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
707 if (theId == "ACTIVATE_PART_CMD")
709 else if (theId == "DEACTIVATE_PART_CMD")
714 //**************************************************************
715 void XGUI_Workshop::activatePart(bool toActivate)
718 QFeatureList aFeatures = mySelector->selectedFeatures();
719 if (aFeatures.size() > 0) {
720 changeCurrentDocument(aFeatures.first());
721 myObjectBrowser->activateCurrentPart(true);
724 changeCurrentDocument(FeaturePtr());
725 myObjectBrowser->activateCurrentPart(false);