[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Wed Oct 26 08:11:27 CEST 2005
SVN commit 474353 by staikos:
remove even more orders of map lookups
M +52 -41 kstvcurve.cpp
--- trunk/extragear/graphics/kst/kst/kstvcurve.cpp #474352:474353
@@ -252,7 +252,7 @@
MinPosY = 0;
}
- NS = QMAX(cxV->length(), cyV->length());
+ NS = kMax(cxV->length(), cyV->length());
return setLastUpdateResult(depUpdated ? UPDATE : NO_CHANGE);
}
@@ -1102,6 +1102,10 @@
b_1 = benchtmp.elapsed();
#endif
+ KstVectorPtr exv = *_inputVectors.find(EXVECTOR);
+ KstVectorPtr eyv = *_inputVectors.find(EYVECTOR);
+ KstVectorPtr exmv = *_inputVectors.find(EXMINUSVECTOR);
+ KstVectorPtr eymv = *_inputVectors.find(EYMINUSVECTOR);
// draw the bargraph bars, if any...
if (hasBars()) {
bool has_top = true;
@@ -1125,12 +1129,11 @@
// determine the bar position width.
// NOTE: this assumes even X spacing if XError is not defined
// There may a better way...
- if (hasXError()) {
- getEXPoint(i_pt, rX, rY, drX);
- } else {
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ if (exv) {
+ drX = exv->interpolate(i_pt, NS);
}
+ rX = xv->interpolate(i_pt, NS);
+ rY = yv->interpolate(i_pt, NS);
rX -= drX/2.0;
rX2 = rX + drX;
if (_xLog) {
@@ -1273,26 +1276,25 @@
#endif
// draw the x-errors, if any...
- if ((hasXError() || hasXMinusError()) && !hasBars()) {
+ if ((exv || exmv) && !hasBars()) {
double rX1;
double rX2;
- double rEXLo, rEXHi;
bool do_low_flag = true;
bool do_high_flag = true;
- bool errorPlus = hasXError();
- bool errorMinus = hasXMinusError();
bool errorSame = false;
-
- if (errorPlus && errorMinus && xETag() == xEMinusTag()) {
+
+ if (exv && exmv && xETag() == xEMinusTag()) {
errorSame = true;
}
-
+
for (i_pt = i0; i_pt <= iN; i_pt++) {
do_low_flag = true;
do_high_flag = true;
-
+
+ rX = xv->interpolate(i_pt, NS);
+ rY = yv->interpolate(i_pt, NS);
if (errorSame) {
- getEXPoint(i_pt, rX, rY, rEX);
+ rEX = exv->interpolate(i_pt, NS);
if (_xLog) {
rX1 = logX(rX-fabs(rEX));
rX2 = logX(rX+fabs(rEX));
@@ -1300,17 +1302,18 @@
rX1 = rX-fabs(rEX);
rX2 = rX+fabs(rEX);
}
- } else if (errorPlus && errorMinus) {
- getEXPoints(i_pt, rX, rY, rEXLo, rEXHi);
+ } else if (exv && exmv) {
+ double rEXHi = fabs(exv->interpolate(i_pt, NS));
+ double rEXLo = fabs(exmv->interpolate(i_pt, NS));
if (_xLog) {
- rX1 = logX(rX-fabs(rEXLo));
- rX2 = logX(rX+fabs(rEXHi));
+ rX1 = logX(rX - rEXLo);
+ rX2 = logX(rX + rEXHi);
} else {
- rX1 = rX-fabs(rEXLo);
- rX2 = rX+fabs(rEXHi);
+ rX1 = rX - rEXLo;
+ rX2 = rX + rEXHi;
}
- } else if (errorPlus) {
- getEXPoint(i_pt, rX, rY, rEX);
+ } else if (exv) {
+ rEX = exv->interpolate(i_pt, NS);
if (_xLog) {
rX1 = logX(rX);
rX2 = logX(rX+fabs(rEX));
@@ -1320,7 +1323,7 @@
}
do_low_flag = false;
} else {
- getEXMinusPoint(i_pt, rX, rY, rEX);
+ rEX = exmv->interpolate(i_pt, NS);
if (_xLog) {
rX1 = logX(rX-fabs(rEX));
rX2 = logX(rX);
@@ -1363,17 +1366,14 @@
}
// draw the y-errors, if any...
- if (hasYError() || hasYMinusError()) {
+ if (eyv || eymv) {
double rY1;
double rY2;
- double rEYLo, rEYHi;
bool do_low_flag = true;
bool do_high_flag = true;
- bool errorPlus = hasYError();
- bool errorMinus = hasYMinusError();
bool errorSame = false;
- if (errorPlus && errorMinus && yETag() == yEMinusTag()) {
+ if (eyv && eymv && yETag() == yEMinusTag()) {
errorSame = true;
}
@@ -1381,8 +1381,10 @@
do_low_flag = true;
do_high_flag = true;
+ rX = xv->interpolate(i_pt, NS);
+ rY = yv->interpolate(i_pt, NS);
if (errorSame) {
- getEYPoint(i_pt, rX, rY, rEY);
+ rEY = eyv->interpolate(i_pt, NS);
if (_yLog) {
rY1 = logY(rY-fabs(rEY));
rY2 = logY(rY+fabs(rEY));
@@ -1390,17 +1392,18 @@
rY1 = rY-fabs(rEY);
rY2 = rY+fabs(rEY);
}
- } else if (errorPlus && errorMinus) {
- getEYPoints(i_pt, rX, rY, rEYLo, rEYHi);
+ } else if (eyv && eymv) {
+ double rEYHi = fabs(eyv->interpolate(i_pt, NS));
+ double rEYLo = fabs(eymv->interpolate(i_pt, NS));
if (_yLog) {
- rY1 = logY(rY-fabs(rEYLo));
- rY2 = logY(rY+fabs(rEYHi));
+ rY1 = logY(rY - rEYLo);
+ rY2 = logY(rY + rEYHi);
} else {
- rY1 = rY-fabs(rEYLo);
- rY2 = rY+fabs(rEYHi);
+ rY1 = rY - rEYLo;
+ rY2 = rY + rEYHi;
}
- } else if (errorPlus) {
- getEYPoint(i_pt, rX, rY, rEY);
+ } else if (eyv) {
+ rEY = eyv->interpolate(i_pt, NS);
if (_yLog) {
rY1 = logY(rY);
rY2 = logY(rY+fabs(rEY));
@@ -1410,7 +1413,7 @@
}
do_low_flag = false;
} else {
- getEYMinusPoint(i_pt, rX, rY, rEY);
+ rEY = eymv->interpolate(i_pt, NS);
if (_yLog) {
rY1 = logY(rY-fabs(rEY));
rY2 = logY(rY);
@@ -1475,6 +1478,14 @@
if (!yMin || !yMax) {
return;
}
+
+ KstVectorPtr xv = *_inputVectors.find(COLOR_XVECTOR);
+ KstVectorPtr yv = *_inputVectors.find(COLOR_YVECTOR);
+ if (!xv || !yv) {
+ *yMin = *yMax = 0;
+ return;
+ }
+
// get range of the curve to search for min/max
int i0, iN;
if (xIsRising()) {
@@ -1488,8 +1499,8 @@
bool first = true;
double newYMax = 0, newYMin = 0;
for (int i_pt = i0; i_pt <= iN; i_pt++) {
- double rX, rY;
- point(i_pt, rX, rY);
+ double rX = xv->interpolate(i_pt, NS);
+ double rY = yv->interpolate(i_pt, NS);
// make sure this point is visible
if (rX >= xFrom && rX <= xTo) {
// update min/max
More information about the Kst
mailing list