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);
return isModified;
}
+//********************************************************************
+bool XGUI_FacesPanel::hideEmptyObjects()
+{
+ bool isModified = false;
+ static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ for (QMap<int, ModuleBase_ViewerPrsPtr>::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<int, ModuleBase_ViewerPrsPtr> theItems,
//********************************************************************
void XGUI_FacesPanel::onTransparencyChanged()
{
- bool isModified = redisplayObjects(myItemObjects, false);
+ bool isModified = false;
+ if (useTransparency()) {
+ std::set<std::shared_ptr<ModelAPI_Object> > 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));
bool displayHiddenObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& 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