mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Show category text in legend
Create empty string for standard legends. Show category text if present.
This commit is contained in:
parent
f70d2c4949
commit
3208abad19
@ -164,10 +164,9 @@ void RimColorLegendCollection::createStandardColorLegends()
|
||||
for ( size_t i = 0; i < colorArray.size(); i++ )
|
||||
{
|
||||
cvf::Color3f color3f( colorArray[i] );
|
||||
QColor colorQ( colorArray[i].r(), colorArray[i].g(), colorArray[i].b() );
|
||||
|
||||
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
|
||||
colorLegendItem->setValues( colorQ.name(), static_cast<int>( i ), color3f );
|
||||
colorLegendItem->setValues( "", static_cast<int>( i ), color3f );
|
||||
|
||||
colorLegend->appendColorLegendItem( colorLegendItem );
|
||||
colorLegend->setReadOnly( true );
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "Rim3dWellLogCurve.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
@ -2128,7 +2129,21 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
|
||||
}
|
||||
}
|
||||
else
|
||||
valueTxt = QString( "%1" ).arg( value );
|
||||
{
|
||||
auto items = legendConfigToUpdate->colorLegend()->colorLegendItems();
|
||||
auto it = std::find_if( items.begin(),
|
||||
items.end(),
|
||||
[value]( const RimColorLegendItem* const item )
|
||||
{ return item->categoryValue() == value; } );
|
||||
if ( it != items.end() && !( *it )->categoryName().isEmpty() )
|
||||
{
|
||||
valueTxt = QString( "%1 (%2)" ).arg( ( *it )->categoryName() ).arg( value );
|
||||
}
|
||||
else
|
||||
{
|
||||
valueTxt = QString( "%1" ).arg( value );
|
||||
}
|
||||
}
|
||||
|
||||
categoryVector.push_back( std::make_tuple( valueTxt, value, categoryColor ) );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user