(#396) Fixed updatePlotData system. Set curve name from result variable

This commit is contained in:
Jacob Støren 2015-09-03 09:49:36 +02:00
parent 9a6221b7e8
commit 5dd726129c
4 changed files with 121 additions and 87 deletions

View File

@ -84,16 +84,23 @@ 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();
}
}
//--------------------------------------------------------------------------------------------------
@ -101,57 +108,67 @@ void RimWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* chan
//--------------------------------------------------------------------------------------------------
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();
bool hasData = false;
cvf::ref<RigResultAccessor> resAcc = RigResultAccessorFactory::createResultAccessor(
eclipseCase->reservoirData(), 0,
porosityModel,
m_timeStep,
m_eclipseResultDefinition->resultVariable());
if (resAcc.notNull())
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)
m_plotCurve->setSamples(values.data(), depthValues.data(), (int)values.size());
if (hasData)
{
RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
{
wellLogPlot->updateAvailableDepthRange();
}
}
updateCurveTitle();
}
}
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);
if (wellLogPlot)
{
wellLogPlot->updateAvailableDepthRange();
}
m_plot->replot();
}
}
//--------------------------------------------------------------------------------------------------
@ -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);
}

View File

@ -41,6 +41,7 @@ public:
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);

View File

@ -61,21 +61,24 @@ void RimWellLogPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
{
if (changedField == &m_showCurve)
{
if (newValue == true)
{
m_plotCurve->attach(m_plot);
}
else
{
m_plotCurve->detach();
}
this->updateCurveVisibility();
m_plot->replot();
}
m_plotCurve->setTitle(this->m_userName());
if (m_showCurve())
{
if (changedField == &m_userName)
{
m_plotCurve->setTitle(this->m_userName());
m_plot->replot();
}
this->updatePlotData();
if (&m_curveColor == changedField)
{
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));
m_plot->replot();
}
}
}
//--------------------------------------------------------------------------------------------------
@ -86,40 +89,31 @@ caf::PdmFieldHandle* RimWellLogPlotCurve::objectToggleField()
return &m_showCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::updateCurveVisibility()
{
if (m_showCurve())
{
m_plotCurve->attach(m_plot);
}
else
{
m_plotCurve->detach();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotCurve::updatePlotData()
{
CVF_ASSERT(m_plot);
// Dummy Data
this->updateCurveVisibility();
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->setTitle(this->m_userName());
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));
RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
{
wellLogPlot->updateAvailableDepthRange();
}
m_plot->replot();
// Todo: Rest of the curve setup controlled from this class
}
//--------------------------------------------------------------------------------------------------
@ -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();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -48,6 +48,7 @@ public:
virtual void updatePlotData();
protected:
void updateCurveVisibility();
// Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);