From 714aafc05ce5b6d0014e77090a06e9ab8f38e32a Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 9 Jul 2018 08:54:59 +0200 Subject: [PATCH] #3155 Slightly tweak X-autozoom so it zooms to the nearest outside minor tick. * Looks much better and makes the problem of having tick labels overlap with neighbour tracks much rarer. --- .../ProjectDataModel/RimWellLogPlot.cpp | 1 + .../ProjectDataModel/RimWellLogTrack.cpp | 22 +++++++++++++++---- .../ProjectDataModel/RimWellLogTrack.h | 4 +++- .../UserInterface/RiuWellLogPlot.cpp | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index ecc50f414f..f77be785fb 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -643,6 +643,7 @@ void RimWellLogPlot::updateTracks(bool autoScaleXAxis) { m_tracks[tIdx]->setAutoScaleXEnabled(true); m_tracks[tIdx]->calculateXZoomRangeAndUpdateQwt(); + m_tracks[tIdx]->updateAxisAndGridTickIntervals(); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 38ea481f07..5671c3b8de 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -248,7 +248,6 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { updateParentPlotLayout(); updateAxisAndGridTickIntervals(); - m_wellLogTrackPlotWidget->replot(); } else if (changedField == &m_explicitTickIntervals) { @@ -262,7 +261,6 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, if (!m_explicitTickIntervals()) { updateAxisAndGridTickIntervals(); - m_wellLogTrackPlotWidget->replot(); } } else if (changedField == &m_xAxisGridVisibility || @@ -270,7 +268,6 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, changedField == &m_minorTickInterval) { updateAxisAndGridTickIntervals(); - m_wellLogTrackPlotWidget->replot(); } else if (changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax) { @@ -284,7 +281,6 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateEditors(); updateParentPlotLayout(); updateAxisAndGridTickIntervals(); - m_wellLogTrackPlotWidget->replot(); // TODO: See if we can get rid of duplicate replot } else if (changedField == &m_isAutoScaleXEnabled) { @@ -495,6 +491,7 @@ void RimWellLogTrack::updateAxisAndGridTickIntervals() m_wellLogTrackPlotWidget->enableDepthGridLines(true, true); break; } + m_wellLogTrackPlotWidget->replot(); } //-------------------------------------------------------------------------------------------------- @@ -977,6 +974,11 @@ void RimWellLogTrack::calculateXZoomRange() } } + if (m_minorTickInterval() != 0.0) + { + std::tie(minValue, maxValue) = adjustXRange(minValue, maxValue, m_minorTickInterval()); + } + m_visibleXRangeMin = minValue; m_visibleXRangeMax = maxValue; @@ -1186,6 +1188,18 @@ bool RimWellLogTrack::isFirstVisibleTrackInPlot() const return plot->firstVisibleTrackIndex() == ownIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimWellLogTrack::adjustXRange(double minValue, double maxValue, double tickInterval) +{ + double minRemainder = std::fmod(minValue, tickInterval); + double maxRemainder = std::fmod(maxValue, tickInterval); + double adjustedMin = minValue - minRemainder; + double adjustedMax = maxValue + (tickInterval - maxRemainder); + return std::make_pair(adjustedMin, adjustedMax); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 3cb2eb395c..ca51ea041f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -131,11 +131,11 @@ public: void uiOrderingForXAxisSettings(caf::PdmUiOrdering& uiOrdering); void setFormationsForCaseWithSimWellOnly(bool caseWithSimWellOnly); + void updateAxisAndGridTickIntervals(); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; void updateParentPlotLayout(); - void updateAxisAndGridTickIntervals(); virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual caf::PdmFieldHandle* objectToggleField() override; @@ -168,6 +168,8 @@ private: void updateAxisScaleEngine(); bool isFirstVisibleTrackInPlot() const; + std::pair adjustXRange(double minValue, double maxValue, double tickInterval); + private: QString m_xAxisTitle; diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 4079ebc38c..cf26ed47cd 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -380,7 +380,7 @@ void RiuWellLogPlot::placeChildWidgets(int frameHeight, int frameWidth) positionTitle(frameWidth); - const int trackPadding = 0; + const int trackPadding = 2; std::map trackWidths = calculateTrackWidthsToMatchFrame(frameWidth); size_t visibleTrackCount = trackWidths.size();