#5456 Auto zoom X in Well Log Plots if the range changes considerably when changing curve data

This commit is contained in:
Gaute Lindkvist 2020-02-04 09:45:32 +01:00
parent cb30841d1e
commit 228b651789
4 changed files with 142 additions and 63 deletions

View File

@ -175,33 +175,42 @@ void RimWellLogCurve::updateZoomInParentPlot()
{
const double eps = 1.0e-8;
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
double minPlotDepth, maxPlotDepth;
wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth );
RimWellLogTrack* wellLogTrack;
firstAncestorOrThisOfType( wellLogTrack );
bool updatePlotZoom = false;
if ( minPlotDepth == std::numeric_limits<double>::infinity() ||
maxPlotDepth == -std::numeric_limits<double>::infinity() )
if ( wellLogTrack )
{
wellLogTrack->setAutoScaleXIfNecessary();
RimWellLogPlot* wellLogPlot;
wellLogTrack->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
updatePlotZoom = true;
}
else
{
double plotRange = std::abs( maxPlotDepth - minPlotDepth );
double minCurveDepth, maxCurveDepth;
m_curveData->calculateDepthRange( wellLogPlot->depthType(),
wellLogPlot->depthUnit(),
&minCurveDepth,
&maxCurveDepth );
updatePlotZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
maxCurveDepth > maxPlotDepth + eps * plotRange;
}
if ( updatePlotZoom )
{
wellLogPlot->setAutoScaleDepthEnabled( true );
double minPlotDepth, maxPlotDepth;
wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth );
bool updateDepthZoom = false;
if ( minPlotDepth == std::numeric_limits<double>::infinity() ||
maxPlotDepth == -std::numeric_limits<double>::infinity() )
{
updateDepthZoom = true;
}
else
{
double plotRange = std::abs( maxPlotDepth - minPlotDepth );
double minCurveDepth, maxCurveDepth;
m_curveData->calculateDepthRange( wellLogPlot->depthType(),
wellLogPlot->depthUnit(),
&minCurveDepth,
&maxCurveDepth );
updateDepthZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
maxCurveDepth > maxPlotDepth + eps * plotRange;
}
if ( updateDepthZoom )
{
wellLogPlot->setAutoScaleDepthEnabled( true );
}
wellLogPlot->updateZoom();
}
}
@ -245,3 +254,17 @@ void RimWellLogCurve::calculateCurveDataXRange()
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
RimPlotCurve::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_showCurve )
{
updateZoomInParentPlot();
}
}

View File

@ -80,6 +80,7 @@ protected:
void updateLegendsInPlot() override;
void setOverrideCurveDataXRange( double minimumValue, double maximumValue );
void calculateCurveDataXRange();
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
private:
cvf::ref<RigWellLogCurveData> m_curveData;

View File

