From a6938acd07314567d02ed265808ceb1efeeb4849 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 15 Dec 2017 15:38:32 +0300 Subject: [PATCH] Issue #2364: eye is open for solid with all faces hidden --- src/XGUI/XGUI_FacesPanel.cpp | 46 +++++++++++++++++++----------------- src/XGUI/XGUI_FacesPanel.h | 13 +++++----- src/XGUI/XGUI_Workshop.cpp | 2 +- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index a815c49ec..01211ae75 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -34,6 +34,7 @@ #include "ModuleBase_Tools.h" #include "ModuleBase_ViewerPrs.h" +#include "XGUI_ObjectsBrowser.h" #include "XGUI_SelectionMgr.h" #include "XGUI_SelectionFilterType.h" #include "XGUI_Tools.h" @@ -85,11 +86,11 @@ void XGUI_FacesPanel::reset(const bool isToFlushRedisplay) myItems.clear(); // restore previous view of presentations - bool isModified = redisplayObjects(myItemObjects, false); + bool isModified = redisplayObjects(myItemObjects); std::set > aHiddenObjects = myHiddenObjects; - isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects, false) || isModified; + isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects) || isModified; if (isModified)// && isToFlushRedisplay) // flush signal immediatelly until container is filled - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + flushRedisplay(); updateProcessedObjects(myItems, myItemObjects); myHiddenObjects.clear(); @@ -261,10 +262,9 @@ void XGUI_FacesPanel::processSelection() ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); } } - if (isModified) - { + if (isModified) { updateProcessedObjects(myItems, myItemObjects); - Events_Loop::loop()->flush(aDispEvent); + flushRedisplay(); } } @@ -290,11 +290,11 @@ bool XGUI_FacesPanel::processDelete() isModified = true; } if (isModified) { - bool isRedisplayed = redisplayObjects(aRestoredObjects, false); - isRedisplayed = displayHiddenObjects(aRestoredObjects, myHiddenObjects, false) + bool isRedisplayed = redisplayObjects(aRestoredObjects); + isRedisplayed = displayHiddenObjects(aRestoredObjects, myHiddenObjects) || isRedisplayed; if (isRedisplayed) - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + flushRedisplay(); // should be after flush of redisplay to have items object to be updated updateProcessedObjects(myItems, myItemObjects); } @@ -308,8 +308,7 @@ bool XGUI_FacesPanel::processDelete() //******************************************************************** bool XGUI_FacesPanel::redisplayObjects( - const std::set >& theObjects, - const bool isToFlushRedisplay) + const std::set >& theObjects) { if (theObjects.empty()) return false; @@ -325,16 +324,13 @@ bool XGUI_FacesPanel::redisplayObjects( ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); isModified = true; } - if (isModified && isToFlushRedisplay) - Events_Loop::loop()->flush(aDispEvent); return isModified; } //******************************************************************** bool XGUI_FacesPanel::displayHiddenObjects( const std::set >& theObjects, - std::set >& theHiddenObjects, - const bool isToFlushRedisplay) + std::set >& theHiddenObjects) { if (theObjects.empty()) return false; @@ -354,9 +350,6 @@ bool XGUI_FacesPanel::displayHiddenObjects( ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); isModified = true; } - - if (isModified && isToFlushRedisplay) - Events_Loop::loop()->flush(aDispEvent); return isModified; } @@ -506,15 +499,14 @@ void XGUI_FacesPanel::onTransparencyChanged() bool isModified = false; if (useTransparency()) { std::set > aHiddenObjects = myHiddenObjects; - isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects, false); + isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects); } else isModified = hideEmptyObjects(); - isModified = redisplayObjects(myItemObjects, false) || isModified; + isModified = redisplayObjects(myItemObjects) || isModified; if (isModified) - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); - + flushRedisplay(); } //******************************************************************** @@ -523,3 +515,13 @@ void XGUI_FacesPanel::onClosed() setActivePanel(false); reset(true); } + +//******************************************************************** +void XGUI_FacesPanel::flushRedisplay() const +{ + Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + // Necessary for update visibility icons in ObjectBrowser + XGUI_ObjectsBrowser* anObjectBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser(); + if (anObjectBrowser) + anObjectBrowser->updateAllIndexes(); +} diff --git a/src/XGUI/XGUI_FacesPanel.h b/src/XGUI/XGUI_FacesPanel.h index ad98a4e55..567fa8e13 100644 --- a/src/XGUI/XGUI_FacesPanel.h +++ b/src/XGUI/XGUI_FacesPanel.h @@ -151,19 +151,15 @@ signals: private: /// Redisplay objects. /// \param theObjects container of objects - /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly /// \return true if some of objects was redisplayed - static bool redisplayObjects(const std::set >& theObjects, - const bool isToFlushRedisplay); + static bool redisplayObjects(const std::set >& theObjects); /// Display objects if the objects are in a container of hidden by this pane. /// \param theObjects container of objects /// \param theHiddenObjects hidden objects, if object is in the container, it should be removed - /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly /// \return true if some of objects was redisplayed static bool displayHiddenObjects(const std::set >& theObjects, - std::set >& theHiddenObjects, - const bool isToFlushRedisplay); + std::set >& theHiddenObjects); /// Iterates by items and hide objects where all sub-shapes are hidden /// \return true if some of objects was redisplayed @@ -190,6 +186,11 @@ protected slots: /// Closes faces panel restore all hidden faces by calling reset() void onClosed(); +private: + /// Flushes redisplay event and perform update of object browser icons + /// (objects might be hidden/shown) + void flushRedisplay() const; + protected: QCheckBox* myHiddenOrTransparent; ///< if checked - transparent, else hidden ModuleBase_ListView* myListView; ///< list control of processed faces diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 796c70af2..da6775edd 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1635,7 +1635,7 @@ bool XGUI_Workshop::prepareForDisplay(const std::set& theObjects) con int anAnswer = QMessageBox::question( desktop(), tr("Show object"), tr("'%1'\n are hidden by %2:\nRemove objects from the panel to be displayed?") - .arg(aHiddenObjectNames.join(',')).arg(facesPanel()->windowTitle()), + .arg(aHiddenObjectNames.join(' ,')).arg(facesPanel()->windowTitle()), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); bool aToBeDisplayed = anAnswer == QMessageBox::Yes; -- 2.39.2