gEDA-dev: Checking for mm vs. mil display modes in PCB
Michael Stovenour
mstovenour at yahoo.com
Mon Dec 10 17:50:41 EST 2007
Is there a better way than this to check for mm vs. mil modes? I'm working on a quick patch to allow decrementing the grid all the way down to 1 (effectively off). I have it working, see the bottom code, except that, when the grid bottoms out at 1; the funky check for mm vs. mil modes prevents mm mode from incrementing up from 1.
ORIGINAL: src/action.c
...
case F_Grid:
if (!r)
{
if ((value == (int) value && PCB->Grid == (int) PCB->Grid)
|| (value != (int) value && PCB->Grid != (int) PCB->Grid))
SetGrid (value + PCB->Grid, False);
else
Message (_
("Don't combine metric/English grids like that!\n"));
}
This code mostly works. It fixes a nasty "feature" that I found by mistake where I set the grid to 1 with :SetValue(Grid,1) (effectively off) so that I could make some measurements. I then I incremented the grid +5 mil with <key>G. The status window indicated 5.0 mil snap, but the coordinate window indicated that the mouse was moving 5.01 mm. If I can just solve the "how to tell I'm in mm display mode" problem this is a good fix. BTW, this patch works at least as well as the original code since it only requires the user to explicitly pick a grid size from the menu or set it with SetValue. At least it doesn't allow the grid increment to a slightly wrong grid spacing. Any it only misbehaves this way for mm; mil works great.
NEW: src/action.c
...
case F_Grid:
if (!r)
{
if ((value == (int) value && PCB->Grid == (int) PCB->Grid)
|| (value != (int) value && PCB->Grid != (int) PCB->Grid))
{
//On the way down short against the minimum PCB drawing unit
if ((value + PCB->Grid) < 1)
SetGrid (1, False);
else if (PCB->Grid == 1)
SetGrid ( value, False);
else
SetGrid (value + PCB->Grid, False);
}
else
Message (_
("Don't combine metric/English grids like that!\n"));
}
else
SetGrid (value, False);
break;
More information about the geda-dev
mailing list