Basic well log plot functionality with dummy data up & running

Traces can be added to and deleted from well log plots, and curves with
dummy data can be added and deleted. TODO: Replace dummy data with real
well log data and data extracted from the model.
This commit is contained in:
Pål Hagen
2015-08-31 02:06:37 +02:00
parent 3f09c1bc66
commit 9d4f9d617f
10 changed files with 172 additions and 34 deletions

View File

@@ -25,6 +25,7 @@
#include <QAction>
#include <vector>
CAF_CMD_SOURCE_INIT(RicNewWellLogPlotCurveFeature, "RicNewWellLogPlotCurveFeature");
@@ -44,7 +45,15 @@ void RicNewWellLogPlotCurveFeature::onActionTriggered(bool isChecked)
RimWellLogPlotTrace* wellLogPlotTrace = selectedWellLogPlotTrace();
if (wellLogPlotTrace)
{
wellLogPlotTrace->addCurve();
// TODO: replace dummy values with values extracted from model or read from well log files
std::vector<double> depthValues, values;
depthValues.push_back(0);
depthValues.push_back(-1000);
values.push_back(wellLogPlotTrace->curves.size() + 1);
values.push_back(wellLogPlotTrace->curves.size() + 1);
wellLogPlotTrace->addCurve(depthValues, values);
}
}

View File

@@ -579,6 +579,7 @@ void RimProject::computeUtmAreaOfInterest()
#include "RimEclipseFaultColors.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrace.h"
#include "RimWellLogPlotCurve.h"
#include <QMenu>
@@ -760,6 +761,11 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
else if (dynamic_cast<RimWellLogPlotTrace*>(uiItem))
{
commandIds << "RicNewWellLogPlotCurveFeature";
commandIds << "RicDeleteItemFeature";
}
else if (dynamic_cast<RimWellLogPlotCurve*>(uiItem))
{
commandIds << "RicDeleteItemFeature";
}
if (dynamic_cast<RimManagedViewCollection*>(uiItem))

View File

@@ -22,10 +22,12 @@
#include "RimWellLogPlotTrace.h"
#include "RiuWellLogPlot.h"
#include "RiuWellLogTracePlot.h"
#include "RiuMainWindow.h"
#include "cafPdmUiTreeView.h"
#include "cvfAssert.h"
CAF_PDM_SOURCE_INIT(RimWellLogPlot, "WellLogPlot");
@@ -104,8 +106,19 @@ void RimWellLogPlot::addTrace()
RimWellLogPlotTrace* trace = new RimWellLogPlotTrace();
traces.push_back(trace);
trace->setUiName(QString("Trace %1").arg(traces.size()));
RiuWellLogTracePlot* viewer = m_viewer->createTracePlot();
trace->setViewer(viewer);
RiuMainWindow::instance()->projectTreeView()->setExpanded(this, true);
updateConnectedEditors();
m_viewer->update(*this);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogPlot* RimWellLogPlot::viewer()
{
return m_viewer;
}

View File

@@ -25,8 +25,8 @@
#include <QPointer>
class RimWellLogPlotTrace;
class RiuWellLogPlot;
class RimWellLogPlotTrace;
//==================================================================================================
@@ -45,6 +45,8 @@ public:
void addTrace();
RiuWellLogPlot* viewer();
protected:
// Overridden PDM methods

View File

