added function to JKQTPPlotElement that allow to transform a complete vector of x- or y-values in one call

This commit is contained in:
jkriege2 2019-06-16 19:15:07 +02:00
parent 56d59b1760
commit 1363cf7012
2 changed files with 24 additions and 0 deletions

View File

@ -239,6 +239,25 @@ double JKQTPPlotElement::transformY(double y) const {
return parent->getYAxis()->x2p(y);
}
QVector<double> JKQTPPlotElement::transformX(const QVector<double>& x) const {
QVector<double> res;
res.resize(x.size());
for (int i=0; i<x.size(); i++) {
res[i]=parent->getXAxis()->x2p(x[i]);
}
return res;
}
QVector<double> JKQTPPlotElement::transformY(const QVector<double>& y) const {
QVector<double> res;
res.resize(y.size());
for (int i=0; i<y.size(); i++) {
res[i]=parent->getYAxis()->x2p(y[i]);
}
return res;
}
double JKQTPPlotElement::backtransformX(double x) const {
return parent->getXAxis()->p2x(x);
}

View File

@ -244,6 +244,11 @@ class JKQTP_LIB_EXPORT JKQTPPlotElement: public QObject {
return QPolygonF(transform(x));
}
/** \brief transform all x-coordinates in a vector \a x */
QVector<double> transformX(const QVector<double>& x) const;
/** \brief transform all y-coordinates in a vector \a x */
QVector<double> transformY(const QVector<double>& x) const;
/** \brief clear the internal datastore for hitTest()
*