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

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-347-g54d2fd7)



The branch, master has been updated
       via  54d2fd7dc6bf09dad1d9657c5cd3635bb31e14b7 (commit)
       via  3b8bbb1f0e4f549ad2e366e36365e59f7657622e (commit)
       via  d089b532b3b5ca2b5e155a23994ed35fb85ec4a5 (commit)
      from  d3a0d4da489f9cd213472e58d18f21774760984b (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/include/prototype.h       |   16 ++--
 gschem/src/o_box.c               |  210 ++++++++++----------------------------
 gschem/src/o_circle.c            |  133 +++++++++---------------
 libgeda/include/prototype.h      |    2 +
 libgeda/include/prototype_priv.h |    2 -
 5 files changed, 114 insertions(+), 249 deletions(-)


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

commit 54d2fd7dc6bf09dad1d9657c5cd3635bb31e14b7
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 8 18:57:11 2008 +0000

    gschem: Use libgeda's hatching routines for drawing hatched boxes.

:100644 100644 91303b1... d338a7a... M	gschem/include/prototype.h
:100644 100644 c72933b... f046b8e... M	gschem/src/o_box.c

commit 3b8bbb1f0e4f549ad2e366e36365e59f7657622e
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 8 18:43:56 2008 +0000

    gschem: Use libgeda's hatching routines for drawing hatched circles.

:100644 100644 f0313e6... 91303b1... M	gschem/include/prototype.h
:100644 100644 38f50c2... 991dfe6... M	gschem/src/o_circle.c

commit d089b532b3b5ca2b5e155a23994ed35fb85ec4a5
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 8 18:42:41 2008 +0000

    libgeda: Make box and circle hatching functions public
    
    Allows them to be used in the GUI for hatching these objects.

:100644 100644 0fb7a08... 68fb9c4... M	libgeda/include/prototype.h
:100644 100644 c123c2d... 3a9afca... M	libgeda/include/prototype_priv.h

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

commit 54d2fd7dc6bf09dad1d9657c5cd3635bb31e14b7
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 8 18:57:11 2008 +0000

    gschem: Use libgeda's hatching routines for drawing hatched boxes.

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 91303b1..d338a7a 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -507,10 +507,10 @@ void o_box_draw_dotted(GdkDrawable *w, GdkGC *gc, GdkColor *color, GdkCapStyle c
 void o_box_draw_dashed(GdkDrawable *w, GdkGC *gc, GdkColor *color, GdkCapStyle cap, gint filled, gint x, gint y, gint width, gint height, gint line_width, gint length, gint space);
 void o_box_draw_center(GdkDrawable *w, GdkGC *gc, GdkColor *color, GdkCapStyle cap, gint filled, gint x, gint y, gint width, gint height, gint line_width, gint length, gint space);
 void o_box_draw_phantom(GdkDrawable *w, GdkGC *gc, GdkColor *color, GdkCapStyle cap, gint filled, gint x, gint y, gint width, gint height, gint line_width, gint length, gint space);
-void o_box_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint width, gint height, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
-void o_box_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint width, gint height, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
-void o_box_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint width, gint height, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
-void o_box_fill_mesh(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint width, gint height, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_box_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, BOX *box, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_box_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, BOX *box, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_box_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, BOX *box, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_box_fill_mesh(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, BOX *box, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
 void o_box_eraserubber(GSCHEM_TOPLEVEL *w_current);
 void o_box_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current);
 void o_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y);
diff --git a/gschem/src/o_box.c b/gschem/src/o_box.c
index c72933b..f046b8e 100644
--- a/gschem/src/o_box.c
+++ b/gschem/src/o_box.c
@@ -42,7 +42,7 @@ typedef void (*DRAW_FUNC)( GdkDrawable *w, GdkGC *gc, GdkColor *color,
                            gint line_width, gint length, gint space );
 
 typedef void (*FILL_FUNC)( GdkDrawable *w, GdkGC *gc, GdkColor *color,
-                           gint x, gint y, gint width, gint height,
+                           GSCHEM_TOPLEVEL *w_current, BOX *box,
                            gint fill_width, gint angle1, gint pitch1,
                            gint angle2, gint pitch2 );
 
@@ -222,9 +222,9 @@ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   }
 	
   angle1 = o_current->fill_angle1;
-  pitch1 = SCREENabs( toplevel, o_current->fill_pitch1 );
+  pitch1 = o_current->fill_pitch1;
   angle2 = o_current->fill_angle2;
-  pitch2 = SCREENabs( toplevel, o_current->fill_pitch2 );
+  pitch2 = o_current->fill_pitch2;
 	
   switch(o_current->fill_type) {
     case FILLING_HOLLOW:
@@ -267,9 +267,7 @@ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   }
 
   (*fill_func)(w_current->backingstore, w_current->gc, color,
-               s_upper_x, s_upper_y,
-               abs(s_lower_x - s_upper_x),
-               abs(s_lower_y - s_upper_y),
+               w_current, o_current->box,
                fill_width, angle1, pitch1, angle2, pitch2);
 
   if ((o_current->draw_grips == TRUE) && (w_current->draw_grips == TRUE)) {
@@ -543,14 +541,12 @@ void o_box_draw_phantom(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      2nd angle for pattern.
  *  \param [in] pitch2      2nd pitch for pattern.
  */
-void o_box_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-		       gint x, gint y,
-		       gint width, gint height,
-		       gint fill_width,
-		       gint angle1, gint pitch1,
-		       gint angle2, gint pitch2)
+void o_box_fill_hollow (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                        GSCHEM_TOPLEVEL *w_current, BOX *box,
+                        gint fill_width,
+                        gint angle1, gint pitch1,
+                        gint angle2, gint pitch2)
 {
-  
 }
 
 /*! \brief Fill inside of box with a solid pattern.
@@ -582,18 +578,25 @@ void o_box_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      (unused)
  *  \param [in] pitch2      (unused)
  */
-void o_box_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-		     gint x, gint y,
-		     gint width, gint height,
-		     gint fill_width,
-		     gint angle1, gint pitch1, gint angle2, gint pitch2)
+void o_box_fill_fill (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                      GSCHEM_TOPLEVEL *w_current, BOX *box,
+                      gint fill_width,
+                      gint angle1, gint pitch1,
+                      gint angle2, gint pitch2)
 {
-  gdk_gc_set_foreground(gc, color);
-  gdk_gc_set_line_attributes(gc, 1, GDK_LINE_SOLID,
-                             GDK_CAP_BUTT, GDK_JOIN_MITER);
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int s_lower_x, s_lower_y;
+  int s_upper_x, s_upper_y;
 
-  gdk_draw_rectangle(w, gc, TRUE, x, y, width, height);
-	
+  WORLDtoSCREEN (toplevel, box->lower_x, box->lower_y, &s_lower_x, &s_lower_y);
+  WORLDtoSCREEN (toplevel, box->upper_x, box->upper_y, &s_upper_x, &s_upper_y);
+
+  gdk_gc_set_foreground (gc, color);
+  gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID,
+                              GDK_CAP_BUTT, GDK_JOIN_MITER);
+
+  gdk_draw_rectangle (w, gc, TRUE, s_upper_x, s_upper_y,
+                      s_lower_x - s_upper_x, s_lower_y - s_upper_y);
 }
 
 /*! \brief Fill inside of box with single line pattern.
@@ -626,136 +629,32 @@ void o_box_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      (unused)
  *  \param [in] pitch2      (unused)
  */
