mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-03 12:10:57 -06:00
282 lines
9.4 KiB
C++
282 lines
9.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2015- Statoil ASA
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
//
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimWellLogPlotCurve.h"
|
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RiuWellLogTrackPlot.h"
|
|
#include "RiuWellLogPlotCurve.h"
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
// NB! Special macro for pure virtual class
|
|
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimWellLogPlotCurve, "WellLogPlotCurve");
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellLogPlotCurve::RimWellLogPlotCurve()
|
|
{
|
|
CAF_PDM_InitObject("Curve", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_showCurve, "Show", true, "Show curve", "", "", "");
|
|
m_showCurve.uiCapability()->setUiHidden(true);
|
|
CAF_PDM_InitFieldNoDefault(&m_customCurveName, "CurveDescription", "Custom Name", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_generatedCurveName, "GeneratedCurveName", "Autogenerated Name", "", "", "");
|
|
m_generatedCurveName.uiCapability()->setUiReadOnly(true);
|
|
m_generatedCurveName.xmlCapability()->setIOReadable(false);
|
|
m_generatedCurveName.xmlCapability()->setIOWritable(false);
|
|
|
|
CAF_PDM_InitField(&m_useCustomCurveName, "UseCustomCurveName", false, "Show Custom Name", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_curveColor, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", "");
|
|
|
|
m_plotCurve = new RiuWellLogPlotCurve;
|
|
m_plotCurve->setXAxis(QwtPlot::xTop);
|
|
m_plotCurve->setYAxis(QwtPlot::yLeft);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellLogPlotCurve::~RimWellLogPlotCurve()
|
|
{
|
|
m_plotCurve->detach();
|
|
m_plot->replot();
|
|
|
|
delete m_plotCurve;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
{
|
|
if (changedField == &m_showCurve)
|
|
{
|
|
this->updateCurveVisibility();
|
|
}
|
|
|
|
if (changedField == &m_customCurveName)
|
|
{
|
|
updatePlotTitle();
|
|
}
|
|
|
|
if (&m_curveColor == changedField)
|
|
{
|
|
m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte())));
|
|
}
|
|
|
|
if (changedField == &m_useCustomCurveName)
|
|
{
|
|
updatePlotTitle();
|
|
updateOptionSensitivity();
|
|
}
|
|
|
|
m_plot->replot();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
caf::PdmFieldHandle* RimWellLogPlotCurve::objectToggleField()
|
|
{
|
|
return &m_showCurve;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::updateCurveVisibility()
|
|
{
|
|
if (m_showCurve())
|
|
{
|
|
m_plotCurve->attach(m_plot);
|
|
}
|
|
else
|
|
{
|
|
m_plotCurve->detach();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::updatePlotConfiguration()
|
|
{
|
|
this->updateCurveVisibility();
|
|
this->updatePlotTitle();
|
|
|
|
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
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::setPlot(RiuWellLogTrackPlot* plot)
|
|
{
|
|
m_plot = plot;
|
|
if (m_showCurve)
|
|
{
|
|
m_plotCurve->attach(m_plot);
|
|
m_plot->replot();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
caf::PdmFieldHandle* RimWellLogPlotCurve::userDescriptionField()
|
|
{
|
|
if (m_useCustomCurveName)
|
|
{
|
|
return &m_customCurveName;
|
|
}
|
|
else
|
|
{
|
|
return &m_generatedCurveName;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimWellLogPlotCurve::depthRange(double* minimumDepth, double* maximumDepth) const
|
|
{
|
|
CVF_ASSERT(minimumDepth && maximumDepth);
|
|
CVF_ASSERT(m_plotCurve);
|
|
|
|
if (m_plotCurve->data()->size() < 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
*minimumDepth = m_plotCurve->minYValue();
|
|
*maximumDepth = m_plotCurve->maxYValue();
|
|
|
|
return true;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimWellLogPlotCurve::valueRange(double* minimumValue, double* maximumValue) const
|
|
{
|
|
CVF_ASSERT(minimumValue && maximumValue);
|
|
CVF_ASSERT(m_plotCurve);
|
|
|
|
if (m_plotCurve->data()->size() < 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
*minimumValue = m_plotCurve->minXValue();
|
|
*maximumValue = m_plotCurve->maxXValue();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::setColor(const cvf::Color3f& color)
|
|
{
|
|
m_curveColor = color;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::detachCurve()
|
|
{
|
|
m_plotCurve->detach();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QwtPlotCurve* RimWellLogPlotCurve::plotCurve() const
|
|
{
|
|
return m_plotCurve;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::updatePlotTitle()
|
|
{
|
|
m_generatedCurveName = this->createCurveName();
|
|
|
|
if (m_useCustomCurveName)
|
|
{
|
|
m_plotCurve->setTitle(m_customCurveName);
|
|
}
|
|
else
|
|
{
|
|
m_plotCurve->setTitle(m_generatedCurveName);
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
{
|
|
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Curve Display Name");
|
|
group->add(&m_generatedCurveName);
|
|
group->add(&m_useCustomCurveName);
|
|
group->add(&m_customCurveName);
|
|
|
|
uiOrdering.add(&m_curveColor);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimWellLogPlotCurve::isCurveVisibile()
|
|
{
|
|
return m_showCurve;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::initAfterRead()
|
|
{
|
|
// TODO:
|
|
// In RimWellLogFileCurve::createCurveName, the object being referenced is not initialized at this point
|
|
// No name is read from file
|
|
// How to fix?
|
|
m_generatedCurveName = this->createCurveName();
|
|
|
|
updateOptionSensitivity();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellLogPlotCurve::updateOptionSensitivity()
|
|
{
|
|
m_customCurveName.uiCapability()->setUiReadOnly(!m_useCustomCurveName);
|
|
}
|