Support PDF-export from Python

This commit is contained in:
Gaute Lindkvist
2020-01-21 12:36:22 +01:00
parent 1133816471
commit e1c1981830
9 changed files with 59 additions and 20 deletions

View File

@@ -68,7 +68,8 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots()
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( const QString& snapshotFolderName,
const QString& prefix,
int viewId )
int viewId,
const QString& preferredFileSuffix /*=".png"*/ )
{
RiaApplication* app = RiaApplication::instance();
@@ -98,7 +99,7 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( const QS
fileName.replace( " ", "_" );
QString absoluteFileName = caf::Utils::constructFullFileName( absSnapshotPath, fileName, ".png" );
QString absoluteFileName = caf::Utils::constructFullFileName( absSnapshotPath, fileName, preferredFileSuffix );
RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, viewWindow );
}

View File

@@ -33,8 +33,9 @@ public:
static void saveAllPlots();
static void exportSnapshotOfPlotsIntoFolder( const QString& snapshotFolderName,
const QString& prefix = "",
int viewId = -1 );
const QString& prefix = "",
int viewId = -1,
const QString& preferredFileSuffix = ".png" );
protected:
// Overrides

View File

@@ -50,7 +50,12 @@ CAF_CMD_SOURCE_INIT( RicSnapshotViewToFileFeature, "RicSnapshotViewToFileFeature
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToFileFeature::saveSnapshotAs( const QString& fileName, RimViewWindow* viewWindow )
{
if ( viewWindow )
RimPlotWindow* plotWindow = dynamic_cast<RimPlotWindow*>( viewWindow );
if ( plotWindow && fileName.endsWith( ".pdf" ) )
{
savePlotPDFReportAs( fileName, plotWindow );
}
else if ( viewWindow )
{
QImage image = viewWindow->snapshotWindowContent();
saveSnapshotAs( fileName, image );