#850 Summary : Added snapshot of all well log plots and summary plots to file

This commit is contained in:
Magne Sjaastad 2016-10-27 11:03:13 +02:00
parent 5a63b841b8
commit 70fb105ced
13 changed files with 204 additions and 62 deletions

View File

@ -21,7 +21,13 @@
#include "RiaApplication.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimViewWindow.h"
#include "RimWellLogPlot.h"
#include "RiuMainPlotWindow.h"
#include "RiuWellLogPlot.h"
#include "cafUtils.h"
#include <QAction>
#include <QClipboard>
@ -150,3 +156,104 @@ void RicSnapshotViewToFileFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setIcon(QIcon(":/SnapShotSave.png"));
}
CAF_CMD_SOURCE_INIT(RicSnapshotAllPlotsToFileFeature, "RicSnapshotAllPlotsToFileFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSnapshotAllPlotsToFileFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllPlotsToFileFeature::onActionTriggered(bool isChecked)
{
RiaApplication* app = RiaApplication::instance();
RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow();
if (!mainPlotWindow) return;
RimProject* proj = app->project();
if (!proj) return;
// Save images in snapshot catalog relative to project directory
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");
QDir snapshotPath(snapshotFolderName);
if (!snapshotPath.exists())
{
if (!snapshotPath.mkpath(".")) return;
}
const QString absSnapshotPath = snapshotPath.absolutePath();
QWidget* currentActiveWidget = nullptr;
if (RiaApplication::activeViewWindow())
{
currentActiveWidget = RiaApplication::activeViewWindow()->viewWidget();
}
// Well log plots
{
std::vector<RimWellLogPlot*> wellLogPlots;
proj->descendantsIncludingThisOfType(wellLogPlots);
for (RimWellLogPlot* wellLogPlot : wellLogPlots)
{
if (wellLogPlot && wellLogPlot->viewWidget())
{
mainPlotWindow->setActiveViewer(wellLogPlot->viewWidget());
QString fileName = wellLogPlot->description();
fileName.replace(" ", "_");
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName);
}
}
}
// Summary plots
{
std::vector<RimSummaryPlot*> summaryPlots;
proj->descendantsIncludingThisOfType(summaryPlots);
for (RimSummaryPlot* summaryPlot : summaryPlots)
{
if (summaryPlot && summaryPlot->viewWidget())
{
mainPlotWindow->setActiveViewer(summaryPlot->viewWidget());
QString fileName = summaryPlot->description();
fileName.replace(" ", "_");
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName);
}
}
}
if (currentActiveWidget)
{
mainPlotWindow->setActiveViewer(currentActiveWidget);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllPlotsToFileFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Snapshot All Plots To File");
actionToSetup->setIcon(QIcon(":/SnapShotSave.png"));
}

View File

