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>
29 #include <ModelAPI_Object.h>
31 #include <Events_Loop.h>
32 #include <Events_Error.h>
33 #include <ModuleBase_Operation.h>
34 #include <ModuleBase_Operation.h>
35 #include <ModuleBase_OperationDescription.h>
36 #include <Config_Common.h>
37 #include <Config_FeatureMessage.h>
38 #include <Config_PointerMessage.h>
39 #include <Config_ModuleReader.h>
41 #include <QApplication>
42 #include <QFileDialog>
43 #include <QMessageBox>
44 #include <QMdiSubWindow>
45 #include <QPushButton>
46 #include <QDockWidget>
60 QMap<QString, QString> XGUI_Workshop::myIcons;
62 QString XGUI_Workshop::featureIcon(const std::string& theId)
64 QString aId(theId.c_str());
65 if (myIcons.contains(aId))
70 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
72 myCurrentFile(QString()),
73 myPartSetModule(NULL),
74 mySalomeConnector(theConnector),
79 myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
81 myDisplayer = new XGUI_Displayer(this);
83 mySelector = new XGUI_SelectionMgr(this);
85 myOperationMgr = new XGUI_OperationMgr(this);
86 myActionsMgr = new XGUI_ActionsMgr(this);
87 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
88 myContextMenuMgr = new XGUI_ContextMenuMgr(this);
89 connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)),
90 this, SLOT(onContextMenuCommand(const QString&, bool)));
92 myViewerProxy = new XGUI_ViewerProxy(this);
94 connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
95 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
96 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
97 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
100 //******************************************************
101 XGUI_Workshop::~XGUI_Workshop(void)
105 //******************************************************
106 void XGUI_Workshop::startApplication()
109 //Initialize event listening
110 Events_Loop* aLoop = Events_Loop::loop();
111 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
112 //TODO(sbh): Implement static method to extract event id [SEID]
113 Events_ID aFeatureId = aLoop->eventByName(EVENT_FEATURE_LOADED);
114 aLoop->registerListener(this, aFeatureId);
115 Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
116 aLoop->registerListener(this, aPartSetId);
117 Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
118 aLoop->registerListener(this, aFeatureUpdatedId);
121 myMainWindow->show();
122 updateCommandStatus();
127 //******************************************************
128 void XGUI_Workshop::initMenu()
130 myContextMenuMgr->createActions();
132 if (isSalomeMode()) {
133 // Create only Undo, Redo commands
134 QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD",
135 tr("Undo"), tr("Undo last command"),
136 QIcon(":pictures/undo.png"),
137 QKeySequence::Undo, false);
138 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
139 aAction = salomeConnector()->addEditCommand("REDO_CMD",
140 tr("Redo"), tr("Redo last command"),
141 QIcon(":pictures/redo.png"),
142 QKeySequence::Redo, false);
143 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo()));
144 salomeConnector()->addEditMenuSeparator();
147 XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
149 // File commands group
150 XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
152 XGUI_Command* aCommand;
154 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
155 QIcon(":pictures/save.png"), QKeySequence::Save);
156 aCommand->connectTo(this, SLOT(onSave()));
157 //aCommand->disable();
159 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
160 QIcon(":pictures/undo.png"), QKeySequence::Undo);
161 aCommand->connectTo(this, SLOT(onUndo()));
163 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
164 QIcon(":pictures/redo.png"), QKeySequence::Redo);
165 aCommand->connectTo(this, SLOT(onRedo()));
167 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
168 QIcon(":pictures/rebuild.png"));
170 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
171 QIcon(":pictures/save.png"));
172 aCommand->connectTo(this, SLOT(onSaveAs()));
173 //aCommand->disable();
175 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
176 QIcon(":pictures/open.png"), QKeySequence::Open);
177 aCommand->connectTo(this, SLOT(onOpen()));
179 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
180 // QIcon(":pictures/new.png"), QKeySequence::New);
181 //aCommand->connectTo(this, SLOT(onNew()));
183 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
184 QIcon(":pictures/close.png"), QKeySequence::Close);
185 aCommand->connectTo(this, SLOT(onExit()));
188 //******************************************************
189 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
191 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
192 return aMenuBar->addWorkbench(theName);
195 //******************************************************
196 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
198 //A message to start feature creation received.
199 static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
200 if (theMessage->eventID() == aFeatureLoadedId) {
201 const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
202 addFeature(aFeatureMsg);
205 //Update property panel on corresponding message. If there is no current operation (no
206 //property panel), or received message has different feature to the current - do nothing.
207 static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);
208 if (theMessage->eventID() == aFeatureUpdatedId && myOperationMgr->hasOperation())
210 const Model_FeatureUpdatedMessage* anUpdateMsg =
211 dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
212 FeaturePtr aNewFeature = anUpdateMsg->feature();
213 FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
214 if(aNewFeature == aCurrentFeature) {
215 myPropertyPanel->updateContentWidget(aCurrentFeature);
218 //An operation passed by message. Start it, process and commit.
219 const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
221 ModuleBase_Operation* anOperation =
222 (ModuleBase_Operation*)(aPartSetMsg->pointer());
224 if (myOperationMgr->startOperation(anOperation)) {
225 myPropertyPanel->updateContentWidget(anOperation->feature());
226 if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
227 anOperation->commit();
228 updateCommandStatus();
233 //Show error dialog if error message received.
234 const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
236 emit errorOccurred(QString::fromLatin1(anAppError->description()));
239 myErrorDlg->activateWindow();
244 //******************************************************
245 void XGUI_Workshop::onOperationStarted()
247 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
249 if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
250 connectWithOperation(aOperation);
254 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
255 QWidget* aContent = myPropertyPanel->contentWidget();
256 qDeleteAll(aContent->children());
257 aFactory.createWidget(aContent);
258 myPropertyPanel->setModelWidgets(aFactory.getModelWidgets());
259 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
263 //******************************************************
264 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
266 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
268 //!< No need for property panel
269 updateCommandStatus();
271 if(myOperationMgr->operationsCount() > 1) {
272 myActionsMgr->updateAction(theOperation->getDescription()->operationId());
275 if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) {
276 myActionsMgr->restoreCommandState();
283 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
287 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
291 // Remember features icons
292 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
294 //Find or create Workbench
295 QString aWchName = QString::fromStdString(theMessage->workbenchId());
296 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
297 bool isUsePropPanel = theMessage->isUseInput();
298 if (isSalomeMode()) {
299 QString aId = QString::fromStdString(theMessage->id());
300 QAction* aAction = salomeConnector()->addFeature(aWchName,
302 QString::fromStdString(theMessage->text()),
303 QString::fromStdString(theMessage->tooltip()),
304 QIcon(theMessage->icon().c_str()),
305 QKeySequence(), isUsePropPanel);
306 myActionsMgr->addCommand(aAction);
307 salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
308 myPartSetModule->featureCreated(aAction);
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 QAction* aCommand = 0;
342 if (isSalomeMode()) {
343 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
345 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
346 aCommand = aMenu->feature(theOperation->getDescription()->operationId());
348 //Abort operation on uncheck the command
349 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
353 * Saves document with given name.
355 void XGUI_Workshop::saveDocument(QString theName)
357 QApplication::restoreOverrideCursor();
358 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
359 DocumentPtr aDoc = aMgr->rootDocument();
360 aDoc->save(theName.toLatin1().constData());
361 QApplication::restoreOverrideCursor();
364 //******************************************************
365 void XGUI_Workshop::onExit()
367 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
368 DocumentPtr aDoc = aMgr->rootDocument();
369 if(aDoc->isModified()) {
370 int anAnswer = QMessageBox::question(
371 myMainWindow, tr("Save current file"),
372 tr("The document is modified, save before exit?"),
373 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
374 if(anAnswer == QMessageBox::Save) {
376 } else if (anAnswer == QMessageBox::Cancel) {
383 //******************************************************
384 void XGUI_Workshop::onNew()
386 QApplication::setOverrideCursor(Qt::WaitCursor);
387 if (objectBrowser() == 0) {
389 mySelector->connectViewers();
391 myViewerProxy->connectToViewer();
393 if (!isSalomeMode()) {
394 myMainWindow->showPythonConsole();
395 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
396 aWnd->showMaximized();
397 updateCommandStatus();
399 QApplication::restoreOverrideCursor();
402 //******************************************************
403 void XGUI_Workshop::onOpen()
405 //save current file before close if modified
406 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
407 DocumentPtr aDoc = aMgr->rootDocument();
408 if(aDoc->isModified()) {
409 //TODO(sbh): re-launch the app?
410 int anAnswer = QMessageBox::question(
411 myMainWindow, tr("Save current file"),
412 tr("The document is modified, save before opening another?"),
413 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
414 if(anAnswer == QMessageBox::Save) {
416 } else if (anAnswer == QMessageBox::Cancel) {
423 //show file dialog, check if readable and open
424 myCurrentFile = QFileDialog::getExistingDirectory(mainWindow());
425 if(myCurrentFile.isEmpty())
427 QFileInfo aFileInfo(myCurrentFile);
428 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
429 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
433 QApplication::setOverrideCursor(Qt::WaitCursor);
434 aDoc->load(myCurrentFile.toLatin1().constData());
435 QApplication::restoreOverrideCursor();
436 updateCommandStatus();
439 //******************************************************
440 void XGUI_Workshop::onSave()
442 if(myCurrentFile.isEmpty()) {
446 saveDocument(myCurrentFile);
447 updateCommandStatus();
450 //******************************************************
451 void XGUI_Workshop::onSaveAs()
453 QString aTemp = myCurrentFile;
454 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
455 if(myCurrentFile.isEmpty()) {
456 myCurrentFile = aTemp;
459 QFileInfo aFileInfo(myCurrentFile);
460 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
461 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
467 //******************************************************
468 void XGUI_Workshop::onUndo()
470 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
471 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
472 DocumentPtr aDoc = aMgr->rootDocument();
473 if (aDoc->isOperation())
474 operationMgr()->abortOperation();
476 updateCommandStatus();
479 //******************************************************
480 void XGUI_Workshop::onRedo()
482 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
483 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
484 DocumentPtr aDoc = aMgr->rootDocument();
486 updateCommandStatus();
489 //******************************************************
490 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
493 QString::fromStdString(library(theModule.toStdString()));
494 if (libName.isEmpty()) {
496 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
501 CREATE_FUNC crtInst = 0;
504 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
508 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
509 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
510 QString aMsg((char*) &lpMsgBuf);
511 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
512 ::LocalFree(lpMsgBuf);
514 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
518 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
519 | FORMAT_MESSAGE_IGNORE_INSERTS,
520 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
521 QString aMsg((char*) &lpMsgBuf);
522 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
523 ::LocalFree(lpMsgBuf);
527 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
529 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
531 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
533 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
538 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
540 if (!err.isEmpty()) {
542 QMessageBox::warning(mainWindow(), tr("Error"), err);
544 qWarning( qPrintable( err ));
550 //******************************************************
551 bool XGUI_Workshop::activateModule()
553 Config_ModuleReader aModuleReader;
554 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
555 myPartSetModule = loadModule(moduleName);
556 if (!myPartSetModule)
558 myPartSetModule->createFeatures();
562 //******************************************************
563 void XGUI_Workshop::updateCommandStatus()
565 QList<QAction*> aCommands;
566 if (isSalomeMode()) { // update commands in SALOME mode
567 aCommands = salomeConnector()->commandList();
569 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
570 foreach (XGUI_Command* aCmd, aMenuBar->features())
571 aCommands.append(aCmd);
573 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
574 if (aMgr->hasRootDocument()) {
577 foreach(QAction* aCmd, aCommands) {
578 QString aId = aCmd->data().toString();
579 if (aId == "UNDO_CMD")
581 else if (aId == "REDO_CMD")
583 else // Enable all commands
584 aCmd->setEnabled(true);
586 DocumentPtr aDoc = aMgr->rootDocument();
587 aUndoCmd->setEnabled(aDoc->canUndo());
588 aRedoCmd->setEnabled(aDoc->canRedo());
590 foreach(QAction* aCmd, aCommands) {
591 QString aId = aCmd->data().toString();
592 if (aId == "NEW_CMD")
593 aCmd->setEnabled(true);
594 else if (aId == "EXIT_CMD")
595 aCmd->setEnabled(true);
597 aCmd->setEnabled(false);
602 //******************************************************
603 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
605 QDockWidget* aObjDock = new QDockWidget(theParent);
606 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
607 aObjDock->setWindowTitle(tr("Object browser"));
608 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
609 connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
610 aObjDock->setWidget(myObjectBrowser);
612 myContextMenuMgr->connectObjectBrowser();
616 //******************************************************
618 * Creates dock widgets, places them in corresponding area
619 * and tabifies if necessary.
621 void XGUI_Workshop::createDockWidgets()
623 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
625 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
626 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
627 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
628 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
629 hidePropertyPanel(); //<! Invisible by default
631 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
633 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
634 connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
635 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
636 connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
639 //******************************************************
640 void XGUI_Workshop::showPropertyPanel()
642 QAction* aViewAct = myPropertyPanel->toggleViewAction();
643 //<! Restore ability to close panel from the window's menu
644 aViewAct->setEnabled(true);
645 myPropertyPanel->show();
646 myPropertyPanel->raise();
649 //******************************************************
650 void XGUI_Workshop::hidePropertyPanel()
652 QAction* aViewAct = myPropertyPanel->toggleViewAction();
653 //<! Do not allow to show empty property panel
654 aViewAct->setEnabled(false);
655 myPropertyPanel->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 void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
684 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
686 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
688 aMgr->setCurrentDocument(aDocRef->value());
690 aMgr->setCurrentDocument(aMgr->rootDocument());
694 //******************************************************
695 void XGUI_Workshop::salomeViewerSelectionChanged()
697 emit salomeViewerSelection();
701 //**************************************************************
702 XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
704 return mySalomeConnector->viewer();
707 //**************************************************************
708 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
710 if (theId == "ACTIVATE_PART_CMD")
712 else if (theId == "DEACTIVATE_PART_CMD")
717 //**************************************************************
718 void XGUI_Workshop::activatePart(bool toActivate)
721 QFeatureList aFeatures = mySelector->selectedFeatures();
722 if (aFeatures.size() > 0) {
723 changeCurrentDocument(aFeatures.first());
724 myObjectBrowser->activateCurrentPart(true);
727 changeCurrentDocument(FeaturePtr());
728 myObjectBrowser->activateCurrentPart(false);