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