* only antialias the whole polyline or no segment at all

* Sqrt and Root draw their vertical horizontal line with a single line command to make them showup non-antialiased.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18419 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2007-05-19 10:52:47 +00:00
parent 725aab6154
commit 96860ffe93
3 changed files with 32 additions and 24 deletions

View File

@ -114,15 +114,21 @@ void QLPainter::lines(int const * xp, int const * yp, int np,
if (!isDrawingEnabled())
return;
bool const text_is_antialiased = renderHints() & TextAntialiasing;
setQPainterPen(col, ls, lw);
for (int i = 1; i < np; ++i) {
bool const do_antialiasing = text_is_antialiased
&& xp[i-1] != xp[i] && yp[i-1] != yp[i];
setRenderHint(Antialiasing, do_antialiasing);
drawLine(xp[i-1], yp[i-1], xp[i], yp[i]);
setRenderHint(Antialiasing, false);
// Must use new as np is not known at compile time.
boost::scoped_array<QPoint> points(new QPoint[np]);
bool antialias = false;
for (int i = 0; i < np; ++i) {
points[i].setX(xp[i]);
points[i].setY(yp[i]);
if (i != 0)
antialias |= xp[i-1] != xp[i] && yp[i-1] != yp[i];
}
setQPainterPen(col, ls, lw);
bool const text_is_antialiased = renderHints() & TextAntialiasing;
setRenderHint(Antialiasing, antialias && text_is_antialiased);
drawPolyline(points.get(), np);
setRenderHint(Antialiasing, false);
}

View File

@ -61,14 +61,15 @@ void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const
cell(1).draw(pi, x + w + 8, y);
int const a = dim_.ascent();
int const d = dim_.descent();
int xp[5];
int yp[5];
xp[0] = x + dim_.width(); yp[0] = y - a + 1;
xp[1] = x + w + 4; yp[1] = y - a + 1;
xp[2] = x + w; yp[2] = y + d;
xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2;
xp[4] = x + w - 5; yp[4] = y + (d - a)/2 + 4;
pi.pain.lines(xp, yp, 5, Color::math);
int xp[4];
int yp[4];
pi.pain.line(x + dim_.width(), y - a + 1,
x + w + 4, y - a + 1, Color::math);
xp[0] = x + w + 4; yp[0] = y - a + 1;
xp[1] = x + w; yp[1] = y + d;
xp[2] = x + w - 2; yp[2] = y + (d - a)/2 + 2;
xp[3] = x + w - 5; yp[3] = y + (d - a)/2 + 4;
pi.pain.lines(xp, yp, 4, Color::math);
drawMarkers(pi, x, y);
}

View File

@ -53,13 +53,14 @@ void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
cell(0).draw(pi, x + 10, y);
int const a = dim_.ascent();
int const d = dim_.descent();
int xp[4];
int yp[4];
xp[0] = x + dim_.width(); yp[0] = y - a + 1;
xp[1] = x + 8; yp[1] = y - a + 1;
xp[2] = x + 5; yp[2] = y + d - 1;
xp[3] = x; yp[3] = y + (d - a)/2;
pi.pain.lines(xp, yp, 4, Color::math);
int xp[3];
int yp[3];
pi.pain.line(x + dim_.width(), y - a + 1,
x + 8, y - a + 1, Color::math);
xp[0] = x + 8; yp[0] = y - a + 1;
xp[1] = x + 5; yp[1] = y + d - 1;
xp[2] = x; yp[2] = y + (d - a)/2;
pi.pain.lines(xp, yp, 3, Color::math);
drawMarkers(pi, x, y);
}