]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_WorkshopListener.cpp
Salome HOME
Merge remote-tracking branch 'remotes/origin/Filters_Development_2'
[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     aDisplayer->updateViewer();
362   }
363 }
364
365 //******************************************************
366 void XGUI_WorkshopListener::
367   onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
368 {
369   std::set<ObjectPtr> anObjects = theMsg->objects();
370   std::set<ObjectPtr>::const_iterator aIt;
371 #ifdef DEBUG_FEATURE_CREATED
372   QStringList anInfo;
373   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
374     anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
375   }
376   QString anInfoStr = anInfo.join(";\t");
377   qDebug(QString("onFeatureCreatedMsg: %1, %2")
378     .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
379 #endif
380
381   //bool aHasPart = false;
382   bool aDisplayed = false;
383   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
384     ObjectPtr anObject = *aIt;
385
386 #ifdef DEBUG_RESULT_COMPSOLID
387     ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
388     if (aRes.get()) {
389       ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
390       if (aCompSolidRes.get()) {
391           qDebug(QString("COMPSOLID, numberOfSubs = %1")
392             .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
393       }
394       if (ModelAPI_Tools::compSolidOwner(aRes))
395         qDebug("COMPSOLID sub-object");
396     }
397 #endif
398     // the validity of the data should be checked here in order to avoid display of the objects,
399     // which were created, then deleted, but flush for the creation event happens after that
400     // we should not display disabled objects
401     bool aHide = !anObject->data()->isValid() ||
402                  anObject->isDisabled() ||
403                  !anObject->isDisplayed();
404     if (!aHide) { // check that this is not hidden result
405       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
406       bool isConcealed = aRes && aRes->isConcealed();
407       aHide = aRes && aRes->isConcealed();
408       // Hide the presentation with an empty shape. But isDisplayed state of the object should not
409       // be changed to the object becomes visible when the shape becomes not empty
410       if (!aHide && aRes.get())
411         aHide = !aRes->shape().get() || aRes->shape()->isNull();
412     }
413     if (!aHide) {
414       // setDisplayed has to be called in order to synchronize internal state of the object
415       // with list of displayed objects
416       if (myWorkshop->module()->canDisplayObject(anObject)) {
417         anObject->setDisplayed(true);
418         aDisplayed = displayObject(anObject);
419       } else
420         anObject->setDisplayed(false);
421     }
422   }
423
424   bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
425
426   //if (myObjectBrowser)
427   //  myObjectBrowser->processEvent(theMsg);
428   if (aDisplayed) {
429     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
430     workshop()->displayer()->updateViewer();
431   }
432   //if (aHasPart) { // TODO: Avoid activate last part on loading of document
433   //  activateLastPart();
434   //}
435 }
436
437 //******************************************************
438 void XGUI_WorkshopListener::onFeatureEmptyPresentationMsg(
439                                       const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
440 {
441   std::set<ObjectPtr> anObjects = theMsg->objects();
442   std::set<ObjectPtr>::const_iterator aIt;
443 #ifdef DEBUG_FEATURE_CREATED
444   QStringList anInfo;
445   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
446     anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
447   }
448   QString anInfoStr = anInfo.join(";\t");
449   qDebug(QString("onFeatureEmptyPresentationMsg: %1, %2")
450     .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
451 #endif
452
453   XGUI_Workshop* aWorkshop = workshop();
454   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
455
456   bool aRedisplayed = false;
457   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
458     ObjectPtr anObject = *aIt;
459     aRedisplayed = aDisplayer->erase(anObject, false) || aRedisplayed;
460   }
461
462   if (aRedisplayed)
463     aDisplayer->updateViewer();
464 }
465
466 bool XGUI_WorkshopListener::event(QEvent * theEvent)
467 {
468   PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
469   if (aPostponedEv) {
470     std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
471     processEvent(aEventPtr);
472     return true;
473   }
474   return false;
475 }
476
477 //**************************************************************
478 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
479 {
480 #ifdef DEBUG_RESULT_COMPSOLID
481   ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
482   if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
483     ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
484     if (aCompSolidRes.get()) {
485       qDebug("COMPSOLID: displayObject");
486     }
487   }
488 #endif
489
490   bool aDisplayed = false;
491   XGUI_Workshop* aWorkshop = workshop();
492   // do not display the object if it has sub objects. They should be displayed separately.
493   if (!aWorkshop->module()->canDisplayObject(theObj) ||
494       ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
495     return aDisplayed;
496
497   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
498   int aNb = aDisplayer->objectsCount();
499   return aDisplayer->display(theObj, false);
500 }
501
502 bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
503                                                    bool theForceRedisplay)
504 {
505   XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
506   FeaturePtr aCurrentFeature;
507   if (anOperationMgr->hasOperation()) {
508     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
509                                                       (anOperationMgr->currentOperation());
510     if (aFOperation) {
511       aCurrentFeature = aFOperation->feature();
512     }
513   }
514
515   bool aCustomized = false;
516   if (aCurrentFeature.get()) {
517     // the customize presentation should be redisplayed if force redislayed is true or
518     // if a list of message objects contains the operation feature for case when
519     // the feature is hidden, but arguments of the feature are modified
520     // e.g. extrusion is hidden(h=0) but sketch is chosen
521     if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
522       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
523                                  ModuleBase_IModule::CustomizeArguments, false) || aCustomized;
524       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
525                                    ModuleBase_IModule::CustomizeResults, false) || aCustomized;
526       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
527                         ModuleBase_IModule::CustomizeHighlightedObjects, false) || aCustomized;
528     }
529   }
530   return aCustomized;
531 }
532
533 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
534 {
535   return myWorkshop;
536 }