From 0aa8458d04c810c023ceb696992733ffccd0a95f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 4 Apr 2019 15:25:22 +0200 Subject: [PATCH] DIALOG_PAD_PROPERTIES: Fix incorrect calculation of Round Rect Radius Ratio, when inches are selected. Fixes: lp:1822720 https://bugs.launchpad.net/kicad/+bug/1822720 --- pcbnew/dialogs/dialog_pad_properties.cpp | 40 +++++++++++++----------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 200a6d195c..b8c0798549 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -326,6 +326,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) { // If drill size has been set, use that. Otherwise default to 1mm. dim = m_dummyPad->GetDrillSize().x; + if( dim == 0 ) dim = Millimeter2iu( 1.0 ); } @@ -349,6 +350,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) if( dim == 0 ) { dim = m_dummyPad->GetDrillSize().y; + if( dim == 0 ) dim = Millimeter2iu( 0.1 ); } @@ -487,24 +489,20 @@ void DIALOG_PAD_PROPERTIES::onCornerRadiusChange( wxCommandEvent& event ) m_dummyPad->GetShape() != PAD_SHAPE_CHAMFERED_RECT ) return; - wxString value = m_tcCornerRadius->GetValue(); - double rrRadius; + double rrRadius = m_cornerRadius.GetValue(); - if( value.ToDouble( &rrRadius ) ) + if( rrRadius < 0.0 ) { - if( rrRadius < 0.0 ) - { - rrRadius = 0.0; - m_tcCornerRadius->ChangeValue( "0.0" ); - } - - transferDataToPad( m_dummyPad ); - m_dummyPad->SetRoundRectCornerRadius( Millimeter2iu( rrRadius ) ); - - auto ratio = wxString::Format( "%.1f", m_dummyPad->GetRoundRectRadiusRatio() * 100 ); - m_tcCornerSizeRatio->ChangeValue( ratio ); - redraw(); + rrRadius = 0.0; + m_tcCornerRadius->ChangeValue( wxString::Format( "%.1f", rrRadius ) ); } + + transferDataToPad( m_dummyPad ); + m_dummyPad->SetRoundRectCornerRadius(rrRadius ); + + auto ratio = wxString::Format( "%.1f", m_dummyPad->GetRoundRectRadiusRatio() * 100 ); + m_tcCornerSizeRatio->ChangeValue( ratio ); + redraw(); } @@ -525,13 +523,15 @@ void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event ) if( ratioPercent < 0.0 ) { ratioPercent = 0.0; - m_tcCornerSizeRatio->ChangeValue( "0.0" ); + value.Printf( "%.1f", ratioPercent ); + m_tcCornerSizeRatio->ChangeValue( value ); } if( ratioPercent > 50.0 ) { ratioPercent = 0.5; - m_tcCornerSizeRatio->ChangeValue( "50.0" ); + value.Printf( "%.1f", ratioPercent*100.0 ); + m_tcCornerSizeRatio->ChangeValue( value ); } asChanged = true; @@ -545,13 +545,15 @@ void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event ) if( ratioPercent < 0.0 ) { ratioPercent = 0.0; - m_tcChamferRatio->ChangeValue( "0.0" ); + value.Printf( "%.1f", ratioPercent ); + m_tcChamferRatio->ChangeValue( value ); } if( ratioPercent > 50.0 ) { ratioPercent = 0.5; - m_tcChamferRatio->ChangeValue( "50.0" ); + value.Printf( "%.1f", ratioPercent*100.0 ); + m_tcChamferRatio->ChangeValue( value ); } asChanged = true;