#13806 Python: Add color legend scripting API

Expose RimColorLegendCollection and RimColorLegend to Python via
CAF_PDM_OBJECT_METHOD entries that let callers create a legend, append
category items with a hex-string color, bind a legend to a (case,
resultName) pair and delete that binding.

Scriptable fields on RimColorLegend and RimColorLegendItem make the
created objects inspectable from Python.

The (case, resultName) binding interface in RimColorLegendCollection,
RimRegularLegendConfig and RimEclipseCellColors now takes a const RimCase*
instead of a case id, matching the caller patterns and avoiding ambiguity
when multiple cases share an id domain.
This commit is contained in:
Magne Sjaastad committed 2026-04-20 18:55:36 +02:00
1 parent 75c1cedaec
commit cf62f07224
13 files changed
+323 -39

No files matched your search

@@ -1157,7 +1157,10 @@ int RimRegularLegendConfig::significantDigitsInData() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::setDefaultConfigForResultName( int caseId, const QString& resultName, bool useDiscreteLogLevels, bool isCategoryResult )
void RimRegularLegendConfig::setDefaultConfigForResultName( const RimCase* rimCase,
const QString& resultName,
bool useDiscreteLogLevels,
bool isCategoryResult )
{
bool useLog = RiaResultNames::isLogarithmicResult( resultName );
@@ -1213,7 +1216,7 @@ void RimRegularLegendConfig::setDefaultConfigForResultName( int caseId, const QS
updateTickCountAndUserDefinedRange();
RimProject* project = RimProject::current();
auto defaultLegend = project->colorLegendCollection()->findDefaultLegendForResult( caseId, resultName );
auto defaultLegend = project->colorLegendCollection()->findDefaultLegendForResult( rimCase, resultName );
if ( defaultLegend )
{
setColorLegend( defaultLegend );