From a83490ece303561709fdbbe04bf54139413229df Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Mon, 16 Oct 2023 17:44:56 +0100 Subject: [PATCH] Update QCustomPlot to 2.1.1 (and apply local patches) --- .../qcustomplot/patches/07-qt6.diff | 70 ------ source/thirdparty/qcustomplot/qcustomplot.cpp | 197 +++++++++------- source/thirdparty/qcustomplot/qcustomplot.h | 211 +++++++++++------- 3 files changed, 245 insertions(+), 233 deletions(-) delete mode 100644 source/thirdparty/qcustomplot/patches/07-qt6.diff diff --git a/source/thirdparty/qcustomplot/patches/07-qt6.diff b/source/thirdparty/qcustomplot/patches/07-qt6.diff deleted file mode 100644 index d25d0355b..000000000 --- a/source/thirdparty/qcustomplot/patches/07-qt6.diff +++ /dev/null @@ -1,70 +0,0 @@ -diff --git a/source/thirdparty/qcustomplot/qcustomplot.h b/source/thirdparty/qcustomplot/qcustomplot.h -index 467a88faa..25c723105 100644 ---- a/source/thirdparty/qcustomplot/qcustomplot.h -+++ b/source/thirdparty/qcustomplot/qcustomplot.h -@@ -158,26 +158,8 @@ class QCPPolarGraph; - - It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject. - */ --#ifndef Q_MOC_RUN - namespace QCP { --#else --class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace -- Q_GADGET -- Q_ENUMS(ExportPen) -- Q_ENUMS(ResolutionUnit) -- Q_ENUMS(SignDomain) -- Q_ENUMS(MarginSide) -- Q_FLAGS(MarginSides) -- Q_ENUMS(AntialiasedElement) -- Q_FLAGS(AntialiasedElements) -- Q_ENUMS(PlottingHint) -- Q_FLAGS(PlottingHints) -- Q_ENUMS(Interaction) -- Q_FLAGS(Interactions) -- Q_ENUMS(SelectionRectMode) -- Q_ENUMS(SelectionType) --public: --#endif -+ Q_NAMESPACE - - /*! - Defines the different units in which the image resolution can be specified in the export -@@ -320,6 +302,20 @@ enum SelectionType { stNone ///< The plottable is not selectable - ,stMultipleDataRanges ///< Any combination of data points/ranges can be selected - }; - -+ Q_ENUM_NS(ExportPen) -+ Q_ENUM_NS(ResolutionUnit) -+ Q_ENUM_NS(SignDomain) -+ Q_ENUM_NS(MarginSide) -+ Q_FLAG_NS(MarginSides) -+ Q_ENUM_NS(AntialiasedElement) -+ Q_FLAG_NS(AntialiasedElements) -+ Q_ENUM_NS(PlottingHint) -+ Q_FLAG_NS(PlottingHints) -+ Q_ENUM_NS(Interaction) -+ Q_FLAG_NS(Interactions) -+ Q_ENUM_NS(SelectionRectMode) -+ Q_ENUM_NS(SelectionType) -+ - /*! \internal - - Returns whether the specified \a value is considered an invalid data value for plottables (i.e. -@@ -388,15 +384,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) - Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) - Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) - Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) --Q_DECLARE_METATYPE(QCP::ExportPen) --Q_DECLARE_METATYPE(QCP::ResolutionUnit) --Q_DECLARE_METATYPE(QCP::SignDomain) --Q_DECLARE_METATYPE(QCP::MarginSide) --Q_DECLARE_METATYPE(QCP::AntialiasedElement) --Q_DECLARE_METATYPE(QCP::PlottingHint) --Q_DECLARE_METATYPE(QCP::Interaction) --Q_DECLARE_METATYPE(QCP::SelectionRectMode) --Q_DECLARE_METATYPE(QCP::SelectionType) -+//no need to use Q_DECLARE_METATYPE on enum since Q_ENUM_NS adds enum as metatype automatically - - /* end of 'src/global.h' */ - diff --git a/source/thirdparty/qcustomplot/qcustomplot.cpp b/source/thirdparty/qcustomplot/qcustomplot.cpp index 81b52caec..3a22c14ae 100644 --- a/source/thirdparty/qcustomplot/qcustomplot.cpp +++ b/source/thirdparty/qcustomplot/qcustomplot.cpp @@ -1,7 +1,7 @@ /*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** -** Copyright (C) 2011-2021 Emanuel Eichhammer ** +** Copyright (C) 2011-2022 Emanuel Eichhammer ** ** ** ** This program is free software: you can redistribute it and/or modify ** ** it under the terms of the GNU General Public License as published by ** @@ -18,16 +18,16 @@ ** ** **************************************************************************** ** Author: Emanuel Eichhammer ** -** Website/Contact: http://www.qcustomplot.com/ ** -** Date: 29.03.21 ** -** Version: 2.1.0 ** +** Website/Contact: https://www.qcustomplot.com/ ** +** Date: 06.11.22 ** +** Version: 2.1.1 ** ****************************************************************************/ #include "qcustomplot.h" /* including file 'src/vector2d.cpp' */ -/* modified 2021-03-29T02:30:44, size 7973 */ +/* modified 2022-11-06T12:45:56, size 7973 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPVector2D @@ -272,7 +272,7 @@ QCPVector2D &QCPVector2D::operator-=(const QCPVector2D &vector) /* including file 'src/painter.cpp' */ -/* modified 2021-03-29T02:30:44, size 8656 */ +/* modified 2022-11-06T12:45:56, size 8656 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPPainter @@ -489,7 +489,7 @@ void QCPPainter::makeNonCosmetic() /* including file 'src/paintbuffer.cpp' */ -/* modified 2021-03-29T02:30:44, size 18915 */ +/* modified 2022-11-06T12:45:56, size 18915 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAbstractPaintBuffer @@ -976,7 +976,7 @@ void QCPPaintBufferGlFbo::reallocateBuffer() /* including file 'src/layer.cpp' */ -/* modified 2021-03-29T02:30:44, size 37615 */ +/* modified 2022-11-06T12:45:56, size 37615 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLayer @@ -1836,7 +1836,7 @@ void QCPLayerable::wheelEvent(QWheelEvent *event) /* including file 'src/axis/range.cpp' */ -/* modified 2021-03-29T02:30:44, size 12221 */ +/* modified 2022-11-06T12:45:56, size 12221 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPRange @@ -2158,7 +2158,7 @@ bool QCPRange::validRange(const QCPRange &range) /* including file 'src/selection.cpp' */ -/* modified 2021-03-29T02:30:44, size 21837 */ +/* modified 2022-11-06T12:45:56, size 21837 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPDataRange @@ -2759,7 +2759,7 @@ QCPDataSelection QCPDataSelection::inverse(const QCPDataRange &outerRange) const /* including file 'src/selectionrect.cpp' */ -/* modified 2021-03-29T02:30:44, size 9215 */ +/* modified 2022-11-06T12:45:56, size 9215 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPSelectionRect @@ -2988,7 +2988,7 @@ void QCPSelectionRect::draw(QCPPainter *painter) /* including file 'src/layout.cpp' */ -/* modified 2021-03-29T02:30:44, size 78863 */ +/* modified 2022-11-06T12:45:56, size 78863 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPMarginGroup @@ -5161,7 +5161,7 @@ void QCPLayoutInset::addElement(QCPLayoutElement *element, const QRectF &rect) /* including file 'src/lineending.cpp' */ -/* modified 2021-03-29T02:30:44, size 11189 */ +/* modified 2022-11-06T12:45:56, size 11189 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPLineEnding @@ -5455,7 +5455,7 @@ void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos, double ang /* including file 'src/axis/labelpainter.cpp' */ -/* modified 2021-03-29T02:30:44, size 27296 */ +/* modified 2022-11-06T12:45:56, size 27519 */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -5653,8 +5653,8 @@ QByteArray QCPLabelPainterPrivate::generateLabelParameterHash() const QByteArray result; result.append(QByteArray::number(mParentPlot->bufferDevicePixelRatio())); result.append(QByteArray::number(mRotation)); - //result.append(QByteArray::number((int)tickLabelSide)); TODO: check whether this is really a cache-invalidating property - result.append(QByteArray::number((int)mSubstituteExponent)); + //result.append(QByteArray::number(int(tickLabelSide))); TODO: check whether this is really a cache-invalidating property + result.append(QByteArray::number(int(mSubstituteExponent))); result.append(QString(mMultiplicationSymbol).toUtf8()); result.append(mColor.name().toLatin1()+QByteArray::number(mColor.alpha(), 16)); result.append(mFont.toString().toLatin1()); @@ -5757,9 +5757,12 @@ QPointF QCPLabelPainterPrivate::getAnchorPos(const QPointF &tickPos) case asTopRight: return tickPos+QPointF(-mPadding*M_SQRT1_2, mPadding*M_SQRT1_2); case asBottomRight: return tickPos+QPointF(-mPadding*M_SQRT1_2, -mPadding*M_SQRT1_2); case asBottomLeft: return tickPos+QPointF(mPadding*M_SQRT1_2, -mPadding*M_SQRT1_2); + default: qDebug() << Q_FUNC_INFO << "invalid mode for anchor side: " << mAnchorSide; break; } + break; } case amSkewedUpright: + // fall through case amSkewedRotated: { QCPVector2D anchorNormal(tickPos-mAnchorReference); @@ -5768,6 +5771,7 @@ QPointF QCPLabelPainterPrivate::getAnchorPos(const QPointF &tickPos) anchorNormal.normalize(); return tickPos+(anchorNormal*mPadding).toPointF(); } + default: qDebug() << Q_FUNC_INFO << "invalid mode for anchor mode: " << mAnchorMode; break; } return tickPos; } @@ -5985,8 +5989,8 @@ QByteArray QCPLabelPainterPrivate::cacheKey(const QString &text, const QColor &c { return text.toUtf8()+ QByteArray::number(color.red()+256*color.green()+65536*color.blue(), 36)+ - QByteArray::number(color.alpha()+256*(int)side, 36)+ - QByteArray::number((int)(rotation*100)%36000, 36); + QByteArray::number(color.alpha()+256*int(side), 36)+ + QByteArray::number(int(rotation*100), 36); } QCPLabelPainterPrivate::AnchorSide QCPLabelPainterPrivate::skewedAnchorSide(const QPointF &tickPos, double sideExpandHorz, double sideExpandVert) const @@ -6054,7 +6058,7 @@ void QCPLabelPainterPrivate::analyzeFontMetrics() /* including file 'src/axis/axisticker.cpp' */ -/* modified 2021-03-29T02:30:44, size 18688 */ +/* modified 2022-11-06T12:45:56, size 18693 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTicker @@ -6438,7 +6442,7 @@ double QCPAxisTicker::pickClosest(double target, const QVector &candidat */ double QCPAxisTicker::getMantissa(double input, double *magnitude) const { - const double mag = qPow(10.0, qFloor(qLn(input)/qLn(10.0))); + const double mag = std::pow(10.0, std::floor(std::log10(input))); if (magnitude) *magnitude = mag; return input/mag; } @@ -6474,7 +6478,7 @@ double QCPAxisTicker::cleanMantissa(double input) const /* including file 'src/axis/axistickerdatetime.cpp' */ -/* modified 2021-03-29T02:30:44, size 18829 */ +/* modified 2022-11-06T12:45:56, size 18829 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTickerDateTime @@ -6831,7 +6835,7 @@ double QCPAxisTickerDateTime::dateTimeToKey(const QDate &date, Qt::TimeSpec time /* including file 'src/axis/axistickertime.cpp' */ -/* modified 2021-03-29T02:30:44, size 11745 */ +/* modified 2022-11-06T12:45:56, size 11745 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTickerTime @@ -7080,7 +7084,7 @@ void QCPAxisTickerTime::replaceUnit(QString &text, QCPAxisTickerTime::TimeUnit u /* including file 'src/axis/axistickerfixed.cpp' */ -/* modified 2021-03-29T02:30:44, size 5575 */ +/* modified 2022-11-06T12:45:56, size 5575 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTickerFixed @@ -7182,7 +7186,7 @@ double QCPAxisTickerFixed::getTickStep(const QCPRange &range) /* including file 'src/axis/axistickertext.cpp' */ -/* modified 2021-03-29T02:30:44, size 8742 */ +/* modified 2022-11-06T12:45:56, size 8742 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTickerText @@ -7399,7 +7403,7 @@ QVector QCPAxisTickerText::createTickVector(double tickStep, const QCPRa /* including file 'src/axis/axistickerpi.cpp' */ -/* modified 2021-03-29T02:30:44, size 11177 */ +/* modified 2022-11-06T12:45:56, size 11177 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTickerPi @@ -7686,7 +7690,7 @@ QString QCPAxisTickerPi::unicodeSubscript(int number) const /* including file 'src/axis/axistickerlog.cpp' */ -/* modified 2021-03-29T02:30:44, size 7890 */ +/* modified 2022-11-06T12:45:56, size 7890 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAxisTickerLog @@ -7827,7 +7831,7 @@ QVector QCPAxisTickerLog::createTickVector(double tickStep, const QCPRan /* including file 'src/axis/axis.cpp' */ -/* modified 2021-03-29T02:30:44, size 99883 */ +/* modified 2022-11-06T12:45:56, size 99911 */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -10348,7 +10352,7 @@ QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData(con int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart if (substituteExponent) { - ePos = text.indexOf(QLatin1Char('e')); + ePos = text.indexOf(QString(mParentPlot->locale().exponential())); if (ePos > 0 && text.at(ePos-1).isDigit()) { eLast = ePos; @@ -10545,7 +10549,7 @@ void QCPAxisPainterPrivate::getMaxTickLabelSize(const QFont &font, const QString /* including file 'src/scatterstyle.cpp' */ -/* modified 2021-03-29T02:30:44, size 17466 */ +/* modified 2022-11-06T12:45:56, size 17466 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPScatterStyle @@ -11018,7 +11022,7 @@ void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const /* including file 'src/plottable.cpp' */ -/* modified 2021-03-29T02:30:44, size 38818 */ +/* modified 2022-11-06T12:45:56, size 38818 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPSelectionDecorator @@ -11989,7 +11993,7 @@ void QCPAbstractPlottable::deselectEvent(bool *selectionStateChanged) /* including file 'src/item.cpp' */ -/* modified 2021-03-29T02:30:44, size 49486 */ +/* modified 2022-11-06T12:45:56, size 49486 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPItemAnchor @@ -13261,7 +13265,7 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const /* including file 'src/core.cpp' */ -/* modified 2021-03-29T02:30:44, size 127198 */ +/* modified 2022-11-06T12:45:56, size 127625 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCustomPlot @@ -13273,7 +13277,7 @@ QCP::Interaction QCPAbstractItem::selectionCategory() const interacts with the user. For tutorials on how to use QCustomPlot, see the website\n - http://www.qcustomplot.com/ + https://www.qcustomplot.com/ */ /* start of documentation of inline functions */ @@ -13597,7 +13601,7 @@ QCustomPlot::QCustomPlot(QWidget *parent) : xAxis2(nullptr), yAxis2(nullptr), legend(nullptr), - mBufferDevicePixelRatio(1.0), // will be adapted to primary screen below + mBufferDevicePixelRatio(1.0), // will be adapted to true value below mPlotLayout(nullptr), mAutoAddPlottableToLegend(true), mAntialiasedElements(QCP::aeNone), @@ -13626,7 +13630,6 @@ QCustomPlot::QCustomPlot(QWidget *parent) : mOpenGlCacheLabelsBackup(true) { setAttribute(Qt::WA_NoMousePropagation); - setAttribute(Qt::WA_OpaquePaintEvent); setFocusPolicy(Qt::ClickFocus); setMouseTracking(true); QLocale currentLocale = locale(); @@ -15468,6 +15471,22 @@ QSize QCustomPlot::sizeHint() const void QCustomPlot::paintEvent(QPaintEvent *event) { Q_UNUSED(event) + + // detect if the device pixel ratio has changed (e.g. moving window between different DPI screens), and adapt buffers if necessary: +#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED +# ifdef QCP_DEVICEPIXELRATIO_FLOAT + double newDpr = devicePixelRatioF(); +# else + double newDpr = devicePixelRatio(); +# endif + if (!qFuzzyCompare(mBufferDevicePixelRatio, newDpr)) + { + setBufferDevicePixelRatio(newDpr); + replot(QCustomPlot::rpQueuedRefresh); + return; + } +#endif + QCPPainter painter(this); if (painter.isActive()) { @@ -16486,7 +16505,7 @@ void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) /* including file 'src/colorgradient.cpp' */ -/* modified 2021-03-29T02:30:44, size 25278 */ +/* modified 2022-11-06T12:45:56, size 25408 */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -16716,10 +16735,10 @@ void QCPColorGradient::colorize(const double *data, const QCPRange &range, QRgb const double value = data[dataIndexFactor*i]; if (skipNanCheck || !std::isnan(value)) { - int index = int((!logarithmic ? value-range.lower : qLn(value/range.lower)) * posToIndexFactor); + qint64 index = qint64((!logarithmic ? value-range.lower : qLn(value/range.lower)) * posToIndexFactor); if (!mPeriodic) { - index = qBound(0, index, mLevelCount-1); + index = qBound(qint64(0), index, qint64(mLevelCount-1)); } else { index %= mLevelCount; @@ -16777,10 +16796,10 @@ void QCPColorGradient::colorize(const double *data, const unsigned char *alpha, const double value = data[dataIndexFactor*i]; if (skipNanCheck || !std::isnan(value)) { - int index = int((!logarithmic ? value-range.lower : qLn(value/range.lower)) * posToIndexFactor); + qint64 index = qint64((!logarithmic ? value-range.lower : qLn(value/range.lower)) * posToIndexFactor); if (!mPeriodic) { - index = qBound(0, index, mLevelCount-1); + index = qBound(qint64(0), index, qint64(mLevelCount-1)); } else { index %= mLevelCount; @@ -17023,7 +17042,7 @@ void QCPColorGradient::updateColorBuffer() for (int i=0; i::const_iterator it = mColorStops.lowerBound(position); + QMap::const_iterator it = const_cast*>(&mColorStops)->lowerBound(position); // force using the const lowerBound method if (it == mColorStops.constEnd()) // position is on or after last stop, use color of last stop { if (useAlpha) @@ -17121,7 +17140,7 @@ void QCPColorGradient::updateColorBuffer() /* including file 'src/selectiondecorator-bracket.cpp' */ -/* modified 2021-03-29T02:30:44, size 12308 */ +/* modified 2022-11-06T12:45:56, size 12308 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPSelectionDecoratorBracket @@ -17407,7 +17426,7 @@ QPointF QCPSelectionDecoratorBracket::getPixelCoordinates(const QCPPlottableInte /* including file 'src/layoutelements/layoutelement-axisrect.cpp' */ -/* modified 2021-03-29T02:30:44, size 47193 */ +/* modified 2022-11-06T12:45:56, size 47193 */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -18692,7 +18711,7 @@ void QCPAxisRect::wheelEvent(QWheelEvent *event) /* including file 'src/layoutelements/layoutelement-legend.cpp' */ -/* modified 2021-03-29T02:30:44, size 31762 */ +/* modified 2022-11-06T12:45:56, size 31762 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPAbstractLegendItem @@ -19616,7 +19635,7 @@ void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) /* including file 'src/layoutelements/layoutelement-textelement.cpp' */ -/* modified 2021-03-29T02:30:44, size 12925 */ +/* modified 2022-11-06T12:45:56, size 12925 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPTextElement @@ -20022,7 +20041,7 @@ QColor QCPTextElement::mainTextColor() const /* including file 'src/layoutelements/layoutelement-colorscale.cpp' */ -/* modified 2021-03-29T02:30:44, size 26531 */ +/* modified 2022-11-06T12:45:56, size 26531 */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -20706,7 +20725,7 @@ void QCPColorScaleAxisRectPrivate::axisSelectableChanged(QCPAxis::SelectablePart /* including file 'src/plottables/plottable-graph.cpp' */ -/* modified 2021-03-29T02:30:44, size 74518 */ +/* modified 2022-11-06T12:45:57, size 74926 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPGraphData @@ -21536,21 +21555,37 @@ QVector QCPGraph::dataToImpulseLines(const QVector &data) { for (int i=0; icoordToPixel(data.at(i).key); - result[i*2+0].setX(valueAxis->coordToPixel(0)); - result[i*2+0].setY(key); - result[i*2+1].setX(valueAxis->coordToPixel(data.at(i).value)); - result[i*2+1].setY(key); + const QCPGraphData ¤t = data.at(i); + if (!qIsNaN(current.value)) + { + const double key = keyAxis->coordToPixel(current.key); + result[i*2+0].setX(valueAxis->coordToPixel(0)); + result[i*2+0].setY(key); + result[i*2+1].setX(valueAxis->coordToPixel(current.value)); + result[i*2+1].setY(key); + } else + { + result[i*2+0] = QPointF(0, 0); + result[i*2+1] = QPointF(0, 0); + } } } else // key axis is horizontal { for (int i=0; icoordToPixel(data.at(i).key); - result[i*2+0].setX(key); - result[i*2+0].setY(valueAxis->coordToPixel(0)); - result[i*2+1].setX(key); - result[i*2+1].setY(valueAxis->coordToPixel(data.at(i).value)); + const QCPGraphData ¤t = data.at(i); + if (!qIsNaN(current.value)) + { + const double key = keyAxis->coordToPixel(data.at(i).key); + result[i*2+0].setX(key); + result[i*2+0].setY(valueAxis->coordToPixel(0)); + result[i*2+1].setX(key); + result[i*2+1].setY(valueAxis->coordToPixel(data.at(i).value)); + } else + { + result[i*2+0] = QPointF(0, 0); + result[i*2+1] = QPointF(0, 0); + } } } return result; @@ -22464,7 +22499,7 @@ int QCPGraph::findIndexBelowY(const QVector *data, double y) const /* including file 'src/plottables/plottable-curve.cpp' */ -/* modified 2021-03-29T02:30:44, size 63851 */ +/* modified 2022-11-06T12:45:56, size 63851 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPCurveData @@ -23922,7 +23957,7 @@ double QCPCurve::pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer: /* including file 'src/plottables/plottable-bars.cpp' */ -/* modified 2021-03-29T02:30:44, size 43907 */ +/* modified 2022-11-06T12:45:56, size 43907 */ //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -25119,7 +25154,7 @@ void QCPBars::connectBars(QCPBars *lower, QCPBars *upper) /* including file 'src/plottables/plottable-statisticalbox.cpp' */ -/* modified 2021-03-29T02:30:44, size 28951 */ +/* modified 2022-11-06T12:45:57, size 28951 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPStatisticalBoxData @@ -25781,7 +25816,7 @@ QVector QCPStatisticalBox::getWhiskerBarLines(QCPStatisticalBoxDataConta /* including file 'src/plottables/plottable-colormap.cpp' */ -/* modified 2021-03-29T02:30:44, size 48149 */ +/* modified 2022-11-06T12:45:56, size 48189 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPColorMapData @@ -26151,8 +26186,8 @@ void QCPColorMapData::recalculateDataBounds() { if (mKeySize > 0 && mValueSize > 0) { - double minHeight = mData[0]; - double maxHeight = mData[0]; + double minHeight = std::numeric_limits::max(); + double maxHeight = -std::numeric_limits::max(); const int dataCount = mValueSize*mKeySize; for (int i=0; i= 0x060200 // don't use QT_VERSION_CHECK here, some moc versions don't understand it +namespace QCP { + Q_NAMESPACE // this is how to add the staticMetaObject to namespaces in newer Qt versions +#else // Qt version older than 6.2.0 +# ifndef Q_MOC_RUN namespace QCP { - Q_NAMESPACE +# else // not in moc run +class QCP { + Q_GADGET + Q_ENUMS(ExportPen) + Q_ENUMS(ResolutionUnit) + Q_ENUMS(SignDomain) + Q_ENUMS(MarginSide) + Q_ENUMS(AntialiasedElement) + Q_ENUMS(PlottingHint) + Q_ENUMS(Interaction) + Q_ENUMS(SelectionRectMode) + Q_ENUMS(SelectionType) + + Q_FLAGS(AntialiasedElements) + Q_FLAGS(PlottingHints) + Q_FLAGS(MarginSides) + Q_FLAGS(Interactions) +public: +# endif +#endif + /*! Defines the different units in which the image resolution can be specified in the export @@ -302,20 +329,6 @@ enum SelectionType { stNone ///< The plottable is not selectable ,stMultipleDataRanges ///< Any combination of data points/ranges can be selected }; - Q_ENUM_NS(ExportPen) - Q_ENUM_NS(ResolutionUnit) - Q_ENUM_NS(SignDomain) - Q_ENUM_NS(MarginSide) - Q_FLAG_NS(MarginSides) - Q_ENUM_NS(AntialiasedElement) - Q_FLAG_NS(AntialiasedElements) - Q_ENUM_NS(PlottingHint) - Q_FLAG_NS(PlottingHints) - Q_ENUM_NS(Interaction) - Q_FLAG_NS(Interactions) - Q_ENUM_NS(SelectionRectMode) - Q_ENUM_NS(SelectionType) - /*! \internal Returns whether the specified \a value is considered an invalid data value for plottables (i.e. @@ -376,21 +389,55 @@ inline int getMarginValue(const QMargins &margins, QCP::MarginSide side) return 0; } - -extern const QMetaObject staticMetaObject; // in moc-run we create a static meta object for QCP "fake" object. This line is the link to it via QCP::staticMetaObject in normal operation as namespace +// for newer Qt versions we have to declare the enums/flags as metatypes inside the namespace using Q_ENUM_NS/Q_FLAG_NS: +// if you change anything here, don't forget to change it for older Qt versions below, too, +// and at the start of the namespace in the fake moc-run class +#if QT_VERSION >= 0x060200 +Q_ENUM_NS(ExportPen) +Q_ENUM_NS(ResolutionUnit) +Q_ENUM_NS(SignDomain) +Q_ENUM_NS(MarginSide) +Q_ENUM_NS(AntialiasedElement) +Q_ENUM_NS(PlottingHint) +Q_ENUM_NS(Interaction) +Q_ENUM_NS(SelectionRectMode) +Q_ENUM_NS(SelectionType) + +Q_FLAG_NS(AntialiasedElements) +Q_FLAG_NS(PlottingHints) +Q_FLAG_NS(MarginSides) +Q_FLAG_NS(Interactions) +#else +extern const QMetaObject staticMetaObject; +#endif } // end of namespace QCP + Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) -//no need to use Q_DECLARE_METATYPE on enum since Q_ENUM_NS adds enum as metatype automatically + +// for older Qt versions we have to declare the enums/flags as metatypes outside the namespace using Q_DECLARE_METATYPE: +// if you change anything here, don't forget to change it for newer Qt versions above, too, +// and at the start of the namespace in the fake moc-run class +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) +Q_DECLARE_METATYPE(QCP::ExportPen) +Q_DECLARE_METATYPE(QCP::ResolutionUnit) +Q_DECLARE_METATYPE(QCP::SignDomain) +Q_DECLARE_METATYPE(QCP::MarginSide) +Q_DECLARE_METATYPE(QCP::AntialiasedElement) +Q_DECLARE_METATYPE(QCP::PlottingHint) +Q_DECLARE_METATYPE(QCP::Interaction) +Q_DECLARE_METATYPE(QCP::SelectionRectMode) +Q_DECLARE_METATYPE(QCP::SelectionType) +#endif /* end of 'src/global.h' */ /* including file 'src/vector2d.h' */ -/* modified 2021-03-29T02:30:44, size 4988 */ +/* modified 2022-11-06T12:45:56, size 4988 */ class QCP_LIB_DECL QCPVector2D { @@ -465,7 +512,7 @@ inline QDebug operator<< (QDebug d, const QCPVector2D &vec) /* including file 'src/painter.h' */ -/* modified 2021-03-29T02:30:44, size 4035 */ +/* modified 2022-11-06T12:45:56, size 4035 */ class QCP_LIB_DECL QCPPainter : public QPainter { @@ -524,7 +571,7 @@ Q_DECLARE_METATYPE(QCPPainter::PainterMode) /* including file 'src/paintbuffer.h' */ -/* modified 2021-03-29T02:30:44, size 5006 */ +/* modified 2022-11-06T12:45:56, size 5006 */ class QCP_LIB_DECL QCPAbstractPaintBuffer { @@ -632,7 +679,7 @@ class QCP_LIB_DECL QCPPaintBufferGlFbo : public QCPAbstractPaintBuffer /* including file 'src/layer.h' */ -/* modified 2021-03-29T02:30:44, size 7038 */ +/* modified 2022-11-06T12:45:56, size 7038 */ class QCP_LIB_DECL QCPLayer : public QObject { @@ -781,7 +828,7 @@ class QCP_LIB_DECL QCPLayerable : public QObject /* including file 'src/axis/range.h' */ -/* modified 2021-03-29T02:30:44, size 5280 */ +/* modified 2022-11-06T12:45:56, size 5280 */ class QCP_LIB_DECL QCPRange { @@ -899,7 +946,7 @@ inline const QCPRange operator/(const QCPRange& range, double value) /* including file 'src/selection.h' */ -/* modified 2021-03-29T02:30:44, size 8569 */ +/* modified 2022-11-06T12:45:56, size 8569 */ class QCP_LIB_DECL QCPDataRange { @@ -1103,7 +1150,7 @@ inline QDebug operator<< (QDebug d, const QCPDataSelection &selection) /* including file 'src/selectionrect.h' */ -/* modified 2021-03-29T02:30:44, size 3354 */ +/* modified 2022-11-06T12:45:56, size 3354 */ class QCP_LIB_DECL QCPSelectionRect : public QCPLayerable { @@ -1157,7 +1204,7 @@ class QCP_LIB_DECL QCPSelectionRect : public QCPLayerable /* including file 'src/layout.h' */ -/* modified 2021-03-29T02:30:44, size 14279 */ +/* modified 2022-11-06T12:45:56, size 14279 */ class QCP_LIB_DECL QCPMarginGroup : public QObject { @@ -1478,7 +1525,7 @@ Q_DECLARE_METATYPE(QCPLayoutInset::InsetPlacement) /* including file 'src/lineending.h' */ -/* modified 2021-03-29T02:30:44, size 4426 */ +/* modified 2022-11-06T12:45:56, size 4426 */ class QCP_LIB_DECL QCPLineEnding { @@ -1542,7 +1589,7 @@ Q_DECLARE_METATYPE(QCPLineEnding::EndingStyle) /* including file 'src/axis/labelpainter.h' */ -/* modified 2021-03-29T02:30:44, size 7086 */ +/* modified 2022-11-06T12:45:56, size 7086 */ class QCPLabelPainterPrivate { @@ -1682,7 +1729,7 @@ Q_DECLARE_METATYPE(QCPLabelPainterPrivate::AnchorSide) /* including file 'src/axis/axisticker.h' */ -/* modified 2021-03-29T02:30:44, size 4230 */ +/* modified 2022-11-06T12:45:56, size 4230 */ class QCP_LIB_DECL QCPAxisTicker { @@ -1747,7 +1794,7 @@ Q_DECLARE_METATYPE(QSharedPointer) /* including file 'src/axis/axistickerdatetime.h' */ -/* modified 2021-03-29T02:30:44, size 3600 */ +/* modified 2022-11-06T12:45:56, size 3600 */ class QCP_LIB_DECL QCPAxisTickerDateTime : public QCPAxisTicker { @@ -1796,7 +1843,7 @@ class QCP_LIB_DECL QCPAxisTickerDateTime : public QCPAxisTicker /* including file 'src/axis/axistickertime.h' */ -/* modified 2021-03-29T02:30:44, size 3542 */ +/* modified 2022-11-06T12:45:56, size 3542 */ class QCP_LIB_DECL QCPAxisTickerTime : public QCPAxisTicker { @@ -1848,7 +1895,7 @@ Q_DECLARE_METATYPE(QCPAxisTickerTime::TimeUnit) /* including file 'src/axis/axistickerfixed.h' */ -/* modified 2021-03-29T02:30:44, size 3308 */ +/* modified 2022-11-06T12:45:56, size 3308 */ class QCP_LIB_DECL QCPAxisTickerFixed : public QCPAxisTicker { @@ -1890,7 +1937,7 @@ Q_DECLARE_METATYPE(QCPAxisTickerFixed::ScaleStrategy) /* including file 'src/axis/axistickertext.h' */ -/* modified 2021-03-29T02:30:44, size 3090 */ +/* modified 2022-11-06T12:45:56, size 3090 */ class QCP_LIB_DECL QCPAxisTickerText : public QCPAxisTicker { @@ -1928,7 +1975,7 @@ class QCP_LIB_DECL QCPAxisTickerText : public QCPAxisTicker /* including file 'src/axis/axistickerpi.h' */ -/* modified 2021-03-29T02:30:44, size 3911 */ +/* modified 2022-11-06T12:45:56, size 3911 */ class QCP_LIB_DECL QCPAxisTickerPi : public QCPAxisTicker { @@ -1987,7 +2034,7 @@ Q_DECLARE_METATYPE(QCPAxisTickerPi::FractionStyle) /* including file 'src/axis/axistickerlog.h' */ -/* modified 2021-03-29T02:30:44, size 2594 */ +/* modified 2022-11-06T12:45:56, size 2594 */ class QCP_LIB_DECL QCPAxisTickerLog : public QCPAxisTicker { @@ -2019,7 +2066,7 @@ class QCP_LIB_DECL QCPAxisTickerLog : public QCPAxisTicker /* including file 'src/axis/axis.h' */ -/* modified 2021-03-29T02:30:44, size 20913 */ +/* modified 2022-11-06T12:45:56, size 20913 */ class QCP_LIB_DECL QCPGrid :public QCPLayerable { @@ -2447,7 +2494,7 @@ class QCPAxisPainterPrivate /* including file 'src/scatterstyle.h' */ -/* modified 2021-03-29T02:30:44, size 7275 */ +/* modified 2022-11-06T12:45:56, size 7275 */ class QCP_LIB_DECL QCPScatterStyle { @@ -2554,7 +2601,7 @@ Q_DECLARE_METATYPE(QCPScatterStyle::ScatterShape) /* including file 'src/datacontainer.h' */ -/* modified 2021-03-29T02:30:44, size 34070 */ +/* modified 2022-11-06T12:45:56, size 34305 */ /*! \relates QCPDataContainer Returns whether the sort key of \a a is less than the sort key of \a b. @@ -3223,6 +3270,8 @@ QCPRange QCPDataContainer::keyRange(bool &foundRange, QCP::SignDomain output parameter \a foundRange indicates whether a sensible range was found. If this is false, you should not use the returned QCPRange (e.g. the data container is empty or all points have the same value). + + Inf and -Inf data values are ignored. If \a inKeyRange has both lower and upper bound set to zero (is equal to QCPRange()), all data points are considered, without any restriction on the keys. @@ -3260,12 +3309,12 @@ QCPRange QCPDataContainer::valueRange(bool &foundRange, QCP::SignDomai if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) continue; current = it->valueRange(); - if ((current.lower < range.lower || !haveLower) && !qIsNaN(current.lower)) + if ((current.lower < range.lower || !haveLower) && !qIsNaN(current.lower) && std::isfinite(current.lower)) { range.lower = current.lower; haveLower = true; } - if ((current.upper > range.upper || !haveUpper) && !qIsNaN(current.upper)) + if ((current.upper > range.upper || !haveUpper) && !qIsNaN(current.upper) && std::isfinite(current.upper)) { range.upper = current.upper; haveUpper = true; @@ -3278,12 +3327,12 @@ QCPRange QCPDataContainer::valueRange(bool &foundRange, QCP::SignDomai if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) continue; current = it->valueRange(); - if ((current.lower < range.lower || !haveLower) && current.lower < 0 && !qIsNaN(current.lower)) + if ((current.lower < range.lower || !haveLower) && current.lower < 0 && !qIsNaN(current.lower) && std::isfinite(current.lower)) { range.lower = current.lower; haveLower = true; } - if ((current.upper > range.upper || !haveUpper) && current.upper < 0 && !qIsNaN(current.upper)) + if ((current.upper > range.upper || !haveUpper) && current.upper < 0 && !qIsNaN(current.upper) && std::isfinite(current.upper)) { range.upper = current.upper; haveUpper = true; @@ -3296,12 +3345,12 @@ QCPRange QCPDataContainer::valueRange(bool &foundRange, QCP::SignDomai if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) continue; current = it->valueRange(); - if ((current.lower < range.lower || !haveLower) && current.lower > 0 && !qIsNaN(current.lower)) + if ((current.lower < range.lower || !haveLower) && current.lower > 0 && !qIsNaN(current.lower) && std::isfinite(current.lower)) { range.lower = current.lower; haveLower = true; } - if ((current.upper > range.upper || !haveUpper) && current.upper > 0 && !qIsNaN(current.upper)) + if ((current.upper > range.upper || !haveUpper) && current.upper > 0 && !qIsNaN(current.upper) && std::isfinite(current.upper)) { range.upper = current.upper; haveUpper = true; @@ -3396,7 +3445,7 @@ void QCPDataContainer::performAutoSqueeze() /* including file 'src/plottable.h' */ -/* modified 2021-03-29T02:30:44, size 8461 */ +/* modified 2022-11-06T12:45:56, size 8461 */ class QCP_LIB_DECL QCPSelectionDecorator { @@ -3553,7 +3602,7 @@ class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable /* including file 'src/item.h' */ -/* modified 2021-03-29T02:30:44, size 9425 */ +/* modified 2022-11-06T12:45:56, size 9425 */ class QCP_LIB_DECL QCPItemAnchor { @@ -3738,7 +3787,7 @@ class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable /* including file 'src/core.h' */ -/* modified 2021-03-29T02:30:44, size 19304 */ +/* modified 2022-11-06T12:45:56, size 19304 */ class QCP_LIB_DECL QCustomPlot : public QWidget { @@ -4108,7 +4157,7 @@ ItemType *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) const /* including file 'src/plottable1d.h' */ -/* modified 2021-03-29T02:30:44, size 25638 */ +/* modified 2022-11-06T12:45:56, size 25638 */ class QCPPlottableInterface1D { @@ -4700,7 +4749,7 @@ void QCPAbstractPlottable1D::drawPolyline(QCPPainter *painter, const Q /* including file 'src/colorgradient.h' */ -/* modified 2021-03-29T02:30:44, size 7262 */ +/* modified 2022-11-06T12:45:56, size 7262 */ class QCP_LIB_DECL QCPColorGradient { @@ -4803,7 +4852,7 @@ Q_DECLARE_METATYPE(QCPColorGradient::GradientPreset) /* including file 'src/selectiondecorator-bracket.h' */ -/* modified 2021-03-29T02:30:44, size 4458 */ +/* modified 2022-11-06T12:45:56, size 4458 */ class QCP_LIB_DECL QCPSelectionDecoratorBracket : public QCPSelectionDecorator { @@ -4872,7 +4921,7 @@ Q_DECLARE_METATYPE(QCPSelectionDecoratorBracket::BracketStyle) /* including file 'src/layoutelements/layoutelement-axisrect.h' */ -/* modified 2021-03-29T02:30:44, size 7529 */ +/* modified 2022-11-06T12:45:56, size 7529 */ class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement { @@ -4998,7 +5047,7 @@ class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement /* including file 'src/layoutelements/layoutelement-legend.h' */ -/* modified 2021-03-29T02:30:44, size 10425 */ +/* modified 2022-11-06T12:45:56, size 10425 */ class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement { @@ -5216,7 +5265,7 @@ Q_DECLARE_METATYPE(QCPLegend::SelectablePart) /* including file 'src/layoutelements/layoutelement-textelement.h' */ -/* modified 2021-03-29T02:30:44, size 5359 */ +/* modified 2022-11-06T12:45:56, size 5359 */ class QCP_LIB_DECL QCPTextElement : public QCPLayoutElement { @@ -5303,7 +5352,7 @@ class QCP_LIB_DECL QCPTextElement : public QCPLayoutElement /* including file 'src/layoutelements/layoutelement-colorscale.h' */ -/* modified 2021-03-29T02:30:44, size 5939 */ +/* modified 2022-11-06T12:45:56, size 5939 */ class QCPColorScaleAxisRectPrivate : public QCPAxisRect @@ -5411,7 +5460,7 @@ class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement /* including file 'src/plottables/plottable-graph.h' */ -/* modified 2021-03-29T02:30:44, size 9316 */ +/* modified 2022-11-06T12:45:56, size 9316 */ class QCP_LIB_DECL QCPGraphData { @@ -5550,7 +5599,7 @@ Q_DECLARE_METATYPE(QCPGraph::LineStyle) /* including file 'src/plottables/plottable-curve.h' */ -/* modified 2021-03-29T02:30:44, size 7434 */ +/* modified 2022-11-06T12:45:56, size 7434 */ class QCP_LIB_DECL QCPCurveData { @@ -5665,7 +5714,7 @@ Q_DECLARE_METATYPE(QCPCurve::LineStyle) /* including file 'src/plottables/plottable-bars.h' */ -/* modified 2021-03-29T02:30:44, size 8955 */ +/* modified 2022-11-06T12:45:56, size 8955 */ class QCP_LIB_DECL QCPBarsGroup : public QObject { @@ -5855,7 +5904,7 @@ Q_DECLARE_METATYPE(QCPBars::WidthType) /* including file 'src/plottables/plottable-statisticalbox.h' */ -/* modified 2021-03-29T02:30:44, size 7522 */ +/* modified 2022-11-06T12:45:56, size 7522 */ class QCP_LIB_DECL QCPStatisticalBoxData { @@ -5972,7 +6021,7 @@ class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable1D