From: nds Date: Thu, 7 Dec 2017 07:02:42 +0000 (+0300) Subject: Issue #2309 Possibility to hide faces : display hidden objects by panel if it uses... X-Git-Tag: V_2.10.0RC~86 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff71a1f7affe3aef9c54a8d3d89330227a9ab360;p=modules%2Fshaper.git Issue #2309 Possibility to hide faces : display hidden objects by panel if it uses transparent presentation. --- diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index 63a571ca7..ad9ca2feb 100755 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -207,6 +207,7 @@ void ModuleBase_ResultPrs::Compute( if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty()) { StdPrs_ShadedShape::Add (thePresentation, myHiddenCompound, myHiddenSubShapesDrawer); + aReadyToDisplay = true; } if (!aReadyToDisplay) { diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index 55b0c1786..565f611f5 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -207,7 +207,8 @@ void XGUI_FacesPanel::processSelection() myLastItemIndex++; isModified = true; - if (aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs))) // redisplay + if (aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs)) || + useTransparency()) // redisplay ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); else { // erase object because it is entirely hidden anObject->setDisplayed(false); @@ -312,6 +313,33 @@ bool XGUI_FacesPanel::displayHiddenObjects( return isModified; } +//******************************************************************** +bool XGUI_FacesPanel::hideEmptyObjects() +{ + bool isModified = false; + static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); + for (QMap::const_iterator anIt = myItems.begin(); + anIt != myItems.end(); anIt++) { + ModuleBase_ViewerPrsPtr aPrs = anIt.value(); + ObjectPtr anObject = aPrs->object(); + if (!anObject.get() || !anObject->isDisplayed()) + continue; + + Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast( + aPrs->interactive()); + if (aResultPrs.IsNull()) + continue; + + if (!aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs))) { + // erase object because it is entirely hidden + anObject->setDisplayed(false); + myHiddenObjects.insert(anObject); + ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); + isModified = true; + } + } + return isModified; +} //******************************************************************** void XGUI_FacesPanel::updateProcessedObjects(QMap theItems, @@ -426,7 +454,15 @@ void XGUI_FacesPanel::onDeleteItem() //******************************************************************** void XGUI_FacesPanel::onTransparencyChanged() { - bool isModified = redisplayObjects(myItemObjects, false); + bool isModified = false; + if (useTransparency()) { + std::set > aHiddenObjects = myHiddenObjects; + isModified = displayHiddenObjects(aHiddenObjects, false); + } + else + isModified = hideEmptyObjects(); + + isModified = redisplayObjects(myItemObjects, false) || isModified; if (isModified) Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); diff --git a/src/XGUI/XGUI_FacesPanel.h b/src/XGUI/XGUI_FacesPanel.h index 1679bdc3e..8b5d71a6b 100644 --- a/src/XGUI/XGUI_FacesPanel.h +++ b/src/XGUI/XGUI_FacesPanel.h @@ -158,6 +158,10 @@ private: bool displayHiddenObjects(const std::set >& theObjects, const bool isToFlushRedisplay); + /// Iterates by items and hide objects where all sub-shapes are hidden + /// \return true if some of objects was redisplayed + bool hideEmptyObjects(); + /// Container of objects participating in the panel, it is filled by internal container /// \param theItems container of selected values /// \param theObjects [out] container of objects