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

Re: gEDA-user: PCB needs alternate grid



> The crosshair snaps to a grid point or pin center whichever is closer, but
> it will snap to a
> grid point or the nearest "defining endpoint" of a pad.  It will not snap to
> a *pad* center.  (I wish it still did :( .)

Here's a patch I made a few months ago to snap the crosshair to the
centre of a pad.  But even this didn't seem to work how I wanted it.

I think we need to have snap points at all the corners and centers
axises, but these would be offset into the pad by some factor, maybe
based on the selected line width and minimum touching copper overlap.

I've attached an image which shows the possible snap points for square
and rounded corner shapes.  An extra weighting along the red lines might
also be useful.

Robert


Index: src/crosshair.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/crosshair.c,v
retrieving revision 1.33
diff -u -r1.33 crosshair.c
--- src/crosshair.c	21 Oct 2007 02:02:16 -0000	1.33
+++ src/crosshair.c	25 Oct 2007 23:01:25 -0000
@@ -832,14 +832,27 @@
     {
       PadTypePtr pad = (PadTypePtr) ptr2;
       LocationType px, py;
+      LocationType cpx, cpy;
+
+      cpx = (pad->Point1.X + pad->Point2.X) / 2;
+      cpy = (pad->Point1.Y + pad->Point2.Y) / 2;
+
       if (SQUARE (pad->Point1.X - Crosshair.X) +
 	  SQUARE (pad->Point1.Y - Crosshair.Y) <
-	  SQUARE (pad->Point2.X - Crosshair.X) + SQUARE (pad->Point2.Y -
+	  SQUARE (cpx - Crosshair.X) + SQUARE (cpy -
 							 Crosshair.Y))
 	{
 	  px = pad->Point1.X;
 	  py = pad->Point1.Y;
 	}
+      else if (SQUARE (cpx - Crosshair.X) +
+	  SQUARE (cpy - Crosshair.Y) <
+	  SQUARE (pad->Point2.X - Crosshair.X) + SQUARE (pad->Point2.Y -
+							 Crosshair.Y))
+	{
+	  px = cpx;
+	  py = cpy;
+	}
       else
 	{
 	  px = pad->Point2.X;

Attachment: snappoints.png
Description: PNG image


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