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,33 +175,42 @@ void RimWellLogCurve::updateZoomInParentPlot()
|
|||||||
{
|
{
|
||||||
const double eps = 1.0e-8;
|
const double eps = 1.0e-8;
|
||||||
|
|
||||||
RimWellLogPlot* wellLogPlot;
|
RimWellLogTrack* wellLogTrack;
|
||||||
firstAncestorOrThisOfType( wellLogPlot );
|
firstAncestorOrThisOfType( wellLogTrack );
|
||||||
if ( wellLogPlot )
|
|
||||||
{
|
|
||||||
double minPlotDepth, maxPlotDepth;
|
|
||||||
wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth );
|
|
||||||
|
|
||||||
bool updatePlotZoom = false;
|
if ( wellLogTrack )
|
||||||
if ( minPlotDepth == std::numeric_limits<double>::infinity() ||
|
{
|
||||||
maxPlotDepth == -std::numeric_limits<double>::infinity() )
|
wellLogTrack->setAutoScaleXIfNecessary();
|
||||||
|
|
||||||
|
RimWellLogPlot* wellLogPlot;
|
||||||
|
wellLogTrack->firstAncestorOrThisOfType( wellLogPlot );
|
||||||
|
|
||||||
|
if ( wellLogPlot )
|
||||||
{
|
{
|
||||||
updatePlotZoom = true;
|
double minPlotDepth, maxPlotDepth;
|
||||||
}
|
wellLogPlot->availableDepthRange( &minPlotDepth, &maxPlotDepth );
|
||||||
else
|
|
||||||
{
|
bool updateDepthZoom = false;
|
||||||
double plotRange = std::abs( maxPlotDepth - minPlotDepth );
|
if ( minPlotDepth == std::numeric_limits<double>::infinity() ||
|
||||||
double minCurveDepth, maxCurveDepth;
|
maxPlotDepth == -std::numeric_limits<double>::infinity() )
|
||||||
m_curveData->calculateDepthRange( wellLogPlot->depthType(),
|
{
|
||||||
wellLogPlot->depthUnit(),
|
updateDepthZoom = true;
|
||||||
&minCurveDepth,
|
}
|
||||||
&maxCurveDepth );
|
else
|
||||||
updatePlotZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
|
{
|
||||||
maxCurveDepth > maxPlotDepth + eps * plotRange;
|
double plotRange = std::abs( maxPlotDepth - minPlotDepth );
|
||||||
}
|
double minCurveDepth, maxCurveDepth;
|
||||||
if ( updatePlotZoom )
|
m_curveData->calculateDepthRange( wellLogPlot->depthType(),
|
||||||
{
|
wellLogPlot->depthUnit(),
|
||||||
wellLogPlot->setAutoScaleDepthEnabled( true );
|
&minCurveDepth,
|
||||||
|
&maxCurveDepth );
|
||||||
|
updateDepthZoom = minCurveDepth < minPlotDepth - eps * plotRange ||
|
||||||
|
maxCurveDepth > maxPlotDepth + eps * plotRange;
|
||||||
|
}
|
||||||
|
if ( updateDepthZoom )
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
@ -863,10 +864,10 @@ void RimWellLogTrack::updateZoomFromQwt()
|
|||||||
QwtInterval xInterval = m_plotWidget->axisRange( QwtPlot::xTop );
|
QwtInterval xInterval = m_plotWidget->axisRange( QwtPlot::xTop );
|
||||||
QwtInterval depthInterval = m_plotWidget->axisRange( QwtPlot::yLeft );
|
QwtInterval depthInterval = m_plotWidget->axisRange( QwtPlot::yLeft );
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user