diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 18fb03df40..364fa48bb7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -196,8 +196,8 @@ QList RimWellLogPlot::calculateValueOptions(const caf::P } else if (fieldNeedingOptions == &m_trackLegendsHorizontal) { - options.push_back(caf::PdmOptionItemInfo("Vertical", false)); - options.push_back(caf::PdmOptionItemInfo("Horizontal", true)); + options.push_back(caf::PdmOptionItemInfo("Vertical", QVariant::fromValue(false))); + options.push_back(caf::PdmOptionItemInfo("Horizontal", QVariant::fromValue(true))); } (*useOptionsOnly) = true; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 4c7b302999..04e3ab6030 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -285,6 +285,10 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax); m_wellLogTrackPlotWidget->replot(); m_isAutoScaleXEnabled = false; + bool emptyRange = std::abs(m_visibleXRangeMax() - m_visibleXRangeMin) < 1.0e-6 * std::max(1.0, std::max(m_visibleXRangeMax(), m_visibleXRangeMin())); + m_explicitTickIntervals.uiCapability()->setUiReadOnly(emptyRange); + m_showXGridLines.uiCapability()->setUiReadOnly(emptyRange); + updateEditors(); updateParentPlotLayout(); updateAxisAndGridTickIntervals(); @@ -465,7 +469,7 @@ void RimWellLogTrack::updateAxisAndGridTickIntervals() xMinorTickIntervals = 10; break; } - m_wellLogTrackPlotWidget->setAutoTickIntervals(xMajorTickIntervals, xMinorTickIntervals); + m_wellLogTrackPlotWidget->setAutoTickIntervalCounts(xMajorTickIntervals, xMinorTickIntervals); } switch (m_showXGridLines()) @@ -685,11 +689,15 @@ void RimWellLogTrack::loadDataAndUpdate() this->updateAxisScaleEngine(); this->updateFormationNamesOnPlot(); this->applyXZoomFromVisibleRange(); - this->updateAxisAndGridTickIntervals(); } + this->updateAxisAndGridTickIntervals(); m_majorTickInterval.uiCapability()->setUiHidden(!m_explicitTickIntervals()); m_minorTickInterval.uiCapability()->setUiHidden(!m_explicitTickIntervals()); + + bool emptyRange = std::abs(m_visibleXRangeMax() - m_visibleXRangeMin) < 1.0e-6 * std::max(1.0, std::max(m_visibleXRangeMax(), m_visibleXRangeMin())); + m_explicitTickIntervals.uiCapability()->setUiReadOnly(emptyRange); + m_showXGridLines.uiCapability()->setUiReadOnly(emptyRange); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.cpp b/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.cpp index 09820f2159..f87e7cc607 100644 --- a/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.cpp +++ b/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.cpp @@ -22,7 +22,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QwtScaleDiv RiuQwtLinearScaleEngine::divideScale(double x1, double x2, double majorStepInterval, double minorStepInterval) +QwtScaleDiv RiuQwtLinearScaleEngine::divideScaleWithExplicitIntervals(double x1, double x2, double majorStepInterval, double minorStepInterval) { QwtInterval interval(x1, x2); QwtInterval roundedInterval = this->align(interval, majorStepInterval); diff --git a/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.h b/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.h index 003d951a64..ec821f19df 100644 --- a/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.h +++ b/ApplicationCode/UserInterface/RiuQwtLinearScaleEngine.h @@ -28,5 +28,5 @@ class RiuQwtLinearScaleEngine : public QwtLinearScaleEngine { public: - QwtScaleDiv divideScale(double x1, double x2, double majorStepInterval, double minorStepInterval); + QwtScaleDiv divideScaleWithExplicitIntervals(double x1, double x2, double majorStepInterval, double minorStepInterval); }; diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp index 2dc9f1b0a1..1d315d72c0 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp @@ -315,7 +315,7 @@ void RiuWellLogTrack::setMajorAndMinorTickIntervals(double majorTickInterval, do if (scaleEngine) { QwtInterval currentRange = this->axisInterval(QwtPlot::xTop); - QwtScaleDiv scaleDiv = scaleEngine->divideScale(currentRange.minValue(), currentRange.maxValue(), majorTickInterval, minorTickInterval); + QwtScaleDiv scaleDiv = scaleEngine->divideScaleWithExplicitIntervals(currentRange.minValue(), currentRange.maxValue(), majorTickInterval, minorTickInterval); this->setAxisScaleDiv(QwtPlot::xTop, scaleDiv); } @@ -324,10 +324,10 @@ void RiuWellLogTrack::setMajorAndMinorTickIntervals(double majorTickInterval, do //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellLogTrack::setAutoTickIntervals(int maxMajorTickIntervals, int maxMinorTickIntervals) +void RiuWellLogTrack::setAutoTickIntervalCounts(int maxMajorTickIntervalCount, int maxMinorTickIntervalCount) { - this->setAxisMaxMajor(QwtPlot::xTop, maxMajorTickIntervals); - this->setAxisMaxMinor(QwtPlot::xTop, maxMinorTickIntervals); + this->setAxisMaxMajor(QwtPlot::xTop, maxMajorTickIntervalCount); + this->setAxisMaxMinor(QwtPlot::xTop, maxMinorTickIntervalCount); // Reapply axis limits to force Qwt to use the tick settings. QwtInterval currentRange = this->axisInterval(QwtPlot::xTop); this->setAxisScale(QwtPlot::xTop, currentRange.minValue(), currentRange.maxValue()); diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.h b/ApplicationCode/UserInterface/RiuWellLogTrack.h index f1cfaa9805..0a0f517b1d 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.h +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.h @@ -56,7 +56,7 @@ public: int widthScaleFactor() const; void enableGridLines(bool majorGridLines, bool minorGridLines); void setMajorAndMinorTickIntervals(double majorTickInterval, double minorTickInterval); - void setAutoTickIntervals(int maxMajorTickIntervals, int maxMinorTickIntervals); + void setAutoTickIntervalCounts(int maxMajorTickIntervalCount, int maxMinorTickIntervalCount); double getCurrentMajorTickInterval() const; double getCurrentMinorTickInterval() const; protected: