diff --git a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index df99ca855a..91ffb8a1ba 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -108,6 +108,7 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) plot->updateAvailableDepthRange(); plot->setVisibleDepthRangeFromContents(); + plotTrace->updateXAxisRangeFromCurves(); plotTrace->viewer()->replot(); RiaApplication::instance()->project()->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 0ad3a4f267..a5bf6dc605 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -193,6 +193,11 @@ void RimWellLogExtractionCurve::updatePlotData() RimWellLogPlotTrace* plotTrace; firstAnchestorOrThisOfType(plotTrace); + if (plotTrace) + { + plotTrace->updateXAxisRangeFromCurves(); + } + RimWellLogPlot* wellLogPlot; firstAnchestorOrThisOfType(wellLogPlot); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index 96a241b6d4..5392b39726 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -119,17 +119,26 @@ void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { RimWellLogPlotCurve::fieldChangedByUi(changedField, oldValue, newValue); + RimWellLogPlot* wellLoglot; + firstAnchestorOrThisOfType(wellLoglot); + + RimWellLogPlotTrace* wellLoglotTrace; + firstAnchestorOrThisOfType(wellLoglotTrace); + if (changedField == &m_wellPath) { this->updatePlotData(); - RimWellLogPlot* wellLoglot; - firstAnchestorOrThisOfType(wellLoglot); if (wellLoglot) { wellLoglot->updateAvailableDepthRange(); wellLoglot->setVisibleDepthRangeFromContents(); } + + if (wellLoglotTrace) + { + wellLoglotTrace->updateXAxisRangeFromCurves(); + } } else if (changedField == &m_wellLogChannnelName) { @@ -140,8 +149,6 @@ void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie this->updatePlotData(); - RimWellLogPlot* wellLoglot; - firstAnchestorOrThisOfType(wellLoglot); if (wellLoglot) { if (!wellLoglot->hasAvailableDepthRange()) @@ -149,6 +156,11 @@ void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie wellLoglot->updateAvailableDepthRange(); wellLoglot->setVisibleDepthRangeFromContents(); } + + if (wellLoglotTrace) + { + wellLoglotTrace->updateXAxisRangeFromCurves(); + } } } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp index dc441fb78c..3668b35018 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp @@ -18,7 +18,9 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimWellLogPlotCurve.h" + #include "RimWellLogPlot.h" + #include "RiuWellLogTracePlot.h" #include "RiuWellLogPlotCurve.h" @@ -157,6 +159,26 @@ bool RimWellLogPlotCurve::depthRange(double* minimumDepth, double* maximumDepth) 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; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -180,4 +202,3 @@ QwtPlotCurve* RimWellLogPlotCurve::plotCurve() const { return m_plotCurve; } - diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h index c61a24ec12..547f9c540a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h @@ -45,6 +45,7 @@ public: void setColor(const cvf::Color3f& color); bool depthRange(double* minimumDepth, double* maximumDepth) const; + bool valueRange(double* minimumValue, double* maximumValue) const; void setPlot(RiuWellLogTracePlot* plot); void detachCurve(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp index a5bfe24ebc..9c052e4581 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp @@ -172,6 +172,8 @@ void RimWellLogPlotTrace::loadDataAndUpdate() { curves[cIdx]->updatePlotData(); } + + updateXAxisRangeFromCurves(); } //-------------------------------------------------------------------------------------------------- @@ -233,6 +235,49 @@ void RimWellLogPlotTrace::updateAxisRangesAndReplot() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotTrace::updateXAxisRangeFromCurves() +{ + double minValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + + size_t curveCount = curves.size(); + if (curveCount < 1) return; + + bool rangeUpdated = false; + + for (size_t cIdx = 0; cIdx < curveCount; cIdx++) + { + double minCurveValue = HUGE_VAL; + double maxCurveValue = -HUGE_VAL; + + if (curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue)) + { + if (minCurveValue < minValue) + { + minValue = minCurveValue; + rangeUpdated = true; + } + + if (maxCurveValue > maxValue) + { + maxValue = maxCurveValue; + rangeUpdated = true; + } + } + } + + if (rangeUpdated) + { + m_minimumValue = minValue; + m_maximumValue = maxValue; + + updateConnectedEditors(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h index e37772c6dd..41f5ecc6e9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h @@ -53,6 +53,7 @@ public: bool availableDepthRange(double* minimumDepth, double* maximumDepth); void updateAxisRangesAndReplot(); + void updateXAxisRangeFromCurves(); RiuWellLogTracePlot* viewer();