mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fix bug in color mapping when changing mapping mode for Tables
* Fix color mapping and ticks in table legend - For Summary and WellConnectivity - Add range types: automatic and user defined - Remove category from mapping type - Add closest to zero for correct logarithmic scale --------- Co-authored-by: Magne Sjaastad <magne.sjaastad@ceetronsolutions.com>
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimTools.h"
|
||||
@@ -43,6 +42,20 @@
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSummaryTable, "RimSummaryTable" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void AppEnum<RimSummaryTable::RangeType>::setUp()
|
||||
{
|
||||
addItem( RimSummaryTable::RangeType::AUTOMATIC, "AUTOMATIC", "Min and Max in Table" );
|
||||
addItem( RimSummaryTable::RangeType::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range" );
|
||||
setDefault( RimSummaryTable::RangeType::AUTOMATIC );
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -87,6 +100,9 @@ RimSummaryTable::RimSummaryTable()
|
||||
m_legendConfig->setAutomaticRanges( 0.0, 100.0, 0.0, 100.0 );
|
||||
m_legendConfig->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::HEAT_MAP ) );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_mappingType, "MappingType", "Mapping Type" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_rangeType, "RangeType", "Range Type" );
|
||||
|
||||
setLegendsVisible( true );
|
||||
setAsPlotMdiWindow();
|
||||
setShowWindow( true );
|
||||
@@ -250,6 +266,23 @@ void RimSummaryTable::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
{
|
||||
m_matrixPlotWidget->setValueFontSize( valueLabelFontSize() );
|
||||
}
|
||||
else if ( changedField == &m_rangeType && m_legendConfig )
|
||||
{
|
||||
auto rangeMode = m_rangeType == RangeType::AUTOMATIC ? RimLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS
|
||||
: RimLegendConfig::RangeModeType::USER_DEFINED;
|
||||
m_legendConfig->setRangeMode( rangeMode );
|
||||
m_legendConfig->updateTickCountAndUserDefinedRange();
|
||||
onLoadDataAndUpdate();
|
||||
}
|
||||
else if ( changedField == &m_mappingType && m_legendConfig )
|
||||
{
|
||||
m_legendConfig->setMappingMode( m_mappingType() );
|
||||
if ( m_rangeType == RangeType::AUTOMATIC )
|
||||
{
|
||||
m_legendConfig->updateTickCountAndUserDefinedRange();
|
||||
}
|
||||
onLoadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -279,7 +312,10 @@ void RimSummaryTable::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
|
||||
|
||||
caf::PdmUiGroup* tableSettingsGroup = uiOrdering.addNewGroup( "Table Settings" );
|
||||
tableSettingsGroup->add( &m_showValueLabels );
|
||||
m_legendConfig->uiOrdering( "FlagColorsAndMappingModeOnly", *tableSettingsGroup );
|
||||
m_legendConfig->uiOrdering( "FlagAndColorsOnly", *tableSettingsGroup );
|
||||
tableSettingsGroup->add( &m_mappingType );
|
||||
tableSettingsGroup->add( &m_rangeType );
|
||||
m_legendConfig->uiOrdering( "UserDefinedMinMaxOnly", *tableSettingsGroup );
|
||||
|
||||
caf::PdmUiGroup* fontGroup = uiOrdering.addNewGroup( "Fonts" );
|
||||
fontGroup->setCollapsedByDefault();
|
||||
@@ -346,6 +382,17 @@ QList<caf::PdmOptionItemInfo> RimSummaryTable::calculateValueOptions( const caf:
|
||||
{
|
||||
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() );
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_mappingType )
|
||||
{
|
||||
std::vector<RimRegularLegendConfig::MappingType> mappingTypes = { RimRegularLegendConfig::MappingType::LINEAR_DISCRETE,
|
||||
RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS,
|
||||
RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS,
|
||||
RimRegularLegendConfig::MappingType::LOG10_DISCRETE };
|
||||
for ( const auto mappingType : mappingTypes )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( caf::AppEnum<RimRegularLegendConfig::MappingType>::uiText( mappingType ), mappingType ) );
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -382,16 +429,27 @@ void RimSummaryTable::onLoadDataAndUpdate()
|
||||
// Clear matrix plot
|
||||
m_matrixPlotWidget->clearPlotData();
|
||||
m_matrixPlotWidget->setColumnHeaders( timeStepStrings );
|
||||
|
||||
double posClosestToZeroValue = std::numeric_limits<double>::max();
|
||||
double negClosestToZeroValue = std::numeric_limits<double>::lowest();
|
||||
for ( const auto& vectorData : m_tableData.vectorDataCollection )
|
||||
{
|
||||
if ( excludedRows.contains( vectorData.category ) ) continue;
|
||||
|
||||
// Find positive and negative value closest to zero
|
||||
for ( const auto& value : vectorData.values )
|
||||
{
|
||||
if ( value > 0.0 && value < posClosestToZeroValue ) posClosestToZeroValue = value;
|
||||
if ( value < 0.0 && value > negClosestToZeroValue ) negClosestToZeroValue = value;
|
||||
}
|
||||
|
||||
m_matrixPlotWidget->setRowValues( vectorData.category, vectorData.values );
|
||||
}
|
||||
|
||||
if ( m_legendConfig )
|
||||
{
|
||||
m_legendConfig->setAutomaticRanges( m_tableData.minValue, m_tableData.maxValue, 0.0, 0.0 );
|
||||
m_legendConfig->setClosestToZeroValues( posClosestToZeroValue, negClosestToZeroValue, posClosestToZeroValue, negClosestToZeroValue );
|
||||
}
|
||||
|
||||
// Set titles and font sizes
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryTableTools.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
@@ -45,6 +46,13 @@ class RimSummaryTable : public RimPlotWindow
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum class RangeType
|
||||
{
|
||||
AUTOMATIC,
|
||||
USER_DEFINED
|
||||
};
|
||||
|
||||
public:
|
||||
RimSummaryTable();
|
||||
~RimSummaryTable() override;
|
||||
@@ -120,6 +128,9 @@ private:
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_valueLabelFontSize;
|
||||
caf::PdmField<bool> m_showValueLabels;
|
||||
|
||||
caf::PdmField<RimRegularLegendConfig::MappingEnum> m_mappingType;
|
||||
caf::PdmField<caf::AppEnum<RangeType>> m_rangeType;
|
||||
|
||||
private:
|
||||
using VectorData = RimSummaryTableTools::VectorData;
|
||||
using TableData = RimSummaryTableTools::TableData;
|
||||
|
||||
Reference in New Issue
Block a user