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

Re: gEDA-user: PCB realign grid sucks



I have asked the same question. Being able to realign to the center of
the pad is very helpful when creating or verifying footprints.

Here is what I change to add the feature:
Index: gui-top-window.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/gui-top-window.c,v
retrieving revision 1.7
diff -r1.7 gui-top-window.c
359c359
<       if (ActionGetLocation(_("Press a button at a grid point")))
---
>       if (ActionGetLocation(_("Press left button at a grid point or right button to snap to center of pin")))

Index: action.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/action.c,v
retrieving revision 1.58
diff -r1.58 action.c
459a460,499
> static void
> SnapToPin(LocationType *x, LocationType *y)
> {
>   int ans;
>   void *ptr1, *ptr2, *ptr3;
>
>   ans = SearchScreen (*x, *y, PAD_TYPE | PIN_TYPE, &ptr1, &ptr2, &ptr3);
>   if (ans == NO_TYPE)
>     ans = SearchScreen (*x, *y, VIA_TYPE | LINEPOINT_TYPE, &ptr1, &ptr2, &ptr3);
>   if (ans == NO_TYPE)
>     ans = SearchScreen (*x, *y, ELEMENT_TYPE, &ptr1, &ptr2, &ptr3);
>   if (ans == NO_TYPE)
>     return;
>
>   if (ans & PAD_TYPE)
>   {
>     PadTypePtr pad = (PadTypePtr) ptr2;
>     *x = (pad->Point1.X + pad->Point2.X) / 2;
>     *y = (pad->Point1.Y + pad->Point2.Y) / 2;
>   }
>   else if (ans & (PIN_TYPE | VIA_TYPE))
>   {
>     PinTypePtr pin = (PinTypePtr) ptr2;
>     *x = pin->X;
>     *y = pin->Y;
>   }
>   else if (ans & LINEPOINT_TYPE)
>   {
>     PointTypePtr pnt = (PointTypePtr) ptr3;
>     *x = pnt->X;
>     *y = pnt->Y;
>   }
>   else if (ans & ELEMENT_TYPE)
>   {
>     ElementTypePtr el = (ElementTypePtr) ptr1;
>     *x = el->MarkX;
>     *y = el->MarkY;
>   }
> }
>
2341a2382
>         GdkModifierType mask;
2342a2384
>         LocationType X, Y;
2345c2387,2392
<           gui_get_pointer(&childX, &childY);
---
>           gdk_window_get_pointer (Output.drawing_area->window,
>                       &childX, &childY, &mask);
>         X = TO_PCB_X(childX);
>         Y = TO_PCB_Y(childY);
>         if (mask & GDK_BUTTON3_MASK)
>             SnapToPin(&X, &Y);
2348c2395
<           if (MoveCrosshairAbsolute (TO_PCB_X (childX), TO_PCB_Y (childY)))
---
>           if (MoveCrosshairAbsolute (X, Y))


The above are the cvs diff output against the lastest cvs code from sourceforge.