Salome HOME
ffaebad9d96aca5838ca7e65b92d54585a88576b
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
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_SalomeViewer.h"
18 #include "XGUI_ActionsMgr.h"
19 #include "XGUI_ErrorDialog.h"
20 #include "XGUI_ViewerProxy.h"
21 #include "XGUI_PropertyPanel.h"
22 #include "XGUI_ContextMenuMgr.h"
23 #include "XGUI_ModuleConnector.h"
24 #include "XGUI_Preferences.h"
25
26 #include <ModelAPI_Events.h>
27 #include <ModelAPI_PluginManager.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>
35
36 #include <PartSetPlugin_Part.h>
37
38 #include <Events_Loop.h>
39 #include <Events_Error.h>
40 #include <Events_LongOp.h>
41
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
48 #include <Config_Common.h>
49 #include <Config_FeatureMessage.h>
50 #include <Config_PointerMessage.h>
51 #include <Config_ModuleReader.h>
52
53 #include <QApplication>
54 #include <QFileDialog>
55 #include <QMessageBox>
56 #include <QMdiSubWindow>
57 #include <QPushButton>
58 #include <QDockWidget>
59 #include <QLayout>
60 #include <QTimer>
61
62 #ifdef _DEBUG
63 #include <QDebug>
64 #endif
65
66 #ifdef WIN32
67 #include <windows.h>
68 #else
69 #include <dlfcn.h>
70 #endif
71
72 QMap<QString, QString> XGUI_Workshop::myIcons;
73
74 QString XGUI_Workshop::featureIcon(const std::string& theId)
75 {
76   QString aId(theId.c_str());
77   if (myIcons.contains(aId))
78     return myIcons[aId];
79   return QString();
80 }
81
82 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
83     : QObject(),
84       myCurrentDir(QString()),
85       myModule(NULL),
86       mySalomeConnector(theConnector),
87       myPropertyPanel(0),
88       myObjectBrowser(0),
89       myDisplayer(0),
90       myUpdatePrefs(false)
91 {
92   myMainWindow = mySalomeConnector ? 0 : new XGUI_MainWindow();
93
94   myDisplayer = new XGUI_Displayer(this);
95
96   mySelector = new XGUI_SelectionMgr(this);
97   //connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands()));
98
99   myOperationMgr = new XGUI_OperationMgr(this);
100   myActionsMgr = new XGUI_ActionsMgr(this);
101   myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
102   myContextMenuMgr = new XGUI_ContextMenuMgr(this);
103   connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
104           SLOT(onContextMenuCommand(const QString&, bool)));
105
106   myViewerProxy = new XGUI_ViewerProxy(this);
107   connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection()));
108
109   myModuleConnector = new XGUI_ModuleConnector(this);
110
111   connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted()));
112   connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
113   connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
114           SLOT(onOperationStopped(ModuleBase_Operation*)));
115   connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
116   connect(myOperationMgr, SIGNAL(operationStarted()), myActionsMgr, SLOT(update()));
117   connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), myActionsMgr,
118           SLOT(update()));
119   connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
120 }
121
122 //******************************************************
123 XGUI_Workshop::~XGUI_Workshop(void)
124 {
125 }
126
127 //******************************************************
128 void XGUI_Workshop::startApplication()
129 {
130   initMenu();
131   //Initialize event listening
132   Events_Loop* aLoop = Events_Loop::loop();
133   aLoop->registerListener(this, Events_Error::errorID());  //!< Listening application errors.
134   //TODO(sbh): Implement static method to extract event id [SEID]
135   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED));
136   // TODO Is it good to use non standard event within workshop?
137   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
138   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
139   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
140   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
141   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
142   aLoop->registerListener(this, Events_Loop::eventByName("LongOperation"));
143   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
144
145   registerValidators();
146   activateModule();
147   if (myMainWindow) {
148     myMainWindow->show();
149     updateCommandStatus();
150   }
151   XGUI_Preferences::loadCustomProps();
152   onNew();
153 }
154
155 //******************************************************
156 void XGUI_Workshop::initMenu()
157 {
158   myContextMenuMgr->createActions();
159
160   if (isSalomeMode()) {
161     // Create only Undo, Redo commands
162     QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD", tr("Undo"),
163                                                          tr("Undo last command"),
164                                                          QIcon(":pictures/undo.png"),
165                                                          QKeySequence::Undo, false);
166     connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
167     aAction = salomeConnector()->addEditCommand("REDO_CMD", tr("Redo"), tr("Redo last command"),
168                                                 QIcon(":pictures/redo.png"), QKeySequence::Redo,
169                                                 false);
170     connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo()));
171     salomeConnector()->addEditMenuSeparator();
172     return;
173   }
174   // File commands group
175   XGUI_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
176
177   XGUI_Command* aCommand;
178
179   aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
180                                 QIcon(":pictures/save.png"), QKeySequence::Save);
181   aCommand->connectTo(this, SLOT(onSave()));
182   //aCommand->disable();
183
184   aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
185                                 QIcon(":pictures/undo.png"), QKeySequence::Undo);
186   aCommand->connectTo(this, SLOT(onUndo()));
187
188   aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
189                                 QIcon(":pictures/redo.png"), QKeySequence::Redo);
190   aCommand->connectTo(this, SLOT(onRedo()));
191
192   aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
193                                 QIcon(":pictures/rebuild.png"));
194
195   aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
196                                 QIcon(":pictures/save.png"));
197   aCommand->connectTo(this, SLOT(onSaveAs()));
198   //aCommand->disable();
199
200   aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
201                                 QIcon(":pictures/open.png"), QKeySequence::Open);
202   aCommand->connectTo(this, SLOT(onOpen()));
203
204   //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
205   //                              QIcon(":pictures/new.png"), QKeySequence::New);
206   //aCommand->connectTo(this, SLOT(onNew()));
207
208   aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
209                                 QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
210   aCommand->connectTo(this, SLOT(onPreferences()));
211
212   aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
213                                 QIcon(":pictures/close.png"), QKeySequence::Close);
214   aCommand->connectTo(this, SLOT(onExit()));
215   //FIXME: SBH's test action. Can be used for some GUI tests.
216 //  #ifdef _DEBUG
217 //    aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
218 //                                  QIcon(":pictures/close.png"), QKeySequence(), true);
219 //    aCommand->connectTo(myMainWindow, SLOT(dockPythonConsole()));
220 //  #endif
221 }
222
223 //******************************************************
224 XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
225 {
226   XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
227   return aMenuBar->addWorkbench(theName);
228 }
229
230 //******************************************************
231 void XGUI_Workshop::processEvent(const Events_Message* theMessage)
232 {
233   //A message to start feature creation received.
234   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) {
235     const Config_FeatureMessage* aFeatureMsg =
236         dynamic_cast<const Config_FeatureMessage*>(theMessage);
237     if (!aFeatureMsg->isInternal()) {
238       addFeature(aFeatureMsg);
239     }
240   }
241
242   // Process creation of Part
243   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
244     const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
245         dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
246     onFeatureCreatedMsg(aUpdMsg);
247     if (myUpdatePrefs) {
248       if (mySalomeConnector)
249         mySalomeConnector->createPreferences();
250       myUpdatePrefs = false;
251     }
252   }
253   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
254     myUpdatePrefs = true;
255   }
256
257   // Redisplay feature
258   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
259     const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
260         dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
261     onFeatureRedisplayMsg(aUpdMsg);
262   }
263
264   //Update property panel on corresponding message. If there is no current operation (no
265   //property panel), or received message has different feature to the current - do nothing.
266   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
267     const ModelAPI_ObjectUpdatedMessage* anUpdateMsg =
268         dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
269     onFeatureUpdatedMsg(anUpdateMsg);
270   }
271
272   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
273     const ModelAPI_ObjectDeletedMessage* aDelMsg =
274         dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
275     onObjectDeletedMsg(aDelMsg);
276   }
277
278   else if (theMessage->eventID() == Events_LongOp::eventID()) {
279     if (Events_LongOp::isPerformed())
280       QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
281     //QTimer::singleShot(10, this, SLOT(onStartWaiting()));
282     else
283       QApplication::restoreOverrideCursor();
284   }
285
286   //An operation passed by message. Start it, process and commit.
287   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
288     const Config_PointerMessage* aPartSetMsg =
289         dynamic_cast<const Config_PointerMessage*>(theMessage);
290     //myPropertyPanel->cleanContent();
291     ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer();
292
293     if (myOperationMgr->startOperation(anOperation)) {
294       myPropertyPanel->updateContentWidget(anOperation->feature());
295       if (!anOperation->getDescription()->hasXmlRepresentation()) {
296         if (anOperation->commit())
297           updateCommandStatus();
298       }
299     }
300   } else {
301     //Show error dialog if error message received.
302     const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
303     if (anAppError) {
304       emit errorOccurred(QString::fromLatin1(anAppError->description()));
305     }
306   }
307   if (!isSalomeMode()) {
308     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
309     DocumentPtr aDoc = aMgr->rootDocument();
310     if (aDoc->isModified() != myMainWindow->isModifiedState())
311       myMainWindow->setModifiedState(aDoc->isModified());
312   }
313 }
314
315
316 //******************************************************
317 void XGUI_Workshop::onStartWaiting()
318 {
319   if (Events_LongOp::isPerformed()) {
320     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
321   }
322 }
323
324 //******************************************************
325 void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
326 {
327   std::set<ObjectPtr> aFeatures = theMsg->objects();
328   if (myOperationMgr->hasOperation()) {
329     FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
330     std::set<ObjectPtr>::const_iterator aIt;
331     for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
332       ObjectPtr aNewFeature = (*aIt);
333       if (aNewFeature == aCurrentFeature) {
334         myPropertyPanel->updateContentWidget(aCurrentFeature);
335         break;
336       }
337     }
338   }
339   myOperationMgr->validateCurrentOperation();
340 }
341
342 //******************************************************
343 void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
344 {
345   std::set<ObjectPtr> aObjects = theMsg->objects();
346   std::set<ObjectPtr>::const_iterator aIt;
347   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
348     ObjectPtr aObj = (*aIt);
349     if (!aObj->data() || !aObj->data()->isValid())
350       myDisplayer->erase(aObj, false);
351     else {
352       if (myDisplayer->isVisible(aObj))  // TODO VSV: Correction sketch drawing
353         myDisplayer->display(aObj, false);  // In order to update presentation
354       else {
355         if (myOperationMgr->hasOperation()) {
356           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
357           if (aOperation->hasObject(aObj)) {  // Display only current operation results
358             myDisplayer->display(aObj, false);
359           }
360         }
361       }
362     }
363   }
364   myDisplayer->updateViewer();
365 }
366
367 //******************************************************
368 void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
369 {
370   std::set<ObjectPtr> aObjects = theMsg->objects();
371
372   std::set<ObjectPtr>::const_iterator aIt;
373   bool aHasPart = false;
374   bool isDisplayed = false;
375   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
376     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
377     if (aPart) {
378       aHasPart = true;
379       // If a feature is created from the aplication's python console  
380       // it doesn't stored in the operation mgr and doesn't displayed
381     } else if (myOperationMgr->hasOperation()) {
382       ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
383       if (aOperation->hasObject(*aIt)) {  // Display only current operation results
384         myDisplayer->display(*aIt, false);
385         isDisplayed = true;
386       }
387     }
388   }
389   if (isDisplayed)
390     myDisplayer->updateViewer();
391   if (aHasPart) {
392     //The created part will be created in Object Browser later and we have to activate it
393     // only when it is created everywere
394     QTimer::singleShot(50, this, SLOT(activateLastPart()));
395   }
396 }
397
398 //******************************************************
399 void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg)
400 {
401   //std::set<ObjectPtr> aFeatures = theMsg->objects();
402 }
403
404 //******************************************************
405 void XGUI_Workshop::onOperationStarted()
406 {
407   ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
408   if (this->isSalomeMode()) 
409     aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
410   else 
411     aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
412   
413   if (aOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
414     connectWithOperation(aOperation);
415
416     showPropertyPanel();
417     QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
418     ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
419                                                                  myModuleConnector);
420
421     myPropertyPanel->cleanContent();
422     aFactory.createWidget(myPropertyPanel->contentWidget());
423
424     QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
425     QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
426     ModuleBase_ModelWidget* aWidget;
427     for (; anIt != aLast; anIt++) {
428       aWidget = *anIt;
429       aWidget->setFeature(aOperation->feature());
430       QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
431       // Init default values
432       if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
433         aWidget->storeValue();
434       }
435     }
436
437     myPropertyPanel->setModelWidgets(aWidgets);
438     myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
439   }
440   updateCommandStatus();
441 }
442
443 //******************************************************
444 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
445 {
446   //!< No need for property panel
447   updateCommandStatus();
448   hidePropertyPanel();
449   myPropertyPanel->cleanContent();
450 }
451
452 /*
453  *
454  */
455 void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
456 {
457   if (!theMessage) {
458 #ifdef _DEBUG
459     qDebug() << "XGUI_Workshop::addFeature: NULL message.";
460 #endif
461     return;
462   }
463   // Remember features icons
464   myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
465
466   //Find or create Workbench
467   QString aWchName = QString::fromStdString(theMessage->workbenchId());
468   QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
469   bool isUsePropPanel = theMessage->isUseInput();
470   QString aFeatureId = QString::fromStdString(theMessage->id());
471   if (isSalomeMode()) {
472     QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureId,
473                                                      QString::fromStdString(theMessage->text()),
474                                                      QString::fromStdString(theMessage->tooltip()),
475                                                      QIcon(theMessage->icon().c_str()),
476                                                      QKeySequence(), isUsePropPanel);
477     salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
478     myActionsMgr->addCommand(aAction);
479     myModule->featureCreated(aAction);
480   } else {
481
482     XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
483     XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
484     if (!aPage) {
485       aPage = addWorkbench(aWchName);
486     }
487     //Find or create Group
488     QString aGroupName = QString::fromStdString(theMessage->groupId());
489     XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
490     if (!aGroup) {
491       aGroup = aPage->addGroup(aGroupName);
492     }
493     // Check if hotkey sequence is already defined:
494     QKeySequence aHotKey = myActionsMgr->registerShortcut(
495         QString::fromStdString(theMessage->keysequence()));
496     // Create feature...
497     XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
498                                                 QString::fromStdString(theMessage->text()),
499                                                 QString::fromStdString(theMessage->tooltip()),
500                                                 QIcon(theMessage->icon().c_str()), aHotKey,
501                                                 isUsePropPanel);
502     aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
503     myActionsMgr->addCommand(aCommand);
504     myModule->featureCreated(aCommand);
505   }
506 }
507
508 /*
509  * Makes a signal/slot connections between Property Panel
510  * and given operation. The given operation becomes a
511  * current operation and previous operation if exists
512  */
513 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
514 {
515   QAction* aCommand = 0;
516   if (isSalomeMode()) {
517     aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
518   } else {
519     XGUI_MainMenu* aMenu = myMainWindow->menuObject();
520     aCommand = aMenu->feature(theOperation->getDescription()->operationId());
521   }
522   //Abort operation on uncheck the command
523   if (aCommand)
524     connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
525 }
526
527 /*
528  * Saves document with given name.
529  */
530 void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
531 {
532   QApplication::restoreOverrideCursor();
533   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
534   DocumentPtr aDoc = aMgr->rootDocument();
535   aDoc->save(theName.toLatin1().constData(), theFileNames);
536   QApplication::restoreOverrideCursor();
537 }
538
539 //******************************************************
540 void XGUI_Workshop::onExit()
541 {
542   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
543   DocumentPtr aDoc = aMgr->rootDocument();
544   if (aDoc->isModified()) {
545     int anAnswer = QMessageBox::question(
546         myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
547         QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
548     if (anAnswer == QMessageBox::Save) {
549       bool saved = onSave();
550       if (!saved) {
551         return;
552       }
553     } else if (anAnswer == QMessageBox::Cancel) {
554       return;
555     }
556   }
557   qApp->exit();
558 }
559
560 //******************************************************
561 void XGUI_Workshop::onNew()
562 {
563   QApplication::setOverrideCursor(Qt::WaitCursor);
564   if (objectBrowser() == 0) {
565     createDockWidgets();
566     mySelector->connectViewers();
567   }
568   myViewerProxy->connectToViewer();
569   showObjectBrowser();
570   if (!isSalomeMode()) {
571     myMainWindow->showPythonConsole();
572     QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
573     aWnd->showMaximized();
574     updateCommandStatus();
575   }
576   myContextMenuMgr->connectViewer();
577   QApplication::restoreOverrideCursor();
578 }
579
580 //******************************************************
581 void XGUI_Workshop::onOpen()
582 {
583   //save current file before close if modified
584   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
585   DocumentPtr aDoc = aMgr->rootDocument();
586   if (aDoc->isModified()) {
587     //TODO(sbh): re-launch the app?
588     int anAnswer = QMessageBox::question(
589         myMainWindow, tr("Save current file"),
590         tr("The document is modified, save before opening another?"),
591         QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
592     if (anAnswer == QMessageBox::Save) {
593       onSave();
594     } else if (anAnswer == QMessageBox::Cancel) {
595       return;
596     }
597     aDoc->close();
598     myCurrentDir = "";
599   }
600
601   //show file dialog, check if readable and open
602   myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
603   if (myCurrentDir.isEmpty())
604     return;
605   QFileInfo aFileInfo(myCurrentDir);
606   if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
607     QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
608     myCurrentDir = "";
609     return;
610   }
611   QApplication::setOverrideCursor(Qt::WaitCursor);
612   aDoc->load(myCurrentDir.toLatin1().constData());
613   myObjectBrowser->rebuildDataTree();
614   displayAllResults();
615   updateCommandStatus();
616   myMainWindow->setCurrentDir(myCurrentDir);
617   QApplication::restoreOverrideCursor();
618 }
619
620 //******************************************************
621 bool XGUI_Workshop::onSave()
622 {
623   if (myCurrentDir.isEmpty()) {
624     return onSaveAs();
625   }
626   std::list<std::string> aFiles;
627   saveDocument(myCurrentDir, aFiles);
628   updateCommandStatus();
629   myMainWindow->setModifiedState(false);
630   return true;
631 }
632
633 //******************************************************
634 bool XGUI_Workshop::onSaveAs()
635 {
636   QFileDialog dialog(mainWindow());
637   dialog.setWindowTitle(tr("Select directory to save files..."));
638   dialog.setFileMode(QFileDialog::Directory);
639   dialog.setFilter(tr("Folders (*)"));
640   dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
641   dialog.setViewMode(QFileDialog::Detail);
642
643   if (!dialog.exec()) {
644     return false;
645   }
646   QString aTempDir = dialog.selectedFiles().first();
647   QDir aDir(aTempDir);
648   if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) {
649     int answer = QMessageBox::question(
650         myMainWindow,
651         //: Title of the dialog which asks user if he wants to save study in existing non-empty folder
652         tr("Save"),
653         tr("The folder already contains some files, save anyway?"),
654         QMessageBox::Save | QMessageBox::Cancel);
655     if (answer == QMessageBox::Cancel) {
656       return false;
657     }
658   }
659   myCurrentDir = aTempDir;
660   if (!isSalomeMode()) {
661     myMainWindow->setCurrentDir(myCurrentDir, false);
662     myMainWindow->setModifiedState(false);
663   }
664   return onSave();
665 }
666
667 //******************************************************
668 void XGUI_Workshop::onUndo()
669 {
670   objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
671   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
672   DocumentPtr aDoc = aMgr->rootDocument();
673   if (aDoc->isOperation())
674     operationMgr()->abortOperation();
675   aDoc->undo();
676   updateCommandStatus();
677 }
678
679 //******************************************************
680 void XGUI_Workshop::onRedo()
681 {
682   objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
683   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
684   DocumentPtr aDoc = aMgr->rootDocument();
685   if (aDoc->isOperation())
686     operationMgr()->abortOperation();
687   aDoc->redo();
688   updateCommandStatus();
689 }
690
691 //******************************************************
692 void XGUI_Workshop::onPreferences()
693 {
694   XGUI_Prefs aModif;
695   XGUI_Preferences::editPreferences(aModif);
696   if (aModif.size() > 0) {
697     QString aSection;
698     foreach (XGUI_Pref aPref, aModif)
699     {
700       aSection = aPref.first;
701       if (aSection == XGUI_Preferences::VIEWER_SECTION) {
702         if (!isSalomeMode())
703           myMainWindow->viewer()->updateFromResources();
704       } else if (aSection == XGUI_Preferences::MENU_SECTION) {
705         if (!isSalomeMode())
706           myMainWindow->menuObject()->updateFromResources();
707       }
708     }
709   }
710 }
711
712 //******************************************************
713 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
714 {
715   QString libName = QString::fromStdString(library(theModule.toStdString()));
716   if (libName.isEmpty()) {
717     qWarning(qPrintable(tr("Information about module \"%1\" doesn't exist.").arg(theModule)));
718     return 0;
719   }
720
721   QString err;
722   CREATE_FUNC crtInst = 0;
723
724 #ifdef WIN32
725   HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
726   if (!modLib) {
727     LPVOID lpMsgBuf;
728     ::FormatMessage(
729         FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
730         0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
731     QString aMsg((char*) &lpMsgBuf);
732     err = QString("Failed to load  %1. %2").arg(libName).arg(aMsg);
733     ::LocalFree(lpMsgBuf);
734   } else {
735     crtInst = (CREATE_FUNC) ::GetProcAddress(modLib, CREATE_MODULE);
736     if (!crtInst) {
737       LPVOID lpMsgBuf;
738       ::FormatMessage(
739           FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
740               | FORMAT_MESSAGE_IGNORE_INSERTS,
741           0, ::GetLastError(), 0, (LPTSTR) & lpMsgBuf, 0, 0);
742       QString aMsg((char*) &lpMsgBuf);
743       err = QString("Failed to find  %1 function. %2").arg( CREATE_MODULE).arg(aMsg);
744       ::LocalFree(lpMsgBuf);
745     }
746   }
747 #else
748   void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY | RTLD_GLOBAL );
749   if ( !modLib ) {
750     err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
751   } else {
752     crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
753     if ( !crtInst ) {
754       err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
755     }
756   }
757 #endif
758
759   ModuleBase_IModule* aModule = crtInst ? crtInst(this) : 0;
760
761   if (!err.isEmpty()) {
762     if (mainWindow()) {
763       QMessageBox::warning(mainWindow(), tr("Error"), err);
764     } else {
765       qWarning(qPrintable(err));
766     }
767   }
768   return aModule;
769 }
770
771 //******************************************************
772 bool XGUI_Workshop::activateModule()
773 {
774   Config_ModuleReader aModuleReader;
775   QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
776   myModule = loadModule(moduleName);
777   if (!myModule)
778     return false;
779   myModule->createFeatures();
780   myActionsMgr->update();
781   return true;
782 }
783
784 //******************************************************
785 void XGUI_Workshop::updateCommandStatus()
786 {
787   QList<QAction*> aCommands;
788   if (isSalomeMode()) {  // update commands in SALOME mode
789     aCommands = salomeConnector()->commandList();
790   } else {
791     XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
792     foreach (XGUI_Command* aCmd, aMenuBar->features())
793       aCommands.append(aCmd);
794   }
795   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
796   if (aMgr->hasRootDocument()) {
797     QAction* aUndoCmd;
798     QAction* aRedoCmd;
799     foreach(QAction* aCmd, aCommands)
800     {
801       QString aId = aCmd->data().toString();
802       if (aId == "UNDO_CMD")
803         aUndoCmd = aCmd;
804       else if (aId == "REDO_CMD")
805         aRedoCmd = aCmd;
806       else
807         // Enable all commands
808         aCmd->setEnabled(true);
809     }
810     DocumentPtr aDoc = aMgr->rootDocument();
811     aUndoCmd->setEnabled(aDoc->canUndo());
812     aRedoCmd->setEnabled(aDoc->canRedo());
813   } else {
814     foreach(QAction* aCmd, aCommands)
815     {
816       QString aId = aCmd->data().toString();
817       if (aId == "NEW_CMD")
818         aCmd->setEnabled(true);
819       else if (aId == "EXIT_CMD")
820         aCmd->setEnabled(true);
821       else
822         aCmd->setEnabled(false);
823     }
824   }
825   myActionsMgr->update();
826 }
827
828 //******************************************************
829 QList<QAction*> XGUI_Workshop::getModuleCommands() const
830 {
831   QList<QAction*> aCommands;
832   if (isSalomeMode()) {  // update commands in SALOME mode
833     aCommands = salomeConnector()->commandList();
834   } else {
835     XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
836     foreach(XGUI_Command* aCmd, aMenuBar->features())
837     {
838       aCommands.append(aCmd);
839     }
840   }
841   return aCommands;
842 }
843
844 //******************************************************
845 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
846 {
847   QDockWidget* aObjDock = new QDockWidget(theParent);
848   aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
849   aObjDock->setWindowTitle(tr("Object browser"));
850   aObjDock->setStyleSheet(
851       "::title { position: relative; padding-left: 5px; text-align: left center }");
852   myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
853   connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
854           SLOT(changeCurrentDocument(ObjectPtr)));
855   aObjDock->setWidget(myObjectBrowser);
856
857   myContextMenuMgr->connectObjectBrowser();
858   return aObjDock;
859 }
860
861 //******************************************************
862 /*
863  * Creates dock widgets, places them in corresponding area
864  * and tabifies if necessary.
865  */
866 void XGUI_Workshop::createDockWidgets()
867 {
868   QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
869   QDockWidget* aObjDock = createObjectBrowser(aDesktop);
870   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
871   myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
872   myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
873   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
874   hidePropertyPanel();  //<! Invisible by default
875   hideObjectBrowser();
876   aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
877
878   QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
879   connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
880   QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
881   connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
882 //TODO(sbh): KeyReleasedProblem
883   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
884           SLOT(onKeyReleased(QKeyEvent*)));
885
886   connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
887           SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
888   connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
889           SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
890   connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
891           SLOT(setAcceptEnabled(bool)));
892
893 }
894
895 //******************************************************
896 void XGUI_Workshop::showPropertyPanel()
897 {
898   QAction* aViewAct = myPropertyPanel->toggleViewAction();
899   //<! Restore ability to close panel from the window's menu
900   aViewAct->setEnabled(true);
901   myPropertyPanel->show();
902   myPropertyPanel->raise();
903 }
904
905 //******************************************************
906 void XGUI_Workshop::hidePropertyPanel()
907 {
908   QAction* aViewAct = myPropertyPanel->toggleViewAction();
909   //<! Do not allow to show empty property panel
910   aViewAct->setEnabled(false);
911   myPropertyPanel->hide();
912 }
913
914 //******************************************************
915 void XGUI_Workshop::showObjectBrowser()
916 {
917   myObjectBrowser->parentWidget()->show();
918 }
919
920 //******************************************************
921 void XGUI_Workshop::hideObjectBrowser()
922 {
923   myObjectBrowser->parentWidget()->hide();
924 }
925
926 //******************************************************
927 void XGUI_Workshop::onFeatureTriggered()
928 {
929   QAction* aCmd = dynamic_cast<QAction*>(sender());
930   if (aCmd) {
931     QString aId = salomeConnector()->commandId(aCmd);
932     if (!aId.isNull())
933       myModule->launchOperation(aId);
934   }
935 }
936
937 //******************************************************
938 void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
939 {
940   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
941   if (theObj) {
942     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(theObj);
943     if (aPart) {
944       DocumentPtr aPartDoc = aPart->partDoc();
945       if (aPartDoc) {
946         aMgr->setCurrentDocument(aPartDoc);
947         return;
948       }
949     }
950   }
951   aMgr->setCurrentDocument(aMgr->rootDocument());
952 }
953
954 //******************************************************
955 void XGUI_Workshop::salomeViewerSelectionChanged()
956 {
957   emit salomeViewerSelection();
958 }
959
960 //**************************************************************
961 XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
962 {
963   return mySalomeConnector->viewer();
964 }
965
966 //**************************************************************
967 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
968 {
969   QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
970   if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
971     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
972     activatePart(aPart);
973   } else if (theId == "DEACTIVATE_PART_CMD")
974     activatePart(ResultPartPtr());
975   else if (theId == "DELETE_CMD")
976     deleteObjects(aObjects);
977   else if (theId == "SHOW_CMD")
978     showObjects(aObjects, true);
979   else if (theId == "HIDE_CMD")
980     showObjects(aObjects, false);
981   else if (theId == "SHOW_ONLY_CMD")
982     showOnlyObjects(aObjects);
983 }
984
985 //**************************************************************
986 void XGUI_Workshop::onWidgetValuesChanged()
987 {
988   ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
989   FeaturePtr aFeature = anOperation->feature();
990
991   ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
992   //if (aCustom)
993   //  aCustom->storeValue(aFeature);
994
995   const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
996   QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
997   for (; anIt != aLast; anIt++) {
998     ModuleBase_ModelWidget* aCustom = *anIt;
999     if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) {
1000       //aCustom->storeValue(aFeature);
1001       aCustom->storeValue();
1002     }
1003   }
1004 }
1005
1006 //**************************************************************
1007 void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
1008 {
1009   if (theFeature)
1010     theFeature->activate();
1011   changeCurrentDocument(theFeature);
1012   myObjectBrowser->activatePart(theFeature);
1013 }
1014
1015 //**************************************************************
1016 void XGUI_Workshop::activateLastPart()
1017 {
1018   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
1019   DocumentPtr aDoc = aMgr->rootDocument();
1020   std::string aGrpName = ModelAPI_ResultPart::group();
1021   ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
1022   ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
1023   if (aPart)
1024     activatePart(aPart);
1025 }
1026
1027 //**************************************************************
1028 void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
1029 {
1030   QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
1031   QMessageBox::StandardButton aRes = QMessageBox::warning(
1032       aDesktop, tr("Delete features"), tr("Seleted features will be deleted. Continue?"),
1033       QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
1034   // ToDo: definbe deleting method
1035   if (aRes == QMessageBox::Yes) {
1036     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
1037     aMgr->rootDocument()->startOperation();
1038     foreach (ObjectPtr aObj, theList)
1039     {
1040       ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
1041       if (aPart) {
1042         DocumentPtr aDoc = aPart->document();
1043         if (aDoc == aMgr->currentDocument()) {
1044           aDoc->close();
1045         }
1046         //aMgr->rootDocument()->removeFeature(aPart->owner());
1047       } else {
1048         FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
1049         if (aFeature)
1050           aObj->document()->removeFeature(aFeature);
1051       }
1052     }
1053     myDisplayer->updateViewer();
1054     aMgr->rootDocument()->finishOperation();
1055   }
1056 }
1057
1058 //**************************************************************
1059 void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
1060 {
1061   foreach (ObjectPtr aObj, theList)
1062   {
1063     ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
1064     if (aRes) {
1065       if (isVisible) {
1066         myDisplayer->display(aRes, false);
1067       } else {
1068         myDisplayer->erase(aRes, false);
1069       }
1070     }
1071   }
1072   myDisplayer->updateViewer();
1073 }
1074
1075 //**************************************************************
1076 void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
1077 {
1078   myDisplayer->eraseAll(false);
1079   showObjects(theList, true);
1080 }
1081
1082
1083 //**************************************************************
1084 void XGUI_Workshop::updateCommandsOnViewSelection()
1085 {
1086   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
1087   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1088   XGUI_Selection* aSelection = mySelector->selection();
1089   if (aSelection->getSelected().size() == 0)
1090     return;
1091
1092   QList<QAction*> aActions = getModuleCommands();
1093   foreach(QAction* aAction, aActions)
1094   {
1095     QString aId = aAction->data().toString();
1096     std::list<ModelAPI_Validator*> aValidators;
1097     std::list<std::list<std::string> > anArguments;
1098     aFactory->validators(aId.toStdString(), aValidators, anArguments);
1099     std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
1100     for (; aValidator != aValidators.end(); aValidator++) {
1101       if (*aValidator) {
1102         const ModuleBase_SelectionValidator* aSelValidator =
1103             dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
1104         if (aSelValidator) {
1105           aAction->setEnabled(aSelValidator->isValid(aSelection));
1106         }
1107       }
1108     }
1109   }
1110 }
1111
1112 //**************************************************************
1113 void XGUI_Workshop::registerValidators() const
1114 {
1115   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
1116   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
1117 }
1118
1119 //**************************************************************
1120 void XGUI_Workshop::displayAllResults()
1121 {
1122   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
1123   DocumentPtr aRootDoc = aMgr->rootDocument();
1124   displayDocumentResults(aRootDoc);
1125   for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {
1126     ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
1127     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
1128     displayDocumentResults(aPart->partDoc());
1129   }
1130   myDisplayer->updateViewer();
1131 }
1132
1133 //**************************************************************
1134 void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc)
1135 {
1136   if (!theDoc)
1137     return;
1138   displayGroupResults(theDoc, ModelAPI_ResultConstruction::group());
1139   displayGroupResults(theDoc, ModelAPI_ResultBody::group());
1140 }
1141
1142 //**************************************************************
1143 void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup)
1144 {
1145   for (int i = 0; i < theDoc->size(theGroup); i++)
1146     myDisplayer->display(theDoc->object(theGroup, i), false);
1147 }