mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5882 Add color gradient as icon for legend palettes.
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
#include "RimColorLegendItem.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimColorLegend, "ColorLegend" );
|
||||
@@ -119,3 +122,20 @@ cvf::Color3ubArray RimColorLegend::colorArray() const
|
||||
}
|
||||
return colorArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::IconProvider RimColorLegend::paletteIconProvider() const
|
||||
{
|
||||
std::vector<QString> colorNames;
|
||||
std::vector<RimColorLegendItem*> legendItems = colorLegendItems();
|
||||
for ( auto legendItem : legendItems )
|
||||
{
|
||||
QColor color = RiaColorTools::toQColor( legendItem->color() );
|
||||
colorNames.push_back( color.name() );
|
||||
}
|
||||
caf::IconProvider iconProvider;
|
||||
iconProvider.setBackgroundColorGradient( colorNames );
|
||||
return iconProvider;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
cvf::Color3ubArray colorArray() const;
|
||||
|
||||
caf::IconProvider paletteIconProvider() const;
|
||||
|
||||
public:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
|
||||
@@ -1091,7 +1091,10 @@ QList<caf::PdmOptionItemInfo>
|
||||
|
||||
for ( RimColorLegend* colorLegend : colorLegends )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( colorLegend->colorLegendName(), colorLegend ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( colorLegend->colorLegendName(),
|
||||
colorLegend,
|
||||
false,
|
||||
colorLegend->paletteIconProvider() ) );
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_rangeMode )
|
||||
|
||||
Reference in New Issue
Block a user