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 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
517 aWidget->setFeature(aOperation->feature());
518 aWidget->enableFocusProcessing();
519 QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
520 // Init default values
521 if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
522 aWidget->storeValue();
526 aOperation->setPropertyPanel(myPropertyPanel);
527 myPropertyPanel->setModelWidgets(aWidgets);
528 if (!aOperation->activateByPreselection())
529 myPropertyPanel->activateNextWidget(NULL);
530 // Widget activation (from the previous method) may commit the current operation
531 // if pre-selection is enougth for it. So we shouldn't update prop panel's title
532 if(myOperationMgr->isCurrentOperation(aOperation)) {
533 myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
536 updateCommandStatus();
539 //******************************************************
540 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
542 //!< No need for property panel
543 updateCommandStatus();
545 myPropertyPanel->cleanContent();
548 bool XGUI_Workshop::event(QEvent * theEvent)
550 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
552 boost::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
553 processEvent(aEventPtr);
562 void XGUI_Workshop::addFeature(const boost::shared_ptr<Config_FeatureMessage>& theMessage)
566 qDebug() << "XGUI_Workshop::addFeature: NULL message.";
570 // Remember features icons
571 myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
573 //Find or create Workbench
574 QString aWchName = QString::fromStdString(theMessage->workbenchId());
575 QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
576 bool isUsePropPanel = theMessage->isUseInput();
577 QString aFeatureId = QString::fromStdString(theMessage->id());
578 if (isSalomeMode()) {
579 QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureId,
580 QString::fromStdString(theMessage->text()),
581 QString::fromStdString(theMessage->tooltip()),
582 QIcon(theMessage->icon().c_str()),
585 salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
586 salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind()));
588 myActionsMgr->addCommand(aAction);
589 myModule->featureCreated(aAction);
592 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
593 XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
595 aPage = addWorkbench(aWchName);
597 //Find or create Group
598 QString aGroupName = QString::fromStdString(theMessage->groupId());
599 XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
601 aGroup = aPage->addGroup(aGroupName);
603 QString aDocKind = QString::fromStdString(theMessage->documentKind());
604 // Check if hotkey sequence is already defined:
605 QKeySequence aHotKey = myActionsMgr->registerShortcut(
606 QString::fromStdString(theMessage->keysequence()));
608 XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
609 QString::fromStdString(theMessage->text()),
610 QString::fromStdString(theMessage->tooltip()),
611 QIcon(theMessage->icon().c_str()),
615 aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
616 myActionsMgr->addCommand(aCommand);
617 myModule->featureCreated(aCommand);
622 * Makes a signal/slot connections between Property Panel
623 * and given operation. The given operation becomes a
624 * current operation and previous operation if exists
626 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
628 QAction* aCommand = 0;
629 if (isSalomeMode()) {
630 aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
632 XGUI_MainMenu* aMenu = myMainWindow->menuObject();
633 FeaturePtr aFeature = theOperation->feature();
635 aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
637 //Abort operation on uncheck the command
639 connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
644 * Saves document with given name.
646 void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
648 QApplication::restoreOverrideCursor();
649 SessionPtr aMgr = ModelAPI_Session::get();
650 aMgr->save(theName.toLatin1().constData(), theFileNames);
651 QApplication::restoreOverrideCursor();
654 bool XGUI_Workshop::isActiveOperationAborted()
656 return myOperationMgr->abortAllOperations();
659 //******************************************************
660 void XGUI_Workshop::onExit()
662 SessionPtr aMgr = ModelAPI_Session::get();
663 if (aMgr->isModified()) {
664 int anAnswer = QMessageBox::question(
665 myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
666 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
667 if (anAnswer == QMessageBox::Save) {
668 bool saved = onSave();
672 } else if (anAnswer == QMessageBox::Cancel) {
679 //******************************************************
680 void XGUI_Workshop::onNew()
682 QApplication::setOverrideCursor(Qt::WaitCursor);
683 if (objectBrowser() == 0) {
685 mySelector->connectViewers();
687 myViewerProxy->connectToViewer();
689 if (!isSalomeMode()) {
690 myMainWindow->showPythonConsole();
691 QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
692 aWnd->showMaximized();
693 updateCommandStatus();
695 myContextMenuMgr->connectViewer();
696 QApplication::restoreOverrideCursor();
699 //******************************************************
700 void XGUI_Workshop::onOpen()
702 if(!isActiveOperationAborted())
704 //save current file before close if modified
705 SessionPtr aSession = ModelAPI_Session::get();
706 if (aSession->isModified()) {
707 //TODO(sbh): re-launch the app?
708 int anAnswer = QMessageBox::question(
709 myMainWindow, tr("Save current file"),
710 tr("The document is modified, save before opening another?"),
711 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
712 if (anAnswer == QMessageBox::Save) {
714 } else if (anAnswer == QMessageBox::Cancel) {
717 aSession->moduleDocument()->close();
721 //show file dialog, check if readable and open
722 myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
723 if (myCurrentDir.isEmpty())
725 QFileInfo aFileInfo(myCurrentDir);
726 if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
727 QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
731 QApplication::setOverrideCursor(Qt::WaitCursor);
732 aSession->load(myCurrentDir.toLatin1().constData());
733 myObjectBrowser->rebuildDataTree();
735 updateCommandStatus();
736 QApplication::restoreOverrideCursor();
739 //******************************************************
740 bool XGUI_Workshop::onSave()
742 if(!isActiveOperationAborted())
744 if (myCurrentDir.isEmpty()) {
747 std::list<std::string> aFiles;
748 saveDocument(myCurrentDir, aFiles);
749 updateCommandStatus();
750 myMainWindow->setModifiedState(false);
754 //******************************************************
755 bool XGUI_Workshop::onSaveAs()
757 if(!isActiveOperationAborted())
759 QFileDialog dialog(mainWindow());
760 dialog.setWindowTitle(tr("Select directory to save files..."));
761 dialog.setFileMode(QFileDialog::Directory);
762 dialog.setFilter(tr("Folders (*)"));
763 dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
764 dialog.setViewMode(QFileDialog::Detail);
766 if (!dialog.exec()) {
769 QString aTempDir = dialog.selectedFiles().first();
771 if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) {
772 int answer = QMessageBox::question(
774 //: Title of the dialog which asks user if he wants to save study in existing non-empty folder
776 tr("The folder already contains some files, save anyway?"),
777 QMessageBox::Save | QMessageBox::Cancel);
778 if (answer == QMessageBox::Cancel) {
782 myCurrentDir = aTempDir;
783 if (!isSalomeMode()) {
784 myMainWindow->setCurrentDir(myCurrentDir, false);
785 myMainWindow->setModifiedState(false);
790 //******************************************************
791 void XGUI_Workshop::onUndo()
793 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
794 SessionPtr aMgr = ModelAPI_Session::get();
795 if (aMgr->isOperation())
796 operationMgr()->onAbortOperation();
798 updateCommandStatus();
801 //******************************************************
802 void XGUI_Workshop::onRedo()
804 objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
805 SessionPtr aMgr = ModelAPI_Session::get();
806 if (aMgr->isOperation())
807 operationMgr()->onAbortOperation();
809 updateCommandStatus();
812 //******************************************************
813 void XGUI_Workshop::onRebuild()
815 SessionPtr aMgr = ModelAPI_Session::get();
816 bool aWasOperation = aMgr->isOperation(); // keep this value
817 if (!aWasOperation) {
818 aMgr->startOperation();
820 static const Events_ID aRebuildEvent = Events_Loop::loop()->eventByName("Rebuild");
821 Events_Loop::loop()->send(boost::shared_ptr<Events_Message>(
822 new Events_Message(aRebuildEvent, this)));
823 if (!aWasOperation) {
824 aMgr->finishOperation();
828 //******************************************************
829 void XGUI_Workshop::onPreferences()
832 XGUI_Preferences::editPreferences(aModif);
833 if (aModif.size() > 0) {
835 foreach (XGUI_Pref aPref, aModif)
837 aSection = aPref.first;
838 if (aSection == XGUI_Preferences::VIEWER_SECTION) {
840 myMainWindow->viewer()->updateFromResources();
841 } else if (aSection == XGUI_Preferences::MENU_SECTION) {
843 myMainWindow->menuObject()->updateFromResources();
849 //******************************************************
850 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
852 QString libName = QString::fromStdString(library(theModule.toStdString()));
853 if (libName.isEmpty()) {
854 qWarning(qPrintable(tr("Information about module \"%1\" doesn't exist.").arg(theModule)));
859 CREATE_FUNC crtInst = 0;
862 HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
866 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
867 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
868 QString aMsg((char*) &lpMsgBuf);
869 err = QString("Failed to load %1. %2").arg(libName).arg(aMsg);
870 ::LocalFree(lpMsgBuf);
872 crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
876 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
877 | FORMAT_MESSAGE_IGNORE_INSERTS,
878 0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
879 QString aMsg((char*) &lpMsgBuf);
880 err = QString("Failed to find %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
881 ::LocalFree(lpMsgBuf);
885 void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY | RTLD_GLOBAL );
887 err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
889 crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
891 err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
896 ModuleBase_IModule* aModule = crtInst ? crtInst(myModuleConnector) : 0;
898 if (!err.isEmpty()) {
900 Events_Error::send(err.toStdString());
902 qWarning(qPrintable(err));
908 //******************************************************
909 bool XGUI_Workshop::activateModule()
911 Config_ModuleReader aModuleReader;
912 QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
913 myModule = loadModule(moduleName);
916 myModule->createFeatures();
917 myActionsMgr->update();
921 //******************************************************
922 void XGUI_Workshop::updateCommandStatus()
924 QList<QAction*> aCommands;
925 if (isSalomeMode()) { // update commands in SALOME mode
926 aCommands = salomeConnector()->commandList();
928 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
929 foreach (XGUI_Command* aCmd, aMenuBar->features())
930 aCommands.append(aCmd);
932 SessionPtr aMgr = ModelAPI_Session::get();
933 if (aMgr->hasModuleDocument()) {
936 foreach(QAction* aCmd, aCommands) {
937 QString aId = aCmd->data().toString();
938 if (aId == "UNDO_CMD")
940 else if (aId == "REDO_CMD")
943 // Enable all commands
944 aCmd->setEnabled(true);
946 aUndoCmd->setEnabled(aMgr->canUndo());
947 aRedoCmd->setEnabled(aMgr->canRedo());
949 foreach(QAction* aCmd, aCommands) {
950 QString aId = aCmd->data().toString();
951 if (aId == "NEW_CMD")
952 aCmd->setEnabled(true);
953 else if (aId == "EXIT_CMD")
954 aCmd->setEnabled(true);
956 aCmd->setEnabled(false);
959 myActionsMgr->update();
962 //******************************************************
963 QList<QAction*> XGUI_Workshop::getModuleCommands() const
965 QList<QAction*> aCommands;
966 if (isSalomeMode()) { // update commands in SALOME mode
967 aCommands = salomeConnector()->commandList();
969 XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
970 foreach(XGUI_Command* aCmd, aMenuBar->features())
972 aCommands.append(aCmd);
978 //******************************************************
979 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
981 QDockWidget* aObjDock = new QDockWidget(theParent);
982 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
983 aObjDock->setWindowTitle(tr("Object browser"));
984 aObjDock->setStyleSheet(
985 "::title { position: relative; padding-left: 5px; text-align: left center }");
986 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
987 connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
988 SLOT(changeCurrentDocument(ObjectPtr)));
989 aObjDock->setWidget(myObjectBrowser);
991 myContextMenuMgr->connectObjectBrowser();
995 //******************************************************
997 * Creates dock widgets, places them in corresponding area
998 * and tabifies if necessary.
1000 void XGUI_Workshop::createDockWidgets()
1002 QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
1003 QDockWidget* aObjDock = createObjectBrowser(aDesktop);
1004 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
1005 myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
1006 myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
1007 aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
1008 hidePropertyPanel(); //<! Invisible by default
1009 hideObjectBrowser();
1010 aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
1012 QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
1013 connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
1014 QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
1015 connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
1016 connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
1017 SLOT(onKeyReleased(QKeyEvent*)));
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();