[Kst] [Bug 125888] printing does not correctly handle legend curve width

Andrew Walker arwalker at sumusltd.com
Fri May 12 21:52:34 CEST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=125888         




------- Additional Comments From arwalker sumusltd com  2006-05-12 21:52 -------
SVN commit 540266 by arwalker:

CCBUG:125888 Print curve legends at proper width

 M  +2 -7      libkstapp/kst2dplot.cpp  
 M  +1 -2      libkstapp/kstviewlegend.cpp  
 M  +6 -11     libkstmath/kstcurvepointsymbol.cpp  
 M  +5 -3      libkstmath/kstvcurve.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #540265:540266
 @ -2286,7 +2286,7  @
 void Kst2DPlot::paintSelf(KstPainter& p, const QRegion& bounds) {
   if (p.type() == KstPainter::P_EXPORT || p.type() == KstPainter::P_PRINT) {
     p.save();
-    p.setViewport(geometry());
+    p.translate(geometry().left(), geometry().top());
     draw(p);
     p.restore();
     KstPlotBase::paintSelf(p, bounds);
 @ -2376,10 +2376,7  @
   benchTime.start();
 #endif
 
-  p.setWindow(0, 0, int(p.viewport().width()),
-                    int(p.viewport().height()));
-
-  QRect winRect = p.window();
+  QRect winRect = geometry();
   int x_px = winRect.width();
   int y_px = winRect.height();
 
 @ -2565,8 +2562,6  @
     p.fillRect(RelWinRegion, QBrush(foregroundColor(), Qt::DiagCrossPattern));
     p.drawRect(RelWinRegion);
   }
-
-  p.setWindow(old_window);
 }
 
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #540265:540266
 @ -355,8 +355,7  @
     adjustSizeForText(_parent->geometry());
     KstBorderedViewObject::paintSelf(p, bounds);
     const QRect cr(contentsRectForDevice(p));
-    p.setViewport(cr);
-    p.setWindow(0, 0, cr.width(), cr.height());
+    p.translate(cr.left(), cr.top());
     if (!_transparent) {
       p.fillRect(0, 0, cr.width(), cr.height(), _backgroundColor);
     }
--- trunk/extragear/graphics/kst/src/libkstmath/kstcurvepointsymbol.cpp #540265:540266
 @ -23,25 +23,20  @
 namespace KstCurvePointSymbol {
 
 void draw(int Type, QPainter *p, int x, int y, int lineSize, int size) {
+  Q_UNUSED(size)
+  
   int s;
 
   if (Type < 0 || Type > KSTPOINT_MAXTYPE) {
     Type = 0;
   }
 
-  if (size == -1) {
-    QRect r = p->window();
-    s = (r.width() + r.height())/400;
+  if (lineSize == 0 || lineSize == 1) {
+    s = 3;
   } else {
-    s = size/200;
+    s = ( 3 * lineSize ) / 2;
   }
-
-  if (s < 1) {
-    s = 1;
-  }
-
-  s += lineSize;
-
+  
   switch (Type) {
     case 0:
       p->drawLine(x-s, y-s, x+s, y+s);
--- trunk/extragear/graphics/kst/src/libkstmath/kstvcurve.cpp #540265:540266
 @ -1666,17 +1666,19  @
 
 
 void KstVCurve::paintLegendSymbol(KstPainter *p, const QRect& bound) {
+  int width = lineWidth() * p->lineWidthAdjustmentFactor();
+  
   p->save();
   if (hasLines()) {
     // draw a line from left to right centered vertically
-    p->setPen(QPen(color(), lineWidth() * p->lineWidthAdjustmentFactor(), KstLineStyle[lineStyle()]));
+    p->setPen(QPen(color(), width, KstLineStyle[lineStyle()]));
     p->drawLine(bound.left(), bound.top() + bound.height()/2,
                 bound.right(), bound.top() + bound.height()/2);
   }
   if (hasPoints()) {
     // draw a point in the middle
-    p->setPen(QPen(color(), lineWidth() * p->lineWidthAdjustmentFactor()));
-    KstCurvePointSymbol::draw(pointType, p, bound.left() + bound.width()/2, bound.top() + bound.height()/2, lineWidth(), 600);
+    p->setPen(QPen(color(), width));
+    KstCurvePointSymbol::draw(pointType, p, bound.left() + bound.width()/2, bound.top() + bound.height()/2, width, 600);
   }
   p->restore();
 }


More information about the Kst mailing list