From 6652e5acf44ba1a9a8ae190aa1ba96d9f118be6b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 27 Nov 2021 00:53:28 +0000 Subject: [PATCH] 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 --- pcbnew/router/pns_component_dragger.cpp | 32 ++++++++++--------------- pcbnew/router/pns_kicad_iface.cpp | 25 ++++++++++--------- pcbnew/router/router_preview_item.cpp | 21 ++++++++++++++++ 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/pcbnew/router/pns_component_dragger.cpp b/pcbnew/router/pns_component_dragger.cpp index b5ea99bc88..0ad2214f4c 100644 --- a/pcbnew/router/pns_component_dragger.cpp +++ b/pcbnew/router/pns_component_dragger.cpp @@ -160,15 +160,14 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP ) m_world->KillChildren(); 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_draggedItems.Clear(); - for( auto item : m_solids ) + for( SOLID* s : m_solids ) { - SOLID* s = static_cast( item ); - auto p_next = aP - m_p0 + s->Pos(); + VECTOR2I p_next = aP - m_p0 + s->Pos(); std::unique_ptr snew( static_cast( s->Clone() ) ); snew->SetPos( p_next ); @@ -178,7 +177,7 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP ) if( !s->IsRoutable() ) continue; - for( auto& l : m_conns ) + for( DRAGGED_CONNECTION& l : m_conns ) { 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.ClearLinks(); 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" ); m_draggedItems.Add( l_new ); - auto l_orig( cn.origLine ); + LINE l_orig( cn.origLine ); m_currentNode->Remove( l_orig ); m_currentNode->Add( l_new ); } @@ -251,18 +250,11 @@ bool COMPONENT_DRAGGER::FixRoute() if( node ) { - bool ok; - - if( Settings().AllowDRCViolations() ) - ok = true; - else - ok = !node->CheckColliding( m_draggedItems ); - - if( !ok ) - return false; - - Router()->CommitRouting( node ); - return true; + if( Settings().AllowDRCViolations() || !node->CheckColliding( m_draggedItems ) ) + { + Router()->CommitRouting( node ); + return true; + } } return false; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index a4a0ba7a84..96d5e92f5f 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -921,19 +921,6 @@ std::unique_ptr PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad ) std::unique_ptr solid = std::make_unique(); - 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 ) solid->SetRoutable( false ); @@ -953,6 +940,18 @@ std::unique_ptr PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad ) solid->SetPos( VECTOR2I( c.x - offset.x, c.y - 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( aPad->GetEffectiveShape() ); diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 6ff990d293..7ca6cec326 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -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 { + bool holeDrawn = false; + switch( aShape->Type() ) { 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->SetLineWidth( halfWidth + c->GetRadius() - h->GetRadius() ); gal->DrawCircle( c->GetCenter(), ( halfWidth + c->GetRadius() + h->GetRadius() ) / 2 ); + + holeDrawn = true; } else { @@ -384,6 +388,23 @@ void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) cons case SH_NULL: 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( m_hole ); + SHAPE_SEGMENT* slot = dynamic_cast( m_hole ); + + if( circle ) + gal->DrawCircle( circle->GetCenter(), circle->GetRadius() ); + else if( slot ) + gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, slot->GetWidth() ); + } }