Files
ResInsight/GrpcInterface/Python/rips/plot.py
T
Kristian Bendiksen 77c32a3fa5 #14772 Python: Add snapshot export object methods and forward exportSnapshots to them
- Add RimViewWindow_exportSnapshot on RimViewWindow (3D views and
  plots) with explicit ExportFolder, Prefix, Width, Height and
  FileFormat parameters. Generated as ViewWindow.export_snapshot().
- Add RimProject_exportSnapshots for exporting all views and/or plots
  with a ContentType parameter. Generated as Project.export_snapshots().
- Add RiaDefines::SnapshotFileFormat and SnapshotContentType enums,
  registered as Python StrEnums.
- Extract single-item exportSnapshotOfView()/exportSnapshotOfPlot()
  from the RicSnapshotAll*ToFileFeature loops so the object methods
  and the legacy loops share the implementation.
- RicfExportSnapshots resolves the export folder from the command file
  executor and forwards to the object methods.

Python: the hand-written ViewWindow.export_snapshot() wrapper is
removed (generated method is compatible). PlotWindow.export_snapshot()
and Project.export_snapshots() keep their legacy argument names
(file_prefix, output_format, snapshot_type, plot_format) as deprecated
aliases. Case.export_snapshots_of_all_views() is deprecated in favor
of View.export_snapshot().

Also fix Case.views(), which compared the view id to the case id and
therefore never returned any views.
2026-09-22 14:19:23 +02:00

63 lines
1.8 KiB
Python

"""
ResInsight 2d plot module
"""
import warnings
from .pdmobject import add_method
from .resinsight_classes import (
PlotWindow as PlotWindow,
Plot as Plot,
SnapshotFileFormat,
)
@add_method(PlotWindow)
def export_snapshot(
self,
export_folder="",
file_prefix="",
output_format="PNG",
width=-1,
height=-1,
prefix=None,
file_format=None,
):
"""Export snapshot for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the 'snapshots' folder next to the project file.
file_prefix (str): Deprecated, use prefix. Exported file name prefix
output_format(str): Deprecated, use file_format. Enum string. Can be 'PNG' or 'PDF'.
width (int): The width of the exported snapshot. By default will use the existing size.
height (int): The height of the exported snapshot. By default will use the existing size.
prefix (str): Exported file name prefix
file_format (SnapshotFileFormat): 'PNG' or 'PDF'
"""
if file_prefix:
warnings.warn(
"PlotWindow.export_snapshot(file_prefix=...) is deprecated, use prefix=...",
DeprecationWarning,
stacklevel=3,
)
if output_format != "PNG":
warnings.warn(
"PlotWindow.export_snapshot(output_format=...) is deprecated, use file_format=...",
DeprecationWarning,
stacklevel=3,
)
if prefix is None:
prefix = file_prefix
if file_format is None:
file_format = SnapshotFileFormat(output_format)
self._call_pdm_method_void(
"exportSnapshot",
export_folder=export_folder,
prefix=prefix,
width=width,
height=height,
file_format=file_format,
)