From a835ba0715a202c155ca57be55dc3149e90b1aa5 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 4 Mar 2024 13:42:57 -0800 Subject: [PATCH] Add "Mechanical" pad property Prevents mechanical support pads from being used to check pad types. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16747 --- common/pcb.keywords | 1 + include/pad_shapes.h | 6 ++++-- pcbnew/dialogs/dialog_pad_properties.cpp | 8 ++++++++ pcbnew/dialogs/dialog_pad_properties_base.cpp | 6 +++--- pcbnew/dialogs/dialog_pad_properties_base.fbp | 4 ++-- pcbnew/dialogs/dialog_pad_properties_base.h | 2 +- pcbnew/footprint.cpp | 1 + pcbnew/pad.cpp | 4 +++- pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp | 1 + pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp | 1 + pcbnew/plot_brditems_plotter.cpp | 1 + 11 files changed, 26 insertions(+), 9 deletions(-) diff --git a/common/pcb.keywords b/common/pcb.keywords index ae4e2f61e5..3b0bc62766 100644 --- a/common/pcb.keywords +++ b/common/pcb.keywords @@ -243,6 +243,7 @@ pad_prop_fiducial_glob pad_prop_castellated pad_prop_testpoint pad_prop_heatsink +pad_prop_mechanical padvia prefer_zone_connections private_layers diff --git a/include/pad_shapes.h b/include/pad_shapes.h index f0535f0ac7..53f96315d4 100644 --- a/include/pad_shapes.h +++ b/include/pad_shapes.h @@ -75,7 +75,8 @@ enum class PAD_ATTRIB /** * The set of pad properties used in Gerber files (Draw files, and P&P files) - * to define some properties in fabrication or test files. + * to define some properties in fabrication or test files. Also used by + * DRC to check some properties. */ enum class PAD_PROP { @@ -85,7 +86,8 @@ enum class PAD_PROP FIDUCIAL_LOCAL, ///< a fiducial (usually a smd) local to the parent footprint TESTPOINT, ///< a test point pad HEATSINK, ///< a pad used as heat sink, usually in SMD footprints - CASTELLATED ///< a pad with a castellated through hole + CASTELLATED, ///< a pad with a castellated through hole + MECHANICAL, ///< a pad used for mechanical support }; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index bbd3b62010..a18ad30fc5 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -744,6 +744,7 @@ void DIALOG_PAD_PROPERTIES::initValues() case PAD_PROP::TESTPOINT: m_choiceFabProperty->SetSelection( 4 ); break; case PAD_PROP::HEATSINK: m_choiceFabProperty->SetSelection( 5 ); break; case PAD_PROP::CASTELLATED: m_choiceFabProperty->SetSelection( 6 ); break; + case PAD_PROP::MECHANICAL: m_choiceFabProperty->SetSelection( 7 ); break; } // Ensure the pad property is compatible with the pad type @@ -1440,6 +1441,12 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK() warning_msgs.Add( _( "Warning: BGA property is for SMD pads." ) ); } + if( m_previewPad->GetProperty() == PAD_PROP::MECHANICAL + && m_previewPad->GetAttribute() != PAD_ATTRIB::PTH ) + { + warning_msgs.Add( _( "Warning: Mechanical property is for PTH pads." ) ); + } + if( m_previewPad->GetShape() == PAD_SHAPE::ROUNDRECT || m_previewPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT ) { @@ -1686,6 +1693,7 @@ PAD_PROP DIALOG_PAD_PROPERTIES::getSelectedProperty() case 4: prop = PAD_PROP::TESTPOINT; break; case 5: prop = PAD_PROP::HEATSINK; break; case 6: prop = PAD_PROP::CASTELLATED; break; + case 7: prop = PAD_PROP::MECHANICAL; break; } return prop; diff --git a/pcbnew/dialogs/dialog_pad_properties_base.cpp b/pcbnew/dialogs/dialog_pad_properties_base.cpp index b60078f908..e927edaebd 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.cpp +++ b/pcbnew/dialogs/dialog_pad_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) +// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf0) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -548,14 +548,14 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind m_staticTextFabProperty = new wxStaticText( m_panelGeneral, wxID_ANY, _("Fabrication property:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextFabProperty->Wrap( -1 ); - m_staticTextFabProperty->SetToolTip( _("Optional property to specify a special purpose or constraint in fabrication files:\nBGA attribute is for pads in BGA footprints\nFiducial local is a fiducial for the parent footprint\nFiducial global is a fiducial for the whole board\nTest Point pad is useful to specify test points in Gerber files\nHeatsink pad specify a thermal pad\nCastellated specify castellated through hole pads on a board edge\nThese properties are specified in Gerber X2 files.") ); + m_staticTextFabProperty->SetToolTip( _("Optional property to specify a special purpose or constraint in fabrication files:\nBGA attribute is for pads in BGA footprints\nFiducial local is a fiducial for the parent footprint\nFiducial global is a fiducial for the whole board\nTest Point specifies an electrical test point\nHeatsink specifies a thermal pad\nCastellated specifies a through hole pad on a board edge\nMechanical specifies a through-hole pad that is used for mechanical support") ); m_middleBoxSizer->Add( m_staticTextFabProperty, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_middleBoxSizer->Add( 0, 2, 0, wxEXPAND, 5 ); - wxString m_choiceFabPropertyChoices[] = { _("None"), _("BGA pad"), _("Fiducial, local to footprint"), _("Fiducial, global to board"), _("Test point pad"), _("Heatsink pad"), _("Castellated pad (through hole only)") }; + wxString m_choiceFabPropertyChoices[] = { _("None"), _("BGA pad"), _("Fiducial, local to footprint"), _("Fiducial, global to board"), _("Test point pad"), _("Heatsink pad"), _("Castellated pad (through hole only)"), _("Mechanical") }; int m_choiceFabPropertyNChoices = sizeof( m_choiceFabPropertyChoices ) / sizeof( wxString ); m_choiceFabProperty = new wxChoice( m_panelGeneral, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceFabPropertyNChoices, m_choiceFabPropertyChoices, 0 ); m_choiceFabProperty->SetSelection( 0 ); diff --git a/pcbnew/dialogs/dialog_pad_properties_base.fbp b/pcbnew/dialogs/dialog_pad_properties_base.fbp index 2f571955a4..a851e096ce 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.fbp +++ b/pcbnew/dialogs/dialog_pad_properties_base.fbp @@ -6886,7 +6886,7 @@ ; ; forward_declare 0 - Optional property to specify a special purpose or constraint in fabrication files: BGA attribute is for pads in BGA footprints Fiducial local is a fiducial for the parent footprint Fiducial global is a fiducial for the whole board Test Point pad is useful to specify test points in Gerber files Heatsink pad specify a thermal pad Castellated specify castellated through hole pads on a board edge These properties are specified in Gerber X2 files. + Optional property to specify a special purpose or constraint in fabrication files: BGA attribute is for pads in BGA footprints Fiducial local is a fiducial for the parent footprint Fiducial global is a fiducial for the whole board Test Point specifies an electrical test point Heatsink specifies a thermal pad Castellated specifies a through hole pad on a board edge Mechanical specifies a through-hole pad that is used for mechanical support @@ -6921,7 +6921,7 @@ 1 0 - "None" "BGA pad" "Fiducial, local to footprint" "Fiducial, global to board" "Test point pad" "Heatsink pad" "Castellated pad (through hole only)" + "None" "BGA pad" "Fiducial, local to footprint" "Fiducial, global to board" "Test point pad" "Heatsink pad" "Castellated pad (through hole only)" "Mechanical" 1 1 diff --git a/pcbnew/dialogs/dialog_pad_properties_base.h b/pcbnew/dialogs/dialog_pad_properties_base.h index 6220cd61ae..7ab565e86e 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.h +++ b/pcbnew/dialogs/dialog_pad_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) +// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf0) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 85b5de4215..125aa336b2 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1145,6 +1145,7 @@ int FOOTPRINT::GetLikelyAttribute() const case PAD_PROP::HEATSINK: case PAD_PROP::CASTELLATED: + case PAD_PROP::MECHANICAL: continue; case PAD_PROP::NONE: diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index d7afd546df..e82f479456 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -1229,6 +1229,7 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& case PAD_PROP::TESTPOINT: props += _( "Test point" ); break; case PAD_PROP::HEATSINK: props += _( "Heat sink" ); break; case PAD_PROP::CASTELLATED: props += _( "Castellated" ); break; + case PAD_PROP::MECHANICAL: props += _( "Mechanical" ); break; } aList.emplace_back( ShowPadShape(), props ); @@ -2112,7 +2113,8 @@ static struct PAD_DESC .Map( PAD_PROP::FIDUCIAL_LOCAL, _HKI( "Fiducial, local to footprint" ) ) .Map( PAD_PROP::TESTPOINT, _HKI( "Test point pad" ) ) .Map( PAD_PROP::HEATSINK, _HKI( "Heatsink pad" ) ) - .Map( PAD_PROP::CASTELLATED, _HKI( "Castellated pad" ) ); + .Map( PAD_PROP::CASTELLATED, _HKI( "Castellated pad" ) ) + .Map( PAD_PROP::MECHANICAL, _HKI( "Mechanical pad" ) ); ENUM_MAP& zcMap = ENUM_MAP::Instance(); diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp index b415471245..3ef0d32d7b 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp @@ -1490,6 +1490,7 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const case PAD_PROP::TESTPOINT: property = "pad_prop_testpoint"; break; case PAD_PROP::HEATSINK: property = "pad_prop_heatsink"; break; case PAD_PROP::CASTELLATED: property = "pad_prop_castellated"; break; + case PAD_PROP::MECHANICAL: property = "pad_prop_mechanical"; break; default: THROW_IO_ERROR( wxString::Format( wxT( "unknown pad property: %d" ), diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp index e9e74ab430..ce9985c39c 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp @@ -5074,6 +5074,7 @@ PAD* PCB_IO_KICAD_SEXPR_PARSER::parsePAD( FOOTPRINT* aParent ) case T_pad_prop_testpoint: pad->SetProperty( PAD_PROP::TESTPOINT ); break; case T_pad_prop_castellated: pad->SetProperty( PAD_PROP::CASTELLATED ); break; case T_pad_prop_heatsink: pad->SetProperty( PAD_PROP::HEATSINK ); break; + case T_pad_prop_mechanical: pad->SetProperty( PAD_PROP::MECHANICAL ); break; case T_none: pad->SetProperty( PAD_PROP::NONE ); break; case T_RIGHT: break; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 479e946444..1591b60510 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -184,6 +184,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_ break; case PAD_PROP::NONE: + case PAD_PROP::MECHANICAL: break; }