Eeschema: Normalize layer ordering between plot and screen

Fixes: lp:1833428
* https://bugs.launchpad.net/kicad/+bug/1833428
This commit is contained in:
Seth Hillbrand 2019-06-19 07:48:35 -07:00
parent b124599de3
commit 8f7278e34f
6 changed files with 40 additions and 61 deletions

View File

@ -41,8 +41,7 @@ SCH_BITMAP::SCH_BITMAP( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_BITMAP_T )
{
m_pos = pos;
m_Layer = LAYER_NOTES; // used only to draw/plot a rectangle,
// when a bitmap cannot be drawn or plotted
m_Layer = LAYER_SCHEMATIC_BITMAPS;
m_image = new BITMAP_BASE();
}

View File

@ -509,9 +509,11 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
* library editor and library viewer do not use m_drawList, and therefore
* their SCH_SCREEN::Draw() draws nothing
*/
std::vector< SCH_ITEM* > junctions;
std::vector< SCH_ITEM* > bitmaps;
std::vector< SCH_ITEM* > other;
std::vector< SCH_ITEM* > items;
// Ensure links are up to date, even if a library was reloaded for some reason:
UpdateSymbolLinks();
// Ensure links are up to date, even if a library was reloaded for some reason:
UpdateSymbolLinks();
@ -521,36 +523,25 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
if( item->IsMoving() || item->IsResized() )
continue;
if( item->Type() == SCH_JUNCTION_T )
junctions.push_back( item );
else if( item->Type() == SCH_BITMAP_T )
bitmaps.push_back( item );
else
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
// if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) )
other.push_back( item );
items.push_back( item );
}
// Bitmaps are drawn first to ensure they are in the background
// This is particularly important for the wxPostscriptDC (used in *nix printers) as
// the bitmap PS command clears the screen
for( auto item : bitmaps )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
std::sort( items.begin(), items.end(), [] ( const SCH_ITEM* a, const SCH_ITEM* b )
{
if( a->Type() == b->Type() )
return a->GetLayer() > b->GetLayer();
for( auto item : other )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
return a->Type() > b->Type();
} );
for( auto item : junctions )
for( auto item : items )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
}
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
{
// Ensure links are up to date, even if a library was reloaded for some reason:
std::vector< SCH_ITEM* > junctions;
std::vector< SCH_ITEM* > bitmaps;
std::vector< SCH_ITEM* > other;
std::vector< SCH_ITEM* > items;
// Ensure links are up to date, even if a library was reloaded for some reason:
UpdateSymbolLinks();
@ -560,32 +551,18 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter )
if( item->IsMoving() || item->IsResized() )
continue;
if( item->Type() == SCH_JUNCTION_T )
junctions.push_back( item );
else if( item->Type() == SCH_BITMAP_T )
bitmaps.push_back( item );
else
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
// if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) )
other.push_back( item );
items.push_back( item );
}
// Bitmaps are drawn first to ensure they are in the background
// This is particularly important for the wxPostscriptDC (used in *nix printers) as
// the bitmap PS command clears the screen
for( auto item : bitmaps )
std::sort( items.begin(), items.end(), [] ( const SCH_ITEM* a, const SCH_ITEM* b )
{
aPlotter->SetCurrentLineWidth( item->GetPenSize() );
item->Plot( aPlotter );
}
if( a->Type() == b->Type() )
return a->GetLayer() > b->GetLayer();
for( auto item : other )
{
aPlotter->SetCurrentLineWidth( item->GetPenSize() );
item->Plot( aPlotter );
}
return a->Type() > b->Type();
} );
for( auto item : junctions )
for( auto item : items )
{
aPlotter->SetCurrentLineWidth( item->GetPenSize() );
item->Plot( aPlotter );

View File

@ -46,14 +46,17 @@ static const LAYER_NUM SCH_LAYER_ORDER[] =
LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY,
LAYER_ERC_ERR, LAYER_ERC_WARN,
LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS,
LAYER_JUNCTION, LAYER_NOCONNECT,
LAYER_NOCONNECT,
LAYER_JUNCTION,
LAYER_HIERLABEL,
LAYER_WIRE, LAYER_BUS,
LAYER_WIRE,
LAYER_BUS,
LAYER_NOTES,
LAYER_DEVICE,
LAYER_DEVICE_BACKGROUND,
LAYER_NOTES,
LAYER_SHEET,
LAYER_SHEET_BACKGROUND,
LAYER_SCHEMATIC_BITMAPS,
LAYER_WORKSHEET
};

View File

@ -104,23 +104,22 @@ enum KICAD_T
PCB_NETINFO_T, ///< class NETINFO_ITEM, a description of a net
// Schematic draw Items. The order of these items effects the sort order.
// It is currently ordered to mimic the old Eeschema locate behavior where
// the smallest item is the selected item.
// The SCH_MARKER_T is drawn last (on top of others)
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_LINE_T,
SCH_BITMAP_T,
SCH_JUNCTION_T,
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_BUS_WIRE_ENTRY_T,
SCH_BUS_BUS_ENTRY_T,
SCH_LINE_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
SCH_BITMAP_T,
// Be prudent with these 3 types:
// they should be used only to locate a specific field type

View File

@ -257,6 +257,7 @@ enum SCH_LAYER_ID: int
LAYER_ERC_ERR,
LAYER_DEVICE_BACKGROUND,
LAYER_SHEET_BACKGROUND,
LAYER_SCHEMATIC_BITMAPS,
LAYER_SCHEMATIC_GRID,
LAYER_SCHEMATIC_BACKGROUND,
LAYER_SCHEMATIC_CURSOR,