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