1 #include "ModuleBase_IModule.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 "XGUI_SelectionMgr.h"
12 #include "XGUI_Selection.h"
13 #include "XGUI_ObjectsBrowser.h"
14 #include "XGUI_Displayer.h"
15 #include "XGUI_OperationMgr.h"
16 #include "XGUI_SalomeConnector.h"
17 #include "XGUI_ActionsMgr.h"
18 #include "XGUI_ErrorDialog.h"
19 #include "XGUI_ViewerProxy.h"
20 #include "XGUI_PropertyPanel.h"
21 #include "XGUI_ContextMenuMgr.h"
22 #include "XGUI_ModuleConnector.h"
23 #include "XGUI_Preferences.h"
24 #include <XGUI_QtEvents.h>
26 #include <ModelAPI_Events.h>
27 #include <ModelAPI_Session.h>
28 #include <ModelAPI_Feature.h>
29 #include <ModelAPI_Data.h>
30 #include <ModelAPI_AttributeDocRef.h>
31 #include <ModelAPI_Object.h>
32 #include <ModelAPI_Validator.h>
33 #include <ModelAPI_ResultConstruction.h>
34 #include <ModelAPI_ResultBody.h>
36 #include <PartSetPlugin_Part.h>
38 #include <Events_Loop.h>
39 #include <Events_Error.h>
40 #include <Events_LongOp.h>
42 #include <ModuleBase_Operation.h>
43 #include <ModuleBase_Operation.h>
44 #include <ModuleBase_OperationDescription.h>
45 #include <ModuleBase_SelectionValidator.h>
46 #include <ModuleBase_WidgetFactory.h>
47 #include <ModuleBase_Tools.h>
48 #include <ModuleBase_IViewer.h>
50 #include <Config_Common.h>
51 #include <Config_FeatureMessage.h>
52 #include <Config_PointerMessage.h>
53 #include <Config_ModuleReader.h>
55 #include <QApplication>
56 #include <QFileDialog>
57 #include <QMessageBox>
58 #include <QMdiSubWindow>
59 #include <QPushButton>
60 #include <QDockWidget>
76 QMap<QString, QString> XGUI_Workshop::myIcons;
78 QString XGUI_Workshop::featureIcon(const std::string& theId)
80 QString aId(theId.c_str());
81 if (myIcons.contains(aId))
86 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
88 myCurrentDir(QString()),
90 mySalomeConnector(theConnector),
95 myPartActivating(false)
97 myMainWindow = mySalomeConnector ? 0 : new XGUI_MainWindow();
99 myDisplayer = new XGUI_Displayer(this);
101 mySelector = new XGUI_SelectionMgr(this);
102 //connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands()));
104 myOperationMgr = new XGUI_OperationMgr(this);
105 myActionsMgr = new XGUI_ActionsMgr(this);
106 myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
107 myContextMenuMgr = new XGUI_ContextMenuMgr(this);
108 connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
109 SLOT(onContextMenuCommand(const QString&, bool)));
111 myViewerProxy = new XGUI_ViewerProxy(this);
112 connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection()));
114 myModuleConnector = new XGUI_ModuleConnector(this);
116 connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
117 SLOT(onOperationStarted()));
118 connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
119 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
120 SLOT(onOperationStopped(ModuleBase_Operation*)));
121 connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
122 connect(myOperationMgr, SIGNAL(operationStarted()), myActionsMgr, SLOT(update()));
123 connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), myActionsMgr,
125 connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
128 //******************************************************
129 XGUI_Workshop::~XGUI_Workshop(void)
134 //******************************************************
135 void XGUI_Workshop::startApplication()
138 //Initialize event listening
139 Events_Loop* aLoop = Events_Loop::loop();
140 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
141 //TODO(sbh): Implement static method to extract event id [SEID]
142 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED));
143 // TODO Is it good to use non standard event within workshop?
144 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
145 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
146 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
147 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
148 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
149 aLoop->registerListener(this, Events_Loop::eventByName("LongOperation"));
150 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
151 aLoop->registerListener(this, Events_Loop::eventByName("CurrentDocumentChanged"));
152 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOSHOW));
153 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
155 registerValidators();
158 myMainWindow->show();
159 updateCommandStatus();
161 XGUI_Preferences::loadCustomProps();
165 //******************************************************
166 void XGUI_Workshop::initMenu()
168 myContextMenuMgr->createActions();
170 if (isSalomeMode()) {
171 // Create only Undo, Redo commands
172 QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD", tr("Undo"),
173 tr("Undo last command"),
174 QIcon(":pictures/undo.png"),
175 QKeySequence::Undo, false);
176 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
177 aAction = salomeConnector()->addEditCommand("REDO_CMD", tr("Redo"), tr("Redo last command"),
178 QIcon(":pictures/redo.png"), QKeySequence::Redo,
180 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo()));
181 salomeConnector()->addEditMenuSeparator();
182 aAction = salomeConnector()->addEditCommand("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
183 QIcon(":pictures/rebuild.png"), QKeySequence(),
185 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild()));
186 salomeConnector()->addEditMenuSeparator();
189 // File commands group
190 XGUI_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
192 XGUI_Command* aCommand;
194 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
195 QIcon(":pictures/save.png"), QKeySequence::Save);
196 aCommand->connectTo(this, SLOT(onSave()));
197 //aCommand->disable();
199 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
200 QIcon(":pictures/undo.png"), QKeySequence::Undo);
201 aCommand->connectTo(this, SLOT(onUndo()));
203 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
204 QIcon(":pictures/redo.png"), QKeySequence::Redo);
205 aCommand->connectTo(this, SLOT(onRedo()));
207 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
208 QIcon(":pictures/rebuild.png"), QKeySequence());
209 aCommand->connectTo(this, SLOT(onRebuild()));
211 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
212 QIcon(":pictures/save.png"), QKeySequence());
213 aCommand->connectTo(this, SLOT(onSaveAs()));
214 //aCommand->disable();
216 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
217 QIcon(":pictures/open.png"), QKeySequence::Open);
218 aCommand->connectTo(this, SLOT(onOpen()));
220 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
221 // QIcon(":pictures/new.png"), QKeySequence::New);
222 //aCommand->connectTo(this, SLOT(onNew()));
224 aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
225 QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
226 aCommand->connectTo(this, SLOT(onPreferences()));
228 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
229 QIcon(":pictures/close.png"), QKeySequence::Close);
230 aCommand->connectTo(this, SLOT(onExit()));
231 //FIXME: SBH's test action. Can be used for some GUI tests.
233 // aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
234 // QIcon(":pictures/close.png"), QKeySequence(), true);
235 // aCommand->connectTo(myMainWindow, SLOT(dockPythonConsole()));
239 //******************************************************
240 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
242 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
243 return aMenuBar->addWorkbench(theName);
246 //******************************************************
247 void XGUI_Workshop::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
249 if (QApplication::instance()->thread() != QThread::currentThread()) {
251 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
253 SessionPtr aMgr = ModelAPI_Session::get();
254 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
255 QApplication::postEvent(this, aPostponeEvent);
259 //A message to start feature creation received.
260 if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) {
261 boost::shared_ptr<Config_FeatureMessage> aFeatureMsg =
262 boost::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
263 if (!aFeatureMsg->isInternal()) {
264 addFeature(aFeatureMsg);
268 // Process creation of Part
269 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
270 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
271 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
272 onFeatureCreatedMsg(aUpdMsg);
274 if (mySalomeConnector)
275 mySalomeConnector->createPreferences();
276 myUpdatePrefs = false;
279 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
280 myUpdatePrefs = true;
284 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
285 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
286 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
287 onFeatureRedisplayMsg(aUpdMsg);
290 //Update property panel on corresponding message. If there is no current operation (no
291 //property panel), or received message has different feature to the current - do nothing.
292 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
293 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
294 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
295 onFeatureUpdatedMsg(anUpdateMsg);
298 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
299 boost::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
300 boost::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
301 onObjectDeletedMsg(aDelMsg);
304 else if (theMessage->eventID() == Events_LongOp::eventID()) {
305 if (Events_LongOp::isPerformed())
306 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
308 QApplication::restoreOverrideCursor();
311 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW)) {
312 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
313 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
314 const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
315 QList<ObjectPtr> aList;
316 std::set<ObjectPtr>::const_iterator aIt;
317 for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
319 showObjects(aList, true);
322 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOHIDE)) {
323 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
324 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
325 const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
326 QList<ObjectPtr> aList;
327 std::set<ObjectPtr>::const_iterator aIt;
328 for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
330 showObjects(aList, false);
333 //An operation passed by message. Start it, process and commit.
334 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
335 boost::shared_ptr<Config_PointerMessage> aPartSetMsg =
336 boost::dynamic_pointer_cast<Config_PointerMessage>(theMessage);
337 //myPropertyPanel->cleanContent();
338 ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer();
340 if (myOperationMgr->startOperation(anOperation)) {
341 myPropertyPanel->updateContentWidget(anOperation->feature());
342 if (!anOperation->getDescription()->hasXmlRepresentation()) {
343 if (anOperation->commit())
344 updateCommandStatus();
348 else if (theMessage->eventID() == Events_Loop::loop()->eventByName("CurrentDocumentChanged")) {
349 myActionsMgr->update();
350 // Find and Activate active part
351 if (myPartActivating)
353 SessionPtr aMgr = ModelAPI_Session::get();
354 DocumentPtr aActiveDoc = aMgr->activeDocument();
355 DocumentPtr aDoc = aMgr->moduleDocument();
356 if (aActiveDoc == aDoc) {
357 activatePart(ResultPartPtr());
360 std::string aGrpName = ModelAPI_ResultPart::group();
361 for (int i = 0; i < aDoc->size(aGrpName); i++) {
362 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aDoc->object(aGrpName, i));
363 if (aPart->partDoc() == aActiveDoc) {
364 activatePart(aPart); // Activate a part which corresponds to active Doc
368 // If not found then activate global document
369 activatePart(ResultPartPtr());
372 //Show error dialog if error message received.
373 boost::shared_ptr<Events_Error> anAppError = boost::dynamic_pointer_cast<Events_Error>(theMessage);
375 emit errorOccurred(QString::fromLatin1(anAppError->description()));
378 if (!isSalomeMode()) {
379 SessionPtr aMgr = ModelAPI_Session::get();
380 if (aMgr->isModified() != myMainWindow->isModifiedState())
381 myMainWindow->setModifiedState(aMgr->isModified());
386 //******************************************************
387 void XGUI_Workshop::onStartWaiting()
389 if (Events_LongOp::isPerformed()) {
390 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
394 //******************************************************
395 void XGUI_Workshop::onFeatureUpdatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
397 std::set<ObjectPtr> aFeatures = theMsg->objects();
398 if (myOperationMgr->hasOperation()) {
399 FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
400 std::set<ObjectPtr>::const_iterator aIt;
401 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
402 ObjectPtr aNewFeature = (*aIt);
403 if (aNewFeature == aCurrentFeature) {
404 myPropertyPanel->updateContentWidget(aCurrentFeature);
409 myOperationMgr->onValidateOperation();
411 myObjectBrowser->processEvent(theMsg);
414 //******************************************************
415 void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
417 std::set<ObjectPtr> aObjects = theMsg->objects();
418 std::set<ObjectPtr>::const_iterator aIt;
420 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
421 ObjectPtr aObj = (*aIt);
422 if (!aObj->data() || !aObj->data()->isValid() || aObj->document()->isConcealed(aObj))
423 myDisplayer->erase(aObj, false);
425 if (myDisplayer->isVisible(aObj)) {
426 myDisplayer->display(aObj, false); // In order to update presentation
427 if (myOperationMgr->hasOperation()) {
428 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
429 if (!aOperation->hasObject(aObj))
430 if (!myDisplayer->isActive(aObj))
431 myDisplayer->activate(aObj, aModes);
434 if (myOperationMgr->hasOperation()) {
435 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
436 // Display only current operation results if operation has preview
437 if (aOperation->hasObject(aObj) && aOperation->hasPreview()) {
438 myDisplayer->display(aObj, false);
439 // Deactivate object of current operation from selection
440 if (myDisplayer->isActive(aObj))
441 myDisplayer->deactivate(aObj);
447 myDisplayer->updateViewer();
450 //******************************************************
451 void XGUI_Workshop::onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
453 std::set<ObjectPtr> aObjects = theMsg->objects();
455 std::set<ObjectPtr>::const_iterator aIt;
456 bool aHasPart = false;
457 bool isDisplayed = false;
458 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
459 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
462 // If a feature is created from the aplication's python console
463 // it doesn't stored in the operation mgr and doesn't displayed
464 } else if (myOperationMgr->hasOperation()) {
465 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
466 if (!(*aIt)->document()->isConcealed(*aIt) &&
467 aOperation->hasObject(*aIt)) { // Display only current operation results
468 myDisplayer->display(*aIt, false);
474 myObjectBrowser->processEvent(theMsg);
476 myDisplayer->updateViewer();
477 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
478 // activateLastPart();
482 //******************************************************
483 void XGUI_Workshop::onObjectDeletedMsg(const boost::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg)
486 myObjectBrowser->processEvent(theMsg);
487 //std::set<ObjectPtr> aFeatures = theMsg->objects();
490 //******************************************************
491 void XGUI_Workshop::onOperationStarted()
493 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
494 if (this->isSalomeMode())
495 aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
497 aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
499 if (aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel
500 connectWithOperation(aOperation);
503 QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
504 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
507 myPropertyPanel->cleanContent();
508 aFactory.createWidget(myPropertyPanel->contentWidget());
509 ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
511 QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
512 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
513 ModuleBase_ModelWidget* aWidget;
514 for (; anIt != aLast; anIt++) {
516 aWidget->setFeature(aOperation->feature());
517 aWidget->enableFocusProcessing();
518 QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
519 // Init default values
520 if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
521 aWidget->storeValue();
525 aOperation->setPropertyPanel(myPropertyPanel);
526 myPropertyPanel->setModelWidgets(aWidgets);
527 myPropertyPanel->activateNextWidget(NULL);
528 // Widget activation (from the previous method) may commit the current operation
529 // if pre-selection is enougth for it. So we shouldn't update prop panel's title
530 if(myOperationMgr->isCurrentOperation(aOperation)) {
531 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
534 updateCommandStatus();
537 //******************************************************
538 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
540 //!< No need for property panel
541 updateCommandStatus();
543 myPropertyPanel->cleanContent();
546 bool XGUI_Workshop::event(QEvent * theEvent)
548 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
550 boost::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
551 processEvent(aEventPtr);
560 void XGUI_Workshop::addFeature(const boost::shared_ptr<Config_FeatureMessage>& theMessage)
564 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
568 // Remember features icons
569 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
571 //Find or create Workbench
572 QString aWchName = QString::fromStdString(theMessage->workbenchId());
573 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
574 bool isUsePropPanel = theMessage->isUseInput();
575 QString aFeatureId = QString::fromStdString(theMessage->id());
576 if (isSalomeMode()) {
577 QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureId,
578 QString::fromStdString(theMessage->text()),
579 QString::fromStdString(theMessage->tooltip()),
580 QIcon(theMessage->icon().c_str()),
583 salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
584 myActionsMgr->addCommand(aAction);
585 myModule->featureCreated(aAction);
588 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
589 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
591 aPage = addWorkbench(aWchName);
593 //Find or create Group
594 QString aGroupName = QString::fromStdString(theMessage->groupId());
595 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
597 aGroup = aPage->addGroup(aGroupName);
599 QString aDocKind = QString::fromStdString(theMessage->documentKind());
600 // Check if hotkey sequence is already defined:
601 QKeySequence aHotKey = myActionsMgr->registerShortcut(
602 QString::fromStdString(theMessage->keysequence()));
604 XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
605 QString::fromStdString(theMessage->text()),
606 QString::fromStdString(theMessage->tooltip()),
607 QIcon(theMessage->icon().c_str()),
611 aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
612 myActionsMgr->addCommand(aCommand);
613 myModule->featureCreated(aCommand);
618 * Makes a signal/slot connections between Property Panel
619 * and given operation. The given operation becomes a
620 * current operation and previous operation if exists
622 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
624 QAction* aCommand = 0;
625 if (isSalomeMode()) {
626 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
628 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
629 FeaturePtr aFeature = theOperation->feature();
631 aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
633 //Abort operation on uncheck the command
635 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
640 * Saves document with given name.
642 void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
644 QApplication::restoreOverrideCursor();
645 SessionPtr aMgr = ModelAPI_Session::get();
646 aMgr->save(theName.toLatin1().constData(), theFileNames);
647 QApplication::restoreOverrideCursor();
650 bool XGUI_Workshop::isActiveOperationAborted()
652 return myOperationMgr->abortAllOperations();
655 //******************************************************
656 void XGUI_Workshop::onExit()
658 SessionPtr aMgr = ModelAPI_Session::get();
659 if (aMgr->isModified()) {
660 int anAnswer = QMessageBox::question(
661 myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
662 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
663 if (anAnswer == QMessageBox::Save) {
664 bool saved = onSave();
668 } else if (anAnswer == QMessageBox::Cancel) {
675 //******************************************************
676 void XGUI_Workshop::onNew()
678 QApplication::setOverrideCursor(Qt::WaitCursor);
679 if (objectBrowser() == 0) {
681 mySelector->connectViewers();
683 myViewerProxy->connectToViewer();
685 if (!isSalomeMode()) {
686 myMainWindow->showPythonConsole();
687 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
688 aWnd->showMaximized();
689 updateCommandStatus();
691 myContextMenuMgr->connectViewer();
692 QApplication::restoreOverrideCursor();
695 //******************************************************
696 void XGUI_Workshop::onOpen()
698 if(!isActiveOperationAborted())
700 //save current file before close if modified
701 SessionPtr aSession = ModelAPI_Session::get();
702 if (aSession->isModified()) {
703 //TODO(sbh): re-launch the app?
704 int anAnswer = QMessageBox::question(
705 myMainWindow, tr("Save current file"),
706 tr("The document is modified, save before opening another?"),
707 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
708 if (anAnswer == QMessageBox::Save) {
710 } else if (anAnswer == QMessageBox::Cancel) {
713 aSession->moduleDocument()->close();
717 //show file dialog, check if readable and open
718 myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
719 if (myCurrentDir.isEmpty())
721 QFileInfo aFileInfo(myCurrentDir);
722 if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
723 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
727 QApplication::setOverrideCursor(Qt::WaitCursor);
728 aSession->load(myCurrentDir.toLatin1().constData());
729 myObjectBrowser->rebuildDataTree();
731 updateCommandStatus();
732 QApplication::restoreOverrideCursor();
735 //******************************************************
736 bool XGUI_Workshop::onSave()
738 if(!isActiveOperationAborted())
740 if (myCurrentDir.isEmpty()) {
743 std::list<std::string> aFiles;
744 saveDocument(myCurrentDir, aFiles);
745 updateCommandStatus();
746 myMainWindow->setModifiedState(false);
750 //******************************************************
751 bool XGUI_Workshop::onSaveAs()
753 if(!isActiveOperationAborted())
755 QFileDialog dialog(mainWindow());
756 dialog.setWindowTitle(tr("Select directory to save files..."));
757 dialog.setFileMode(QFileDialog::Directory);
758 dialog.setFilter(tr("Folders (*)"));
759 dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
760 dialog.setViewMode(QFileDialog::Detail);
762 if (!dialog.exec()) {
765 QString aTempDir = dialog.selectedFiles().first();
767 if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) {
768 int answer = QMessageBox::question(
770 //: Title of the dialog which asks user if he wants to save study in existing non-empty folder
772 tr("The folder already contains some files, save anyway?"),
773 QMessageBox::Save | QMessageBox::Cancel);
774 if (answer == QMessageBox::Cancel) {
778 myCurrentDir = aTempDir;
779 if (!isSalomeMode()) {
780 myMainWindow->setCurrentDir(myCurrentDir, false);
781 myMainWindow->setModifiedState(false);
786 //******************************************************
787 void XGUI_Workshop::onUndo()
789 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
790 SessionPtr aMgr = ModelAPI_Session::get();
791 if (aMgr->isOperation())
792 operationMgr()->onAbortOperation();
794 updateCommandStatus();
797 //******************************************************
798 void XGUI_Workshop::onRedo()
800 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
801 SessionPtr aMgr = ModelAPI_Session::get();
802 if (aMgr->isOperation())
803 operationMgr()->onAbortOperation();
805 updateCommandStatus();
808 //******************************************************
809 void XGUI_Workshop::onRebuild()
811 SessionPtr aMgr = ModelAPI_Session::get();
812 bool aWasOperation = aMgr->isOperation(); // keep this value
813 if (!aWasOperation) {
814 aMgr->startOperation();
816 static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild");
817 Events_Loop::loop()->send(boost::shared_ptr<Events_Message>(
818 new Events_Message(aRebuildEvent, this)));
819 if (!aWasOperation) {
820 aMgr->finishOperation();
824 //******************************************************
825 void XGUI_Workshop::onPreferences()
828 XGUI_Preferences::editPreferences(aModif);
829 if (aModif.size() > 0) {
831 foreach (XGUI_Pref aPref, aModif)
833 aSection = aPref.first;
834 if (aSection == XGUI_Preferences::VIEWER_SECTION) {
836 myMainWindow->viewer()->updateFromResources();
837 } else if (aSection == XGUI_Preferences::MENU_SECTION) {
839 myMainWindow->menuObject()->updateFromResources();
845 //******************************************************
846 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
848 QString libName = QString::fromStdString(library(theModule.toStdString()));
849 if (libName.isEmpty()) {
850 qWarning(qPrintable(tr("Information about module \"%1\" doesn't exist.").arg(theModule)));
855 CREATE_FUNC crtInst = 0;
858 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
862 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
863 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
864 QString aMsg((char*) &lpMsgBuf);
865 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
866 ::LocalFree(lpMsgBuf);
868 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
872 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
873 | FORMAT_MESSAGE_IGNORE_INSERTS,
874 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
875 QString aMsg((char*) &lpMsgBuf);
876 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
877 ::LocalFree(lpMsgBuf);
881 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY | RTLD_GLOBAL );
883 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
885 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
887 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
892 ModuleBase_IModule* aModule = crtInst ? crtInst(myModuleConnector) : 0;
894 if (!err.isEmpty()) {
896 Events_Error::send(err.toStdString());
898 qWarning(qPrintable(err));
904 //******************************************************
905 bool XGUI_Workshop::activateModule()
907 Config_ModuleReader aModuleReader;
908 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
909 myModule = loadModule(moduleName);
912 myModule->createFeatures();
913 myActionsMgr->update();
917 //******************************************************
918 void XGUI_Workshop::updateCommandStatus()
920 QList<QAction*> aCommands;
921 if (isSalomeMode()) { // update commands in SALOME mode
922 aCommands = salomeConnector()->commandList();
924 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
925 foreach (XGUI_Command* aCmd, aMenuBar->features())
926 aCommands.append(aCmd);
928 SessionPtr aMgr = ModelAPI_Session::get();
929 if (aMgr->hasModuleDocument()) {
932 foreach(QAction* aCmd, aCommands) {
933 QString aId = aCmd->data().toString();
934 if (aId == "UNDO_CMD")
936 else if (aId == "REDO_CMD")
939 // Enable all commands
940 aCmd->setEnabled(true);
942 aUndoCmd->setEnabled(aMgr->canUndo());
943 aRedoCmd->setEnabled(aMgr->canRedo());
945 foreach(QAction* aCmd, aCommands) {
946 QString aId = aCmd->data().toString();
947 if (aId == "NEW_CMD")
948 aCmd->setEnabled(true);
949 else if (aId == "EXIT_CMD")
950 aCmd->setEnabled(true);
952 aCmd->setEnabled(false);
955 myActionsMgr->update();
958 //******************************************************
959 QList<QAction*> XGUI_Workshop::getModuleCommands() const
961 QList<QAction*> aCommands;
962 if (isSalomeMode()) { // update commands in SALOME mode
963 aCommands = salomeConnector()->commandList();
965 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
966 foreach(XGUI_Command* aCmd, aMenuBar->features())
968 aCommands.append(aCmd);
974 //******************************************************
975 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
977 QDockWidget* aObjDock = new QDockWidget(theParent);
978 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
979 aObjDock->setWindowTitle(tr("Object browser"));
980 aObjDock->setStyleSheet(
981 "::title { position: relative; padding-left: 5px; text-align: left center }");
982 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
983 connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
984 SLOT(changeCurrentDocument(ObjectPtr)));
985 aObjDock->setWidget(myObjectBrowser);
987 myContextMenuMgr->connectObjectBrowser();
991 //******************************************************
993 * Creates dock widgets, places them in corresponding area
994 * and tabifies if necessary.
996 void XGUI_Workshop::createDockWidgets()
998 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
999 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
1000 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
1001 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
1002 myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
1003 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
1004 hidePropertyPanel(); //<! Invisible by default
1005 hideObjectBrowser();
1006 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
1008 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
1009 connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
1010 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
1011 connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
1012 connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
1013 SLOT(onKeyReleased(QKeyEvent*)));
1014 //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
1015 // SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
1016 //connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
1017 // SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
1018 connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
1019 SLOT(setAcceptEnabled(bool)));
1023 //******************************************************
1024 void XGUI_Workshop::showPropertyPanel()
1026 QAction* aViewAct = myPropertyPanel->toggleViewAction();
1027 //<! Restore ability to close panel from the window's menu
1028 aViewAct->setEnabled(true);
1029 myPropertyPanel->show();
1030 myPropertyPanel->raise();
1033 //******************************************************
1034 void XGUI_Workshop::hidePropertyPanel()
1036 QAction* aViewAct = myPropertyPanel->toggleViewAction();
1037 //<! Do not allow to show empty property panel
1038 aViewAct->setEnabled(false);
1039 myPropertyPanel->hide();
1042 //******************************************************
1043 void XGUI_Workshop::showObjectBrowser()
1045 myObjectBrowser->parentWidget()->show();
1048 //******************************************************
1049 void XGUI_Workshop::hideObjectBrowser()
1051 myObjectBrowser->parentWidget()->hide();
1054 //******************************************************
1055 void XGUI_Workshop::onFeatureTriggered()
1057 QAction* aCmd = dynamic_cast<QAction*>(sender());
1059 QString aId = salomeConnector()->commandId(aCmd);
1061 myModule->launchOperation(aId);
1065 //******************************************************
1066 void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
1068 SessionPtr aMgr = ModelAPI_Session::get();
1070 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(theObj);
1072 DocumentPtr aPartDoc = aPart->partDoc();
1074 aMgr->setActiveDocument(aPartDoc);
1079 aMgr->setActiveDocument(aMgr->moduleDocument());
1082 //******************************************************
1083 void XGUI_Workshop::salomeViewerSelectionChanged()
1085 emit salomeViewerSelection();
1088 //**************************************************************
1089 ModuleBase_IViewer* XGUI_Workshop::salomeViewer() const
1091 return mySalomeConnector->viewer();
1094 //**************************************************************
1095 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
1097 QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
1098 if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
1099 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
1100 activatePart(aPart);
1101 } else if (theId == "DEACTIVATE_PART_CMD")
1102 activatePart(ResultPartPtr());
1103 else if (theId == "DELETE_CMD")
1104 deleteObjects(aObjects);
1105 else if (theId == "SHOW_CMD")
1106 showObjects(aObjects, true);
1107 else if (theId == "HIDE_CMD")
1108 showObjects(aObjects, false);
1109 else if (theId == "SHOW_ONLY_CMD")
1110 showOnlyObjects(aObjects);
1111 else if (theId == "SHADING_CMD")
1112 setDisplayMode(aObjects, XGUI_Displayer::Shading);
1113 else if (theId == "WIREFRAME_CMD")
1114 setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
1115 else if (theId == "HIDEALL_CMD")
1116 myDisplayer->eraseAll();
1119 //**************************************************************
1120 void XGUI_Workshop::onWidgetValuesChanged()
1122 ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
1123 FeaturePtr aFeature = anOperation->feature();
1125 ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
1127 // aCustom->storeValue(aFeature);
1129 const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
1130 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
1131 for (; anIt != aLast; anIt++) {
1132 ModuleBase_ModelWidget* aCustom = *anIt;
1133 if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) {
1134 //aCustom->storeValue(aFeature);
1135 aCustom->storeValue();
1140 //**************************************************************
1141 void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
1143 if (!myPartActivating) {
1144 myPartActivating = true;
1146 theFeature->activate();
1147 changeCurrentDocument(theFeature);
1148 myObjectBrowser->activatePart(theFeature);
1149 myPartActivating = false;
1153 //**************************************************************
1154 void XGUI_Workshop::activateLastPart()
1156 SessionPtr aMgr = ModelAPI_Session::get();
1157 DocumentPtr aDoc = aMgr->moduleDocument();
1158 std::string aGrpName = ModelAPI_ResultPart::group();
1159 ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
1160 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
1162 activatePart(aPart);
1166 //**************************************************************
1167 void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
1169 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
1170 QMessageBox::StandardButton aRes = QMessageBox::warning(
1171 aDesktop, tr("Delete features"), tr("Seleted features will be deleted. Continue?"),
1172 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
1173 // ToDo: definbe deleting method
1174 if (aRes == QMessageBox::Yes) {
1175 SessionPtr aMgr = ModelAPI_Session::get();
1176 aMgr->startOperation();
1177 foreach (ObjectPtr aObj, theList)
1179 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
1181 DocumentPtr aDoc = aPart->document();
1182 if (aDoc == aMgr->activeDocument()) {
1185 //aMgr->moduleDocument()->removeFeature(aPart->owner());
1187 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
1189 aObj->document()->removeFeature(aFeature);
1192 myDisplayer->updateViewer();
1193 aMgr->finishOperation();
1197 //**************************************************************
1198 void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
1200 foreach (ObjectPtr aObj, theList)
1202 ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
1205 myDisplayer->display(aRes, false);
1207 myDisplayer->erase(aRes, false);
1211 myDisplayer->updateViewer();
1214 //**************************************************************
1215 void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
1217 myDisplayer->eraseAll(false);
1218 showObjects(theList, true);
1222 //**************************************************************
1223 void XGUI_Workshop::updateCommandsOnViewSelection()
1225 XGUI_Selection* aSelection = mySelector->selection();
1226 if (aSelection->getSelected().size() == 0)
1229 // Restrict validators to manage only nested (child) features
1230 // of the current feature i.e. if current feature is Sketch -
1231 // Sketch Features & Constraints can be validated.
1232 QStringList aNestedIds;
1233 if(myOperationMgr->hasOperation()) {
1234 FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
1236 aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
1239 SessionPtr aMgr = ModelAPI_Session::get();
1240 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1241 QList<QAction*> aActions = getModuleCommands();
1242 foreach(QAction* aAction, aActions) {
1243 QString aId = aAction->data().toString();
1244 if(!aNestedIds.contains(aId))
1246 std::list<ModelAPI_Validator*> aValidators;
1247 std::list<std::list<std::string> > anArguments;
1248 aFactory->validators(aId.toStdString(), aValidators, anArguments);
1249 std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
1250 for (; aValidator != aValidators.end(); aValidator++) {
1252 const ModuleBase_SelectionValidator* aSelValidator =
1253 dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
1254 if (aSelValidator) {
1255 aAction->setEnabled(aSelValidator->isValid(aSelection));
1262 //**************************************************************
1263 void XGUI_Workshop::registerValidators() const
1265 SessionPtr aMgr = ModelAPI_Session::get();
1266 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1269 //**************************************************************
1270 void XGUI_Workshop::displayAllResults()
1272 SessionPtr aMgr = ModelAPI_Session::get();
1273 DocumentPtr aRootDoc = aMgr->moduleDocument();
1274 displayDocumentResults(aRootDoc);
1275 for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {
1276 ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
1277 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
1278 displayDocumentResults(aPart->partDoc());
1280 myDisplayer->updateViewer();
1283 //**************************************************************
1284 void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc)
1288 displayGroupResults(theDoc, ModelAPI_ResultConstruction::group());
1289 displayGroupResults(theDoc, ModelAPI_ResultBody::group());
1292 //**************************************************************
1293 void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup)
1295 for (int i = 0; i < theDoc->size(theGroup); i++)
1296 myDisplayer->display(theDoc->object(theGroup, i), false);
1299 //**************************************************************
1300 void XGUI_Workshop::setDisplayMode(const QList<ObjectPtr>& theList, int theMode)
1302 foreach(ObjectPtr aObj, theList) {
1303 myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
1305 if (theList.size() > 0)
1306 myDisplayer->updateViewer();