[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Fri Aug 3 05:57:15 CEST 2007
SVN commit 695837 by treat:
Refactor a bit now that I know better how this is going to work.
M +5 -6 plotitem.cpp
M +4 -26 plotrenderitem.cpp
M +3 -14 plotrenderitem.h
M +8 -11 vectorcurverenderitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #695836:695837
@@ -66,14 +66,13 @@
void PlotItem::paint(QPainter *painter) {
ViewItem::paint(painter);
- QRectF range = rect();
- range = range.normalized();
- painter->translate(range.x(), range.y());
- range.moveTopLeft(QPoint(0,0));
+ QRectF plotRect = rect();
+ plotRect = plotRect.normalized();
+ painter->translate(plotRect.x(), plotRect.y());
+ plotRect.moveTopLeft(QPoint(0,0));
foreach (PlotRenderItem *renderer, _renderers) {
-
- renderer->setRange(range);
+ renderer->setPlotRect(plotRect);
renderer->paint(painter);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #695836:695837
@@ -32,21 +32,13 @@
}
-void PlotRenderItem::setProjectedRange(const QRectF &range) {
- _projectedRange = range;
-
- _range = mapFromProjection(range);
-
- refreshRange();
+void PlotRenderItem::setPlotRect(const QRectF &plotRect) {
+ _plotRect = plotRect;
}
-void PlotRenderItem::setRange(const QRectF &range) {
- _range = range;
-
- _projectedRange = mapToProjection(range);
-
- refreshRange();
+QRectF PlotRenderItem::plotRect() {
+ return _plotRect;
}
@@ -60,16 +52,6 @@
}
-QRectF PlotRenderItem::projectedRange() {
- return _projectedRange;
-}
-
-
-QRectF PlotRenderItem::range() {
- return _range;
-}
-
-
QRectF PlotRenderItem::mapToProjection(const QRectF &rect) {
return QRectF(mapToProjection(rect.topLeft()), mapToProjection(rect.bottomRight()));
}
@@ -79,10 +61,6 @@
return QRectF(mapFromProjection(rect.topLeft()), mapFromProjection(rect.bottomRight()));
}
-
-void PlotRenderItem::refreshRange() {
}
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #695836:695837
@@ -29,14 +29,9 @@
void setType(RenderType type);
RenderType type();
- // FIXME better name?
- void setRange(const QRectF &range);
- QRectF range();
+ void setPlotRect(const QRectF &plotRect);
+ QRectF plotRect();
- // FIXME better name?
- void setProjectedRange(const QRectF &range);
- QRectF projectedRange();
-
void setRelationList(const KstRelationList &relationList);
KstRelationList relationList() const;
@@ -49,17 +44,11 @@
QRectF mapToProjection(const QRectF &rect);
QRectF mapFromProjection(const QRectF &rect);
- // FIXME still not clear...
- // Recompute auxilliary range information if the
- // properties of the full plot have changed.
- void refreshRange();
-
private:
QString _name;
RenderType _type;
- QRectF _range;
- QRectF _projectedRange;
+ QRectF _plotRect;
KstRelationList _relationList;
};
--- branches/work/kst/portto4/kst/src/libkstapp/vectorcurverenderitem.cpp #695836:695837
@@ -33,7 +33,7 @@
KstCurveRenderContext context;
context.painter = painter;
- context.window = range().toRect(); //no idea if this should be floating point
+ context.window = plotRect().toRect(); //no idea if this should be floating point
//FIXME rename these methods in kstvcurve
QRectF vectorRect(relation->minX(),
@@ -48,13 +48,10 @@
QRectF zoomRect = t.mapRect(vectorRect);
zoomRect.moveTopLeft(vectorRect.topLeft());
- //FIXME this should no longer be called range...
- QRectF plotRect = range();
-
// qDebug() << "============================================================>"
// << "vectorRect" << vectorRect
// << "zoombox" << zoomRect
-// << "plotRect" << plotRect << endl;
+// << "plotRect" << plotRect() << endl;
//FIXME Completely refactor KstCurveRenderContext now that we know what these are
@@ -65,14 +62,14 @@
context.YMax = zoomRect.bottom();
//These are the bounding box in regular QGV coord
- context.Lx = plotRect.left();
- context.Hx = plotRect.right();
- context.Ly = plotRect.top();
- context.Hy = plotRect.bottom();
+ context.Lx = plotRect().left();
+ context.Hx = plotRect().right();
+ context.Ly = plotRect().top();
+ context.Hy = plotRect().bottom();
//To convert between the last two...
- double m_X = double(plotRect.width()-1)/(context.XMax - context.XMin);
- double m_Y = -double(plotRect.height()-1)/(context.YMax - context.YMin);
+ double m_X = double(plotRect().width()-1)/(context.XMax - context.XMin);
+ double m_Y = -double(plotRect().height()-1)/(context.YMax - context.YMin);
double b_X = context.Lx - m_X * context.XMin;
double b_Y = context.Ly - m_Y * context.YMax;
More information about the Kst
mailing list