-void o_box_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-		      gint x, gint y,
-		      gint width, gint height,
-		      gint fill_width,
-		      gint angle1, gint pitch1, gint angle2, gint pitch2)
+void o_box_fill_hatch (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                       GSCHEM_TOPLEVEL *w_current, BOX *box,
+                       gint fill_width,
+                       gint angle1, gint pitch1,
+                       gint angle2, gint pitch2)
 {
-  int x3, y3, x4, y4;
-  double cos_a_, sin_a_;
-  double x0, y0, r;
-  double x1, y1, x2, y2;
-  double amin, amax, a[4], min1, min2, max1, max2;
+  int i;
+  GArray *lines;
 
-  gdk_gc_set_line_attributes(gc, fill_width, GDK_LINE_SOLID,
-                             GDK_CAP_BUTT, GDK_JOIN_MITER);
+  lines = g_array_new (FALSE, FALSE, sizeof (LINE));
 
-  /*
-   * The function uses a matrix. Its elements are obtained from the sinus
-   * and the cosinus of the angle <B>angle1</B>. It represents the rotation
-   * matrix that when applied to a point, rotate it of <B>angle1</B>.
-   */
-  cos_a_ = cos(((double) angle1) * M_PI/180);
-  sin_a_ = sin(((double) angle1) * M_PI/180);
+  m_hatch_box (box, angle1, pitch1, lines);
 
-  /*
-   * The function considers the smallest circle around the box. Its radius
-   * is given by the following relation. Its center is given by the point
-   * a the middle of the box horizontally and vertically (intersection of
-   * its two diagonals.
-   */
-  r = sqrt((double) (pow(width, 2) + pow(height, 2))) / 2;
+  for (i=0; i < lines->len; i++) {
+    int x1, y1, x2, y2;
+    LINE *line = &g_array_index (lines, LINE, i);
 
-  /*
-   * When drawing a line in a circle there is two intersections. With the
-   * previously described circle, these intersections are out of the box.
-   * They can be easily calculated, the first by resolution of an equation
-   * and the second one by symetry in relation to the vertical axis going
-   * through the center of the circle.
-   *
-   * These two points are then rotated of angle <B>angle1</B> using the matrix
-   * previously mentionned.
-   */
-  y0 = 0;
-  while(y0 < r) {
-    x0 = pow(r, 2) - pow(y0, 2);
-    x0 = sqrt(x0);
-    
-    x1 = (x0*cos_a_ - y0*sin_a_);
-    y1 = (x0*sin_a_ + y0*cos_a_);
-    x2 = ((-x0)*cos_a_ - y0*sin_a_);
-    y2 = ((-x0)*sin_a_ + y0*cos_a_);
-    
-    /*
-     * It now parametrizes the segment : first intersection is given
-     * the value of 0 and the second is given the value of 1. The four
-     * values for each intersection of the segment and the four
-     * sides (vertical or horizontal) of the box are given by the
-     * following relations :
-     */
-    if((int) (x2 - x1) != 0) {
-      a[0] = ((-width/2) - x1) / (x2 - x1);
-      a[1] = ((width/2)  - x1) / (x2 - x1);
-    } else {
-      a[0] = 0; a[1] = 1;
-    }
-    
-    if((int) (y2 - y1) != 0) {
-      a[2] = ((-height/2) - y1) / (y2 - y1);
-      a[3] = ((height/2)  - y1) / (y2 - y1);
-    } else {
-      a[2] = 0; a[3] = 1;
-    }
-    /*
-     * It now has to check which of these four values are for
-     * intersections with the sides of the box (some values may be
-     * for intersections out of the box). This is made by a min/max
-     * function.
-     */
-    if(a[0] < a[1]) {
-      min1 = a[0]; max1 = a[1];
-    } else {
-      min1 = a[1]; max1 = a[0];
-    }
-    
-    if(a[2] < a[3]) {
-      min2 = a[2]; max2 = a[3];
-    } else {
-      min2 = a[3]; max2 = a[2];
-    }
-    
-    amin = (min1 < min2) ? min2 : min1;
-    amin = (amin < 0) ? 0 : amin;
-    
-    amax = (max1 < max2) ? max1 : max2;
-    amax = (amax < 1) ? amax : 1;
-    
-    /*
-     * If the segment really go through the box it draws the line.
-     * It also take the opportunity of the symetry in the box in
-     * relation to its center to draw the second line at the same time.
-     *
-     * If there is no intersection of the segment with any of the sides,
-     * then there is no need to continue : there would be no more
-     * segment in the box to draw.
-     */
-    
-    if((amax > amin) && (amax != 1) && (amin != 0)) {
-      /* There is intersection between the line and the box edges */
-      x3 = (int) (x1 + amin*(x2 - x1));
-      y3 = (int) (y1 + amin*(y2 - y1));
-      
-      x4 = (int) (x1 + amax*(x2 - x1));
-      y4 = (int) (y1 + amax*(y2 - y1));
-      
-      gdk_draw_line(w, gc, x3 + (x + width/2),
-		    (y + height/2) - y3, x4 + (x + width/2),
-		    (y + height/2) - y4);
-      
-      gdk_draw_line(w, gc, -x3 + (x + width/2),
-		    +y3 + (y + height/2), -x4 + (x + width/2),
-		    +y4 + (y + height/2));
-      
-    } else {
-      break;
-    }
-    
-    y0 = y0 + pitch1;
-    
+    WORLDtoSCREEN (w_current->toplevel, line->x[0], line->y[0], &x1, &y1);
+    WORLDtoSCREEN (w_current->toplevel, line->x[1], line->y[1], &x2, &y2);
+    o_line_draw_solid (w, gc, color, GDK_CAP_BUTT,
+                       x1, y1, x2, y2, fill_width, -1, -1);
   }
+
+  g_array_free (lines, TRUE);
 }
-  
+
 /*! \brief Fill inside of box with mesh pattern.
  *  \par Function Description
  *  This function fills the inside of the box with a pattern made of two
@@ -783,17 +682,16 @@ void o_box_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      2nd angle for pattern.
  *  \param [in] pitch2      2nd pitch for pattern.
  */
-void o_box_fill_mesh(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-		     gint x, gint y,
-		     gint width, gint height,
-		     gint fill_width,
-		     gint angle1, gint pitch1,
-		     gint angle2, gint pitch2)
+void o_box_fill_mesh (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                      GSCHEM_TOPLEVEL *w_current, BOX *box,
+                      gint fill_width,
+                      gint angle1, gint pitch1,
+                      gint angle2, gint pitch2)
 {
-  o_box_fill_hatch(w, gc, color, x, y, width, height,
-		   fill_width, angle1, pitch1, -1, -1);
-  o_box_fill_hatch(w, gc, color, x, y, width, height,
-	  	   fill_width, angle2, pitch2, -1, -1);
+  o_box_fill_hatch (w, gc, color, w_current, box,
+                    fill_width, angle1, pitch1, -1, -1);
+  o_box_fill_hatch (w, gc, color, w_current, box,
+                    fill_width, angle2, pitch2, -1, -1);
 }
 
 

commit 3b8bbb1f0e4f549ad2e366e36365e59f7657622e
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 8 18:43:56 2008 +0000

    gschem: Use libgeda's hatching routines for drawing hatched circles.

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index f0313e6..91303b1 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -536,10 +536,10 @@ void o_bus_rubberbus_xor(GSCHEM_TOPLEVEL *w_current);
 void o_bus_eraserubber(GSCHEM_TOPLEVEL *w_current);
 /* o_circle.c */
 void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current);
