1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "XGUI_WorkshopListener.h"
23 #include <AppElements_MainWindow.h>
26 #include <Config_FeatureMessage.h>
27 #include <Config_PointerMessage.h>
28 #include <Config_Keywords.h>
30 #include <Events_InfoMessage.h>
31 #include <Events_Loop.h>
32 #include <Events_LongOp.h>
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>
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>
53 #include <SUIT_Application.h>
54 #include <SUIT_Session.h>
56 #include "XGUI_ActionsMgr.h"
57 #include "XGUI_Displayer.h"
58 #include "XGUI_ErrorMgr.h"
59 #include "XGUI_FacesPanel.h"
60 #include "XGUI_OperationMgr.h"
61 #include "XGUI_ModuleConnector.h"
62 #include "XGUI_PropertyPanel.h"
63 #include "XGUI_QtEvents.h"
64 #include "XGUI_SalomeConnector.h"
65 #include "XGUI_SelectionMgr.h"
66 #include "XGUI_Workshop.h"
69 #include <QApplication>
70 #include <QMainWindow>
79 #pragma warning(disable : 4189) // for declaration of unused variables (MAYBE_UNUSED)
82 //#define DEBUG_FEATURE_CREATED
83 //#define DEBUG_FEATURE_REDISPLAY
84 //#define DEBUG_FEATURE_UPDATED
85 //#define DEBUG_RESULT_COMPSOLID
87 #ifdef DEBUG_FEATURE_REDISPLAY
88 const std::string DebugFeatureKind = "";//"Extrusion";
91 XGUI_WorkshopListener::XGUI_WorkshopListener(XGUI_Workshop* theWorkshop)
92 : myWorkshop(theWorkshop),
97 //******************************************************
98 XGUI_WorkshopListener::~XGUI_WorkshopListener(void)
102 //******************************************************
103 void XGUI_WorkshopListener::initializeEventListening()
105 //Initialize event listening
106 Events_Loop* aLoop = Events_Loop::loop();
107 aLoop->registerListener(this, Events_InfoMessage::errorID()); //!< Listening application errors.
108 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
109 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
110 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
111 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES));
112 aLoop->registerListener(this, Events_LongOp::eventID());
113 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
115 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
116 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
117 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
118 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION));
120 aLoop->registerListener(this, Events_Loop::eventByName("FinishOperation"));
121 aLoop->registerListener(this, Events_Loop::eventByName("AbortOperation"));
122 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE));
123 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE));
126 //******************************************************
127 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
129 if (QApplication::instance() &&
130 QApplication::instance()->thread() != QThread::currentThread()) {
132 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
134 SessionPtr aMgr = ModelAPI_Session::get();
135 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
136 QApplication::postEvent(this, aPostponeEvent);
140 // Process creation of Part
141 if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
142 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
143 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
144 onFeatureCreatedMsg(aUpdMsg);
146 XGUI_SalomeConnector* aSalomeConnector = workshop()->salomeConnector();
147 if (aSalomeConnector)
148 aSalomeConnector->createPreferences();
149 myUpdatePrefs = false;
152 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
153 myUpdatePrefs = true;
156 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
157 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
158 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
159 onFeatureRedisplayMsg(aUpdMsg);
161 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES)) {
162 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
163 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
164 std::set<ObjectPtr> aObjList = aUpdMsg->objects();
165 std::set<ObjectPtr>::const_iterator aIt;
166 std::list<ResultPtr>::const_iterator aResIt;
167 XGUI_Displayer* aDisplayer = workshop()->displayer();
169 for (aIt = aObjList.begin(); aIt != aObjList.end(); ++aIt) {
170 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
172 aAIS = aDisplayer->getAISObject(aFeature);
174 workshop()->module()->customizePresentation(aFeature, aAIS);
176 std::list<ResultPtr> aResults = aFeature->results();
177 for (aResIt = aResults.begin(); aResIt != aResults.end(); ++aResIt) {
178 aAIS = aDisplayer->getAISObject(*aResIt);
180 workshop()->module()->customizePresentation(*aResIt, aAIS);
184 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) {
185 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
186 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
187 onFeatureEmptyPresentationMsg(aUpdMsg);
188 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)) {
189 ModuleBase_ModelWidget* aWidget = workshop()->propertyPanel()->activeWidget();
191 ModuleBase_WidgetSelector* aWidgetSelector =
192 dynamic_cast<ModuleBase_WidgetSelector*>(aWidget);
194 workshop()->selector()->setSelected(aWidgetSelector->getAttributeSelection());
196 } else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation")/* ||
197 theMessage->eventID() == Events_Loop::eventByName("AbortOperation")*/)
198 workshop()->facesPanel()->reset(false); // do not flush redisplay, it is flushed after event
200 //Update property panel on corresponding message. If there is no current operation (no
201 //property panel), or received message has different feature to the current - do nothing.
202 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
203 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
204 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
205 onFeatureUpdatedMsg(anUpdateMsg);
206 } else if (theMessage->eventID() == Events_LongOp::eventID()) {
207 if (Events_LongOp::isPerformed()) {
208 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
210 QApplication::restoreOverrideCursor();
212 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) {
213 // the viewer's update context will not happens until viewer updated is emitted
214 workshop()->displayer()->enableUpdateViewer(false);
215 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)) {
216 // the viewer's update context is unblocked, the viewer's update works
217 XGUI_Displayer* aDisplayer = workshop()->displayer();
218 aDisplayer->enableUpdateViewer(true);
219 } else if ((theMessage->eventID() ==
220 Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)) ||
221 (theMessage->eventID() ==
222 Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE))) {
223 myWorkshop->updateAutoComputeState();
225 //Show error dialog if error message received.
226 std::shared_ptr<Events_InfoMessage> anIngfoMsg =
227 std::dynamic_pointer_cast<Events_InfoMessage>(theMessage);
229 emit errorOccurred(anIngfoMsg);
234 SessionPtr aMgr = ModelAPI_Session::get();
235 AppElements_MainWindow* aMainWindow = workshop()->mainWindow();
236 if (aMgr->isModified() != aMainWindow->isModifiedState())
237 aMainWindow->setModifiedState(aMgr->isModified());
241 //******************************************************
242 void XGUI_WorkshopListener::onFeatureUpdatedMsg(
243 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
245 #ifdef DEBUG_FEATURE_UPDATED
246 std::set<ObjectPtr> anObjects = theMsg->objects();
247 std::set<ObjectPtr>::const_iterator aIt;
249 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
250 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
252 QString anInfoStr = anInfo.join(";\t");
253 qDebug(QString("onFeatureUpdatedMsg: %1, %2")
254 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
256 std::set<ObjectPtr> aFeatures = theMsg->objects();
257 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
258 if (anOperationMgr->hasOperation()) {
259 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
260 (anOperationMgr->currentOperation());
262 FeaturePtr aCurrentFeature = aFOperation->feature();
263 std::set<ObjectPtr>::const_iterator aIt;
264 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
265 ObjectPtr aNewFeature = (*aIt);
266 if (aNewFeature == aCurrentFeature) {
267 workshop()->propertyPanel()->updateContentWidget(aCurrentFeature);
273 //anOperationMgr->onValidateOperation();
275 //if (myObjectBrowser)
276 // myObjectBrowser->processEvent(theMsg);
279 //******************************************************
280 void XGUI_WorkshopListener::
281 onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
283 std::set<ObjectPtr> anObjects = theMsg->objects();
284 std::set<ObjectPtr>::const_iterator aIt;
286 #ifdef DEBUG_FEATURE_REDISPLAY
288 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
289 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
291 QString anInfoStr = anInfo.join(";\t");
292 qDebug(QString("onFeatureRedisplayMsg: %1, %2")
293 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
296 XGUI_Workshop* aWorkshop = workshop();
297 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
298 bool aRedisplayed = false;
299 //std::list<ObjectPtr> aHiddenObjects;
300 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
301 ObjectPtr aObj = (*aIt);
303 // Hide the object if it is invalid or concealed one
304 bool aHide = !aObj->data() || !aObj->data()->isValid() ||
305 aObj->isDisabled() || (!aObj->isDisplayed());
307 if (!aHide) { // check that this is not hidden result
308 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
309 aHide = aRes && aRes->isConcealed();
311 // Hide the presentation with an empty shape. But isDisplayed state of the object should not
312 // be changed to the object becomes visible when the shape becomes not empty
313 if (!aHide && aRes.get())
314 aHide = !aRes->shape().get() || aRes->shape()->isNull();
317 #ifdef DEBUG_RESULT_COMPSOLID
318 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
320 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
321 if (aCompSolidRes.get()) {
322 qDebug(QString("COMPSOLID, numberOfSubs = %1")
323 .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
325 if (ModelAPI_Tools::compSolidOwner(aRes))
326 qDebug("COMPSOLID sub-object");
329 #ifdef DEBUG_FEATURE_REDISPLAY
330 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
331 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
332 if (aFeature.get()) {
333 std::string aKind = aFeature->getKind();
334 if (aKind == DebugFeatureKind || DebugFeatureKind.empty()) {
335 qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
336 .arg(aHide).arg(anObjInfo).toStdString().c_str());
341 //we should provide objects which are hidden in the viewer, e.g. sketch always should
342 // visualizes all sub-features, if some features are to be hidden, sould be proposed may
343 // be to removed #1223
344 // aHiddenObjects.push_back(aObj);
345 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
346 #ifdef DEBUG_FEATURE_REDISPLAY
347 // Redisplay the visible object or the object of the current operation
348 bool isVisibleObject = aDisplayer->isVisible(aObj);
350 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
354 // Redisplay the visible object or the object of the current operation
355 bool isVisibleObject = aDisplayer->isVisible(aObj);
356 #ifdef DEBUG_FEATURE_REDISPLAY
357 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
360 if (isVisibleObject) { // redisplay visible object
361 //displayObject(aObj); // In order to update presentation
362 // in order to avoid the check whether the object can be redisplayed, the exact method
363 // of redisplay is called. This modification is made in order to have the line is updated
364 // by creation of a horizontal constraint on the line by preselection
365 if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
366 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
369 aRedisplayed = aDisplayer->redisplay(aObj, false) || aRedisplayed;
370 // Deactivate object of current operation from selection
371 aWorkshop->deactivateActiveObject(aObj, false);
373 } else { // display object if the current operation has it
374 if (displayObject(aObj)) {
376 // Deactivate object of current operation from selection
377 aWorkshop->deactivateActiveObject(aObj, false);
383 // this processing should be moved in another place in order to do not cause problems in
384 // flush messages chain
385 //if (aHiddenObjects.size() > 0)
386 // myWorkshop->module()->processHiddenObject(aHiddenObjects);
388 bool isCustomized = customizeFeature(anObjects, aRedisplayed);
389 if (aRedisplayed || isCustomized) {
390 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
392 // Do not update viewer here because it can be called in a loop
393 // In this case Update has to be called after redisplay event
394 //aDisplayer->updateViewer();
398 //******************************************************
399 void XGUI_WorkshopListener::
400 onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
402 bool isLoadedScript = false;
403 SUIT_Session* aSession = SUIT_Session::session();
406 QVariant aVar = aSession->activeApplication()->property("IsLoadedScript");
407 isLoadedScript = !aVar.isNull() && aVar.toBool();
410 std::set<ObjectPtr> anObjects = theMsg->objects();
411 std::set<ObjectPtr>::const_iterator aIt;
412 #ifdef DEBUG_FEATURE_CREATED
414 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
415 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
417 QString anInfoStr = anInfo.join(";\t");
418 qDebug(QString("onFeatureCreatedMsg: %1, %2")
419 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
422 //bool aHasPart = false;
423 bool aDisplayed = false;
424 if (!isLoadedScript) {
425 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
426 ObjectPtr anObject = *aIt;
428 #ifdef DEBUG_RESULT_COMPSOLID
429 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
431 ResultCompSolidPtr aCompSolidRes =
432 std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
433 if (aCompSolidRes.get()) {
434 qDebug(QString("COMPSOLID, numberOfSubs = %1")
435 .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
437 if (ModelAPI_Tools::compSolidOwner(aRes))
438 qDebug("COMPSOLID sub-object");
442 ResultBodyPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
444 if (aRes.get() && aRes->numberOfSubs() > 0)
445 for (int anIndex = 0; anIndex < aRes->numberOfSubs(); ++anIndex)
446 setDisplayed(aRes->subResult(anIndex), aDisplayed);
448 setDisplayed(anObject, aDisplayed);
451 MAYBE_UNUSED bool isCustomized = customizeFeature(anObjects, aDisplayed);
453 //if (myObjectBrowser)
454 // myObjectBrowser->processEvent(theMsg);
456 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
457 workshop()->displayer()->updateViewer();
459 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
460 // activateLastPart();
464 //******************************************************
465 void XGUI_WorkshopListener::onFeatureEmptyPresentationMsg(
466 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
468 std::set<ObjectPtr> anObjects = theMsg->objects();
469 std::set<ObjectPtr>::const_iterator aIt;
470 #ifdef DEBUG_FEATURE_CREATED
472 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
473 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
475 QString anInfoStr = anInfo.join(";\t");
476 qDebug(QString("onFeatureEmptyPresentationMsg: %1, %2")
477 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
480 XGUI_Workshop* aWorkshop = workshop();
481 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
483 bool aRedisplayed = false;
484 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
485 ObjectPtr anObject = *aIt;
486 aRedisplayed = aDisplayer->erase(anObject, false) || aRedisplayed;
490 aDisplayer->updateViewer();
493 bool XGUI_WorkshopListener::event(QEvent * theEvent)
495 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
497 std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
498 processEvent(aEventPtr);
504 //**************************************************************
505 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
507 #ifdef DEBUG_RESULT_COMPSOLID
508 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
509 if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
510 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
511 if (aCompSolidRes.get()) {
512 qDebug("COMPSOLID: displayObject");
517 bool aDisplayed = false;
518 XGUI_Workshop* aWorkshop = workshop();
519 // do not display the object if it has sub objects. They should be displayed separately.
520 if (!aWorkshop->module()->canDisplayObject(theObj) ||
521 ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
524 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
525 return aDisplayer->display(theObj, false);
528 bool XGUI_WorkshopListener::customizeFeature(const std::set<ObjectPtr>& theObjects,
529 bool theForceRedisplay)
531 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
532 FeaturePtr aCurrentFeature;
533 if (anOperationMgr->hasOperation()) {
534 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
535 (anOperationMgr->currentOperation());
537 aCurrentFeature = aFOperation->feature();
541 bool aCustomized = false;
542 if (aCurrentFeature.get()) {
543 // the customize presentation should be redisplayed if force redislayed is true or
544 // if a list of message objects contains the operation feature for case when
545 // the feature is hidden, but arguments of the feature are modified
546 // e.g. extrusion is hidden(h=0) but sketch is chosen
547 if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
548 aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
549 ModuleBase_IModule::CustomizeArguments, false) || aCustomized;
550 aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
551 ModuleBase_IModule::CustomizeResults, false) || aCustomized;
552 aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
553 ModuleBase_IModule::CustomizeHighlightedObjects, false) || aCustomized;
559 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
565 void XGUI_WorkshopListener::setDisplayed(ObjectPtr theObject, bool& theDisplayed)
567 // the validity of the data should be checked here in order to avoid display of the objects,
568 // which were created, then deleted, but flush for the creation event happens after that
569 // we should not display disabled objects
570 bool aHide = !theObject->data()->isValid() ||
571 theObject->isDisabled() ||
572 !theObject->isDisplayed();
573 if (!aHide) { // check that this is not hidden result
574 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
575 aHide = aRes && aRes->isConcealed();
576 // Hide the presentation with an empty shape. But isDisplayed state of the object should not
577 // be changed to the object becomes visible when the shape becomes not empty
578 if (!aHide && aRes.get())
579 aHide = !aRes->shape().get() || aRes->shape()->isNull();
582 // setDisplayed has to be called in order to synchronize internal state of the object
583 // with list of displayed objects
584 if (myWorkshop->module()->canDisplayObject(theObject)) {
585 theObject->setDisplayed(true);
586 theDisplayed = displayObject(theObject);
589 theObject->setDisplayed(false);