Search code examples
c++wxwidgets

wxWidgets drawing clockwise elliptical arcs


The docs for wxDC::DrawEllipticArc state:

start and end specify the start and end of the arc relative to the three-o'clock position from the center of the rectangle. Angles are specified in degrees (360 is a complete circle). Positive values mean counter-clockwise motion.

So calling:

wxDC::DrawEllipticArc( ... 90, 270 )

Gives me:

Fair enough, the arc is drawn from 12o'clock to 6o'clock in the counter-clockwise direction.

Now I want to draw from 12o'clock to 6o'clock in the clockwise direction. So I call:

wxDC::DrawEllipticArc( ... -90, -270 )

But I get the same result!

I have tried all sorts of combinations of +/-90 and +/-270 in different orders, but everything produces either the 12o'clock to 6o'clock in the counter-clockwise arc ( usulally ) or a full circle ( sometimes ) I cannot find a combination to produce 'the other half'.

============ Fix ================

In my input data ( a DXF file ) the clockwise direction is indicated by an end angle less than the start angle. So this code does the job

   if( ea < sa ) {
        // required to draw in clockwise direction
        // work arround for wxWidgets bug http://trac.wxwidgets.org/ticket/4437
      ea += 360;
   }
    dc.DrawEllipticArc ( ... sa, ea );

wxWidgets 3.0.0 with gcc / codeblocks / mingw on Windows 7


Solution

  • There is a problem in this function, it's being discussed here and the summary is that it's almost certainly buggy, but we just don't know how exactly to fix it yet. Please add your comments there.

    This being said, I think you might be able to achieve the result that you need by drawing an arc from 270 to 450...