mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
#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.
This commit is contained in:
1 parent
ee28576c48
commit
77c32a3fa5
17 files changed
+711
-170
No files matched your search
@@ -111,37 +111,57 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QS
|
||||
}
|
||||
}
|
||||
|
||||
const QString absSnapshotPath = snapshotPath.absolutePath();
|
||||
RiaLogging::info( std::format( "Exporting snapshot of all views to {}", snapshotFolderName ) );
|
||||
|
||||
for ( auto riv : viewsForSnapshot )
|
||||
{
|
||||
RiuViewer* viewer = riv->viewer();
|
||||
if ( !viewer ) continue;
|
||||
if ( !viewer->ownerViewWindow() ) continue;
|
||||
|
||||
RiaApplication::instance()->setActiveReservoirView( riv );
|
||||
|
||||
Riu3DMainWindowTools::setActiveViewer( viewer->ownerViewWindow()->dockWindowName() );
|
||||
|
||||
RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate();
|
||||
RiaPlotWindowRedrawScheduler::instance()->clearAllScheduledUpdates();
|
||||
|
||||
riv->createDisplayModelAndRedraw();
|
||||
viewer->repaint();
|
||||
|
||||
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName( riv );
|
||||
if ( !prefix.isEmpty() )
|
||||
{
|
||||
fileName = prefix + fileName;
|
||||
}
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName( absSnapshotPath, fileName, ".png" );
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, riv, width, height );
|
||||
exportSnapshotOfView( riv, snapshotPath.absolutePath(), width, height, prefix );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Export a snapshot of a single view into the given folder. The folder is created if it does not exist.
|
||||
/// <= 0 for width and height means to use the existing view size
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllViewsToFileFeature::exportSnapshotOfView( Rim3dView* riv,
|
||||
const QString& snapshotFolderName,
|
||||
int width,
|
||||
int height,
|
||||
const QString& prefix )
|
||||
{
|
||||
if ( !riv ) return;
|
||||
|
||||
RiuViewer* viewer = riv->viewer();
|
||||
if ( !viewer ) return;
|
||||
if ( !viewer->ownerViewWindow() ) return;
|
||||
|
||||
QDir snapshotPath( snapshotFolderName );
|
||||
if ( !snapshotPath.exists() )
|
||||
{
|
||||
if ( !snapshotPath.mkpath( "." ) ) return;
|
||||
}
|
||||
|
||||
RiaApplication::instance()->setActiveReservoirView( riv );
|
||||
|
||||
Riu3DMainWindowTools::setActiveViewer( viewer->ownerViewWindow()->dockWindowName() );
|
||||
|
||||
RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate();
|
||||
RiaPlotWindowRedrawScheduler::instance()->clearAllScheduledUpdates();
|
||||
|
||||
riv->createDisplayModelAndRedraw();
|
||||
viewer->repaint();
|
||||
|
||||
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName( riv );
|
||||
if ( !prefix.isEmpty() )
|
||||
{
|
||||
fileName = prefix + fileName;
|
||||
}
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName( snapshotPath.absolutePath(), fileName, ".png" );
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, riv, width, height );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user