-void o_circle_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint radius, gint width, gint angle1, gint pitch1, gint angle2, gint pitch2);
-void o_circle_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint radius, gint width, gint angle1, gint pitch1, gint angle2, gint pitch2);
-void o_circle_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint radius, gint width, gint angle1, gint pitch1, gint angle2, gint pitch2);
-void o_circle_fill_mesh(GdkDrawable *w, GdkGC *gc, GdkColor *color, gint x, gint y, gint radius, gint width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_circle_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, CIRCLE *circle, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_circle_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, CIRCLE *circle, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_circle_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, CIRCLE *circle, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
+void o_circle_fill_mesh(GdkDrawable *w, GdkGC *gc, GdkColor *color, GSCHEM_TOPLEVEL *w_current, CIRCLE *circle, gint fill_width, gint angle1, gint pitch1, gint angle2, gint pitch2);
 void o_circle_eraserubber(GSCHEM_TOPLEVEL *w_current);
 void o_circle_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current);
 void o_circle_start(GSCHEM_TOPLEVEL *w_current, int x, int y);
diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index 38f50c2..991dfe6 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -34,7 +34,7 @@ typedef void (*DRAW_FUNC)( GdkDrawable *w, GdkGC *gc, GdkColor *color,
                            gint arc_width, gint length, gint space );
 
 typedef void (*FILL_FUNC)( GdkDrawable *w, GdkGC *gc, GdkColor *color,
-                           gint x, gint y, gint radius,
+                           GSCHEM_TOPLEVEL *w_current, CIRCLE *circle,
                            gint fill_width, gint angle1, gint pitch1,
                            gint angle2, gint pitch2 );
 
