#1214 Generalized export of snapshot images for all plot window types

This commit is contained in:
Magne Sjaastad 2017-02-14 15:03:54 +01:00
parent fa0e0d32ef
commit 758ac9ef8c
5 changed files with 33 additions and 38 deletions

View File

@ -2285,7 +2285,7 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName); QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder); saveSnapshotForAllViews(fullPathGeneratedFolder);
RicSnapshotAllPlotsToFileFeature::createSnapshotOfAllPlotsInFolder(fullPathGeneratedFolder); RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);
QDir baseDir(testCaseFolder.filePath(baseFolderName)); QDir baseDir(testCaseFolder.filePath(baseFolderName));
QDir genDir(testCaseFolder.filePath(generatedFolderName)); QDir genDir(testCaseFolder.filePath(generatedFolderName));

View File

@ -20,12 +20,10 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimViewWindow.h" #include "RimViewWindow.h"
#include "RimWellLogPlot.h"
#include "RiuMainPlotWindow.h" #include "RiuMainPlotWindow.h"
#include "RiuWellLogPlot.h"
#include "cafUtils.h" #include "cafUtils.h"
@ -35,6 +33,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QMdiSubWindow> #include <QMdiSubWindow>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicSnapshotViewToClipboardFeature, "RicSnapshotViewToClipboardFeature"); CAF_CMD_SOURCE_INIT(RicSnapshotViewToClipboardFeature, "RicSnapshotViewToClipboardFeature");
@ -178,13 +177,16 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots()
// Save images in snapshot catalog relative to project directory // Save images in snapshot catalog relative to project directory
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots"); QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");
createSnapshotOfAllPlotsInFolder(snapshotFolderName); exportSnapshotOfAllPlotsIntoFolder(snapshotFolderName);
QString text = QString("Exported snapshots to folder : \n%1").arg(snapshotFolderName);
QMessageBox::information(nullptr, "Export Snapshots To Folder", text);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicSnapshotAllPlotsToFileFeature::createSnapshotOfAllPlotsInFolder(QString snapshotFolderName) void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName)
{ {
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
@ -199,41 +201,20 @@ void RicSnapshotAllPlotsToFileFeature::createSnapshotOfAllPlotsInFolder(QString
const QString absSnapshotPath = snapshotPath.absolutePath(); const QString absSnapshotPath = snapshotPath.absolutePath();
// Well log plots std::vector<RimViewWindow*> viewWindows;
proj->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows);
for (auto viewWindow : viewWindows)
{ {
std::vector<RimWellLogPlot*> wellLogPlots; if (viewWindow->isMdiWindow() && viewWindow->viewWidget())
proj->descendantsIncludingThisOfType(wellLogPlots);
for (RimWellLogPlot* wellLogPlot : wellLogPlots)
{ {
if (wellLogPlot && wellLogPlot->viewWidget()) QString fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
{
QString fileName = wellLogPlot->description();
fileName = caf::Utils::makeValidFileBasename(fileName); fileName = caf::Utils::makeValidFileBasename(fileName);
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png"); QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
absoluteFileName.replace(" ", "_"); absoluteFileName.replace(" ", "_");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, wellLogPlot); RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, viewWindow);
}
}
}
// Summary plots
{
std::vector<RimSummaryPlot*> summaryPlots;
proj->descendantsIncludingThisOfType(summaryPlots);
for (RimSummaryPlot* summaryPlot : summaryPlots)
{
if (summaryPlot && summaryPlot->viewWidget())
{
QString fileName = summaryPlot->description();
fileName = caf::Utils::makeValidFileBasename(fileName);
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
absoluteFileName.replace(" ", "_");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, summaryPlot);
}
} }
} }
} }

View File

@ -66,7 +66,7 @@ class RicSnapshotAllPlotsToFileFeature : public caf::CmdFeature
public: public:
static void saveAllPlots(); static void saveAllPlots();
static void createSnapshotOfAllPlotsInFolder(QString snapshotFolderName); static void exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName);
protected: protected:
// Overrides // Overrides

View File

@ -90,6 +90,19 @@ void RimViewWindow::updateMdiWindowVisibility()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimViewWindow::isMdiWindow() const
{
if (m_windowController())
{
return true;
}
return false;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -51,6 +51,7 @@ public:
void setAs3DViewMdiWindow() { setAsMdiWindow(0); } void setAs3DViewMdiWindow() { setAsMdiWindow(0); }
void setAsPlotMdiWindow() { setAsMdiWindow(1); } void setAsPlotMdiWindow() { setAsMdiWindow(1); }
bool isMdiWindow() const;
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry); void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry);
RimMdiWindowGeometry mdiWindowGeometry(); RimMdiWindowGeometry mdiWindowGeometry();