(#538) Added depth unit and conversion between meter and feet

This commit is contained in:
Magne Sjaastad 2015-12-02 13:39:16 +01:00
parent fe261560bd
commit d18e8f7bd3
7 changed files with 121 additions and 10 deletions

View File

@ -77,5 +77,6 @@ public:
UNIT_FEET
};
static double feetPerMeter() { return 3.2808399; }
};

View File

@ -265,7 +265,16 @@ void RimWellLogExtractionCurve::updatePlotData()
}
}
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->depthPlotValues().data(), static_cast<int>(m_curveData->xPlotValues().size()));
RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER;
RimWellLogPlot* wellLogPlot;
firstAnchestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
{
displayUnit = wellLogPlot->depthUnit();
}
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->depthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices());
zoomAllOwnerTrackAndPlot();

View File

@ -114,7 +114,13 @@ void RimWellLogFileCurve::updatePlotData()
}
}
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->depthPlotValues().data(), static_cast<int>(m_curveData->xPlotValues().size()));
RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER;
if (wellLogPlot)
{
displayUnit = wellLogPlot->depthUnit();
}
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->depthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices());
zoomAllOwnerTrackAndPlot();

View File

@ -66,6 +66,9 @@ RimWellLogPlot::RimWellLogPlot()
caf::AppEnum< RimWellLogPlot::DepthTypeEnum > depthType = MEASURED_DEPTH;
CAF_PDM_InitField(&m_depthType, "DepthType", depthType, "Depth type", "", "", "");
caf::AppEnum< RimDefines::DepthUnitType > depthUnit = RimDefines::UNIT_METER;
CAF_PDM_InitField(&m_depthUnit, "DepthUnit", depthUnit, "Depth unit", "", "", "");
CAF_PDM_InitField(&m_minVisibleDepth, "MinimumDepth", 0.0, "Min", "", "", "");
CAF_PDM_InitField(&m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max", "", "", "");
@ -150,7 +153,8 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
{
updateViewerWidgetWindowTitle();
}
if (changedField == &m_depthType)
if (changedField == &m_depthType ||
changedField == &m_depthUnit)
{
updateTracks();
}
@ -366,6 +370,7 @@ void RimWellLogPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
{
uiOrdering.add(&m_userName);
uiOrdering.add(&m_depthType);
uiOrdering.add(&m_depthUnit);
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Visible Depth Range");
gridGroup->add(&m_minVisibleDepth);
@ -509,6 +514,14 @@ RimWellLogPlot::DepthTypeEnum RimWellLogPlot::depthType() const
return m_depthType.value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimDefines::DepthUnitType RimWellLogPlot::depthUnit() const
{
return m_depthUnit.value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -527,7 +540,15 @@ QString RimWellLogPlot::depthPlotTitle() const
break;
}
depthTitle += " [m]";
if (m_depthUnit == RimDefines::UNIT_METER)
{
depthTitle += " [m]";
}
else if (m_depthUnit == RimDefines::UNIT_FEET)
{
depthTitle += " [ft]";
}
return depthTitle;
}

View File

@ -25,6 +25,7 @@
#include "cafAppEnum.h"
#include <QPointer>
#include "RimDefines.h"
class RiuWellLogPlot;
class RimWellLogTrack;
@ -52,6 +53,7 @@ public:
void setDescription(const QString& description);
DepthTypeEnum depthType() const;
RimDefines::DepthUnitType depthUnit() const;
QString depthPlotTitle() const;
caf::PdmField< std::vector<int> > windowGeometry;
@ -100,8 +102,11 @@ private:
caf::PdmField<bool> m_showWindow;
caf::PdmField<QString> m_userName;
caf::PdmField< caf::AppEnum< DepthTypeEnum > > m_depthType;
caf::PdmChildArrayField<RimWellLogTrack*> m_tracks;
caf::PdmField< caf::AppEnum< DepthTypeEnum > > m_depthType;
caf::PdmField< caf::AppEnum< RimDefines::DepthUnitType > > m_depthUnit;
caf::PdmChildArrayField<RimWellLogTrack*> m_tracks;
caf::PdmField<double> m_minVisibleDepth;
caf::PdmField<double> m_maxVisibleDepth;

View File

@ -116,16 +116,32 @@ std::vector<double> RigWellLogCurveData::xPlotValues() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogCurveData::depthPlotValues() const
std::vector<double> RigWellLogCurveData::depthPlotValues(RimDefines::DepthUnitType destinationDepthUnit) const
{
std::vector<double> filteredValues;
if (m_tvDepths.size())
{
RigCurveDataTools::getValuesByIntervals(m_tvDepths, m_intervalsOfContinousValidValues, &filteredValues);
if (destinationDepthUnit == m_depthUnit)
{
RigCurveDataTools::getValuesByIntervals(m_tvDepths, m_intervalsOfContinousValidValues, &filteredValues);
}
else
{
std::vector<double> convertedValues = convertDepthValues(destinationDepthUnit, m_tvDepths);
RigCurveDataTools::getValuesByIntervals(convertedValues, m_intervalsOfContinousValidValues, &filteredValues);
}
}
else
{
RigCurveDataTools::getValuesByIntervals(m_measuredDepths, m_intervalsOfContinousValidValues, &filteredValues);
if (destinationDepthUnit == m_depthUnit)
{
RigCurveDataTools::getValuesByIntervals(m_measuredDepths, m_intervalsOfContinousValidValues, &filteredValues);
}
else
{
std::vector<double> convertedValues = convertDepthValues(destinationDepthUnit, m_measuredDepths);
RigCurveDataTools::getValuesByIntervals(convertedValues, m_intervalsOfContinousValidValues, &filteredValues);
}
}
return filteredValues;
@ -256,3 +272,50 @@ RimDefines::DepthUnitType RigWellLogCurveData::depthUnit() const
{
return m_depthUnit;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogCurveData::convertFromMeterToFeet(const std::vector<double>& valuesInMeter)
{
std::vector<double> valuesInFeet(valuesInMeter.size());
for (size_t i = 0; i < valuesInMeter.size(); i++)
{
valuesInFeet[i] = valuesInMeter[i] * RimDefines::feetPerMeter();
}
return valuesInFeet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogCurveData::convertFromFeetToMeter(const std::vector<double>& valuesInFeet)
{
std::vector<double> valuesInMeter(valuesInFeet.size());
for (size_t i = 0; i < valuesInFeet.size(); i++)
{
valuesInMeter[i] = valuesInFeet[i] / RimDefines::feetPerMeter();
}
return valuesInMeter;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogCurveData::convertDepthValues(RimDefines::DepthUnitType destinationDepthUnit, const std::vector<double>& values) const
{
CVF_ASSERT(destinationDepthUnit != m_depthUnit);
if (destinationDepthUnit == RimDefines::UNIT_METER)
{
return convertFromFeetToMeter(values);
}
else
{
return convertFromMeterToFeet(values);
}
}

View File

@ -54,7 +54,7 @@ public:
RimDefines::DepthUnitType depthUnit() const;
std::vector<double> xPlotValues() const;
std::vector<double> depthPlotValues() const;
std::vector<double> depthPlotValues(RimDefines::DepthUnitType displayDepthUnit) const;
std::vector< std::pair<size_t, size_t> > polylineStartStopIndices() const;
private:
@ -63,6 +63,12 @@ private:
static void splitIntervalAtEmptySpace(const std::vector<double>& depthValues,
size_t startIdx, size_t stopIdx,
std::vector< std::pair<size_t, size_t> >* intervals);
std::vector<double> convertDepthValues(RimDefines::DepthUnitType destinationDepthUnit, const std::vector<double>& originalValues) const;
static std::vector<double> convertFromMeterToFeet(const std::vector<double>& valuesInMeter);
static std::vector<double> convertFromFeetToMeter(const std::vector<double>& valuesInFeet);
private:
std::vector<double> m_xValues;
std::vector<double> m_measuredDepths;