@@ -207,9 +207,9 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   }
 	
   angle1 = o_current->fill_angle1;
-  pitch1 = SCREENabs( toplevel, o_current->fill_pitch1 );
+  pitch1 = o_current->fill_pitch1;
   angle2 = o_current->fill_angle2;
-  pitch2 = SCREENabs( toplevel, o_current->fill_pitch2 );
+  pitch2 = o_current->fill_pitch2;
 	
   switch(o_current->fill_type) {
     case FILLING_HOLLOW:
@@ -252,8 +252,7 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   }
 
   (*fill_func)(w_current->backingstore, w_current->gc, color,
-               s_x, s_y,
-               radius,
+               w_current, o_current->circle,
                fill_width, angle1, pitch1, angle2, pitch2);
 
 #if DEBUG
@@ -293,12 +292,12 @@ void o_circle_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
  *  \param [in] angle2      2nd angle for pattern.
  *  \param [in] pitch2      2nd pitch for pattern.
  */
-void o_circle_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-			  gint x, gint y, gint radius,
-			  gint width,
-			  gint angle1, gint pitch1, gint angle2, gint pitch2)
+void o_circle_fill_hollow (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                           GSCHEM_TOPLEVEL *w_current, CIRCLE *circle,
+                           gint fill_width,
+                           gint angle1, gint pitch1,
+                           gint angle2, gint pitch2)
 {
-  
 }
 
 /*! \brief Fill inside of circle with a solid pattern.
@@ -331,18 +330,25 @@ void o_circle_fill_hollow(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      (unused)
  *  \param [in] pitch2      (unused)
  */
