diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp index 584040615c..44668055e4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -32,8 +32,6 @@ #include "cvfBoundingBox.h" #include "cvfMath.h" -#include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -53,9 +51,18 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display double planeWidth, const std::vector& drawSurfaceVertices) { + CVF_ASSERT(rim3dWellLogCurve); + // Make sure all drawables are cleared in case we return early to avoid a // previous drawable being "stuck" when changing result type. clearCurvePointsAndGeometry(); + + float curveUIRange = rim3dWellLogCurve->maxCurveUIValue() - rim3dWellLogCurve->minCurveUIValue(); + if (curveUIRange < 1.0e-6f) + { + return; + } + std::vector resultValues; std::vector resultMds; @@ -70,11 +77,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (resultValues.empty()) return; CVF_ASSERT(resultValues.size() == resultMds.size()); - if (rim3dWellLogCurve->maxCurveValue() - rim3dWellLogCurve->minCurveValue() < 1.0e-6) - { - return; - } - RimWellPathCollection* wellPathCollection = nullptr; m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); @@ -117,25 +119,36 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), resultMds.end()); - double maxClampedResult = -HUGE_VAL; - double minClampedResult = HUGE_VAL; + double maxVisibleResult = -std::numeric_limits::max(); + double minVisibleResult = std::numeric_limits::max(); + + double curveEpsilon = 1.0e-6; for (double& result : m_curveValues) { if (!RigCurveDataTools::isValidValue(result, false)) continue; - result = cvf::Math::clamp(result, rim3dWellLogCurve->minCurveValue(), rim3dWellLogCurve->maxCurveValue()); - - maxClampedResult = std::max(result, maxClampedResult); - minClampedResult = std::min(result, minClampedResult); + if ((rim3dWellLogCurve->minCurveUIValue() - result) > curveEpsilon * curveUIRange) + { + result = -std::numeric_limits::max(); + } + else if ((result - rim3dWellLogCurve->maxCurveUIValue()) > curveEpsilon * curveUIRange) + { + result = std::numeric_limits::max(); + } + else + { + maxVisibleResult = std::max(result, maxVisibleResult); + minVisibleResult = std::min(result, minVisibleResult); + } } - if (minClampedResult >= maxClampedResult) + if (minVisibleResult > maxVisibleResult) { return; } - double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult); + double plotRangeToResultRangeFactor = planeWidth / curveUIRange; m_curveVertices.reserve(interpolatedWellPathPoints.size()); for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++) @@ -144,7 +157,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display if (RigCurveDataTools::isValidValue(m_curveValues[i], false)) { - scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor; + scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - rim3dWellLogCurve->minCurveUIValue()) * plotRangeToResultRangeFactor; } cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); m_curveVertices.push_back(cvf::Vec3f(curvePoint)); @@ -169,8 +182,12 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display indices.reserve(m_curveVertices.size() * 2); for (size_t i = 0; i < m_curveVertices.size() - 1; ++i) { - indices.push_back(cvf::uint(i)); - indices.push_back(cvf::uint(i + 1)); + if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) + { + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); + } } cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); @@ -348,6 +365,15 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con } expandedBottomVertices.insert(expandedBottomVertices.end(), extraBottomVertices.begin(), extraBottomVertices.end()); } + else + { + // Add the invalid points and values. + expandedCurveVertices.push_back(m_curveVertices[i]); + expandedBottomVertices.push_back(m_bottomVertices[i]); + expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); + expandedValues.push_back(m_curveValues[i]); + + } } CVF_ASSERT(expandedCurveVertices.size() == expandedBottomVertices.size()); diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 03981c60af..4108d72774 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -29,7 +29,6 @@ #include "cvfVector3.h" #include -#include // Needed for HUGE_VAL on Linux //================================================================================================== /// @@ -65,17 +64,15 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- Rim3dWellLogCurve::Rim3dWellLogCurve() - : m_minCurveDataValue(-HUGE_VAL) - , m_maxCurveDataValue(HUGE_VAL) + : m_minCurveDataValue(-std::numeric_limits::max()) + , m_maxCurveDataValue(std::numeric_limits::max()) { CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", ""); CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_minCurveValue, "MinCurveValue", -HUGE_VAL, "Minimum Curve Value", "", "Clip curve values below this.", ""); - CAF_PDM_InitField(&m_maxCurveValue, "MaxCurveValue", HUGE_VAL, "Maximum Curve Value", "", "Clip curve values above this.", ""); - m_minCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - m_maxCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_minCurveUIValue, "MinCurveValue", -std::numeric_limits::max(), "Minimum Curve Value", "", "Clip curve values below this.", ""); + CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits::max(), "Maximum Curve Value", "", "Clip curve values above this.", ""); CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", ""); @@ -164,17 +161,17 @@ void Rim3dWellLogCurve::setColor(const cvf::Color3f& color) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Rim3dWellLogCurve::minCurveValue() const +float Rim3dWellLogCurve::minCurveUIValue() const { - return m_minCurveValue(); + return m_minCurveUIValue(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double Rim3dWellLogCurve::maxCurveValue() const +float Rim3dWellLogCurve::maxCurveUIValue() const { - return m_maxCurveValue(); + return m_maxCurveUIValue(); } //-------------------------------------------------------------------------------------------------- @@ -212,8 +209,8 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) // Disable filled draw style in the GUI because of triangle stitching issue #2860. // configurationGroup->add(&m_drawStyle); configurationGroup->add(&m_color); - configurationGroup->add(&m_minCurveValue); - configurationGroup->add(&m_maxCurveValue); + configurationGroup->add(&m_minCurveUIValue); + configurationGroup->add(&m_maxCurveUIValue); } //-------------------------------------------------------------------------------------------------- @@ -221,24 +218,10 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) //-------------------------------------------------------------------------------------------------- void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - caf::PdmUiDoubleSliderEditorAttribute* sliderAttribute = dynamic_cast(attribute); - if (sliderAttribute) + if (m_minCurveDataValue == -std::numeric_limits::max() && + m_maxCurveDataValue == std::numeric_limits::max()) { - if (m_minCurveDataValue == -HUGE_VAL && - m_maxCurveDataValue == HUGE_VAL) - { - this->resetMinMaxValues(); - } - if (field == &m_minCurveValue) - { - sliderAttribute->m_minimum = m_minCurveDataValue; - sliderAttribute->m_maximum = m_maxCurveDataValue; - } - else if (field == &m_maxCurveValue) - { - sliderAttribute->m_minimum = m_minCurveDataValue; - sliderAttribute->m_maximum = m_maxCurveDataValue; - } + this->resetMinMaxValues(); } } @@ -298,8 +281,8 @@ void Rim3dWellLogCurve::resetMinMaxValues() std::vector values; std::vector measuredDepths; this->curveValuesAndMds(&values, &measuredDepths); - double foundMinValue = HUGE_VAL; - double foundMaxValue = -HUGE_VAL; + double foundMinValue = std::numeric_limits::max(); + double foundMaxValue = -std::numeric_limits::max(); for (double value : values) { if (RigCurveDataTools::isValidValue(value, false)) @@ -309,11 +292,12 @@ void Rim3dWellLogCurve::resetMinMaxValues() } } - // Update data boundaries m_minCurveDataValue = foundMinValue; m_maxCurveDataValue = foundMaxValue; - // Update selected GUI boundaries - m_minCurveValue = m_minCurveDataValue; - m_maxCurveValue = m_maxCurveDataValue; + m_minCurveUIValue = m_minCurveDataValue; + m_maxCurveUIValue = m_maxCurveDataValue; + + m_minCurveUIValue.uiCapability()->setUiName(QString("Minimum Curve Value (%1)").arg(m_minCurveDataValue)); + m_maxCurveUIValue.uiCapability()->setUiName(QString("Maximum Curve Value (%1)").arg(m_maxCurveDataValue)); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index e0c4ef85bf..244b58584e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -78,8 +78,8 @@ public: void setColor(const cvf::Color3f& color); - double minCurveValue() const; - double maxCurveValue() const; + float minCurveUIValue() const; + float maxCurveUIValue() const; void resetMinMaxValuesAndUpdateUI(); bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, cvf::Vec3d* closestPoint, @@ -101,10 +101,10 @@ protected: caf::PdmField m_drawPlane; caf::PdmField m_drawStyle; caf::PdmField m_color; - caf::PdmField m_minCurveValue; - caf::PdmField m_maxCurveValue; - double m_minCurveDataValue; - double m_maxCurveDataValue; + caf::PdmField m_minCurveUIValue; + caf::PdmField m_maxCurveUIValue; + float m_minCurveDataValue; + float m_maxCurveDataValue; cvf::ref m_geometryGenerator; private: caf::PdmField m_showCurve;