gEDA-dev: [PATCH] PCB/gtk: Draw rotated arcs correctly

Peter TB Brett peter at peter-b.co.uk
Tue Apr 17 06:32:55 EDT 2007


On Tuesday 17 April 2007 11:29:38 Peter Clifton wrote:
> On Tue, 2007-04-17 at 11:00 +0100, Peter TB Brett wrote:
> > On Tuesday 17 April 2007 10:38:20 Bernd Jendrissek wrote:
> > > diff -up ./src/hid/gtk/gtkhid-main.c.borig ./src/hid/gtk/gtkhid-main.c
> > > --- ./src/hid/gtk/gtkhid-main.c.borig	2007-04-16 17:56:08.000000000
> > > +0200 +++ ./src/hid/gtk/gtkhid-main.c	2007-04-17 11:23:09.000000000
> > > +0200 @@ -649,6 +649,10 @@ ghid_draw_arc (hidGC gc, int cx, int cy,
> > >  		start_angle =-start_angle + 180;;
> > >  		delta_angle = -delta_angle;;
> > >  		}
> > > +  /* Prevent overflow in X11. */
> > > +  if (start_angle + 180 >= 360) {
> > > +    start_angle -= 360;
> > > +  }
> >
> > How about something along these lines:
> >
> >    angle = start_angle + 180 % 360;
> >
> >    gdk_draw_arc (gport->drawable, gport->u_gc, 0,
> >                 DRAW_X (cx) - vrx, DRAW_Y (cy) - vry,
> >                 vrx * 2, vry * 2, angle * 64, delta_angle * 64);
> >
> > This avoids a branch, and requires fewer instructions. OTOH, can
> > start_angle be negative?
>
> Perhaps a better solution (thinking about it) is to make sure the angle
> never over-flows in the first place. Can PCB's internal data-structures
> accommodate any necessary range limitation?
>
> You'd then perform the limit wrapping at each load / modification to the
> data-structure rather than at draw time. This prevents any internal
> overflows too, whilst keeping drawing faster.

This seems like a better way of doing it.  Fixing at draw time is a bit of a 
hack.

Cheers,

Peter


-- 
Fisher Society committee                    http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
CU Spaceflight                              http://tinyurl.com/ognu2

v3sw6YChw7$ln3pr6$ck3ma8u7+Lw3+2m0l7Ci6e4+8t4Gb8en6g6Pa2Xs5Mr4p4
  hackerkey.com                                  peter-b.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.seul.org/pipermail/geda-dev/attachments/20070417/4083851c/attachment.pgp


More information about the geda-dev mailing list