Don't make inferences about object type based on shape.

This commit is contained in:
Jeff Young 2021-12-01 19:31:59 +00:00
parent 58189dca7a
commit 09ed60feb3
2 changed files with 11 additions and 19 deletions

View File

@ -48,8 +48,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, KIGFX::VIEW* a
m_clearance = -1; m_clearance = -1;
m_originLayer = m_layer = LAYER_SELECT_OVERLAY ; m_originLayer = m_layer = LAYER_SELECT_OVERLAY ;
m_showTrackClearance = false; m_showClearance = false;
m_showViaClearance = false;
// initialize variables, overwritten by Update( aItem ), if aItem != NULL // initialize variables, overwritten by Update( aItem ), if aItem != NULL
m_router = nullptr; m_router = nullptr;
@ -208,7 +207,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
{ {
const SHAPE_LINE_CHAIN_BASE* l = (const SHAPE_LINE_CHAIN_BASE*) aShape; const SHAPE_LINE_CHAIN_BASE* l = (const SHAPE_LINE_CHAIN_BASE*) aShape;
if( m_showTrackClearance && m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
gal->SetLineWidth( m_width + 2 * m_clearance ); gal->SetLineWidth( m_width + 2 * m_clearance );
drawLineChain( l, gal ); drawLineChain( l, gal );
@ -227,7 +226,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) aShape; const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) aShape;
const int w = l->Width(); const int w = l->Width();
if( m_showTrackClearance && m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
gal->SetLineWidth( w + 2 * m_clearance ); gal->SetLineWidth( w + 2 * m_clearance );
drawLineChain( l, gal ); drawLineChain( l, gal );
@ -248,7 +247,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
gal->SetIsStroke( false ); gal->SetIsStroke( false );
if( m_showTrackClearance && m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
gal->SetLineWidth( w + 2 * m_clearance ); gal->SetLineWidth( w + 2 * m_clearance );
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 );
@ -266,7 +265,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
const SHAPE_CIRCLE* c = static_cast<const SHAPE_CIRCLE*>( aShape ); const SHAPE_CIRCLE* c = static_cast<const SHAPE_CIRCLE*>( aShape );
gal->SetStrokeColor( m_color ); gal->SetStrokeColor( m_color );
if( m_showViaClearance && m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
gal->SetIsStroke( false ); gal->SetIsStroke( false );
gal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance ); gal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
@ -302,7 +301,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
const SHAPE_RECT* r = (const SHAPE_RECT*) aShape; const SHAPE_RECT* r = (const SHAPE_RECT*) aShape;
gal->SetFillColor( m_color ); gal->SetFillColor( m_color );
if( m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
VECTOR2I p0( r->GetPosition() ), s( r->GetSize() ); VECTOR2I p0( r->GetPosition() ), s( r->GetSize() );
gal->SetIsStroke( true ); gal->SetIsStroke( true );
@ -334,7 +333,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
gal->SetFillColor( m_color ); gal->SetFillColor( m_color );
if( m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
gal->SetIsStroke( true ); gal->SetIsStroke( true );
gal->SetLineWidth( 2 * m_clearance ); gal->SetLineWidth( 2 * m_clearance );
@ -363,7 +362,7 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
gal->SetIsFill( false ); gal->SetIsFill( false );
gal->SetIsStroke( true ); gal->SetIsStroke( true );
if( m_showTrackClearance && m_clearance > 0 ) if( m_showClearance && m_clearance > 0 )
{ {
gal->SetLineWidth( w + 2 * m_clearance ); gal->SetLineWidth( w + 2 * m_clearance );
gal->DrawArc( arc->GetCenter(), arc->GetRadius(), start_angle, start_angle + angle ); gal->DrawArc( arc->GetCenter(), arc->GetRadius(), start_angle, start_angle + angle );

View File

@ -74,14 +74,9 @@ public:
m_clearance = aClearance; m_clearance = aClearance;
} }
void ShowTrackClearance( bool aEnabled ) void ShowClearance( bool aEnabled )
{ {
m_showTrackClearance = aEnabled; m_showClearance = aEnabled;
}
void ShowViaClearance( bool aEnabled )
{
m_showViaClearance = aEnabled;
} }
#if defined(DEBUG) #if defined(DEBUG)
@ -128,9 +123,7 @@ private:
int m_layer; int m_layer;
int m_originLayer; int m_originLayer;
int m_clearance; int m_clearance;
bool m_showClearance;
bool m_showTrackClearance;
bool m_showViaClearance;
// fixme: shouldn't this go to VIEW? // fixme: shouldn't this go to VIEW?
static const int ClearanceOverlayDepth; static const int ClearanceOverlayDepth;