mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5456 Auto zoom X in Well Log Plots if the range changes considerably when changing curve data
This commit is contained in:
parent
cb30841d1e
commit
228b651789
@ -175,18 +175,26 @@ void RimWellLogCurve::updateZoomInParentPlot()
|
||||
{
|
||||
const double eps = 1.0e-8;
|
||||
|
||||
RimWellLogTrack* wellLogTrack;
|
||||
firstAncestorOrThisOfType( wellLogTrack );
|
||||
|
||||
if ( wellLogTrack )
|
||||
{
|
||||
wellLogTrack->setAutoScaleXIfNecessary();
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
firstAncestorOrThisOfType( wellLogPlot );
|
||||
wellLogTrack->firstAncestorOrThisOfType( wellLogPlot );
|
||||
|
||||
if ( wellLogPlot )
|
||||
{
|
||||
double minPlotDepth, maxPlotDepth;
|
||||
wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth );
|
||||
|
||||
bool updatePlotZoom = false;
|
||||
bool updateDepthZoom = false;
|
||||
if ( minPlotDepth == std::numeric_limits<double>::infinity() ||
|
||||
maxPlotDepth == -std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
updatePlotZoom = true;
|
||||
updateDepthZoom = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -196,12 +204,13 @@ void RimWellLogCurve::updateZoomInParentPlot()
|
||||
wellLogPlot->depthUnit(),
|
||||
&minCurveDepth,
|
||||
&maxCurveDepth );
|
||||
updatePlotZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
|
||||
updateDepthZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
|
||||
maxCurveDepth > maxPlotDepth + eps * plotRange;
|
||||
}
|
||||
if ( updatePlotZoom )
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
@ -865,8 +866,8 @@ void RimWellLogTrack::updateZoomFromQwt()
|
||||
|
||||
m_visibleXRangeMin = xInterval.minValue();
|
||||
m_visibleXRangeMax = xInterval.maxValue();
|
||||
m_visibleYRangeMin = depthInterval.minValue();
|
||||
m_visibleYRangeMax = depthInterval.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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user