diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index aa679285f0..3248d5a811 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -887,15 +887,9 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n mainPlotWnd->show(); mainPlotWnd->raise(); - if ( snapshotHeight > -1 && snapshotWidth > -1 ) - { - // TODO - handle snapshot view sizes - // RiuMainWindowTools::setWindowSizeOnWidgetsInViewWindows( mainPlotWnd, snapshotWidth, snapshotHeight ); - } - processEvents(); - RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( snapshotFolder ); + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( snapshotFolder, snapshotWidth, snapshotHeight ); } } @@ -905,15 +899,9 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n mainWnd->show(); mainWnd->raise(); - if ( snapshotHeight > -1 && snapshotWidth > -1 ) - { - // TODO - handle snapshot view sizes - // RiuMainWindowTools::setFixedWindowSizeFor3dViews( mainWnd, snapshotWidth, snapshotHeight ); - } - processEvents(); - RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( snapshotFolder ); + RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( snapshotFolder, snapshotWidth, snapshotHeight ); } auto mainPlotWnd = mainPlotWindow(); diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp index ff4ffd6b67..60c367b4de 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -249,18 +249,20 @@ void RiaRegressionTestRunner::runRegressionTest() QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath( generatedFolderName ); if ( regressionTestConfig.exportSnapshots3dViews ) { - setDefaultSnapshotSizeFor3dViews(); - - RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( fullPathGeneratedFolder ); + QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize(); + RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( fullPathGeneratedFolder, + defaultSize.width(), + defaultSize.height() ); QApplication::processEvents(); } if ( regressionTestConfig.exportSnapshotsPlots ) { - setDefaultSnapshotSizeForPlotWindows(); - - RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( fullPathGeneratedFolder ); + QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize(); + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( fullPathGeneratedFolder, + defaultSize.width(), + defaultSize.height() ); } uint64_t usedMemoryBeforeClose = caf::MemoryInspector::getApplicationPhysicalMemoryUsageMiB(); @@ -546,32 +548,6 @@ void RiaRegressionTestRunner::removeDirectoryWithContent( QDir& dirToDelete ) caf::Utils::removeDirectoryAndFilesRecursively( dirToDelete.absolutePath() ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaRegressionTestRunner::setDefaultSnapshotSizeFor3dViews() -{ - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if ( !mainWnd ) return; - - // TODO - fix snapshot view sizes - // QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize(); - // RiuMainWindowTools::setFixedWindowSizeFor3dViews( mainWnd, defaultSize.width(), defaultSize.height() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaRegressionTestRunner::setDefaultSnapshotSizeForPlotWindows() -{ - RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow(); - if ( !plotMainWindow ) return; - - // TODO - fix snapshot view sizes - // QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize(); - // RiuMainWindowTools::setWindowSizeOnWidgetsInViewWindows( plotMainWindow, defaultSize.width(), defaultSize.height() ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h index 6033e993b1..fd1cb2bfd7 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h @@ -45,8 +45,7 @@ public: static void updateRegressionTest( const QString& testRootPath ); - static void setDefaultSnapshotSizeFor3dViews(); - static void setDefaultSnapshotSizeForPlotWindows(); + static QSize regressionDefaultImageSize(); private: RiaRegressionTestRunner(); @@ -64,7 +63,6 @@ private: const QDir& testDir ); static void removeDirectoryWithContent( QDir& dirToDelete ); - static QSize regressionDefaultImageSize(); static QString diff2htmlHeaderText( const QString& testRootPath ); QFileInfoList subDirectoriesForTestExecution( const QDir& directory ); diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp b/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp index 0c40125a25..5b7002da9a 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.cpp @@ -69,6 +69,8 @@ RicfExportSnapshots::RicfExportSnapshots() CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id" ); CAF_PDM_InitScriptableField( &m_exportFolder, "exportFolder", QString(), "Export Folder" ); CAF_PDM_InitScriptableFieldNoDefault( &m_plotOutputFormat, "plotOutputFormat", "Output Format" ); + CAF_PDM_InitScriptableField( &m_width, "width", -1, "Width" ); + CAF_PDM_InitScriptableField( &m_height, "height", -1, "Height" ); } //-------------------------------------------------------------------------------------------------- @@ -83,13 +85,16 @@ caf::PdmScriptResponse RicfExportSnapshots::execute() return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error ); } + int width = m_width(); + int height = m_height(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); CVF_ASSERT( mainWnd ); - QByteArray curState = mainWnd->dockManager()->saveState( 0 ); - mainWnd->dockManager()->restoreState( RiuDockWidgetTools::defaultDockState( RiuDockWidgetTools::dockStateHideAll3DWindowName() ) ); + // QByteArray curState = mainWnd->dockManager()->saveState( 0 ); + // mainWnd->dockManager()->restoreState( RiuDockWidgetTools::defaultDockState( RiuDockWidgetTools::dockStateHideAll3DWindowName() ) ); - QApplication::processEvents(); + // QApplication::processEvents(); QString absolutePathToSnapshotDir = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::SNAPSHOTS ); @@ -105,21 +110,26 @@ caf::PdmScriptResponse RicfExportSnapshots::execute() { if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) { - RiaRegressionTestRunner::setDefaultSnapshotSizeFor3dViews(); - - QApplication::processEvents(); + QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize(); + width = defaultSize.width(); + height = defaultSize.height(); } - RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( absolutePathToSnapshotDir, m_prefix, m_caseId(), m_viewId() ); + RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( absolutePathToSnapshotDir, + width, + height, + m_prefix, + m_caseId(), + m_viewId() ); } if ( m_type == RicfExportSnapshots::SnapshotsType::PLOTS || m_type == RicfExportSnapshots::SnapshotsType::ALL ) { bool activateWidget = false; if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) { - RiaRegressionTestRunner::setDefaultSnapshotSizeForPlotWindows(); - - QApplication::processEvents(); + QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize(); + width = defaultSize.width(); + height = defaultSize.height(); } else { @@ -128,12 +138,18 @@ caf::PdmScriptResponse RicfExportSnapshots::execute() QString fileSuffix = ".png"; if ( m_plotOutputFormat == PlotOutputFormat::PDF ) fileSuffix = ".pdf"; - RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( absolutePathToSnapshotDir, activateWidget, m_prefix, m_viewId(), fileSuffix ); + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( absolutePathToSnapshotDir, + width, + height, + activateWidget, + m_prefix, + m_viewId(), + fileSuffix ); } QApplication::processEvents(); - mainWnd->dockManager()->restoreState( curState ); + // mainWnd->dockManager()->restoreState( curState ); return caf::PdmScriptResponse(); } diff --git a/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.h b/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.h index 52c58cfc65..4c515b459f 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.h +++ b/ApplicationLibCode/CommandFileInterface/RicfExportSnapshots.h @@ -62,4 +62,6 @@ private: caf::PdmField m_viewId; caf::PdmField m_exportFolder; caf::PdmField m_plotOutputFormat; + caf::PdmField m_width; + caf::PdmField m_height; }; diff --git a/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp b/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp index c7247f672d..2e6885db21 100644 --- a/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp +++ b/ApplicationLibCode/CommandFileInterface/RicfSetMainWindowSize.cpp @@ -19,6 +19,8 @@ #include "RicfSetMainWindowSize.h" +#include "RiaLogging.h" + #include "RiuMainWindow.h" #include "cafPdmFieldScriptingCapability.h" @@ -39,6 +41,6 @@ RicfSetMainWindowSize::RicfSetMainWindowSize() //-------------------------------------------------------------------------------------------------- caf::PdmScriptResponse RicfSetMainWindowSize::execute() { - if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->resize( m_width, m_height ); + RiaLogging::warning( "Method set_main_window_size has been obsoleted. Set size of image snapshots directly in the snapshot methods." ); return caf::PdmScriptResponse(); } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index 255d9cbb3a..86aae644fe 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -56,8 +56,8 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots() // Save images in snapshot catalog relative to project directory QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath( "snapshots" ); - bool activateWidget = true; - exportSnapshotOfPlotsIntoFolder( snapshotFolderName, activateWidget ); + // save using existing plot sizes + exportSnapshotOfPlotsIntoFolder( snapshotFolderName, -1, -1, true /* activateWidget */ ); QString text = QString( "Exported snapshots to folder : \n%1" ).arg( snapshotFolderName ); RiaLogging::info( text.toStdString() ); @@ -67,6 +67,8 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots() /// //-------------------------------------------------------------------------------------------------- void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( const QString& snapshotFolderName, + int width, + int height, bool activateWidget, const QString& prefix, int viewId, @@ -106,7 +108,7 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( const QS QString absoluteFileName = caf::Utils::constructFullFileName( absSnapshotPath, fileName, preferredFileSuffix ); - RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, viewWindow ); + RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, viewWindow, width, height ); } } } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h index 658bdac2ae..7fee4334af 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h @@ -33,6 +33,8 @@ public: static void saveAllPlots(); static void exportSnapshotOfPlotsIntoFolder( const QString& snapshotFolderName, + int width = -1, + int height = -1, bool activateWidget = false, const QString& prefix = "", int viewId = -1, diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 8eac73513e..d4a51d04f0 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -70,11 +70,14 @@ void RicSnapshotAllViewsToFileFeature::saveAllViews() //-------------------------------------------------------------------------------------------------- /// Export snapshots of a given view (or viewId == -1 for all views) for the given case (or caseId == -1 for all cases) +/// -1 for width and height means to use the existing view size //-------------------------------------------------------------------------------------------------- void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QString& snapshotFolderName, - const QString& prefix /*= ""*/, - int caseId /*= -1*/, - int viewId /*= -1*/ ) + int width, + int height, + const QString& prefix, + int caseId, + int viewId ) { RimProject* project = RimProject::current(); if ( project == nullptr ) return; @@ -136,7 +139,7 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QS QString absoluteFileName = caf::Utils::constructFullFileName( absSnapshotPath, fileName, ".png" ); - RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, riv ); + RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, riv, width, height ); if ( RimGridView* rigv = dynamic_cast( riv ) ) { diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h index c95b5d4698..e317183ab0 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h @@ -29,8 +29,12 @@ class RicSnapshotAllViewsToFileFeature : public caf::CmdFeature public: static void saveAllViews(); - static void - exportSnapshotOfViewsIntoFolder( const QString& snapshotFolderName, const QString& prefix = "", int caseId = -1, int viewId = -1 ); + static void exportSnapshotOfViewsIntoFolder( const QString& snapshotFolderName, + int width = -1, + int height = -1, + const QString& prefix = "", + int caseId = -1, + int viewId = -1 ); protected: void onActionTriggered( bool isChecked ) override; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index e1645b3491..51c130827b 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -48,7 +48,7 @@ CAF_CMD_SOURCE_INIT( RicSnapshotViewToFileFeature, "RicSnapshotViewToFileFeature //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, RimViewWindow* viewWindow ) +void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, RimViewWindow* viewWindow, int width, int height ) { auto* plotWindow = dynamic_cast( viewWindow ); if ( plotWindow && fileName.endsWith( ".pdf" ) ) @@ -57,7 +57,7 @@ void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, RimV } else if ( viewWindow ) { - QImage image = viewWindow->snapshotWindowContent(); + QImage image = viewWindow->captureSnapshot( width, height ); saveSnapshotAs( fileName, image ); } } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h index 9eb446ab59..dd72e9d137 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.h @@ -32,7 +32,7 @@ class RicSnapshotViewToFileFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void saveSnapshotAs( const QString& fileName, RimViewWindow* viewWindow ); + static void saveSnapshotAs( const QString& fileName, RimViewWindow* viewWindow, int width = -1, int height = -1 ); static void saveSnapshotAs( const QString& fileName, const QImage& image ); static void savePlotPdfReportAs( const QString& fileName, RimPlotWindow* plotWindow ); diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp index d8cdbae446..7393ed36ff 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp @@ -651,7 +651,7 @@ QImage RimMultiPlot::captureSnapshot( int width, int height ) QSize orgViewSize = m_viewer->size(); - image = captureImage( m_viewer->bookWidget(), width, height ); + image = RimViewWindow::captureSnapshot( m_viewer->bookWidget(), width, height ); m_viewer->resize( orgViewSize ); doUpdateLayout(); diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp index 6ede9a37d5..97db4c3bb9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp @@ -228,19 +228,28 @@ QImage RimViewWindow::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- QImage RimViewWindow::captureSnapshot( int width, int height ) { - return captureImage( viewWidget(), width, height ); + return captureSnapshot( viewWidget(), width, height ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QImage RimViewWindow::captureImage( QWidget* widget, int width, int height ) +QImage RimViewWindow::captureSnapshot( QWidget* widget, int width, int height ) { if ( !widget ) return QImage(); - QSize orgSize = widget->size(); + bool shouldResize = width > 0 && height > 0 && ( widget->width() != width || widget->height() != height ); - widget->setFixedSize( width, height ); + QSize orgSize = widget->size(); + if ( shouldResize ) + { + widget->setFixedSize( width, height ); + } + else + { + width = widget->width(); + height = widget->height(); + } QPixmap pix( width, height ); pix.fill( Qt::transparent ); @@ -248,10 +257,12 @@ QImage RimViewWindow::captureImage( QWidget* widget, int width, int height ) QPainter painter( &pix ); widget->render( &painter ); - // reset fixed size and restore original size - widget->setMinimumSize( 0, 0 ); - widget->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX ); - widget->resize( orgSize ); + if ( shouldResize ) + { + widget->setMinimumSize( 0, 0 ); + widget->setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX ); + widget->resize( orgSize ); + } return pix.toImage(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.h b/ApplicationLibCode/ProjectDataModel/RimViewWindow.h index b33fce97c5..052b140f68 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.h @@ -25,6 +25,8 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include + class RimDockWindowController; namespace ads @@ -101,7 +103,7 @@ protected: void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - QImage captureImage( QWidget* widget, int width, int height ); + QImage captureSnapshot( QWidget* widget, int width, int height ); private: friend class RimProject; diff --git a/GrpcInterface/GrpcProtos/Commands.proto b/GrpcInterface/GrpcProtos/Commands.proto index 5dbdf8fc6e..8449d6c7e8 100644 --- a/GrpcInterface/GrpcProtos/Commands.proto +++ b/GrpcInterface/GrpcProtos/Commands.proto @@ -55,6 +55,8 @@ message ExportSnapshotsRequest { int32 viewId = 4; string exportFolder = 5; PlotOutputFormat plotOutputFormat = 6; + int32 width = 7; + int32 height = 8; } message ExportPropertyRequest { diff --git a/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_plots.py b/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_plots.py index e54926b110..577069ae01 100644 --- a/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_plots.py +++ b/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_plots.py @@ -15,7 +15,7 @@ export_folder = tempfile.mkdtemp() print("Exporting to: " + export_folder) for plot in plots: - plot.export_snapshot(export_folder=export_folder) + plot.export_snapshot(export_folder=export_folder, width=1024, height=768) plot.export_snapshot(export_folder=export_folder, output_format="PDF") if isinstance(plot, rips.WellLogPlot): plot.export_data_as_las(export_folder=export_folder) diff --git a/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_snapshots.py b/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_snapshots.py index f4f49366d0..e67d35f386 100644 --- a/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_snapshots.py +++ b/GrpcInterface/Python/rips/PythonExamples/export_and_plotting/export_snapshots.py @@ -10,7 +10,7 @@ resinsight = rips.Instance.find() cases = resinsight.project.cases() # Set main window size -resinsight.set_main_window_size(width=800, height=500) +# resinsight.set_main_window_size(width=1280, height=900) n = 5 # every n-th time_step for snapshot property_list = ["SOIL", "PRESSURE"] # list of parameter for snapshot @@ -42,4 +42,4 @@ for case in cases: ) for time_step in range(0, len(time_steps), 10): view.set_time_step(time_step=time_step) - view.export_snapshot() + view.export_snapshot(width=1024, height=768) diff --git a/GrpcInterface/Python/rips/plot.py b/GrpcInterface/Python/rips/plot.py index 2c6300a1fd..d1176ce109 100644 --- a/GrpcInterface/Python/rips/plot.py +++ b/GrpcInterface/Python/rips/plot.py @@ -9,13 +9,15 @@ from .resinsight_classes import PlotWindow as PlotWindow, Plot as Plot @add_method(PlotWindow) -def export_snapshot(self, export_folder="", file_prefix="", output_format="PNG"): +def export_snapshot(self, export_folder="", file_prefix="", output_format="PNG", width=-1, height=-1): """Export snapshot for the current plot Arguments: export_folder(str): The path to export to. By default will use the global export folder prefix (str): Exported file name prefix output_format(str): 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. """ return self._execute_command( @@ -25,5 +27,7 @@ def export_snapshot(self, export_folder="", file_prefix="", output_format="PNG") viewId=self.id, exportFolder=export_folder, plotOutputFormat=output_format, + width=width, + height=height, ) ) diff --git a/GrpcInterface/Python/rips/view.py b/GrpcInterface/Python/rips/view.py index 901e75a7be..04b30bdc6c 100644 --- a/GrpcInterface/Python/rips/view.py +++ b/GrpcInterface/Python/rips/view.py @@ -245,7 +245,7 @@ def visible_cells(self, time_step=0): @add_method(ViewWindow) -def export_snapshot(self, prefix="", export_folder=""): +def export_snapshot(self, prefix="", export_folder="", width=-1, height=-1): """Export snapshot for the current view Arguments: @@ -260,5 +260,7 @@ def export_snapshot(self, prefix="", export_folder=""): caseId=case_id, viewId=self.id, exportFolder=export_folder, + width=width, + height=height ) )