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>
61 QMap<QString, QString> XGUI_Workshop::myIcons;
63 QString XGUI_Workshop::featureIcon(const std::string& theId)
65 QString aId(theId.c_str());
66 if (myIcons.contains(aId))
71 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
73 myCurrentFile(QString()),
74 myPartSetModule(NULL),
75 mySalomeConnector(theConnector),
80 myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
82 myDisplayer = new XGUI_Displayer(this);
84 mySelector = new XGUI_SelectionMgr(this);
86 myOperationMgr = new XGUI_OperationMgr(this);
87 myActionsMgr = new XGUI_ActionsMgr(this);
88 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
89 myContextMenuMgr = new XGUI_ContextMenuMgr(this);
90 connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)),
91 this, SLOT(onContextMenuCommand(const QString&, bool)));
93 myViewerProxy = new XGUI_ViewerProxy(this);
95 connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
96 connect(myOperationMgr, SIGNAL(operationResumed()), this, SLOT(onOperationStarted()));
97 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
98 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
99 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
102 //******************************************************
103 XGUI_Workshop::~XGUI_Workshop(void)
107 //******************************************************
108 void XGUI_Workshop::startApplication()
111 //Initialize event listening
112 Events_Loop* aLoop = Events_Loop::loop();
113 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
114 //TODO(sbh): Implement static method to extract event id [SEID]
115 Events_ID aFeatureId = aLoop->eventByName(EVENT_FEATURE_LOADED);
116 aLoop->registerListener(this, aFeatureId);
117 Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
118 aLoop->registerListener(this, aPartSetId);
119 Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
120 aLoop->registerListener(this, aFeatureUpdatedId);
121 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
125 myMainWindow->show();
126 updateCommandStatus();
131 //******************************************************
132 void XGUI_Workshop::initMenu()
134 myContextMenuMgr->createActions();
136 if (isSalomeMode()) {
137 // Create only Undo, Redo commands
138 QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD",
139 tr("Undo"), tr("Undo last command"),
140 QIcon(":pictures/undo.png"),
141 QKeySequence::Undo, false);
142 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
143 aAction = salomeConnector()->addEditCommand("REDO_CMD",
144 tr("Redo"), tr("Redo last command"),
145 QIcon(":pictures/redo.png"),
146 QKeySequence::Redo, false);
147 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo()));
148 salomeConnector()->addEditMenuSeparator();
151 XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
153 // File commands group
154 XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
156 XGUI_Command* aCommand;
158 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
159 QIcon(":pictures/save.png"), QKeySequence::Save);
160 aCommand->connectTo(this, SLOT(onSave()));
161 //aCommand->disable();
163 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
164 QIcon(":pictures/undo.png"), QKeySequence::Undo);
165 aCommand->connectTo(this, SLOT(onUndo()));
167 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
168 QIcon(":pictures/redo.png"), QKeySequence::Redo);
169 aCommand->connectTo(this, SLOT(onRedo()));
171 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
172 QIcon(":pictures/rebuild.png"));
174 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
175 QIcon(":pictures/save.png"));
176 aCommand->connectTo(this, SLOT(onSaveAs()));
177 //aCommand->disable();
179 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
180 QIcon(":pictures/open.png"), QKeySequence::Open);
181 aCommand->connectTo(this, SLOT(onOpen()));
183 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
184 // QIcon(":pictures/new.png"), QKeySequence::New);
185 //aCommand->connectTo(this, SLOT(onNew()));
187 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
188 QIcon(":pictures/close.png"), QKeySequence::Close);
189 aCommand->connectTo(this, SLOT(onExit()));
192 //******************************************************
193 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
195 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
196 return aMenuBar->addWorkbench(theName);
199 //******************************************************
200 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
202 //A message to start feature creation received.
203 static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
204 if (theMessage->eventID() == aFeatureLoadedId) {
205 const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
206 addFeature(aFeatureMsg);
209 // Process creation of Part
210 if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) {
211 const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
212 FeaturePtr aFeature = aUpdMsg->feature();
213 if (aFeature->getKind() == "Part") {
214 //The created part will be created in Object Browser later and we have to activate that
215 // only when it created everywere
216 QTimer::singleShot(50, this, SLOT(activateLastPart()));
220 //Update property panel on corresponding message. If there is no current operation (no
221 //property panel), or received message has different feature to the current - do nothing.
222 static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);
223 if (theMessage->eventID() == aFeatureUpdatedId && myOperationMgr->hasOperation())
225 const Model_FeatureUpdatedMessage* anUpdateMsg =
226 dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
227 FeaturePtr aNewFeature = anUpdateMsg->feature();
228 FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
229 if(aNewFeature == aCurrentFeature) {
230 myPropertyPanel->updateContentWidget(aCurrentFeature);
233 //An operation passed by message. Start it, process and commit.
234 const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
236 ModuleBase_Operation* anOperation =
237 (ModuleBase_Operation*)(aPartSetMsg->pointer());
239 if (myOperationMgr->startOperation(anOperation)) {
240 myPropertyPanel->updateContentWidget(anOperation->feature());
241 if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
242 anOperation->commit();
243 updateCommandStatus();
248 //Show error dialog if error message received.
249 const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
251 emit errorOccurred(QString::fromLatin1(anAppError->description()));
254 myErrorDlg->activateWindow();
259 //******************************************************
260 void XGUI_Workshop::onOperationStarted()
262 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
264 if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
265 connectWithOperation(aOperation);
269 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
270 QWidget* aContent = myPropertyPanel->contentWidget();
271 qDeleteAll(aContent->children());
272 aFactory.createWidget(aContent);
273 myPropertyPanel->setModelWidgets(aFactory.getModelWidgets());
274 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
278 //******************************************************
279 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
281 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
283 //!< No need for property panel
284 updateCommandStatus();
286 if(myOperationMgr->operationsCount() > 1) {
287 myActionsMgr->updateAction(theOperation->getDescription()->operationId());
290 if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) {
291 myActionsMgr->restoreCommandState();
298 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
302 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
306 // Remember features icons
307 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
309 //Find or create Workbench
310 QString aWchName = QString::fromStdString(theMessage->workbenchId());
311 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
312 bool isUsePropPanel = theMessage->isUseInput();
313 if (isSalomeMode()) {
314 QString aId = QString::fromStdString(theMessage->id());
315 QAction* aAction = salomeConnector()->addFeature(aWchName,
317 QString::fromStdString(theMessage->text()),
318 QString::fromStdString(theMessage->tooltip()),
319 QIcon(theMessage->icon().c_str()),
320 QKeySequence(), isUsePropPanel);
321 myActionsMgr->addCommand(aAction);
322 salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
323 myPartSetModule->featureCreated(aAction);
326 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
327 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
329 aPage = addWorkbench(aWchName);
331 //Find or create Group
332 QString aGroupName = QString::fromStdString(theMessage->groupId());
333 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
335 aGroup = aPage->addGroup(aGroupName);
338 XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
339 QString::fromStdString(theMessage->text()),
340 QString::fromStdString(theMessage->tooltip()),
341 QIcon(theMessage->icon().c_str()),
342 QKeySequence(), isUsePropPanel);
343 aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
344 myActionsMgr->addCommand(aCommand);
345 myPartSetModule->featureCreated(aCommand);
350 * Makes a signal/slot connections between Property Panel
351 * and given operation. The given operation becomes a
352 * current operation and previous operation if exists
354 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
356 QAction* aCommand = 0;
357 if (isSalomeMode()) {
358 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
360 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
361 aCommand = aMenu->feature(theOperation->getDescription()->operationId());
363 //Abort operation on uncheck the command
364 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
368 * Saves document with given name.
370 void XGUI_Workshop::saveDocument(QString theName)
372 QApplication::restoreOverrideCursor();
373 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
374 DocumentPtr aDoc = aMgr->rootDocument();
375 aDoc->save(theName.toLatin1().constData());
376 QApplication::restoreOverrideCursor();
379 //******************************************************
380 void XGUI_Workshop::onExit()
382 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
383 DocumentPtr aDoc = aMgr->rootDocument();
384 if(aDoc->isModified()) {
385 int anAnswer = QMessageBox::question(
386 myMainWindow, tr("Save current file"),
387 tr("The document is modified, save before exit?"),
388 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
389 if(anAnswer == QMessageBox::Save) {
391 } else if (anAnswer == QMessageBox::Cancel) {
398 //******************************************************
399 void XGUI_Workshop::onNew()
401 QApplication::setOverrideCursor(Qt::WaitCursor);
402 if (objectBrowser() == 0) {
404 mySelector->connectViewers();
406 myViewerProxy->connectToViewer();
408 if (!isSalomeMode()) {
409 myMainWindow->showPythonConsole();
410 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
411 aWnd->showMaximized();
412 updateCommandStatus();
414 QApplication::restoreOverrideCursor();
417 //******************************************************
418 void XGUI_Workshop::onOpen()
420 //save current file before close if modified
421 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
422 DocumentPtr aDoc = aMgr->rootDocument();
423 if(aDoc->isModified()) {
424 //TODO(sbh): re-launch the app?
425 int anAnswer = QMessageBox::question(
426 myMainWindow, tr("Save current file"),
427 tr("The document is modified, save before opening another?"),
428 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
429 if(anAnswer == QMessageBox::Save) {
431 } else if (anAnswer == QMessageBox::Cancel) {
438 //show file dialog, check if readable and open
439 myCurrentFile = QFileDialog::getExistingDirectory(mainWindow());
440 if(myCurrentFile.isEmpty())
442 QFileInfo aFileInfo(myCurrentFile);
443 if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
444 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
448 QApplication::setOverrideCursor(Qt::WaitCursor);
449 aDoc->load(myCurrentFile.toLatin1().constData());
450 QApplication::restoreOverrideCursor();
451 updateCommandStatus();
454 //******************************************************
455 void XGUI_Workshop::onSave()
457 if(myCurrentFile.isEmpty()) {
461 saveDocument(myCurrentFile);
462 updateCommandStatus();
465 //******************************************************
466 void XGUI_Workshop::onSaveAs()
468 QString aTemp = myCurrentFile;
469 myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
470 if(myCurrentFile.isEmpty()) {
471 myCurrentFile = aTemp;
474 QFileInfo aFileInfo(myCurrentFile);
475 if(aFileInfo.exists() && !aFileInfo.isWritable()) {
476 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
482 //******************************************************
483 void XGUI_Workshop::onUndo()
485 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
486 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
487 DocumentPtr aDoc = aMgr->rootDocument();
488 if (aDoc->isOperation())
489 operationMgr()->abortOperation();
491 updateCommandStatus();
494 //******************************************************
495 void XGUI_Workshop::onRedo()
497 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
498 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
499 DocumentPtr aDoc = aMgr->rootDocument();
501 updateCommandStatus();
504 //******************************************************
505 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
508 QString::fromStdString(library(theModule.toStdString()));
509 if (libName.isEmpty()) {
511 qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) ));
516 CREATE_FUNC crtInst = 0;
519 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
523 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
524 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
525 QString aMsg((char*) &lpMsgBuf);
526 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
527 ::LocalFree(lpMsgBuf);
529 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
533 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
534 | FORMAT_MESSAGE_IGNORE_INSERTS,
535 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
536 QString aMsg((char*) &lpMsgBuf);
537 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
538 ::LocalFree(lpMsgBuf);
542 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
544 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
546 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
548 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
553 XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
555 if (!err.isEmpty()) {
557 QMessageBox::warning(mainWindow(), tr("Error"), err);
559 qWarning( qPrintable( err ));
565 //******************************************************
566 bool XGUI_Workshop::activateModule()
568 Config_ModuleReader aModuleReader;
569 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
570 myPartSetModule = loadModule(moduleName);
571 if (!myPartSetModule)
573 myPartSetModule->createFeatures();
577 //******************************************************
578 void XGUI_Workshop::updateCommandStatus()
580 QList<QAction*> aCommands;
581 if (isSalomeMode()) { // update commands in SALOME mode
582 aCommands = salomeConnector()->commandList();
584 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
585 foreach (XGUI_Command* aCmd, aMenuBar->features())
586 aCommands.append(aCmd);
588 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
589 if (aMgr->hasRootDocument()) {
592 foreach(QAction* aCmd, aCommands) {
593 QString aId = aCmd->data().toString();
594 if (aId == "UNDO_CMD")
596 else if (aId == "REDO_CMD")
598 else // Enable all commands
599 aCmd->setEnabled(true);
601 DocumentPtr aDoc = aMgr->rootDocument();
602 aUndoCmd->setEnabled(aDoc->canUndo());
603 aRedoCmd->setEnabled(aDoc->canRedo());
605 foreach(QAction* aCmd, aCommands) {
606 QString aId = aCmd->data().toString();
607 if (aId == "NEW_CMD")
608 aCmd->setEnabled(true);
609 else if (aId == "EXIT_CMD")
610 aCmd->setEnabled(true);
612 aCmd->setEnabled(false);
617 //******************************************************
618 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
620 QDockWidget* aObjDock = new QDockWidget(theParent);
621 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
622 aObjDock->setWindowTitle(tr("Object browser"));
623 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
624 connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
625 aObjDock->setWidget(myObjectBrowser);
627 myContextMenuMgr->connectObjectBrowser();
631 //******************************************************
633 * Creates dock widgets, places them in corresponding area
634 * and tabifies if necessary.
636 void XGUI_Workshop::createDockWidgets()
638 QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
640 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
641 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
642 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
643 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
644 hidePropertyPanel(); //<! Invisible by default
646 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
648 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
649 connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
650 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
651 connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
654 //******************************************************
655 void XGUI_Workshop::showPropertyPanel()
657 QAction* aViewAct = myPropertyPanel->toggleViewAction();
658 //<! Restore ability to close panel from the window's menu
659 aViewAct->setEnabled(true);
660 myPropertyPanel->show();
661 myPropertyPanel->raise();
664 //******************************************************
665 void XGUI_Workshop::hidePropertyPanel()
667 QAction* aViewAct = myPropertyPanel->toggleViewAction();
668 //<! Do not allow to show empty property panel
669 aViewAct->setEnabled(false);
670 myPropertyPanel->hide();
673 //******************************************************
674 void XGUI_Workshop::showObjectBrowser()
676 myObjectBrowser->parentWidget()->show();
679 //******************************************************
680 void XGUI_Workshop::hideObjectBrowser()
682 myObjectBrowser->parentWidget()->hide();
685 //******************************************************
686 void XGUI_Workshop::onFeatureTriggered()
688 QAction* aCmd = dynamic_cast<QAction*>(sender());
690 QString aId = salomeConnector()->commandId(aCmd);
692 myPartSetModule->launchOperation(aId);
696 //******************************************************
697 void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
699 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
701 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
703 aMgr->setCurrentDocument(aDocRef->value());
705 aMgr->setCurrentDocument(aMgr->rootDocument());
709 //******************************************************
710 void XGUI_Workshop::salomeViewerSelectionChanged()
712 emit salomeViewerSelection();
716 //**************************************************************
717 XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
719 return mySalomeConnector->viewer();
722 //**************************************************************
723 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
725 QFeatureList aFeatures = mySelector->selectedFeatures();
726 if ((theId == "ACTIVATE_PART_CMD") && (aFeatures.size() > 0))
727 activatePart(aFeatures.first());
728 else if (theId == "DEACTIVATE_PART_CMD")
729 activatePart(FeaturePtr());
733 //**************************************************************
734 void XGUI_Workshop::activatePart(FeaturePtr theFeature)
736 changeCurrentDocument(theFeature);
737 myObjectBrowser->activatePart(theFeature);
740 //**************************************************************
741 void XGUI_Workshop::activateLastPart()
743 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
744 DocumentPtr aDoc = aMgr->rootDocument();
745 FeaturePtr aLastPart = aDoc->feature(PARTS_GROUP, aDoc->size(PARTS_GROUP) - 1, true);
746 activatePart(aLastPart);