Draw pad holes when dragging.

Most of the time they're under the pad, but the provide needed
info when the hole is larger than the pad.

Fixes https://gitlab.com/kicad/code/kicad/issues/9786
This commit is contained in:
Jeff Young 2021-11-27 00:53:28 +00:00
parent 9547c72e73
commit 6652e5acf4
3 changed files with 45 additions and 33 deletions

View File

@ -160,15 +160,14 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP )
m_world->KillChildren(); m_world->KillChildren();
m_currentNode = m_world->Branch(); m_currentNode = m_world->Branch();
for( auto item : m_initialDraggedItems.Items() ) for( const ITEM_SET::ENTRY& item : m_initialDraggedItems.Items() )
m_currentNode->Remove( item ); m_currentNode->Remove( item );
m_draggedItems.Clear(); m_draggedItems.Clear();
for( auto item : m_solids ) for( SOLID* s : m_solids )
{ {
SOLID* s = static_cast<SOLID*>( item ); VECTOR2I p_next = aP - m_p0 + s->Pos();
auto p_next = aP - m_p0 + s->Pos();
std::unique_ptr<SOLID> snew( static_cast<SOLID*>( s->Clone() ) ); std::unique_ptr<SOLID> snew( static_cast<SOLID*>( s->Clone() ) );
snew->SetPos( p_next ); snew->SetPos( p_next );
@ -178,7 +177,7 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP )
if( !s->IsRoutable() ) if( !s->IsRoutable() )
continue; continue;
for( auto& l : m_conns ) for( DRAGGED_CONNECTION& l : m_conns )
{ {
if( l.attachedPad == s ) if( l.attachedPad == s )
{ {
@ -226,9 +225,9 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP )
} }
} }
for( auto& cn : m_conns ) for( COMPONENT_DRAGGER::DRAGGED_CONNECTION& cn : m_conns )
{ {
auto l_new( cn.origLine ); LINE l_new( cn.origLine );
l_new.Unmark(); l_new.Unmark();
l_new.ClearLinks(); l_new.ClearLinks();
l_new.DragCorner( cn.p_next, cn.origLine.CLine().Find( cn.p_orig ) ); l_new.DragCorner( cn.p_next, cn.origLine.CLine().Find( cn.p_orig ) );
@ -236,7 +235,7 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP )
PNS_DBG( Dbg(), AddLine, l_new.CLine(), BLUE, 100000, "cdrag-new-fanout" ); PNS_DBG( Dbg(), AddLine, l_new.CLine(), BLUE, 100000, "cdrag-new-fanout" );
m_draggedItems.Add( l_new ); m_draggedItems.Add( l_new );
auto l_orig( cn.origLine ); LINE l_orig( cn.origLine );
m_currentNode->Remove( l_orig ); m_currentNode->Remove( l_orig );
m_currentNode->Add( l_new ); m_currentNode->Add( l_new );
} }
@ -251,18 +250,11 @@ bool COMPONENT_DRAGGER::FixRoute()
if( node ) if( node )
{ {
bool ok; if( Settings().AllowDRCViolations() || !node->CheckColliding( m_draggedItems ) )
{
if( Settings().AllowDRCViolations() ) Router()->CommitRouting( node );
ok = true; return true;
else }
ok = !node->CheckColliding( m_draggedItems );
if( !ok )
return false;
Router()->CommitRouting( node );
return true;
} }
return false; return false;

View File

@ -921,19 +921,6 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>(); std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
if( aPad->GetDrillSize().x > 0 )
{
SHAPE_SEGMENT* slot = (SHAPE_SEGMENT*) aPad->GetEffectiveHoleShape()->Clone();
if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
{
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
slot->SetWidth( slot->GetWidth() + bds.GetHolePlatingThickness() * 2 );
}
solid->SetHole( slot );
}
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH ) if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
solid->SetRoutable( false ); solid->SetRoutable( false );
@ -953,6 +940,18 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) ); solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
solid->SetOffset( VECTOR2I( offset.x, offset.y ) ); solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
if( aPad->GetDrillSize().x > 0 )
{
SHAPE_SEGMENT* slot = (SHAPE_SEGMENT*) aPad->GetEffectiveHoleShape()->Clone();
if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
{
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
slot->SetWidth( slot->GetWidth() + bds.GetHolePlatingThickness() * 2 );
}
solid->SetHole( slot );
}
auto shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() ); auto shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );

View File

@ -200,6 +200,8 @@ void ROUTER_PREVIEW_ITEM::drawLineChain( const SHAPE_LINE_CHAIN_BASE* aL, KIGFX:
void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) const void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) const
{ {
bool holeDrawn = false;
switch( aShape->Type() ) switch( aShape->Type() )
{ {
case SH_POLY_SET_TRIANGLE: case SH_POLY_SET_TRIANGLE:
@ -281,6 +283,8 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
gal->SetIsFill( false ); gal->SetIsFill( false );
gal->SetLineWidth( halfWidth + c->GetRadius() - h->GetRadius() ); gal->SetLineWidth( halfWidth + c->GetRadius() - h->GetRadius() );
gal->DrawCircle( c->GetCenter(), ( halfWidth + c->GetRadius() + h->GetRadius() ) / 2 ); gal->DrawCircle( c->GetCenter(), ( halfWidth + c->GetRadius() + h->GetRadius() ) / 2 );
holeDrawn = true;
} }
else else
{ {
@ -384,6 +388,23 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons
case SH_NULL: case SH_NULL:
break; break;
} }
if( m_hole && !holeDrawn )
{
gal->SetLayerDepth( m_depth );
gal->SetIsStroke( true );
gal->SetIsFill( false );
gal->SetStrokeColor( m_color );
gal->SetLineWidth( 1 );
SHAPE_CIRCLE* circle = dynamic_cast<SHAPE_CIRCLE*>( m_hole );
SHAPE_SEGMENT* slot = dynamic_cast<SHAPE_SEGMENT*>( m_hole );
if( circle )
gal->DrawCircle( circle->GetCenter(), circle->GetRadius() );
else if( slot )
gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, slot->GetWidth() );
}
} }