Janitor: Update qwt to 6.2.0

This commit is contained in:
Magne Sjaastad
2022-03-18 13:16:07 +01:00
committed by GitHub
parent ffc84457c6
commit 8d3f381b4f
29 changed files with 130 additions and 36 deletions

View File

@@ -57,6 +57,7 @@
#include "cafPdmUiListEditor.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <cmath>
#include <limits>
#include <map>

View File

@@ -43,6 +43,7 @@
#include "qwt_plot.h"
#include "qwt_plot_barchart.h"
#include "qwt_text.h"
#include <limits>
#include <map>

View File

@@ -76,6 +76,7 @@
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_textlabel.h"
#include "qwt_text.h"
#include <QDateTime>
#include <QDebug>

View File

@@ -39,6 +39,7 @@
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_scale_draw.h"
#include "qwt_text.h"
#include <cmath>
#include <set>

View File

@@ -95,6 +95,8 @@
#include "caf.h"
#include "cvfAssert.h"
#include "qwt_scale_map.h"
#include <QWheelEvent>
#include <algorithm>

View File

@@ -24,9 +24,64 @@
#include "cvfMatrix3.h"
#include "RiaOffshoreSphericalCoords.h"
#include "qwt_curve_fitter.h"
#include "qwt_spline.h"
#include "qwt_spline_curve_fitter.h"
#include <algorithm>
#include <cmath>
int RigWellPathGeometryTools::lookup( double x, const QPolygonF& values )
{
#if 0
//qLowerBound/qHigherBound ???
#endif
int i1;
const int size = values.size();
if ( x <= values[0].x() )
i1 = 0;
else if ( x >= values[size - 2].x() )
i1 = size - 2;
else
{
i1 = 0;
int i2 = size - 2;
int i3 = 0;
while ( i2 - i1 > 1 )
{
i3 = i1 + ( ( i2 - i1 ) >> 1 );
if ( values[i3].x() > x )
i2 = i3;
else
i1 = i3;
}
}
return i1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigWellPathGeometryTools::value( double x, const QPolygonF& values )
{
if ( values.size() == 0 ) return 0.0;
const int i = lookup( x, values );
if ( i >= values.size() - 1 ) return values.back().y();
auto low = values[i];
auto high = values[i + 1];
auto delta = ( x - low.x() ) / ( high.x() - low.x() );
return ( 1 - delta ) * low.y() + delta * high.y();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -97,24 +152,24 @@ std::vector<double> RigWellPathGeometryTools::interpolateMdFromTvd( const std::v
std::vector<double> interpolatedMdValues;
interpolatedMdValues.reserve( tvdValuesToInterpolateFrom.size() );
QwtSpline spline = createSpline( originalMdValues, originalTvdValues );
std::vector<int> segmentStartIndices = findSplineSegmentsContainingRoots( spline, tvdValuesToInterpolateFrom );
auto splinePoints = createSplinePoints( originalMdValues, originalTvdValues );
std::vector<int> segmentStartIndices = findSplineSegmentsContainingRoots( splinePoints, tvdValuesToInterpolateFrom );
for ( size_t i = 0; i < segmentStartIndices.size(); ++i )
{
double currentTVDValue = tvdValuesToInterpolateFrom[i];
double startMD = spline.points().front().x();
double endMD = spline.points().back().y();
double startMD = splinePoints.front().x();
double endMD = splinePoints.back().y();
if ( segmentStartIndices[i] != -1 )
{
int startIndex = segmentStartIndices[i];
int endIndex = startIndex + 1;
// Search interval for best MD value
startMD = spline.points()[startIndex].x();
endMD = spline.points().back().y();
startMD = splinePoints[startIndex].x();
endMD = splinePoints.back().y();
if ( endIndex < spline.points().size() )
if ( endIndex < splinePoints.size() )
{
if ( !interpolatedMdValues.empty() )
{
@@ -125,10 +180,10 @@ std::vector<double> RigWellPathGeometryTools::interpolateMdFromTvd( const std::v
}
startMD = std::max( startMD, interpolatedMdValues.back() + 0.1 * mdDiff );
}
endMD = spline.points()[endIndex].x();
endMD = splinePoints[endIndex].x();
}
}
double mdValue = solveForX( spline, startMD, endMD, currentTVDValue );
double mdValue = solveForX( splinePoints, startMD, endMD, currentTVDValue );
interpolatedMdValues.push_back( mdValue );
}
return interpolatedMdValues;
@@ -193,7 +248,7 @@ std::pair<double, double>
///
//--------------------------------------------------------------------------------------------------
std::vector<int>
RigWellPathGeometryTools::findSplineSegmentsContainingRoots( const QwtSpline& spline,
RigWellPathGeometryTools::findSplineSegmentsContainingRoots( const QPolygonF& points,
const std::vector<double>& tvdValuesToInterpolateFrom )
{
std::vector<int> segmentStartIndices;
@@ -206,9 +261,9 @@ std::vector<int>
bool foundMatch = false;
// Increment current_it until we find an interval containing our TVD
while ( currentSplineStartIndex < spline.points().size() - 2 )
while ( currentSplineStartIndex < points.size() - 2 )
{
double diffCurrent = spline.points()[currentSplineStartIndex].y() - tvdValue;
double diffCurrent = points[currentSplineStartIndex].y() - tvdValue;
if ( std::abs( diffCurrent ) < 1.0e-8 ) // Current is matching the point
{
foundMatch = true;
@@ -217,7 +272,7 @@ std::vector<int>
int nextStartIndex = currentSplineStartIndex + 1;
double diffNext = spline.points()[nextStartIndex].y() - tvdValue;
double diffNext = points[nextStartIndex].y() - tvdValue;
if ( diffCurrent * diffNext < 0.0 ) // One is above, the other is below
{
foundMatch = true;
@@ -325,7 +380,7 @@ cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane( const s
//--------------------------------------------------------------------------------------------------
/// Golden-section minimization: https://en.wikipedia.org/wiki/Golden-section_search
//--------------------------------------------------------------------------------------------------
double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX, double maxX, double y )
double RigWellPathGeometryTools::solveForX( const QPolygonF& spline, double minX, double maxX, double y )
{
const double phi = ( 1.0 + std::sqrt( 5.0 ) ) / 2.0;
const double tol = 1.0e-8;
@@ -334,8 +389,8 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX
double c = b - ( b - a ) / phi;
double d = a + ( b - a ) / phi;
double fc = spline.value( c ) - y;
double fd = spline.value( d ) - y;
double fc = value( c, spline ) - y;
double fd = value( d, spline ) - y;
for ( int n = 0; n < 100; ++n )
{
@@ -350,7 +405,8 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX
d = c;
fd = fc;
c = b - ( b - a ) / phi;
fc = spline.value( c ) - y;
fc = value( c, spline ) - y;
}
else
{
@@ -358,7 +414,7 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX
c = d;
fc = fd;
d = a + ( b - a ) / phi;
fd = spline.value( d ) - y;
fd = value( d, spline ) - y;
}
}
return ( a + b ) / 2.0;
@@ -367,8 +423,8 @@ double RigWellPathGeometryTools::solveForX( const QwtSpline& spline, double minX
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtSpline RigWellPathGeometryTools::createSpline( const std::vector<double>& originalMdValues,
const std::vector<double>& originalTvdValues )
QPolygonF RigWellPathGeometryTools::createSplinePoints( const std::vector<double>& originalMdValues,
const std::vector<double>& originalTvdValues )
{
QPolygonF polygon;
for ( size_t i = 0; i < originalMdValues.size(); ++i )
@@ -376,7 +432,9 @@ QwtSpline RigWellPathGeometryTools::createSpline( const std::vector<double>& ori
polygon << QPointF( originalMdValues[i], originalTvdValues[i] );
}
QwtSplineCurveFitter curveFitter;
QPolygonF splinePoints = curveFitter.fitCurve( polygon );
double tolerance = 0.5;
auto splinePoints = curveFitter.spline()->polygon( polygon, tolerance );
if ( splinePoints.empty() ) splinePoints = polygon;
// Extend spline from 0.0 (if it does not already exist) to a large value for MD
// This is to force a specific and known extrapolation.
@@ -405,8 +463,5 @@ QwtSpline RigWellPathGeometryTools::createSpline( const std::vector<double>& ori
splinePoints.push_back( endPoint );
}
QwtSpline spline;
spline.setPoints( splinePoints );
return spline;
return splinePoints;
}

View File

@@ -20,12 +20,10 @@
#include "cvfVector3.h"
#include <qwt_curve_fitter.h>
#include <qwt_spline.h>
#include <vector>
#include <QPolygon>
#include <gsl/gsl>
#include <vector>
class RigWellPath;
@@ -56,10 +54,15 @@ private:
const std::vector<cvf::Vec3d>& vertices );
static cvf::Vec3d estimateDominantDirectionInXYPlane( const std::vector<cvf::Vec3d>& vertices );
static double solveForX( const QwtSpline& spline, double minX, double maxX, double y );
static double solveForX( const QPolygonF& spline, double minX, double maxX, double y );
static QwtSpline createSpline( const std::vector<double>& originalMdValues,
const std::vector<double>& originalTvdValues );
static std::vector<int> findSplineSegmentsContainingRoots( const QwtSpline& spline,
static QPolygonF createSplinePoints( const std::vector<double>& originalMdValues,
const std::vector<double>& originalTvdValues );
static std::vector<int> findSplineSegmentsContainingRoots( const QPolygonF& points,
const std::vector<double>& tvdValuesToInterpolateFrom );
// Temporary helper function to method removed from Qwt >= 6.2
static int lookup( double x, const QPolygonF& values );
static double value( double x, const QPolygonF& values );
};

View File

@@ -36,7 +36,9 @@
#include "qwt_scale_widget.h"
#include <QColor>
#include <QPainter>
#include <cmath>
#include <limits>
#include <map>

View File

@@ -41,6 +41,7 @@
#include "qwt_legend.h"
#include "qwt_plot.h"
#include "qwt_plot_zoomer.h"
#include "qwt_text.h"
#include <QBoxLayout>
#include <QContextMenuEvent>
@@ -48,6 +49,8 @@
#include <QLabel>
#include <QMenu>
#include <cmath> // Needed for HUGE_VAL on Linux
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -70,7 +70,7 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren
// Attach a zoomer for the right axis
m_zoomerRight = new RiuQwtPlotZoomer( qwtPlot()->canvas() );
m_zoomerRight->setAxis( QwtPlot::xTop, QwtPlot::yRight );
m_zoomerRight->setAxes( QwtPlot::xTop, QwtPlot::yRight );
m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff );
m_zoomerRight->initMousePattern( 1 );

View File

@@ -40,6 +40,7 @@
#include "cvfAssert.h"
#include <QPainterPath>
#include <QPen>
#include <QTimer>
#include <QWidget>

View File

@@ -45,6 +45,7 @@
#include <QMdiSubWindow>
#include <QMenu>
#include <QPagedPaintDevice>
#include <QPainter>
#include <QScrollArea>
#include <QScrollBar>
#include <QTimer>

View File

@@ -56,6 +56,7 @@
#include <QHBoxLayout>
#include <QMdiSubWindow>
#include <QMenu>
#include <QPainter>
#include <QScrollBar>
#include <QTimer>

View File

@@ -25,6 +25,7 @@
#include "qwt_plot.h"
#include "qwt_plot_zoneitem.h"
#include "qwt_text.h"
#include <QString>

View File

@@ -25,6 +25,7 @@
#include <memory>
#include <vector>
#include <QColor>
#include <QPointer>
class QString;

View File

@@ -38,6 +38,7 @@
#include "qwt_plot_marker.h"
#include "qwt_plot_picker.h"
#include "qwt_symbol.h"
#include "qwt_text.h"
#include <QComboBox>
#include <QDockWidget>

View File

@@ -26,6 +26,7 @@
#include "qwt_date_scale_draw.h"
#include "qwt_plot_curve.h"
#include "qwt_text.h"
#include <cfloat> // For DBL_MAX

View File

@@ -19,6 +19,8 @@
#include "RiuQwtDateScaleWrapper.h"
#include "RiuQwtPlotTools.h"
#include "qwt_text.h"
#include <set>
//--------------------------------------------------------------------------------------------------

View File

@@ -18,6 +18,8 @@
#include "RiuQwtLinearScaleEngine.h"
#include "qwt_interval.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -27,6 +27,7 @@
#include "RiuQwtSymbol.h"
#include "qwt_date.h"
#include "qwt_graphic.h"
#include "qwt_interval_symbol.h"
#include "qwt_painter.h"
#include "qwt_plot_curve.h"
@@ -35,6 +36,7 @@
#include "qwt_scale_map.h"
#include "qwt_symbol.h"
#include <cmath>
#include <limits>
//--------------------------------------------------------------------------------------------------

View File

@@ -18,6 +18,10 @@
#include "RiuQwtPlotItemGroup.h"
#include "qwt_graphic.h"
#include <QRect>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -20,8 +20,10 @@
#include "caf.h"
#include "qwt_interval.h"
#include "qwt_plot.h"
#include "qwt_scale_div.h"
#include "qwt_scale_map.h"
#include <QEvent>
#include <QWheelEvent>

View File

@@ -61,6 +61,8 @@
#include <QFont>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QPainter>
#include <QPainterPath>
#include <QVBoxLayout>
#include <QWheelEvent>

View File

@@ -6,6 +6,7 @@
#include <QMouseEvent>
#include <qwt_plot.h>
#include <qwt_scale_map.h>
#include <qwt_scale_widget.h>
//--------------------------------------------------------------------------------------------------

View File

@@ -41,6 +41,7 @@
#include "qwt_plot_curve.h"
#include "qwt_plot_marker.h"
#include "qwt_scale_engine.h"
#include "qwt_text.h"
#include <QButtonGroup>
#include <QCheckBox>

View File

@@ -107,7 +107,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
// Attach a zoomer for the right axis
m_zoomerRight = new RiuQwtPlotZoomer( m_plotWidget->qwtPlot()->canvas() );
m_zoomerRight->setAxis( QwtPlot::xTop, QwtPlot::yRight );
m_zoomerRight->setAxes( QwtPlot::xTop, QwtPlot::yRight );
m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff );
m_zoomerRight->initMousePattern( 1 );

View File

@@ -35,6 +35,7 @@
#include "qwt_plot_curve.h"
#include "qwt_plot_grid.h"
#include "qwt_plot_layout.h"
#include "qwt_text.h"
#include <QFocusEvent>
#include <QHBoxLayout>

View File

@@ -38,6 +38,7 @@
#include "qwt_plot.h"
#include "qwt_plot_marker.h"
#include "qwt_plot_shapeitem.h"
#include "qwt_text.h"
#include <QBrush>
#include <Qt>

2
ThirdParty/qwt vendored