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"
22 #include <ModelAPI_PluginManager.h>
23 #include <ModelAPI_Feature.h>
24 #include <ModelAPI_Data.h>
25 #include <ModelAPI_AttributeDocRef.h>
27 #include <Events_Loop.h>
28 #include <Events_Error.h>
29 #include <ModuleBase_PropPanelOperation.h>
30 #include <ModuleBase_Operation.h>
31 #include <Config_FeatureMessage.h>
32 #include <Config_PointerMessage.h>
34 #include <QApplication>
35 #include <QFileDialog>
36 #include <QMessageBox>
37 #include <QMdiSubWindow>
38 #include <QPushButton>
39 #include <QDockWidget>
52 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
54 myCurrentFile(QString()),
55 myPartSetModule(NULL),
56 mySalomeConnector(theConnector),
57 myPropertyPanelDock(0),
61 myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
63 myDisplayer = new XGUI_Displayer(this);
65 mySelector = new XGUI_SelectionMgr(this);
66 connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
68 myOperationMgr = new XGUI_OperationMgr(this);
69 myActionsMgr = new XGUI_ActionsMgr(this);
70 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
72 myViewerProxy = new XGUI_ViewerProxy(this);
74 connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
75 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
76 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
77 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
80 //******************************************************
81 XGUI_Workshop::~XGUI_Workshop(void)
85 //******************************************************
86 void XGUI_Workshop::startApplication()
89 //Initialize event listening
90 Events_Loop* aLoop = Events_Loop::loop();
91 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
92 //TODO(sbh): Implement static method to extract event id [SEID]
93 Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
94 aLoop->registerListener(this, aFeatureId);
95 Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
96 aLoop->registerListener(this, aPartSetId);
100 updateCommandStatus();
103 // Testing of document creation
104 //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
105 //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
106 //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
108 //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
109 //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
110 //aPoint2 = aMgr->rootDocument()->addFeature("Point");
112 //aPart = aMgr->rootDocument()->addFeature("Part");
116 //******************************************************
117 void XGUI_Workshop::initMenu()
119 if (isSalomeMode()) {
120 // Create only Undo, Redo commands
121 salomeConnector()->addEditCommand("UNDO_CMD",
122 tr("Undo"), tr("Undo last command"),
123 QIcon(":pictures/undo.png"),
124 false, this, SLOT(onUndo()),
126 salomeConnector()->addEditCommand("REDO_CMD",
127 tr("Redo"), tr("Redo last command"),
128 QIcon(":pictures/redo.png"),
129 false, this, SLOT(onRedo()),
131 salomeConnector()->addEditMenuSeparator();
134 XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
136 // File commands group
137 XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
139 XGUI_Command* aCommand;
141 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
142 QIcon(":pictures/save.png"), QKeySequence::Save);
143 aCommand->connectTo(this, SLOT(onSave()));
144 //aCommand->disable();
146 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
147 QIcon(":pictures/undo.png"), QKeySequence::Undo);
148 aCommand->connectTo(this, SLOT(onUndo()));
150 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
151 QIcon(":pictures/redo.png"), QKeySequence::Redo);
152 aCommand->connectTo(this, SLOT(onRedo()));
154 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
155 QIcon(":pictures/rebuild.png"));
157 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
158 QIcon(":pictures/save.png"));
159 aCommand->connectTo(this, SLOT(onSaveAs()));
160 //aCommand->disable();
162 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
163 QIcon(":pictures/open.png"), QKeySequence::Open);
164 aCommand->connectTo(this, SLOT(onOpen()));
166 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
167 // QIcon(":pictures/new.png"), QKeySequence::New);
168 //aCommand->connectTo(this, SLOT(onNew()));
170 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
171 QIcon(":pictures/close.png"), QKeySequence::Close);
172 aCommand->connectTo(this, SLOT(onExit()));
176 //******************************************************
177 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
179 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
180 return aMenuBar->addWorkbench(theName);
183 //******************************************************
184 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
186 static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
187 if (theMessage->eventID() == aFeatureId) {
188 const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
189 addFeature(aFeatureMsg);
192 const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
194 ModuleBase_PropPanelOperation* anOperation =
195 (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
197 if (myOperationMgr->startOperation(anOperation)) {
198 if (anOperation->xmlRepresentation().isEmpty()) {
199 anOperation->commit();
200 updateCommandStatus();
205 const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
207 emit errorOccurred(QString::fromLatin1(anAppError->description()));
210 myErrorDlg->activateWindow();
214 qDebug() << "XGUI_Workshop::ProcessEvent: "
215 << "Catch message, but it can not be processed.";
220 //******************************************************
221 void XGUI_Workshop::onOperationStarted()
223 ModuleBase_PropPanelOperation* aOperation =
224 (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
226 if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
227 connectWithOperation(aOperation);
228 QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
229 qDeleteAll(aPropWidget->children());
233 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
234 aFactory.createWidget(aPropWidget);
235 setPropertyPannelTitle(aOperation->description());
239 //******************************************************
240 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
242 ModuleBase_PropPanelOperation* aOperation =
243 (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
245 if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
246 updateCommandStatus();
249 updateCommandStatus();
250 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 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
268 bool isUsePropPanel = theMessage->isUseInput();
269 if (isSalomeMode()) {
270 QString aId = QString::fromStdString(theMessage->id());
271 salomeConnector()->addFeature(aWchName,
272 QString::fromStdString(theMessage->id()),
274 QString::fromStdString(theMessage->tooltip()),
275 QIcon(theMessage->icon().c_str()),
276 isUsePropPanel, this,
277 SLOT(onFeatureTriggered()), QKeySequence());
278 myActionsMgr->addCommand(aId, salomeConnector()->command(aId));
279 salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
283 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
284 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
286 aPage = addWorkbench(aWchName);
288 //Find or create Group
289 QString aGroupName = QString::fromStdString(theMessage->groupId());
290 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
292 aGroup = aPage->addGroup(aGroupName);
295 XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
296 QString::fromStdString(theMessage->text()),
297 QString::fromStdString(theMessage->tooltip()),
298 QIcon(theMessage->icon().c_str()),
299 QKeySequence(), isUsePropPanel);
300 aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
301 myActionsMgr->addCommand(aCommand);
302 myPartSetModule->featureCreated(aCommand);
307 * Makes a signal/slot connections between Property Panel
308 * and given operation. The given operation becomes a
309 * current operation and previous operation if exists
311 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
313 QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
314 connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
315 QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
316 connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
318 QAction* aCommand = 0;
319 if (isSalomeMode()) {
320 aCommand = salomeConnector()->command(theOperation->operationId());
322 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
323 aCommand = aMenu->feature(theOperation->operationId());
325 //Abort operation on uncheck the command
326 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
330 * Saves document with given name.
332 void XGUI_Workshop::saveDocument(QString theName)
334 QApplication::restoreOverrideCursor();
335 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
336 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
337 aDoc->save(theName.toLatin1().constData());
338 QApplication::restoreOverrideCursor();
341 //******************************************************
342 void XGUI_Workshop::onExit()
344 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
345 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
346 if(aDoc->isModified()) {
347 int anAnswer = QMessageBox::question(
348 myMainWindow, tr("Save current file"),
349 tr("The document is modified, save before exit?"),
350 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
351 if(anAnswer == QMessageBox::Save) {
353 } else if (anAnswer == QMessageBox::Cancel) {
360 //******************************************************
361 void XGUI_Workshop::onNew()
363 QApplication::setOverrideCursor(Qt::WaitCursor);
364 if (objectBrowser() == 0) {
366 mySelector->connectViewers();
368 myViewerProxy->connectToViewer();
370 if (!isSalomeMode()) {
371 myMainWindow->showPythonConsole();
372 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
373 aWnd->showMaximized();
374 updateCommandStatus();
376 QApplication::restoreOverrideCursor();
379 //******************************************************
380 void XGUI_Workshop::onOpen()
382 //save current file before close if modified
383 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
384 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
385 if(aDoc->isModified()) {
386 //TODO(sbh): re-launch the app?
387 int anAnswer = QMessageBox::question(
388 myMainWindow, tr("Save current file"),
389 tr("The document is modified, save before opening another?"),
390 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
391 if(anAnswer == QMessageBox::Save) {
393 } else if (anAnswer == QMessageBox::Cancel) {
400 //show file dialog, check if readable and open
401 myCurrentFile = QFileDialog::getOpenFileName(mainWindow());
402 if(myCurrentFile.isEmpty())
404 QFileInfo aFileInfo(myCurrentFile);
405 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
406 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
410 QApplication::setOverrideCursor(Qt::WaitCursor);
411 aDoc->load(myCurrentFile.toLatin1().constData());
412 QApplication::restoreOverrideCursor();
413 updateCommandStatus();
416 //******************************************************
417 void XGUI_Workshop::onSave()
419 if(myCurrentFile.isEmpty()) {
423 saveDocument(myCurrentFile);
424 updateCommandStatus();
427 //******************************************************
428 void XGUI_Workshop::onSaveAs()
430 QString aTemp = myCurrentFile;
431 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
432 if(myCurrentFile.isEmpty()) {
433 myCurrentFile = aTemp;
436 QFileInfo aFileInfo(myCurrentFile);
437 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
438 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
444 //******************************************************
445 void XGUI_Workshop::onUndo()
447 objectBrowser()->setCurrentIndex(QModelIndex());
448 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
449 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
451 updateCommandStatus();
454 //******************************************************
455 void XGUI_Workshop::onRedo()
457 objectBrowser()->setCurrentIndex(QModelIndex());
458 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
459 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
461 updateCommandStatus();
464 //******************************************************
465 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
467 QString libName = library(theModule);
468 if (libName.isEmpty()) {
470 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
475 CREATE_FUNC crtInst = 0;
479 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
483 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
484 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
485 QString aMsg((char*) &lpMsgBuf);
486 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
487 ::LocalFree(lpMsgBuf);
489 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
493 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
494 | FORMAT_MESSAGE_IGNORE_INSERTS,
495 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
496 QString aMsg((char*) &lpMsgBuf);
497 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
498 ::LocalFree(lpMsgBuf);
502 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
504 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
507 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
509 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
513 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
515 if (!err.isEmpty()) {
516 if (mainWindow() && mainWindow()->isVisible())
517 QMessageBox::warning(mainWindow(), tr("Error"), err);
519 qWarning( qPrintable( err ));
524 //******************************************************
525 bool XGUI_Workshop::activateModule()
527 myPartSetModule = loadModule("PartSet");
528 if (!myPartSetModule)
530 myPartSetModule->createFeatures();
534 //******************************************************
535 void XGUI_Workshop::updateCommandStatus()
537 if (isSalomeMode()) // TODO: update commands in SALOME
539 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
541 QList<XGUI_Command*> aCommands = aMenuBar->features();
542 QList<XGUI_Command*>::const_iterator aIt;
544 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
545 if (aMgr->hasRootDocument()) {
546 XGUI_Command* aUndoCmd;
547 XGUI_Command* aRedoCmd;
548 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
549 if ((*aIt)->id() == "UNDO_CMD")
551 else if ((*aIt)->id() == "REDO_CMD")
553 else // Enable all commands
556 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
557 aUndoCmd->setEnabled(aDoc->canUndo());
558 aRedoCmd->setEnabled(aDoc->canRedo());
560 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
561 if ((*aIt)->id() == "NEW_CMD")
563 else if ((*aIt)->id() == "EXIT_CMD")
571 //******************************************************
572 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
574 QDockWidget* aObjDock = new QDockWidget(theParent);
575 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
576 aObjDock->setWindowTitle(tr("Object browser"));
577 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
578 aObjDock->setWidget(myObjectBrowser);
582 //******************************************************
583 QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
585 QDockWidget* aPropPanel = new QDockWidget(theParent);
586 aPropPanel->setWindowTitle(tr("Property Panel"));
587 QAction* aViewAct = aPropPanel->toggleViewAction();
588 aPropPanel->setObjectName(XGUI::PROP_PANEL);
590 QWidget* aContent = new QWidget(aPropPanel);
591 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
592 aMainLay->setContentsMargins(3, 3, 3, 3);
593 aPropPanel->setWidget(aContent);
595 QFrame* aFrm = new QFrame(aContent);
596 aFrm->setFrameStyle(QFrame::Sunken);
597 aFrm->setFrameShape(QFrame::Panel);
598 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
599 aBtnLay->setContentsMargins(0, 0, 0, 0);
600 aMainLay->addWidget(aFrm);
602 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
604 aBtnLay->addWidget(aBtn);
605 aBtnLay->addStretch(1);
606 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
607 aBtn->setObjectName(XGUI::PROP_PANEL_OK);
609 aBtnLay->addWidget(aBtn);
610 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
611 aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
613 aBtnLay->addWidget(aBtn);
615 QWidget* aCustomWidget = new QWidget(aContent);
616 aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
617 aMainLay->addWidget(aCustomWidget);
618 aMainLay->addStretch(1);
623 //******************************************************
624 void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
626 myPropertyPanelDock->setWindowTitle(theTitle);
629 //******************************************************
631 * Creates dock widgets, places them in corresponding area
632 * and tabifies if necessary.
634 void XGUI_Workshop::createDockWidgets()
636 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
638 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
639 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
640 myPropertyPanelDock = createPropertyPanel(aDesktop);
641 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
642 hidePropertyPanel(); //<! Invisible by default
644 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
647 //******************************************************
648 void XGUI_Workshop::showPropertyPanel()
650 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
651 //<! Restore ability to close panel from the window's menu
652 aViewAct->setEnabled(true);
653 myPropertyPanelDock->show();
654 myPropertyPanelDock->raise();
657 //******************************************************
658 void XGUI_Workshop::hidePropertyPanel()
660 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
661 //<! Do not allow to show empty property panel
662 aViewAct->setEnabled(false);
663 myPropertyPanelDock->hide();
666 //******************************************************
667 void XGUI_Workshop::showObjectBrowser()
669 myObjectBrowser->parentWidget()->show();
672 //******************************************************
673 void XGUI_Workshop::hideObjectBrowser()
675 myObjectBrowser->parentWidget()->hide();
678 //******************************************************
679 void XGUI_Workshop::onFeatureTriggered()
681 QAction* aCmd = dynamic_cast<QAction*>(sender());
683 QString aId = salomeConnector()->commandId(aCmd);
685 myPartSetModule->launchOperation(aId);
689 //******************************************************
690 void XGUI_Workshop::changeCurrentDocument()
692 QFeatureList aFeatures = objectBrowser()->selectedFeatures();
694 // Set current document
695 if (aFeatures.size() > 0) {
696 FeaturePtr aFeature = aFeatures.first();
698 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
699 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
701 aMgr->setCurrentDocument(aDocRef->value());
705 //******************************************************
706 void XGUI_Workshop::salomeViewerSelectionChanged()
708 emit salomeViewerSelection();
712 //**************************************************************
713 XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
715 return mySalomeConnector->viewer();