#12179 Avoid showing unused values in category legend

This commit is contained in:
Magne Sjaastad authored and GitHub committed 2025-02-26 15:21:12 +01:00
1 parent fe417cf40a
commit d05de77748
9 files changed
+61 -40

No files matched your search

@@ -42,10 +42,12 @@
#include "RimSimWellInViewCollection.h"
#include "RimTernaryLegendConfig.h"
#include "cafCategoryMapper.h"
#include "cvfColor3.h"
#include <QString>
#include "cafCategoryMapper.h"
#include "cvfColor3.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -491,7 +493,8 @@ void RimEclipseResultDefinitionTools::updateLegendForFlowDiagnostics( const RimE
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinitionTools::updateCellResultLegend( const RimEclipseResultDefinition* resultDefinition,
RimRegularLegendConfig* legendConfigToUpdate,
int timeStep )
int timeStep,
RimEclipseView* sourceCellVisibilityView )
{
if ( !resultDefinition || !legendConfigToUpdate ) return;
@@ -638,19 +641,17 @@ void RimEclipseResultDefinitionTools::updateCellResultLegend( const RimEclipseRe
if ( resultDefinition->showOnlyVisibleCategoriesInLegend() )
{
auto eclView = resultDefinition->firstAncestorOrThisOfType<RimEclipseView>();
if ( eclView && eclView->showWindow() )
// If a predefined view is nullptr, search for an ancestor view
auto cellVisibilityView = sourceCellVisibilityView ? sourceCellVisibilityView
: resultDefinition->firstAncestorOrThisOfType<RimEclipseView>();
if ( cellVisibilityView && cellVisibilityView->showWindow() )
{
// Check if current result is cell result, and update the visible set of values
// TODO: Can be extended to the separate geometry results (separate fault result, separate
// intersection results), but this requires some refactoring
if ( eclView->cellResult() == resultDefinition )
{
std::set<int> visibleCategorySet = RigVisibleCategoriesCalculator::visibleCategories( eclView );
std::set<int> visibleCategorySet =
RigVisibleCategoriesCalculator::visibleCategories( cellVisibilityView, resultDefinition );
visibleCategoryValues.clear();
visibleCategoryValues.insert( visibleCategoryValues.begin(), visibleCategorySet.begin(), visibleCategorySet.end() );
}
// If we have a view, use the unique values defined by visible cells in this view
visibleCategoryValues.clear();
visibleCategoryValues.insert( visibleCategoryValues.begin(), visibleCategorySet.begin(), visibleCategorySet.end() );
}
}