-void o_circle_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-			gint x, gint y, gint radius,
-			gint width,
-			gint angle1, gint pitch1, gint angle2, gint pitch2)
+void o_circle_fill_fill (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                         GSCHEM_TOPLEVEL *w_current, CIRCLE *circle,
+                         gint fill_width,
+                         gint angle1, gint pitch1,
+                         gint angle2, gint pitch2)
 {
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int s_x, s_y;
+  int radius;
+
   gdk_gc_set_foreground(gc, color);
   gdk_gc_set_line_attributes(gc, 1, GDK_LINE_SOLID,
                              GDK_CAP_BUTT, GDK_JOIN_MITER);
 
-  gdk_draw_arc(w, gc,
-               TRUE, x-radius, y-radius, 2*radius, 2*radius, 0, FULL_CIRCLE);
+  WORLDtoSCREEN (toplevel, circle->center_x, circle->center_y, &s_x, &s_y);
+  radius = SCREENabs (toplevel, circle->radius);
 
+  gdk_draw_arc (w, gc, TRUE, s_x - radius, s_y - radius,
+                2 * radius, 2 * radius, 0, FULL_CIRCLE);
 }
 
 /*! \brief Fill inside of circle with single line pattern.
@@ -378,68 +384,30 @@ void o_circle_fill_fill(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      (unused)
  *  \param [in] pitch2      (unused)
  */
