mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#739 First crude but working version of Summary plotting
This commit is contained in:
@@ -41,6 +41,9 @@
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimViewController.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimWellLogCurve.h"
|
||||
@@ -244,6 +247,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
commandIds << "RicNewWellLogPlotFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryPlotCollection*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewSummaryPlotFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewWellLogPlotTrackFeature";
|
||||
@@ -260,6 +267,15 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "RicExportToLasFileFeature";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewSummaryCurveFeature";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryCurve*>(uiItem))
|
||||
{
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||
{
|
||||
commandIds << "RicAddWellLogToPlotFeature";
|
||||
|
||||
@@ -89,6 +89,7 @@ RimPlotCurve::RimPlotCurve()
|
||||
|
||||
m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve;
|
||||
|
||||
m_parentQwtPlot = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "qwt_date.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve");
|
||||
|
||||
@@ -128,7 +129,7 @@ QString RimSummaryCurve::createCurveAutoName()
|
||||
void RimSummaryCurve::zoomAllParentPlot()
|
||||
{
|
||||
// Todo
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -186,9 +187,7 @@ RifReaderEclipseSummary* RimSummaryCurve::summaryReader()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
// TODO: Used to hide the entry for a case in the tree view as we have no
|
||||
// setUiTreeHidden(true)
|
||||
uiTreeOrdering.setForgetRemainingFields(true);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -197,6 +196,8 @@ void RimSummaryCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
void RimSummaryCurve::curveData(std::vector<QDateTime>* timeSteps, std::vector<double>* values)
|
||||
{
|
||||
RifReaderEclipseSummary* reader = summaryReader();
|
||||
|
||||
if (!reader) return;
|
||||
|
||||
if (timeSteps)
|
||||
{
|
||||
|
||||
@@ -44,8 +44,8 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
|
||||
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Summary Plot"), "Name", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&curves, "SummaryCurves", "", "", "", "");
|
||||
curves.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_curves, "SummaryCurves", "", "", "", "");
|
||||
m_curves.uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -55,19 +55,7 @@ RimSummaryPlot::~RimSummaryPlot()
|
||||
{
|
||||
deletePlotWidget();
|
||||
|
||||
curves.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimSummaryPlot::createPlotWidget(QWidget* parent)
|
||||
{
|
||||
assert(m_viewer.isNull());
|
||||
|
||||
m_viewer = new RiuResultQwtPlot(parent);
|
||||
|
||||
return m_viewer;
|
||||
m_curves.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -90,19 +78,56 @@ RiuResultQwtPlot* RimSummaryPlot::viewer()
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::addCurve(RimSummaryCurve* curve)
|
||||
{
|
||||
if (curve)
|
||||
{
|
||||
m_curves.push_back(curve);
|
||||
if (m_viewer)
|
||||
{
|
||||
curve->setParentQwtPlot(m_viewer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_showWindow)
|
||||
{
|
||||
if (m_showWindow)
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateViewerWidget();
|
||||
}
|
||||
|
||||
uiCapability()->updateUiIconFromToggleField();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::loadDataAndUpdate()
|
||||
{
|
||||
m_viewer->deleteAllCurves();
|
||||
updateViewerWidget();
|
||||
|
||||
for (size_t i = 0; i < curves.size(); i++)
|
||||
for (size_t i = 0; i < m_curves.size(); i++)
|
||||
{
|
||||
RimSummaryCurve* curve = curves[i];
|
||||
RimSummaryCurve* curve = m_curves[i];
|
||||
|
||||
curve->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
// Todo: Update zoom
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -123,10 +148,15 @@ void RimSummaryPlot::updateViewerWidget()
|
||||
if (!m_viewer)
|
||||
{
|
||||
m_viewer = new RiuResultQwtPlot(RiuMainWindow::instance());
|
||||
for (size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
|
||||
{
|
||||
m_curves[cIdx]->setParentQwtPlot(m_viewer);
|
||||
}
|
||||
|
||||
|
||||
RiuMainWindow::instance()->addViewer(m_viewer, std::vector<int>());
|
||||
RiuMainWindow::instance()->setActiveViewer(m_viewer);
|
||||
|
||||
}
|
||||
|
||||
//updateViewerWidgetWindowTitle();
|
||||
@@ -152,8 +182,8 @@ void RimSummaryPlot::updateViewerWidget()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::detachAllCurves()
|
||||
{
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
for (size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx)
|
||||
{
|
||||
curves[cIdx]->detachQwtCurve();
|
||||
m_curves[cIdx]->detachQwtCurve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,22 +46,25 @@ public:
|
||||
void setDescription(const QString& description);
|
||||
void loadDataAndUpdate();
|
||||
RiuResultQwtPlot* viewer();
|
||||
void addCurve(RimSummaryCurve* curve);
|
||||
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> curves;
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
void updateViewerWidget();
|
||||
|
||||
void detachAllCurves();
|
||||
|
||||
QWidget* createPlotWidget(QWidget* parent);
|
||||
void deletePlotWidget();
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> m_curves;
|
||||
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
caf::PdmField<QString> m_userName;
|
||||
|
||||
|
||||
@@ -98,15 +98,19 @@ RifReaderEclipseSummary* RimSummaryPlotCollection::createSummaryFileReader(const
|
||||
std::string headerFile;
|
||||
bool isFormatted = false;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(eclipseCase.toStdString(), &headerFile, &isFormatted);
|
||||
|
||||
if (headerFile.empty()) return nullptr;
|
||||
|
||||
std::vector<std::string> dataFiles = RifEclipseSummaryTools::findSummaryDataFiles(eclipseCase.toStdString());
|
||||
|
||||
if (!dataFiles.size()) return nullptr;
|
||||
|
||||
RifReaderEclipseSummary* reader = new RifReaderEclipseSummary;
|
||||
if (!reader->open(headerFile, dataFiles))
|
||||
{
|
||||
delete reader;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -46,7 +46,6 @@ RimWellLogCurve::RimWellLogCurve()
|
||||
m_qwtPlotCurve->setXAxis(QwtPlot::xTop);
|
||||
m_qwtPlotCurve->setYAxis(QwtPlot::yLeft);
|
||||
|
||||
m_parentQwtPlot = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user