Fix draw order issues in eeschema and libedit.

Eeschema (where only the parent component is in the view) uses
draw order.

LibEdit (where the individual items are in the view) uses the
viewPriority setting.
This commit is contained in:
Jeff Young 2018-08-31 22:39:11 +01:00
parent 917943f8f8
commit c3479154ca
3 changed files with 29 additions and 14 deletions

View File

@ -287,6 +287,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SyncView();
GetGalCanvas()->GetViewControls()->SetSnapping( true );
GetGalCanvas()->GetView()->UseDrawPriority( true );
}

View File

@ -164,7 +164,6 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
//printf("bkgd2 %.02f %.02f %.02f %.02f\n", c2.r, c2.g, c2.b, c2.a);
m_gal->EnableDepthTest( false );
m_gal->AdvanceDepth();
/* m_gal->SetLineWidth( 10 );
m_gal->SetIsFill( false );
@ -215,16 +214,19 @@ void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit
{
size_t pinIndex = 0;
for( auto& item : aComp->GetDrawItems() )
auto visitItem = [&]( LIB_ITEM& item, bool aBackground )
{
if( !aDrawFields && item.Type() == LIB_FIELD_T )
continue;
if( aBackground != ( item.GetFillMode() == FILLED_WITH_BG_BODYCOLOR ) )
return;
if( !aDrawFields && item.Type() == LIB_FIELD_T )
return;
if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
continue;
return;
if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
continue;
return;
if( item.Type() == LIB_PIN_T )
{
@ -239,7 +241,16 @@ void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit
}
else
Draw( &item, aLayer );
}
};
// Apply a z-order heuristic (because we don't yet let the user edit it):
// draw body-filled objects first.
for( auto& item : aComp->GetDrawItems() )
visitItem( item, true );
for( auto& item : aComp->GetDrawItems() )
visitItem( item, false );
}
@ -1040,7 +1051,6 @@ void SCH_PAINTER::draw ( SCH_GLOBALLABEL *aLabel, int aLayer )
m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_GLOBLABEL ) );
m_gal->DrawPolyline( pts2 );
m_gal->AdvanceDepth(); // fixme
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
}
@ -1060,7 +1070,6 @@ void SCH_PAINTER::draw ( SCH_HIERLABEL *aLabel, int aLayer )
m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEETLABEL ) );
m_gal->DrawPolyline( pts2 );
m_gal->AdvanceDepth(); // fixme
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
}
@ -1108,11 +1117,7 @@ void SCH_PAINTER::draw ( SCH_SHEET *aSheet, int aLayer )
for( auto& sheetPin : aSheet->GetPins() )
{
m_gal->AdvanceDepth();
draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
}
}
void SCH_PAINTER::draw ( SCH_NO_CONNECT *aNC, int aLayer )

View File

@ -116,10 +116,19 @@ void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
{
Clear();
int fgPriority = INT_MAX / 2;
int bgPriority = 0;
for ( auto &item : aPart->GetDrawItems() )
{
//printf("-- ADD %p\n", &item );
Add( &item );
// Apply a z-order heuristic (because we don't yet let the user edit it):
// push body-filled objects to the back.
if( item.GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
Add( &item, bgPriority++ );
else
Add( &item, fgPriority++ );
}
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );