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));
124 aLoop->registerListener(this, ModelAPI_ObjectRenamedMessage::eventId());
127 //******************************************************
128 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
130 if (QApplication::instance() &&
131 QApplication::instance()->thread() != QThread::currentThread()) {
133 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
135 SessionPtr aMgr = ModelAPI_Session::get();
136 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
137 QApplication::postEvent(this, aPostponeEvent);
141 // Process creation of Part
142 if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
143 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
144 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
145 onFeatureCreatedMsg(aUpdMsg);
147 XGUI_SalomeConnector* aSalomeConnector = workshop()->salomeConnector();
148 if (aSalomeConnector)
149 aSalomeConnector->createPreferences();
150 myUpdatePrefs = false;
153 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
154 myUpdatePrefs = true;
157 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
158 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
159 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
160 onFeatureRedisplayMsg(aUpdMsg);
162 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES)) {
163 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
164 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
165 std::set<ObjectPtr> aObjList = aUpdMsg->objects();
166 std::set<ObjectPtr>::const_iterator aIt;
167 std::list<ResultPtr>::const_iterator aResIt;
168 XGUI_Displayer* aDisplayer = workshop()->displayer();
170 for (aIt = aObjList.begin(); aIt != aObjList.end(); ++aIt) {
171 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
173 aAIS = aDisplayer->getAISObject(aFeature);
175 workshop()->module()->customizePresentation(aFeature, aAIS);
177 std::list<ResultPtr> aResults = aFeature->results();
178 for (aResIt = aResults.begin(); aResIt != aResults.end(); ++aResIt) {
179 aAIS = aDisplayer->getAISObject(*aResIt);
181 workshop()->module()->customizePresentation(*aResIt, aAIS);
185 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) {
186 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
187 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
188 onFeatureEmptyPresentationMsg(aUpdMsg);
189 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION)) {
190 ModuleBase_ModelWidget* aWidget = workshop()->propertyPanel()->activeWidget();
192 ModuleBase_WidgetSelector* aWidgetSelector =
193 dynamic_cast<ModuleBase_WidgetSelector*>(aWidget);
195 workshop()->selector()->setSelected(aWidgetSelector->getAttributeSelection());
198 else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation")/* ||
199 theMessage->eventID() == Events_Loop::eventByName("AbortOperation")*/)
201 XGUI_FacesPanel* aFacesPanel = workshop()->facesPanel();
203 aFacesPanel->reset(false); // do not flush redisplay, it is flushed after event
205 //Update property panel on corresponding message. If there is no current operation (no
206 //property panel), or received message has different feature to the current - do nothing.
207 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
208 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
209 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
210 onFeatureUpdatedMsg(anUpdateMsg);
211 } else if (theMessage->eventID() == Events_LongOp::eventID()) {
212 if (Events_LongOp::isPerformed()) {
213 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
215 QApplication::restoreOverrideCursor();
217 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) {
218 // the viewer's update context will not happens until viewer updated is emitted
219 workshop()->displayer()->enableUpdateViewer(false);
220 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)) {
221 // the viewer's update context is unblocked, the viewer's update works
222 XGUI_Displayer* aDisplayer = workshop()->displayer();
223 aDisplayer->enableUpdateViewer(true);
225 else if ((theMessage->eventID() ==
226 Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE)) ||
227 (theMessage->eventID() ==
228 Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE))) {
229 myWorkshop->updateAutoComputeState();
231 else if (theMessage->eventID() == ModelAPI_ObjectRenamedMessage::eventId()) {
232 myWorkshop->updateGroupsText();
233 myWorkshop->displayer()->updateViewer();
235 //Show error dialog if error message received.
236 std::shared_ptr<Events_InfoMessage> anIngfoMsg =
237 std::dynamic_pointer_cast<Events_InfoMessage>(theMessage);
239 emit errorOccurred(anIngfoMsg);
244 SessionPtr aMgr = ModelAPI_Session::get();
245 AppElements_MainWindow* aMainWindow = workshop()->mainWindow();
246 if (aMgr->isModified() != aMainWindow->isModifiedState())
247 aMainWindow->setModifiedState(aMgr->isModified());
251 //******************************************************
252 void XGUI_WorkshopListener::onFeatureUpdatedMsg(
253 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
255 #ifdef DEBUG_FEATURE_UPDATED
256 std::set<ObjectPtr> anObjects = theMsg->objects();
257 std::set<ObjectPtr>::const_iterator aIt;
259 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
260 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
262 QString anInfoStr = anInfo.join(";\t");
263 qDebug(QString("onFeatureUpdatedMsg: %1, %2")
264 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
266 std::set<ObjectPtr> aFeatures = theMsg->objects();
267 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
268 if (anOperationMgr->hasOperation()) {
269 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
270 (anOperationMgr->currentOperation());
272 FeaturePtr aCurrentFeature = aFOperation->feature();
273 std::set<ObjectPtr>::const_iterator aIt;
274 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
275 ObjectPtr aNewFeature = (*aIt);
276 if (aNewFeature == aCurrentFeature) {
277 workshop()->propertyPanel()->updateContentWidget(aCurrentFeature);
283 //anOperationMgr->onValidateOperation();
285 //if (myObjectBrowser)
286 // myObjectBrowser->processEvent(theMsg);
289 //******************************************************
290 void XGUI_WorkshopListener::
291 onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
293 std::set<ObjectPtr> anObjects = theMsg->objects();
294 std::set<ObjectPtr>::const_iterator aIt;
296 #ifdef DEBUG_FEATURE_REDISPLAY
298 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
299 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
301 QString anInfoStr = anInfo.join(";\t");
302 qDebug(QString("onFeatureRedisplayMsg: %1, %2")
303 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
306 XGUI_Workshop* aWorkshop = workshop();
307 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
308 bool aRedisplayed = false;
309 //std::list<ObjectPtr> aHiddenObjects;
310 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
311 ObjectPtr aObj = (*aIt);
313 // Hide the object if it is invalid or concealed one
314 bool aHide = !aObj->data() || !aObj->data()->isValid() ||
315 aObj->isDisabled() || (!aObj->isDisplayed());
317 if (!aHide) { // check that this is not hidden result
318 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
319 aHide = aRes && aRes->isConcealed();
321 // Hide the presentation with an empty shape. But isDisplayed state of the object should not
322 // be changed to the object becomes visible when the shape becomes not empty
323 if (!aHide && aRes.get())
324 aHide = !aRes->shape().get() || aRes->shape()->isNull();
327 #ifdef DEBUG_RESULT_COMPSOLID
328 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
330 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
331 if (aCompSolidRes.get()) {
332 qDebug(QString("COMPSOLID, numberOfSubs = %1")
333 .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
335 if (ModelAPI_Tools::compSolidOwner(aRes))
336 qDebug("COMPSOLID sub-object");
339 #ifdef DEBUG_FEATURE_REDISPLAY
340 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
341 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
342 if (aFeature.get()) {
343 std::string aKind = aFeature->getKind();
344 if (aKind == DebugFeatureKind || DebugFeatureKind.empty()) {
345 qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
346 .arg(aHide).arg(anObjInfo).toStdString().c_str());
351 //we should provide objects which are hidden in the viewer, e.g. sketch always should
352 // visualizes all sub-features, if some features are to be hidden, sould be proposed may
353 // be to removed #1223
354 // aHiddenObjects.push_back(aObj);
355 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
356 #ifdef DEBUG_FEATURE_REDISPLAY
357 // Redisplay the visible object or the object of the current operation
358 bool isVisibleObject = aDisplayer->isVisible(aObj);
360 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
364 // Redisplay the visible object or the object of the current operation
365 bool isVisibleObject = aDisplayer->isVisible(aObj);
366 #ifdef DEBUG_FEATURE_REDISPLAY
367 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
370 if (isVisibleObject) { // redisplay visible object
371 //displayObject(aObj); // In order to update presentation
372 // in order to avoid the check whether the object can be redisplayed, the exact method
373 // of redisplay is called. This modification is made in order to have the line is updated
374 // by creation of a horizontal constraint on the line by preselection
375 if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
376 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
379 aRedisplayed = aDisplayer->redisplay(aObj, false) || aRedisplayed;
380 // Deactivate object of current operation from selection
381 aWorkshop->deactivateActiveObject(aObj, false);
383 } else { // display object if the current operation has it
384 if (displayObject(aObj)) {
386 // Deactivate object of current operation from selection
387 aWorkshop->deactivateActiveObject(aObj, false);
393 // this processing should be moved in another place in order to do not cause problems in
394 // flush messages chain
395 //if (aHiddenObjects.size() > 0)
396 // myWorkshop->module()->processHiddenObject(aHiddenObjects);
398 bool isCustomized = customizeFeature(anObjects, aRedisplayed);
399 if (aRedisplayed || isCustomized) {
400 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
402 // Do not update viewer here because it can be called in a loop
403 // In this case Update has to be called after redisplay event
404 //aDisplayer->updateViewer();
408 //******************************************************
409 void XGUI_WorkshopListener::
410 onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
412 bool isLoadedScript = false;
413 SUIT_Session* aSession = SUIT_Session::session();
416 QVariant aVar = aSession->activeApplication()->property("IsLoadedScript");
417 isLoadedScript = !aVar.isNull() && aVar.toBool();
420 std::set<ObjectPtr> anObjects = theMsg->objects();
421 std::set<ObjectPtr>::const_iterator aIt;
422 #ifdef DEBUG_FEATURE_CREATED
424 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
425 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
427 QString anInfoStr = anInfo.join(";\t");
428 qDebug(QString("onFeatureCreatedMsg: %1, %2")
429 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
432 //bool aHasPart = false;
433 bool aDisplayed = false;
434 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
435 ObjectPtr anObject = *aIt;
437 #ifdef DEBUG_RESULT_COMPSOLID
438 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
440 ResultCompSolidPtr aCompSolidRes =
441 std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
442 if (aCompSolidRes.get()) {
443 qDebug(QString("COMPSOLID, numberOfSubs = %1")
444 .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
446 if (ModelAPI_Tools::compSolidOwner(aRes))
447 qDebug("COMPSOLID sub-object");
451 ResultBodyPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
452 if (aRes.get() && aRes->numberOfSubs() > 0)
453 for (int anIndex = 0; anIndex < aRes->numberOfSubs(); ++anIndex)
454 setDisplayed(aRes->subResult(anIndex), isLoadedScript, aDisplayed);
456 setDisplayed(anObject, isLoadedScript, aDisplayed);
459 MAYBE_UNUSED bool isCustomized = customizeFeature(anObjects, aDisplayed);
461 //if (myObjectBrowser)
462 // myObjectBrowser->processEvent(theMsg);
464 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
465 workshop()->displayer()->updateViewer();
467 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
468 // activateLastPart();
472 //******************************************************
473 void XGUI_WorkshopListener::onFeatureEmptyPresentationMsg(
474 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
476 std::set<ObjectPtr> anObjects = theMsg->objects();
477 std::set<ObjectPtr>::const_iterator aIt;
478 #ifdef DEBUG_FEATURE_CREATED
480 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
481 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
483 QString anInfoStr = anInfo.join(";\t");
484 qDebug(QString("onFeatureEmptyPresentationMsg: %1, %2")
485 .arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
488 XGUI_Workshop* aWorkshop = workshop();
489 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
491 bool aRedisplayed = false;
492 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
493 ObjectPtr anObject = *aIt;
494 aRedisplayed = aDisplayer->erase(anObject, false) || aRedisplayed;
498 aDisplayer->updateViewer();
501 bool XGUI_WorkshopListener::event(QEvent * theEvent)
503 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
505 std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
506 processEvent(aEventPtr);
512 //**************************************************************
513 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
515 #ifdef DEBUG_RESULT_COMPSOLID
516 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
517 if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
518 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
519 if (aCompSolidRes.get()) {
520 qDebug("COMPSOLID: displayObject");
525 bool aDisplayed = false;
526 XGUI_Workshop* aWorkshop = workshop();
527 // do not display the object if it has sub objects. They should be displayed separately.
528 if (!aWorkshop->module()->canDisplayObject(theObj) ||
529 ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
532 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
533 return aDisplayer->display(theObj, false);
536 bool XGUI_WorkshopListener::customizeFeature(const std::set<ObjectPtr>& theObjects,
537 bool theForceRedisplay)
539 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
540 FeaturePtr aCurrentFeature;
541 if (anOperationMgr->hasOperation()) {
542 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
543 (anOperationMgr->currentOperation());
545 aCurrentFeature = aFOperation->feature();
549 bool aCustomized = false;
550 if (aCurrentFeature.get()) {
551 // the customize presentation should be redisplayed if force redislayed is true or
552 // if a list of message objects contains the operation feature for case when
553 // the feature is hidden, but arguments of the feature are modified
554 // e.g. extrusion is hidden(h=0) but sketch is chosen
555 if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
556 aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
557 ModuleBase_IModule::CustomizeArguments, false) || aCustomized;
558 aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
559 ModuleBase_IModule::CustomizeResults, false) || aCustomized;
560 aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
561 ModuleBase_IModule::CustomizeHighlightedObjects, false) || aCustomized;
567 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
573 void XGUI_WorkshopListener::setDisplayed(
574 ObjectPtr theObject, const bool theIsLoadedScript, bool& theDisplayed)
576 if (theIsLoadedScript) {
577 theObject->setDisplayed(theDisplayed);
580 // the validity of the data should be checked here in order to avoid display of the objects,
581 // which were created, then deleted, but flush for the creation event happens after that
582 // we should not display disabled objects
583 bool aHide = !theObject->data()->isValid() ||
584 theObject->isDisabled() ||
585 !theObject->isDisplayed();
586 if (!aHide) { // check that this is not hidden result
587 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
588 aHide = aRes && aRes->isConcealed();
589 // Hide the presentation with an empty shape. But isDisplayed state of the object should not
590 // be changed to the object becomes visible when the shape becomes not empty
591 if (!aHide && aRes.get())
592 aHide = !aRes->shape().get() || aRes->shape()->isNull();
595 // setDisplayed has to be called in order to synchronize internal state of the object
596 // with list of displayed objects
597 if (myWorkshop->module()->canDisplayObject(theObject)) {
598 theObject->setDisplayed(true);
599 theDisplayed = displayObject(theObject);
602 theObject->setDisplayed(false);