mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Color Legend : Make sure there are at least two color items (#7006)
* #7004 Color Legend : Make sure there are at least two color items The interpolation methods require minimum two items
This commit is contained in:
parent
f20939ffbd
commit
9884d531bb
@ -25,6 +25,8 @@
|
||||
|
||||
#include "cafPdmFieldReorderCapability.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -94,6 +96,7 @@ void RimColorLegend::addReorderCapability()
|
||||
void RimColorLegend::appendColorLegendItem( RimColorLegendItem* colorLegendItem )
|
||||
{
|
||||
m_colorLegendItems.push_back( colorLegendItem );
|
||||
onColorLegendItemHasChanged();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -143,11 +146,18 @@ void RimColorLegend::orderChanged( const caf::SignalEmitter* emitter )
|
||||
cvf::Color3ubArray RimColorLegend::colorArray() const
|
||||
{
|
||||
std::vector<RimColorLegendItem*> legendItems = colorLegendItems();
|
||||
cvf::Color3ubArray colorArray( legendItems.size() );
|
||||
|
||||
// The interpolation algorithm requires minimum two levels
|
||||
size_t colorCount = std::max( size_t( 2 ), legendItems.size() );
|
||||
|
||||
cvf::Color3ubArray colorArray( colorCount );
|
||||
colorArray.setAll( cvf::Color3ub::GRAY );
|
||||
|
||||
for ( size_t i = 0; i < legendItems.size(); i++ )
|
||||
{
|
||||
colorArray.set( i, cvf::Color3ub( legendItems[i]->color() ) );
|
||||
}
|
||||
|
||||
return colorArray;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user