Merge pull request #8691 from OPM/platform-offscreen

Add example for headless plot export using Python
Fix childPtrArray issue
This commit is contained in:
Magne Sjaastad 2022-03-15 15:32:48 +01:00
parent 888243db8e
commit 8b01a7c7f9
2 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,35 @@
import sys
import os
import rips
use_platform_offscreen = True
if use_platform_offscreen:
# To use offscreen, the path to fonts must be specified in the environment variable QT_QPA_FONTDIR="C:/windows/fonts"
resinsight = rips.Instance.launch(
command_line_parameters=["-platform offscreen", "--size", 1200, 1000]
)
qpa_fontdir = os.environ["QT_QPA_FONTDIR"]
print("Environment var QT_QPA_FONTDIR : " + qpa_fontdir)
else:
resinsight = rips.Instance.find()
summary_filename = "NORNE.SMSPEC"
project = resinsight.project
summary_case = project.import_summary_case(summary_filename)
summary_plot_collection = project.descendants(rips.SummaryPlotCollection)[0]
summary_plot_collection.new_summary_plot(summary_cases=[summary_case], address="FOPR")
summary_plot_collection.new_summary_plot(
summary_cases=[summary_case], address="WOPR:A*;WOPR:B*"
)
plots = resinsight.project.plots()
for plot in plots:
plot.export_snapshot()
# plot.export_snapshot(output_format="PDF")
resinsight.exit()

View File

@ -181,9 +181,13 @@ void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject*
auto scriptability = field->template capability<caf::PdmAbstractFieldScriptingCapability>();
if ( scriptability )
{
if ( !dynamic_cast<caf::PdmValueField*>( field ) )
bool isPdmPtrArrayField = ( dynamic_cast<caf::PdmPtrArrayFieldHandle*>( field ) &&
!dynamic_cast<caf::PdmChildArrayFieldHandle*>( field ) );
if ( !isPdmPtrArrayField && !dynamic_cast<caf::PdmValueField*>( field ) )
{
// Recursive object update is not supported
// Update of child objects and child object arrays are not supported
// Update of PdmPtrArrayField is supported, used by RimcSummaryPlotCollection_newSummaryPlot
// https://github.com/OPM/ResInsight/issues/7794
continue;
}