-void o_circle_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-			 gint x, gint y, gint radius,
-			 gint width,
-			 gint angle1, gint pitch1, gint angle2, gint pitch2)
+void o_circle_fill_hatch (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                          GSCHEM_TOPLEVEL *w_current, CIRCLE *circle,
+                          gint fill_width,
+                          gint angle1, gint pitch1,
+                          gint angle2, gint pitch2)
 {
-  double x0, y0, x1, y1, x2, y2;
-  double cos_a_, sin_a_;
+  int i;
+  GArray *lines;
 
-  gdk_gc_set_line_attributes(gc, width, GDK_LINE_SOLID,
-                             GDK_CAP_BUTT, GDK_JOIN_MITER);
+  lines = g_array_new (FALSE, FALSE, sizeof (LINE));
 
-  /*
-   * The function use a matrix. Its elements are obtained from the sinus and
-   * cosinus of the angle <B>angle1</B>. It represent the rotation matrix that
-   * when applied to a point, rotate it of <B>angle1</B>.
-   */
-  cos_a_ = cos(((double) angle1) * M_PI/180);
-  sin_a_ = sin(((double) angle1) * M_PI/180);
+  m_hatch_circle (circle, angle1, pitch1, lines);
 
-  /*
-   * When drawing a line in a circle there is two intersections. It looks for
-   * the coordinates of one of these points when the line is horizontal.
-   * The second one can be easily obtained by symmetry in relation to the
-   * vertical axis going through the centre of the circle.
-   *
-   * These two points are then rotated of angle <B>angle1</B> using the
-   * elements of the rotation matrix previously computed.
-   *
-   * The corresponding line can be drawn providing that the coordinates
-   * are rounded.
-   *
-   * These operations are repeated for every horizontal line that can fit
-   * in the upper half of the circle (using and incrementing the variable
-   * <B>y0</B>).
-   */
-  y0 = 0;
-  while(y0 < (double) radius) {
-    x0 = pow((double) radius, 2) - pow(y0, 2);
-    x0 = sqrt(x0);
-
-    x1 = (x0*cos_a_ - y0*sin_a_) + x;
-    y1 = y - (x0*sin_a_ + y0*cos_a_);
-    x2 = ((-x0)*cos_a_ - y0*sin_a_) + x;
-    y2 = y - ((-x0)*sin_a_ + y0*cos_a_);
-		
-    gdk_draw_line(w, gc,
-                  (int) x1, (int) y1, (int) x2, (int) y2);
-        
-    /*
-     * The function use the symetry in relation to the centre of the circle.
-     * It avoid repetitive computation for the second half of the surface
-     * of the circle.
-     */
-    x1 = (x0*cos_a_ - (-y0)*sin_a_) + x;
-    y1 = y- (x0*sin_a_ + (-y0)*cos_a_);
-    x2 = ((-x0)*cos_a_ - (-y0)*sin_a_) + x;
-    y2 = y- ((-x0)*sin_a_ + (-y0)*cos_a_);
-    
-    gdk_draw_line(w, gc, (int) x1, (int) y1, (int) x2, (int) y2);
-    
-    y0 = y0 + pitch1;
+  for (i=0; i < lines->len; i++) {
+    int x1, y1, x2, y2;
+    LINE *line = &g_array_index (lines, LINE, i);
+
+    WORLDtoSCREEN (w_current->toplevel, line->x[0], line->y[0], &x1, &y1);
+    WORLDtoSCREEN (w_current->toplevel, line->x[1], line->y[1], &x2, &y2);
+    o_line_draw_solid (w, gc, color, GDK_CAP_BUTT,
+                       x1, y1, x2, y2, fill_width, -1, -1);
   }
+
+  g_array_free (lines, TRUE);
 }
 
 /*! \brief Fill inside of circle with mesh pattern.
@@ -472,17 +440,16 @@ void o_circle_fill_hatch(GdkDrawable *w, GdkGC *gc, GdkColor *color,
  *  \param [in] angle2      2nd angle for pattern.
  *  \param [in] pitch2      2nd pitch for pattern.
  */
-void o_circle_fill_mesh(GdkDrawable *w, GdkGC *gc, GdkColor *color,
-			gint x, gint y, gint radius,
-			gint width,
-			gint angle1, gint pitch1, gint angle2, gint pitch2)
+void o_circle_fill_mesh (GdkDrawable *w, GdkGC *gc, GdkColor *color,
+                         GSCHEM_TOPLEVEL *w_current, CIRCLE *circle,
+                         gint fill_width,
+                         gint angle1, gint pitch1,
+                         gint angle2, gint pitch2)
 {
-  o_circle_fill_hatch(w, gc, color,
-                      x, y, radius,
-                      width, angle1, pitch1, -1, -1);
-  o_circle_fill_hatch(w, gc, color,
-                      x, y, radius,
-                      width, angle2, pitch2, -1, -1);
+  o_circle_fill_hatch (w, gc, color, w_current, circle,
+                       fill_width, angle1, pitch1, -1, -1);
+  o_circle_fill_hatch (w, gc, color, w_current, circle,
+                       fill_width, angle2, pitch2, -1, -1);
 	
 }
 

commit d089b532b3b5ca2b5e155a23994ed35fb85ec4a5
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Dec 8 18:42:41 2008 +0000

    libgeda: Make box and circle hatching functions public
    
    Allows them to be used in the GUI for hatching these objects.

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 0fb7a08..68fb9c4 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -89,6 +89,8 @@ void PAPERSIZEtoWORLD(int width, int height, int border, int *right, int *bottom
 double round_5_2_1(double unrounded);
 
 /* m_hatch.c */
+void m_hatch_box(BOX *box, gint angle, gint pitch, GArray *lines);
+void m_hatch_circle(CIRCLE *circle, gint angle, gint pitch, GArray *lines);
 void m_hatch_path(PATH *path, gint angle, gint pitch, GArray *lines);
 
 /* m_polygon.c */
diff --git a/libgeda/include/prototype_priv.h b/libgeda/include/prototype_priv.h
index c123c2d..3a9afca 100644
--- a/libgeda/include/prototype_priv.h
+++ b/libgeda/include/prototype_priv.h
@@ -56,8 +56,6 @@ void m_bounds_init(BOUNDS *bounds);
 void m_bounds_of_points(BOUNDS *bounds, sPOINT points[], gint count);
 
 /* m_hatch.c */
-void m_hatch_box(BOX *box, gint angle, gint pitch, GArray *lines);
-void m_hatch_circle(CIRCLE *circle, gint angle, gint pitch, GArray *lines);
 void m_hatch_polygon(GArray *points, gint angle, gint pitch, GArray *lines);
 
 /* m_polygon.c */




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