mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add result type and create and use custom legend if possible
* Update submodule * Use postfix functions and add custom color legend * Add type to RigEclipseResultAddress Read types from ROFF and create default legend based on type or custom created legend. * Use caseId to connect legend configuration to result in a case
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "RimColorLegendCollection.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaFractureDefines.h"
|
||||
|
||||
#include "RimColorLegend.h"
|
||||
@@ -76,9 +77,59 @@ bool RimColorLegendCollection::isStandardColorLegend( RimColorLegend* legend )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::deleteCustomColorLegends()
|
||||
{
|
||||
m_defaultColorLegendNameForResult.clear();
|
||||
m_customColorLegends.deleteChildren();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegend* RimColorLegendCollection::createColorLegend( const QString& name, const std::vector<std::pair<int, QString>>& valuesAndNames )
|
||||
{
|
||||
auto colors = RiaColorTables::categoryPaletteColors().color3ubArray();
|
||||
|
||||
auto colorLegend = new RimColorLegend();
|
||||
colorLegend->setColorLegendName( name );
|
||||
int colorIndex = 0;
|
||||
for ( const auto& [value, name] : valuesAndNames )
|
||||
{
|
||||
auto item = new RimColorLegendItem();
|
||||
auto color = colors[colorIndex++ % colors.size()];
|
||||
cvf::Color3f color3f( color );
|
||||
|
||||
item->setValues( name, value, color3f );
|
||||
|
||||
colorLegend->appendColorLegendItem( item );
|
||||
}
|
||||
|
||||
appendCustomColorLegend( colorLegend );
|
||||
|
||||
return colorLegend;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::deleteColorLegend( int caseId, const QString& resultName )
|
||||
{
|
||||
m_defaultColorLegendNameForResult.erase( createLookupKey( caseId, resultName ) );
|
||||
|
||||
auto legend = findDefaultLegendForResult( caseId, resultName );
|
||||
if ( !legend ) return;
|
||||
|
||||
m_customColorLegends.removeChild( legend );
|
||||
delete legend;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimColorLegendCollection::setDefaultColorLegendForResult( int caseId, const QString& resultName, RimColorLegend* colorLegend )
|
||||
{
|
||||
auto key = createLookupKey( caseId, resultName );
|
||||
m_defaultColorLegendNameForResult[key] = colorLegend;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -170,6 +221,22 @@ RimColorLegend* RimColorLegendCollection::findByName( const QString& name ) cons
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimColorLegend* RimColorLegendCollection::findDefaultLegendForResult( int caseId, const QString& resultName ) const
|
||||
{
|
||||
auto key = createLookupKey( caseId, resultName );
|
||||
|
||||
auto it = m_defaultColorLegendNameForResult.find( key );
|
||||
if ( it != m_defaultColorLegendNameForResult.end() )
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -246,6 +313,14 @@ RimColorLegend* RimColorLegendCollection::createRockTypeColorLegend() const
|
||||
return colorLegend;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimColorLegendCollection::createLookupKey( int caseId, const QString& resultName )
|
||||
{
|
||||
return QString( "%1 (case %2)" ).arg( resultName ).arg( caseId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user