DIALOG_PAD_PROPERTIES: use our UNIT_BINDER to manage pad rotation and remove

the wxFloatingPointValidator (that has also issues with fp separator).
Try to fix a bug related to pad rotation in some locales (see bug 9331).
This commit is contained in:
jean-pierre charras 2021-10-30 11:56:24 +02:00
parent 0ef6e94b52
commit 48be569a29
5 changed files with 29 additions and 37 deletions

View File

@ -131,14 +131,14 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_mixedChamferRatioUnits ),
m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits ),
m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits ),
m_OrientValidator( 3, &m_OrientValue ),
m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits ),
m_maskMargin( aParent, m_maskMarginLabel, m_maskMarginCtrl, m_maskMarginUnits ),
m_pasteMargin( aParent, m_pasteMarginLabel, m_pasteMarginCtrl, m_pasteMarginUnits ),
m_pasteMarginRatio( aParent, m_pasteMarginRatioLabel, m_pasteMarginRatioCtrl,
m_pasteMarginRatioUnits ),
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits ),
m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits )
m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits ),
m_pad_orientation( aParent, m_PadOrientText, m_cb_padrotation, m_orientationUnits )
{
SetName( PAD_PROPERTIES_DLG_NAME );
m_isFpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( aParent ) != nullptr;
@ -155,10 +155,6 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_padNetSelector->SetBoard( m_board );
m_padNetSelector->SetNetInfo( &m_board->GetNetInfo() );
m_OrientValidator.SetRange( -360.0, 360.0 );
m_orientation->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_orientation );
m_cbShowPadOutline->SetValue( m_sketchPreview );
m_FlippedWarningIcon->SetBitmap( KiBitmap( BITMAPS::dialog_warning ) );
@ -195,6 +191,8 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_chamferRatio.SetUnits( EDA_UNITS::PERCENT );
m_mixedCornerRatio.SetUnits( EDA_UNITS::PERCENT );
m_mixedChamferRatio.SetUnits( EDA_UNITS::PERCENT );
m_pad_orientation.SetUnits( EDA_UNITS::DEGREES );
m_pad_orientation.SetPrecision( 3 );
m_pasteMargin.SetNegativeZero();
@ -455,7 +453,6 @@ void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event )
void DIALOG_PAD_PROPERTIES::initValues()
{
wxString msg;
double angle;
// Disable pad net name wxTextCtrl if the caller is the footprint editor
// because nets are living only in the board managed by the board editor
@ -482,7 +479,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
if( footprint )
{
angle = m_dummyPad->GetOrientation();
double angle = m_dummyPad->GetOrientation();
angle -= footprint->GetOrientation();
m_dummyPad->SetOrientation( angle );
@ -558,6 +555,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
m_thermalGap.ChangeValue( m_dummyPad->GetThermalGap() );
m_pasteMargin.ChangeValue( m_dummyPad->GetLocalSolderPasteMargin() );
m_pasteMarginRatio.ChangeDoubleValue( m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
m_pad_orientation.ChangeDoubleValue( m_dummyPad->GetOrientation() );
switch( m_dummyPad->GetZoneConnection() )
{
@ -573,13 +571,6 @@ void DIALOG_PAD_PROPERTIES::initValues()
else
m_ZoneCustomPadShape->SetSelection( 0 );
angle = m_dummyPad->GetOrientation();
NORMALIZE_ANGLE_180( angle );
// Pad Orient
// Note: use ChangeValue() instead of SetValue() so that we don't generate events
m_orientation->ChangeValue( StringFromValue( EDA_UNITS::DEGREES, angle ) );
switch( m_dummyPad->GetShape() )
{
default:
@ -1692,8 +1683,6 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( PAD* aPad )
if( !m_spokeWidth.Validate( 0, INT_MAX ) )
return false;
m_OrientValidator.TransferFromWindow();
aPad->SetAttribute( code_type[m_padType->GetSelection()] );
aPad->SetShape( code_shape[m_PadShapeSelector->GetSelection()] );
@ -1713,6 +1702,9 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( PAD* aPad )
aPad->SetThermalSpokeWidth( m_spokeWidth.GetValue() );
aPad->SetThermalGap( m_thermalGap.GetValue() );
// And rotation
aPad->SetOrientation( m_pad_orientation.GetDoubleValue() );
switch( m_ZoneConnectionChoice->GetSelection() )
{
default:
@ -1791,7 +1783,6 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( PAD* aPad )
else
aPad->SetPadToDieLength( 0 );
aPad->SetOrientation( m_OrientValue * 10.0 );
aPad->SetNumber( m_padNumCtrl->GetValue() );
aPad->SetNetCode( m_padNetSelector->GetSelectedNetcode() );

View File

@ -158,12 +158,12 @@ private:
UNIT_BINDER m_chamferRatio;
UNIT_BINDER m_mixedCornerRatio, m_mixedChamferRatio;
UNIT_BINDER m_holeX, m_holeY;
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
UNIT_BINDER m_clearance;
UNIT_BINDER m_maskMargin;
UNIT_BINDER m_pasteMargin, m_pasteMarginRatio;
UNIT_BINDER m_spokeWidth, m_thermalGap;
UNIT_BINDER m_pad_orientation;
};
/**

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -337,12 +337,13 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
m_PadOrientText->Wrap( -1 );
gbSizerPadOrientation->Add( m_PadOrientText, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_orientation = new wxComboBox( m_panelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), 0, NULL, 0 );
m_orientation->Append( _("0") );
m_orientation->Append( _("90") );
m_orientation->Append( _("-90") );
m_orientation->Append( _("180") );
gbSizerPadOrientation->Add( m_orientation, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_cb_padrotation = new wxComboBox( m_panelGeneral, wxID_ANY, _("0"), wxDefaultPosition, wxSize( 100,-1 ), 0, NULL, 0 );
m_cb_padrotation->Append( _("0") );
m_cb_padrotation->Append( _("90") );
m_cb_padrotation->Append( _("-90") );
m_cb_padrotation->Append( _("180") );
m_cb_padrotation->SetSelection( 0 );
gbSizerPadOrientation->Add( m_cb_padrotation, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_orientationUnits = new wxStaticText( m_panelGeneral, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 );
m_orientationUnits->Wrap( -1 );
@ -369,7 +370,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
wxString m_holeShapeCtrlChoices[] = { _("Circular"), _("Oval") };
int m_holeShapeCtrlNChoices = sizeof( m_holeShapeCtrlChoices ) / sizeof( wxString );
m_holeShapeCtrl = new wxChoice( m_panelGeneral, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_holeShapeCtrlNChoices, m_holeShapeCtrlChoices, 0 );
m_holeShapeCtrl->SetSelection( 0 );
m_holeShapeCtrl->SetSelection( 1 );
gbSizerHole->Add( m_holeShapeCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 5 ), wxEXPAND|wxRIGHT, 5 );
m_holeXLabel = new wxStaticText( m_panelGeneral, wxID_ANY, _("Hole size X:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -1005,8 +1006,8 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
m_mixedCornerRatioCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onCornerSizePercentChange ), NULL, this );
m_sizeXCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
m_sizeYCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
m_orientation->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_orientation->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_cb_padrotation->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_cb_padrotation->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_holeShapeCtrl->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnDrillShapeSelected ), NULL, this );
m_holeXCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
m_holeYCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
@ -1065,8 +1066,8 @@ DIALOG_PAD_PROPERTIES_BASE::~DIALOG_PAD_PROPERTIES_BASE()
m_mixedCornerRatioCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onCornerSizePercentChange ), NULL, this );
m_sizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
m_sizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
m_orientation->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_orientation->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_cb_padrotation->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_cb_padrotation->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::PadOrientEvent ), NULL, this );
m_holeShapeCtrl->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnDrillShapeSelected ), NULL, this );
m_holeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
m_holeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );

View File

@ -4111,7 +4111,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_orientation</property>
<property name="name">m_cb_padrotation</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -4119,7 +4119,7 @@
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">-1</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size">100,-1</property>
<property name="style"></property>
@ -4130,7 +4130,7 @@
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="value">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@ -4402,7 +4402,7 @@
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -126,7 +126,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
wxTextCtrl* m_sizeYCtrl;
wxStaticText* m_sizeYUnits;
wxStaticText* m_PadOrientText;
wxComboBox* m_orientation;
wxComboBox* m_cb_padrotation;
wxStaticText* m_orientationUnits;
wxStaticLine* m_staticline6;
wxStaticText* m_holeShapeLabel;