#5585 Improve the way we decide on autozoom for the X-range in Well Log Tracks

This commit is contained in:
Gaute Lindkvist
2020-04-15 09:29:04 +02:00
committed by Magne Sjaastad
parent 0b47e27e89
commit 7b445a7fb7
2 changed files with 30 additions and 25 deletions

View File

@@ -263,7 +263,7 @@ void RimWellLogCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& newValue )
{
RimPlotCurve::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_showCurve )
if ( changedField == &m_showCurve && m_showCurve() )
{
updateZoomInParentPlot();
}

View File

@@ -82,6 +82,8 @@
#include <QWheelEvent>
#include <algorithm>
#define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0
#define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0
#define RI_SCROLLWHEEL_ZOOMFACTOR 1.1
@@ -1252,17 +1254,20 @@ void RimWellLogTrack::setAutoScaleYEnabled( bool enabled )
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAutoScaleXIfNecessary()
{
const double eps = 1.0e-8;
calculateXZoomRange();
// If the new range is larger than the existing
if ( m_availableXRangeMin < m_visibleXRangeMin || m_availableXRangeMax > m_visibleXRangeMax )
{
setAutoScaleXEnabled( true );
}
// If the new range is much smaller than the existing
if ( std::abs( m_availableXRangeMax - m_availableXRangeMin ) < 0.1 * std::abs( m_visibleXRangeMax - m_visibleXRangeMin ) )
double maxRange = std::max( m_visibleXRangeMax - m_visibleXRangeMin, m_availableXRangeMax - m_availableXRangeMin );
double maxLow = std::max( m_visibleXRangeMin(), m_availableXRangeMin );
double minHigh = std::min( m_visibleXRangeMax(), m_availableXRangeMax );
double overlap = minHigh - maxLow;
if ( maxRange < eps || overlap < eps * maxRange )
{
setAutoScaleXEnabled( true );
}
updateXZoom();
}