[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Jan 21 03:50:04 CET 2009
SVN commit 914430 by netterfield:
Fix superscript and subscript size/placement
Fix selection box around multi line labels.
Do some graphics call optimizations suggested by techbase.
M +0 -12 devel-docs/Kst2Specs/Bugs
M +9 -1 devel-docs/Kst2Specs/FixedBugs
M +1 -2 src/libkstapp/labelitem.cpp
M +14 -5 src/libkstapp/labelrenderer.cpp
M +3 -2 src/libkstapp/labelrenderer.h
M +3 -2 src/libkstapp/plotrenderitem.cpp
M +8 -2 src/libkstapp/view.cpp
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Bugs #914429:914430
@@ -19,17 +19,10 @@
When plots are using name-based auto-labels, any '_' in field names gets interpreted as a subscript.
There needs to be an option to somehow escape these when using them in a label.
*cbn*
----------
-No space allocated for subscripts or superscripts in axis lables
- The subscript is cut off
-
---------
Formatting/spacing issues:
- -Superscript and subscript size and position seems off. This should be researched more
- but wikipedia as an almost reasonable article on it. It suggests both should be scaled by ~60%, and subscripts dropped by 16% and superscripts raised by 44%. OOffice, illustrator, and photoshop use scale 58%, raise 33%, lower 33%. msoffice uses 65%, -14%, +35%. It might also pay to compare w/ TeX.
-
-The spacing between the X-axis numbers and the axis is too small.
-The spacing between the Y-axis numbers and the axis doesn't seem to scale with window size.
-The plot selection buttons are too small.
@@ -73,7 +66,6 @@
---------
-
The first pane of the data wizard should be reading directories in
the background, instead of in the foreground where it steals X focus
until the directory is read. �I ran into a interminable-focus-stealing
@@ -81,7 +73,3 @@
X restart.
--------
-
-
-
-
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/FixedBugs #914429:914430
@@ -327,4 +327,12 @@
(Editorial: Fundamentally, I think this is because qt's QGraphics system has been used to track placement
of objects, and QGraphics doesn't have the right model of what we are doing.)
*Mike*
----------
\ No newline at end of file
+---------
+
+ -Superscript and subscript size and position seems off. This should be researched more
+ but wikipedia as an almost reasonable article on it. It suggests both should be scaled by ~60%, and subscripts dropped by 16% and superscripts raised by 44%. OOffice, illustrator, and photoshop use scale 58%, raise 33%, lower 33%. msoffice uses 65%, -14%, +35%. It might also pay to compare w/ TeX.
+
+---------
+
+No space allocated for subscripts or superscripts in axis lables
+ The subscript is cut off
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #914429:914430
@@ -65,8 +65,7 @@
Label::renderLabel(rc, _parsed->chunk);
// Make sure we have a rect for selection, movement, etc
- setViewRect(QRectF(box.x(), box.y(), rc.x, fm.height()));
-
+ setViewRect(QRectF(box.x(), box.y(), rc.xMax, (rc.lines+1) * fm.height()));
painter->restore();
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/labelrenderer.cpp #914429:914430
@@ -24,9 +24,15 @@
#include "document.h"
#include "objectstore.h"
#include "application.h"
+#include "applicationsettings.h"
#include <QDebug>
+const double subscript_scale = 0.60;
+const double subscript_drop = 0.16;
+const double superscript_scale = 0.60;
+const double superscript_raise = 0.44;
+
namespace Label {
void renderLabel(RenderContext& rc, Label::Chunk *fi) {
@@ -43,12 +49,14 @@
while (fi) {
if (fi->vOffset != Label::Chunk::None) {
if (fi->vOffset == Label::Chunk::Up) {
- rc.y -= int(0.4 * rc.fontHeight());
+ rc.size = int(double(rc.size)*superscript_scale);
+ rc.y -= int(superscript_raise * rc.fontHeight());
} else { // Down
- rc.y += int(0.4 * rc.fontHeight());
+ rc.size = int(double(rc.size)*subscript_scale);
+ rc.y += int(subscript_drop * rc.fontHeight());
}
- if (rc.size > 5) {
- rc.size = (rc.size*2)/3;
+ if (rc.size<Kst::ApplicationSettings::self()->minimumFontSize()) {
+ rc.size = Kst::ApplicationSettings::self()->minimumFontSize();
}
}
@@ -72,6 +80,7 @@
rc.x = oldX;
rc.y += rc.fontAscent() + rc.fontDescent() + 1;
fi = fi->next;
+ rc.lines++;
continue;
}
@@ -143,7 +152,7 @@
}
rc.x += rc.fontWidth(txt);
} else if (fi->tab) {
- const int tabWidth = rc.fontWidth("MMMMMMMM");
+ const int tabWidth = rc.fontWidth("MMMM");
const int toSkip = tabWidth - (rc.x - rc.xStart) % tabWidth;
if (rc.p && fi->attributes.underline) {
const int spaceWidth = rc.fontWidth(" ");
--- branches/work/kst/portto4/kst/src/libkstapp/labelrenderer.h #914429:914430
@@ -38,6 +38,7 @@
_cache = 0L;
substitute = true;
setFont(font);
+ lines = 0;
}
inline const QFont& font() const {
@@ -114,12 +115,12 @@
bool substitute;
QVector<DataRef> *_cache;
QPen pen;
+ int lines;
private:
QFont _font;
QFontMetrics _fm;
- int _ascent, _descent, _height, _lineSpacing; // caches to avoid performance problem
- // with QFont*
+ int _ascent, _descent, _height, _lineSpacing; // caches to avoid performance problem // with QFont*
int _fontSize;
};
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #914429:914430
@@ -226,8 +226,9 @@
}
if (plotItem()->isTiedZoom()) {
painter->save();
- painter->setOpacity(0.5);
- painter->fillPath(checkBox(), Qt::black);
+ QColor c = Qt::black;
+ c.setAlphaF(c.alphaF() * 0.5);
+ painter->fillPath(checkBox(), c);
painter->restore();
}
painter->drawPath(checkBox());
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #914429:914430
@@ -406,8 +406,14 @@
return;
painter->save();
- painter->setPen(Qt::gray);
- painter->setOpacity(0.2);
+ QColor c = Qt::gray;
+ c.setAlphaF(c.alphaF() * 0.2);
+ painter->setPen(c);
+ // http://techbase.kde.org/Development/Tutorials/Graphics/Performance says
+ // setOpacity turns off hardware acceleration.
+ // they suggest setting alpha in the color instead, which
+ // we have done, above.
+ //painter->setOpacity(0.2);
const QRectF r = sceneRect();
qreal spacing = gridSpacing().width();
More information about the Kst
mailing list