diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 3e0a808193..0c91a0a806 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -103,6 +103,11 @@ #define MINIMUM_LINE_WIDTH_MM 0.005 // minimal line width entered in a dialog #define MAXIMUM_LINE_WIDTH_MM 100.0 // max line width entered in a dialog +// Default pad properies +#define DEFAULT_PAD_WIDTH_MM 2.54 // master pad width +#define DEFAULT_PAD_HEIGTH_MM 1.27 // master pad heigth +#define DEFAULT_PAD_DRILL_DIAMETER_MM 0.8 // master pad drill diameter for PTH +#define DEFAULT_PAD_REACT_RADIUS 15 // master pad corner radius in percent /** * Container to handle a stock of specific vias each with unique diameter and drill sizes @@ -653,6 +658,8 @@ public: void SetGridOrigin( const VECTOR2I& aOrigin ) { m_gridOrigin = aOrigin; } const VECTOR2I& GetGridOrigin() { return m_gridOrigin; } + void SetDefaultMasterPad(); + private: void initFromOther( const BOARD_DESIGN_SETTINGS& aOther ); diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index c8e826e263..40755a2284 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -53,6 +53,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: m_HasStackup = false; // no stackup defined by default m_Pad_Master = std::make_unique( nullptr ); + SetDefaultMasterPad(); LSET all_set = LSET().set(); m_enabledLayers = all_set; // All layers enabled at first. @@ -1481,3 +1482,15 @@ bool BOARD_DESIGN_SETTINGS::GetTextUpright( PCB_LAYER_ID aLayer ) const { return m_TextUpright[ GetLayerClass( aLayer ) ]; } + +void BOARD_DESIGN_SETTINGS::SetDefaultMasterPad() +{ + m_Pad_Master.get()->SetSizeX( pcbIUScale.mmToIU( DEFAULT_PAD_WIDTH_MM ) ); + m_Pad_Master.get()->SetSizeY( pcbIUScale.mmToIU( DEFAULT_PAD_HEIGTH_MM ) ); + m_Pad_Master.get()->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); + m_Pad_Master.get()->SetDrillSize( + VECTOR2I( pcbIUScale.mmToIU( DEFAULT_PAD_DRILL_DIAMETER_MM ), 0 ) ); + m_Pad_Master.get()->SetShape( PAD_SHAPE::ROUNDRECT ); + m_Pad_Master.get()->SetRoundRectCornerRadius( + pcbIUScale.mmToIU( DEFAULT_PAD_HEIGTH_MM / 100.0 * DEFAULT_PAD_REACT_RADIUS ) ); +} diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 2133c84404..8f651ae589 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -558,20 +558,35 @@ void DIALOG_PAD_PROPERTIES::initValues() m_FlippedWarningSizer->Show( footprint->IsFlipped() ); m_parentInfo->SetLabel( msg ); } - } - m_primitives = m_previewPad->GetPrimitives(); - - if( m_currentPad ) - { m_padNumCtrl->SetValue( m_previewPad->GetNumber() ); } else { PAD_TOOL* padTool = m_parent->GetToolManager()->GetTool(); m_padNumCtrl->SetValue( padTool->GetLastPadNumber() ); + + if( m_isFpEditor ) + { + switch( m_board->Footprints()[0]->GetAttributes() ) + { + case FOOTPRINT_ATTR_T::FP_THROUGH_HOLE: + m_previewPad->SetAttribute( PAD_ATTRIB::PTH ); + + if( m_previewPad->GetDrillSizeX() == 0 ) + m_board->GetDesignSettings().SetDefaultMasterPad(); + + break; + + case FOOTPRINT_ATTR_T::FP_SMD: + m_previewPad->SetAttribute( PAD_ATTRIB::SMD ); + break; + } + } } + m_primitives = m_previewPad->GetPrimitives(); + m_padNetSelector->SetSelectedNetcode( m_previewPad->GetNetCode() ); // Display current pad parameters units: @@ -965,15 +980,23 @@ void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event ) m_gbSizerHole->Show( hasHole ); m_staticline6->Show( hasHole ); + if( !hasHole ) { m_holeX.ChangeValue( 0 ); m_holeY.ChangeValue( 0 ); } - else if ( m_holeX.GetValue() == 0 && m_currentPad ) + else if( m_holeX.GetValue() == 0 ) { - m_holeX.ChangeValue( m_currentPad->GetDrillSize().x ); - m_holeY.ChangeValue( m_currentPad->GetDrillSize().y ); + if( m_currentPad ) + { + m_holeX.ChangeValue( m_currentPad->GetDrillSize().x ); + m_holeY.ChangeValue( m_currentPad->GetDrillSize().y ); + } + else + { + m_holeX.ChangeValue( pcbIUScale.mmToIU( DEFAULT_PAD_DRILL_DIAMETER_MM ) ); + } } if( !hasConnection )