Skip to content

Commit

Permalink
Basic well log plot functionality with dummy data up & running
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
palhagen committed Aug 31, 2015
1 parent 3f09c1b commit 9d4f9d6
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 31 deletions.
11 changes: 10 additions & 1 deletion ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <QAction>

#include <vector>

CAF_CMD_SOURCE_INIT(RicNewWellLogPlotCurveFeature, "RicNewWellLogPlotCurveFeature");

Expand All @@ -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);
}
}

Expand Down
6 changes: 6 additions & 0 deletions ApplicationCode/ProjectDataModel/RimProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ void RimProject::computeUtmAreaOfInterest()
#include "RimEclipseFaultColors.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrace.h"
#include "RimWellLogPlotCurve.h"
#include <QMenu>


Expand Down Expand Up @@ -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))
Expand Down
15 changes: 14 additions & 1 deletion ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion ApplicationCode/ProjectDataModel/RimWellLogPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include <QPointer>

class RimWellLogPlotTrace;
class RiuWellLogPlot;
class RimWellLogPlotTrace;


//==================================================================================================
Expand All @@ -45,6 +45,8 @@ class RimWellLogPlot : public caf::PdmObject

void addTrace();

RiuWellLogPlot* viewer();

protected:

// Overridden PDM methods
Expand Down
60 changes: 60 additions & 0 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

#include "RimWellLogPlotCurve.h"

#include "RiuWellLogTracePlot.h"

#include "qwt_plot_curve.h"

#include "cvfAssert.h"

CAF_PDM_SOURCE_INIT(RimWellLogPlotCurve, "WellLogPlotCurve");

Expand All @@ -31,13 +36,19 @@ RimWellLogPlotCurve::RimWellLogPlotCurve()

CAF_PDM_InitField(&show, "Show", true, "Show curve", "", "", "");
show.uiCapability()->setUiHidden(true);

m_plotCurve = new QwtPlotCurve;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCurve::~RimWellLogPlotCurve()
{
m_plotCurve->detach();
m_plot->replot();

delete m_plotCurve;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -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;
}
20 changes: 19 additions & 1 deletion ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"

#include <vector>

class RiuWellLogTracePlot;
class QwtPlotCurve;
class QString;


//==================================================================================================
///
///
Expand All @@ -33,6 +40,13 @@ class RimWellLogPlotCurve : public caf::PdmObject
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
Expand All @@ -44,5 +58,9 @@ class RimWellLogPlotCurve : public caf::PdmObject
private:
caf::PdmField<bool> show;

// TODO: Add curves
RiuWellLogTracePlot* m_plot;
QwtPlotCurve* m_plotCurve;

std::vector<double> m_depthValues;
std::vector<double> m_values;
};
37 changes: 36 additions & 1 deletion ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -39,13 +43,16 @@ RimWellLogPlotTrace::RimWellLogPlotTrace()

CAF_PDM_InitFieldNoDefault(&curves, "Curves", "", "", "", "");
curves.uiCapability()->setUiHidden(true);

m_viewer = NULL;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotTrace::~RimWellLogPlotTrace()
{
delete m_viewer;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -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;
}
14 changes: 12 additions & 2 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"

#include <QPointer>

#include <vector>

class RimWellLogPlotCurve;
class RiuWellLogTracePlot;

//==================================================================================================
///
Expand All @@ -36,7 +41,12 @@ class RimWellLogPlotTrace : public caf::PdmObject
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:

Expand All @@ -48,5 +58,5 @@ class RimWellLogPlotTrace : public caf::PdmObject

private:
caf::PdmField<bool> show;
caf::PdmChildArrayField<RimWellLogPlotCurve*> curves;
QPointer<RiuWellLogTracePlot> m_viewer;
};
28 changes: 7 additions & 21 deletions ApplicationCode/UserInterface/RiuWellLogPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrace.h"

#include "cvfAssert.h"

#include <QHBoxLayout>

//--------------------------------------------------------------------------------------------------
Expand All @@ -46,28 +48,12 @@ RiuWellLogPlot::~RiuWellLogPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::update(const RimWellLogPlot& plot)
RiuWellLogTracePlot* RiuWellLogPlot::createTracePlot()
{
clear();

for (size_t traceIdx = 0; traceIdx < plot.traces.size(); traceIdx++)
{
RiuWellLogTracePlot* tracePlot = new RiuWellLogTracePlot(this);
m_layout->addWidget(tracePlot);
m_children.append(tracePlot);
}
}
RiuWellLogTracePlot* tracePlot = new RiuWellLogTracePlot(this);

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::clear()
{
for (int childIdx = 0; childIdx < m_children.size(); childIdx++)
{
m_layout->removeWidget(m_children[childIdx]);
delete m_children[childIdx];
}
m_layout->addWidget(tracePlot);
m_tracePlots.append(tracePlot);

m_children.clear();
return tracePlot;
}
5 changes: 2 additions & 3 deletions ApplicationCode/UserInterface/RiuWellLogPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ class RiuWellLogPlot : public QWidget
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;
};

1 comment on commit 9d4f9d6

@palhagen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue (#396)

Please sign in to comment.