fixed some compiler warnings

added possibility to modify line width in JKQTPxyParametrizedScatterGraph
improved key symbols of JKQTPxyParametrizedScatterGraph
This commit is contained in:
jkriege2 2018-12-16 14:59:39 +01:00
parent 48c376fe1b
commit 4099cfcd7e
13 changed files with 338 additions and 209 deletions

View File

@ -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<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end+1, static_cast<long long>(imax));
imax=qMin(datarange_end+1, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -146,8 +146,8 @@ void JKQTPbarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(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<size_t>(yColumn),static_cast<size_t>(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<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -221,8 +221,8 @@ bool JKQTPbarVerticalGraph::getXMinMax(double& minx, double& maxx, double& small
for (int i=imin; i<imax; i++) {
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(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<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -388,10 +388,10 @@ void JKQTPbarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end+1, static_cast<long long>(imax));
imax=qMin(datarange_end+1, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -415,8 +415,8 @@ void JKQTPbarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(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<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(xColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -529,10 +529,10 @@ bool JKQTPbarHorizontalGraph::getYMinMax(double& miny, double& maxy, double& sma
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -545,8 +545,8 @@ bool JKQTPbarHorizontalGraph::getYMinMax(double& miny, double& maxy, double& sma
for (int i=imin; i<imax; i++) {
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(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<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -738,10 +738,10 @@ bool JKQTPbarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -786,10 +786,10 @@ bool JKQTPbarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;

View File

@ -129,10 +129,10 @@ bool JKQTPgraph::getDataMinMax(int column, double &minx, double &maxx, double &s
int imax=datastore->getColumn(column).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -226,10 +226,10 @@ bool JKQTPxyGraph::getXMinMax(double& minx, double& maxx, double& smallestGreate
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -265,10 +265,10 @@ bool JKQTPxyGraph::getYMinMax(double& miny, double& maxy, double& smallestGreate
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -453,10 +453,10 @@ void JKQTPsingleColumnGraph::intSortData()
int imax=datastore->getColumn(dataColumn).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -506,7 +506,7 @@ JKQTPgraphErrors::JKQTPgraphErrors(QColor graphColor) {
void JKQTPgraphErrors::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, long long datarange_end, int xErrorColumnLower, int yErrorColumnLower, bool xErrorSymmetric, bool yErrorSymmetric, double xrelshift, double yrelshift, const QVector<int>* 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<int>* dataorder) {
//std::cout<<"JKQTPgraphErrors::intPlotXYErrorIndicators(p, "<<parent<<", "<<xColumn<<", "<<yColumn<<", "<<xErrorColumn<<", "<<yErrorColumn<<", "<<xErrorStyle<<", "<<yErrorStyle<<", ...)\n";
if (parent==nullptr) return;
JKQTPdatastore* datastore=parent->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<size_t>(xColumn)).getRows();
if (yColumn>=0) imaxy=datastore->getColumn(static_cast<size_t>(yColumn)).getRows();
int imax=qMin(imaxx, imaxy);
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -861,7 +861,7 @@ void JKQTPgraphErrors::intPlotXYErrorIndicators(JKQTPEnhancedPainter& painter, J
//std::cout<<"end\n";
}
bool JKQTPgraphErrors::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*/)
bool JKQTPgraphErrors::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*/)
{
return false;
}
@ -901,7 +901,7 @@ JKQTPxGraphErrors::JKQTPxGraphErrors(QColor graphColor):
xErrorColumnLower=-1;
}
void JKQTPxGraphErrors::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<int>* 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<int>* 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<int>* 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<int>* 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<int>* 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<int>* 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<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;

View File

@ -96,8 +96,8 @@ class LIB_EXPORT JKQTPgraph: public QObject {
virtual QColor getKeyLabelColor()=0;
JKQTPGET_SET_VMACRO(QString, title)
JKQTPGET_SET_MACRO(long long, datarange_start)
JKQTPGET_SET_MACRO(long long, datarange_end)
JKQTPGET_SET_MACRO(int, datarange_start)
JKQTPGET_SET_MACRO(int, datarange_end)
JKQTPGET_SET_MACRO(bool, visible)
/** \brief returns the parent painter class */
@ -174,9 +174,9 @@ class LIB_EXPORT JKQTPgraph: public QObject {
QString title;
/** \brief start of the range of plot data. -1 switches the lower data range border off. */
long long datarange_start;
int datarange_start;
/** \brief end of the range of plot data. -1 switches the upper data range border off. */
long long datarange_end;
int datarange_end;
/** \brief indicates whether the graph is visible in the plot */
bool visible;
@ -377,16 +377,16 @@ class LIB_EXPORT 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. This method is called by
* the JKQTPgraph descendents */
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<int>* 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<int>* 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<int> *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<int> *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<int> *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<int> *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<int> *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<int> *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<int> *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<int> *dataorder=nullptr);
virtual double getXErrorU(int i, JKQTPdatastore* ds) const;
virtual double getXErrorL(int i, JKQTPdatastore* ds) const;

View File

@ -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<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -264,10 +264,10 @@ bool JKQTPboxplotVerticalGraph::getXMinMax(double& minx, double& maxx, double& s
int imax=datastore->getColumn(posColumn).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -314,10 +314,10 @@ bool JKQTPboxplotVerticalGraph::getYMinMax(double& miny, double& maxy, double& s
int imax=datastore->getColumn(medianColumn).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -464,10 +464,10 @@ bool JKQTPboxplotHorizontalGraph::getXMinMax(double& miny, double& maxy, double&
int imax=datastore->getColumn(medianColumn).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -520,10 +520,10 @@ bool JKQTPboxplotHorizontalGraph::getYMinMax(double& minx, double& maxx, double&
int imax=datastore->getColumn(posColumn).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -584,10 +584,10 @@ void JKQTPboxplotHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -1171,10 +1171,10 @@ void JKQTPboxplotVerticalGraph::intSortData()
int imax=datastore->getColumn(posColumn).getRows();
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;

View File

@ -347,6 +347,11 @@ JKQTPcolumn JKQTPdatastore::getColumn(size_t i) const
return columns.value(i);
}
JKQTPcolumn JKQTPdatastore::getColumn(int i) const
{
return columns.value(i);
}
size_t JKQTPdatastore::addCopiedItem(JKQTPdatastoreItemFormat dataformat, double* data, size_t columnsnum, size_t rows) {
JKQTPdatastoreItem* it=nullptr;
if ((dataformat==JKQTPsingleColumn)||(columnsnum==1)) {
@ -537,12 +542,8 @@ size_t JKQTPdatastore::addLinearColumn(size_t rows, double start, double end, co
return addColumnForItem(itemid, 0, name);
}
/** \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 JKQTPdatastore::get(size_t column, size_t row) const {
return columns[column].getValue(row);
}
long long JKQTPdatastore::getNextLowerIndex(size_t column, size_t row, long long start, long long end) const
int JKQTPdatastore::getNextLowerIndex(size_t column, size_t row, int start, int end) const
{
const JKQTPcolumn& col=columns[column];
if (start<0 && end>=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)<d)||(d==0.0))) {
@ -569,12 +570,12 @@ long long JKQTPdatastore::getNextLowerIndex(size_t column, size_t row, long long
}
}
long long JKQTPdatastore::getNextLowerIndex(size_t column, size_t row) const
int JKQTPdatastore::getNextLowerIndex(size_t column, size_t row) const
{
return getNextLowerIndex(column, row, 0, columns[column].getRows()-1);
}
long long JKQTPdatastore::getNextHigherIndex(size_t column, size_t row, long long start, long long end) const
int JKQTPdatastore::getNextHigherIndex(size_t column, size_t row, int start, int end) const
{
const JKQTPcolumn& col=columns[column];
if (start<0 && end>=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)<d)||(d==0.0))) {
@ -598,16 +599,24 @@ long long JKQTPdatastore::getNextHigherIndex(size_t column, size_t row, long lon
}
}
long long JKQTPdatastore::getNextHigherIndex(size_t column, size_t row) const
int JKQTPdatastore::getNextHigherIndex(size_t column, size_t row) const
{
return getNextHigherIndex(column, row, 0, columns[column].getRows()-1);
}
void JKQTPdatastore::set(size_t column, size_t row, double value)
{
columns[column].setValue(row, value);
int JKQTPdatastore::getNextLowerIndex(int column, size_t row, int start, int end) const {
return getNextLowerIndex(static_cast<size_t>(column), row, start, end);
}
int JKQTPdatastore::getNextLowerIndex(int column, size_t row) const {
return getNextLowerIndex(static_cast<size_t>(column), row);
}
int JKQTPdatastore::getNextHigherIndex(int column, size_t row, int start, int end) const {
return getNextHigherIndex(static_cast<size_t>(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<size_t>(column), row);
}

View File

@ -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<size_t>(column), static_cast<size_t>(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<size_t>(column), static_cast<size_t>(row), value);
}
#endif // JKQTPDATASTORAGE_H

View File

@ -25,6 +25,7 @@
#include <QDebug>
#include <iostream>
#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<int>(datastore->getColumn(static_cast<size_t>(dataColumn)).getRows());
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -160,7 +160,7 @@ void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter)
}
intSortData();
for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax);
int i=qBound<int>(imin, getDataIndex(static_cast<int>(iii)), imax);
const double xv=datastore->get(dataColumn,i);
if (JKQTPIsOKFloat(xv)) {
lines<<QLineF(transform(xv, baseline), transform(xv, baseline+peakHeight));
@ -172,7 +172,7 @@ void JKQTPPeakStreamGraph::draw(JKQTPEnhancedPainter &painter)
}
intSortData();
for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax);
int i=qBound<int>(imin, getDataIndex(iii), imax);
const double yv=datastore->get(dataColumn,i);
if (JKQTPIsOKFloat(yv)) {
lines<<QLineF(transform(baseline, yv), transform(baseline+peakHeight, yv));
@ -311,10 +311,10 @@ void JKQTPxyLineGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -424,10 +424,10 @@ bool JKQTPxyLineErrorGraph::getXMinMax(double &minx, double &maxx, double &small
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -472,10 +472,10 @@ bool JKQTPxyLineErrorGraph::getYMinMax(double &miny, double &maxy, double &small
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -629,10 +629,10 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -648,8 +648,8 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
double yold=-1;
// double xstart=-1;
// double ystart=-1;
double x0=xAxis->x2p(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<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -793,8 +793,8 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
double yold=-1;
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());
//double y0=yAxis->x2p(0);
//if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin());
bool first=false;
intSortData();
for (int iii=imin; iii<imax; iii++) {
@ -1335,10 +1335,10 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -1356,6 +1356,7 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
QPolygonF linesP;
QVector<QColor> linecols;
QVector<QColor> linecolss;
QVector<double> 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<<symbColor;
lines<<QLineF(xl1, yl1, xl2, yl2);
linesP<<QPointF(x,y);
linewidths<<lineW;
}
if (drawSelectionLine && symbol!=JKQTPnoSymbol && symbolColumn<0) {
@ -1427,9 +1430,10 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
}
}
QPen pp=p;
if (colorColumn>=0) {
if (colorColumn>=0 || linewidthColumn>=0) {
for (int i=0; i<lines.size(); i++) {
pp.setColor(linecols.value(i, selectionLineColor));
pp.setColor(linecols.value(i, color));
pp.setWidthF(linewidths.value(i, lineWidth));
painter.setPen(pp);
painter.drawLine(lines[i]);
}
@ -1444,6 +1448,58 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
drawErrorsAfter(painter);
}
void JKQTPxyParametrizedScatterGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
{
const double minSize=qMin(rect.width(), rect.height());
const double maxSize=qMax(rect.width(), rect.height());
double symbolSize1=parent->pt2px(painter, this->symbolSize);
if (symbolSize1>minSize*0.9) symbolSize1=minSize*0.9;
if (symbolSize1<minSize*0.6) symbolSize1=minSize*0.6;
double symbolSize2=parent->pt2px(painter, this->symbolSize*0.75);
if (symbolSize2>minSize*0.6) symbolSize2=minSize*0.5;
if (symbolSize2<minSize*0.5) symbolSize2=minSize*0.5;
if (sizeColumn<0) {
symbolSize2=symbolSize1;
}
QColor color1=getKeyLabelColor();
QColor color2=getKeyLabelColor();
if (colorColumn>=0 && colorColumnContainsRGB) {
color1=QColor("red");
color2=QColor("blue");
}
if (colorColumn>=0 && !colorColumnContainsRGB) {
QImage img;
double colorval[]={0,1};
JKQTPimagePlot_array2image<double>(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<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -1513,7 +1569,7 @@ void JKQTPxyParametrizedScatterGraph::cbGetDataMinMax(double &dmin, double &dmax
bool JKQTPxyParametrizedScatterGraph::usesColumn(int c)
{
return (c==colorColumn) || (c==sizeColumn) || (c==symbolColumn) || JKQTPxyLineGraph::usesColumn(c);
return (c==colorColumn) || (c==sizeColumn) || (c==symbolColumn) || (c==linewidthColumn) || JKQTPxyLineGraph::usesColumn(c);
}
double JKQTPxyParametrizedScatterGraph::getInternalDataMin() const
@ -1536,6 +1592,16 @@ double JKQTPxyParametrizedScatterGraph::getLocalSymbolSize(int i)
return datastore->get(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<int64_t>(datastore->getColumn(symbolColumn).getRows())) return symbol;
int id=static_cast<int>(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<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -1645,10 +1711,10 @@ bool JKQTPxyParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy
int imax=qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -1690,7 +1756,7 @@ void JKQTPxyParametrizedErrorScatterGraph::drawErrorsBefore(JKQTPEnhancedPainter
else plotErrorIndicators(painter, parent, xAxis, yAxis, xColumn, yColumn, datarange_start, datarange_end, 0, 0, &sortedIndices);
}
bool JKQTPxyParametrizedErrorScatterGraph::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*/)
bool JKQTPxyParametrizedErrorScatterGraph::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*/)
{
QColor c=getLocalColor(index);
errorColor=c.darker();

View File

@ -198,7 +198,8 @@ class LIB_EXPORT JKQTPxyParametrizedScatterGraph: public JKQTPxyLineGraph, publi
/** \brief plots the graph to the plotter object specified as parent */
virtual void draw(JKQTPEnhancedPainter& painter);
/** \brief plots a key marker inside the specified rectangle \a rect */
virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect);
/** \brief returns the color to be used for the key label */
virtual QColor getKeyLabelColor();
@ -208,6 +209,8 @@ class LIB_EXPORT JKQTPxyParametrizedScatterGraph: public JKQTPxyLineGraph, publi
JKQTPSET_CAST_MACRO(size_t, int, colorColumn)
JKQTPGET_SET_MACRO(int, symbolColumn)
JKQTPSET_CAST_MACRO(size_t, int, symbolColumn)
JKQTPGET_SET_MACRO(int, linewidthColumn)
JKQTPSET_CAST_MACRO(size_t, int, linewidthColumn)
JKQTPGET_SET_MACRO(bool, colorColumnContainsRGB)
JKQTPGET_SET_MACRO(bool, gridModeForSymbolSize)
JKQTPGET_SET_MACRO(double, gridDeltaX)
@ -247,6 +250,8 @@ class LIB_EXPORT JKQTPxyParametrizedScatterGraph: public JKQTPxyLineGraph, publi
int colorColumn;
/** \brief this column contains the symbol type */
int symbolColumn;
/** \brief this column contains the line width */
int linewidthColumn;
/** \brief if the gridModeForSymbolSize mode is actiavted (false), the plot assumes that the scatter symbols are ordered in a grid. It the uses the given griDeltaX and gridDeltaY to calculate the symbol size, so they fill the available space to a fraction gridSymbolFractionSize. */
bool gridModeForSymbolSize;
@ -260,6 +265,7 @@ class LIB_EXPORT JKQTPxyParametrizedScatterGraph: public JKQTPxyLineGraph, publi
/** \brief if this is true, the value in the colorColumn is converted to an integer, representing a color in ARGB format (as in QRgb) */
bool colorColumnContainsRGB;
double getLocalLineWidth(int i);
double getLocalSymbolSize(int i);
QColor getLocalColor(int i);
JKQTPgraphSymbols getLocalSymbolType(int i);
@ -350,7 +356,7 @@ class LIB_EXPORT JKQTPxyParametrizedErrorScatterGraph: public JKQTPxyParametrize
/** \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);
};

View File

@ -110,10 +110,10 @@ void JKQTPfilledCurveXGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -286,10 +286,10 @@ void JKQTPfilledCurveYGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -518,10 +518,10 @@ bool JKQTPfilledVerticalRangeGraph::getYMinMax(double &miny, double &maxy, doubl
int imax=qMin(qMin(datastore->getColumn(static_cast<size_t>(xColumn)).getRows(), datastore->getColumn(static_cast<size_t>(yColumn)).getRows()), datastore->getColumn(static_cast<size_t>(yColumn2)).getRows());
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -586,10 +586,10 @@ void JKQTPfilledVerticalRangeGraph::draw(JKQTPEnhancedPainter &painter)
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;

View File

@ -170,7 +170,7 @@ enum JKQTPRGBMathImageRGBMode {
*/
template <class T>
inline QVector<T> JKQTPimagePlot_arrayToVector(const T* input, long long N) {
inline QVector<T> JKQTPimagePlot_arrayToVector(const T* input, int N) {
if (!input || N<=0) return QVector<double>();
T dummy;
QVector<T> 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<width*height; ++i)
{
register T v=dbl[i];
T v=dbl[i];
if (!(std::isnan(static_cast<long double>(v)) || std::isinf(static_cast<long double>(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<width*height; ++i)
{
register T v=dbl[i];
T v=dbl[i];
if (!(std::isnan(static_cast<long double>(v)) || std::isinf(static_cast<long double>(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<width*height; ++i)
{
register T v=dbl_in[i];
T v=dbl_in[i];
if (std::isfinite(static_cast<long double>(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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = trunc(double(dbl[j*width+i]-min)*255.0/delta);
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
const register QRgb l=line[i];
const QRgb l=line[i];
//if (j==5) qDebug()<<"r: "<<v<<qGreen(l)<<qBlue(l)<<qAlpha(255);
line[i]=qRgb(v,qGreen(l),qBlue(l));
}
}
} else if (channel==1) {
for (register int j=0; j<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
const register QRgb l=line[i];
const QRgb l=line[i];
//if (j==5) qDebug()<<"g: "<<qRed(l)<<v<<qBlue(l)<<qAlpha(255);
line[i]=qRgb(qRed(l),v,qBlue(l));
}
}
} else if (channel==2) {
for (register int j=0; j<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
const register QRgb l=line[i];
const QRgb l=line[i];
//if (j==5) qDebug()<<"b: "<<qRed(l)<<qGreen(l)<<v<<qAlpha(255);
line[i]=qRgb(qRed(l),qGreen(l),v);
}
@ -367,34 +367,34 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma
} else if (rgbMode==JKQTPRGBMathImageModeCMYMode) {
//qDebug()<<"RGBMode";
if (channel==0) {
for (register int j=0; j<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = trunc(double(dbl[j*width+i]-min)*255.0/delta);
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
const register QRgb l=line[i];
const QRgb l=line[i];
//if (j==5) qDebug()<<"r: "<<v<<qGreen(l)<<qBlue(l)<<qAlpha(255);
line[i]=QColor::fromCmyk(v,QColor(l).magenta(),QColor(l).yellow(),QColor(l).black()).rgba();
}
}
} else if (channel==1) {
for (register int j=0; j<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
const register QRgb l=line[i];
const QRgb l=line[i];
//if (j==5) qDebug()<<"g: "<<qRed(l)<<v<<qBlue(l)<<qAlpha(255);
line[i]=QColor::fromCmyk(QColor(l).cyan(),v,QColor(l).yellow(),QColor(l).black()).rgba();
}
}
} else if (channel==2) {
for (register int j=0; j<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
const register QRgb l=line[i];
const QRgb l=line[i];
//if (j==5) qDebug()<<"b: "<<qRed(l)<<qGreen(l)<<v<<qAlpha(255);
line[i]=QColor::fromCmyk(QColor(l).cyan(),QColor(l).magenta(),v,QColor(l).black()).rgba();
}
@ -402,9 +402,9 @@ inline void JKQTPimagePlot_array2RGBimage(T* dbl_in, int width, int height, QIma
}
} else if (rgbMode==JKQTPRGBMathImageModeHSVMode) {
if (channel==0) {
for (register int j=0; j<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = trunc(double(dbl[j*width+i]-min)*220.0/delta);
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = trunc(double(dbl[j*width+i]-min)*255.0/delta);
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 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<height; ++j) {
for (int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
for (int i=0; i<width; ++i) {
int v = (dbl[j*width+i]-min)*255/delta;
v = (v < 0) ? 0 : ( (v > 255) ? 255 : v);
QColor c=QColor::fromRgba(line[i]);
@ -573,7 +573,7 @@ extern LIB_EXPORT QList<int*> global_jkqtpimagetools_lutstore;
\param infColor color to use for pixels that are infinity
*/
template <class T>
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<width*height; ++i)
{
register T v=dbl_in[i];
T v=dbl_in[i];
if (!(std::isnan(static_cast<long double>(v)) || std::isinf(static_cast<long double>(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<width*height; i++) {
dbl[i]=log10(dbl_in[i])/logB;
dbl1[i]=log10(dbl_in[i])/logB;
}
dbl=dbl1;
min=log10(min)/logB;
max=log10(max)/logB;
}
double delta=max-min;
int* lut_used=nullptr;
const int* lut_used=nullptr;
int lutSize=JKQTPimagePlot_LUTSIZE;
if (global_jkqtpimagetools_lutstore.size()<=0) global_jkqtpimagetools_lutstore=JKQTPimagePlot_makeQList<int*>(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<const unsigned int*>(lut_used);
// LUT found: collor the image accordingly
for (register int j=0; j<height; ++j) {
QRgb* line=(QRgb*)(img.scanLine(height-1-j));
for (register int i=0; i<width; ++i) {
register double val=dbl[j*width+i];
for (int j=0; j<height; ++j) {
QRgb* line=reinterpret_cast<QRgb*>(img.scanLine(height-1-j));
for (int i=0; i<width; ++i) {
double val=dbl[j*width+i];
if (std::isnan(val)) {
line[i]=nanColor.rgba();
} else if (std::isinf(val)) {
line[i]=infColor.rgba();
} else {
register int v = (val-min)/delta*lutSize;
register int vv = (v < 0) ? 0 : ( (v > lutSize) ? (lutSize) : v);
line[i]=lut_used[vv];
const int v = static_cast<int>((val-min)/delta*static_cast<double>(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 <class T>
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);
}

View File

@ -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<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;
@ -197,10 +197,10 @@ void JKQTPimpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
int imin=0;
// interpret data ranges
if (datarange_start>-1) {
imin=qMin(datarange_start, static_cast<long long>(imax));
imin=qMin(datarange_start, static_cast<int>(imax));
}
if (datarange_end>-1) {
imax=qMin(datarange_end, static_cast<long long>(imax));
imax=qMin(datarange_end, static_cast<int>(imax));
}
if (imax<imin) {
int h=imin;

View File

@ -59,7 +59,7 @@ double JKQTPHighResTimer::get_time(){
struct timeval tv;
gettimeofday(&tv,0);
long long t1, t2;
int t1, t2;
t1 = last.tv_sec * 1000000 + last.tv_usec;
t2 = tv.tv_sec * 1000000 + tv.tv_usec;
return abs(t2 - t1);

View File

@ -1198,7 +1198,7 @@ LIB_EXPORT QPolygonF jkqtpRotateRect(QRectF r, double angle);
*/
template <class T>
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 <class T>
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]<a[r]);
@ -1238,10 +1238,10 @@ inline void jkqtpQuicksort(T* a, long long l, long long r){
implementation from http://www.linux-related.de/index.html?/coding/sort/sort_quick.htm
*/
template <class T, class T2>
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]<a[r]);
@ -1274,7 +1274,7 @@ inline void jkqtpQuicksort(T* a, T2* a2, long long l, long long r){
*/
template <class T, class T2>
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;