improved code (removed code repeats by using getIndexRange(), using const where appropriate)

This commit is contained in:
jkriege2 2020-09-19 15:39:02 +02:00
parent 7e425e7bb5
commit abe1c655ba
5 changed files with 403 additions and 498 deletions

View File

@ -53,27 +53,17 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
JKQTPAutoOutputTimer jkaaot("JKQTPBarHorizontalGraph::draw"); JKQTPAutoOutputTimer jkaaot("JKQTPBarHorizontalGraph::draw");
#endif #endif
if (parent==nullptr) return; if (parent==nullptr) return;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
if (datastore==nullptr) return; if (datastore==nullptr) return;
drawErrorsBefore(painter); drawErrorsBefore(painter);
QPen p=getLinePenForRects(painter, parent); const QPen p=getLinePenForRects(painter, parent);
const QBrush b=getFillBrush(painter, parent);
QBrush b=getFillBrush(painter, parent); int imax=0;
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
int imin=0; int imin=0;
if (getIndexRange(imin, imax)) {
if (imax<imin) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
{
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
// double x0=transformX(0); // double x0=transformX(0);
@ -87,9 +77,9 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
const bool hasStackPar=hasStackParent(); const bool hasStackPar=hasStackParent();
for (int iii=imin; iii<imax; iii++) { for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax); int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i)); const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
int sr=datastore->getNextLowerIndex(xColumn, i); const int sr=datastore->getNextLowerIndex(xColumn, i);
int lr=datastore->getNextHigherIndex(xColumn, i); const int lr=datastore->getNextHigherIndex(xColumn, i);
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i)); double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
double yv0=y0; double yv0=y0;
if (!qFuzzyIsNull(getBaseline())) yv0=transformY(getBaseline()); if (!qFuzzyIsNull(getBaseline())) yv0=transformY(getBaseline());
@ -114,9 +104,9 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
delta=deltap+deltam; delta=deltap+deltam;
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=transformX(xv+shift*delta-width*deltam); const double x=transformX(xv+shift*delta-width*deltam);
double y=transformY(yv); double y=transformY(yv);
double xx=transformX(xv+shift*delta+width*deltap); const double xx=transformX(xv+shift*delta+width*deltap);
double yy=yv0; double yy=yv0;
//std::cout<<"delta="<<delta<<" x="<<x<<" y="<<y<<" xx="<<xx<<" yy="<<yy<<std::endl; //std::cout<<"delta="<<delta<<" x="<<x<<" y="<<y<<" xx="<<xx<<" yy="<<yy<<std::endl;
@ -239,83 +229,76 @@ void JKQTPBarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
JKQTPAutoOutputTimer jkaaot("JKQTPBarVerticalGraph::draw"); JKQTPAutoOutputTimer jkaaot("JKQTPBarVerticalGraph::draw");
#endif #endif
if (parent==nullptr) return; if (parent==nullptr) return;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
if (datastore==nullptr) return; if (datastore==nullptr) return;
drawErrorsBefore(painter); drawErrorsBefore(painter);
QPen p=getLinePenForRects(painter, parent); const QPen p=getLinePenForRects(painter, parent);
const QBrush b=getFillBrush(painter, parent);
QBrush b=getFillBrush(painter, parent); int imax=0;
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
int imin=0; int imin=0;
if (imax<imin) { if (getIndexRange(imin, imax)) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
double x0=transformX(0); double x0=transformX(0);
if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin()); if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin());
// double y0=transformY(0); // double y0=transformY(0);
// if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin()); // if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin());
{ {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
intSortData(); intSortData();
const bool hasStackPar=hasStackParent(); const bool hasStackPar=hasStackParent();
double delta=1; double delta=1;
double deltap=0; double deltap=0;
double deltam=0; double deltam=0;
for (int iii=imin; iii<imax; iii++) { for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax); int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i)); 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)); double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
int sr=datastore->getNextLowerIndex(yColumn, i); int sr=datastore->getNextLowerIndex(yColumn, i);
int lr=datastore->getNextHigherIndex(yColumn, i); int lr=datastore->getNextHigherIndex(yColumn, i);
double xv0=x0; double xv0=x0;
if (!qFuzzyIsNull(getBaseline())) xv0=transformX(getBaseline()); if (!qFuzzyIsNull(getBaseline())) xv0=transformX(getBaseline());
if (hasStackPar) { if (hasStackPar) {
double stackLastX=getParentStackedMax(i); double stackLastX=getParentStackedMax(i);
const double xvold=xv; const double xvold=xv;
xv0=transformX(stackLastX)+(getLineWidth()); xv0=transformX(stackLastX)+(getLineWidth());
xv=stackLastX+xvold; xv=stackLastX+xvold;
} }
if (sr<0 && lr<0) { // only one y-value if (sr<0 && lr<0) { // only one y-value
deltam=0.5; deltam=0.5;
deltap=0.5; deltap=0.5;
} else if (lr<0) { // the right-most y-value } else if (lr<0) { // the right-most y-value
deltap=deltam=fabs(yv-datastore->get(yColumn,sr))/2.0; deltap=deltam=fabs(yv-datastore->get(yColumn,sr))/2.0;
} else if (sr<0) { // the left-most y-value } else if (sr<0) { // the left-most y-value
deltam=deltap=fabs(datastore->get(yColumn,lr)-yv)/2.0; deltam=deltap=fabs(datastore->get(yColumn,lr)-yv)/2.0;
} else { } else {
deltam=fabs(yv-datastore->get(yColumn,sr))/2.0; deltam=fabs(yv-datastore->get(yColumn,sr))/2.0;
deltap=fabs(datastore->get(yColumn,lr)-yv)/2.0; deltap=fabs(datastore->get(yColumn,lr)-yv)/2.0;
} }
delta=deltap+deltam; delta=deltap+deltam;
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=xv0; double x=xv0;
if (!qFuzzyIsNull(getBaseline())) x=transformX(getBaseline()); if (!qFuzzyIsNull(getBaseline())) x=transformX(getBaseline());
double y=transformY(yv+shift*delta+width*deltap); double y=transformY(yv+shift*delta+width*deltap);
double xx=transformX(xv); double xx=transformX(xv);
double yy=transformY(yv+shift*delta-width*deltam); double yy=transformY(yv+shift*delta-width*deltam);
if (x>xx) { qSwap(x,xx); } if (x>xx) { qSwap(x,xx); }
//qDebug()<<"delta="<<delta<<" x="<<x<<" y="<<y<<" xx="<<xx<<" yy="<<yy; //qDebug()<<"delta="<<delta<<" x="<<x<<" y="<<y<<" xx="<<xx<<" yy="<<yy;
//qDebug()<<"xv="<<xv<<" x0="<<x0<<" x="<<x<<"..."<<xx; //qDebug()<<"xv="<<xv<<" x0="<<x0<<" x="<<x<<"..."<<xx;
if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(xx) && JKQTPIsOKFloat(y) && JKQTPIsOKFloat(yy)) { if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(xx) && JKQTPIsOKFloat(y) && JKQTPIsOKFloat(yy)) {
painter.setBrush(b); painter.setBrush(b);
painter.setPen(p); painter.setPen(p);
QRectF r(QPointF(x, y), QPointF(xx, yy)); QRectF r(QPointF(x, y), QPointF(xx, yy));
painter.drawRect(r); painter.drawRect(r);
}
} }
} }
} }
} }
drawErrorsAfter(painter); drawErrorsAfter(painter);
} }
@ -363,33 +346,29 @@ bool JKQTPBarHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
if (imax<imin) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
for (int i=imin; i<imax; i++) { for (int i=imin; i<imax; i++) {
double xvsgz; double xvsgz;
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore); const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
double xvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore); const double xvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(xvv) ) { if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(xvv) ) {
if (start || xv>maxx) maxx=xv; if (start || xv>maxx) maxx=xv;
if (start || xv<minx) minx=xv; if (start || xv<minx) minx=xv;
xvsgz=xv; SmallestGreaterZeroCompare_xvsgz(); xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
start=false; start=false;
if (xvv>maxx) maxx=xvv; if (xvv>maxx) maxx=xvv;
if (xvv<minx) minx=xvv; if (xvv<minx) minx=xvv;
xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz(); xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz();
start=false; start=false;
}
} }
return !start;
} }
return !start; return false;
} }
} }
@ -465,33 +444,29 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
if (imax<imin) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
for (int i=imin; i<imax; i++) {
double yv=getBaseline(); for (int i=imin; i<imax; i++) {
if (JKQTPIsOKFloat(yv)) { double yv=getBaseline();
if (yv>maxy) maxy=yv; if (JKQTPIsOKFloat(yv)) {
if (yv<miny) miny=yv; if (yv>maxy) maxy=yv;
double xvsgz; if (yv<miny) miny=yv;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz(); double xvsgz;
} xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i)); }
if (JKQTPIsOKFloat(yv)) { yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (yv>maxy) maxy=yv; if (JKQTPIsOKFloat(yv)) {
if (yv<miny) miny=yv; if (yv>maxy) maxy=yv;
double xvsgz; if (yv<miny) miny=yv;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz(); double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
} }
return true;
} }
return true;
} else { } else {
bool start=false; bool start=false;
miny=getBaseline(); miny=getBaseline();
@ -505,34 +480,30 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
if (imax<imin) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
for (int i=imin; i<imax; i++) { for (int i=imin; i<imax; i++) {
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore); const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore); const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) { if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
if (start || yv>maxy) maxy=yv; if (start || yv>maxy) maxy=yv;
if (start || yv<miny) miny=yv; if (start || yv<miny) miny=yv;
double xvsgz; double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz(); xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yvv>maxy) maxy=yvv; if (start || yvv>maxy) maxy=yvv;
if (start || yvv<miny) miny=yvv; if (start || yvv<miny) miny=yvv;
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz(); xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false; start=false;
}
} }
return !start;
} }
return !start;
} }
return false;
} }
int JKQTPBarVerticalErrorGraph::getBarErrorColumn() const int JKQTPBarVerticalErrorGraph::getBarErrorColumn() const