@@ -19,6 +19,11 @@
#include "RimWellLogPlotCurve.h"
#include "RiuWellLogTracePlot.h"
#include "qwt_plot_curve.h"
#include "cvfAssert.h"
CAF_PDM_SOURCE_INIT(RimWellLogPlotCurve, "WellLogPlotCurve");
@@ -31,6 +36,8 @@ RimWellLogPlotCurve::RimWellLogPlotCurve()
CAF_PDM_InitField(&show, "Show", true, "Show curve", "", "", "");
show.uiCapability()->setUiHidden(true);
m_plotCurve = new QwtPlotCurve;
}
//--------------------------------------------------------------------------------------------------
@@ -38,6 +45,10 @@ RimWellLogPlotCurve::RimWellLogPlotCurve()
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCurve::~RimWellLogPlotCurve()
{
m_plotCurve->detach();
m_plot->replot();
delete m_plotCurve;
}
//--------------------------------------------------------------------------------------------------
@@ -54,3 +65,52 @@ caf::PdmFieldHandle* RimWellLogPlotCurve::objectToggleField()
{
return &show;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::plot(std::vector<double> depthValues, std::vector<double> values)
{
CVF_ASSERT(m_plot);
m_depthValues = depthValues;
m_values = values;
m_plotCurve->setTitle(this->uiName());
m_plotCurve->setSamples(values.data(), depthValues.data(), (int) depthValues.size());
m_plotCurve->attach(m_plot);
m_plot->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimWellLogPlotCurve::pointCount() const
{
return m_depthValues.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const double* RimWellLogPlotCurve::depthValues() const
{
return m_depthValues.data();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const double* RimWellLogPlotCurve::values() const
{
return m_values.data();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::setPlot(RiuWellLogTracePlot* plot)
{
m_plot = plot;
}

View File

@@ -22,6 +22,13 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include <vector>
class RiuWellLogTracePlot;
class QwtPlotCurve;
class QString;
//==================================================================================================
///
///
@@ -33,6 +40,13 @@ public:
RimWellLogPlotCurve();
virtual ~RimWellLogPlotCurve();
void setPlot(RiuWellLogTracePlot* plot);
void plot(std::vector<double> m_depthValues, std::vector<double> m_values);
size_t pointCount() const;
const double* depthValues() const;
const double* values() const;
protected:
// Overridden PDM methods
@@ -44,5 +58,9 @@ private:
private:
caf::PdmField<bool> show;
// TODO: Add curves
RiuWellLogTracePlot* m_plot;
QwtPlotCurve* m_plotCurve;
std::vector<double> m_depthValues;
std::vector<double> m_values;
};

View File

@@ -19,11 +19,15 @@
#include "RimWellLogPlotTrace.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCurve.h"
#include "RiuWellLogTracePlot.h"
#include "RiuWellLogPlot.h"
#include "RiuMainWindow.h"
#include "cafPdmUiTreeView.h"
#include "cvfAssert.h"
CAF_PDM_SOURCE_INIT(RimWellLogPlotTrace, "WellLogPlotTrace");
@@ -39,6 +43,8 @@ RimWellLogPlotTrace::RimWellLogPlotTrace()
CAF_PDM_InitFieldNoDefault(&curves, "Curves", "", "", "", "");
curves.uiCapability()->setUiHidden(true);
m_viewer = NULL;
}
//--------------------------------------------------------------------------------------------------
@@ -46,6 +52,7 @@ RimWellLogPlotTrace::RimWellLogPlotTrace()
//--------------------------------------------------------------------------------------------------
RimWellLogPlotTrace::~RimWellLogPlotTrace()
{
delete m_viewer;
}
//--------------------------------------------------------------------------------------------------
@@ -66,12 +73,40 @@ caf::PdmFieldHandle* RimWellLogPlotTrace::objectToggleField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::addCurve()
void RimWellLogPlotTrace::addCurve(std::vector<double>& depthValues, std::vector<double>& values)
{
CVF_ASSERT(m_viewer);
RimWellLogPlotCurve* curve = new RimWellLogPlotCurve();
curves.push_back(curve);
curve->setPlot(m_viewer);
curve->setUiName(QString("Curve %1").arg(curves.size()));
curve->plot(depthValues, values);
RiuMainWindow::instance()->projectTreeView()->setExpanded(this, true);
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::setViewer(RiuWellLogTracePlot* viewer)
{
if (m_viewer)
{
delete m_viewer;
}
m_viewer = viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTracePlot* RimWellLogPlotTrace::viewer()
{
return m_viewer;
}

View File

@@ -23,7 +23,12 @@
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
#include <QPointer>
#include <vector>
class RimWellLogPlotCurve;
class RiuWellLogTracePlot;
//==================================================================================================
///
@@ -36,7 +41,12 @@ public:
RimWellLogPlotTrace();
virtual ~RimWellLogPlotTrace();
void addCurve();
void setViewer(RiuWellLogTracePlot* viewer);
void addCurve(std::vector<double>& depthValues, std::vector<double>& values);
RiuWellLogTracePlot* viewer();
caf::PdmChildArrayField<RimWellLogPlotCurve*> curves;
protected:
@@ -48,5 +58,5 @@ private:
private:
caf::PdmField<bool> show;
caf::PdmChildArrayField<RimWellLogPlotCurve*> curves;
QPointer<RiuWellLogTracePlot> m_viewer;
};

View File

@@ -24,6 +24,8 @@
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrace.h"
#include "cvfAssert.h"
#include <QHBoxLayout>
//--------------------------------------------------------------------------------------------------
@@ -46,28 +48,12 @@ RiuWellLogPlot::~RiuWellLogPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::update(const RimWellLogPlot& plot)
RiuWellLogTracePlot* RiuWellLogPlot::createTracePlot()
{
clear();
RiuWellLogTracePlot* tracePlot = new RiuWellLogTracePlot(this);
for (size_t traceIdx = 0; traceIdx < plot.traces.size(); traceIdx++)
{
RiuWellLogTracePlot* tracePlot = new RiuWellLogTracePlot(this);
m_layout->addWidget(tracePlot);
m_children.append(tracePlot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::clear()
{
for (int childIdx = 0; childIdx < m_children.size(); childIdx++)
{
m_layout->removeWidget(m_children[childIdx]);
delete m_children[childIdx];
}
m_children.clear();
m_layout->addWidget(tracePlot);
m_tracePlots.append(tracePlot);
return tracePlot;
}

View File

@@ -39,11 +39,10 @@ public:
RiuWellLogPlot(QWidget* parent = NULL);
virtual ~RiuWellLogPlot();
void update(const RimWellLogPlot& plot);
void clear();
RiuWellLogTracePlot* createTracePlot();
private:
QHBoxLayout* m_layout;
QList<RiuWellLogTracePlot*> m_children;
QList<RiuWellLogTracePlot*> m_tracePlots;
};