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_Operation.h>
30 #include <ModuleBase_Operation.h>
31 #include <ModuleBase_OperationDescription.h>
32 #include <Config_FeatureMessage.h>
33 #include <Config_PointerMessage.h>
35 #include <QApplication>
36 #include <QFileDialog>
37 #include <QMessageBox>
38 #include <QMdiSubWindow>
39 #include <QPushButton>
40 #include <QDockWidget>
53 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
55 myCurrentFile(QString()),
56 myPartSetModule(NULL),
57 mySalomeConnector(theConnector),
58 myPropertyPanelDock(0),
62 myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
64 myDisplayer = new XGUI_Displayer(this);
66 mySelector = new XGUI_SelectionMgr(this);
67 connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
69 myOperationMgr = new XGUI_OperationMgr(this);
70 myActionsMgr = new XGUI_ActionsMgr(this);
71 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
73 myViewerProxy = new XGUI_ViewerProxy(this);
75 connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
76 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
77 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
78 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
81 //******************************************************
82 XGUI_Workshop::~XGUI_Workshop(void)
86 //******************************************************
87 void XGUI_Workshop::startApplication()
90 //Initialize event listening
91 Events_Loop* aLoop = Events_Loop::loop();
92 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
93 //TODO(sbh): Implement static method to extract event id [SEID]
94 Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
95 aLoop->registerListener(this, aFeatureId);
96 Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
97 aLoop->registerListener(this, aPartSetId);
100 myMainWindow->show();
101 updateCommandStatus();
104 // Testing of document creation
105 //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
106 //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
107 //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
109 //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
110 //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
111 //aPoint2 = aMgr->rootDocument()->addFeature("Point");
113 //aPart = aMgr->rootDocument()->addFeature("Part");
117 //******************************************************
118 void XGUI_Workshop::initMenu()
120 if (isSalomeMode()) {
121 // Create only Undo, Redo commands
122 salomeConnector()->addEditCommand("UNDO_CMD",
123 tr("Undo"), tr("Undo last command"),
124 QIcon(":pictures/undo.png"),
125 false, this, SLOT(onUndo()),
127 salomeConnector()->addEditCommand("REDO_CMD",
128 tr("Redo"), tr("Redo last command"),
129 QIcon(":pictures/redo.png"),
130 false, this, SLOT(onRedo()),
132 salomeConnector()->addEditMenuSeparator();
135 XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
137 // File commands group
138 XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
140 XGUI_Command* aCommand;
142 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
143 QIcon(":pictures/save.png"), QKeySequence::Save);
144 aCommand->connectTo(this, SLOT(onSave()));
145 //aCommand->disable();
147 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
148 QIcon(":pictures/undo.png"), QKeySequence::Undo);
149 aCommand->connectTo(this, SLOT(onUndo()));
151 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
152 QIcon(":pictures/redo.png"), QKeySequence::Redo);
153 aCommand->connectTo(this, SLOT(onRedo()));
155 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
156 QIcon(":pictures/rebuild.png"));
158 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
159 QIcon(":pictures/save.png"));
160 aCommand->connectTo(this, SLOT(onSaveAs()));
161 //aCommand->disable();
163 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
164 QIcon(":pictures/open.png"), QKeySequence::Open);
165 aCommand->connectTo(this, SLOT(onOpen()));
167 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
168 // QIcon(":pictures/new.png"), QKeySequence::New);
169 //aCommand->connectTo(this, SLOT(onNew()));
171 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
172 QIcon(":pictures/close.png"), QKeySequence::Close);
173 aCommand->connectTo(this, SLOT(onExit()));
177 //******************************************************
178 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
180 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
181 return aMenuBar->addWorkbench(theName);
184 //******************************************************
185 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
187 static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
188 if (theMessage->eventID() == aFeatureId) {
189 const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
190 addFeature(aFeatureMsg);
193 const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
195 ModuleBase_Operation* anOperation =
196 (ModuleBase_Operation*)(aPartSetMsg->pointer());
198 if (myOperationMgr->startOperation(anOperation)) {
199 if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
200 anOperation->commit();
201 updateCommandStatus();
206 const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
208 emit errorOccurred(QString::fromLatin1(anAppError->description()));
211 myErrorDlg->activateWindow();
215 qDebug() << "XGUI_Workshop::ProcessEvent: "
216 << "Catch message, but it can not be processed.";
221 //******************************************************
222 void XGUI_Workshop::onOperationStarted()
224 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
226 if(!aOperation->getDescription()->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->getDescription()->description());
239 //******************************************************
240 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
242 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
244 if(aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
245 updateCommandStatus();
248 updateCommandStatus();
249 myActionsMgr->restoreCommandState();
256 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
260 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
264 //Find or create Workbench
265 QString aWchName = QString::fromStdString(theMessage->workbenchId());
266 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
267 bool isUsePropPanel = theMessage->isUseInput();
268 if (isSalomeMode()) {
269 QString aId = QString::fromStdString(theMessage->id());
270 salomeConnector()->addFeature(aWchName,
271 QString::fromStdString(theMessage->id()),
273 QString::fromStdString(theMessage->tooltip()),
274 QIcon(theMessage->icon().c_str()),
275 isUsePropPanel, this,
276 SLOT(onFeatureTriggered()), QKeySequence());
277 myActionsMgr->addCommand(aId, salomeConnector()->command(aId));
278 salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
282 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
283 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
285 aPage = addWorkbench(aWchName);
287 //Find or create Group
288 QString aGroupName = QString::fromStdString(theMessage->groupId());
289 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
291 aGroup = aPage->addGroup(aGroupName);
294 XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
295 QString::fromStdString(theMessage->text()),
296 QString::fromStdString(theMessage->tooltip()),
297 QIcon(theMessage->icon().c_str()),
298 QKeySequence(), isUsePropPanel);
299 aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
300 myActionsMgr->addCommand(aCommand);
301 myPartSetModule->featureCreated(aCommand);
306 * Makes a signal/slot connections between Property Panel
307 * and given operation. The given operation becomes a
308 * current operation and previous operation if exists
310 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
312 QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
313 connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
314 QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
315 connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
317 QAction* aCommand = 0;
318 if (isSalomeMode()) {
319 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
321 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
322 aCommand = aMenu->feature(theOperation->getDescription()->operationId());
324 //Abort operation on uncheck the command
325 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
329 * Saves document with given name.
331 void XGUI_Workshop::saveDocument(QString theName)
333 QApplication::restoreOverrideCursor();
334 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
335 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
336 aDoc->save(theName.toLatin1().constData());
337 QApplication::restoreOverrideCursor();
340 //******************************************************
341 void XGUI_Workshop::onExit()
343 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
344 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
345 if(aDoc->isModified()) {
346 int anAnswer = QMessageBox::question(
347 myMainWindow, tr("Save current file"),
348 tr("The document is modified, save before exit?"),
349 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
350 if(anAnswer == QMessageBox::Save) {
352 } else if (anAnswer == QMessageBox::Cancel) {
359 //******************************************************
360 void XGUI_Workshop::onNew()
362 QApplication::setOverrideCursor(Qt::WaitCursor);
363 if (objectBrowser() == 0) {
365 mySelector->connectViewers();
367 myViewerProxy->connectToViewer();
369 if (!isSalomeMode()) {
370 myMainWindow->showPythonConsole();
371 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
372 aWnd->showMaximized();
373 updateCommandStatus();
375 QApplication::restoreOverrideCursor();
378 //******************************************************
379 void XGUI_Workshop::onOpen()
381 //save current file before close if modified
382 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
383 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
384 if(aDoc->isModified()) {
385 //TODO(sbh): re-launch the app?
386 int anAnswer = QMessageBox::question(
387 myMainWindow, tr("Save current file"),
388 tr("The document is modified, save before opening another?"),
389 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
390 if(anAnswer == QMessageBox::Save) {
392 } else if (anAnswer == QMessageBox::Cancel) {
399 //show file dialog, check if readable and open
400 myCurrentFile = QFileDialog::getOpenFileName(mainWindow());
401 if(myCurrentFile.isEmpty())
403 QFileInfo aFileInfo(myCurrentFile);
404 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
405 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
409 QApplication::setOverrideCursor(Qt::WaitCursor);
410 aDoc->load(myCurrentFile.toLatin1().constData());
411 QApplication::restoreOverrideCursor();
412 updateCommandStatus();
415 //******************************************************
416 void XGUI_Workshop::onSave()
418 if(myCurrentFile.isEmpty()) {
422 saveDocument(myCurrentFile);
423 updateCommandStatus();
426 //******************************************************
427 void XGUI_Workshop::onSaveAs()
429 QString aTemp = myCurrentFile;
430 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
431 if(myCurrentFile.isEmpty()) {
432 myCurrentFile = aTemp;
435 QFileInfo aFileInfo(myCurrentFile);
436 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
437 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
443 //******************************************************
444 void XGUI_Workshop::onUndo()
446 objectBrowser()->setCurrentIndex(QModelIndex());
447 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
448 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
450 updateCommandStatus();
453 //******************************************************
454 void XGUI_Workshop::onRedo()
456 objectBrowser()->setCurrentIndex(QModelIndex());
457 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
458 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
460 updateCommandStatus();
463 //******************************************************
464 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
466 QString libName = library(theModule);
467 if (libName.isEmpty()) {
469 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
474 CREATE_FUNC crtInst = 0;
478 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
482 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
483 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
484 QString aMsg((char*) &lpMsgBuf);
485 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
486 ::LocalFree(lpMsgBuf);
488 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
492 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
493 | FORMAT_MESSAGE_IGNORE_INSERTS,
494 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
495 QString aMsg((char*) &lpMsgBuf);
496 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
497 ::LocalFree(lpMsgBuf);
501 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
503 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
506 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
508 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
512 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
514 if (!err.isEmpty()) {
515 if (mainWindow() && mainWindow()->isVisible())
516 QMessageBox::warning(mainWindow(), tr("Error"), err);
518 qWarning( qPrintable( err ));
523 //******************************************************
524 bool XGUI_Workshop::activateModule()
526 myPartSetModule = loadModule("PartSet");
527 if (!myPartSetModule)
529 myPartSetModule->createFeatures();
533 //******************************************************
534 void XGUI_Workshop::updateCommandStatus()
536 if (isSalomeMode()) // TODO: update commands in SALOME
538 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
540 QList<XGUI_Command*> aCommands = aMenuBar->features();
541 QList<XGUI_Command*>::const_iterator aIt;
543 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
544 if (aMgr->hasRootDocument()) {
545 XGUI_Command* aUndoCmd;
546 XGUI_Command* aRedoCmd;
547 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
548 if ((*aIt)->id() == "UNDO_CMD")
550 else if ((*aIt)->id() == "REDO_CMD")
552 else // Enable all commands
555 boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
556 aUndoCmd->setEnabled(aDoc->canUndo());
557 aRedoCmd->setEnabled(aDoc->canRedo());
559 for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
560 if ((*aIt)->id() == "NEW_CMD")
562 else if ((*aIt)->id() == "EXIT_CMD")
570 //******************************************************
571 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
573 QDockWidget* aObjDock = new QDockWidget(theParent);
574 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
575 aObjDock->setWindowTitle(tr("Object browser"));
576 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
577 aObjDock->setWidget(myObjectBrowser);
581 //******************************************************
582 QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
584 QDockWidget* aPropPanel = new QDockWidget(theParent);
585 aPropPanel->setWindowTitle(tr("Property Panel"));
586 QAction* aViewAct = aPropPanel->toggleViewAction();
587 aPropPanel->setObjectName(XGUI::PROP_PANEL);
589 QWidget* aContent = new QWidget(aPropPanel);
590 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
591 aMainLay->setContentsMargins(3, 3, 3, 3);
592 aPropPanel->setWidget(aContent);
594 QFrame* aFrm = new QFrame(aContent);
595 aFrm->setFrameStyle(QFrame::Sunken);
596 aFrm->setFrameShape(QFrame::Panel);
597 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
598 aBtnLay->setContentsMargins(0, 0, 0, 0);
599 aMainLay->addWidget(aFrm);
601 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
603 aBtnLay->addWidget(aBtn);
604 aBtnLay->addStretch(1);
605 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
606 aBtn->setObjectName(XGUI::PROP_PANEL_OK);
608 aBtnLay->addWidget(aBtn);
609 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
610 aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
612 aBtnLay->addWidget(aBtn);
614 QWidget* aCustomWidget = new QWidget(aContent);
615 aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
616 aMainLay->addWidget(aCustomWidget);
617 aMainLay->addStretch(1);
622 //******************************************************
623 void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
625 myPropertyPanelDock->setWindowTitle(theTitle);
628 //******************************************************
630 * Creates dock widgets, places them in corresponding area
631 * and tabifies if necessary.
633 void XGUI_Workshop::createDockWidgets()
635 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
637 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
638 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
639 myPropertyPanelDock = createPropertyPanel(aDesktop);
640 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
641 hidePropertyPanel(); //<! Invisible by default
643 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
646 //******************************************************
647 void XGUI_Workshop::showPropertyPanel()
649 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
650 //<! Restore ability to close panel from the window's menu
651 aViewAct->setEnabled(true);
652 myPropertyPanelDock->show();
653 myPropertyPanelDock->raise();
656 //******************************************************
657 void XGUI_Workshop::hidePropertyPanel()
659 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
660 //<! Do not allow to show empty property panel
661 aViewAct->setEnabled(false);
662 myPropertyPanelDock->hide();
665 //******************************************************
666 void XGUI_Workshop::showObjectBrowser()
668 myObjectBrowser->parentWidget()->show();
671 //******************************************************
672 void XGUI_Workshop::hideObjectBrowser()
674 myObjectBrowser->parentWidget()->hide();
677 //******************************************************
678 void XGUI_Workshop::onFeatureTriggered()
680 QAction* aCmd = dynamic_cast<QAction*>(sender());
682 QString aId = salomeConnector()->commandId(aCmd);
684 myPartSetModule->launchOperation(aId);
688 //******************************************************
689 void XGUI_Workshop::changeCurrentDocument()
691 QFeatureList aFeatures = objectBrowser()->selectedFeatures();
693 // Set current document
694 if (aFeatures.size() > 0) {
695 FeaturePtr aFeature = aFeatures.first();
697 boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
698 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
700 aMgr->setCurrentDocument(aDocRef->value());
704 //******************************************************
705 void XGUI_Workshop::salomeViewerSelectionChanged()
707 emit salomeViewerSelection();
711 //**************************************************************
712 XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
714 return mySalomeConnector->viewer();