[Kst] branches/work/kst/portto4/kst/src

Adam Treat treat at kde.org
Wed Aug 1 17:03:21 CEST 2007


SVN commit 695184 by treat:

* And we're back to drawing the red dot, but
at least this time we're drawing with the right
QPainter brush.  Also, the scale of the dot changes
as the plot is scaled.  So that's nice.


 M  +6 -6      libkstapp/plotitem.cpp  
 M  +0 -2      libkstapp/plotrenderitem.h  
 M  +6 -16     libkstapp/vectorcurverenderitem.cpp  
 M  +0 -1      libkstapp/vectorcurverenderitem.h  
 M  +2 -3      libkstmath/kstcurvepointsymbol.cpp  
 M  +1 -1      libkstmath/kstcurvepointsymbol.h  
 M  +1 -1      libkstmath/kstimage.cpp  
 M  +2 -1      libkstmath/kstrelation.h  
 M  +2 -2      libkstmath/kstvcurve.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #695183:695184
@@ -65,14 +65,14 @@
 
   painter->translate(rect().x(), rect().y());
 
+  QRectF range = boundingRect();
+  range = painter->transform().mapRect(range);
+  range.moveTopLeft(QPoint(0,0));
+
   foreach (PlotRenderItem *renderer, _renderers) {
 
-    renderer->setRange(painter->window()); //FIXME no idea if this is the idea...
-
-    QList<QPainterPath> paths = renderer->projectedPaths();
-    foreach (QPainterPath path, paths) {
-      painter->drawPath(path);
-    }
+    renderer->setRange(range); //FIXME no idea if this is the idea...
+    renderer->paint(painter);
   }
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #695183:695184
@@ -42,8 +42,6 @@
 
     virtual void paint(QPainter *painter) = 0;
 
-    virtual QList<QPainterPath> projectedPaths() = 0;
-
   protected:
     virtual QPointF mapToProjection(const QPointF &point) = 0;
     virtual QPointF mapFromProjection(const QPointF &point) = 0;
--- branches/work/kst/portto4/kst/src/libkstapp/vectorcurverenderitem.cpp #695183:695184
@@ -25,25 +25,15 @@
 
 
 void VectorCurveRenderItem::paint(QPainter *painter) {
-    Q_UNUSED(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);
+    }
 }
 
 
-QList<QPainterPath> VectorCurveRenderItem::projectedPaths() {
-//   QList<QPainterPath> paths;
-// 
-//   foreach (KstRelationPtr relation, relationList()) {
-//     QPainterPath path;
-//     KstCurveRenderContext context;
-//     context.path = &path;
-//     context.rect = range().toRect();
-//     relation->paint(context);
-//     paths << path;
-//   }
-//   return paths;
-}
-
-
 QPointF VectorCurveRenderItem::mapToProjection(const QPointF &point) {
   return point;
 }
--- branches/work/kst/portto4/kst/src/libkstapp/vectorcurverenderitem.h #695183:695184
@@ -22,7 +22,6 @@
     virtual ~VectorCurveRenderItem();
 
     virtual void paint(QPainter *painter);
-    virtual QList<QPainterPath> projectedPaths();
 
   protected:
     virtual QPointF mapToProjection(const QPointF &point);
--- branches/work/kst/portto4/kst/src/libkstmath/kstcurvepointsymbol.cpp #695183:695184
@@ -134,9 +134,8 @@
 }
 
 
-int dim(QPainter *p) {
-  QRect r = p->window();
-  return qMax(1, ((r.width() + r.height()) / 400));
+int dim(const QRect &window) {
+  return qMax(1, ((window.width() + window.height()) / 400));
 }
 
 }
--- branches/work/kst/portto4/kst/src/libkstmath/kstcurvepointsymbol.h #695183:695184
@@ -27,7 +27,7 @@
     /** draw the point on a painter the scale of the point is based on size */
     KST_EXPORT void draw(int type, QPainter *p, int x, int y, int lineSize = 0, int size = -1);
     /** Get the dimension of a point */
-    KST_EXPORT int dim(QPainter *p);
+    KST_EXPORT int dim(const QRect &window);
 }
 
 #endif
--- branches/work/kst/portto4/kst/src/libkstmath/kstimage.cpp #695183:695184
@@ -559,7 +559,7 @@
   bool xLog = context.xLog, yLog = context.yLog;
   double xLogBase = context.xLogBase;
   double yLogBase = context.yLogBase;
-  KstPainter* p = context.p;
+  /*Kst*/QPainter* p = context.p;
   QColor invalid = context.backgroundColor;
   
   double x, y, width, height;
--- branches/work/kst/portto4/kst/src/libkstmath/kstrelation.h #695183:695184
@@ -42,7 +42,8 @@
                               yLogBase(0.0), penWidth(0)
     {}
 
-    KstPainter* p;
+    QPainter* p;
+    QRect window;
     double Lx, Hx, Ly, Hy;
     double m_X, m_Y, b_X, b_Y;
     double x_max, y_max, x_min, y_min;
--- branches/work/kst/portto4/kst/src/libkstmath/kstvcurve.cpp #695183:695184
@@ -854,7 +854,7 @@
     return;
   }
 
-  KstPainter *p = context.p;
+  /*Kst*/QPainter *p = context.p;
   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;
@@ -879,7 +879,7 @@
   benchtmp.start();
 #endif
 
-  int pointDim = KstCurvePointSymbol::dim(p);
+  int pointDim = KstCurvePointSymbol::dim(context.window);
   if (sampleCount() > 0) {
     Qt::PenStyle style = KstLineStyle[lineStyle()];
     int i0, iN;


More information about the Kst mailing list