[Kst] kdeextragear-2/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Mon Aug 9 19:13:51 CEST 2004
CVS commit by rchern:
Remember last point for contour plots instead of recalculating
M +37 -26 kst2dplot.cpp 1.214
--- kdeextragear-2/kst/kst/kst2dplot.cpp #1.213:1.214
@@ -3851,5 +3851,9 @@ void Kst2DPlot::plotImages(QPainter& p,
if (image->hasContourMap()) {
p.setPen(QPen(image->contourColor(),0));
- //do the drawing
+ //do the drawing for each contour line
+ QValueList<double> lines = image->contourLines();
+ QPoint lastPoint; //used to remember the previous point
+ bool hasPrevBottom = false;
+ for (uint k = 0; k < lines.count(); k++) {
for (int i = d2i(ceil(img_Lx_pix)); i + CONTOUR_STEP < d2i(floor(img_Hx_pix)); i += CONTOUR_STEP) {
for (int j = d2i(ceil(img_Ly_pix)); j + CONTOUR_STEP < d2i(floor(img_Hy_pix)); j += CONTOUR_STEP) {
@@ -3867,4 +3871,5 @@ void Kst2DPlot::plotImages(QPainter& p,
new_y_large = pow(10, new_y_large);
}
+
image->getNearestZ(new_x_small, new_y_small, zTL);
image->getNearestZ(new_x_large, new_y_small, zTR);
@@ -3871,14 +3876,15 @@ void Kst2DPlot::plotImages(QPainter& p,
image->getNearestZ(new_x_small, new_y_large, zBL);
image->getNearestZ(new_x_large, new_y_large, zBR);
+
//determine the lines to draw
- //check each contour line
- QValueList<double> lines = image->contourLines();
- for (uint k = 0; k < lines.count(); k++) {
int numPoints = 0;
bool passTop = false, passBottom = false, passLeft = false, passRight = false;
QPoint topPoint, bottomPoint, leftPoint, rightPoint;
- lines[k];
//passes through the top
- if ((lines[k] < zTR && lines[k] > zTL) || (lines[k] < zTL && lines[k] > zTR)) {
+ if (hasPrevBottom) {
+ topPoint = lastPoint;
+ numPoints++;
+ passTop = true;
+ } else if (j==d2i(ceil(img_Ly_pix)) && ((lines[k] < zTR && lines[k] > zTL) || (lines[k] < zTL && lines[k] > zTR))) {
numPoints++;
passTop = true;
@@ -3886,4 +3892,5 @@ void Kst2DPlot::plotImages(QPainter& p,
topPoint.setY(j);
}
+ hasPrevBottom = false;
//passes through the bottom
if ((lines[k] < zBR && lines[k] > zBL) || (lines[k] < zBL && lines[k] > zBR)) {
@@ -3892,4 +3899,8 @@ void Kst2DPlot::plotImages(QPainter& p,
bottomPoint.setX((int)(((lines[k] - zBL)*CONTOUR_STEP + (zBR - zBL)*i) / (zBR - zBL)));
bottomPoint.setY(j+CONTOUR_STEP);
+ if (j + 2*CONTOUR_STEP < d2i(floor(img_Hy_pix))) {
+ lastPoint = bottomPoint;
+ hasPrevBottom = true;
+ }
}
//passes through the left
More information about the Kst
mailing list