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();
184 // File commands group
185 XGUI_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
187 XGUI_Command* aCommand;
189 aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
190 QIcon(":pictures/save.png"), QKeySequence::Save);
191 aCommand->connectTo(this, SLOT(onSave()));
192 //aCommand->disable();
194 aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
195 QIcon(":pictures/undo.png"), QKeySequence::Undo);
196 aCommand->connectTo(this, SLOT(onUndo()));
198 aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
199 QIcon(":pictures/redo.png"), QKeySequence::Redo);
200 aCommand->connectTo(this, SLOT(onRedo()));
202 aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
203 QIcon(":pictures/rebuild.png"), QKeySequence());
204 aCommand->connectTo(this, SLOT(onRebuild()));
206 aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
207 QIcon(":pictures/save.png"), QKeySequence());
208 aCommand->connectTo(this, SLOT(onSaveAs()));
209 //aCommand->disable();
211 aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
212 QIcon(":pictures/open.png"), QKeySequence::Open);
213 aCommand->connectTo(this, SLOT(onOpen()));
215 //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
216 // QIcon(":pictures/new.png"), QKeySequence::New);
217 //aCommand->connectTo(this, SLOT(onNew()));
219 aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
220 QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
221 aCommand->connectTo(this, SLOT(onPreferences()));
223 aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
224 QIcon(":pictures/close.png"), QKeySequence::Close);
225 aCommand->connectTo(this, SLOT(onExit()));
226 //FIXME: SBH's test action. Can be used for some GUI tests.
228 // aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
229 // QIcon(":pictures/close.png"), QKeySequence(), true);
230 // aCommand->connectTo(myMainWindow, SLOT(dockPythonConsole()));
234 //******************************************************
235 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
237 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
238 return aMenuBar->addWorkbench(theName);
241 //******************************************************
242 void XGUI_Workshop::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
244 if (QApplication::instance()->thread() != QThread::currentThread()) {
246 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
248 SessionPtr aMgr = ModelAPI_Session::get();
249 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
250 QApplication::postEvent(this, aPostponeEvent);
254 //A message to start feature creation received.
255 if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) {
256 boost::shared_ptr<Config_FeatureMessage> aFeatureMsg =
257 boost::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
258 if (!aFeatureMsg->isInternal()) {
259 addFeature(aFeatureMsg);
263 // Process creation of Part
264 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
265 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
266 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
267 onFeatureCreatedMsg(aUpdMsg);
269 if (mySalomeConnector)
270 mySalomeConnector->createPreferences();
271 myUpdatePrefs = false;
274 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
275 myUpdatePrefs = true;
279 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
280 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
281 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
282 onFeatureRedisplayMsg(aUpdMsg);
285 //Update property panel on corresponding message. If there is no current operation (no
286 //property panel), or received message has different feature to the current - do nothing.
287 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
288 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
289 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
290 onFeatureUpdatedMsg(anUpdateMsg);
293 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
294 boost::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
295 boost::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
296 onObjectDeletedMsg(aDelMsg);
299 else if (theMessage->eventID() == Events_LongOp::eventID()) {
300 if (Events_LongOp::isPerformed())
301 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
303 QApplication::restoreOverrideCursor();
306 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW)) {
307 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
308 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
309 const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
310 QList<ObjectPtr> aList;
311 std::set<ObjectPtr>::const_iterator aIt;
312 for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
314 showObjects(aList, true);
317 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOHIDE)) {
318 boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
319 boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
320 const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
321 QList<ObjectPtr> aList;
322 std::set<ObjectPtr>::const_iterator aIt;
323 for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
325 showObjects(aList, false);
328 //An operation passed by message. Start it, process and commit.
329 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
330 boost::shared_ptr<Config_PointerMessage> aPartSetMsg =
331 boost::dynamic_pointer_cast<Config_PointerMessage>(theMessage);
332 //myPropertyPanel->cleanContent();
333 ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer();
335 if (myOperationMgr->startOperation(anOperation)) {
336 myPropertyPanel->updateContentWidget(anOperation->feature());
337 if (!anOperation->getDescription()->hasXmlRepresentation()) {
338 if (anOperation->commit())
339 updateCommandStatus();
343 else if (theMessage->eventID() == Events_Loop::loop()->eventByName("CurrentDocumentChanged")) {
344 myActionsMgr->update();
345 // Find and Activate active part
346 if (myPartActivating)
348 SessionPtr aMgr = ModelAPI_Session::get();
349 DocumentPtr aActiveDoc = aMgr->activeDocument();
350 DocumentPtr aDoc = aMgr->moduleDocument();
351 if (aActiveDoc == aDoc) {
352 activatePart(ResultPartPtr());
355 std::string aGrpName = ModelAPI_ResultPart::group();
356 for (int i = 0; i < aDoc->size(aGrpName); i++) {
357 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aDoc->object(aGrpName, i));
358 if (aPart->partDoc() == aActiveDoc) {
359 activatePart(aPart); // Activate a part which corresponds to active Doc
363 // If not found then activate global document
364 activatePart(ResultPartPtr());
367 //Show error dialog if error message received.
368 boost::shared_ptr<Events_Error> anAppError = boost::dynamic_pointer_cast<Events_Error>(theMessage);
370 emit errorOccurred(QString::fromLatin1(anAppError->description()));
373 if (!isSalomeMode()) {
374 SessionPtr aMgr = ModelAPI_Session::get();
375 if (aMgr->isModified() != myMainWindow->isModifiedState())
376 myMainWindow->setModifiedState(aMgr->isModified());
381 //******************************************************
382 void XGUI_Workshop::onStartWaiting()
384 if (Events_LongOp::isPerformed()) {
385 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
389 //******************************************************
390 void XGUI_Workshop::onFeatureUpdatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
392 std::set<ObjectPtr> aFeatures = theMsg->objects();
393 if (myOperationMgr->hasOperation()) {
394 FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
395 std::set<ObjectPtr>::const_iterator aIt;
396 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
397 ObjectPtr aNewFeature = (*aIt);
398 if (aNewFeature == aCurrentFeature) {
399 myPropertyPanel->updateContentWidget(aCurrentFeature);
404 myOperationMgr->onValidateOperation();
406 myObjectBrowser->processEvent(theMsg);
409 //******************************************************
410 void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
412 std::set<ObjectPtr> aObjects = theMsg->objects();
413 std::set<ObjectPtr>::const_iterator aIt;
414 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
415 ObjectPtr aObj = (*aIt);
416 if (!aObj->data() || !aObj->data()->isValid() || aObj->document()->isConcealed(aObj))
417 myDisplayer->erase(aObj, false);
419 if (myDisplayer->isVisible(aObj)) {
420 myDisplayer->display(aObj, false); // In order to update presentation
421 if (myOperationMgr->hasOperation()) {
422 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
423 if (!aOperation->hasObject(aObj))
424 if (!myDisplayer->isActive(aObj))
425 myDisplayer->activate(aObj);
428 if (myOperationMgr->hasOperation()) {
429 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
430 // Display only current operation results if operation has preview
431 if (aOperation->hasObject(aObj) && aOperation->hasPreview()) {
432 myDisplayer->display(aObj, false);
433 // Deactivate object of current operation from selection
434 if (myDisplayer->isActive(aObj))
435 myDisplayer->deactivate(aObj);
441 myDisplayer->updateViewer();
444 //******************************************************
445 void XGUI_Workshop::onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
447 std::set<ObjectPtr> aObjects = theMsg->objects();
449 std::set<ObjectPtr>::const_iterator aIt;
450 bool aHasPart = false;
451 bool isDisplayed = false;
452 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
453 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
456 // If a feature is created from the aplication's python console
457 // it doesn't stored in the operation mgr and doesn't displayed
458 } else if (myOperationMgr->hasOperation()) {
459 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
460 if (!(*aIt)->document()->isConcealed(*aIt) &&
461 aOperation->hasObject(*aIt)) { // Display only current operation results
462 myDisplayer->display(*aIt, false);
468 myObjectBrowser->processEvent(theMsg);
470 myDisplayer->updateViewer();
471 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
472 // activateLastPart();
476 //******************************************************
477 void XGUI_Workshop::onObjectDeletedMsg(const boost::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg)
480 myObjectBrowser->processEvent(theMsg);
481 //std::set<ObjectPtr> aFeatures = theMsg->objects();
484 //******************************************************
485 void XGUI_Workshop::onOperationStarted()
487 ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
488 if (this->isSalomeMode())
489 aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
491 aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
493 if (aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel
494 connectWithOperation(aOperation);
497 QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
498 ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
501 myPropertyPanel->cleanContent();
502 aFactory.createWidget(myPropertyPanel->contentWidget());
503 ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
505 QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
506 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
507 ModuleBase_ModelWidget* aWidget;
508 for (; anIt != aLast; anIt++) {
510 aWidget->setFeature(aOperation->feature());
511 aWidget->enableFocusProcessing();
512 QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
513 // Init default values
514 if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
515 aWidget->storeValue();
519 aOperation->setPropertyPanel(myPropertyPanel);
520 myPropertyPanel->setModelWidgets(aWidgets);
521 myPropertyPanel->activateNextWidget(NULL);
522 // Widget activation (from the previous method) may commit the current operation
523 // if pre-selection is enougth for it. So we shouldn't update prop panel's title
524 if(myOperationMgr->isCurrentOperation(aOperation)) {
525 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
528 updateCommandStatus();
531 //******************************************************
532 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
534 //!< No need for property panel
535 updateCommandStatus();
537 myPropertyPanel->cleanContent();
540 bool XGUI_Workshop::event(QEvent * theEvent)
542 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
544 boost::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
545 processEvent(aEventPtr);
554 void XGUI_Workshop::addFeature(const boost::shared_ptr<Config_FeatureMessage>& theMessage)
558 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
562 // Remember features icons
563 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
565 //Find or create Workbench
566 QString aWchName = QString::fromStdString(theMessage->workbenchId());
567 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
568 bool isUsePropPanel = theMessage->isUseInput();
569 QString aFeatureId = QString::fromStdString(theMessage->id());
570 if (isSalomeMode()) {
571 QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureId,
572 QString::fromStdString(theMessage->text()),
573 QString::fromStdString(theMessage->tooltip()),
574 QIcon(theMessage->icon().c_str()),
577 salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
578 myActionsMgr->addCommand(aAction);
579 myModule->featureCreated(aAction);
582 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
583 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
585 aPage = addWorkbench(aWchName);
587 //Find or create Group
588 QString aGroupName = QString::fromStdString(theMessage->groupId());
589 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
591 aGroup = aPage->addGroup(aGroupName);
593 QString aDocKind = QString::fromStdString(theMessage->documentKind());
594 // Check if hotkey sequence is already defined:
595 QKeySequence aHotKey = myActionsMgr->registerShortcut(
596 QString::fromStdString(theMessage->keysequence()));
598 XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
599 QString::fromStdString(theMessage->text()),
600 QString::fromStdString(theMessage->tooltip()),
601 QIcon(theMessage->icon().c_str()),
605 aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
606 myActionsMgr->addCommand(aCommand);
607 myModule->featureCreated(aCommand);
612 * Makes a signal/slot connections between Property Panel
613 * and given operation. The given operation becomes a
614 * current operation and previous operation if exists
616 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
618 QAction* aCommand = 0;
619 if (isSalomeMode()) {
620 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
622 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
623 FeaturePtr aFeature = theOperation->feature();
625 aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
627 //Abort operation on uncheck the command
629 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
634 * Saves document with given name.
636 void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
638 QApplication::restoreOverrideCursor();
639 SessionPtr aMgr = ModelAPI_Session::get();
640 aMgr->save(theName.toLatin1().constData(), theFileNames);
641 QApplication::restoreOverrideCursor();
644 bool XGUI_Workshop::isActiveOperationAborted()
646 return myOperationMgr->abortAllOperations();
649 //******************************************************
650 void XGUI_Workshop::onExit()
652 SessionPtr aMgr = ModelAPI_Session::get();
653 if (aMgr->isModified()) {
654 int anAnswer = QMessageBox::question(
655 myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
656 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
657 if (anAnswer == QMessageBox::Save) {
658 bool saved = onSave();
662 } else if (anAnswer == QMessageBox::Cancel) {
669 //******************************************************
670 void XGUI_Workshop::onNew()
672 QApplication::setOverrideCursor(Qt::WaitCursor);
673 if (objectBrowser() == 0) {
675 mySelector->connectViewers();
677 myViewerProxy->connectToViewer();
679 if (!isSalomeMode()) {
680 myMainWindow->showPythonConsole();
681 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
682 aWnd->showMaximized();
683 updateCommandStatus();
685 myContextMenuMgr->connectViewer();
686 QApplication::restoreOverrideCursor();
689 //******************************************************
690 void XGUI_Workshop::onOpen()
692 if(!isActiveOperationAborted())
694 //save current file before close if modified
695 SessionPtr aSession = ModelAPI_Session::get();
696 if (aSession->isModified()) {
697 //TODO(sbh): re-launch the app?
698 int anAnswer = QMessageBox::question(
699 myMainWindow, tr("Save current file"),
700 tr("The document is modified, save before opening another?"),
701 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
702 if (anAnswer == QMessageBox::Save) {
704 } else if (anAnswer == QMessageBox::Cancel) {
707 aSession->moduleDocument()->close();
711 //show file dialog, check if readable and open
712 myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
713 if (myCurrentDir.isEmpty())
715 QFileInfo aFileInfo(myCurrentDir);
716 if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
717 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
721 QApplication::setOverrideCursor(Qt::WaitCursor);
722 aSession->load(myCurrentDir.toLatin1().constData());
723 myObjectBrowser->rebuildDataTree();
725 updateCommandStatus();
726 QApplication::restoreOverrideCursor();
729 //******************************************************
730 bool XGUI_Workshop::onSave()
732 if(!isActiveOperationAborted())
734 if (myCurrentDir.isEmpty()) {
737 std::list<std::string> aFiles;
738 saveDocument(myCurrentDir, aFiles);
739 updateCommandStatus();
740 myMainWindow->setModifiedState(false);
744 //******************************************************
745 bool XGUI_Workshop::onSaveAs()
747 if(!isActiveOperationAborted())
749 QFileDialog dialog(mainWindow());
750 dialog.setWindowTitle(tr("Select directory to save files..."));
751 dialog.setFileMode(QFileDialog::Directory);
752 dialog.setFilter(tr("Folders (*)"));
753 dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
754 dialog.setViewMode(QFileDialog::Detail);
756 if (!dialog.exec()) {
759 QString aTempDir = dialog.selectedFiles().first();
761 if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) {
762 int answer = QMessageBox::question(
764 //: Title of the dialog which asks user if he wants to save study in existing non-empty folder
766 tr("The folder already contains some files, save anyway?"),
767 QMessageBox::Save | QMessageBox::Cancel);
768 if (answer == QMessageBox::Cancel) {
772 myCurrentDir = aTempDir;
773 if (!isSalomeMode()) {
774 myMainWindow->setCurrentDir(myCurrentDir, false);
775 myMainWindow->setModifiedState(false);
780 //******************************************************
781 void XGUI_Workshop::onUndo()
783 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
784 SessionPtr aMgr = ModelAPI_Session::get();
785 if (aMgr->isOperation())
786 operationMgr()->onAbortOperation();
788 updateCommandStatus();
791 //******************************************************
792 void XGUI_Workshop::onRedo()
794 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
795 SessionPtr aMgr = ModelAPI_Session::get();
796 if (aMgr->isOperation())
797 operationMgr()->onAbortOperation();
799 updateCommandStatus();
802 //******************************************************
803 void XGUI_Workshop::onRebuild()
805 SessionPtr aMgr = ModelAPI_Session::get();
806 bool aWasOperation = aMgr->isOperation(); // keep this value
807 if (!aWasOperation) {
808 aMgr->startOperation();
810 static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild");
811 Events_Loop::loop()->send(boost::shared_ptr<Events_Message>(
812 new Events_Message(aRebuildEvent, this)));
813 if (!aWasOperation) {
814 aMgr->finishOperation();
818 //******************************************************
819 void XGUI_Workshop::onPreferences()
822 XGUI_Preferences::editPreferences(aModif);
823 if (aModif.size() > 0) {
825 foreach (XGUI_Pref aPref, aModif)
827 aSection = aPref.first;
828 if (aSection == XGUI_Preferences::VIEWER_SECTION) {
830 myMainWindow->viewer()->updateFromResources();
831 } else if (aSection == XGUI_Preferences::MENU_SECTION) {
833 myMainWindow->menuObject()->updateFromResources();
839 //******************************************************
840 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
842 QString libName = QString::fromStdString(library(theModule.toStdString()));
843 if (libName.isEmpty()) {
844 qWarning(qPrintable(tr("Information about module \"%1\" doesn't exist.").arg(theModule)));
849 CREATE_FUNC crtInst = 0;
852 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
856 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
857 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
858 QString aMsg((char*) &lpMsgBuf);
859 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
860 ::LocalFree(lpMsgBuf);
862 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
866 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
867 | FORMAT_MESSAGE_IGNORE_INSERTS,
868 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
869 QString aMsg((char*) &lpMsgBuf);
870 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
871 ::LocalFree(lpMsgBuf);
875 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY | RTLD_GLOBAL );
877 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
879 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
881 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
886 ModuleBase_IModule* aModule = crtInst ? crtInst(myModuleConnector) : 0;
888 if (!err.isEmpty()) {
890 Events_Error::send(err.toStdString());
892 qWarning(qPrintable(err));
898 //******************************************************
899 bool XGUI_Workshop::activateModule()
901 Config_ModuleReader aModuleReader;
902 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
903 myModule = loadModule(moduleName);
906 myModule->createFeatures();
907 myActionsMgr->update();
911 //******************************************************
912 void XGUI_Workshop::updateCommandStatus()
914 QList<QAction*> aCommands;
915 if (isSalomeMode()) { // update commands in SALOME mode
916 aCommands = salomeConnector()->commandList();
918 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
919 foreach (XGUI_Command* aCmd, aMenuBar->features())
920 aCommands.append(aCmd);
922 SessionPtr aMgr = ModelAPI_Session::get();
923 if (aMgr->hasModuleDocument()) {
926 foreach(QAction* aCmd, aCommands) {
927 QString aId = aCmd->data().toString();
928 if (aId == "UNDO_CMD")
930 else if (aId == "REDO_CMD")
933 // Enable all commands
934 aCmd->setEnabled(true);
936 aUndoCmd->setEnabled(aMgr->canUndo());
937 aRedoCmd->setEnabled(aMgr->canRedo());
939 foreach(QAction* aCmd, aCommands) {
940 QString aId = aCmd->data().toString();
941 if (aId == "NEW_CMD")
942 aCmd->setEnabled(true);
943 else if (aId == "EXIT_CMD")
944 aCmd->setEnabled(true);
946 aCmd->setEnabled(false);
949 myActionsMgr->update();
952 //******************************************************
953 QList<QAction*> XGUI_Workshop::getModuleCommands() const
955 QList<QAction*> aCommands;
956 if (isSalomeMode()) { // update commands in SALOME mode
957 aCommands = salomeConnector()->commandList();
959 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
960 foreach(XGUI_Command* aCmd, aMenuBar->features())
962 aCommands.append(aCmd);
968 //******************************************************
969 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
971 QDockWidget* aObjDock = new QDockWidget(theParent);
972 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
973 aObjDock->setWindowTitle(tr("Object browser"));
974 aObjDock->setStyleSheet(
975 "::title { position: relative; padding-left: 5px; text-align: left center }");
976 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
977 connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
978 SLOT(changeCurrentDocument(ObjectPtr)));
979 aObjDock->setWidget(myObjectBrowser);
981 myContextMenuMgr->connectObjectBrowser();
985 //******************************************************
987 * Creates dock widgets, places them in corresponding area
988 * and tabifies if necessary.
990 void XGUI_Workshop::createDockWidgets()
992 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
993 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
994 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
995 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
996 myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
997 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
998 hidePropertyPanel(); //<! Invisible by default
1000 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
1002 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
1003 connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
1004 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
1005 connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
1006 connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
1007 SLOT(onKeyReleased(QKeyEvent*)));
1008 //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
1009 // SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
1010 //connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
1011 // SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
1012 connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
1013 SLOT(setAcceptEnabled(bool)));
1017 //******************************************************
1018 void XGUI_Workshop::showPropertyPanel()
1020 QAction* aViewAct = myPropertyPanel->toggleViewAction();
1021 //<! Restore ability to close panel from the window's menu
1022 aViewAct->setEnabled(true);
1023 myPropertyPanel->show();
1024 myPropertyPanel->raise();
1027 //******************************************************
1028 void XGUI_Workshop::hidePropertyPanel()
1030 QAction* aViewAct = myPropertyPanel->toggleViewAction();
1031 //<! Do not allow to show empty property panel
1032 aViewAct->setEnabled(false);
1033 myPropertyPanel->hide();
1036 //******************************************************
1037 void XGUI_Workshop::showObjectBrowser()
1039 myObjectBrowser->parentWidget()->show();
1042 //******************************************************
1043 void XGUI_Workshop::hideObjectBrowser()
1045 myObjectBrowser->parentWidget()->hide();
1048 //******************************************************
1049 void XGUI_Workshop::onFeatureTriggered()
1051 QAction* aCmd = dynamic_cast<QAction*>(sender());
1053 QString aId = salomeConnector()->commandId(aCmd);
1055 myModule->launchOperation(aId);
1059 //******************************************************
1060 void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
1062 SessionPtr aMgr = ModelAPI_Session::get();
1064 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(theObj);
1066 DocumentPtr aPartDoc = aPart->partDoc();
1068 aMgr->setActiveDocument(aPartDoc);
1073 aMgr->setActiveDocument(aMgr->moduleDocument());
1076 //******************************************************
1077 void XGUI_Workshop::salomeViewerSelectionChanged()
1079 emit salomeViewerSelection();
1082 //**************************************************************
1083 ModuleBase_IViewer* XGUI_Workshop::salomeViewer() const
1085 return mySalomeConnector->viewer();
1088 //**************************************************************
1089 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
1091 QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
1092 if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
1093 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
1094 activatePart(aPart);
1095 } else if (theId == "DEACTIVATE_PART_CMD")
1096 activatePart(ResultPartPtr());
1097 else if (theId == "DELETE_CMD")
1098 deleteObjects(aObjects);
1099 else if (theId == "SHOW_CMD")
1100 showObjects(aObjects, true);
1101 else if (theId == "HIDE_CMD")
1102 showObjects(aObjects, false);
1103 else if (theId == "SHOW_ONLY_CMD")
1104 showOnlyObjects(aObjects);
1105 else if (theId == "SHADING_CMD")
1106 setDisplayMode(aObjects, XGUI_Displayer::Shading);
1107 else if (theId == "WIREFRAME_CMD")
1108 setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
1109 else if (theId == "HIDEALL_CMD")
1110 myDisplayer->eraseAll();
1113 //**************************************************************
1114 void XGUI_Workshop::onWidgetValuesChanged()
1116 ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
1117 FeaturePtr aFeature = anOperation->feature();
1119 ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
1121 // aCustom->storeValue(aFeature);
1123 const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
1124 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
1125 for (; anIt != aLast; anIt++) {
1126 ModuleBase_ModelWidget* aCustom = *anIt;
1127 if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) {
1128 //aCustom->storeValue(aFeature);
1129 aCustom->storeValue();
1134 //**************************************************************
1135 void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
1137 if (!myPartActivating) {
1138 myPartActivating = true;
1140 theFeature->activate();
1141 changeCurrentDocument(theFeature);
1142 myObjectBrowser->activatePart(theFeature);
1143 myPartActivating = false;
1147 //**************************************************************
1148 void XGUI_Workshop::activateLastPart()
1150 SessionPtr aMgr = ModelAPI_Session::get();
1151 DocumentPtr aDoc = aMgr->moduleDocument();
1152 std::string aGrpName = ModelAPI_ResultPart::group();
1153 ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
1154 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
1156 activatePart(aPart);
1160 //**************************************************************
1161 void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
1163 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
1164 QMessageBox::StandardButton aRes = QMessageBox::warning(
1165 aDesktop, tr("Delete features"), tr("Seleted features will be deleted. Continue?"),
1166 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
1167 // ToDo: definbe deleting method
1168 if (aRes == QMessageBox::Yes) {
1169 SessionPtr aMgr = ModelAPI_Session::get();
1170 aMgr->startOperation();
1171 foreach (ObjectPtr aObj, theList)
1173 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
1175 DocumentPtr aDoc = aPart->document();
1176 if (aDoc == aMgr->activeDocument()) {
1179 //aMgr->moduleDocument()->removeFeature(aPart->owner());
1181 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
1183 aObj->document()->removeFeature(aFeature);
1186 myDisplayer->updateViewer();
1187 aMgr->finishOperation();
1191 //**************************************************************
1192 void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
1194 foreach (ObjectPtr aObj, theList)
1196 ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
1199 myDisplayer->display(aRes, false);
1201 myDisplayer->erase(aRes, false);
1205 myDisplayer->updateViewer();
1208 //**************************************************************
1209 void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
1211 myDisplayer->eraseAll(false);
1212 showObjects(theList, true);
1216 //**************************************************************
1217 void XGUI_Workshop::updateCommandsOnViewSelection()
1219 XGUI_Selection* aSelection = mySelector->selection();
1220 if (aSelection->getSelected().size() == 0)
1223 // Restrict validators to manage only nested (child) features
1224 // of the current feature i.e. if current feature is Sketch -
1225 // Sketch Features & Constraints can be validated.
1226 QStringList aNestedIds;
1227 if(myOperationMgr->hasOperation()) {
1228 FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
1230 aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
1233 SessionPtr aMgr = ModelAPI_Session::get();
1234 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1235 QList<QAction*> aActions = getModuleCommands();
1236 foreach(QAction* aAction, aActions) {
1237 QString aId = aAction->data().toString();
1238 if(!aNestedIds.contains(aId))
1240 std::list<ModelAPI_Validator*> aValidators;
1241 std::list<std::list<std::string> > anArguments;
1242 aFactory->validators(aId.toStdString(), aValidators, anArguments);
1243 std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
1244 for (; aValidator != aValidators.end(); aValidator++) {
1246 const ModuleBase_SelectionValidator* aSelValidator =
1247 dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
1248 if (aSelValidator) {
1249 aAction->setEnabled(aSelValidator->isValid(aSelection));
1256 //**************************************************************
1257 void XGUI_Workshop::registerValidators() const
1259 SessionPtr aMgr = ModelAPI_Session::get();
1260 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1263 //**************************************************************
1264 void XGUI_Workshop::displayAllResults()
1266 SessionPtr aMgr = ModelAPI_Session::get();
1267 DocumentPtr aRootDoc = aMgr->moduleDocument();
1268 displayDocumentResults(aRootDoc);
1269 for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {
1270 ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
1271 ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
1272 displayDocumentResults(aPart->partDoc());
1274 myDisplayer->updateViewer();
1277 //**************************************************************
1278 void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc)
1282 displayGroupResults(theDoc, ModelAPI_ResultConstruction::group());
1283 displayGroupResults(theDoc, ModelAPI_ResultBody::group());
1286 //**************************************************************
1287 void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup)
1289 for (int i = 0; i < theDoc->size(theGroup); i++)
1290 myDisplayer->display(theDoc->object(theGroup, i), false);
1293 //**************************************************************
1294 void XGUI_Workshop::setDisplayMode(const QList<ObjectPtr>& theList, int theMode)
1296 foreach(ObjectPtr aObj, theList) {
1297 myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
1299 if (theList.size() > 0)
1300 myDisplayer->updateViewer();