Summary: | strange loss of drawing precision when drawing circles | ||
---|---|---|---|
Product: | [Applications] kig | Reporter: | Maurizio Paolini <maurizio.paolini> |
Component: | general | Assignee: | David E. Narvaez <david.narvaez> |
Status: | CONFIRMED --- | ||
Severity: | normal | CC: | rdieter |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
URL: | http://dmf.unicatt.it/~paolini/kig/bugs/ | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
two tangent circles
patch proposal patch file (clean version) png showing a (different) problem when drawing circles/arcs same as previous, but with unmodified kig |
Description
Maurizio Paolini
2016-02-25 19:44:47 UTC
One comment that could help debugging: Once we have the zoomed window after steps 1 and 2 above: - move the cursor over a point of the displayed thin line (beyond the end-point of the arc): nothing appears - move the cursor over a point where the thin line *should* be (on the prolongation of the thick line), and surprisingly you see the text "select this circle", meaning that internally the circle positioning is correct Created attachment 97618 [details]
two tangent circles
This is a striking example. The two circles are constructed as tangent, however their representation in the kig windows is not!
Further digging leads me to suspect that the problem is not in kig, but in
the QT method
QPainter::drawEllipse
I can motivate, if necessary
Maybe this issue is related to this qt bugreport: https://bugreports.qt.io/browse/QTBUG-1292 A simple workaround to the problem consists in commenting the method "CircleImp::draw" in both objects/circle_imp.cc and objects/circle_imp.h. In this way kig falls back to the generic method for drawing conics, which works fine for circles. With this workaround the last attachments with two tangent circles gives the expected behaviour Created attachment 97700 [details]
patch proposal
This patch adds toScreenF methods alongside toScreen and uses it to create a QRectF instead of a QRect in CircleImp::draw
Created attachment 97715 [details]
patch file (clean version)
the previous patch file contained unrelated differences
I'd recommend submitting your patch to reviewboard.kde.org, that's the ideal way. (In reply to Rex Dieter from comment #7) > I'd recommend submitting your patch to reviewboard.kde.org, that's the ideal > way. Done... but no comments so far. Now I am not sure what to do. Should I push my commit? Should I wait some more (how long)? solved via reviewboard: https://git.reviewboard.kde.org/r/127354/ An identical problem is present when drawing circular arcs! Since the correction is minimal and perfectly similar to what was done for circular arcs I took the liberty of pushing it into origin/master. The commit is visible as: http://commits.kde.org/kig/2f22efe4cb70960cf2362680783477ed44b2492e Anyway, there are still problems when drawing arcs and circles; apparently of a different nature: it becomes apparent when the radius of circle/arc is much larger then the size for the displayed canvas. I will attach an image that shows the problem. It shows a zoom (window from (1.8;1.8) to (2.2;2.2) ) of a construction of an arc by three points (one endpoint is inside the window) and the circle that supports that arc: it should be perfectly superposed. However the figure was obtained by forcing kig to draw the arc using the generic method for curves. As can be seen, the generic method for curves works far better then with the direct use of Qt primitives. kig with its standard drawArc would produce a drawing more or less superposed with the circle. At the moment I don't know if this is a Qt problem or a kig problem Created attachment 98046 [details]
png showing a (different) problem when drawing circles/arcs
Created attachment 98047 [details]
same as previous, but with unmodified kig
A standalone minimal C++ program using Qt5 and drawEllipse shows that the precision loss with circles having large radius is actually a Qt problem! I will try to file a qt bug report about this problem. However I suspect that using drawEllipse in this situation is not the right way to go... indeed this will cause the creation of a very large Rect and QRectF that will intersect the visible part in a tiny region. This *might* entail a big performance loss. Using drawCurve could be an option (only for circles with big radius), however some adaptation is required. Opened a qt bug report: https://bugreports.qt.io/browse/QTBUG-52312 |