From 4099cfcd7e86c3575085ae1a88aeb2728935827d Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 16 Dec 2018 14:59:39 +0100 Subject: [PATCH] fixed some compiler warnings added possibility to modify line width in JKQTPxyParametrizedScatterGraph improved key symbols of JKQTPxyParametrizedScatterGraph --- lib/jkqtplotter/jkqtpbarchartelements.cpp | 52 +++---- lib/jkqtplotter/jkqtpbasegraphs.cpp | 36 ++--- lib/jkqtplotter/jkqtpbasegraphs.h | 20 +-- lib/jkqtplotter/jkqtpboxplotelements.cpp | 28 ++-- lib/jkqtplotter/jkqtpdatastorage.cpp | 47 +++--- lib/jkqtplotter/jkqtpdatastorage.h | 53 ++++++- lib/jkqtplotter/jkqtpelements.cpp | 144 ++++++++++++++----- lib/jkqtplotter/jkqtpelements.h | 10 +- lib/jkqtplotter/jkqtpfilledcurveelements.cpp | 16 +-- lib/jkqtplotter/jkqtpimagetools.h | 115 +++++++-------- lib/jkqtplotter/jkqtpimpulseselements.cpp | 8 +- lib/jkqtplottertools/jkqtphighrestimer.cpp | 2 +- lib/jkqtplottertools/jkqtptools.h | 16 +-- 13 files changed, 338 insertions(+), 209 deletions(-) diff --git a/lib/jkqtplotter/jkqtpbarchartelements.cpp b/lib/jkqtplotter/jkqtpbarchartelements.cpp index 0109c630ee..8a77887df7 100644 --- a/lib/jkqtplotter/jkqtpbarchartelements.cpp +++ b/lib/jkqtplotter/jkqtpbarchartelements.cpp @@ -120,10 +120,10 @@ void JKQTPbarVerticalGraph::draw(JKQTPEnhancedPainter& painter) { int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end+1, static_cast(imax)); + imax=qMin(datarange_end+1, static_cast(imax)); } if (imaxget(static_cast(xColumn),static_cast(i)); - long long sr=datastore->getNextLowerIndex(xColumn, i, datarange_start, datarange_end); - long long lr=datastore->getNextHigherIndex(xColumn, i, datarange_start, datarange_end); + int sr=datastore->getNextLowerIndex(xColumn, i, datarange_start, datarange_end); + int lr=datastore->getNextHigherIndex(xColumn, i, datarange_start, datarange_end); double yv=datastore->get(static_cast(yColumn),static_cast(i)); double yv0=y0; if (!qFuzzyIsNull(baseline)) yv0=yAxis->x2p(baseline); @@ -206,10 +206,10 @@ bool JKQTPbarVerticalGraph::getXMinMax(double& minx, double& maxx, double& small int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxget(static_cast(xColumn),static_cast(i)); - long long sr=datastore->getNextLowerIndex(xColumn, i, datarange_start, datarange_end); - long long lr=datastore->getNextHigherIndex(xColumn, i, datarange_start, datarange_end); + int sr=datastore->getNextLowerIndex(xColumn, i, datarange_start, datarange_end); + int lr=datastore->getNextHigherIndex(xColumn, i, datarange_start, datarange_end); double delta, deltap, deltam; if (sr<0 && lr<0) { // only one x-value @@ -268,10 +268,10 @@ bool JKQTPbarVerticalGraph::getYMinMax(double& miny, double& maxy, double& small int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end+1, static_cast(imax)); + imax=qMin(datarange_end+1, static_cast(imax)); } if (imaxget(static_cast(xColumn),static_cast(i)); double yv=datastore->get(static_cast(yColumn),static_cast(i)); - long long sr=datastore->getNextLowerIndex(yColumn, i, datarange_start, datarange_end); - long long lr=datastore->getNextHigherIndex(yColumn, i, datarange_start, datarange_end); + int sr=datastore->getNextLowerIndex(yColumn, i, datarange_start, datarange_end); + int lr=datastore->getNextHigherIndex(yColumn, i, datarange_start, datarange_end); double xv0=x0; if (!qFuzzyIsNull(baseline)) xv0=xAxis->x2p(baseline); if (hasStackPar) { @@ -479,10 +479,10 @@ bool JKQTPbarHorizontalGraph::getXMinMax(double& minx, double& maxx, double& sma int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(xColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxget(static_cast(yColumn),static_cast(i)); double delta, deltap, deltam; - long long sr=datastore->getNextLowerIndex(yColumn, i, datarange_start, datarange_end); - long long lr=datastore->getNextHigherIndex(yColumn, i, datarange_start, datarange_end); + int sr=datastore->getNextLowerIndex(yColumn, i, datarange_start, datarange_end); + int lr=datastore->getNextHigherIndex(yColumn, i, datarange_start, datarange_end); if (sr<0 && lr<0) { // only one y-value deltam=0.5; @@ -664,10 +664,10 @@ bool JKQTPbarHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(column).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(dataColumn).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax* dataorder) { +void JKQTPgraphErrors::intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPerrorPlotstyle xErrorStyle, JKQTPerrorPlotstyle yErrorStyle, int datarange_start, int datarange_end, int xErrorColumnLower, int yErrorColumnLower, bool xErrorSymmetric, bool yErrorSymmetric, double xrelshift, double yrelshift, const QVector* dataorder) { //std::cout<<"JKQTPgraphErrors::intPlotXYErrorIndicators(p, "<getDatastore(); @@ -529,17 +529,17 @@ void JKQTPgraphErrors::intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, J p.setCapStyle(Qt::RoundCap); painter.setPen(p); - unsigned long long imaxx=0, imaxy=0; + unsigned int imaxx=0, imaxy=0; if (xColumn>=0) imaxx=datastore->getColumn(static_cast(xColumn)).getRows(); if (yColumn>=0) imaxy=datastore->getColumn(static_cast(yColumn)).getRows(); int imax=qMin(imaxx, imaxy); int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax* dataorder) { +void JKQTPxGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis *xAxis, JKQTPcoordinateAxis *yAxis, int xColumn, int yColumn, int datarange_start, int datarange_end, double xrelshift, double yrelshift, const QVector* dataorder) { intPlotXYErrorIndicators(painter, parent, xAxis, yAxis, xColumn, yColumn, xErrorColumn, -1, xErrorStyle, JKQTPnoError, datarange_start, datarange_end, xErrorColumnLower, -1, xErrorSymmetric, true, xrelshift, yrelshift, dataorder); } @@ -937,7 +937,7 @@ JKQTPyGraphErrors::JKQTPyGraphErrors(QColor graphColor): yErrorColumnLower=-1; } -void JKQTPyGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, long long datarange_start, long long datarange_end, double xrelshift, double yrelshift, const QVector* dataorder) { +void JKQTPyGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int datarange_start, int datarange_end, double xrelshift, double yrelshift, const QVector* dataorder) { intPlotXYErrorIndicators(painter, parent, xAxis, yAxis, xColumn, yColumn, -1, yErrorColumn, JKQTPnoError, yErrorStyle, datarange_start, datarange_end, -1, yErrorColumnLower, true, yErrorSymmetric, xrelshift, yrelshift, dataorder); } @@ -978,7 +978,7 @@ JKQTPxyGraphErrors::JKQTPxyGraphErrors(QColor graphColor): } -void JKQTPxyGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, long long datarange_start, long long datarange_end, double xrelshift, double yrelshift, const QVector* dataorder) { +void JKQTPxyGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int datarange_start, int datarange_end, double xrelshift, double yrelshift, const QVector* dataorder) { this->intPlotXYErrorIndicators(painter, parent, xAxis, yAxis, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, datarange_start, datarange_end, xErrorColumnLower, yErrorColumnLower, xErrorSymmetric, yErrorSymmetric, xrelshift, yrelshift, dataorder); } @@ -1037,10 +1037,10 @@ void JKQTPxyGraph::intSortData() int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax* dataorder=nullptr)=0; + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int datarange_start=-1, int datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector* dataorder=nullptr)=0; /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - void intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPerrorPlotstyle xErrorStyle, JKQTPerrorPlotstyle yErrorStyle, long long datarange_start=-1, long long datarange_end=-1, int xErrorColumnLower=-1, int yErrorColumnLower=-1, bool xErrorSymmetric=true, bool yErrorSymmetric=true, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); + void intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPerrorPlotstyle xErrorStyle, JKQTPerrorPlotstyle yErrorStyle, int datarange_start=-1, int datarange_end=-1, int xErrorColumnLower=-1, int yErrorColumnLower=-1, bool xErrorSymmetric=true, bool yErrorSymmetric=true, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); /** \brief this function can be used to set the color of the error indicators automatically * * return \c true and the colors to use, if applicable, the default implementation returns false */ - virtual bool intPlotXYErrorIndicatorsGetColor(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPerrorPlotstyle xErrorStyle, JKQTPerrorPlotstyle yErrorStyle, long long index, QColor& errorColor, QColor& errorFillColor); + virtual bool intPlotXYErrorIndicatorsGetColor(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int xErrorColumn, int yErrorColumn, JKQTPerrorPlotstyle xErrorStyle, JKQTPerrorPlotstyle yErrorStyle, int index, QColor& errorColor, QColor& errorFillColor); virtual double getXErrorU(int i, JKQTPdatastore* ds) const; @@ -441,7 +441,7 @@ class LIB_EXPORT JKQTPxGraphErrors: public JKQTPgraphErrors { /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, long long datarange_start=-1, long long datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int datarange_start=-1, int datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); virtual double getXErrorU(int i, JKQTPdatastore* ds) const; virtual double getXErrorL(int i, JKQTPdatastore* ds) const; @@ -490,7 +490,7 @@ class LIB_EXPORT JKQTPyGraphErrors: public JKQTPgraphErrors { /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, long long datarange_start=-1, long long datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int datarange_start=-1, int datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); virtual double getYErrorU(int i, JKQTPdatastore* ds) const; virtual double getYErrorL(int i, JKQTPdatastore* ds) const; @@ -546,7 +546,7 @@ class LIB_EXPORT JKQTPxyGraphErrors: public JKQTPgraphErrors { /** \brief draw error indicators with the parameters defined in this class. The position of the datapoints is * given by the \a xColumn and \a yColumn. It is also possible to specify a datarange. */ - virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, long long datarange_start=-1, long long datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); + virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQtBasePlotter* parent, JKQTPcoordinateAxis* xAxis, JKQTPcoordinateAxis* yAxis, int xColumn, int yColumn, int datarange_start=-1, int datarange_end=-1, double xrelshift=0, double yrelshift=0.0, const QVector *dataorder=nullptr); virtual double getXErrorU(int i, JKQTPdatastore* ds) const; virtual double getXErrorL(int i, JKQTPdatastore* ds) const; diff --git a/lib/jkqtplotter/jkqtpboxplotelements.cpp b/lib/jkqtplotter/jkqtpboxplotelements.cpp index 16122c93b9..aef0112f41 100644 --- a/lib/jkqtplotter/jkqtpboxplotelements.cpp +++ b/lib/jkqtplotter/jkqtpboxplotelements.cpp @@ -128,10 +128,10 @@ void JKQTPboxplotVerticalGraph::draw(JKQTPEnhancedPainter& painter) { int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(posColumn).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(medianColumn).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(medianColumn).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(posColumn).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(posColumn).getRows(); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax=0) return getNextLowerIndex(column, row, 0, end); @@ -551,9 +552,9 @@ long long JKQTPdatastore::getNextLowerIndex(size_t column, size_t row, long long else { double d=0; const double v=col.getValue(row); - long long res=-1; - for ( long long i=start; i<=end; i++) { - if (i!=(long long)row) { + int res=-1; + for ( int i=start; i<=end; i++) { + if (i!=(int)row) { const double v1=col.getValue(i); const double dd=v1-v; if ((dd<0) && ((fabs(dd)=0) return getNextHigherIndex(column, row, 0, end); @@ -583,9 +584,9 @@ long long JKQTPdatastore::getNextHigherIndex(size_t column, size_t row, long lon else { double d=0; const double v=col.getValue(row); - long long res=-1; - for ( long long i=start; i<=end; i++) { - if (i!=(long long)row) { + int res=-1; + for ( int i=start; i<=end; i++) { + if (i!=(int)row) { const double v1=col.getValue(i); const double dd=v1-v; if ((dd>0) && ((fabs(dd)(column), row, start, end); } +int JKQTPdatastore::getNextLowerIndex(int column, size_t row) const { + return getNextLowerIndex(static_cast(column), row); +} + +int JKQTPdatastore::getNextHigherIndex(int column, size_t row, int start, int end) const { + return getNextHigherIndex(static_cast(column), row, start, end); +} + + size_t JKQTPdatastore::getMaxRows() { @@ -980,3 +989,7 @@ void JKQTPdatastoreModel::reloadModel() reset(); #endif } + +int JKQTPdatastore::getNextHigherIndex(int column, size_t row) const { + return getNextHigherIndex(static_cast(column), row); +} diff --git a/lib/jkqtplotter/jkqtpdatastorage.h b/lib/jkqtplotter/jkqtpdatastorage.h index 68443c4a06..e4ffe8539a 100644 --- a/lib/jkqtplotter/jkqtpdatastorage.h +++ b/lib/jkqtplotter/jkqtpdatastorage.h @@ -211,18 +211,31 @@ class LIB_EXPORT JKQTPdatastore{ /** \brief returns the value at position (\c column, \c row). \c column is the logical column and will be mapped to the according memory block internally!) */ - double get(size_t column, size_t row) const; + inline double get(size_t column, size_t row) const ; + + /** \brief returns the value at position (\c column, \c row). \c column is the logical column and will be mapped to the according memory block internally!) */ + inline double get(int column, size_t row) const ; /** \brief gets the index of the datapoint with the nearest, but lower value in the column (in a given inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column)*/ - long long getNextLowerIndex(size_t column, size_t row, long long start, long long end) const; + int getNextLowerIndex(size_t column, size_t row, int start, int end) const; /** \brief gets the index of the datapoint with the nearest, but lower value in the column */ - long long getNextLowerIndex(size_t column, size_t row) const; + int getNextLowerIndex(size_t column, size_t row) const; /** \brief gets the index of the datapoint with the nearest, but higher value in the column (in a given inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column) */ - long long getNextHigherIndex(size_t column, size_t row, long long start, long long end) const; + int getNextHigherIndex(size_t column, size_t row, int start, int end) const; /** \brief gets the index of the datapoint with the nearest, but higher value in the column */ - long long getNextHigherIndex(size_t column, size_t row) const; + int getNextHigherIndex(size_t column, size_t row) const; /** \brief sets the value at position (\c column, \c row). \c column is the logical column and will be mapped to the according memory block internally!) */ - void set(size_t column, size_t row, double value); + inline void set(size_t column, size_t row, double value); + /** \brief sets the value at position (\c column, \c row). \c column is the logical column and will be mapped to the according memory block internally!) */ + inline void set(int column, size_t row, double value); + /** \brief gets the index of the datapoint with the nearest, but lower value in the column (in a given inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column)*/ + int getNextLowerIndex(int column, size_t row, int start, int end) const; + /** \brief gets the index of the datapoint with the nearest, but lower value in the column */ + int getNextLowerIndex(int column, size_t row) const; + /** \brief gets the index of the datapoint with the nearest, but higher value in the column (in a given inclusive row range [start ... end] values of -1 for the ranges are "wildcards", i.e. start/end of column) */ + int getNextHigherIndex(int column, size_t row, int start, int end) const; + /** \brief gets the index of the datapoint with the nearest, but higher value in the column */ + int getNextHigherIndex(int column, size_t row) const; @@ -511,6 +524,10 @@ class LIB_EXPORT JKQTPdatastore{ /** \brief returns the JKQTPcolumn object for the \a i -th column in the store */ JKQTPcolumn getColumn(size_t i) const; + + /** \brief returns the JKQTPcolumn object for the \a i -th column in the store */ + JKQTPcolumn getColumn(int i) const; + /** \brief returns the maximum number of rows in all columns */ size_t getMaxRows(); @@ -589,6 +606,8 @@ class LIB_EXPORT JKQTPdatastore{ /** \brief return a list with all columns available in the datastore */ QStringList getColumnNames() const; + /** \brief add a column with \a rows entries from the array \a data, + * ownership of the memory behind \a data is transfered to the datastore */ size_t addInternalColumn(double *data, size_t rows, const QString& name); }; @@ -853,4 +872,26 @@ inline double JKQTPcolumn::getValue(size_t n) const { return datastore->getItem(datastoreItem)->get(datastoreOffset, n); } +//////////////////////////////////////////////////////////////////////////////////////////////// +inline double JKQTPdatastore::get(size_t column, size_t row) const { + return columns[column].getValue(row); +} + +//////////////////////////////////////////////////////////////////////////////////////////////// +inline double JKQTPdatastore::get(int column, size_t row) const { + return get(static_cast(column), static_cast(row)); +} + +//////////////////////////////////////////////////////////////////////////////////////////////// +inline void JKQTPdatastore::set(size_t column, size_t row, double value) { + columns[column].setValue(row, value); +} + +//////////////////////////////////////////////////////////////////////////////////////////////// +inline void JKQTPdatastore::set(int column, size_t row, double value) { + set(static_cast(column), static_cast(row), value); +} + + + #endif // JKQTPDATASTORAGE_H diff --git a/lib/jkqtplotter/jkqtpelements.cpp b/lib/jkqtplotter/jkqtpelements.cpp index ee70d412d4..4a57a8caba 100644 --- a/lib/jkqtplotter/jkqtpelements.cpp +++ b/lib/jkqtplotter/jkqtpelements.cpp @@ -25,6 +25,7 @@ #include #include #include "jkqtplottertools/jkqtptools.h" +#include "jkqtplotter/jkqtpimagetools.h" #include "jkqtplotter/jkqtpimageelements.h" #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtplotter.h" @@ -103,7 +104,6 @@ bool JKQTPPeakStreamGraph::getXMinMax(double &minx, double &maxx, double &smalle return true; //smallestGreaterZero=qMax(double(0.0), qMin(baseline, baseline+peakHeight)); } - return false; } bool JKQTPPeakStreamGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) @@ -116,7 +116,6 @@ bool JKQTPPeakStreamGraph::getYMinMax(double &miny, double &maxy, double &smalle return true; //smallestGreaterZero=qMax(double(0.0), qMin(baseline, baseline+peakHeight)); } - return false; } void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter) @@ -127,6 +126,7 @@ void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter) if (parent==nullptr) return; JKQTPdatastore* datastore=parent->getDatastore(); if (datastore==nullptr) return; + if (dataColumn<0) return; drawErrorsBefore(painter); @@ -135,14 +135,14 @@ void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter) QPen p=getLinePen(painter); p.setCapStyle(Qt::FlatCap); - int imax=datastore->getColumn(dataColumn).getRows(); + int imax=static_cast(datastore->getColumn(static_cast(dataColumn)).getRows()); int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax(imin, getDataIndex(static_cast(iii)), imax); const double xv=datastore->get(dataColumn,i); if (JKQTPIsOKFloat(xv)) { lines<(imin, getDataIndex(iii), imax); const double yv=datastore->get(dataColumn,i); if (JKQTPIsOKFloat(yv)) { lines<-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxx2p(0); - if (parent->getXAxis()->isLogAxis()) x0=xAxis->x2p(parent->getXAxis()->getMin()); + //double x0=xAxis->x2p(0); + //if (parent->getXAxis()->isLogAxis()) x0=xAxis->x2p(parent->getXAxis()->getMin()); double y0=yAxis->x2p(0); if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin()); bool subsequentItem=false; @@ -774,10 +774,10 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) { int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxx2p(0); if (parent->getXAxis()->isLogAxis()) x0=xAxis->x2p(parent->getXAxis()->getMin()); - double y0=yAxis->x2p(0); - if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin()); + //double y0=yAxis->x2p(0); + //if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin()); bool first=false; intSortData(); for (int iii=imin; iii-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax linecols; QVector linecolss; + QVector linewidths; intSortData(); double specSymbSize=0; bool hasSpecSymbSize=false; @@ -1368,6 +1369,7 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter) double y=yAxis->x2p(yv); if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { double symbSize= parent->pt2px(painter, getLocalSymbolSize(i)); + double lineW= parent->pt2px(painter, getLocalLineWidth(i)); if (gridModeForSymbolSize) { if (!hasSpecSymbSize) { @@ -1394,6 +1396,7 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter) linecols<=0) { + if (colorColumn>=0 || linewidthColumn>=0) { for (int i=0; ipt2px(painter, this->symbolSize); + if (symbolSize1>minSize*0.9) symbolSize1=minSize*0.9; + if (symbolSize1pt2px(painter, this->symbolSize*0.75); + if (symbolSize2>minSize*0.6) symbolSize2=minSize*0.5; + if (symbolSize2=0 && colorColumnContainsRGB) { + color1=QColor("red"); + color2=QColor("blue"); + } + + if (colorColumn>=0 && !colorColumnContainsRGB) { + QImage img; + double colorval[]={0,1}; + JKQTPimagePlot_array2image(colorval, 2, 1, img, get_palette(), double(0.0), double(1.0)); + color1=img.pixel(0,0); + color2=img.pixel(1,0); + } + + double symbolWidth=parent->pt2px(painter, this->symbolWidth*0.7*parent->get_lineWidthMultiplier()); + if (symbolWidth>0.2*symbolSize) symbolWidth=0.3*symbolSize; + double lineWidth=parent->pt2px(painter, this->lineWidth*0.7*parent->get_lineWidthMultiplier()); + if (lineWidth>0.1*maxSize) lineWidth=0.1*maxSize; + + painter.save(); + QPen p=painter.pen(); + p.setColor(color1); + p.setStyle(style); + p.setWidthF(lineWidth); + painter.setPen(p); + double x1=rect.left()+symbolSize1/2.0; + double y1=rect.top()+symbolSize1/2.0; + double x2=rect.right()-symbolSize2/2.0; + double y2=rect.bottom()-symbolSize2/2.0; + JKQTPplotSymbol(painter, x1, y1, symbol, symbolSize1, symbolWidth, color1, color1.lighter()); + JKQTPplotSymbol(painter, x2, y2, symbol, symbolSize2, symbolWidth, color2, color2.lighter()); + if (drawLine) painter.drawLine(x1,y1, x2,y2); + painter.restore(); +} + QColor JKQTPxyParametrizedScatterGraph::getKeyLabelColor() { return getLocalColor(-1); @@ -1458,13 +1514,13 @@ void JKQTPxyParametrizedScatterGraph::setParent(JKQtBasePlotter *parent) void JKQTPxyParametrizedScatterGraph::getOutsideSize(JKQTPEnhancedPainter &painter, int &leftSpace, int &rightSpace, int &topSpace, int &bottomSpace) { JKQTPxyLineGraph::getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); - if (showColorBar&& colorColumn>=0) cbGetOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); + if (showColorBar&& colorColumn>=0 && !colorColumnContainsRGB) cbGetOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace); } void JKQTPxyParametrizedScatterGraph::drawOutside(JKQTPEnhancedPainter &painter, QRect leftSpace, QRect rightSpace, QRect topSpace, QRect bottomSpace) { JKQTPxyLineGraph::drawOutside(painter, leftSpace, rightSpace, topSpace, bottomSpace); - if (showColorBar&& colorColumn>=0) cbDrawOutside(painter, leftSpace, rightSpace, topSpace, bottomSpace); + if (showColorBar&& colorColumn>=0 && !colorColumnContainsRGB) cbDrawOutside(painter, leftSpace, rightSpace, topSpace, bottomSpace); } void JKQTPxyParametrizedScatterGraph::cbGetDataMinMax(double &dmin, double &dmax) @@ -1479,10 +1535,10 @@ void JKQTPxyParametrizedScatterGraph::cbGetDataMinMax(double &dmin, double &dmax int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxget(sizeColumn,i); } +double JKQTPxyParametrizedScatterGraph::getLocalLineWidth(int i) +{ + if (parent==nullptr) return lineWidth; + JKQTPdatastore* datastore=parent->getDatastore(); + if (datastore==nullptr) return lineWidth; + if (linewidthColumn<0) return lineWidth; + if (i>=(int64_t)datastore->getColumn(linewidthColumn).getRows()) return lineWidth; + return datastore->get(linewidthColumn,i); +} + QColor JKQTPxyParametrizedScatterGraph::getLocalColor(int i) { if (parent==nullptr) return color; @@ -1571,10 +1637,10 @@ JKQTPgraphSymbols JKQTPxyParametrizedScatterGraph::getLocalSymbolType(int i) JKQTPdatastore* datastore=parent->getDatastore(); if (datastore==nullptr) return symbol; if (symbolColumn<0) return symbol; - if (i>=(int64_t)datastore->getColumn(symbolColumn).getRows()) return symbol; - int id=floor(datastore->get(symbolColumn,i)); - if (id<0 || id>JKQTPmaxSymbolID) return symbol; - return JKQTPgraphSymbols(id); + if (i>=static_cast(datastore->getColumn(symbolColumn).getRows())) return symbol; + int id=static_cast(floor(datastore->get(symbolColumn,i))); + if (id<0) return symbol; + return JKQTPgraphSymbols(id%(JKQTPmaxSymbolID+1)); } @@ -1596,10 +1662,10 @@ bool JKQTPxyParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imaxgetColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()), datastore->getColumn(static_cast(yColumn2)).getRows()); // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax -inline QVector JKQTPimagePlot_arrayToVector(const T* input, long long N) { +inline QVector JKQTPimagePlot_arrayToVector(const T* input, int N) { if (!input || N<=0) return QVector(); T dummy; QVector out(N, dummy); @@ -220,7 +220,7 @@ inline double JKQTPimagePlot_getImageMin(T* dbl, int width, int height) bool first=true; for (int i=1; i(v)) || std::isinf(static_cast(v)))) { if (first) { min=max=v; @@ -251,7 +251,7 @@ inline double JKQTPimagePlot_getImageMax(T* dbl, int width, int height) bool first=true; for (int i=1; i(v)) || std::isinf(static_cast(v)))) { if (first) { min=max=v; @@ -295,7 +295,7 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma if (minColor == maxColor) { for (int i=1; i(v))) { if (first) { min=max=v; @@ -331,34 +331,34 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma if (rgbMode==JKQTPRGBMathImageModeRGBMode) { //qDebug()<<"RGBMode"; if (channel==0) { - for (register int j=0; j 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; //if (j==5) qDebug()<<"r: "< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; //if (j==5) qDebug()<<"g: "< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; //if (j==5) qDebug()<<"b: "< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; //if (j==5) qDebug()<<"r: "< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; //if (j==5) qDebug()<<"g: "< 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; //if (j==5) qDebug()<<"b: "< 360) ? 360 : v); QColor l=QColor::fromRgb(line[i]); @@ -415,9 +415,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } } else if (channel==1) { - for (register int j=0; j 255) ? 255 : v); QColor l=QColor::fromRgb(line[i]); @@ -428,9 +428,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } } else if (channel==2) { - for (register int j=0; j 255) ? 255 : v); QColor l=QColor::fromRgb(line[i]); @@ -444,9 +444,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } else if (rgbMode==JKQTPRGBMathImageModeHSLMode) { if (channel==0) { - for (register int j=0; j 360) ? 360 : v); QColor l=line[i]; @@ -455,9 +455,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } } else if (channel==1) { - for (register int j=0; j 255) ? 255 : v); QColor l=line[i]; @@ -466,9 +466,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } } else if (channel==2) { - for (register int j=0; j 255) ? 255 : v); QColor l=line[i]; @@ -480,19 +480,19 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } if (channel==3) { - for (register int j=0; j 255) ? 255 : v); - const register QRgb l=line[i]; + const QRgb l=line[i]; line[i]=qRgba(qRed(l),qGreen(l),qBlue(l),v); } } } else if (channel==4) { - for (register int j=0; j 255) ? 255 : v); QColor c=QColor::fromRgba(line[i]); @@ -501,9 +501,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma } } } else if (channel==5) { - for (register int j=0; j 255) ? 255 : v); QColor c=QColor::fromRgba(line[i]); @@ -573,7 +573,7 @@ extern LIB_EXPORT QList global_jkqtpimagetools_lutstore; \param infColor color to use for pixels that are infinity */ template -inline void JKQTPimagePlot_array2image(T* dbl_in, int width, int height, QImage &img, JKQTPMathImageColorPalette palette, T minColor, T maxColor, JKQTPMathImageColorRangeFailAction paletteMinFail=JKQTPMathImageLastPaletteColor, JKQTPMathImageColorRangeFailAction paletteMaxFail=JKQTPMathImageLastPaletteColor, QColor minFailColor=QColor("black"), QColor maxFailColor=QColor("black"), QColor nanColor=QColor("black"), QColor infColor=QColor("black"), bool logScale=false, double logBase=10.0, int* lutUser=0, int lutUserSize=0) +inline void JKQTPimagePlot_array2image(const T* dbl_in, int width, int height, QImage &img, JKQTPMathImageColorPalette palette, T minColor, T maxColor, JKQTPMathImageColorRangeFailAction paletteMinFail=JKQTPMathImageLastPaletteColor, JKQTPMathImageColorRangeFailAction paletteMaxFail=JKQTPMathImageLastPaletteColor, QColor minFailColor=QColor("black"), QColor maxFailColor=QColor("black"), QColor nanColor=QColor("black"), QColor infColor=QColor("black"), bool logScale=false, double logBase=10.0, const int* lutUser=0, int lutUserSize=0) { if (!dbl_in || width<=0 || height<=0) return; @@ -584,7 +584,7 @@ inline void JKQTPimagePlot_array2image(T* dbl_in, int width, int height, QImage bool first=true; for (int i=1; i(v)) || std::isinf(static_cast(v)))) { if (first) { min=max=v; @@ -603,21 +603,23 @@ inline void JKQTPimagePlot_array2image(T* dbl_in, int width, int height, QImage max = maxColor; } - T* dbl=dbl_in; + const T* dbl=dbl_in; + T* dbl1=nullptr; if (logScale) { double logB=log10(logBase); - dbl=(T*)malloc(width*height*sizeof(T)); + dbl1=(T*)malloc(width*height*sizeof(T)); //memcpy(dbl, dbl_in, width*height*sizeof(T)); for (int i=0; i(nullptr, JKQTPimagePlot_getPredefinedPalettes().size()+2); @@ -638,19 +640,20 @@ inline void JKQTPimagePlot_array2image(T* dbl_in, int width, int height, QImage if (lut_used!=nullptr && lutSize>0) { + const unsigned int* lut_usedui=reinterpret_cast(lut_used); // LUT found: collor the image accordingly - for (register int j=0; j(img.scanLine(height-1-j)); + for (int i=0; i lutSize) ? (lutSize) : v); - line[i]=lut_used[vv]; + const int v = static_cast((val-min)/delta*static_cast(lutSize)); + const int vv = (v < 0) ? 0 : ( (v > lutSize) ? (lutSize) : v); + line[i]=lut_usedui[vv]; if ((v<0)&&(paletteMinFail==JKQTPMathImageGivenColor)) { line[i]=minFailColor.rgba(); } else if ((v>lutSize)&&(paletteMaxFail==JKQTPMathImageGivenColor)) { @@ -669,12 +672,12 @@ inline void JKQTPimagePlot_array2image(T* dbl_in, int width, int height, QImage } } - if (logScale) free(dbl); + if (dbl1) free(dbl1); }; template -inline void JKQTPimagePlot_array2image(T* dbl_in, int width, int height, QImage &img, int* lutUser, int lutUserSize, T minColor, T maxColor, JKQTPMathImageColorRangeFailAction paletteMinFail=JKQTPMathImageLastPaletteColor, JKQTPMathImageColorRangeFailAction paletteMaxFail=JKQTPMathImageLastPaletteColor, QColor minFailColor=QColor("black"), QColor maxFailColor=QColor("black"), QColor nanColor=QColor("black"), QColor infColor=QColor("black"), bool logScale=false, double logBase=10.0) +inline void JKQTPimagePlot_array2image(const T* dbl_in, int width, int height, QImage &img, const int* lutUser, int lutUserSize, T minColor, T maxColor, JKQTPMathImageColorRangeFailAction paletteMinFail=JKQTPMathImageLastPaletteColor, JKQTPMathImageColorRangeFailAction paletteMaxFail=JKQTPMathImageLastPaletteColor, QColor minFailColor=QColor("black"), QColor maxFailColor=QColor("black"), QColor nanColor=QColor("black"), QColor infColor=QColor("black"), bool logScale=false, double logBase=10.0) { JKQTPimagePlot_array2image(dbl_in, width, height, img, JKQTPMathImageUSER_PALETTE, minColor, maxColor, paletteMinFail, paletteMaxFail, minFailColor, maxFailColor, nanColor, infColor, logScale, logBase, lutUser, lutUserSize); } diff --git a/lib/jkqtplotter/jkqtpimpulseselements.cpp b/lib/jkqtplotter/jkqtpimpulseselements.cpp index 75a912bfe2..4aed0ebc4e 100644 --- a/lib/jkqtplotter/jkqtpimpulseselements.cpp +++ b/lib/jkqtplotter/jkqtpimpulseselements.cpp @@ -83,10 +83,10 @@ void JKQTPimpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) { int imin=0; // interpret data ranges if (datarange_start>-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax-1) { - imin=qMin(datarange_start, static_cast(imax)); + imin=qMin(datarange_start, static_cast(imax)); } if (datarange_end>-1) { - imax=qMin(datarange_end, static_cast(imax)); + imax=qMin(datarange_end, static_cast(imax)); } if (imax -inline void jkqtpSwap(T* a, long long l, long long r){ +inline void jkqtpSwap(T* a, int l, int r){ const T tmp=a[l]; a[l]=a[r]; a[r]=tmp; @@ -1213,10 +1213,10 @@ inline void jkqtpSwap(T* a, long long l, long long r){ implementation from http://www.linux-related.de/index.html?/coding/sort/sort_quick.htm */ template -inline void jkqtpQuicksort(T* a, long long l, long long r){ +inline void jkqtpQuicksort(T* a, int l, int r){ if(r>l){ - long long i=l-1; - long long j=r; + int i=l-1; + int j=r; for(;;){ while(a[++i] -inline void jkqtpQuicksort(T* a, T2* a2, long long l, long long r){ +inline void jkqtpQuicksort(T* a, T2* a2, int l, int r){ if(r>l){ - long long i=l-1; - long long j=r; + int i=l-1; + int j=r; for(;;){ while(a[++i] -inline void jkqtpSort(T* input, T2* input2, long long N, T* output=nullptr, T2* output2=nullptr) { +inline void jkqtpSort(T* input, T2* input2, int N, T* output=nullptr, T2* output2=nullptr) { if ((!input)) return ; if (N<=0) return; T* data=input;