@ -55,3 +55,18 @@ protected:
};
//==================================================================================================
///
//==================================================================================================
class RicSnapshotAllPlotsToFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -163,6 +163,14 @@ void RimSummaryPlot::selectAxisInPropertyEditor(int axis)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimSummaryPlot::viewWidget()
{
return m_qwtPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -292,14 +300,6 @@ void RimSummaryPlot::updateCaseNameHasChanged()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimSummaryPlot::viewer()
{
return m_qwtPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -554,6 +554,14 @@ void RimSummaryPlot::setDescription(const QString& description)
m_userName = description;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimSummaryPlot::description() const
{
return m_userName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -55,6 +55,8 @@ public:
virtual ~RimSummaryPlot();
void setDescription(const QString& description);
QString description() const;
void addCurve(RimSummaryCurve* curve);
void addCurveFilter(RimSummaryCurveFilter* curveFilter);
@ -65,8 +67,6 @@ public:
void handleViewerDeletion();
void updateCaseNameHasChanged();
QWidget* viewer();
void updateAxes();
virtual void zoomAll() override;
void setZoomWindow(const QwtInterval& leftAxis,
@ -81,6 +81,8 @@ public:
void selectAxisInPropertyEditor(int axis);
virtual QWidget* viewWidget() override;
protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }

View File

@ -944,3 +944,11 @@ cvf::ref<caf::DisplayCoordTransform> RimView::displayCoordTransform()
return coordTrans;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimView::viewWidget()
{
return m_viewer;
}

View File

@ -165,6 +165,8 @@ public:
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform();
virtual QWidget* viewWidget() override;
public:
virtual void loadDataAndUpdate() = 0;
virtual RimCase* ownerCase() = 0;

View File

@ -1,5 +1,23 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimViewWindow.h"
#include "QWidget"
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimViewWindow, "ViewWindow"); // Do not use. Abstract class
@ -21,14 +39,6 @@ RimViewWindow::~RimViewWindow(void)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::setViewWidget(QWidget* viewWidget)
{
m_viewWidget = viewWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -20,7 +20,8 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "QPointer"
#include <vector>
struct RimMdiWindowGeometry
{
@ -47,16 +48,9 @@ public:
virtual QImage snapshotWindowContent() = 0;
virtual void zoomAll() = 0;
protected:
void setViewWidget(QWidget* viewWidget);
// Possible abilities of this class
//caf::PdmField<QString> name;
//caf::PdmField<bool> showWindow;
virtual QWidget* viewWidget() = 0;
private:
caf::PdmField< std::vector<int> > m_windowGeometry;
QPointer<QWidget> m_viewWidget;
};

View File

@ -49,6 +49,7 @@ namespace caf {
CAF_PDM_SOURCE_INIT(RimWellLogPlot, "WellLogPlot");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -268,14 +269,6 @@ void RimWellLogPlot::moveTracks(RimWellLogTrack* insertAfterTrack, const std::ve
updateTrackNames();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogPlot* RimWellLogPlot::viewer()
{
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -380,6 +373,14 @@ void RimWellLogPlot::zoomAll()
updateDepthZoom();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellLogPlot::viewWidget()
{
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -536,6 +537,14 @@ void RimWellLogPlot::setDescription(const QString& description)
m_userName = description;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogPlot::description() const
{
return m_userName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -54,6 +54,7 @@ public:
virtual ~RimWellLogPlot();
void setDescription(const QString& description);
QString description() const;
DepthTypeEnum depthType() const;
@ -73,8 +74,6 @@ public:
void updateTracks();
void updateTrackNames();
RiuWellLogPlot* viewer();
void updateDepthZoom();
void setDepthZoomByFactorAndCenter(double zoomFactor, double zoomCenter);
void panDepth(double panFactor);
@ -86,6 +85,7 @@ public:
bool hasAvailableDepthRange() const;
virtual void zoomAll() override;
virtual QWidget* viewWidget() override;
protected:

View File

@ -101,7 +101,12 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
{
wellLogPlot->calculateAvailableDepthRange();
wellLogPlot->updateDepthZoom();
if (wellLogPlot->viewer()) wellLogPlot->viewer()->updateChildrenLayout();
RiuWellLogPlot* wellLogPlotViewer = dynamic_cast<RiuWellLogPlot*>(wellLogPlot->viewWidget());
if (wellLogPlotViewer)
{
wellLogPlotViewer->updateChildrenLayout();
}
}
}
else if (changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax)

View File

@ -129,9 +129,7 @@ void RiuMainPlotWindow::closeEvent(QCloseEvent* event)
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::createActions()
{
m_snapshotAllViewsToFile = new QAction(QIcon(":/SnapShotSaveViews.png"), "Snapshot All Views To File", this);
connect(m_snapshotAllViewsToFile, SIGNAL(triggered()), SLOT(slotSnapshotAllViewsToFile()));
}
//--------------------------------------------------------------------------------------------------
@ -237,6 +235,7 @@ void RiuMainPlotWindow::createToolBars()
toolbar->setObjectName(toolbar->windowTitle());
toolbar->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
toolbar->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature"));
toolbar->addAction(cmdFeatureMgr->action("RicSnapshotAllPlotsToFileFeature"));
}
{
@ -549,10 +548,9 @@ void RiuMainPlotWindow::selectedObjectsChanged()
if (selectedWellLogPlot)
{
if (selectedWellLogPlot->viewer())
if (selectedWellLogPlot->viewWidget())
{
setActiveViewer(selectedWellLogPlot->viewer());
setActiveViewer(selectedWellLogPlot->viewWidget());
}
isActiveWellLogPlotChanged = true;
}
@ -575,9 +573,9 @@ void RiuMainPlotWindow::selectedObjectsChanged()
if (selectedSummaryPlot)
{
if (selectedSummaryPlot->viewer())
if (selectedSummaryPlot->viewWidget())
{
setActiveViewer(selectedSummaryPlot->viewer());
setActiveViewer(selectedSummaryPlot->viewWidget());
}
isActiveSummaryPlotChanged = true;
}
@ -597,18 +595,6 @@ void RiuMainPlotWindow::selectedObjectsChanged()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::slotSnapshotAllViewsToFile()
{
RiaApplication* app = RiaApplication::instance();
// Save images in snapshot catalog relative to project directory
QString absolutePathToSnapshotDir = app->createAbsolutePathFromProjectRelativePath("snapshots");
app->saveSnapshotForAllViews(absolutePathToSnapshotDir);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -94,8 +94,6 @@ private:
QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI
private:
QAction* m_snapshotAllViewsToFile;
QMdiArea* m_mdiArea;
RiuViewer* m_mainViewer;
@ -107,8 +105,6 @@ private slots:
friend class RiuMdiSubWindow;
void slotSnapshotAllViewsToFile();
void slotBuildWindowActions();
void slotSubWindowActivated(QMdiSubWindow* subWindow);