[Kst] extragear/graphics/kst
George Staikos
staikos at kde.org
Wed Jan 25 08:01:57 CET 2006
SVN commit 502186 by staikos:
- catch < instead of <= 0.0 for YMin (as opposed to XMin which was correct)
- remove trailing whitespace
- remove non-conforming code
M +2 -2 devel-docs/RELEASE_PLAN
M +47 -36 kst/kst2dplot.cpp
M +1 -1 kst/kst2dplot.h
--- trunk/extragear/graphics/kst/devel-docs/RELEASE_PLAN #502185:502186
@@ -1,4 +1,4 @@
-Next release: 1.2.0 (Final Jan 31)
+Next release: 1.2.0 (Final Jan 31 - yes, we are frozen)
1.2 Release Plan - scripting and tools release
----------------
@@ -12,12 +12,12 @@
- Saving works?
- Docs
- margin/padding becomes tenths of font size(0)
- - Address or revert commits 500673 and 499791
2) Review changes to .kst format
1.3 Release Plan - data analysis release (Apr 31 2006 :-))
----------------
1) Features remaining:
+ - Completely refactor the repository structure
- Implement proper drag+drop, undo and copy/cut/paste
- Object templates and complex object construction (main focus)
- GL Renderer?
--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #502185:502186
@@ -839,20 +839,20 @@
}
-void Kst2DPlot::autoBorder(bool log, double& min, double& max) {
+QPair<double, double> Kst2DPlot::computeAutoBorder(bool log, double currentMin, double currentMax) {
+ double min = currentMin, max = currentMax;
if (log) {
min = log10(min);
- max = (max > 0.0) ? log10(max): 0.0;
- double dx = (max-min)/40.0;
- max += dx;
- min -= dx;
- max = pow(10.0, max);
- min = pow(10.0, min);
+ max = max > 0.0 ? log10(max) : 0.0;
+ double dx = (max - min) / 40.0;
+ max = pow(10.0, max + dx);
+ min = pow(10.0, min - dx);
} else {
- double dx = (max-min)/40.0;
+ double dx = (max - min) / 40.0;
max += dx;
min -= dx;
- }
+ }
+ return qMakePair(min, max);
}
@@ -898,7 +898,9 @@
XMin = pow(10.0, -350.0);
}
if (_xScaleMode == AUTOBORDER) {
- autoBorder(_xLog, XMin, XMax);
+ QPair<double, double> borders = computeAutoBorder(_xLog, XMin, XMax);
+ XMin = borders.first;
+ XMax = borders.second;
}
break;
@@ -1091,11 +1093,13 @@
YMax = YMin + 0.2;
}
- if (_yLog && YMin < 0.0) {
+ if (_yLog && YMin <= 0.0) {
YMin = pow(10.0, -350.0);
}
if (_yScaleMode == AUTOBORDER) {
- autoBorder(_yLog, YMin, YMax);
+ QPair<double, double> borders = computeAutoBorder(_yLog, YMin, YMax);
+ YMin = borders.first;
+ YMax = borders.second;
}
break;
@@ -1131,7 +1135,7 @@
YMax = YMin + 0.2;
}
- if (_yLog && YMin < 0.0) {
+ if (_yLog && YMin <= 0.0) {
YMin = pow(10.0, -350.0);
}
break;
@@ -1203,7 +1207,7 @@
c->readUnlock();
}
- if (_yLog && YMin < 0.0) {
+ if (_yLog && YMin <= 0.0) {
YMin = pow(10.0, -350.0);
}
if (YMin >= YMax) { // has to be legal, even for autoup...
@@ -1980,15 +1984,15 @@
int yFullTickLabelWidth = 0;
int xLabelWidth = 0;
int yLabelHeight = 0;
-
+
_fullTickLabel->setRotation(0);
-
+
if (tpx.delta && tpxLabelCount) {
_fullTickLabel->setText(tpx.labels[0]);
xFullTickLabelWidth = _fullTickLabel->size().width();
xFullTickLabelLineSpacing = _fullTickLabel->lineSpacing();
xLabelWidth = _xLabel->size().width();
-
+
}
if (tpy.delta && tpyLabelCount > 0) {
_fullTickLabel->setText(tpy.labels[0]);
@@ -1996,7 +2000,7 @@
yFullTickLabelLineSpacing = _fullTickLabel->lineSpacing();
yLabelHeight = _yLabel->size().height();
}
-
+
// calculate offsets if we are using delta values
if (tpx.delta && tpxLabelCount > 0 && tpy.delta && tpyLabelCount > 0) {
if (xFullTickLabelWidth + xleft_bdr_px + xFullTickLabelLineSpacing >= (x_px - xLabelWidth)/2.0) {
@@ -2472,7 +2476,7 @@
context._backgroundColor = _backgroundColor;
// paint the curves
- p.save();
+ p.save();
if (_xReversed) {
p.scale(-1, 1);
p.translate(d2i(-1.0 * Hx - Lx), 0);
@@ -2480,10 +2484,10 @@
if (_yReversed) {
p.scale(1, -1);
p.translate(0, d2i(-1.0 * Hy - Ly));
- }
- p.setClipRect(int(Lx), int(Ly), int(Hx - Lx), int(Hy - Ly), QPainter::CoordPainter);
+ }
+ p.setClipRect(int(Lx), int(Ly), int(Hx - Lx), int(Hy - Ly), QPainter::CoordPainter);
for (KstBaseCurveList::Iterator i = Curves.begin(); i != Curves.end(); ++i) {
- (*i)->paint(context);
+ (*i)->paint(context);
}
p.restore();
@@ -3544,7 +3548,7 @@
double best_distance = 1.0E300;
double dx_per_pix;
int i_near_x;
-
+
// convert 1 pixel to plot units.
if (_xReversed) {
dx_per_pix = (double)(pr.right() + 2 - pos.x() + 2) / (double)pr.width() * (xmax - xmin) + xmin;
@@ -3554,8 +3558,8 @@
if (isXLog()) {
dx_per_pix = pow(10.0, dx_per_pix);
}
- dx_per_pix -= xpos;
-
+ dx_per_pix -= xpos;
+
for (KstVCurveList::Iterator i = vcurves.begin(); i != vcurves.end(); ++i) {
i_near_x = (*i)->getIndexNearXY(xpos, dx_per_pix, ypos);
(*i)->point(i_near_x, near_x, near_y);
@@ -3677,7 +3681,7 @@
msg = i18n("Curve name, (x, y)", "%3 (%1, %2)").arg(xlabel).arg(ylabel).arg(name);
}
}
-
+
// display the z value of the topmost image underneath cursor, if available...
KstImageList images = kstObjectSubList<KstBaseCurve,KstImage>(Curves);
if (images.count() > 0) {
@@ -4572,11 +4576,13 @@
YMin -= 0.1;
YMax = YMin + 0.2;
}
- if (_yLog && YMin < 0.0) {
+ if (_yLog && YMin <= 0.0) {
YMin = pow(10.0, -350.0);
}
- autoBorder(_yLog, YMin, YMax);
+ QPair<double, double> borders = computeAutoBorder(_yLog, YMin, YMax);
+ YMin = borders.first;
+ YMax = borders.second;
setYScaleMode(FIXED);
}
@@ -5620,7 +5626,7 @@
p.restore();
tpy.labels.pop_front();
}
-
+
int xTickPos = d2i(xleft_bdr_px - _yTickLabel->lineSpacing() / 4);
if (yTicksOutPlot()) {
xTickPos -= d2i(2.0 * ytick_len_px);
@@ -5690,7 +5696,7 @@
_yLabel->paint(p);
p.restore();
}
-
+
if (!_suppressTop) {
p.save();
if (_xTransformed) {
@@ -5993,7 +5999,7 @@
double best_distance = 1.0E300;
double xmin, ymin, xmax, ymax;
double xpos, ypos;
-
+
getCursorPos(pos, xpos, ypos, xmin, xmax, ymin, ymax);
// convert 1 pixel to plot units.
@@ -6548,26 +6554,31 @@
PlotRegion.height());
}
+
double Kst2DPlot::verticalSizeFactor() {
// roughtly, geometry/dataRect. But use an estimate rather
// than calculating it, so that we get stable results.
// this is used by cleanup to do a better job with
// sizing plots with supressed borders.
double f = 1.3;
- if (_suppressTop)
+ if (_suppressTop) {
f -= 0.1;
- if (_suppressBottom)
+ }
+ if (_suppressBottom) {
f -= 0.2;
-
+ }
+
return f;
}
double Kst2DPlot::horizontalSizeFactor() {
double f = 1.3;
- if (_suppressLeft)
+ if (_suppressLeft) {
f -= 0.25;
- if (_suppressRight)
+ }
+ if (_suppressRight) {
f -= 0.05;
+ }
return f;
}
--- trunk/extragear/graphics/kst/kst/kst2dplot.h #502185:502186
@@ -429,7 +429,7 @@
double ymax,
bool x_log = false,
bool y_log = false);
- void autoBorder(bool log, double& min, double& max);
+ QPair<double, double> computeAutoBorder(bool log, double min, double max);
void setBorders(double& xleft_bdr_px, double& xright_bdr_px,
double& ytop_bdr_px, double& ybot_bdr_px,
TickParameters &tpx, TickParameters &tpy,
More information about the Kst
mailing list