[Kst] extragear/graphics/kst/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Jan 26 00:39:30 CET 2006
SVN commit 502442 by netterfield:
Change variable name from C to CR so we don't use c and C.
No functional change.
M +27 -30 kstviewobject.cpp
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #502441:502442
@@ -703,13 +703,10 @@
// from left-to-right and top-to-bottom based on the position
// of their top-left corner.
//
-
- //kstdDebug() << "cleanup with w=" << w << " and h=" << h << endl;
- //kstdDebug() << "columns=" << _columns << endl;
int plotLoc[rows*_columns]; // what plot lives at each grid location
int unAssigned[cnt]; // what plots haven't got a home yet?
int n_unassigned = 0;
- int r,c, C;
+ int r,c, CR;
for (int i=0; i<rows*_columns; i++) {
plotLoc[i] = -1;
}
@@ -718,49 +715,49 @@
// unless there is another plot which is closer, in which case the
// plot gets dumped into an un-assigned list for placement into a
// random un-filled grid space.
- // the Location is defined relative to the top left corner.
- // QUESTION: should we use the center instead?
+ // the Location is defined relative to the left-middle.
+ // QUESTION: should we use the middle-middle instead?
// NOTE: the choice of grid location assumes a regular grid, which is
- // broken when surpressed axis/labels is taken into account. This
- // could have an effect if the plots are grown by >50%. Using the center
- // instead of the top left would reduce this...
+ // broken when supressed axis/labels are taken into account. This
+ // could have an effect if the plots are grown by >50%.
for (int i=0; i<cnt; i++) {
- //r = int(childrenCopy[i]->aspectRatio().y*rows+0.5);
- r = int((childrenCopy[i]->aspectRatio().y+childrenCopy[i]->aspectRatio().h/2)*rows);
+ //r = int(childrenCopy[i]->aspectRatio().y*rows+0.5); //use top
+ r = int((childrenCopy[i]->aspectRatio().y+childrenCopy[i]->aspectRatio().h/2)*rows); // use center
c = int(childrenCopy[i]->aspectRatio().x*_columns+0.5);
if (c>=_columns) c = _columns-1;
if (r>=rows) r = rows-1;
- C = c + r*_columns;
+ CR = c + r*_columns;
if (childrenCopy[i]->dirty()) { // newly added plots get no priority
dirty = true;
unAssigned[n_unassigned] = i;
n_unassigned++;
- } else if (plotLoc[C]<0) {
- plotLoc[C] = i;
+ } else if (plotLoc[CR]<0) {
+ plotLoc[CR] = i;
} else { // another plot is already at this grid point
double d1, d2;
// put the further of the two in the unassigned list
+ // use Manhatten distance.
d1 = fabs(double(r) - childrenCopy[i]->aspectRatio().y*rows) +
fabs(double(c) - childrenCopy[i]->aspectRatio().x*_columns);
- d2 = fabs(double(r) - childrenCopy[plotLoc[C]]->aspectRatio().y*rows) +
- fabs(double(c) - childrenCopy[plotLoc[C]]->aspectRatio().x*_columns);
+ d2 = fabs(double(r) - childrenCopy[plotLoc[CR]]->aspectRatio().y*rows) +
+ fabs(double(c) - childrenCopy[plotLoc[CR]]->aspectRatio().x*_columns);
if (d1>=d2) {
unAssigned[n_unassigned] = i;
} else {
- unAssigned[n_unassigned] = plotLoc[C];
- plotLoc[C] = i;
+ unAssigned[n_unassigned] = plotLoc[CR];
+ plotLoc[CR] = i;
}
n_unassigned++;
}
}
// now dump the unassigned plots in random holes.
- // FIXME: instead, dump them in the closest hole.
- C = 0;
+ // Question: should be dump them in the closest holes?
+ CR = 0;
for (int i=0; i<n_unassigned; i++) {
- for (;plotLoc[C]!=-1; C++){};
- plotLoc[C] = unAssigned[i];
+ for (;plotLoc[CR]!=-1; CR++){};
+ plotLoc[CR] = unAssigned[i];
}
double HR[rows], sum_HR=0;
@@ -769,9 +766,9 @@
for (r=0; r<rows; r++) {
HR[r] = 10.0;
for (c=0; c<_columns; c++) {
- C = c + r*_columns;
- if (plotLoc[C]>-1) {
- hr = childrenCopy[plotLoc[C]]->verticalSizeFactor();
+ CR = c + r*_columns;
+ if (plotLoc[CR]>-1) {
+ hr = childrenCopy[plotLoc[CR]]->verticalSizeFactor();
if (hr < HR[r]) {
HR[r] = hr;
}
@@ -790,11 +787,11 @@
//h = _geom.height() / rows;
h = int(double(_geom.height()) * HR[r]/sum_HR);
for (c=0; c<_columns; c++) {
- C = c + r*_columns;
- if (plotLoc[C] >=0) {
+ CR = c + r*_columns;
+ if (plotLoc[CR] >=0) {
QSize sz(w, h);
- r = C/_columns;
- c = C%_columns;
+ r = CR/_columns;
+ c = CR%_columns;
QPoint pt(w*c, y);
// adjust the last column to be sure that we don't spill over
@@ -807,7 +804,7 @@
sz.setHeight(_geom.height() - y);
}
- ob = childrenCopy[plotLoc[C]];
+ ob = childrenCopy[plotLoc[CR]];
ob->move(pt);
ob->resize(sz);
}
More information about the Kst
mailing list