@ -151,6 +151,11 @@ void AppEnum<RiuPlotAnnotationTool::RegionDisplay>::setUp()
///
//--------------------------------------------------------------------------------------------------
RimWellLogTrack::RimWellLogTrack()
: m_availableXRangeMin( RI_LOGPLOTTRACK_MINX_DEFAULT )
, m_availableXRangeMax( RI_LOGPLOTTRACK_MAXX_DEFAULT )
, m_availableDepthRangeMin( RI_LOGPLOTTRACK_MINX_DEFAULT )
, m_availableDepthRangeMax( RI_LOGPLOTTRACK_MAXX_DEFAULT )
{
CAF_PDM_InitObject( "Track", ":/WellLogTrack16x16.png", "", "" );
@ -163,12 +168,12 @@ RimWellLogTrack::RimWellLogTrack()
CAF_PDM_InitField( &m_visibleXRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" );
CAF_PDM_InitField( &m_visibleXRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" );
CAF_PDM_InitField( &m_visibleYRangeMin, "VisibleYRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" );
CAF_PDM_InitField( &m_visibleYRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" );
m_visibleYRangeMin.uiCapability()->setUiHidden( true );
m_visibleYRangeMin.xmlCapability()->disableIO();
m_visibleYRangeMax.uiCapability()->setUiHidden( true );
m_visibleYRangeMax.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_visibleDepthRangeMin, "VisibleYRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" );
CAF_PDM_InitField( &m_visibleDepthRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" );
m_visibleDepthRangeMin.uiCapability()->setUiHidden( true );
m_visibleDepthRangeMin.xmlCapability()->disableIO();
m_visibleDepthRangeMax.uiCapability()->setUiHidden( true );
m_visibleDepthRangeMax.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "" );
m_isAutoScaleXEnabled.uiCapability()->setUiHidden( true );
@ -344,11 +349,6 @@ void RimWellLogTrack::calculateXZoomRange()
stCurve->updateStackedPlotData();
}
if ( !m_isAutoScaleXEnabled() )
{
return;
}
double minValue = HUGE_VAL;
double maxValue = -HUGE_VAL;
@ -387,11 +387,8 @@ void RimWellLogTrack::calculateXZoomRange()
std::tie( minValue, maxValue ) = adjustXRange( minValue, maxValue, m_minorTickInterval() );
}
m_visibleXRangeMin = minValue;
m_visibleXRangeMax = maxValue;
computeAndSetXRangeMinForLogarithmicScale();
updateEditors();
m_availableXRangeMin = minValue;
m_availableXRangeMax = maxValue;
}
//--------------------------------------------------------------------------------------------------
@ -442,8 +439,8 @@ void RimWellLogTrack::calculateYZoomRange()
}
}
m_visibleYRangeMin = minDepth;
m_visibleYRangeMax = maxDepth;
m_availableDepthRangeMin = minDepth;
m_availableDepthRangeMax = maxDepth;
}
//--------------------------------------------------------------------------------------------------
@ -453,9 +450,15 @@ void RimWellLogTrack::updateXZoom()
{
if ( !m_plotWidget ) return;
calculateXZoomRange();
if ( m_isAutoScaleXEnabled )
{
calculateXZoomRange();
m_visibleXRangeMin = m_availableXRangeMin;
m_visibleXRangeMax = m_availableXRangeMax;
computeAndSetXRangeMinForLogarithmicScale();
updateEditors();
}
updateXAxisAndGridTickIntervals();
@ -479,7 +482,7 @@ void RimWellLogTrack::updateYZoom()
{
if ( !m_plotWidget ) return;
m_plotWidget->setAxisRange( QwtPlot::yLeft, m_visibleYRangeMin(), m_visibleYRangeMax() );
m_plotWidget->setAxisRange( QwtPlot::yLeft, m_visibleDepthRangeMin(), m_visibleDepthRangeMax() );
}
//--------------------------------------------------------------------------------------------------
@ -554,7 +557,6 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
if ( m_isAutoScaleXEnabled() )
{
calculateXZoomRange();
updateXZoom();
m_plotWidget->scheduleReplot();
}
@ -568,7 +570,6 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
m_explicitTickIntervals.uiCapability()->setUiHidden( m_isLogarithmicScaleEnabled() );
calculateXZoomRange();
updateXZoom();
m_plotWidget->scheduleReplot();
}
@ -863,10 +864,10 @@ void RimWellLogTrack::updateZoomFromQwt()
QwtInterval xInterval = m_plotWidget->axisRange( QwtPlot::xTop );
QwtInterval depthInterval = m_plotWidget->axisRange( QwtPlot::yLeft );
m_visibleXRangeMin = xInterval.minValue();
m_visibleXRangeMax = xInterval.maxValue();
m_visibleYRangeMin = depthInterval.minValue();
m_visibleYRangeMax = depthInterval.maxValue();
m_visibleXRangeMin = xInterval.minValue();
m_visibleXRangeMax = xInterval.maxValue();
m_visibleDepthRangeMin = depthInterval.minValue();
m_visibleDepthRangeMax = depthInterval.maxValue();
}
//--------------------------------------------------------------------------------------------------
@ -1048,8 +1049,8 @@ void RimWellLogTrack::deleteAllCurves()
void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX )
{
calculateXZoomRange();
*minX = m_visibleXRangeMin;
*maxX = m_visibleXRangeMax;
*minX = m_availableXRangeMin;
*maxX = m_availableXRangeMax;
}
//--------------------------------------------------------------------------------------------------
@ -1058,8 +1059,28 @@ void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX )
void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximumDepth )
{
calculateYZoomRange();
*minimumDepth = m_visibleYRangeMin;
*maximumDepth = m_visibleYRangeMax;
*minimumDepth = m_availableDepthRangeMin;
*maximumDepth = m_availableDepthRangeMax;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::visibleXAxisRange( double* minX, double* maxX )
{
CAF_ASSERT( minX && maxX );
*minX = m_visibleXRangeMin;
*maxX = m_visibleXRangeMax;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::visibleDepthRange( double* minDepth, double* maxDepth )
{
CAF_ASSERT( minDepth && maxDepth );
*minDepth = m_visibleDepthRangeMin;
*maxDepth = m_visibleDepthRangeMax;
}
//--------------------------------------------------------------------------------------------------
@ -1176,9 +1197,36 @@ void RimWellLogTrack::setAutoScaleXEnabled( bool enabled )
}
//--------------------------------------------------------------------------------------------------
/// Empty implementation as Well Log Tracks always has depth set by Well Log Plot
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAutoScaleYEnabled( bool enabled ) {}
void RimWellLogTrack::setAutoScaleYEnabled( bool enabled )
{
if ( enabled )
{
m_visibleDepthRangeMin = m_availableDepthRangeMin;
m_visibleDepthRangeMax = m_availableDepthRangeMax;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAutoScaleXIfNecessary()
{
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 ) )
{
setAutoScaleXEnabled( true );
}
updateXZoom();
}
//--------------------------------------------------------------------------------------------------
///
@ -1391,8 +1439,8 @@ void RimWellLogTrack::setVisibleXRange( double minValue, double maxValue )
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setVisibleYRange( double minValue, double maxValue )
{
m_visibleYRangeMin = minValue;
m_visibleYRangeMax = maxValue;
m_visibleDepthRangeMin = minValue;
m_visibleDepthRangeMax = maxValue;
}
//--------------------------------------------------------------------------------------------------
@ -1543,8 +1591,6 @@ void RimWellLogTrack::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
calculateXZoomRange();
calculateYZoomRange();
updateZoomInQwt();
}

