Cleaned away dummy data and moved curve creation logic to the command feature

This commit is contained in:
Jacob Støren 2015-09-01 09:06:02 +02:00
parent 3a7959ff13
commit 57d195d9d8
5 changed files with 16 additions and 28 deletions

View File

@ -26,6 +26,8 @@
#include <QAction>
#include <vector>
#include "RiuMainWindow.h"
#include "RimWellLogPlotCurve.h"
CAF_CMD_SOURCE_INIT(RicNewWellLogPlotCurveFeature, "RicNewWellLogPlotCurveFeature");
@ -45,17 +47,13 @@ void RicNewWellLogPlotCurveFeature::onActionTriggered(bool isChecked)
RimWellLogPlotTrace* wellLogPlotTrace = selectedWellLogPlotTrace();
if (wellLogPlotTrace)
{
// 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(250);
depthValues.push_back(1000);
RimWellLogPlotCurve* curve = new RimWellLogPlotCurve();
wellLogPlotTrace->addCurve(curve);
values.push_back(wellLogPlotTrace->curves.size() + 1);
values.push_back(wellLogPlotTrace->curves.size() + 0.5);
values.push_back(wellLogPlotTrace->curves.size() + 1);
curve->setUiName(QString("Curve %1").arg(wellLogPlotTrace->curves.size()));
wellLogPlotTrace->addCurve(depthValues, values);
wellLogPlotTrace->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(curve);
}
}

View File

@ -69,6 +69,9 @@ void RimWellLogPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
m_plot->replot();
}
}
//--------------------------------------------------------------------------------------------------
@ -82,15 +85,13 @@ caf::PdmFieldHandle* RimWellLogPlotCurve::objectToggleField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::plot(const std::vector<double>& depthValues, const std::vector<double>& values)
void RimWellLogPlotCurve::updatePlot()
{
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->setSamples(values.data(), depthValues.data(), (int) depthValues.size());
m_plotCurve->attach(m_plot);
m_plot->replot();
}

View File

@ -41,7 +41,7 @@ public:
virtual ~RimWellLogPlotCurve();
void setPlot(RiuWellLogTracePlot* plot);
void plot(const std::vector<double>& m_depthValues, const std::vector<double>& m_values);
protected:
@ -50,13 +50,10 @@ protected:
private:
virtual caf::PdmFieldHandle* objectToggleField();
void updatePlot();
private:
caf::PdmField<bool> show;
RiuWellLogTracePlot* m_plot;
QwtPlotCurve* m_plotCurve;
std::vector<double> m_depthValues;
std::vector<double> m_values;
};

View File

@ -77,19 +77,11 @@ caf::PdmFieldHandle* RimWellLogPlotTrace::objectToggleField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::addCurve(const std::vector<double>& depthValues, const std::vector<double>& values)
void RimWellLogPlotTrace::addCurve(RimWellLogPlotCurve* curve)
{
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);
updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(curve);
}

View File

@ -42,7 +42,7 @@ public:
virtual ~RimWellLogPlotTrace();
void setViewer(RiuWellLogTracePlot* viewer);
void addCurve(const std::vector<double>& depthValues, const std::vector<double>& values);
void addCurve(RimWellLogPlotCurve* curve);
RiuWellLogTracePlot* viewer();