Tighten up layer handling for LIB_SYMBOL.

We have to draw the parent symbol on the union of all layers that
its children might reside on, but we only want to draw each child
on its layers.

And we need to make sure LAYER_PRIVATE_NOTES gets into the layers
order list.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13943
This commit is contained in:
Jeff Young 2023-06-12 15:38:36 +01:00
parent a3f62cc8de
commit 451b9e20a1
3 changed files with 30 additions and 8 deletions

View File

@ -1121,13 +1121,15 @@ const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aConvert,
void LIB_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 6;
aLayers[0] = LAYER_DEVICE;
aLayers[1] = LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_REFERENCEPART;
aLayers[3] = LAYER_VALUEPART;
aLayers[4] = LAYER_FIELDS;
aLayers[5] = LAYER_SELECTION_SHADOWS;
aCount = 0;
aLayers[ aCount++ ] = LAYER_DEVICE;
aLayers[ aCount++ ] = LAYER_DEVICE_BACKGROUND;
aLayers[ aCount++ ] = LAYER_REFERENCEPART;
aLayers[ aCount++ ] = LAYER_VALUEPART;
aLayers[ aCount++ ] = LAYER_FIELDS;
aLayers[ aCount++ ] = LAYER_PRIVATE_NOTES;
aLayers[ aCount++ ] = LAYER_NOTES_BACKGROUND;
aLayers[ aCount++ ] = LAYER_SELECTION_SHADOWS;
}

View File

@ -749,11 +749,31 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields,
drawnSymbol = tmpSymbol.get();
}
// The parent must exist on the union of all its children's draw layers. But that doesn't
// mean we want to draw each child on the union.
auto childOnLayer =
[]( const LIB_ITEM& item, int layer )
{
int layers[512], layers_count;
item.ViewGetLayers( layers, layers_count );
for( int ii = 0; ii < layers_count; ++ii )
{
if( layers[ii] == layer )
return true;
}
return false;
};
for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() )
{
if( !aDrawFields && item.Type() == LIB_FIELD_T )
continue;
if( !childOnLayer( item, aLayer ) )
continue;
if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
continue;

View File

@ -52,7 +52,7 @@ static const int SCH_LAYER_ORDER[] =
LAYER_BUS_JUNCTION, LAYER_JUNCTION, LAYER_NOCONNECT,
LAYER_HIERLABEL, LAYER_GLOBLABEL, LAYER_LOCLABEL,
LAYER_SHEETFILENAME, LAYER_SHEETNAME, LAYER_SHEETLABEL, LAYER_SHEETFIELDS,
LAYER_NOTES,
LAYER_NOTES, LAYER_PRIVATE_NOTES,
LAYER_WIRE, LAYER_BUS,
LAYER_DEVICE,
LAYER_SHEET,