#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();
}
}