In many cases the graphic drawing presents strange precision loss, like circles that should go through the same point but they don't. Numerical error does not explain the result. In the web page above there is an example. An arc and a circle are constructed such that the circle is the support circle of the arc. They should be exactly superposed, but they aren't (zoom in an area of size approximately 1) Please note that: - if exported in png format the precision error is present - if exported in SVG (or other vector formats) the result is instead CORRECT! This suggests that the problem is not in the kig "calc" engine, but somewhere else. In my opinion this problems was not present in earlier kig versions (say kde2 or kde3), but it is there since quite some time. It is quite annoying... Reproducible: Always Steps to Reproduce: 1. Download "bug.kig" from the web page 2. Zoom around an end-point of the arc (near the origin) such that the window size is of order one Actual Results: The arc (thick line) is separated from the circle (thin line) Expected Results: The arc should be perfectly superposed with the circle Numerical precision cannot be blamed, this example is not that extreme!
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