pcbnew: Draw the clearance outline first

In Cairo, we don't have z-ordering implemented, so we need to draw the
clearance outline first otherwise it will draw a large, grey overlay
that hides the actual track while routing.

Fixes: lp:1779228
* https://bugs.launchpad.net/kicad/+bug/1779228
This commit is contained in:
Seth Hillbrand 2018-06-28 20:26:36 -07:00
parent ce379f56af
commit 33075e55a4
1 changed files with 40 additions and 21 deletions

View File

@ -160,16 +160,18 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{ {
auto gal = aView->GetGAL(); auto gal = aView->GetGAL();
//col.Brighten(0.7); //col.Brighten(0.7);
gal->SetLayerDepth( m_depth );
if( m_type == PR_SHAPE ) if( m_type == PR_SHAPE )
{ {
if( !m_shape ) if( !m_shape )
return; return;
gal->SetLineWidth( m_width ); // N.B. The order of draw here is important
gal->SetStrokeColor( m_color ); // Cairo doesn't current support z-ordering, so we need
gal->SetFillColor( m_color ); // to draw the clearance first to ensure it is in the background
gal->SetLayerDepth( ClearanceOverlayDepth );
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
gal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
gal->SetIsStroke( m_width ? true : false ); gal->SetIsStroke( m_width ? true : false );
gal->SetIsFill( true ); gal->SetIsFill( true );
@ -178,61 +180,67 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
case SH_LINE_CHAIN: case SH_LINE_CHAIN:
{ {
const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) m_shape; const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) m_shape;
drawLineChain( *l, gal );
if( m_showTrackClearance && m_clearance > 0 ) if( m_showTrackClearance && m_clearance > 0 )
{ {
gal->SetLayerDepth( ClearanceOverlayDepth );
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
gal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
gal->SetLineWidth( m_width + 2 * m_clearance ); gal->SetLineWidth( m_width + 2 * m_clearance );
drawLineChain( *l, gal ); drawLineChain( *l, gal );
} }
gal->SetLayerDepth( m_depth );
gal->SetLineWidth( m_width );
gal->SetStrokeColor( m_color );
gal->SetFillColor( m_color );
drawLineChain( *l, gal );
break; break;
} }
case SH_SEGMENT: case SH_SEGMENT:
{ {
const SHAPE_SEGMENT* s = (const SHAPE_SEGMENT*) m_shape; const SHAPE_SEGMENT* s = (const SHAPE_SEGMENT*) m_shape;
gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() );
if( m_showTrackClearance && m_clearance > 0 ) if( m_showTrackClearance && m_clearance > 0 )
{ {
gal->SetLayerDepth( ClearanceOverlayDepth ); gal->SetLineWidth( m_width + 2 * m_clearance );
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
gal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() + 2 * m_clearance ); gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() + 2 * m_clearance );
} }
gal->SetLayerDepth( m_depth );
gal->SetLineWidth( m_width );
gal->SetStrokeColor( m_color );
gal->SetFillColor( m_color );
gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() );
break; break;
} }
case SH_CIRCLE: case SH_CIRCLE:
{ {
const SHAPE_CIRCLE* c = (const SHAPE_CIRCLE*) m_shape; const SHAPE_CIRCLE* c = (const SHAPE_CIRCLE*) m_shape;
gal->DrawCircle( c->GetCenter(), c->GetRadius() ); gal->SetStrokeColor( m_color );
if( m_showViaClearance && m_clearance > 0 ) if( m_showViaClearance && m_clearance > 0 )
{ {
gal->SetLayerDepth( ClearanceOverlayDepth );
gal->SetFillColor( COLOR4D( DARKDARKGRAY ) );
gal->SetIsStroke( false ); gal->SetIsStroke( false );
gal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance ); gal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
} }
gal->SetLayerDepth( m_depth );
gal->SetIsStroke( m_width ? true : false );
gal->SetLineWidth( m_width );
gal->SetFillColor( m_color );
gal->DrawCircle( c->GetCenter(), c->GetRadius() );
break; break;
} }
case SH_RECT: case SH_RECT:
{ {
const SHAPE_RECT* r = (const SHAPE_RECT*) m_shape; const SHAPE_RECT* r = (const SHAPE_RECT*) m_shape;
gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() ); gal->SetFillColor( m_color );
if( m_clearance > 0 ) if( m_clearance > 0 )
{ {
gal->SetLayerDepth( ClearanceOverlayDepth );
VECTOR2I p0( r->GetPosition() ), s( r->GetSize() ); VECTOR2I p0( r->GetPosition() ), s( r->GetSize() );
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
gal->SetIsStroke( true ); gal->SetIsStroke( true );
gal->SetLineWidth( 2 * m_clearance ); gal->SetLineWidth( 2 * m_clearance );
gal->DrawLine( p0, VECTOR2I( p0.x + s.x, p0.y ) ); gal->DrawLine( p0, VECTOR2I( p0.x + s.x, p0.y ) );
@ -241,6 +249,12 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal->DrawLine( p0 + s, VECTOR2I( p0.x, p0.y + s.y ) ); gal->DrawLine( p0 + s, VECTOR2I( p0.x, p0.y + s.y ) );
} }
gal->SetLayerDepth( m_depth );
gal->SetIsStroke( m_width ? true : false );
gal->SetLineWidth( m_width );
gal->SetStrokeColor( m_color );
gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
break; break;
} }
@ -252,18 +266,23 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{ {
polygon.push_back( c->CDPoint( i ) ); polygon.push_back( c->CDPoint( i ) );
} }
gal->DrawPolygon( polygon );
gal->SetFillColor( m_color );
if( m_clearance > 0 ) if( m_clearance > 0 )
{ {
gal->SetLayerDepth( ClearanceOverlayDepth );
gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) );
gal->SetIsStroke( true ); gal->SetIsStroke( true );
gal->SetLineWidth( 2 * m_clearance ); gal->SetLineWidth( 2 * m_clearance );
// need the implicit last segment to be explicit for DrawPolyline // need the implicit last segment to be explicit for DrawPolyline
polygon.push_back( c->CDPoint( 0 ) ); polygon.push_back( c->CDPoint( 0 ) );
gal->DrawPolyline( polygon ); gal->DrawPolyline( polygon );
} }
gal->SetLayerDepth( m_depth );
gal->SetIsStroke( m_width ? true : false );
gal->SetLineWidth( m_width );
gal->SetStrokeColor( m_color );
gal->DrawPolygon( polygon );
break; break;
} }