View File

@ -93,55 +93,39 @@ void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
QPen p=getLinePen(painter, parent); QPen p=getLinePen(painter, parent);
p.setCapStyle(Qt::FlatCap); p.setCapStyle(Qt::FlatCap);
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); int imax=0;
int imin=0; int imin=0;
if (imax<imin) { if (getIndexRange(imin, imax)) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
//double xold=-1; double x0=transformX(getBaseline());
//double yold=-1; if (parent->getXAxis()->isLogAxis()) {
double x0=transformX(getBaseline()); if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
if (parent->getXAxis()->isLogAxis()) { else x0=transformX(parent->getXAxis()->getMin());
if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
else x0=transformX(parent->getXAxis()->getMin());
}
// double y0=transformY(getBaseline());
// if (parent->getYAxis()->isLogAxis()) {
// y0=transformY(parent->getYAxis()->getMin());
// if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
// else y0=transformY(parent->getYAxis()->getMin());
// }
//bool first=false;
QVector<QLineF> lines;
QVector<QPointF> points;
intSortData();
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));
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=transformX(xv);
double y=transformY(yv);
lines.append(QLineF(x0, y, x, y));
points.append(QPointF(x,y));
// xold=x;
// yold=y;
//first=true;
} }
}
painter.setPen(p); QVector<QLineF> lines;
if (lines.size()>0) painter.drawLines(lines); QVector<QPointF> points;
if (drawSymbols && points.size()>0) { intSortData();
painter.save(); auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();}); for (int iii=imin; iii<imax; iii++) {
for (auto& p: points) { const int i=qBound(imin, getDataIndex(iii), imax);
plotStyledSymbol(parent, painter, p.x(), p.y()); const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
const double x=transformX(xv);
const double y=transformY(yv);
lines.append(QLineF(x0, y, x, y));
points.append(QPointF(x,y));
}
}
painter.setPen(p);
if (lines.size()>0) painter.drawLines(lines);
if (drawSymbols && points.size()>0) {
painter.save(); auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();});
for (auto& p: points) {
plotStyledSymbol(parent, painter, p.x(), p.y());
}
} }
} }
@ -210,55 +194,42 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
QPen p=getLinePen(painter, parent); QPen p=getLinePen(painter, parent);
p.setCapStyle(Qt::FlatCap); p.setCapStyle(Qt::FlatCap);
int imax=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); int imax=0;
int imin=0; int imin=0;
if (imax<imin) { if (getIndexRange(imin, imax)) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
//double xold=-1;
//double yold=-1;
//bool first=false;
// double x0=transformX(getBaseline());
// if (parent->getXAxis()->isLogAxis()) {
// if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
// else x0=transformX(parent->getXAxis()->getMin());
// }
double y0=transformY(getBaseline());
if (parent->getYAxis()->isLogAxis()) {
y0=transformY(parent->getYAxis()->getMin());
if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
else y0=transformY(parent->getYAxis()->getMin());
}
QVector<QLineF> lines;
QVector<QPointF> points;
intSortData();
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));
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) ) {
double x=transformX(xv);
double y=transformY(yv);
lines.append(QLineF(x, y0, x, y));
points.append(QPointF(x,y)); double y0=transformY(getBaseline());
//xold=x; if (parent->getYAxis()->isLogAxis()) {
//yold=y; y0=transformY(parent->getYAxis()->getMin());
//first=true; if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
else y0=transformY(parent->getYAxis()->getMin());
} }
} QVector<QLineF> lines;
painter.setPen(p); QVector<QPointF> points;
if (lines.size()>0) painter.drawLines(lines); intSortData();
if (drawSymbols && points.size()>0) { for (int iii=imin; iii<imax; iii++) {
painter.save(); auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();}); const int i=qBound(imin, getDataIndex(iii), imax);
for (auto& p: points) { const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
plotStyledSymbol(parent, painter, p.x(), p.y()); const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) ) {
const double x=transformX(xv);
const double y=transformY(yv);
lines.append(QLineF(x, y0, x, y));
points.append(QPointF(x,y));
}
}
painter.setPen(p);
if (lines.size()>0) painter.drawLines(lines);
if (drawSymbols && points.size()>0) {
painter.save(); auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();});
for (auto& p: points) {
plotStyledSymbol(parent, painter, p.x(), p.y());
}
} }
} }
} }

View File

@ -61,7 +61,7 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
JKQTPAutoOutputTimer jkaaot("JKQTPXYLineGraph::draw"); JKQTPAutoOutputTimer jkaaot("JKQTPXYLineGraph::draw");
#endif #endif
if (parent==nullptr) return; if (parent==nullptr) return;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
if (datastore==nullptr) return; if (datastore==nullptr) return;
//qDebug()<<"JKQTPXYLineGraph::draw();"; //qDebug()<<"JKQTPXYLineGraph::draw();";
@ -72,63 +72,56 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<2; //qDebug()<<"JKQTPXYLineGraph::draw(): "<<2;
QPen p=getLinePen(painter, parent); const QPen p=getLinePen(painter, parent);
const QPen penSelection=getHighlightingLinePen(painter, parent);
QPen penSelection=getHighlightingLinePen(painter, parent); int imax=0;
int imax= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
int imin=0; int imin=0;
if (getIndexRange(imin, imax)) {
if (imax<imin) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
std::vector<QPolygonF> vec_linesP; std::vector<QPolygonF> vec_linesP;
vec_linesP.push_back(QPolygonF()); vec_linesP.push_back(QPolygonF());
intSortData(); intSortData();
for (int iii=imin; iii<imax; iii++) { for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax); const int i=qBound(imin, getDataIndex(iii), imax);
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i)); const 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)); const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
double x=transformX(xv); const double x=transformX(xv);
double y=transformY(yv); const double y=transformY(yv);
//qDebug()<<"JKQTPXYLineGraph::draw(): (xv, yv) = ( "<<xv<<", "<<yv<<" )"; //qDebug()<<"JKQTPXYLineGraph::draw(): (xv, yv) = ( "<<xv<<", "<<yv<<" )";
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
if (isHighlighted() && getSymbolType()!=JKQTPNoSymbol) { if (isHighlighted() && getSymbolType()!=JKQTPNoSymbol) {
//JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle, parent->pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color()); //JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle, parent->pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color());
} }
if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) { if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) {
plotStyledSymbol(parent, painter, x, y); plotStyledSymbol(parent, painter, x, y);
if (drawLine) { if (drawLine) {
vec_linesP[vec_linesP.size()-1] << QPointF(x,y); vec_linesP[vec_linesP.size()-1] << QPointF(x,y);
}
} else {
vec_linesP.push_back(QPolygonF());
} }
} else {
vec_linesP.push_back(QPolygonF());
} }
} }
} //qDebug()<<"JKQTPXYLineGraph::draw(): "<<4<<" lines="<<lines.size();
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<4<<" lines="<<lines.size(); //qDebug()<<"JKQTPXYLineGraph::draw(): "<<5<<" p="<<painter.pen();
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<5<<" p="<<painter.pen(); for (auto &linesP : vec_linesP) {
for (auto &linesP : vec_linesP) { if (linesP.size()>0) {
if (linesP.size()>0) { if (isHighlighted()) {
if (isHighlighted()) { painter.setPen(penSelection);
painter.setPen(penSelection); //painter.drawLines(lines);
painter.drawPolyline(linesP);
}
painter.setPen(p);
//painter.drawLines(lines); //painter.drawLines(lines);
painter.drawPolyline(linesP); painter.drawPolyline(linesP);
} }
painter.setPen(p);
//painter.drawLines(lines);
painter.drawPolyline(linesP);
} }
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<6;
} }
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<6;
} }
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<7; //qDebug()<<"JKQTPXYLineGraph::draw(): "<<7;
drawErrorsAfter(painter); drawErrorsAfter(painter);
@ -205,36 +198,30 @@ bool JKQTPXYLineErrorGraph::getXMinMax(double &minx, double &maxx, double &small
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
if (imax<imin) { double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
int h=imin; if (JKQTPIsOKFloat(xv)) {
imin=imax; if (start || xv>maxx) maxx=xv;
imax=h; if (start || xv<minx) minx=xv;
} const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
if (imin<0) imin=0; start=false;
if (imax<0) imax=0; }
xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
for (int i=imin; i<imax; i++) { if (JKQTPIsOKFloat(xv)) {
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore); if (start || xv>maxx) maxx=xv;
if (JKQTPIsOKFloat(xv)) { if (start || xv<minx) minx=xv;
if (start || xv>maxx) maxx=xv; const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
if (start || xv<minx) minx=xv; start=false;
const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz(); }
start=false;
}
xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
if (JKQTPIsOKFloat(xv)) {
if (start || xv>maxx) maxx=xv;
if (start || xv<minx) minx=xv;
const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
start=false;
} }
return !start;
} }
return !start;
} }
return false;
} }
bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) { bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) {
@ -248,36 +235,30 @@ bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &small
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
if (imax<imin) { double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
int h=imin; if (JKQTPIsOKFloat(yv)) {
imin=imax; if (start || yv>maxy) maxy=yv;
imax=h; if (start || yv<miny) miny=yv;
} const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (imin<0) imin=0; start=false;
if (imax<0) imax=0; }
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
for (int i=imin; i<imax; i++) { if (JKQTPIsOKFloat(yv)) {
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore); if (start || yv>maxy) maxy=yv;
if (JKQTPIsOKFloat(yv)) { if (start || yv<miny) miny=yv;
if (start || yv>maxy) maxy=yv; const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yv<miny) miny=yv; start=false;
const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz(); }
start=false;
}
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
if (JKQTPIsOKFloat(yv)) {
if (start || yv>maxy) maxy=yv;
if (start || yv<miny) miny=yv;
const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
start=false;
} }
return !start;
} }
return !start;
} }
return false;
} }
bool JKQTPXYLineErrorGraph::usesColumn(int c) const bool JKQTPXYLineErrorGraph::usesColumn(int c) const
@ -359,102 +340,109 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QPen p=getLinePen(painter, parent); const QPen p=getLinePen(painter, parent);
const QPen penSelection=getHighlightingLinePen(painter, parent);
QPen penSelection=getHighlightingLinePen(painter, parent); int imax=0;
int imax= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
int imin=0; int imin=0;
if (imax<imin) { if (getIndexRange(imin, imax)) {
int h=imin;
imin=imax;
imax=h;
}
if (imin<0) imin=0;
if (imax<0) imax=0;
QVector<QLineF> lines;
QPolygonF linesP;
QVector<QColor> linecols;
QVector<QColor> linecolss;
QVector<double> linewidths;
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<3<<" imin="<<imin<<" imax="<<imax;
{
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
double xold=-1;
double yold=-1;
bool first=false;
intSortData(); QVector<QLineF> lines;
double specSymbSize=0; QPolygonF linesP;
bool hasSpecSymbSize=false; QVector<QColor> linecols;
for (int iii=imin; iii<imax; iii++) { QVector<QColor> linecolss;
int i=qBound(imin, getDataIndex(iii), imax); QVector<double> linewidths;
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i)); //qDebug()<<"JKQTPXYLineGraph::draw(): "<<3<<" imin="<<imin<<" imax="<<imax;
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i)); {
double x=transformX(xv); painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
double y=transformY(yv); double xold=-1;
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) { double yold=-1;
double symbSize= parent->pt2px(painter, getLocalSymbolSize(i)); bool first=false;
double lineW= parent->pt2px(painter, getLocalLineWidth(i));
if (gridModeForSymbolSize) { intSortData();
if (!hasSpecSymbSize) { double specSymbSize=0;
double sSX= fabs(transformX( xv+gridDeltaX*gridSymbolFractionSize/2.0)-transformX( xv-gridDeltaX*gridSymbolFractionSize/2.0)); bool hasSpecSymbSize=false;
double sSY= fabs(transformY( yv+gridDeltaY*gridSymbolFractionSize/2.0)-transformY( yv-gridDeltaY*gridSymbolFractionSize/2.0)); for (int iii=imin; iii<imax; iii++) {
hasSpecSymbSize=true; int i=qBound(imin, getDataIndex(iii), imax);
specSymbSize=qMin(sSX,sSY); 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));
double x=transformX(xv);
double y=transformY(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) {
double sSX= fabs(transformX( xv+gridDeltaX*gridSymbolFractionSize/2.0)-transformX( xv-gridDeltaX*gridSymbolFractionSize/2.0));
double sSY= fabs(transformY( yv+gridDeltaY*gridSymbolFractionSize/2.0)-transformY( yv-gridDeltaY*gridSymbolFractionSize/2.0));
hasSpecSymbSize=true;
specSymbSize=qMin(sSX,sSY);
}
symbSize=specSymbSize;
} }
symbSize=specSymbSize; QColor symbColor=getLocalColor(i);
} QColor symbFillColor=JKQTPGetDerivedColor(symbolFillDerivationMode, symbColor);
QColor symbColor=getLocalColor(i); //qDebug()<<i<<symbolSize<<symbColor;
QColor symbFillColor=JKQTPGetDerivedColor(symbolFillDerivationMode, symbColor); if (drawLine) {
//qDebug()<<i<<symbolSize<<symbColor; linesP<<QPointF(x,y);
if (drawLine) {
linesP<<QPointF(x,y);
}
if (first && drawLine) {
double xl1=xold;
double yl1=yold;
double xl2=x;
double yl2=y;
if (isHighlighted()) {
if (colorColumn>=0) linecolss<<symbColor.lighter();
else linecolss<<getHighlightingLineColor();
} }
linecols<<symbColor; if (first && drawLine) {
lines<<QLineF(xl1, yl1, xl2, yl2); double xl1=xold;
linewidths<<lineW; double yl1=yold;
} double xl2=x;
double yl2=y;
if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) { if (isHighlighted()) {
if (isHighlighted() && getSymbolType()!=JKQTPNoSymbol && symbolColumn<0) { if (colorColumn>=0) linecolss<<symbColor.lighter();
JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle,symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color()); else linecolss<<getHighlightingLineColor();
} else { }
JKQTPPlotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), symbColor, symbFillColor); linecols<<symbColor;
lines<<QLineF(xl1, yl1, xl2, yl2);
linewidths<<lineW;
} }
if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) {
if (isHighlighted() && getSymbolType()!=JKQTPNoSymbol && symbolColumn<0) {
JKQTPPlotSymbol(painter, x, y, JKQTPFilledCircle,symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), penSelection.color(), penSelection.color());
} else {
JKQTPPlotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, getSymbolLineWidth()*parent->getLineWidthMultiplier()), symbColor, symbFillColor);
}
}
xold=x;
yold=y;
first=true;
} }
xold=x;
yold=y;
first=true;
} }
} }
}
if (lines.size()>0) { if (lines.size()>0) {
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
if (isHighlighted()) { if (isHighlighted()) {
QPen pp=penSelection; QPen pp=penSelection;
if (colorColumn>=0) { if (colorColumn>=0) {
for (int i=0; i<lines.size(); i++) {
pp.setColor(linecolss.value(i, getHighlightingLineColor()));
painter.setPen(pp);
painter.drawLine(lines[i]);
}
} else {
pp.setColor(getHighlightingLineColor());
painter.setPen(pp);
painter.drawPolyline(linesP);
}
}
QPen pp=p;
if (colorColumn>=0 || linewidthColumn>=0) {
for (int i=0; i<lines.size(); i++) { for (int i=0; i<lines.size(); i++) {
pp.setColor(linecolss.value(i, getHighlightingLineColor())); pp.setColor(linecols.value(i, getLineColor()));
pp.setWidthF(linewidths.value(i, parent->pt2px(painter, getLineWidth()*parent->getLineWidthMultiplier())));
painter.setPen(pp); painter.setPen(pp);
painter.drawLine(lines[i]); painter.drawLine(lines[i]);
} }
@ -463,21 +451,8 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
painter.setPen(pp); painter.setPen(pp);
painter.drawPolyline(linesP); painter.drawPolyline(linesP);
} }
}
QPen pp=p;
if (colorColumn>=0 || linewidthColumn>=0) {
for (int i=0; i<lines.size(); i++) {
pp.setColor(linecols.value(i, getLineColor()));
pp.setWidthF(linewidths.value(i, parent->pt2px(painter, getLineWidth()*parent->getLineWidthMultiplier())));
painter.setPen(pp);
painter.drawLine(lines[i]);
}
} else {
pp.setColor(getHighlightingLineColor());
painter.setPen(pp);
painter.drawPolyline(linesP);
}
}
} }
drawErrorsAfter(painter); drawErrorsAfter(painter);
@ -897,36 +872,30 @@ bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
if (imax<imin) { const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
int h=imin; if (JKQTPIsOKFloat(xv) ) {
imin=imax; if (start || xv>maxx) maxx=xv;
imax=h; if (start || xv<minx) minx=xv;
} const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
if (imin<0) imin=0; }
if (imax<0) imax=0; const double xvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
if (JKQTPIsOKFloat(xvv)) {
for (int i=imin; i<imax; i++) { start=false;
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore); if (start || xvv>maxx) maxx=xvv;
if (JKQTPIsOKFloat(xv) ) { if (start || xvv<minx) minx=xvv;
if (start || xv>maxx) maxx=xv; const double xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz();
if (start || xv<minx) minx=xv; start=false;
const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz(); }
}
const double xvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
if (JKQTPIsOKFloat(xvv)) {
start=false;
if (start || xvv>maxx) maxx=xvv;
if (start || xvv<minx) minx=xvv;
const double xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
} }
return !start;
} }
return !start;
} }
return false;
} }
bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
@ -941,36 +910,30 @@ bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy
if (parent==nullptr) return false; if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore(); const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0; int imin=0;
int imax= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn)))); if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
if (imax<imin) { const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
int h=imin; if (JKQTPIsOKFloat(yv)) {
imin=imax; if (start || yv>maxy) maxy=yv;
imax=h; if (start || yv<miny) miny=yv;
} const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (imin<0) imin=0; start=false;
if (imax<0) imax=0; }
const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
for (int i=imin; i<imax; i++) { if (JKQTPIsOKFloat(yvv) ) {
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore); if (start || yvv>maxy) maxy=yvv;
if (JKQTPIsOKFloat(yv)) { if (start || yvv<miny) miny=yvv;
if (start || yv>maxy) maxy=yv; const double xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
if (start || yv<miny) miny=yv; start=false;
const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz(); }
start=false;
}
const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
if (JKQTPIsOKFloat(yvv) ) {
if (start || yvv>maxy) maxy=yvv;
if (start || yvv<miny) miny=yvv;
const double xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
} }
return !start;
} }
return !start;
} }
return false;
} }
bool JKQTPXYParametrizedErrorScatterGraph::usesColumn(int c) const bool JKQTPXYParametrizedErrorScatterGraph::usesColumn(int c) const

View File

@ -623,7 +623,7 @@ void JKQTPXGraphErrorData::setXErrorColumnLower(int __value) {
} }
double JKQTPXGraphErrorData::getXErrorU(int i, JKQTPDatastore *ds) const double JKQTPXGraphErrorData::getXErrorU(int i, const JKQTPDatastore *ds) const
{ {
if (ds && xErrorColumn>=0 && i>=0 && i<static_cast<int>(ds->getRows(xErrorColumn))) { if (ds && xErrorColumn>=0 && i>=0 && i<static_cast<int>(ds->getRows(xErrorColumn))) {
return ds->get(xErrorColumn, static_cast<size_t>(i)); return ds->get(xErrorColumn, static_cast<size_t>(i));
@ -631,7 +631,7 @@ double JKQTPXGraphErrorData::getXErrorU(int i, JKQTPDatastore *ds) const
return 0.0; return 0.0;
} }
double JKQTPXGraphErrorData::getXErrorL(int i, JKQTPDatastore *ds) const double JKQTPXGraphErrorData::getXErrorL(int i, const JKQTPDatastore *ds) const
{ {
if (ds) { if (ds) {
if (xErrorSymmetric) { if (xErrorSymmetric) {
@ -699,7 +699,7 @@ void JKQTPYGraphErrorData::setYErrorColumnLower(int __value) {
} }
double JKQTPYGraphErrorData::getYErrorU(int i, JKQTPDatastore *ds) const double JKQTPYGraphErrorData::getYErrorU(int i, const JKQTPDatastore *ds) const
{ {
if (ds && yErrorColumn>=0 && i>=0 && i<static_cast<int>(ds->getRows(yErrorColumn))) { if (ds && yErrorColumn>=0 && i>=0 && i<static_cast<int>(ds->getRows(yErrorColumn))) {
return ds->get(yErrorColumn, static_cast<size_t>(i)); return ds->get(yErrorColumn, static_cast<size_t>(i));
@ -707,7 +707,7 @@ double JKQTPYGraphErrorData::getYErrorU(int i, JKQTPDatastore *ds) const
return 0.0; return 0.0;
} }
double JKQTPYGraphErrorData::getYErrorL(int i, JKQTPDatastore *ds) const double JKQTPYGraphErrorData::getYErrorL(int i, const JKQTPDatastore *ds) const
{ {
if (ds) { if (ds) {
if (yErrorSymmetric) { if (yErrorSymmetric) {
@ -735,7 +735,7 @@ bool JKQTPXGraphErrors::errorUsesColumn(int c) const
return c==(xErrorColumn) || (c==xErrorColumnLower); return c==(xErrorColumn) || (c==xErrorColumnLower);
} }
void JKQTPXGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph *parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector<int>* dataorder) const { void JKQTPXGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, const JKQTBasePlotter* parent, const JKQTPGraph *parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector<int>* dataorder) const {
intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, -1, xErrorStyle, JKQTPNoError, xErrorColumnLower, -1, xErrorSymmetric, true, xrelshift, yrelshift, dataorder); intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, -1, xErrorStyle, JKQTPNoError, xErrorColumnLower, -1, xErrorSymmetric, true, xrelshift, yrelshift, dataorder);
} }
@ -747,7 +747,7 @@ JKQTPYGraphErrors::JKQTPYGraphErrors()
{ {
} }
void JKQTPYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector<int>* dataorder) const { void JKQTPYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, const JKQTBasePlotter* parent, const JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector<int>* dataorder) const {
intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, -1, yErrorColumn, JKQTPNoError, yErrorStyle, -1, yErrorColumnLower, true, yErrorSymmetric, xrelshift, yrelshift, dataorder); intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, -1, yErrorColumn, JKQTPNoError, yErrorStyle, -1, yErrorColumnLower, true, yErrorSymmetric, xrelshift, yrelshift, dataorder);
} }
@ -767,7 +767,7 @@ JKQTPXYGraphErrors::JKQTPXYGraphErrors()
} }
void JKQTPXYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector<int>* dataorder) const { void JKQTPXYGraphErrors::plotErrorIndicators(JKQTPEnhancedPainter& painter, const JKQTBasePlotter* parent, const JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift, double yrelshift, const QVector<int>* dataorder) const {
this->intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, xErrorColumnLower, yErrorColumnLower, xErrorSymmetric, yErrorSymmetric, xrelshift, yrelshift, dataorder); this->intPlotXYErrorIndicators(painter, parent, parentGraph, xColumn, yColumn, xErrorColumn, yErrorColumn, xErrorStyle, yErrorStyle, xErrorColumnLower, yErrorColumnLower, xErrorSymmetric, yErrorSymmetric, xrelshift, yrelshift, dataorder);
} }

View File

@ -227,9 +227,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXGraphErrorData {
JKQTPErrorPlotstyle xErrorStyle; JKQTPErrorPlotstyle xErrorStyle;
/** \brief returns the upper x-error for the i-th datapoint, read from datastore \a ds */ /** \brief returns the upper x-error for the i-th datapoint, read from datastore \a ds */
virtual double getXErrorU(int i, JKQTPDatastore* ds) const; virtual double getXErrorU(int i, const JKQTPDatastore* ds) const;
/** \brief returns the lower x-error for the i-th datapoint, read from datastore \a ds */ /** \brief returns the lower x-error for the i-th datapoint, read from datastore \a ds */
virtual double getXErrorL(int i, JKQTPDatastore* ds) const; virtual double getXErrorL(int i, const JKQTPDatastore *ds) const;
}; };
@ -277,9 +277,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPYGraphErrorData {
JKQTPErrorPlotstyle yErrorStyle; JKQTPErrorPlotstyle yErrorStyle;
/** \brief returns the upper y-error for the i-th datapoint, read from datastore \a ds */ /** \brief returns the upper y-error for the i-th datapoint, read from datastore \a ds */
virtual double getYErrorU(int i, JKQTPDatastore* ds) const; virtual double getYErrorU(int i, const JKQTPDatastore* ds) const;
/** \brief returns the lower y-error for the i-th datapoint, read from datastore \a ds */ /** \brief returns the lower y-error for the i-th datapoint, read from datastore \a ds */
virtual double getYErrorL(int i, JKQTPDatastore* ds) const; virtual double getYErrorL(int i, const JKQTPDatastore* ds) const;
}; };
@ -301,7 +301,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXGraphErrors: public JKQTPXGraphErrorData, pub
protected: protected:
/** \brief draws the error indicators */ /** \brief draws the error indicators */
virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector<int> *dataorder=nullptr) const ; virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, const JKQTBasePlotter* parent, const JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector<int> *dataorder=nullptr) const ;
}; };
@ -323,7 +323,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPYGraphErrors: public JKQTPYGraphErrorData, pub
protected: protected:
/** \brief draws the error indicators */ /** \brief draws the error indicators */
virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector<int> *dataorder=nullptr) const ; virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, const JKQTBasePlotter* parent, const JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector<int> *dataorder=nullptr) const ;
}; };
@ -347,7 +347,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXYGraphErrors: public JKQTPXGraphErrorData, pu
protected: protected:
/** \brief draws the error indicators */ /** \brief draws the error indicators */
virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, JKQTBasePlotter* parent, JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector<int> *dataorder=nullptr) const ; virtual void plotErrorIndicators(JKQTPEnhancedPainter& painter, const JKQTBasePlotter* parent, const JKQTPGraph* parentGraph, int xColumn, int yColumn, double xrelshift=0, double yrelshift=0.0, const QVector<int> *dataorder=nullptr) const ;
}; };