Skip to content

Commit

Permalink
(#396) Fixed updatePlotData system. Set curve name from result variable
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobStoren committed Sep 3, 2015
1 parent 9a6221b commit 5dd7261
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 85 deletions.
125 changes: 80 additions & 45 deletions ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,74 +84,91 @@ RimWellLogExtractionCurve::~RimWellLogExtractionCurve()
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimWellLogPlotCurve::fieldChangedByUi(changedField, oldValue, newValue);

if (changedField == &m_case)
{
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());

m_eclipseResultDefinition->setEclipseCase(eclipseCase);
m_geomResultDefinition->setGeoMechCase(geomCase);
this->updatePlotData();
}

RimWellLogPlotCurve::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &m_wellPath)
{
this->updatePlotData();
}

if (changedField == &m_timeStep)
{
this->updatePlotData();
}

}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::updatePlotData()
{
bool isNeedingUpdate = false;
std::vector<double> values;
std::vector<double> depthValues;
RimWellLogPlotCurve::updatePlotData();

RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
m_eclipseResultDefinition->setEclipseCase(eclipseCase);
m_geomResultDefinition->setGeoMechCase(geomCase);

if (m_wellPath)
if (m_showCurve)
{
if (eclipseCase)
{
RigEclipseWellLogExtractor extractor(eclipseCase->reservoirData(), m_wellPath->wellPathGeometry());
depthValues = (extractor.measuredDepth());

RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
m_eclipseResultDefinition->loadResult();

cvf::ref<RigResultAccessor> resAcc = RigResultAccessorFactory::createResultAccessor(
eclipseCase->reservoirData(), 0,
porosityModel,
m_timeStep,
m_eclipseResultDefinition->resultVariable());
if (resAcc.notNull())
bool hasData = false;

std::vector<double> values;
std::vector<double> depthValues;

RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
m_eclipseResultDefinition->setEclipseCase(eclipseCase);
m_geomResultDefinition->setGeoMechCase(geomCase);

if (m_wellPath)
{
if (eclipseCase)
{
extractor.curveData(resAcc.p(), &values);
isNeedingUpdate = true;
RigEclipseWellLogExtractor extractor(eclipseCase->reservoirData(), m_wellPath->wellPathGeometry());
depthValues = (extractor.measuredDepth());

RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
m_eclipseResultDefinition->loadResult();

cvf::ref<RigResultAccessor> resAcc = RigResultAccessorFactory::createResultAccessor(
eclipseCase->reservoirData(), 0,
porosityModel,
m_timeStep,
m_eclipseResultDefinition->resultVariable());
if (resAcc.notNull())
{
extractor.curveData(resAcc.p(), &values);
hasData = true;
}
}
}
else if (geomCase)
{

}
}
else if (geomCase)
{

if (isNeedingUpdate)
{
m_plotCurve->setSamples(values.data(), depthValues.data(), (int)depthValues.size());
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));

RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);
}
}

m_plotCurve->setSamples(values.data(), depthValues.data(), (int)values.size());

if (wellLogPlot)
if (hasData)
{
wellLogPlot->updateAvailableDepthRange();
RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);

if (wellLogPlot)
{
wellLogPlot->updateAvailableDepthRange();
}
}

updateCurveTitle();


m_plot->replot();
}

}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -241,4 +258,22 @@ void RimWellLogExtractionCurve::initAfterRead()
m_geomResultDefinition->setGeoMechCase(geomCase);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::updateCurveTitle()
{
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
QString resVar;
if (eclipseCase)
{
resVar = m_eclipseResultDefinition->resultVariable();
}

m_userName = resVar;

m_plotCurve->setTitle(m_userName);
}


Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class RimWellLogExtractionCurve : public RimWellLogPlotCurve
virtual void updatePlotData();

protected:
void updateCurveTitle();

virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
Expand Down
77 changes: 37 additions & 40 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,24 @@ void RimWellLogPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
{
if (changedField == &m_showCurve)
{
if (newValue == true)
this->updateCurveVisibility();
m_plot->replot();
}

if (m_showCurve())
{
if (changedField == &m_userName)
{
m_plotCurve->attach(m_plot);
m_plotCurve->setTitle(this->m_userName());
m_plot->replot();
}
else

if (&m_curveColor == changedField)
{
m_plotCurve->detach();
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));
m_plot->replot();
}


}

m_plotCurve->setTitle(this->m_userName());

this->updatePlotData();
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -89,37 +92,28 @@ caf::PdmFieldHandle* RimWellLogPlotCurve::objectToggleField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::updatePlotData()
void RimWellLogPlotCurve::updateCurveVisibility()
{
CVF_ASSERT(m_plot);

// Dummy Data

std::vector<double> values;
values.push_back(34);
values.push_back(47);
values.push_back(49);
values.push_back(22);
values.push_back(20);

std::vector<double> depthValues;
depthValues.push_back(200);
depthValues.push_back(400);
depthValues.push_back(600);
depthValues.push_back(800);
depthValues.push_back(1000);

m_plotCurve->setSamples(values.data(), depthValues.data(), (int) depthValues.size());
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));

RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);

if (wellLogPlot)
if (m_showCurve())
{
m_plotCurve->attach(m_plot);
}
else
{
wellLogPlot->updateAvailableDepthRange();
m_plotCurve->detach();
}
m_plot->replot();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::updatePlotData()
{
this->updateCurveVisibility();

m_plotCurve->setTitle(this->m_userName());
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));
// Todo: Rest of the curve setup controlled from this class
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -128,8 +122,11 @@ void RimWellLogPlotCurve::updatePlotData()
void RimWellLogPlotCurve::setPlot(RiuWellLogTracePlot* plot)
{
m_plot = plot;
m_plotCurve->attach(m_plot);
m_plot->replot();
if (m_showCurve)
{
m_plotCurve->attach(m_plot);
m_plot->replot();
}
}

//--------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class RimWellLogPlotCurve : public caf::PdmObject
virtual void updatePlotData();

protected:
void updateCurveVisibility();

// Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
Expand Down

0 comments on commit 5dd7261

Please sign in to comment.