[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-111-g9784a91)



The branch, master has been updated
       via  9784a9117e42632527601faef9a3ed937b718208 (commit)
      from  88c2a580ef65de000a3e797301fd8b4f302fc2ff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/o_circle.c |   67 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 45 insertions(+), 22 deletions(-)


=================
 Commit Messages
=================

commit 9784a9117e42632527601faef9a3ed937b718208
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 03:51:22 2009 +0000

    gschem: Ensure circles are well hinted to the grid
    
    gschem's canvas can have a fractionally different X and Y scale factor
    in some cases, which can cause misalignment of circles with other
    objects. Since logic bubbles are often placed to touch the boxes of
    components, ensuring they align well is important.
    
    The code used here is similar to that added for arcs in
    commit 508ab0fd9a1e4317ee660bc9eba79fcb49329841

:100644 100644 7473192... e8e0786... M	gschem/src/o_circle.c

=========
 Changes
=========

commit 9784a9117e42632527601faef9a3ed937b718208
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Fri Jan 2 03:51:22 2009 +0000

    gschem: Ensure circles are well hinted to the grid
    
    gschem's canvas can have a fractionally different X and Y scale factor
    in some cases, which can cause misalignment of circles with other
    objects. Since logic bubbles are often placed to touch the boxes of
    components, ensuring they align well is important.
    
    The code used here is similar to that added for arcs in
    commit 508ab0fd9a1e4317ee660bc9eba79fcb49329841

diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index 7473192..e8e0786 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -49,8 +49,9 @@ typedef void (*FILL_FUNC)( GdkDrawable *w, GdkGC *gc, COLOR *color,
 void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int s_x, s_y;
-  int radius;
+  int sx1, sy1, sx2, sy2;
+  double cx, cy;
+  double radius;
   int line_width, length, space;
   int fill_width, angle1, pitch1, angle2, pitch2;
   COLOR *color;
@@ -79,8 +80,6 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
     color = x_color_lookup (o_current->color);
   }
 
-  radius = SCREENabs( toplevel, o_current->circle->radius );
-
   /*
    * The values describing the line type are extracted from the
    * <B>o_current</B> pointed structure. These are the width of the line, the
@@ -105,9 +104,6 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   length = SCREENabs( toplevel, o_current->line_length );
   space = SCREENabs( toplevel, o_current->line_space );
 
-  WORLDtoSCREEN( toplevel, o_current->circle->center_x, o_current->circle->center_y,
-                 &s_x, &s_y );
-
   /*
    * The values needed for the fill operation are taken from the
    * <B>o_current</B> pointed OBJECT. It include the type of fill required, the
@@ -183,20 +179,33 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
                 color, w_current, o_current->circle,
                 fill_width, angle1, pitch1, angle2, pitch2);
 
-  gschem_cairo_set_source_color (w_current->cr, color);
-  cairo_new_sub_path (w_current->cr);
-  cairo_arc (w_current->cr, s_x + 0.5, s_y + 0.5, radius, 0., 2 * M_PI);
+  WORLDtoSCREEN (toplevel, o_current->circle->center_x - o_current->circle->radius,
+                           o_current->circle->center_y + o_current->circle->radius,
+                           &sx1, &sy1);
+  WORLDtoSCREEN (toplevel, o_current->circle->center_x + o_current->circle->radius,
+                           o_current->circle->center_y - o_current->circle->radius,
+                           &sx2, &sy2);
+
+  cx = (double)(sx1 + sx2) / 2.;
+  cy = (double)(sy1 + sy2) / 2.;
+  radius = (double)(sy2 - sy1) / 2.;
+
+  cairo_translate (w_current->cr, cx, cy);
+
+  /* Adjust for non-uniform X/Y scale factor. Note that the + 1
+     allows for the case where sx2 == sx1 or sy2 == sy1 */
+  cairo_scale (w_current->cr, (double)(sx2 - sx1 + 1) /
+                              (double)(sy2 - sy1 + 1), 1.);
+
+  gschem_cairo_arc (w_current->cr, line_width, 0., 0., radius, 0., 360);
+  cairo_identity_matrix (w_current->cr);
 
+  gschem_cairo_set_source_color (w_current->cr, color);
   if (o_current->fill_type == FILLING_FILL)
     cairo_fill_preserve (w_current->cr);
-
   gschem_cairo_stroke (w_current->cr, o_current->line_type,
                        o_current->line_end, line_width, length, space);
 
-#if DEBUG
-  printf("drawing circle\n");
-#endif
-
   if (o_current->selected && w_current->draw_grips) {
     o_circle_draw_grips (w_current, o_current);
   }
@@ -407,7 +416,9 @@ void o_circle_invalidate_rubber (GSCHEM_TOPLEVEL *w_current)
 void o_circle_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int x, y, radius;
+  int sx1, sy1, sx2, sy2;
+  double cx, cy;
+  double radius;
   int color;
 
   if (o_current->circle == NULL) {
@@ -420,14 +431,26 @@ void o_circle_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_
     color = o_current->color;
   }
 
-  /* radius of the circle */
-  radius = SCREENabs( toplevel, o_current->circle->radius );
+  WORLDtoSCREEN (toplevel, o_current->circle->center_x + dx - o_current->circle->radius,
+                           o_current->circle->center_y + dy + o_current->circle->radius,
+                           &sx1, &sy1);
+  WORLDtoSCREEN (toplevel, o_current->circle->center_x + dx + o_current->circle->radius,
+                           o_current->circle->center_y + dy - o_current->circle->radius,
+                           &sx2, &sy2);
+
+  cx = (double)(sx1 + sx2) / 2.;
+  cy = (double)(sy1 + sy2) / 2.;
+  radius = (double)(sy2 - sy1) / 2.;
+
+  cairo_translate (w_current->cr, cx, cy);
 
-  WORLDtoSCREEN (toplevel, o_current->circle->center_x + dx,
-                           o_current->circle->center_y + dy, &x, &y);
+  /* Adjust for non-uniform X/Y scale factor. Note that the + 1
+     allows for the case where sx2 == sx1 or sy2 == sy1 */
+  cairo_scale (w_current->cr, (double)(sx2 - sx1 + 1) /
+                              (double)(sy2 - sy1 + 1), 1.);
 
-  cairo_new_sub_path (w_current->cr);
-  cairo_arc (w_current->cr, x + 0.5, y + 0.5, radius, 0., 2 * M_PI);
+  gschem_cairo_arc (w_current->cr, 1, 0., 0., radius, 0., 360);
+  cairo_identity_matrix (w_current->cr);
 
   gschem_cairo_set_source_color (w_current->cr, x_color_lookup_dark (color));
   gschem_cairo_stroke (w_current->cr, TYPE_SOLID, END_NONE, 1, -1, -1);




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs