Salome HOME
Arc problems fixing: 1. reentrant of the tangent arc should not fill center point...
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #include "XGUI_WorkshopListener.h"
4 #include "XGUI_Workshop.h"
5 #include "XGUI_Displayer.h"
6 #include "XGUI_ErrorMgr.h"
7 #include "XGUI_OperationMgr.h"
8 #include "XGUI_SalomeConnector.h"
9 #include "XGUI_ActionsMgr.h"
10 #include "XGUI_PropertyPanel.h"
11 #include "XGUI_ModuleConnector.h"
12 #include "XGUI_QtEvents.h"
13
14 #ifndef HAVE_SALOME
15 #include <AppElements_MainWindow.h>
16 #endif
17
18 #include <ModuleBase_IModule.h>
19 #include <ModuleBase_Events.h>
20
21 #include <ModelAPI_Object.h>
22 #include <ModelAPI_Events.h>
23 #include <ModelAPI_Session.h>
24 #include <ModelAPI_Result.h>
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Data.h>
27 #include <ModelAPI_ResultBody.h>
28 #include <ModelAPI_ResultGroup.h>
29 #include <ModelAPI_ResultCompSolid.h>
30 #include <ModelAPI_Tools.h>
31
32 #include <Events_Loop.h>
33 #include <Events_LongOp.h>
34
35 #include <ModuleBase_IWorkshop.h>
36
37 #include <ModuleBase_Operation.h>
38 #include <ModuleBase_OperationDescription.h>
39 #include <ModuleBase_OperationFeature.h>
40 #include <ModuleBase_Tools.h>
41 #include <ModuleBase_IViewer.h>
42 #include <ModuleBase_FilterFactory.h>
43 #include <ModuleBase_WidgetSelector.h>
44
45 #include <Config_FeatureMessage.h>
46 #include <Config_PointerMessage.h>
47 #include <Config_SelectionFilterMessage.h>
48 #include <Config_Keywords.h>
49 #include <Events_InfoMessage.h>
50
51 #include <QApplication>
52 #include <QMainWindow>
53 #include <QThread>
54 #include <QAction>
55
56 #ifdef _DEBUG
57 #include <QDebug>
58 #include <iostream>
59 #endif
60
61 //#define DEBUG_FEATURE_CREATED
62 //#define DEBUG_FEATURE_REDISPLAY
63 //#define DEBUG_FEATURE_UPDATED
64 //#define DEBUG_RESULT_COMPSOLID
65
66 #ifdef DEBUG_FEATURE_REDISPLAY
67 const std::string DebugFeatureKind = "";//"Extrusion";
68 #endif
69
70 XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
71   : myWorkshop(theWorkshop),
72     myUpdatePrefs(false)
73 {
74   XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
75 }
76
77 //******************************************************
78 XGUI_WorkshopListener::~XGUI_WorkshopListener(void)
79 {
80 }
81
82 //******************************************************
83 void XGUI_WorkshopListener::initializeEventListening()
84 {
85   //Initialize event listening
86   Events_Loop* aLoop = Events_Loop::loop();
87   aLoop->registerListener(this, Events_InfoMessage::errorID());  //!< Listening application errors.
88   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
89   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
90   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
91   aLoop->registerListener(this, Events_LongOp::eventID());
92   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
93   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
94
95   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
96   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
97   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
98   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION));
99 }
100
101 //******************************************************
102 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
103 {
104   if (QApplication::instance()->thread() != QThread::currentThread()) {
105     #ifdef _DEBUG
106     std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
107     #endif
108     SessionPtr aMgr = ModelAPI_Session::get();
109     PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
110     QApplication::postEvent(this, aPostponeEvent);
111     return;
112   }
113
114   // Process creation of Part
115   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
116     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
117         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
118     onFeatureCreatedMsg(aUpdMsg);
119     if (myUpdatePrefs) {
120       XGUI_SalomeConnector* aSalomeConnector = workshop()->salomeConnector();
121       if (aSalomeConnector)
122         aSalomeConnector->createPreferences();
123       myUpdatePrefs = false;
124     }
125   }
126   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
127     myUpdatePrefs = true;
128   }
129   // Redisplay feature
130   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
131     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
132         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
133     onFeatureRedisplayMsg(aUpdMsg);
134   } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) {
135     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
136         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
137     onFeatureEmptyPresentationMsg(aUpdMsg);
138   } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)) {
139     ModuleBase_ModelWidget* aWidget = workshop()->propertyPanel()->activeWidget();
140     if (aWidget) {
141       ModuleBase_WidgetSelector* aWidgetSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aWidget);
142       if (aWidgetSelector)
143         myWorkshop->setSelected(aWidgetSelector->getAttributeSelection());
144     }
145   }
146
147   //Update property panel on corresponding message. If there is no current operation (no
148   //property panel), or received message has different feature to the current - do nothing.
149   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
150     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
151         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
152     onFeatureUpdatedMsg(anUpdateMsg);
153   } else if (theMessage->eventID() == Events_LongOp::eventID()) {
154     if (Events_LongOp::isPerformed()) {
155       QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
156     } else {
157       QApplication::restoreOverrideCursor();
158     }
159   }
160   else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
161     std::shared_ptr<Config_SelectionFilterMessage> aMsg = 
162       std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
163     if (aMsg) {
164       ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
165       if (!aMsg->attributeId().empty()) {
166         aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(),
167                                aMsg->parameters());
168       }
169     }
170   } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) {
171     // the viewer's update context will not happens until viewer updated is emitted
172       workshop()->displayer()->enableUpdateViewer(false);
173   } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)) {
174     // the viewer's update context is unblocked, the viewer's update works
175     XGUI_Displayer* aDisplayer = workshop()->displayer();
176     aDisplayer->enableUpdateViewer(true);
177   } else {
178     //Show error dialog if error message received.
179     std::shared_ptr<Events_InfoMessage> anIngfoMsg = std::dynamic_pointer_cast<Events_InfoMessage>(theMessage);
180     if (anIngfoMsg) {
181       emit errorOccurred(anIngfoMsg);
182     }
183     return;
184   }
185 #ifndef HAVE_SALOME
186     SessionPtr aMgr = ModelAPI_Session::get();
187     AppElements_MainWindow* aMainWindow = workshop()->mainWindow();
188     if (aMgr->isModified() != aMainWindow->isModifiedState())
189       aMainWindow->setModifiedState(aMgr->isModified());
190 #endif
191 }
192
193 //******************************************************
194 void XGUI_WorkshopListener::onFeatureUpdatedMsg(
195                                      const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
196 {
197 #ifdef DEBUG_FEATURE_UPDATED
198   std::set<ObjectPtr> anObjects = theMsg->objects();
199   std::set<ObjectPtr>::const_iterator aIt;
200   QStringList anInfo;
201   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
202     anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
203   }
204   QString anInfoStr = anInfo.join(";\t");
205   qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
206 #endif
207   std::set<ObjectPtr> aFeatures = theMsg->objects();
208   XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
209   if (anOperationMgr->hasOperation()) {
210     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
211                                                       (anOperationMgr->currentOperation());
212     if (aFOperation) {
213       FeaturePtr aCurrentFeature = aFOperation->feature();
214       std::set<ObjectPtr>::const_iterator aIt;
215       for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
216         ObjectPtr aNewFeature = (*aIt);
217         if (aNewFeature == aCurrentFeature) {
218           workshop()->propertyPanel()->updateContentWidget(aCurrentFeature);
219           break;
220         }
221       }
222     }
223   }
224   //anOperationMgr->onValidateOperation();
225
226   //if (myObjectBrowser)
227   //  myObjectBrowser->processEvent(theMsg);
228 }
229
230 //******************************************************
231 void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
232 {
233   std::set<ObjectPtr> anObjects = theMsg->objects();
234   std::set<ObjectPtr>::const_iterator aIt;
235
236 #ifdef DEBUG_FEATURE_REDISPLAY
237   QStringList anInfo;
238   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
239     anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
240   }
241   QString anInfoStr = anInfo.join(";\t");
242   qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
243 #endif
244
245   XGUI_Workshop* aWorkshop = workshop();
246   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
247   bool aFirstVisualizedBody = false;
248
249   bool aRedisplayed = false;
250   //std::list<ObjectPtr> aHiddenObjects;
251   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
252     ObjectPtr aObj = (*aIt);
253
254     // Hide the object if it is invalid or concealed one
255     bool aHide = !aObj->data() || !aObj->data()->isValid() || 
256       aObj->isDisabled() || (!aObj->isDisplayed());
257     if (!aHide) { // check that this is not hidden result
258       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
259       aHide = aRes && aRes->isConcealed();
260
261       // Hide the presentation with an empty shape. But isDisplayed state of the object should not
262       // be changed to the object becomes visible when the shape becomes not empty
263       if (!aHide && aRes.get())
264         aHide = !aRes->shape().get() || aRes->shape()->isNull();
265     }
266
267 #ifdef DEBUG_RESULT_COMPSOLID
268     ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
269     if (aRes.get()) {
270       ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
271       if (aCompSolidRes.get()) {
272           qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
273       }
274       if (ModelAPI_Tools::compSolidOwner(aRes))
275         qDebug("COMPSOLID sub-object");
276     }
277 #endif
278     #ifdef DEBUG_FEATURE_REDISPLAY
279       QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
280       FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
281       if (aFeature.get()) {
282         std::string aKind = aFeature->getKind();
283         if (aKind == DebugFeatureKind || DebugFeatureKind.empty()) {
284           qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
285                                             .arg(aHide).arg(anObjInfo).toStdString().c_str());
286         }
287       }
288     #endif
289     if (aHide) {
290       //we should provide objects which are hidden in the viewer, e.g. sketch always should visualizes
291       // all sub-features, if some features are to be hidden, sould be proposed may be to removed #1223
292       //aHiddenObjects.push_back(aObj);
293       aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
294       #ifdef DEBUG_FEATURE_REDISPLAY
295         // Redisplay the visible object or the object of the current operation
296         bool isVisibleObject = aDisplayer->isVisible(aObj);
297
298         QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
299         //qDebug(QString("visible=%1 : erase  = %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
300       #endif
301     }
302     else {
303       // Redisplay the visible object or the object of the current operation
304       bool isVisibleObject = aDisplayer->isVisible(aObj);
305       #ifdef DEBUG_FEATURE_REDISPLAY
306         QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
307         //qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
308       #endif
309
310       if (isVisibleObject)  { // redisplay visible object
311         //displayObject(aObj);  // In order to update presentation
312         // in order to avoid the check whether the object can be redisplayed, the exact method
313         // of redisplay is called. This modification is made in order to have the line is updated
314         // by creation of a horizontal constraint on the line by preselection
315         if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
316           aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
317         }
318         else {
319           aRedisplayed = aDisplayer->redisplay(aObj, false) || aRedisplayed;
320           // Deactivate object of current operation from selection
321           aWorkshop->deactivateActiveObject(aObj, false);
322         }
323       } else { // display object if the current operation has it
324         if (displayObject(aObj, aFirstVisualizedBody)) {
325           aRedisplayed = true;
326           // Deactivate object of current operation from selection
327           aWorkshop->deactivateActiveObject(aObj, false);
328         }
329       }
330     }
331   }
332   // this processing should be moved in another place in order to do not cause problems in
333   // flush messages chain
334   //if (aHiddenObjects.size() > 0)
335   //  myWorkshop->module()->processHiddenObject(aHiddenObjects);
336
337   bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
338   if (aRedisplayed || isCustomized) {
339     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
340
341     //VSV FitAll updated viewer by it self
342     if (aFirstVisualizedBody)
343       myWorkshop->viewer()->fitAll();
344     else 
345       aDisplayer->updateViewer();
346   }
347 }
348
349 //******************************************************
350 void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
351 {
352   std::set<ObjectPtr> anObjects = theMsg->objects();
353   std::set<ObjectPtr>::const_iterator aIt;
354 #ifdef DEBUG_FEATURE_CREATED
355   QStringList anInfo;
356   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
357     anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
358   }
359   QString anInfoStr = anInfo.join(";\t");
360   qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
361 #endif
362
363   bool aFirstVisualizedBody = false;
364
365   //bool aHasPart = false;
366   bool aDisplayed = false;
367   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
368     ObjectPtr anObject = *aIt;
369
370 #ifdef DEBUG_RESULT_COMPSOLID
371     ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
372     if (aRes.get()) {
373       ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
374       if (aCompSolidRes.get()) {
375           qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
376       }
377       if (ModelAPI_Tools::compSolidOwner(aRes))
378         qDebug("COMPSOLID sub-object");
379     }
380 #endif
381     // the validity of the data should be checked here in order to avoid display of the objects,
382     // which were created, then deleted, but flush for the creation event happens after that
383     // we should not display disabled objects
384     bool aHide = !anObject->data()->isValid() || 
385                  anObject->isDisabled() ||
386                  !anObject->isDisplayed();
387     if (!aHide) { // check that this is not hidden result
388       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
389       bool isConcealed = aRes && aRes->isConcealed();
390       aHide = aRes && aRes->isConcealed();
391       // Hide the presentation with an empty shape. But isDisplayed state of the object should not
392       // be changed to the object becomes visible when the shape becomes not empty
393       if (!aHide && aRes.get())
394         aHide = !aRes->shape().get() || aRes->shape()->isNull();
395     }
396     if (!aHide) {
397       // setDisplayed has to be called in order to synchronize internal state of the object 
398       // with list of displayed objects
399       if (myWorkshop->module()->canDisplayObject(anObject)) {
400         anObject->setDisplayed(true);
401         aDisplayed = displayObject(*aIt, aFirstVisualizedBody);
402       } else 
403         anObject->setDisplayed(false);
404     }
405   }
406
407   bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
408
409   //if (myObjectBrowser)
410   //  myObjectBrowser->processEvent(theMsg);
411   if (aDisplayed) {
412     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
413     //VSV FitAll updated viewer by it self
414     if (aFirstVisualizedBody)
415       myWorkshop->viewer()->fitAll();
416     else
417       workshop()->displayer()->updateViewer();
418   }
419   //if (aHasPart) { // TODO: Avoid activate last part on loading of document
420   //  activateLastPart();
421   //}
422 }
423
424 //******************************************************
425 void XGUI_WorkshopListener::onFeatureEmptyPresentationMsg(
426                                       const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
427 {
428   std::set<ObjectPtr> anObjects = theMsg->objects();
429   std::set<ObjectPtr>::const_iterator aIt;
430 #ifdef DEBUG_FEATURE_CREATED
431   QStringList anInfo;
432   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
433     anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
434   }
435   QString anInfoStr = anInfo.join(";\t");
436   qDebug(QString("onFeatureEmptyPresentationMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
437 #endif
438
439   XGUI_Workshop* aWorkshop = workshop();
440   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
441
442   bool aRedisplayed = false;
443   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
444     ObjectPtr anObject = *aIt;
445     aRedisplayed = aDisplayer->erase(anObject, false) || aRedisplayed;
446   }
447
448   if (aRedisplayed)
449     aDisplayer->updateViewer();
450 }
451
452 bool XGUI_WorkshopListener::event(QEvent * theEvent)
453 {
454   PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
455   if (aPostponedEv) {
456     std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
457     processEvent(aEventPtr);
458     return true;
459   }
460   return false;
461 }
462
463 //**************************************************************
464 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody)
465 {
466 #ifdef DEBUG_RESULT_COMPSOLID
467   ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
468   if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
469     ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
470     if (aCompSolidRes.get()) {
471       qDebug("COMPSOLID: displayObject");
472     }
473   }
474 #endif
475
476   bool aDisplayed = false;
477   XGUI_Workshop* aWorkshop = workshop();
478   // do not display the object if it has sub objects. They should be displayed separately.
479   if (!aWorkshop->module()->canDisplayObject(theObj) ||
480       ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
481     return aDisplayed;
482
483   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
484   int aNb = aDisplayer->objectsCount();
485   aDisplayed = aDisplayer->display(theObj, false);
486
487   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
488   if (aNb == 0 && aResult.get()) {
489     std::string aResultGroupName = aResult->groupName();
490     if (aResultGroupName == ModelAPI_ResultBody::group() ||
491         aResultGroupName == ModelAPI_ResultGroup::group()) {
492       std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
493       theFirstVisualizedBody = aShapePtr.get() != NULL;
494     }
495   }
496   return aDisplayed;
497 }
498
499 bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
500                                                    bool theForceRedisplay)
501 {
502   XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
503   FeaturePtr aCurrentFeature;
504   if (anOperationMgr->hasOperation()) {
505     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
506                                                       (anOperationMgr->currentOperation());
507     if (aFOperation) {
508       aCurrentFeature = aFOperation->feature();
509     }
510   }
511
512   bool aCustomized = false;
513   if (aCurrentFeature.get()) {
514     // the customize presentation should be redisplayed if force redislayed is true or
515     // if a list of message objects contains the operation feature for case when
516     // the feature is hidden, but arguments of the feature are modified
517     // e.g. extrusion is hidden(h=0) but sketch is chosen
518     if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
519       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
520                                  ModuleBase_IModule::CustomizeArguments, false) || aCustomized;
521       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
522                                    ModuleBase_IModule::CustomizeResults, false) || aCustomized;
523       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
524                         ModuleBase_IModule::CustomizeHighlightedObjects, false) || aCustomized;
525     }
526   }
527   return aCustomized;
528 }
529
530 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
531 {
532   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
533   return aConnector->workshop();
534 }