#12179 Avoid showing unused values in category legend

This commit is contained in:
Magne Sjaastad
2025-02-26 15:21:12 +01:00
committed by GitHub
parent fe417cf40a
commit d05de77748
9 changed files with 61 additions and 40 deletions
@@ -1208,7 +1208,11 @@ void RimGridCrossPlotDataSet::updateLegendRange()
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() );
if ( eclipseCase )
{
m_groupingProperty->updateRangesForEmbeddedLegends( m_timeStep() );
auto eclipseView = dynamic_cast<RimEclipseView*>( m_cellFilterView() );
m_groupingProperty->updateRangesForExplicitLegends( m_groupingProperty->legendConfig(),
m_groupingProperty->ternaryLegendConfig(),
m_timeStep(),
eclipseView );
}
}
if ( !m_legendOverlayFrame )
@@ -300,14 +300,6 @@ RimEclipseView* RimEclipseCellColors::reservoirView()
return m_reservoirView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCellColors::updateRangesForEmbeddedLegends( int currentTimeStep )
{
updateRangesForExplicitLegends( legendConfig(), m_ternaryLegendConfig(), currentTimeStep );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -49,7 +49,6 @@ public:
void setReservoirView( RimEclipseView* ownerReservoirView );
RimEclipseView* reservoirView();
void updateRangesForEmbeddedLegends( int timestep );
RimRegularLegendConfig* legendConfig();
RimTernaryLegendConfig* ternaryLegendConfig();
@@ -1682,7 +1682,8 @@ void RimEclipseResultDefinition::setTernaryEnabled( bool enabled )
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfigToUpdate,
RimTernaryLegendConfig* ternaryLegendConfigToUpdate,
int currentTimeStep )
int currentTimeStep,
RimEclipseView* cellVisibilityView )
{
if ( hasResult() )
@@ -1696,7 +1697,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
}
else
{
RimEclipseResultDefinitionTools::updateCellResultLegend( this, legendConfigToUpdate, currentTimeStep );
RimEclipseResultDefinitionTools::updateCellResultLegend( this, legendConfigToUpdate, currentTimeStep, cellVisibilityView );
}
}
@@ -1706,6 +1707,17 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig,
int currentTimeStep )
{
RimEclipseView* cellVisibilityView = nullptr;
updateRangesForExplicitLegends( legendConfig, ternaryLegendConfig, currentTimeStep, cellVisibilityView );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -137,6 +137,11 @@ public:
void setTernaryEnabled( bool enabled );
void updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfig, RimTernaryLegendConfig* ternaryLegendConfig, int currentTimeStep );
void updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig,
int currentTimeStep,
RimEclipseView* viewUsedForCategoryValues );
void updateLegendTitle( RimRegularLegendConfig* legendConfig, const QString& legendHeading );
bool showOnlyVisibleCategoriesInLegend() const;
@@ -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() );
}
}
@@ -52,7 +52,10 @@ void updateLegendForFlowDiagnostics( const RimEclipseResultDefinition* resultDef
RimRegularLegendConfig* legendConfigToUpdate,
int timeStep );
void updateCellResultLegend( const RimEclipseResultDefinition* resultDefinition, RimRegularLegendConfig* legendConfigToUpdate, int timeStep );
void updateCellResultLegend( const RimEclipseResultDefinition* resultDefinition,
RimRegularLegendConfig* legendConfigToUpdate,
int timeStep,
RimEclipseView* sourceCellVisibilityView );
QList<caf::PdmOptionItemInfo> calcOptionsForVariableUiFieldStandard( RiaDefines::ResultCatType resultCatType,
const RigCaseCellResultsData* results,
@@ -97,33 +97,35 @@ std::set<size_t> RigVisibleCategoriesCalculator::visibleAllanCategories( RimEcli
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<int> RigVisibleCategoriesCalculator::visibleCategories( RimEclipseView* eclView )
std::set<int> RigVisibleCategoriesCalculator::visibleCategories( RimEclipseView* cellVisibilityView,
const RimEclipseResultDefinition* categoryResult )
{
if ( !cellVisibilityView || !categoryResult ) return {};
std::set<int> visibleCategoryValues;
{
// Visible eclipse grid cells
RimEclipseResultDefinition* resDef = eclView->cellResult();
RigEclipseNativeVisibleCellsStatCalc calc( categoryResult->currentGridCellResults(),
categoryResult->eclipseResultAddress(),
cellVisibilityView->currentTotalCellVisibility().p() );
RigEclipseNativeVisibleCellsStatCalc calc( resDef->currentGridCellResults(),
resDef->eclipseResultAddress(),
eclView->currentTotalCellVisibility().p() );
calc.uniqueValues( eclView->currentTimeStep(), visibleCategoryValues );
calc.uniqueValues( cellVisibilityView->currentTimeStep(), visibleCategoryValues );
}
{
// Visible cells in faults and intersections
std::set<size_t> visibleReservoirCells;
RigVisibleCategoriesCalculator::appendVisibleFaultCells( eclView, visibleReservoirCells );
RigVisibleCategoriesCalculator::appendVisibleIntersectionCells( eclView, visibleReservoirCells );
RimEclipseResultDefinition* resDef = eclView->cellResult();
RigVisibleCategoriesCalculator::appendVisibleFaultCells( cellVisibilityView, visibleReservoirCells );
RigVisibleCategoriesCalculator::appendVisibleIntersectionCells( cellVisibilityView, visibleReservoirCells );
cvf::ref<RigResultAccessor> resultAccessor =
RigResultAccessorFactory::createFromResultDefinition( eclView->eclipseCase()->eclipseCaseData(), 0, eclView->currentTimeStep(), resDef );
RigResultAccessorFactory::createFromResultDefinition( cellVisibilityView->eclipseCase()->eclipseCaseData(),
0,
cellVisibilityView->currentTimeStep(),
categoryResult );
if ( resultAccessor.notNull() )
{
@@ -173,6 +175,8 @@ std::set<size_t> RigVisibleCategoriesCalculator::visibleNncConnectionIndices( Ri
//--------------------------------------------------------------------------------------------------
void RigVisibleCategoriesCalculator::appendVisibleFaultCells( RimEclipseView* eclView, std::set<size_t>& visibleCells )
{
if ( eclView->faultCollection()->shouldApplyCellFiltersToFaults() ) return;
if ( eclView->faultCollection() && eclView->faultCollection()->isActive() && !eclView->faultResultSettings()->showCustomFaultResult() )
{
for ( const auto& f : eclView->faultCollection()->faults() )
@@ -24,6 +24,7 @@
class RimEclipseView;
class RigFlowDiagResults;
class RigFlowDiagResultAddress;
class RimEclipseResultDefinition;
//==================================================================================================
///
@@ -37,7 +38,7 @@ public:
size_t timeStepIndex );
static std::set<size_t> visibleAllanCategories( RimEclipseView* eclView );
static std::set<int> visibleCategories( RimEclipseView* eclView );
static std::set<int> visibleCategories( RimEclipseView* cellVisibilityView, const RimEclipseResultDefinition* categoryResult );
private:
static std::set<size_t> visibleNncConnectionIndices( RimEclipseView* eclView );