Eliminate 0.1deg units in DIALOG_PAD_PROPERTIES

This commit is contained in:
Chris Pavlina 2016-04-10 18:14:28 -04:00
parent 0a6583f902
commit 8325d6fdf0
5 changed files with 51 additions and 15 deletions

View File

@ -99,7 +99,8 @@ void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
DIALOG_PAD_PROPERTIES_BASE( aParent )
DIALOG_PAD_PROPERTIES_BASE( aParent ),
m_OrientValidator( 1, &m_OrientValue )
{
m_canUpdate = false;
m_parent = aParent;
@ -108,6 +109,9 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
m_board = m_parent->GetBoard();
m_OrientValidator.SetRange( -360.0, 360.0 );
m_PadOrientCtrl->SetValidator( m_OrientValidator );
m_padMaster = &m_parent->GetDesignSettings().m_Pad_Master;
m_dummyPad = new D_PAD( (MODULE*) NULL );
@ -143,6 +147,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
}
initValues();
TransferDataToWindow();
m_sdbSizerOK->SetDefault();
GetSizer()->SetSizeHints( this );
@ -514,8 +519,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
break;
}
msg.Printf( wxT( "%g" ), angle );
m_PadOrientCtrl->SetValue( msg );
m_OrientValue = angle / 10.0;
// Type of pad selection
m_PadType->SetSelection( 0 );
@ -669,9 +673,9 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
break;
}
wxString msg;
msg.Printf( wxT( "%g" ), m_dummyPad->GetOrientation() );
m_PadOrientCtrl->SetValue( msg );
m_OrientValue = m_dummyPad->GetOrientation() / 10.0;
m_OrientValidator.SetWindow( m_PadOrientCtrl );
m_OrientValidator.TransferToWindow();
transferDataToPad( m_dummyPad );
redraw();
@ -892,11 +896,32 @@ void DIALOG_PAD_PROPERTIES::redraw()
}
bool DIALOG_PAD_PROPERTIES::TransferDataToWindow()
{
if( !wxDialog::TransferDataToWindow() )
return false;
if( !m_panelGeneral->TransferDataToWindow() )
return false;
if( !m_localSettingsPanel->TransferDataToWindow() )
return false;
return true;
}
bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
if( !m_panelGeneral->TransferDataFromWindow() )
return false;
if( !m_localSettingsPanel->TransferDataFromWindow() )
return false;
if( !padValuesOK() )
return false;
@ -1027,6 +1052,16 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
wxString msg;
int x, y;
if( !Validate() )
return true;
if( !m_panelGeneral->Validate() )
return true;
if( !m_localSettingsPanel->Validate() )
return true;
m_OrientValidator.SetWindow( m_PadOrientCtrl );
m_OrientValidator.TransferFromWindow();
aPad->SetAttribute( code_type[m_PadType->GetSelection()] );
aPad->SetShape( code_shape[m_PadShape->GetSelection()] );
@ -1151,11 +1186,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
y = ValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl );
aPad->SetOffset( wxPoint( x, y ) );
double orient_value = 0;
msg = m_PadOrientCtrl->GetValue();
msg.ToDouble( &orient_value );
aPad->SetOrientation( orient_value );
aPad->SetOrientation( m_OrientValue * 10.0 );
msg = m_PadNumCtrl->GetValue().Left( 4 );
aPad->SetPadName( msg );

View File

@ -39,6 +39,7 @@
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <base_units.h>
#include <wx/valnum.h>
#include <class_board.h>
#include <class_module.h>
@ -80,6 +81,9 @@ private:
bool m_canUpdate;
bool m_canEditNetName; // true only if the caller is the board editor
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
private:
void initValues();
bool padValuesOK(); ///< test if all values are acceptable for the pad
@ -118,6 +122,7 @@ private:
/// Updates the different parameters for the component being edited.
/// Automatically fired from the OK button click.
bool TransferDataFromWindow();
bool TransferDataToWindow();
};
#endif // #ifndef _DIALOG_PAD_PROPERTIES_H_

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 28 2016)
// C++ code generated with wxFormBuilder (version Apr 9 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -142,7 +142,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
m_PadOrientCtrl = new wxTextCtrl( m_panelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerShapeType->Add( m_PadOrientCtrl, 0, wxEXPAND|wxLEFT|wxTOP, 5 );
m_customOrientUnits = new wxStaticText( m_panelGeneral, wxID_ANY, _("0.1 deg"), wxDefaultPosition, wxDefaultSize, 0 );
m_customOrientUnits = new wxStaticText( m_panelGeneral, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 );
m_customOrientUnits->Wrap( -1 );
fgSizerShapeType->Add( m_customOrientUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );

View File

@ -2415,7 +2415,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">0.1 deg</property>
<property name="label">deg</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 28 2016)
// C++ code generated with wxFormBuilder (version Apr 9 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!