[Kst] branches/work/kst/portto4/kst/src
Adam Treat
treat at kde.org
Thu Aug 2 19:31:16 CEST 2007
SVN commit 695691 by treat:
Draw something vaguely resembling error bars
M +1 -1 libkstapp/plotitem.cpp
M +41 -6 libkstapp/vectorcurverenderitem.cpp
M +1 -1 libkstmath/kstimage.cpp
M +2 -2 libkstmath/kstrelation.h
M +1 -1 libkstmath/kstvcurve.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #695690:695691
@@ -63,7 +63,7 @@
void PlotItem::paint(QPainter *painter) {
ViewItem::paint(painter);
- painter->translate(rect().x(), rect().y());
+ painter->translate(rect().x(), rect().y() + rect().height());
QRectF range = boundingRect();
range = painter->transform().mapRect(range);
--- branches/work/kst/portto4/kst/src/libkstapp/vectorcurverenderitem.cpp #695690:695691
@@ -25,12 +25,47 @@
void VectorCurveRenderItem::paint(QPainter *painter) {
- foreach (KstRelationPtr relation, relationList()) {
- KstCurveRenderContext context;
- context.p = painter;
- context.window = range().toRect(); //no idea if this should be floating point
- relation->paint(context);
- }
+ foreach (KstRelationPtr relation, relationList()) {
+ KstCurveRenderContext context;
+ context.painter = painter;
+ context.window = range().toRect(); //no idea if this should be floating point
+
+ qDebug() << range() << endl;
+
+ //Everything that comes next is magic... I took most from kst2dplot, hints
+ //from barth and trial and error...
+
+ //These are the region of the plot in vector coord
+ context.XMin = 0.0;
+ context.XMax = 0.1;
+ context.YMin = 0.0;
+ context.YMax = 0.1;
+
+ //These are the bounding box in regular QGV coord
+ context.Lx = 0;
+ context.Hx = range().right();
+ context.Ly = 0;
+ context.Hy = range().bottom();
+
+ //To convert between the last two...
+ double m_X = double(range().width()-1)/(context.XMax - context.XMin);
+ double m_Y = -double(range().height()-1)/(context.YMax - context.YMin);
+ double b_X = context.Lx - m_X * context.XMin;
+ double b_Y = context.Ly - m_Y * context.YMax;
+
+ context.m_X = m_X;
+ context.m_Y = m_Y;
+ context.b_X = b_X;
+ context.b_Y = b_Y;
+
+ painter->save();
+ QTransform t;
+ t.scale(1, -1); //i guess this is dependent upon the Y vector range
+ painter->setTransform(t, true);
+ painter->translate(0, int(-1.0 * context.Hy - context.Ly));
+ relation->paint(context);
+ painter->restore();
+ }
}
--- branches/work/kst/portto4/kst/src/libkstmath/kstimage.cpp #695690:695691
@@ -559,7 +559,7 @@
bool xLog = context.xLog, yLog = context.yLog;
double xLogBase = context.xLogBase;
double yLogBase = context.yLogBase;
- /*Kst*/QPainter* p = context.p;
+ /*Kst*/QPainter* p = context.painter;
QColor invalid = context.backgroundColor;
double x, y, width, height;
--- branches/work/kst/portto4/kst/src/libkstmath/kstrelation.h #695690:695691
@@ -34,7 +34,7 @@
class KstCurveRenderContext {
public:
// FIXME: use reasonable defaults
- KstCurveRenderContext() : p(0L), Lx(0.0), Hx(0.0), Ly(0.0), Hy(0.0),
+ KstCurveRenderContext() : painter(0L), Lx(0.0), Hx(0.0), Ly(0.0), Hy(0.0),
m_X(0.0), m_Y(0.0), b_X(0.0), b_Y(0.0),
x_max(0.0), y_max(0.0), x_min(0.0), y_min(0.0),
XMin(0.0), YMin(0.0), XMax(0.0), YMax(0.0),
@@ -42,7 +42,7 @@
yLogBase(0.0), penWidth(0)
{}
- QPainter* p;
+ QPainter* painter;
QRect window;
double Lx, Hx, Ly, Hy;
double m_X, m_Y, b_X, b_Y;
--- branches/work/kst/portto4/kst/src/libkstmath/kstvcurve.cpp #695690:695691
@@ -854,7 +854,7 @@
return;
}
- /*Kst*/QPainter *p = context.p;
+ /*Kst*/QPainter *p = context.painter;
QColor foregroundColor = context.foregroundColor;
double Lx = context.Lx, Hx = context.Hx, Ly = context.Ly, Hy = context.Hy;
double m_X = context.m_X, m_Y = context.m_Y;
More information about the Kst
mailing list