Version: 1.2.0_devel (using KDE 3.4.3, Gentoo) Compiler: gcc version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8) OS: Linux (x86_64) release 2.6.12-gentoo-r6 There are numerous bugs in printing and exporting to graphics files - presumably related. This report covers many of them: refer to the attached plots for reference: -snapshot.png: a snapshot of of the kst window -png_output.png: exported to graphics file -print.pdf: printed to file. All errors in the graphics output are also in the print output, but not all errors in the print output are in the graphics file output. Open print.pdf and observe the following problems: -The curve is drawn over the text box (text box should be in front) -The ellipse does not appear at all, but it has masked out the plot lines. -the diagonal line becomes very blocky when it is over the plot. -The width of the text box line changes when it is over the plot. -The labels are bitmapped, but at a high resolution (~300dpi?), so it actually looks ~ok on a printer. As saving doesn't currently work, I'm not including a kst file.
Created attachment 13873 [details] Snapshot of the kst window, showing the desired plot
Created attachment 13874 [details] output of printing to pdf.
Created attachment 13875 [details] Output of exporting to png.
This all appears to be related to the clipping regions, and the way they are treated differently between painting and printing.
Is anybody looking at this? It seems that clipping for curves and view objects is non-functional when exporting and printing. Does all this clipping actually save us any time? It adds great complexity to the code and is only used when calling paintInto(...), which should be relatively fast anyway. The simplest solution for now would be to throw out all the clipping stuff and simply paint everything in the reverse order (relative to what is done now).
On Wednesday 14 December 2005 13:37, Andrew Walker wrote: > It seems that clipping for curves and view objects is non-functional when > exporting and printing. Does all this clipping actually save us any time? > It adds great complexity to the code and is only used when calling > paintInto(...), which should be relatively fast anyway. The simplest > solution for now would be to throw out all the clipping stuff and simply > paint everything in the reverse order (relative to what is done now). The clipping is -very- important because without it we overload the X server. It makes Kst freeze repeatedly. We have to paint in the order we're painting now otherwise we double the tree-walking and we get invalid geometries (since the objects aren't updated). Printing is a special case, it should not affect screen painting in any way.
SVN commit 488538 by arwalker: BUG:118148 Replace QPainter with KstPainter. Will need this to fix clipping. M +2 -1 kstbasecurve.h M +1 -1 kstimage.cpp M +1 -1 kstvcurve.cpp --- trunk/extragear/graphics/kst/kst/kstbasecurve.h #488537:488538 @@ -22,6 +22,7 @@ #include <qvaluestack.h> #include "kstdataobject.h" +#include "kstpainter.h" #include "kst_export.h" #include "labelparser.h" @@ -31,7 +32,7 @@ // context for rendering a curve in a plot struct KstCurveRenderContext { - QPainter* p; + KstPainter* p; double Lx, Hx, Ly, Hy; double m_X, m_Y, b_X, b_Y; double x_max, y_max, x_min, y_min; --- trunk/extragear/graphics/kst/kst/kstimage.cpp #488537:488538 @@ -529,7 +529,7 @@ double m_X = context.m_X, m_Y = context.m_Y, b_X = context.b_X, b_Y = context.b_Y; double x_max = context.x_max, y_max = context.y_max, x_min = context.x_min, y_min = context.y_min; bool _xLog = context._xLog, _yLog = context._yLog; - QPainter* p = context.p; + KstPainter* p = context.p; QColor invalid = context._backgroundColor; double x, y, width, height; --- trunk/extragear/graphics/kst/kst/kstvcurve.cpp #488537:488538 @@ -827,7 +827,7 @@ return; } - QPainter *p = context.p; + KstPainter *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;
Meant to do CCBUG and not BUG
SVN commit 488561 by arwalker: CCBUG:118148 Fix up some more problems M +2 -0 kstviewarrow.cpp M +2 -1 kstviewbox.cpp M +2 -1 kstviewellipse.cpp M +3 -3 kstviewline.cpp M +2 -0 kstviewpicture.cpp --- trunk/extragear/graphics/kst/kst/kstviewarrow.cpp #488560:488561 @@ -77,6 +77,7 @@ void KstViewArrow::paint(KstPainter& p, const QRegion& bounds) { + p.save(); if (p.makingMask()) { p.setRasterOp(Qt::SetROP); } @@ -158,6 +159,7 @@ } } KstViewLine::paint(p, bounds); + p.restore(); } --- trunk/extragear/graphics/kst/kst/kstviewbox.cpp #488560:488561 @@ -68,6 +68,7 @@ void KstViewBox::paint(KstPainter& p, const QRegion& bounds) { + p.save(); if (p.makingMask()) { p.setRasterOp(Qt::SetROP); KstViewObject::paint(p, bounds); @@ -100,7 +101,7 @@ r.setHeight(_geom.height() - borderWidth()); p.drawRoundRect(r, _xRound, _yRound); - p.setClipping(false); + p.restore(); } --- trunk/extragear/graphics/kst/kst/kstviewellipse.cpp #488560:488561 @@ -59,6 +59,7 @@ void KstViewEllipse::paint(KstPainter& p, const QRegion& bounds) { + p.save(); if (p.makingMask()) { p.setRasterOp(Qt::SetROP); KstViewObject::paint(p, bounds); @@ -83,7 +84,7 @@ //p.drawEllipse(geometry()); p.drawEllipse(geometry().x() + _borderWidth/2, geometry().y() + _borderWidth/2, geometry().width() - _borderWidth, geometry().height() - _borderWidth); - p.setClipping(false); + p.restore(); } --- trunk/extragear/graphics/kst/kst/kstviewline.cpp #488560:488561 @@ -57,6 +57,7 @@ void KstViewLine::paint(KstPainter& p, const QRegion& bounds) { + p.save(); if (p.makingMask()) { p.setRasterOp(Qt::SetROP); } @@ -64,7 +65,6 @@ QPen pen(_foregroundColor, _width); pen.setCapStyle(_capStyle); pen.setStyle(_penStyle); - const QPen oldPen(p.pen()); p.setPen(pen); const QRect geom(geometry()); @@ -95,8 +95,8 @@ break; } // paint this last - p.setPen(oldPen); - KstViewObject::paint(p, bounds); + KstViewObject::paint(p, bounds); + p.restore(); } --- trunk/extragear/graphics/kst/kst/kstviewpicture.cpp #488560:488561 @@ -68,6 +68,7 @@ void KstViewPicture::paint(KstPainter& p, const QRegion& bounds) { + p.save(); if (p.makingMask()) { p.setRasterOp(Qt::SetROP); KstBorderedViewObject::paint(p, bounds); @@ -118,6 +119,7 @@ } } } + p.restore(); }
SVN commit 488593 by arwalker: CCBUG:118148 When printing or exporting avoid the entire clipping scheme. More efficient and more elegant M +27 -25 ksttoplevelview.cpp M +5 -2 kstviewarrow.cpp M +14 -12 kstviewbox.cpp M +14 -13 kstviewellipse.cpp M +5 -2 kstviewline.cpp M +30 -27 kstviewobject.cpp M +14 -12 kstviewpicture.cpp M +0 -1 kstviewwindow.cpp
Barth, I believe that this fixes all the problems you describe. George, is this going to overload the X server, and if so why?
On Wednesday 14 December 2005 20:17, Andrew Walker wrote: > ------- Barth, I believe that this fixes all the problems you describe. > George, is this going to overload the X server, and if so why? No, since it only does it for printing. That's fine with me. However it still doesn't print properly for me. Objects are quite distorted and some are missing. I can send some kst sessions and .js files tomorrow.
The printing looks very good. I am so happy :-) Exporting to bitmaps (png anyway) seems to drop transparent labels.
I'll take a look at this soon. Andrew ------- Additional Comments From netterfield astro utoronto ca 2005-12-15 06:26 ------- The printing looks very good. I am so happy :-) Exporting to bitmaps (png anyway) seems to drop transparent labels.
George, you reported that several objects were distorted and others missing. Could you provide more information on this. Thanks.
On Friday 16 December 2005 12:52, Andrew Walker wrote: > ------- George, you reported that several objects were distorted and others > missing. Could you provide more information on this. Thanks. I spoke with Barth and the distortion will be address later. Printing does seem to work now, but something [very] recent broken Line drawing. May or not be related to this. I get a vertical line at the start point of a line. Also labels are distorted in the view after a print happens. (font is wrong size, for instance) Printing, though, seems to be fixed.
The problem with transparency of text labels not being preserved in printing can also be seen on the screen, albeit in a slightly different way. If you create a transparent text label and then resize the window it lives in you'll see the text label drawn twice in rapid succession, first without transparency and then with.
SVN commit 489051 by arwalker: CCBUG:118148 Fix problem with transparency not being honoured when printing M +5 -3 kstviewlabel.cpp --- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #489050:489051 @@ -228,7 +228,6 @@ void KstViewLabel::drawToPainter(Label::Parsed *lp, QPainter& p) { - int hJust = KST_JUSTIFY_H(_justify); if (QApplication::reverseLayout()) { if (hJust == KST_JUSTIFY_H_NONE) { @@ -328,7 +327,8 @@ void KstViewLabel::paint(KstPainter& p, const QRegion& bounds) { p.save(); - if (p.type() == KstPainter::P_PRINT) { + if (p.type() == KstPainter::P_PRINT || + p.type() == KstPainter::P_EXPORT) { //p.save(); if (_autoResize) { adjustSizeForText(p.window()); @@ -369,7 +369,9 @@ } } p.restore(); - KstBorderedViewObject::paint(p, bounds); + if (!_transparent) { + KstBorderedViewObject::paint(p, bounds); + } }
The only problem I am still aware of is that after printing a label with auto-resize set (which prints correctly) the label displayed on the screen now has a font size which is too large (presumably the font size used when printing).
On Friday 16 December 2005 18:41, Andrew Walker wrote: > ------- The only problem I am still aware of is that after printing a label > with auto-resize set (which prints correctly) the label displayed on the > screen now has a font size which is too large (presumably the font size > used when printing). _______________________________________________ That's the only one I know of too.
SVN commit 489314 by arwalker: CCBUG:118148 better label behavior in printing and painting M +2 -1 kstborderedviewobject.cpp M +1 -5 kstviewlabel.cpp --- trunk/extragear/graphics/kst/kst/kstborderedviewobject.cpp #489313:489314 @@ -71,10 +71,10 @@ void KstBorderedViewObject::paint(KstPainter& p, const QRegion& bounds) { + p.save(); if (p.makingMask()) { p.setRasterOp(Qt::SetROP); } - // if (_borderWidth > 0 && !_focus && !_selected) { if (_borderWidth > 0) { QRect r; QPen pen(_borderColor, _borderWidth); @@ -86,6 +86,7 @@ r.setHeight(_geom.height() - 2 * _margin - _borderWidth + 1); p.drawRect(r); } + p.restore(); KstViewObject::paint(p, bounds); } --- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #489313:489314 @@ -329,7 +329,6 @@ p.save(); if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) { - //p.save(); if (_autoResize) { adjustSizeForText(p.window()); } else { @@ -345,7 +344,6 @@ drawToPainter(_parsed, p); //setDirty(); - //p.restore(); } else { if (p.type() == KstPainter::P_UPDATE) { setDirty(); @@ -369,9 +367,7 @@ } } p.restore(); - if (!_transparent) { - KstBorderedViewObject::paint(p, bounds); - } + KstBorderedViewObject::paint(p, bounds); }
One other problem is that transparent labels show a border when printing but not when painting. This is because the clipregion in painting does not include thr border and so is never shown.
SVN commit 489316 by arwalker: CCBUG:118148 no longer display borders for transparent label - this is consistent with legend behaviour M +5 -1 kstviewlabel.cpp --- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #489315:489316 @@ -367,7 +367,11 @@ } } p.restore(); - KstBorderedViewObject::paint(p, bounds); + if (_transparent) { + KstViewObject::paint(p, bounds); + } else { + KstBorderedViewObject::paint(p, bounds); + } }
SVN commit 489321 by arwalker: BUG:118148 no longer draw to the back buffer when printing an autoresize label. It wastes time and messes up the repainting of autoresize labels as the back buffer still holds the text size used when printing. M +2 -5 kstviewlabel.cpp --- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #489320:489321 @@ -164,9 +164,6 @@ if (!_parsed) { reparse(); } - if (_parsed) { - drawToBuffer(_parsed); - } } @@ -343,14 +340,14 @@ } drawToPainter(_parsed, p); - //setDirty(); } else { if (p.type() == KstPainter::P_UPDATE) { setDirty(); } if (dirty()) { if (_autoResize) { - adjustSizeForText(p.window()); // calls computeTextSize and drawToBuffer + adjustSizeForText(p.window()); + drawToBuffer(_parsed); } else { computeTextSize(_parsed); drawToBuffer(_parsed);