View File

@ -140,10 +140,14 @@ public:
void setAutoScaleXEnabled( bool enabled ) override;
void setAutoScaleYEnabled( bool enabled ) override;
void setAutoScaleXIfNecessary();
void availableXAxisRange( double* minX, double* maxX );
void availableDepthRange( double* minimumDepth, double* maximumDepth );
void visibleXAxisRange( double* minX, double* maxX );
void visibleDepthRange( double* minimumDepth, double* maximumDepth );
void setVisibleXRange( double minValue, double maxValue );
void setVisibleYRange( double minValue, double maxValue );
@ -283,8 +287,8 @@ private:
caf::PdmChildArrayField<RimWellLogCurve*> m_curves;
caf::PdmField<double> m_visibleXRangeMin;
caf::PdmField<double> m_visibleXRangeMax;
caf::PdmField<double> m_visibleYRangeMin;
caf::PdmField<double> m_visibleYRangeMax;
caf::PdmField<double> m_visibleDepthRangeMin;
caf::PdmField<double> m_visibleDepthRangeMax;
caf::PdmField<bool> m_isAutoScaleXEnabled;
caf::PdmField<bool> m_isLogarithmicScaleEnabled;
@ -326,4 +330,9 @@ private:
QPointer<RiuWellLogTrack> m_plotWidget;
std::unique_ptr<RiuPlotAnnotationTool> m_annotationTool;
double m_availableXRangeMin;
double m_availableXRangeMax;
double m_availableDepthRangeMin;
double m_availableDepthRangeMax;
};