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
This commit is contained in:
jean-pierre charras 2019-04-04 15:25:22 +02:00
parent de4b2dea77
commit 0aa8458d04
1 changed files with 21 additions and 19 deletions

View File

@ -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;