From 0e26f3ab30026d2198ae58c2be61d29d95943cbd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 4 Sep 2023 19:44:39 +0100 Subject: [PATCH] Allow pad number box creation in pad edit mode. (Also fixes a bug where we'd include pad number box in pad shape.) --- pcbnew/pad.cpp | 11 +++++++---- pcbnew/pcb_painter.cpp | 13 +++++++------ pcbnew/pcb_shape.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 488f43381c..fcfb9a4455 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -566,11 +566,14 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const { for( const std::shared_ptr& primitive : m_editPrimitives ) { - for( SHAPE* shape : primitive->MakeEffectiveShapes() ) + if( !primitive->IsAnnotationProxy() ) { - shape->Rotate( m_orient ); - shape->Move( shapePos ); - add( shape ); + for( SHAPE* shape : primitive->MakeEffectiveShapes() ) + { + shape->Rotate( m_orient ); + shape->Move( shapePos ); + add( shape ); + } } } } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 8312f772c9..519e85f157 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1752,12 +1752,13 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer ) if( aShape->IsAnnotationProxy() ) { - m_gal->DrawSegment( pts[0], pts[1], thickness ); - m_gal->DrawSegment( pts[1], pts[2], thickness ); - m_gal->DrawSegment( pts[2], pts[3], thickness ); - m_gal->DrawSegment( pts[3], pts[0], thickness ); - m_gal->DrawSegment( pts[0], pts[2], thickness ); - m_gal->DrawSegment( pts[1], pts[3], thickness ); + m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); + m_gal->DrawLine( pts[0], pts[1] ); + m_gal->DrawLine( pts[1], pts[2] ); + m_gal->DrawLine( pts[2], pts[3] ); + m_gal->DrawLine( pts[3], pts[0] ); + m_gal->DrawLine( pts[0], pts[2] ); + m_gal->DrawLine( pts[1], pts[3] ); } else if( outline_mode ) { diff --git a/pcbnew/pcb_shape.cpp b/pcbnew/pcb_shape.cpp index d78a843baf..a6c5c2245a 100644 --- a/pcbnew/pcb_shape.cpp +++ b/pcbnew/pcb_shape.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -577,5 +578,33 @@ static struct PCB_SHAPE_DESC propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Net" ), isCopper ); + + auto isPadEditMode = + []( INSPECTABLE* aItem ) -> bool + { + if( PCB_SHAPE* shape = dynamic_cast( aItem ) ) + { + if( shape->GetBoard() && shape->GetBoard()->IsFootprintHolder() ) + { + for( FOOTPRINT* fp : shape->GetBoard()->Footprints() ) + { + for( PAD* pad : fp->Pads() ) + { + if( pad->IsEntered() ) + return true; + } + } + } + } + + return false; + }; + + const wxString groupPadPrimitives = _HKI( "Pad Primitives" ); + + propMgr.AddProperty( new PROPERTY( _HKI( "Number Box" ), + &EDA_SHAPE::SetIsAnnotationProxy, &EDA_SHAPE::IsAnnotationProxy ), + groupPadPrimitives ) + .SetAvailableFunc( isPadEditMode ); } } _PCB_SHAPE_DESC;