#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

@@ -19,6 +19,9 @@
#include "RimColorLegendItem.h"
#include "RimColorLegend.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapabilityCvfColor3.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiSliderEditor.h"
#include "cvfColor3.h"
@@ -33,15 +36,15 @@ CAF_PDM_SOURCE_INIT( RimColorLegendItem, "ColorLegendItem" );
//--------------------------------------------------------------------------------------------------
RimColorLegendItem::RimColorLegendItem()
{
CAF_PDM_InitObject( "ColorLegendItem" );
CAF_PDM_InitScriptableObject( "ColorLegendItem" );
CAF_PDM_InitFieldNoDefault( &m_color, "Color", "Color" );
CAF_PDM_InitScriptableFieldNoDefault( &m_color, "Color", "Color" );
m_color = cvf::Color3f( cvf::Color3::ColorIdent::BLACK );
CAF_PDM_InitField( &m_categoryValue, "CategoryValue", 0, "Category Number" );
CAF_PDM_InitScriptableField( &m_categoryValue, "CategoryValue", 0, "Category Number" );
m_categoryValue.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_categoryName, "CategoryName", QString( "" ), "Category Name" );
CAF_PDM_InitScriptableField( &m_categoryName, "CategoryName", QString( "" ), "Category Name" );
CAF_PDM_InitFieldNoDefault( &m_nameProxy, "NameProxy", "Name Proxy" );
m_nameProxy.registerGetMethod( this, &RimColorLegendItem::itemName );