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 bool aHide = !aObj->data() || !aObj->data()->isValid();
423 if (!aHide) { // check that this is not hidden result
424 ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
425 aHide = aRes && aRes->isConcealed();
428 myDisplayer->erase(aObj, false);
430 if (myDisplayer->isVisible(aObj)) {
431 myDisplayer->display(aObj, false); // In order to update presentation
432 if (myOperationMgr->hasOperation()) {
433 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
434 if (!aOperation->hasObject(aObj))
435 if (!myDisplayer->isActive(aObj))
436 myDisplayer->activate(aObj, aModes);
439 if (myOperationMgr->hasOperation()) {
440 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
441 // Display only current operation results if operation has preview
442 if (aOperation->hasObject(aObj) && aOperation->hasPreview()) {
443 myDisplayer->display(aObj, false);
444 // Deactivate object of current operation from selection
445 if (myDisplayer->isActive(aObj))
446 myDisplayer->deactivate(aObj);
452 myDisplayer->updateViewer();
455 //******************************************************
456 void XGUI_Workshop::onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
458 std::set<ObjectPtr> aObjects = theMsg->objects();
460 std::set<ObjectPtr>::const_iterator aIt;
461 bool aHasPart = false;
462 bool isDisplayed = false;
463 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
464 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
467 // If a feature is created from the aplication's python console
468 // it doesn't stored in the operation mgr and doesn't displayed
469 } else if (myOperationMgr->hasOperation()) {
470 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
471 if (aOperation->hasObject(*aIt)) { // Display only current operation results
472 myDisplayer->display(*aIt, false);
478 myObjectBrowser->processEvent(theMsg);
480 myDisplayer->updateViewer();
481 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
482 // activateLastPart();
486 //******************************************************
487 void XGUI_Workshop::onObjectDeletedMsg(const boost::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg)
490 myObjectBrowser->processEvent(theMsg);
491 //std::set<ObjectPtr> aFeatures = theMsg->objects();
494 //******************************************************
495 void XGUI_Workshop::onOperationStarted()
497 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
498 if (this->isSalomeMode())
499 aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
501 aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
503 if (aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel
504 connectWithOperation(aOperation);
507 QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
508 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
511 myPropertyPanel->cleanContent();
512 aFactory.createWidget(myPropertyPanel->contentWidget());
513 ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
515 QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
516 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
517 ModuleBase_ModelWidget* aWidget;
518 for (; anIt != aLast; anIt++) {
520 aWidget->setFeature(aOperation->feature());
521 aWidget->enableFocusProcessing();
522 QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
523 // Init default values
524 if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
525 aWidget->storeValue();
529 aOperation->setPropertyPanel(myPropertyPanel);
530 myPropertyPanel->setModelWidgets(aWidgets);
531 myPropertyPanel->activateNextWidget(NULL);
532 // Widget activation (from the previous method) may commit the current operation
533 // if pre-selection is enougth for it. So we shouldn't update prop panel's title
534 if(myOperationMgr->isCurrentOperation(aOperation)) {
535 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
538 updateCommandStatus();
541 //******************************************************
542 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
544 //!< No need for property panel
545 updateCommandStatus();
547 myPropertyPanel->cleanContent();
550 bool XGUI_Workshop::event(QEvent * theEvent)
552 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
554 boost::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
555 processEvent(aEventPtr);
564 void XGUI_Workshop::addFeature(const boost::shared_ptr<Config_FeatureMessage>& theMessage)
568 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
572 // Remember features icons
573 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
575 //Find or create Workbench
576 QString aWchName = QString::fromStdString(theMessage->workbenchId());
577 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
578 bool isUsePropPanel = theMessage->isUseInput();
579 QString aFeatureId = QString::fromStdString(theMessage->id());
580 if (isSalomeMode()) {
581 QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureId,
582 QString::fromStdString(theMessage->text()),
583 QString::fromStdString(theMessage->tooltip()),
584 QIcon(theMessage->icon().c_str()),
587 salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
588 salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind()));
590 myActionsMgr->addCommand(aAction);
591 myModule->featureCreated(aAction);
594 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
595 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
597 aPage = addWorkbench(aWchName);
599 //Find or create Group
600 QString aGroupName = QString::fromStdString(theMessage->groupId());
601 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
603 aGroup = aPage->addGroup(aGroupName);
605 QString aDocKind = QString::fromStdString(theMessage->documentKind());
606 // Check if hotkey sequence is already defined:
607 QKeySequence aHotKey = myActionsMgr->registerShortcut(
608 QString::fromStdString(theMessage->keysequence()));
610 XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
611 QString::fromStdString(theMessage->text()),
612 QString::fromStdString(theMessage->tooltip()),
613 QIcon(theMessage->icon().c_str()),
617 aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
618 myActionsMgr->addCommand(aCommand);
619 myModule->featureCreated(aCommand);
624 * Makes a signal/slot connections between Property Panel
625 * and given operation. The given operation becomes a
626 * current operation and previous operation if exists
628 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
630 QAction* aCommand = 0;
631 if (isSalomeMode()) {
632 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
634 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
635 FeaturePtr aFeature = theOperation->feature();
637 aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
639 //Abort operation on uncheck the command
641 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
646 * Saves document with given name.
648 void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
650 QApplication::restoreOverrideCursor();
651 SessionPtr aMgr = ModelAPI_Session::get();
652 aMgr->save(theName.toLatin1().constData(), theFileNames);
653 QApplication::restoreOverrideCursor();
656 bool XGUI_Workshop::isActiveOperationAborted()
658 return myOperationMgr->abortAllOperations();
661 //******************************************************
662 void XGUI_Workshop::onExit()
664 SessionPtr aMgr = ModelAPI_Session::get();
665 if (aMgr->isModified()) {
666 int anAnswer = QMessageBox::question(
667 myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
668 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
669 if (anAnswer == QMessageBox::Save) {
670 bool saved = onSave();
674 } else if (anAnswer == QMessageBox::Cancel) {
681 //******************************************************
682 void XGUI_Workshop::onNew()
684 QApplication::setOverrideCursor(Qt::WaitCursor);
685 if (objectBrowser() == 0) {
687 mySelector->connectViewers();
689 myViewerProxy->connectToViewer();
691 if (!isSalomeMode()) {
692 myMainWindow->showPythonConsole();
693 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
694 aWnd->showMaximized();
695 updateCommandStatus();
697 myContextMenuMgr->connectViewer();
698 QApplication::restoreOverrideCursor();
701 //******************************************************
702 void XGUI_Workshop::onOpen()
704 if(!isActiveOperationAborted())
706 //save current file before close if modified
707 SessionPtr aSession = ModelAPI_Session::get();
708 if (aSession->isModified()) {
709 //TODO(sbh): re-launch the app?
710 int anAnswer = QMessageBox::question(
711 myMainWindow, tr("Save current file"),
712 tr("The document is modified, save before opening another?"),
713 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
714 if (anAnswer == QMessageBox::Save) {
716 } else if (anAnswer == QMessageBox::Cancel) {
719 aSession->moduleDocument()->close();
723 //show file dialog, check if readable and open
724 myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
725 if (myCurrentDir.isEmpty())
727 QFileInfo aFileInfo(myCurrentDir);
728 if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
729 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
733 QApplication::setOverrideCursor(Qt::WaitCursor);
734 aSession->load(myCurrentDir.toLatin1().constData());
735 myObjectBrowser->rebuildDataTree();
737 updateCommandStatus();
738 QApplication::restoreOverrideCursor();
741 //******************************************************
742 bool XGUI_Workshop::onSave()
744 if(!isActiveOperationAborted())
746 if (myCurrentDir.isEmpty()) {
749 std::list<std::string> aFiles;
750 saveDocument(myCurrentDir, aFiles);
751 updateCommandStatus();
752 myMainWindow->setModifiedState(false);
756 //******************************************************
757 bool XGUI_Workshop::onSaveAs()
759 if(!isActiveOperationAborted())
761 QFileDialog dialog(mainWindow());
762 dialog.setWindowTitle(tr("Select directory to save files..."));
763 dialog.setFileMode(QFileDialog::Directory);
764 dialog.setFilter(tr("Folders (*)"));
765 dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
766 dialog.setViewMode(QFileDialog::Detail);
768 if (!dialog.exec()) {
771 QString aTempDir = dialog.selectedFiles().first();
773 if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) {
774 int answer = QMessageBox::question(
776 //: Title of the dialog which asks user if he wants to save study in existing non-empty folder
778 tr("The folder already contains some files, save anyway?"),
779 QMessageBox::Save | QMessageBox::Cancel);
780 if (answer == QMessageBox::Cancel) {
784 myCurrentDir = aTempDir;
785 if (!isSalomeMode()) {
786 myMainWindow->setCurrentDir(myCurrentDir, false);
787 myMainWindow->setModifiedState(false);
792 //******************************************************
793 void XGUI_Workshop::onUndo()
795 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
796 SessionPtr aMgr = ModelAPI_Session::get();
797 if (aMgr->isOperation())
798 operationMgr()->onAbortOperation();
800 updateCommandStatus();
803 //******************************************************
804 void XGUI_Workshop::onRedo()
806 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
807 SessionPtr aMgr = ModelAPI_Session::get();
808 if (aMgr->isOperation())
809 operationMgr()->onAbortOperation();
811 updateCommandStatus();
814 //******************************************************
815 void XGUI_Workshop::onRebuild()
817 SessionPtr aMgr = ModelAPI_Session::get();
818 bool aWasOperation = aMgr->isOperation(); // keep this value
819 if (!aWasOperation) {
820 aMgr->startOperation();
822 static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild");
823 Events_Loop::loop()->send(boost::shared_ptr<Events_Message>(
824 new Events_Message(aRebuildEvent, this)));
825 if (!aWasOperation) {
826 aMgr->finishOperation();
830 //******************************************************
831 void XGUI_Workshop::onPreferences()
834 XGUI_Preferences::editPreferences(aModif);
835 if (aModif.size() > 0) {
837 foreach (XGUI_Pref aPref, aModif)
839 aSection = aPref.first;
840 if (aSection == XGUI_Preferences::VIEWER_SECTION) {
842 myMainWindow->viewer()->updateFromResources();
843 } else if (aSection == XGUI_Preferences::MENU_SECTION) {
845 myMainWindow->menuObject()->updateFromResources();
851 //******************************************************
852 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
854 QString libName = QString::fromStdString(library(theModule.toStdString()));
855 if (libName.isEmpty()) {
856 qWarning(qPrintable(tr("Information about module \"%1\" doesn't exist.").arg(theModule)));
861 CREATE_FUNC crtInst = 0;
864 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
868 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
869 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
870 QString aMsg((char*) &lpMsgBuf);
871 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
872 ::LocalFree(lpMsgBuf);
874 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
878 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
879 | FORMAT_MESSAGE_IGNORE_INSERTS,
880 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
881 QString aMsg((char*) &lpMsgBuf);
882 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
883 ::LocalFree(lpMsgBuf);
887 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY | RTLD_GLOBAL );
889 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
891 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
893 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
898 ModuleBase_IModule* aModule = crtInst ? crtInst(myModuleConnector) : 0;
900 if (!err.isEmpty()) {
902 Events_Error::send(err.toStdString());
904 qWarning(qPrintable(err));
910 //******************************************************
911 bool XGUI_Workshop::activateModule()
913 Config_ModuleReader aModuleReader;
914 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
915 myModule = loadModule(moduleName);
918 myModule->createFeatures();
919 myActionsMgr->update();
923 //******************************************************
924 void XGUI_Workshop::updateCommandStatus()
926 QList<QAction*> aCommands;
927 if (isSalomeMode()) { // update commands in SALOME mode
928 aCommands = salomeConnector()->commandList();
930 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
931 foreach (XGUI_Command* aCmd, aMenuBar->features())
932 aCommands.append(aCmd);
934 SessionPtr aMgr = ModelAPI_Session::get();
935 if (aMgr->hasModuleDocument()) {
938 foreach(QAction* aCmd, aCommands) {
939 QString aId = aCmd->data().toString();
940 if (aId == "UNDO_CMD")
942 else if (aId == "REDO_CMD")
945 // Enable all commands
946 aCmd->setEnabled(true);
948 aUndoCmd->setEnabled(aMgr->canUndo());
949 aRedoCmd->setEnabled(aMgr->canRedo());
951 foreach(QAction* aCmd, aCommands) {
952 QString aId = aCmd->data().toString();
953 if (aId == "NEW_CMD")
954 aCmd->setEnabled(true);
955 else if (aId == "EXIT_CMD")
956 aCmd->setEnabled(true);
958 aCmd->setEnabled(false);
961 myActionsMgr->update();
964 //******************************************************
965 QList<QAction*> XGUI_Workshop::getModuleCommands() const
967 QList<QAction*> aCommands;
968 if (isSalomeMode()) { // update commands in SALOME mode
969 aCommands = salomeConnector()->commandList();
971 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
972 foreach(XGUI_Command* aCmd, aMenuBar->features())
974 aCommands.append(aCmd);
980 //******************************************************
981 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
983 QDockWidget* aObjDock = new QDockWidget(theParent);
984 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
985 aObjDock->setWindowTitle(tr("Object browser"));
986 aObjDock->setStyleSheet(
987 "::title { position: relative; padding-left: 5px; text-align: left center }");
988 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
989 connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
990 SLOT(changeCurrentDocument(ObjectPtr)));
991 aObjDock->setWidget(myObjectBrowser);
993 myContextMenuMgr->connectObjectBrowser();
997 //******************************************************
999 * Creates dock widgets, places them in corresponding area
1000 * and tabifies if necessary.
1002 void XGUI_Workshop::createDockWidgets()
1004 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
1005 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
1006 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
1007 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
1008 myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
1009 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
1010 hidePropertyPanel(); //<! Invisible by default
1011 hideObjectBrowser();
1012 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
1014 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
1015 connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
1016 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
1017 connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
1018 connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
1019 SLOT(onKeyReleased(QKeyEvent*)));
1020 connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
1021 SLOT(setAcceptEnabled(bool)));
1025 //******************************************************
1026 void XGUI_Workshop::showPropertyPanel()
1028 QAction* aViewAct = myPropertyPanel->toggleViewAction();
1029 //<! Restore ability to close panel from the window's menu
1030 aViewAct->setEnabled(true);
1031 myPropertyPanel->show();
1032 myPropertyPanel->raise();
1035 //******************************************************
1036 void XGUI_Workshop::hidePropertyPanel()
1038 QAction* aViewAct = myPropertyPanel->toggleViewAction();
1039 //<! Do not allow to show empty property panel
1040 aViewAct->setEnabled(false);
1041 myPropertyPanel->hide();
1044 //******************************************************
1045 void XGUI_Workshop::showObjectBrowser()
1047 myObjectBrowser->parentWidget()->show();
1050 //******************************************************
1051 void XGUI_Workshop::hideObjectBrowser()
1053 myObjectBrowser->parentWidget()->hide();
1056 //******************************************************
1057 void XGUI_Workshop::onFeatureTriggered()
1059 QAction* aCmd = dynamic_cast<QAction*>(sender());
1061 QString aId = salomeConnector()->commandId(aCmd);
1063 myModule->launchOperation(aId);
1067 //******************************************************
1068 void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
1070 SessionPtr aMgr = ModelAPI_Session::get();
1072 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(theObj);
1074 DocumentPtr aPartDoc = aPart->partDoc();
1076 aMgr->setActiveDocument(aPartDoc);
1081 aMgr->setActiveDocument(aMgr->moduleDocument());
1084 //******************************************************
1085 void XGUI_Workshop::salomeViewerSelectionChanged()
1087 emit salomeViewerSelection();
1090 //**************************************************************
1091 ModuleBase_IViewer* XGUI_Workshop::salomeViewer() const
1093 return mySalomeConnector->viewer();
1096 //**************************************************************
1097 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
1099 QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
1100 if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
1101 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
1102 activatePart(aPart);
1103 } else if (theId == "DEACTIVATE_PART_CMD")
1104 activatePart(ResultPartPtr());
1105 else if (theId == "DELETE_CMD")
1106 deleteObjects(aObjects);
1107 else if (theId == "SHOW_CMD")
1108 showObjects(aObjects, true);
1109 else if (theId == "HIDE_CMD")
1110 showObjects(aObjects, false);
1111 else if (theId == "SHOW_ONLY_CMD")
1112 showOnlyObjects(aObjects);
1113 else if (theId == "SHADING_CMD")
1114 setDisplayMode(aObjects, XGUI_Displayer::Shading);
1115 else if (theId == "WIREFRAME_CMD")
1116 setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
1117 else if (theId == "HIDEALL_CMD")
1118 myDisplayer->eraseAll();
1121 //**************************************************************
1122 void XGUI_Workshop::onWidgetValuesChanged()
1124 ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
1125 FeaturePtr aFeature = anOperation->feature();
1127 ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
1129 // aCustom->storeValue(aFeature);
1131 const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
1132 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
1133 for (; anIt != aLast; anIt++) {
1134 ModuleBase_ModelWidget* aCustom = *anIt;
1135 if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) {
1136 //aCustom->storeValue(aFeature);
1137 aCustom->storeValue();
1142 //**************************************************************
1143 void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
1145 if (!myPartActivating) {
1146 myPartActivating = true;
1148 theFeature->activate();
1149 changeCurrentDocument(theFeature);
1150 myObjectBrowser->activatePart(theFeature);
1151 myPartActivating = false;
1155 //**************************************************************
1156 void XGUI_Workshop::activateLastPart()
1158 SessionPtr aMgr = ModelAPI_Session::get();
1159 DocumentPtr aDoc = aMgr->moduleDocument();
1160 std::string aGrpName = ModelAPI_ResultPart::group();
1161 ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
1162 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
1164 activatePart(aPart);
1168 //**************************************************************
1169 void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
1171 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
1172 QMessageBox::StandardButton aRes = QMessageBox::warning(
1173 aDesktop, tr("Delete features"), tr("Seleted features will be deleted. Continue?"),
1174 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
1175 // ToDo: definbe deleting method
1176 if (aRes == QMessageBox::Yes) {
1177 SessionPtr aMgr = ModelAPI_Session::get();
1178 aMgr->startOperation();
1179 foreach (ObjectPtr aObj, theList)
1181 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
1183 DocumentPtr aDoc = aPart->document();
1184 if (aDoc == aMgr->activeDocument()) {
1187 //aMgr->moduleDocument()->removeFeature(aPart->owner());
1189 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
1191 aObj->document()->removeFeature(aFeature);
1194 myDisplayer->updateViewer();
1195 aMgr->finishOperation();
1199 //**************************************************************
1200 void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
1202 foreach (ObjectPtr aObj, theList)
1204 ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
1207 myDisplayer->display(aRes, false);
1209 myDisplayer->erase(aRes, false);
1213 myDisplayer->updateViewer();
1216 //**************************************************************
1217 void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
1219 myDisplayer->eraseAll(false);
1220 showObjects(theList, true);
1224 //**************************************************************
1225 void XGUI_Workshop::updateCommandsOnViewSelection()
1227 XGUI_Selection* aSelection = mySelector->selection();
1228 if (aSelection->getSelected().size() == 0)
1231 // Restrict validators to manage only nested (child) features
1232 // of the current feature i.e. if current feature is Sketch -
1233 // Sketch Features & Constraints can be validated.
1234 QStringList aNestedIds;
1235 if(myOperationMgr->hasOperation()) {
1236 FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
1238 aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
1241 SessionPtr aMgr = ModelAPI_Session::get();
1242 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1243 QList<QAction*> aActions = getModuleCommands();
1244 foreach(QAction* aAction, aActions) {
1245 QString aId = aAction->data().toString();
1246 if(!aNestedIds.contains(aId))
1248 std::list<ModelAPI_Validator*> aValidators;
1249 std::list<std::list<std::string> > anArguments;
1250 aFactory->validators(aId.toStdString(), aValidators, anArguments);
1251 std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
1252 for (; aValidator != aValidators.end(); aValidator++) {
1254 const ModuleBase_SelectionValidator* aSelValidator =
1255 dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
1256 if (aSelValidator) {
1257 aAction->setEnabled(aSelValidator->isValid(aSelection));
1264 //**************************************************************
1265 void XGUI_Workshop::registerValidators() const
1267 SessionPtr aMgr = ModelAPI_Session::get();
1268 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1271 //**************************************************************
1272 void XGUI_Workshop::displayAllResults()
1274 SessionPtr aMgr = ModelAPI_Session::get();
1275 DocumentPtr aRootDoc = aMgr->moduleDocument();
1276 displayDocumentResults(aRootDoc);
1277 for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {
1278 ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
1279 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
1280 displayDocumentResults(aPart->partDoc());
1282 myDisplayer->updateViewer();
1285 //**************************************************************
1286 void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc)
1290 displayGroupResults(theDoc, ModelAPI_ResultConstruction::group());
1291 displayGroupResults(theDoc, ModelAPI_ResultBody::group());
1294 //**************************************************************
1295 void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup)
1297 for (int i = 0; i < theDoc->size(theGroup); i++)
1298 myDisplayer->display(theDoc->object(theGroup, i), false);
1301 //**************************************************************
1302 void XGUI_Workshop::setDisplayMode(const QList<ObjectPtr>& theList, int theMode)
1304 foreach(ObjectPtr aObj, theList) {
1305 myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
1307 if (theList.size() > 0)
1308 myDisplayer->updateViewer();