#5882 Add color gradient as icon for legend palettes.

This commit is contained in:
Gaute Lindkvist
2020-05-29 09:46:44 +02:00
parent 90596be3ee
commit 9130030d7b
5 changed files with 92 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -56,6 +56,8 @@ public:
cvf::Color3ubArray colorArray() const;
caf::IconProvider paletteIconProvider() const;
public:
caf::PdmFieldHandle* userDescriptionField() override;

View File

@@ -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 )