On Wed, 2011-08-31 at 14:00 +0200, Kovacs Levente wrote:
> On Tue, 30 Aug 2011 12:01:00 -0700
> Andrew Poelstra <asp11@xxxxxx> wrote:
>
> > Fixed in git head.
>
> Thanks! Maybe I can see why the "automatic layer (group) change" doesn't work.
> Can you give me any clue where it is located in the code?
src/hid/gtkhid-main.c, SwapSides (...)
Approx line 1408:
if ((active_group == comp_group && comp_on && !solder_on) ||
(active_group == solder_group && solder_on && !comp_on))
{
bool new_comp_vis = Settings.ShowSolderSide && active_group == comp_group;
ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0],
new_comp_vis, new_comp_vis);
ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0],
!new_comp_vis, !new_comp_vis);
}
The failure is probably in picking the correct groups..
at the top of that function:
int active_group = GetLayerGroupNumberByNumber (LayerStack[0]); <-- Probably ok
int comp_group = GetLayerGroupNumberByNumber (component_silk_layer); <-- Probably ok
int solder_group = GetLayerGroupNumberByNumber (solder_silk_layer); <-- Probably ok
bool comp_on = LAYER_PTR (PCB->LayerGroups.Entries[comp_group][0])->On; <-- PROBABLY BAD
bool solder_on = LAYER_PTR (PCB->LayerGroups.Entries[solder_group][0])->On; <-- PROBABLY BAD
IIRC, there is no guarantee that the 0'th index in the group is the one
we should be testing here. The (PCB+GL) rendering code tests group
on/off-ness like this:
int idx = group; /* idx is a group number here */
if (idx >= 0 && idx < max_group)
{
int n = PCB->LayerGroups.Number[group];
for (idx = 0; idx < n-1; idx ++)
{ /* idx is a group entry index here */
int ni = PCB->LayerGroups.Entries[group][idx]; /* ni is a layer number */
if (ni >= 0 && ni < max_copper_layer + 2
&& PCB->Data->Layer[ni].On)
break;
}
idx = PCB->LayerGroups.Entries[group][idx]; /* idx is now a layer number! */
}
if (idx >= 0 && idx < max_copper_layer + 2)
{
group_visible = PCB->Data->Layer[idx].On;
... /* idx is a layer number in this section */
}
else if (idx < 0)
... /* idx is a "magic" group number, created with SL() macros */
What that is doing, is looking for a copper (or silk) layer in the
appropriate group (which gets its number set in "idx", then testing if
that layer is on.
Note that the for-loop stops one-short, as the value left in idx can be
one greater than the termination criteria of the for loop (which IS the
last in the layer group).
idx is abused as both a group index, and a layer index. These are
completely different (boy this code sucks).
(Oh yea, that is ugly!)
I felt sure I'd re-written this because it was ugly before now. I really
shudder to think the above was what _I_ came up with to fix it being
ugly.
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)
Attachment:
signature.asc
Description: This is a digitally signed message part
_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user