Make RimMultiPlot column/row count scriptable via gRPC

* Make RimMultiPlot column/row count scriptable via gRPC
* Add pytest for scriptable multi-plot layout
This commit is contained in:
Håkon Hægland authored and GitHub committed 2026-05-26 18:49:56 +02:00
1 parent e93607d1d7
commit be3621a66d
3 files changed
+60 -5

No files matched your search

@@ -61,10 +61,8 @@ RimMultiPlot::RimMultiPlot()
reorderability->orderChanged.connect( this, &RimMultiPlot::onPlotsReordered );
RiaPreferencesSummary* sumPrefs = RiaPreferencesSummary::current();
CAF_PDM_InitFieldNoDefault( &m_columnCount, "NumberOfColumns", "Number of Columns" );
m_columnCount = sumPrefs->defaultMultiPlotColumnCount();
CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page" );
m_rowsPerPage = sumPrefs->defaultMultiPlotRowCount();
CAF_PDM_InitScriptableField( &m_columnCount, "NumberOfColumns", ColumnCountEnum( sumPrefs->defaultMultiPlotColumnCount() ), "Number of Columns" );
CAF_PDM_InitScriptableField( &m_rowsPerPage, "RowsPerPage", RowCountEnum( sumPrefs->defaultMultiPlotRowCount() ), "Rows per Page" );
CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", true, "Show Sub Plot Titles" );
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count" );
@@ -61,6 +61,7 @@
#include "RiuSummaryMultiPlotBook.h"
#include "RiuSummaryVectorSelectionUi.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiButton.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiComboBoxEditor.h"
@@ -113,7 +114,7 @@ void RimSummaryMultiPlot::clearLayoutInfo()
//--------------------------------------------------------------------------------------------------
RimSummaryMultiPlot::RimSummaryMultiPlot()
{
CAF_PDM_InitObject( "Multi Summary Plot", ":/SummaryPlotLight16x16.png" );
CAF_PDM_InitScriptableObject( "Multi Summary Plot", ":/SummaryPlotLight16x16.png" );
setDeletable( true );
CAF_PDM_InitField( &m_autoPlotTitle, "AutoPlotTitle", true, "Auto Plot Title" );
@@ -0,0 +1,56 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
import rips
import dataroot
def _create_summary_multi_plot(rips_instance):
"""Import a summary case and create one summary plot, returning the
newly created RimSummaryMultiPlot wrapper."""
case_path = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC"
summary_case = rips_instance.project.import_summary_case(case_path)
assert summary_case.id == 1
collection = rips_instance.project.descendants(rips.SummaryPlotCollection)[0]
collection.new_summary_plot(summary_cases=[summary_case], address="FOPT")
multi_plots = rips_instance.project.descendants(rips.MultiSummaryPlot)
assert len(multi_plots) >= 1
return multi_plots[-1]
def test_summary_multi_plot_layout_is_scriptable(rips_instance, initialize_test):
"""The column/row count fields on a summary multi-plot are exposed over
gRPC and round-trip through update()."""
multi_plot = _create_summary_multi_plot(rips_instance)
# Fields are readable (default seeded from the Multi Plot Defaults
# preference; the exact default is environment dependent).
assert multi_plot.number_of_columns in (1, 2, 3, 4)
assert multi_plot.rows_per_page in (1, 2, 3, 4)
# Set, update, and verify the new values are persisted server-side.
multi_plot.number_of_columns = 3
multi_plot.rows_per_page = 2
multi_plot.update()
refetched = rips_instance.project.descendants(rips.MultiSummaryPlot)[-1]
assert refetched.number_of_columns == 3
assert refetched.rows_per_page == 2
def test_summary_multi_plot_layout_override(rips_instance, initialize_test):
"""Forcing a 1x1 layout works regardless of the preference default —
this is what a headless export uses to get deterministic output."""
multi_plot = _create_summary_multi_plot(rips_instance)
multi_plot.number_of_columns = 1
multi_plot.rows_per_page = 1
multi_plot.update()
refetched = rips_instance.project.descendants(rips.MultiSummaryPlot)[-1]
assert refetched.number_of_columns == 1
assert refetched.rows_per_page == 1