Summary: | Symbol scaling is wrong when printing | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Nicolas Brisset <nicolas.brisset> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Proposed patch |
Description
Nicolas Brisset
2006-05-29 22:51:38 UTC
By the way, setting the curve width larger also affects symbol size, and they quickly become visible (weight = 3 looks quite OK). Created attachment 16386 [details]
Proposed patch
Correctly handles zero-width lines.
Better scales for printing.
SVN commit 547292 by arwalker: BUG:128278 Better scale symbols when printing. M +8 -4 kstpainter.cpp M +21 -10 kstvcurve.cpp --- trunk/extragear/graphics/kst/src/libkstmath/kstpainter.cpp #547291:547292 @@ -57,10 +57,14 @@ int KstPainter::lineWidthAdjustmentFactor() const { - const QRect& w(window()); - /* For square windows, the line width is in units of 0.1% of window size */ - /* For printing to Letter or A10, line width is ~in points */ - const int factor = (w.width() + w.height()) / 2000; + int factor = 1; + + if (type() == P_PRINT || type() == P_EXPORT) { + const QRect& w(window()); + + factor = (w.width() + w.height()) / 800; + } + return factor > 0 ? factor : 1; } --- trunk/extragear/graphics/kst/src/libkstmath/kstvcurve.cpp #547291:547292 @@ -871,8 +871,14 @@ if (sampleCount() > 0) { Qt::PenStyle style = KstLineStyle[lineStyle()]; int i0, iN; - int width = lineWidth() * penWidth; //kMax(lineWidth(), penWidth); - + int width; + + if (lineWidth() == 0) { + width = penWidth; + } else { + width = lineWidth() * penWidth; + } + if (xv->isRising()) { i0 = indexNearX(XMin, xv, NS); if (i0 > 0) { @@ -1323,7 +1329,6 @@ QRegion rgn((int)Lx, (int)Ly, (int)w, (int)h); const int size = int(kMax(w, h)) / int(pow(3.0, KSTPOINTDENSITY_MAXTYPE - pointDensity())); QPoint pt; - const int lineWidth = width; //this->lineWidth(); for (i_pt = i0; i_pt <= iN; ++i_pt) { rX = xv->interpolate(i_pt, NS); rY = yv->interpolate(i_pt, NS); @@ -1337,12 +1342,11 @@ pt.setX(d2i(m_X * rX + b_X)); pt.setY(d2i(m_Y * rY + b_Y)); if (rgn.contains(pt)) { - KstCurvePointSymbol::draw(pointType, p, pt.x(), pt.y(), lineWidth); + KstCurvePointSymbol::draw(pointType, p, pt.x(), pt.y(), width); rgn -= QRegion(pt.x()-(size/2), pt.y()-(size/2), size, size, QRegion::Ellipse); } } } else { - const int lineWidth = width; //this->lineWidth(); for (i_pt = i0; i_pt <= iN; ++i_pt) { rX = xv->interpolate(i_pt, NS); rY = yv->interpolate(i_pt, NS); @@ -1356,7 +1360,7 @@ X1 = m_X * rX + b_X; Y1 = m_Y * rY + b_Y; if (X1 >= Lx && X1 <= Hx && Y1 >= Ly && Y1 <= Hy) { - KstCurvePointSymbol::draw(pointType, p, d2i(X1), d2i(Y1), lineWidth); + KstCurvePointSymbol::draw(pointType, p, d2i(X1), d2i(Y1), width); } } } @@ -1640,9 +1644,10 @@ } if (hasLines() && xv->isRising()) { - // if hasLines then we should find the distance between the curve and the point, not the data and the point. if isRising because it is (probably) to slow to use this technique if the data is unordered. - - // borrowed from indexNearX. use binary search to find the indices immediately above and below our xpos. + // if hasLines then we should find the distance between the curve and the point, not the data and + // the point. if isRising because it is (probably) to slow to use this technique if the data is + // unordered. borrowed from indexNearX. use binary search to find the indices immediately above + // and below our xpos. int i_top = NS - 1; int i_bot = 0; @@ -1676,8 +1681,14 @@ void KstVCurve::paintLegendSymbol(KstPainter *p, const QRect& bound) { - int width = lineWidth() * p->lineWidthAdjustmentFactor(); + int width; + if (lineWidth() == 0) { + width = p->lineWidthAdjustmentFactor(); + } else { + width = lineWidth() * p->lineWidthAdjustmentFactor(); + } + p->save(); if (hasLines()) { // draw a line from left to right centered vertically |