X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_FacesPanel.cpp;h=67e3a5aa34bba9cb54fa0ea0c5e3f0f3cf1a035e;hb=1035d41ad342fb22f5ea2552a8fc135aed95f3b8;hp=0c9124ff9c7c7bd1812684c9c398a4e57f175412;hpb=cb8e410e423a4b5ba20a3c00c8afa90b4a713168;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index 0c9124ff9..67e3a5aa3 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,29 +12,37 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "XGUI_FacesPanel.h" +#include "XGUI_ObjectsBrowser.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_Selection.h" +#include "XGUI_Tools.h" +#include "XGUI_Workshop.h" +#include "XGUI_Displayer.h" +#include "XGUI_ViewerProxy.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include - -#include -#include "ModuleBase_IWorkshop.h" -#include "ModuleBase_ListView.h" -#include "ModuleBase_ResultPrs.h" -#include "ModuleBase_Tools.h" -#include "ModuleBase_ViewerPrs.h" - -#include "XGUI_Tools.h" -#include "XGUI_Workshop.h" +#include #include #include @@ -46,7 +54,27 @@ static const int LayoutMargin = 3; //******************************************************************** -XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop) +bool getGroup(ModuleBase_ViewerPrsPtr thePrs, ResultGroupPtr& theResGroup, + FeaturePtr& theGroupFeature) +{ + ObjectPtr anObject = thePrs->object(); + if (!anObject.get()) + return false; + + theResGroup = std::dynamic_pointer_cast(anObject); + if (theResGroup.get()) { + theGroupFeature = ModelAPI_Feature::feature(theResGroup); + } + else { + theGroupFeature = std::dynamic_pointer_cast(anObject); + if (theGroupFeature.get()) + theResGroup = std::dynamic_pointer_cast(theGroupFeature->firstResult()); + } + return true; +} + +//******************************************************************** +XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop) : QDockWidget(theParent), myIsActive(false), myWorkshop(theWorkshop) { setWindowTitle(tr("Hide Faces")); @@ -77,20 +105,58 @@ void XGUI_FacesPanel::reset(const bool isToFlushRedisplay) if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset return; + std::map anObjectToShapes; + std::map anObjectToPrs; + QMap >::const_iterator aIt; + for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) { + getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs); + } + + std::set aObjects; + TopoDS_ListOfShape anEmpty; + std::map::const_iterator aPrsIt; + for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) { + aObjects.insert(aPrsIt->first); + aPrsIt->second->setSubShapeHidden(anEmpty); + } + std::set >::const_iterator aGrpIt; + for (aGrpIt = myHiddenGroups.cbegin(); aGrpIt != myHiddenGroups.cend(); aGrpIt++) + (*aGrpIt)->setDisplayed(true); + myHiddenGroups.clear(); + + if (redisplayObjects(aObjects)) + flushRedisplay(); + // clear internal containers myListView->getControl()->clear(); myItems.clear(); - - // restore previous view of presentations - bool isModified = redisplayObjects(myItemObjects, false); - std::set > aHiddenObjects = myHiddenObjects; - isModified = displayHiddenObjects(aHiddenObjects, false) || isModified; - if (isModified && isToFlushRedisplay) - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); - updateProcessedObjects(myItems, myItemObjects); - myHiddenObjects.clear(); myLastItemIndex = 0; // it should be after redisplay as flag used in customize + myHiddenObjects.clear(); +} + +//******************************************************************** +bool XGUI_FacesPanel::isEmpty() const +{ + return myItems.size() == 0; +} + +//******************************************************************** +void XGUI_FacesPanel::selectionModes(QIntList& theModes) +{ + theModes.append(TopAbs_FACE); +} + +//******************************************************************** +void XGUI_FacesPanel::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) +{ + ModuleBase_IModule* aModule = myWorkshop->module(); + QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters(); + + // The global filter makes problem for groups selection when any operation is launched + // theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter)); + theSelectionFilters.Append(aModule->selectionFilter(SF_FilterInfinite)); + theSelectionFilters.Append(aModule->selectionFilter(SF_ResultGroupNameFilter)); } //******************************************************************** @@ -115,18 +181,15 @@ void XGUI_FacesPanel::setActivePanel(const bool theIsActive) ModuleBase_Tools::setShadowEffect(myListView->getControl(), theIsActive); myIsActive = theIsActive; - if (myIsActive) - { + if (myIsActive) { emit activated(); - // selection should be activated after emit signal, that deactivates current widget(selection) - activateSelection(theIsActive); + // selection should be cleared after emit of signal to do not process selection change + // event by the previous selector + // the selection is cleared by activating selection control + myWorkshop->selector()->clearSelection(); } else - { - // selection should be activated after emit signal, that deactivates current widget(selection) - activateSelection(theIsActive); emit deactivated(); - } } //******************************************************************** @@ -135,6 +198,14 @@ bool XGUI_FacesPanel::useTransparency() const return myHiddenOrTransparent->isChecked(); } +//******************************************************************** +double XGUI_FacesPanel::transparency() const +{ + return useTransparency() ? + Config_PropManager::real("Visualization", "hidden_face_transparency") : 1; +} + + //******************************************************************** void XGUI_FacesPanel::restoreObjects(const std::set& theHiddenObjects) { @@ -186,44 +257,195 @@ bool XGUI_FacesPanel::processAction(ModuleBase_ActionType theActionType) } } +//******************************************************************** +void XGUI_FacesPanel::getObjectsMapFromResult(ResultGroupPtr theResGroup, + FeaturePtr theGroupFeature, + std::map& theObjectToShapes, + std::map& theObjectToPrs) +{ + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + // Process a grouip result + AttributeSelectionListPtr aSelectionList = theGroupFeature->selectionList("group_list"); + AISObjectPtr aPrs; + for (int i = 0; i < aSelectionList->size(); i++) { + AttributeSelectionPtr aSelection = aSelectionList->value(i); + ResultPtr aRes = aSelection->context(); + aPrs = aDisplayer->getAISObject(aRes); + if (aPrs.get()) { + Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast( + aPrs->impl()); + if (!aResultPrs.IsNull()) { + GeomShapePtr aShape = aSelection->value(); + if (theObjectToShapes.find(aRes) != theObjectToShapes.end()) + theObjectToShapes.at(aRes).Append(aShape->impl()); + else { + TopoDS_ListOfShape aListOfShapes; + aListOfShapes.Append(aShape->impl()); + theObjectToShapes[aRes] = aListOfShapes; + theObjectToPrs[aRes] = aResultPrs; + } + } + } + } +} + +//******************************************************************** +void objectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs, + std::map& theObjectToShapes, + std::map& theObjectToPrs) +{ + ObjectPtr anObject = thePrs->object(); + if (!anObject.get()) + return; + + // Process bodies + Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast( + thePrs->interactive()); + if (aResultPrs.IsNull()) + return; + + if (theObjectToShapes.find(anObject) != theObjectToShapes.end()) + theObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(thePrs)); + else { + TopoDS_ListOfShape aListOfShapes; + aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(thePrs)); + theObjectToShapes[anObject] = aListOfShapes; + theObjectToPrs[anObject] = aResultPrs; + } +} + +//******************************************************************** +void XGUI_FacesPanel::getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs, + std::map& theObjectToShapes, + std::map& theObjectToPrs) +{ + ResultGroupPtr aResGroup; + FeaturePtr aGroupFeature; + if (getGroup(thePrs, aResGroup, aGroupFeature)) + getObjectsMapFromResult(aResGroup, aGroupFeature, theObjectToShapes, theObjectToPrs); + else + objectsMapFromPrs(thePrs, theObjectToShapes, theObjectToPrs); +} + //******************************************************************** void XGUI_FacesPanel::processSelection() { - QList aSelected = myWorkshop->selection()->getSelected( - ModuleBase_ISelection::Viewer); + QList aSelected = + myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::AllControls); + + if (aSelected.size() == 0) + return; + bool isModified = false; static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); + + std::map anObjectToShapes; + std::map anObjectToPrs; + std::set aToRemove; + for (int i = 0; i < aSelected.size(); i++) { ModuleBase_ViewerPrsPtr aPrs = aSelected[i]; ObjectPtr anObject = aPrs->object(); if (!anObject.get()) continue; - if (ModuleBase_Tools::getSelectedShape(aPrs).ShapeType() != TopAbs_FACE) - continue; - Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast( - aPrs->interactive()); - if (aResultPrs.IsNull()) + ResultGroupPtr aResGroup; + FeaturePtr aGroupFeature; + if (getGroup(aPrs, aResGroup, aGroupFeature)) { + AttributeSelectionListPtr aSelectionListAttr = + aGroupFeature->data()->selectionList("group_list"); + std::string aType = aSelectionListAttr->selectionType(); + if (aType != "Faces") + continue; + } + else { + GeomShapePtr aShapePtr = aPrs->shape(); + if (!aShapePtr.get() || !aShapePtr->isFace()) + continue; + } + + QString aItemName = aResGroup.get()? + aResGroup->data()->name().c_str() : XGUI_Tools::generateName(aPrs); + if (myListView->hasItem(aItemName)) continue; + if (aResGroup.get()) { + if (aResGroup->isDisplayed()) { + aResGroup->setDisplayed(false); + myHiddenGroups.insert(aResGroup); + } + getObjectsMapFromResult(aResGroup, aGroupFeature, anObjectToShapes, anObjectToPrs); + } + else + objectsMapFromPrs(aPrs, anObjectToShapes, anObjectToPrs); + + // The code is dedicated to remove already selected items if they are selected twice + // It can happen in case of groups selection + QMap::const_iterator aIt; + for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) { + ModuleBase_ViewerPrsPtr aPrs = aIt.value(); + ObjectPtr aObject = aPrs->object(); + ResultGroupPtr aResGroup = std::dynamic_pointer_cast(aObject); + if (aResGroup.get()) + continue; + if (anObjectToShapes.find(aObject) != anObjectToShapes.end()) { + TopoDS_ListOfShape aShapes = anObjectToShapes[aObject]; + GeomShapePtr aShapePtr = aPrs->shape(); + if (aShapes.Contains(aShapePtr->impl())) { + aToRemove.insert(aIt.key()); + } + } + } + myItems.insert(myLastItemIndex, aPrs); - myListView->addItem(generateName(aPrs), myLastItemIndex); + myListView->addItem(aItemName, myLastItemIndex); myLastItemIndex++; isModified = true; + } - if (aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs)) || - useTransparency()) // redisplay - ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); - else { // erase object because it is entirely hidden + // Hide fully hidden shapes + std::map::const_iterator anIt; + for (anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) { + ObjectPtr anObject = anIt->first; + if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end()) + continue; + Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject); + + if (!aResultPrs->hasSubShapeVisible(anIt->second)) { // redisplay + // erase object because it is entirely hidden anObject->setDisplayed(false); myHiddenObjects.insert(anObject); - ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); } + ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); } - if (isModified) - { + + // Process selected presentations + double aTransp = transparency(); + std::map::iterator aPrsIt; + for (aPrsIt = anObjectToPrs.begin(); aPrsIt != anObjectToPrs.end(); aPrsIt++) { + ObjectPtr anObject = aPrsIt->first; + Handle(ModuleBase_ResultPrs) aPrs = aPrsIt->second; + TopoDS_ListOfShape aAlreadyHidden = aPrs->hiddenSubShapes(); + TopoDS_ListOfShape aListOfShapes = anObjectToShapes[anObject]; + TopoDS_ListOfShape::Iterator aShapesIt(aListOfShapes); + for (; aShapesIt.More(); aShapesIt.Next()) { + if (!aAlreadyHidden.Contains(aShapesIt.Value())) + aAlreadyHidden.Append(aShapesIt.Value()); + } + aPrs->setSubShapeHidden(aAlreadyHidden); + aPrs->setHiddenSubShapeTransparency(aTransp); + } + + // Remove duplicate items + if (aToRemove.size() > 0) { + myListView->removeItems(aToRemove); + std::set::const_iterator aIntIt; + for (aIntIt = aToRemove.cbegin(); aIntIt != aToRemove.cend(); aIntIt++) + myItems.remove(*aIntIt); + } + if (isModified) { updateProcessedObjects(myItems, myItemObjects); - Events_Loop::loop()->flush(aDispEvent); + flushRedisplay(); } } @@ -239,35 +461,57 @@ bool XGUI_FacesPanel::processDelete() return false; bool isModified = false; - std::set aRestoredObjects; - for (std::set::const_iterator anIt = aSelectedIds.begin(); anIt != aSelectedIds.end(); - anIt++) { + std::set aRestored; + std::set::const_iterator anIt; + for (anIt = aSelectedIds.begin(); anIt != aSelectedIds.end(); anIt++) { ModuleBase_ViewerPrsPtr aPrs = myItems[*anIt]; - if (aRestoredObjects.find(aPrs->object()) == aRestoredObjects.end()) - aRestoredObjects.insert(aPrs->object()); - myItems.remove(*anIt); - isModified = true; + if (aRestored.find(aPrs) == aRestored.end()) { + aRestored.insert(aPrs); + myItems.remove(*anIt); + isModified = true; + } } - if (isModified) { - bool isRedisplayed = redisplayObjects(aRestoredObjects, false); - isRedisplayed = displayHiddenObjects(aRestoredObjects, false) || isRedisplayed; - if (isRedisplayed) - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); - // should be after flush of redisplay to have items object to be updated - updateProcessedObjects(myItems, myItemObjects); + std::map anObjectToShapes; + std::map anObjectToPrs; + + std::set::const_iterator aIt; + for (aIt = aRestored.cbegin(); aIt != aRestored.cend(); aIt++) { + getObjectsMapFromPrs((*aIt), anObjectToShapes, anObjectToPrs); + ResultGroupPtr aResGroup; + FeaturePtr aGroupFeature; + if (getGroup((*aIt), aResGroup, aGroupFeature)) { + std::set >::iterator aGrpIt = myHiddenGroups.find(aResGroup); + if (aGrpIt != myHiddenGroups.end()) { + aResGroup->setDisplayed(true); + myHiddenGroups.erase(aGrpIt); + } + } } + std::set aRestoredObjects; + std::map::const_iterator aShapesIt; + for (aShapesIt = anObjectToShapes.begin(); aShapesIt != anObjectToShapes.end(); aShapesIt++) { + TopoDS_ListOfShape aShapes = aShapesIt->second; + aRestoredObjects.insert(aShapesIt->first); + Handle(ModuleBase_ResultPrs) aPrs = anObjectToPrs[aShapesIt->first]; + TopoDS_ListOfShape aHiddenShapes = aPrs->hiddenSubShapes(); + TopoDS_ListOfShape::Iterator aSubShapesIt(aShapes); + for (; aSubShapesIt.More(); aSubShapesIt.Next()) { + if (aHiddenShapes.Contains(aSubShapesIt.Value())) + aHiddenShapes.Remove(aSubShapesIt.Value()); + } + aPrs->setSubShapeHidden(aHiddenShapes); + } + if (redisplayObjects(aRestoredObjects)) + flushRedisplay(); + myListView->removeSelectedItems(); - // Restore selection - myListView->restoreSelection(anIndices); - //appendSelectionInHistory(); return true; } //******************************************************************** bool XGUI_FacesPanel::redisplayObjects( - const std::set >& theObjects, - const bool isToFlushRedisplay) + const std::set >& theObjects) { if (theObjects.empty()) return false; @@ -283,65 +527,6 @@ 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, - const bool isToFlushRedisplay) -{ - if (theObjects.empty()) - return false; - - bool isModified = false; - static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); - - for (std::set::const_iterator anIt = theObjects.begin(); anIt != theObjects.end(); - anIt++) - { - ObjectPtr anObject = *anIt; - // if the object was hidden by this panel - if (anObject->isDisplayed() || myHiddenObjects.find(anObject) == myHiddenObjects.end()) - continue; - myHiddenObjects.erase(anObject); - anObject->setDisplayed(true); // it means that the object is hidden by hide all faces - ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent); - isModified = true; - } - - if (isModified && isToFlushRedisplay) - Events_Loop::loop()->flush(aDispEvent); - 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; } @@ -354,9 +539,23 @@ void XGUI_FacesPanel::updateProcessedObjects(QMap anIt != theItems.end(); anIt++) { ModuleBase_ViewerPrsPtr aPrs = anIt.value(); ObjectPtr anObject = aPrs.get() ? aPrs->object() : ObjectPtr(); - if (anObject.get() && theObjects.find(anObject) != theObjects.end()) - continue; - theObjects.insert(anObject); + if (anObject.get()) { + ResultGroupPtr aResGroup = std::dynamic_pointer_cast(anObject); + if (aResGroup.get()) { + FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup); + AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); + for (int i = 0; i < aSelectionList->size(); i++) { + AttributeSelectionPtr aSelection = aSelectionList->value(i); + ResultPtr aRes = aSelection->context(); + if (theObjects.find(aRes) == theObjects.end()) + theObjects.insert(aRes); + } + } + else { + if (theObjects.find(anObject) == theObjects.end()) + theObjects.insert(anObject); + } + } } } @@ -367,88 +566,6 @@ void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent) emit closed(); } -//******************************************************************** -void XGUI_FacesPanel::activateSelection(bool toActivate) -{ - QIntList aShapeTypes; - aShapeTypes.append(TopAbs_FACE); - - if (toActivate) { - myWorkshop->activateSubShapesSelection(aShapeTypes); - } else { - myWorkshop->deactivateSubShapesSelection(); - } - if (toActivate) - activateSelectionFilters(); - else - deactivateSelectionFilters(); -} - -//******************************************************************** -QString XGUI_FacesPanel::generateName(const ModuleBase_ViewerPrsPtr& thePrs) -{ - if (!thePrs.get() || !thePrs->object().get()) - return "Undefined"; - - GeomShapePtr aContext; - ObjectPtr anObject = thePrs->object(); - ResultPtr aResult = std::dynamic_pointer_cast(anObject); - if (aResult.get()) - aContext = aResult->shape(); - else { - // TODO if there is this case - } - - QString aName = anObject->data()->name().c_str(); - if (aContext.get()) { - GeomShapePtr aSubShape(new GeomAPI_Shape()); - aSubShape->setImpl(new TopoDS_Shape(ModuleBase_Tools::getSelectedShape(thePrs))); - if (!aSubShape->isEqual(aContext)) - aName += QString("_%1").arg(GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape)); - } - return aName; -} - -//******************************************************************** -bool XGUI_FacesPanel::customizeObject(const ObjectPtr& theObject, - const AISObjectPtr& thePresentation) -{ - if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset - return false; - - if (thePresentation.get() == NULL) - return false; - - if (myItemObjects.find(theObject) == myItemObjects.end()) // not found - return false; - - // if the object is displayed, the hidden faces are collected and set to the presentation - bool isModified = false; - NCollection_List aHiddenSubShapes; - for (QMap::const_iterator anIt = myItems.begin(); - anIt != myItems.end(); anIt++) { - ModuleBase_ViewerPrsPtr aPrs = anIt.value(); - if (aPrs.get() && aPrs->object() != theObject) - continue; - TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs); - if (!aHiddenSubShapes.Contains(aShape)) - aHiddenSubShapes.Append(aShape); - } - - Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast( - thePresentation->impl()); - if (aResultPrs.IsNull()) - return false; - - isModified = aResultPrs->setSubShapeHidden(aHiddenSubShapes); - - double aTransparency = !useTransparency() ? 1 - : Config_PropManager::real("Visualization", "hidden_face_transparency"); - isModified = aResultPrs->setHiddenSubShapeTransparency(aTransparency) || isModified; - - return isModified; -} - //******************************************************************** void XGUI_FacesPanel::onDeleteItem() { @@ -458,18 +575,22 @@ void XGUI_FacesPanel::onDeleteItem() //******************************************************************** void XGUI_FacesPanel::onTransparencyChanged() { - bool isModified = false; - if (useTransparency()) { - std::set > aHiddenObjects = myHiddenObjects; - isModified = displayHiddenObjects(aHiddenObjects, false); + std::map anObjectToShapes; + std::map anObjectToPrs; + QMap >::const_iterator aIt; + for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) { + getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs); } - else - isModified = hideEmptyObjects(); - - isModified = redisplayObjects(myItemObjects, false) || isModified; - if (isModified) - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + double aTransp = Config_PropManager::real("Visualization", "hidden_face_transparency"); + std::set aObjects; + std::map::const_iterator aPrsIt; + for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) { + aObjects.insert(aPrsIt->first); + aPrsIt->second->setHiddenSubShapeTransparency(useTransparency()? aTransp : 1); + } + if (redisplayObjects(aObjects)) + flushRedisplay(); } //******************************************************************** @@ -478,3 +599,14 @@ 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 = myWorkshop->objectBrowser(); + if (anObjectBrowser) + anObjectBrowser->updateAllIndexes(); + myWorkshop->viewer()->update(); +}