Finally :D

Besides helping out in scripting, I have been slow for my own job because of boredom ascribed to continuous trials but with no results. It was confusing and it had to be. I was doing the right things but at wrong places. đŸ˜›

So I kept line again aside and starting hunting the undo/redo implementation for circle and ellipse. Though logic was same but even trivial things like displaying correct information in the undo stack seemed of much significance to us. This was tricky since I was doing it all in the wrong place. But it worked finally.

Then the bulb glowed again. And I did undo/redo for line without constructor over-riding now. It involved so much less effort today. And that feeling when your commit reduces the lines of code and does the same work correctly. So finally I am done with my undo/redo task. It is over. đŸ˜€

It had to be transformed

So I struggled today to correct the implementation of ellipse we had done previously. Deploying QPainterPath for painting now, the ellipse got its axis parallel to the principal coordinate axes, no matter what was the position of clicks with respect to one another. The two cases are shown below though the tilted one has glitches. The angle of the line connecting center and the point giving major radius mattered.


Yeah ellipse is a case of circle or it could be vice-versa but orientation affected the shape of ellipse. For it to be correct, the computation of angle had to be done. Did it but why the ellipse did not rotate? Manipulated the angles: start angle and span angle. Added the angle to both but common sense told it won’t alter anything. For a test, instead of a span of 360 degrees, reduced span angle and yes it was working.

Whoopee! It struck me. The coordinate system’s origin was translated to the center of the ellipse, rotated about an angle == angle between major axis and the original x-axis and then re-translated to its prime position. And it worked! Can be seen in figure above. So unlike the previous implementation, where we did not had any tilted ellipses, that issue was solved today. The minimal bounding rectangle needs to be figured out yet.