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