#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,18 +175,26 @@ void RimWellLogCurve::updateZoomInParentPlot()
{ {
const double eps = 1.0e-8; const double eps = 1.0e-8;
RimWellLogTrack* wellLogTrack;
firstAncestorOrThisOfType( wellLogTrack );
if ( wellLogTrack )
{
wellLogTrack->setAutoScaleXIfNecessary();
RimWellLogPlot* wellLogPlot; RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType( wellLogPlot ); wellLogTrack->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot ) if ( wellLogPlot )
{ {
double minPlotDepth, maxPlotDepth; double minPlotDepth, maxPlotDepth;
wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth ); wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth );
bool updatePlotZoom = false; bool updateDepthZoom = false;
if ( minPlotDepth == std::numeric_limits<double>::infinity() || if ( minPlotDepth == std::numeric_limits<double>::infinity() ||
maxPlotDepth == -std::numeric_limits<double>::infinity() ) maxPlotDepth == -std::numeric_limits<double>::infinity() )
{ {
updatePlotZoom = true; updateDepthZoom = true;
} }
else else
{ {
@ -196,12 +204,13 @@ void RimWellLogCurve::updateZoomInParentPlot()
wellLogPlot->depthUnit(), wellLogPlot->depthUnit(),
&minCurveDepth, &minCurveDepth,
&maxCurveDepth ); &maxCurveDepth );
updatePlotZoom = minCurveDepth < minPlotDepth - eps * plotRange || updateDepthZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
maxCurveDepth > maxPlotDepth + eps * plotRange; maxCurveDepth > maxPlotDepth + eps * plotRange;
} }
if ( updatePlotZoom ) if ( updateDepthZoom )
{ {
wellLogPlot->setAutoScaleDepthEnabled( true ); wellLogPlot->setAutoScaleDepthEnabled( true );
}
wellLogPlot->updateZoom(); 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 updateLegendsInPlot() override;
void setOverrideCurveDataXRange( double minimumValue, double maximumValue ); void setOverrideCurveDataXRange( double minimumValue, double maximumValue );
void calculateCurveDataXRange(); void calculateCurveDataXRange();
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
private: private:
cvf::ref<RigWellLogCurveData> m_curveData; cvf::ref<RigWellLogCurveData> m_curveData;

View File

@ -151,6 +151,11 @@ void AppEnum<RiuPlotAnnotationTool::RegionDisplay>::setUp()
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellLogTrack::RimWellLogTrack() 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", "", "" ); 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_visibleXRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" );
CAF_PDM_InitField( &m_visibleXRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" ); 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_visibleDepthRangeMin, "VisibleYRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "" );
CAF_PDM_InitField( &m_visibleYRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" ); CAF_PDM_InitField( &m_visibleDepthRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "" );
m_visibleYRangeMin.uiCapability()->setUiHidden( true ); m_visibleDepthRangeMin.uiCapability()->setUiHidden( true );
m_visibleYRangeMin.xmlCapability()->disableIO(); m_visibleDepthRangeMin.xmlCapability()->disableIO();
m_visibleYRangeMax.uiCapability()->setUiHidden( true ); m_visibleDepthRangeMax.uiCapability()->setUiHidden( true );
m_visibleYRangeMax.xmlCapability()->disableIO(); m_visibleDepthRangeMax.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "" ); CAF_PDM_InitField( &m_isAutoScaleXEnabled, "AutoScaleX", true, "Auto Scale", "", "", "" );
m_isAutoScaleXEnabled.uiCapability()->setUiHidden( true ); m_isAutoScaleXEnabled.uiCapability()->setUiHidden( true );
@ -344,11 +349,6 @@ void RimWellLogTrack::calculateXZoomRange()
stCurve->updateStackedPlotData(); stCurve->updateStackedPlotData();
} }
if ( !m_isAutoScaleXEnabled() )
{
return;
}
double minValue = HUGE_VAL; double minValue = HUGE_VAL;
double maxValue = -HUGE_VAL; double maxValue = -HUGE_VAL;
@ -387,11 +387,8 @@ void RimWellLogTrack::calculateXZoomRange()
std::tie( minValue, maxValue ) = adjustXRange( minValue, maxValue, m_minorTickInterval() ); std::tie( minValue, maxValue ) = adjustXRange( minValue, maxValue, m_minorTickInterval() );
} }
m_visibleXRangeMin = minValue; m_availableXRangeMin = minValue;
m_visibleXRangeMax = maxValue; m_availableXRangeMax = maxValue;
computeAndSetXRangeMinForLogarithmicScale();
updateEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -442,8 +439,8 @@ void RimWellLogTrack::calculateYZoomRange()
} }
} }
m_visibleYRangeMin = minDepth; m_availableDepthRangeMin = minDepth;
m_visibleYRangeMax = maxDepth; m_availableDepthRangeMax = maxDepth;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -453,9 +450,15 @@ void RimWellLogTrack::updateXZoom()
{ {
if ( !m_plotWidget ) return; if ( !m_plotWidget ) return;
calculateXZoomRange();
if ( m_isAutoScaleXEnabled ) if ( m_isAutoScaleXEnabled )
{ {
calculateXZoomRange(); m_visibleXRangeMin = m_availableXRangeMin;
m_visibleXRangeMax = m_availableXRangeMax;
computeAndSetXRangeMinForLogarithmicScale();
updateEditors();
} }
updateXAxisAndGridTickIntervals(); updateXAxisAndGridTickIntervals();
@ -479,7 +482,7 @@ void RimWellLogTrack::updateYZoom()
{ {
if ( !m_plotWidget ) return; 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() ) if ( m_isAutoScaleXEnabled() )
{ {
calculateXZoomRange();
updateXZoom(); updateXZoom();
m_plotWidget->scheduleReplot(); m_plotWidget->scheduleReplot();
} }
@ -568,7 +570,6 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
} }
m_explicitTickIntervals.uiCapability()->setUiHidden( m_isLogarithmicScaleEnabled() ); m_explicitTickIntervals.uiCapability()->setUiHidden( m_isLogarithmicScaleEnabled() );
calculateXZoomRange();
updateXZoom(); updateXZoom();
m_plotWidget->scheduleReplot(); m_plotWidget->scheduleReplot();
} }
@ -865,8 +866,8 @@ void RimWellLogTrack::updateZoomFromQwt()
m_visibleXRangeMin = xInterval.minValue(); m_visibleXRangeMin = xInterval.minValue();
m_visibleXRangeMax = xInterval.maxValue(); m_visibleXRangeMax = xInterval.maxValue();
m_visibleYRangeMin = depthInterval.minValue(); m_visibleDepthRangeMin = depthInterval.minValue();
m_visibleYRangeMax = depthInterval.maxValue(); m_visibleDepthRangeMax = depthInterval.maxValue();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1048,8 +1049,8 @@ void RimWellLogTrack::deleteAllCurves()
void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX ) void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX )
{ {
calculateXZoomRange(); calculateXZoomRange();
*minX = m_visibleXRangeMin; *minX = m_availableXRangeMin;
*maxX = m_visibleXRangeMax; *maxX = m_availableXRangeMax;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1058,8 +1059,28 @@ void RimWellLogTrack::availableXAxisRange( double* minX, double* maxX )
void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximumDepth ) void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximumDepth )
{ {
calculateYZoomRange(); calculateYZoomRange();
*minimumDepth = m_visibleYRangeMin; *minimumDepth = m_availableDepthRangeMin;
*maximumDepth = m_visibleYRangeMax; *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 ) void RimWellLogTrack::setVisibleYRange( double minValue, double maxValue )
{ {
m_visibleYRangeMin = minValue; m_visibleDepthRangeMin = minValue;
m_visibleYRangeMax = maxValue; m_visibleDepthRangeMax = maxValue;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1543,8 +1591,6 @@ void RimWellLogTrack::zoomAll()
{ {
setAutoScaleXEnabled( true ); setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true ); setAutoScaleYEnabled( true );
calculateXZoomRange();
calculateYZoomRange();
updateZoomInQwt(); updateZoomInQwt();
} }

View File

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