Skip to content

Make RimMultiPlot column/row count scriptable via gRPC#14043

Merged
magnesj merged 3 commits into
OPM:devfrom
hakonhagland:feature/scriptable-multiplot-layout
May 26, 2026
Merged

Make RimMultiPlot column/row count scriptable via gRPC#14043
magnesj merged 3 commits into
OPM:devfrom
hakonhagland:feature/scriptable-multiplot-layout

Conversation

@hakonhagland
Copy link
Copy Markdown
Contributor

Exposes the multi-plot grid layout (number_of_columns / rows_per_page) to the rips Python client so scripts can set it per multi-plot, instead of silently inheriting the user's interactive preference.

Motivation: RimMultiPlot::m_columnCount and m_rowsPerPage are initialized from RiaPreferencesSummary — the user's interactive Edit → Preferences → Plotting → Multi Plot Defaults setting, backed by the on-disk preferences file that is shared between every ResInsight process on the machine. A headless, rips-driven script had no way to override them, so a preference change made in one interactive session silently altered the output of unrelated scripts. The fields did not surface in the generated Python bindings at all, because they were declared with CAF_PDM_InitFieldNoDefault and the containing class RimSummaryMultiPlot was registered with the non-scriptable CAF_PDM_InitObject.

Changes

  • RimMultiPlot.cpp — declare m_columnCount / m_rowsPerPage with CAF_PDM_InitScriptableField (seeding the default from RiaPreferencesSummary as before), instead of CAF_PDM_InitFieldNoDefault.
  • RimSummaryMultiPlot.cpp — register the class with CAF_PDM_InitScriptableObject (was CAF_PDM_InitObject) so it appears in the generated bindings, and add the missing cafPdmObjectScriptingCapability.h include.

Result

The generated rips classes now expose MultiSummaryPlot.number_of_columns / .rows_per_page as int-valued attributes that round-trip through update():

mp = ri.project.descendants(rips.MultiSummaryPlot)[-1]
mp.number_of_columns = 1
mp.rows_per_page = 1
mp.update()

This lets a headless export force a deterministic layout (e.g. 1×1) regardless of the user's interactive preference.

Scope

Only RimSummaryMultiPlot is made scriptable here; RimMultiPlot itself and RimHistogramMultiPlot keep CAF_PDM_InitObject. Coverage can be expanded in a follow-up if other multi-plot types need the same.

Notes

Test plan

  • rips exposes MultiSummaryPlot.number_of_columns / .rows_per_page; setting + update() round-trips (verified 2 → 1).
  • Headless export of a summary multi-plot honors a forced 1×1 layout regardless of the on-disk Multi Plot Defaults preference.
  • CI passes.

The `m_columnCount` and `m_rowsPerPage` fields on RimMultiPlot are
initialized from RiaPreferencesSummary (the user's interactive
"Edit -> Preferences -> Plotting -> Multi Plot Defaults" setting),
which is backed by the on-disk preferences file shared between every
ResInsight process on the machine.

There is no way for a Python script using rips to override these
fields per multi-plot, because they were declared with
CAF_PDM_InitFieldNoDefault and the containing class RimSummaryMultiPlot
was registered with the non-scriptable CAF_PDM_InitObject. The fields
therefore did not surface in the generated Python bindings, so an
interactive preference change in one session silently changed the
output of unrelated headless scripts.

Make the fields scriptable by switching to CAF_PDM_InitScriptableField,
and register RimSummaryMultiPlot itself as a scriptable class via
CAF_PDM_InitScriptableObject. Add the missing include of
cafPdmObjectScriptingCapability.h in RimSummaryMultiPlot.cpp.

After this change, the generated rips classes expose
MultiSummaryPlot.number_of_columns / .rows_per_page as int-valued
attributes that round-trip through update(). Python clients can now:

    mp = ri.project.descendants(rips.MultiSummaryPlot)[-1]
    mp.number_of_columns = 1
    mp.rows_per_page = 1
    mp.update()

to neutralize the user's interactive preference.

The change does not touch CAF_PDM_InitObject vs InitScriptableObject
for RimMultiPlot itself or for RimHistogramMultiPlot; only
RimSummaryMultiPlot is covered here. Subsequent commits can expand
coverage as needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@magnesj
Copy link
Copy Markdown
Member

magnesj commented May 26, 2026

This feature is a useful improvement. Please add unit tests as pytest for the new Python code.

Copy link
Copy Markdown
Member

@magnesj magnesj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add pytest

Covers the new scriptable RimSummaryMultiPlot fields exposed in the
previous commit:

- number_of_columns / rows_per_page are readable over gRPC and
  round-trip through update()
- forcing a 1x1 layout works regardless of the Multi Plot Defaults
  preference (the deterministic-output case headless export relies on)

Follows the existing rips test conventions (rips_instance /
initialize_test fixtures, dataroot.PATH test data, SIMPLE_SUMMARY2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@magnesj
Copy link
Copy Markdown
Member

magnesj commented May 26, 2026

This looks good. GitHub has issues running tests today, I will give a review when the tests has passed.

@magnesj
Copy link
Copy Markdown
Member

magnesj commented May 26, 2026

Can you please add a dummy commit to trigger CI? GitHub had some issues with Actions earlier today.

Empty commit to re-trigger GitHub Actions, which had issues running
earlier today (per maintainer request on the PR).
@magnesj
Copy link
Copy Markdown
Member

magnesj commented May 26, 2026

Thanks for the contribution.

Copy link
Copy Markdown
Member

@magnesj magnesj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@magnesj magnesj merged commit be3621a into OPM:dev May 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants