mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
improved code (removed code repeats by using getIndexRange(), using const where appropriate)
This commit is contained in:
parent
7e425e7bb5
commit
abe1c655ba
@ -53,27 +53,17 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTPBarHorizontalGraph::draw");
|
||||
#endif
|
||||
if (parent==nullptr) return;
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
if (datastore==nullptr) return;
|
||||
|
||||
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=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
|
||||
int imax=0;
|
||||
int imin=0;
|
||||
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
{
|
||||
if (getIndexRange(imin, imax)) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
|
||||
// double x0=transformX(0);
|
||||
@ -87,9 +77,9 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
const bool hasStackPar=hasStackParent();
|
||||
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));
|
||||
int sr=datastore->getNextLowerIndex(xColumn, i);
|
||||
int lr=datastore->getNextHigherIndex(xColumn, i);
|
||||
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
||||
const int sr=datastore->getNextLowerIndex(xColumn, i);
|
||||
const int lr=datastore->getNextHigherIndex(xColumn, i);
|
||||
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
||||
double yv0=y0;
|
||||
if (!qFuzzyIsNull(getBaseline())) yv0=transformY(getBaseline());
|
||||
@ -114,9 +104,9 @@ void JKQTPBarVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
delta=deltap+deltam;
|
||||
|
||||
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 xx=transformX(xv+shift*delta+width*deltap);
|
||||
const double xx=transformX(xv+shift*delta+width*deltap);
|
||||
double yy=yv0;
|
||||
|
||||
//std::cout<<"delta="<<delta<<" x="<<x<<" y="<<y<<" xx="<<xx<<" yy="<<yy<<std::endl;
|
||||
@ -239,24 +229,17 @@ void JKQTPBarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTPBarVerticalGraph::draw");
|
||||
#endif
|
||||
if (parent==nullptr) return;
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
if (datastore==nullptr) return;
|
||||
|
||||
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=static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
|
||||
int imax=0;
|
||||
int imin=0;
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
double x0=transformX(0);
|
||||
if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin());
|
||||
@ -315,7 +298,7 @@ void JKQTPBarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
drawErrorsAfter(painter);
|
||||
}
|
||||
@ -363,21 +346,15 @@ bool JKQTPBarHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double xvsgz;
|
||||
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 xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(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 (start || xv>maxx) maxx=xv;
|
||||
if (start || xv<minx) minx=xv;
|
||||
@ -391,6 +368,8 @@ bool JKQTPBarHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double
|
||||
}
|
||||
return !start;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPBarHorizontalErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
|
||||
@ -465,15 +444,10 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double yv=getBaseline();
|
||||
@ -492,6 +466,7 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
bool start=false;
|
||||
miny=getBaseline();
|
||||
@ -505,21 +480,15 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
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 yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(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 (start || yv>maxy) maxy=yv;
|
||||
if (start || yv<miny) miny=yv;
|
||||
@ -534,6 +503,8 @@ bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &
|
||||
return !start;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int JKQTPBarVerticalErrorGraph::getBarErrorColumn() const
|
||||
{
|
||||
|
@ -93,47 +93,30 @@ void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPen p=getLinePen(painter, parent);
|
||||
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;
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
//double xold=-1;
|
||||
//double yold=-1;
|
||||
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());
|
||||
// }
|
||||
//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));
|
||||
const int i=qBound(imin, getDataIndex(iii), imax);
|
||||
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)) {
|
||||
double x=transformX(xv);
|
||||
double y=transformY(yv);
|
||||
|
||||
const double x=transformX(xv);
|
||||
const 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);
|
||||
@ -144,6 +127,7 @@ void JKQTPImpulsesHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
plotStyledSymbol(parent, painter, p.x(), p.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
drawErrorsAfter(painter);
|
||||
@ -210,24 +194,12 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
QPen p=getLinePen(painter, parent);
|
||||
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;
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
|
||||
|
||||
//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());
|
||||
@ -238,19 +210,17 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
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));
|
||||
const int i=qBound(imin, getDataIndex(iii), imax);
|
||||
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) ) {
|
||||
double x=transformX(xv);
|
||||
double y=transformY(yv);
|
||||
const double x=transformX(xv);
|
||||
const double y=transformY(yv);
|
||||
|
||||
|
||||
lines.append(QLineF(x, y0, x, y));
|
||||
points.append(QPointF(x,y));
|
||||
//xold=x;
|
||||
//yold=y;
|
||||
//first=true;
|
||||
|
||||
}
|
||||
}
|
||||
painter.setPen(p);
|
||||
@ -262,6 +232,7 @@ void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawErrorsAfter(painter);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
JKQTPAutoOutputTimer jkaaot("JKQTPXYLineGraph::draw");
|
||||
#endif
|
||||
if (parent==nullptr) return;
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
if (datastore==nullptr) return;
|
||||
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw();";
|
||||
@ -72,32 +72,24 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
//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= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
|
||||
int imax=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;
|
||||
vec_linesP.push_back(QPolygonF());
|
||||
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));
|
||||
double x=transformX(xv);
|
||||
double y=transformY(yv);
|
||||
const int i=qBound(imin, getDataIndex(iii), imax);
|
||||
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));
|
||||
const double x=transformX(xv);
|
||||
const double y=transformY(yv);
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): (xv, yv) = ( "<<xv<<", "<<yv<<" )";
|
||||
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
|
||||
|
||||
@ -130,6 +122,7 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<6;
|
||||
}
|
||||
}
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<7;
|
||||
drawErrorsAfter(painter);
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw() ... done";
|
||||
@ -205,18 +198,10 @@ bool JKQTPXYLineErrorGraph::getXMinMax(double &minx, double &maxx, double &small
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
if (getIndexRange(imin, imax)) {
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(xv)) {
|
||||
@ -236,6 +221,8 @@ bool JKQTPXYLineErrorGraph::getXMinMax(double &minx, double &maxx, double &small
|
||||
return !start;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) {
|
||||
if (yErrorColumn<0 || yErrorStyle==JKQTPNoError) {
|
||||
@ -248,18 +235,10 @@ bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &small
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
if (getIndexRange(imin, imax)) {
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
@ -279,6 +258,8 @@ bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &small
|
||||
return !start;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JKQTPXYLineErrorGraph::usesColumn(int c) const
|
||||
{
|
||||
@ -359,21 +340,14 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
|
||||
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= static_cast<int>(qMin(datastore->getRows(static_cast<size_t>(xColumn)), datastore->getRows(static_cast<size_t>(yColumn))));
|
||||
int imax=0;
|
||||
int imin=0;
|
||||
if (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
|
||||
QVector<QLineF> lines;
|
||||
QPolygonF linesP;
|
||||
@ -479,6 +453,7 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
drawErrorsAfter(painter);
|
||||
}
|
||||
@ -897,18 +872,10 @@ bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
if (getIndexRange(imin, imax)) {
|
||||
for (int i=imin; i<imax; i++) {
|
||||
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(xv) ) {
|
||||
@ -928,6 +895,8 @@ bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx
|
||||
return !start;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
||||
{
|
||||
@ -941,18 +910,10 @@ bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy
|
||||
|
||||
if (parent==nullptr) return false;
|
||||
|
||||
JKQTPDatastore* datastore=parent->getDatastore();
|
||||
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||
int imax=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 (imax<imin) {
|
||||
int h=imin;
|
||||
imin=imax;
|
||||
imax=h;
|
||||
}
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
if (getIndexRange(imin, imax)) {
|
||||
for (int i=imin; i<imax; i++) {
|
||||
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
@ -972,6 +933,8 @@ bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy
|
||||
return !start;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JKQTPXYParametrizedErrorScatterGraph::usesColumn(int c) const
|
||||
{
|
||||
|
@ -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))) {
|
||||
return ds->get(xErrorColumn, static_cast<size_t>(i));
|
||||
@ -631,7 +631,7 @@ double JKQTPXGraphErrorData::getXErrorU(int i, JKQTPDatastore *ds) const
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double JKQTPXGraphErrorData::getXErrorL(int i, JKQTPDatastore *ds) const
|
||||
double JKQTPXGraphErrorData::getXErrorL(int i, const JKQTPDatastore *ds) const
|
||||
{
|
||||
if (ds) {
|
||||
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))) {
|
||||
return ds->get(yErrorColumn, static_cast<size_t>(i));
|
||||
@ -707,7 +707,7 @@ double JKQTPYGraphErrorData::getYErrorU(int i, JKQTPDatastore *ds) const
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double JKQTPYGraphErrorData::getYErrorL(int i, JKQTPDatastore *ds) const
|
||||
double JKQTPYGraphErrorData::getYErrorL(int i, const JKQTPDatastore *ds) const
|
||||
{
|
||||
if (ds) {
|
||||
if (yErrorSymmetric) {
|
||||
@ -735,7 +735,7 @@ bool JKQTPXGraphErrors::errorUsesColumn(int c) const
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -227,9 +227,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXGraphErrorData {
|
||||
JKQTPErrorPlotstyle xErrorStyle;
|
||||
|
||||
/** \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 */
|
||||
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;
|
||||
|
||||
/** \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 */
|
||||
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:
|
||||
/** \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:
|
||||
/** \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:
|
||||
/** \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 ;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user