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