From 73a8cd618042c5492711e4e79034654e81cd5e81 Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Mon, 12 May 2014 18:57:46 +0200 Subject: [PATCH] Added eeschema option for the default pin length --- eeschema/dialogs/dialog_eeschema_options.h | 3 + .../dialogs/dialog_eeschema_options_base.cpp | 23 +- .../dialogs/dialog_eeschema_options_base.fbp | 255 +++++++++++++++++- .../dialogs/dialog_eeschema_options_base.h | 7 +- eeschema/eeschema_config.cpp | 22 +- eeschema/general.h | 8 +- eeschema/lib_pin.cpp | 2 +- eeschema/lib_pin.h | 1 - eeschema/pinedit.cpp | 15 +- 9 files changed, 315 insertions(+), 21 deletions(-) diff --git a/eeschema/dialogs/dialog_eeschema_options.h b/eeschema/dialogs/dialog_eeschema_options.h index 01ce909728..1d49bdd694 100644 --- a/eeschema/dialogs/dialog_eeschema_options.h +++ b/eeschema/dialogs/dialog_eeschema_options.h @@ -58,6 +58,9 @@ public: void SetLineWidth( int aWidth ) { m_spinLineWidth->SetValue( aWidth ); } int GetLineWidth( void ) { return m_spinLineWidth->GetValue(); } + void SetPinLength( int aLength ) { m_spinPinLength->SetValue( aLength ); } + int GetPinLength( void ) { return m_spinPinLength->GetValue(); } + void SetTextSize( int text_size ) { m_spinTextSize->SetValue( text_size ); } int GetTextSize( void ) { return m_spinTextSize->GetValue(); } diff --git a/eeschema/dialogs/dialog_eeschema_options_base.cpp b/eeschema/dialogs/dialog_eeschema_options_base.cpp index 6dbad7738f..a64f18ea81 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.cpp +++ b/eeschema/dialogs/dialog_eeschema_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -35,7 +35,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx bSizer3 = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 10, 3, 0, 0 ); + fgSizer1 = new wxFlexGridSizer( 11, 3, 0, 0 ); fgSizer1->AddGrowableCol( 0 ); fgSizer1->AddGrowableCol( 1 ); fgSizer1->AddGrowableCol( 2 ); @@ -89,6 +89,17 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx m_staticLineWidthUnits->Wrap( -1 ); fgSizer1->Add( m_staticLineWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 3 ); + m_staticText52 = new wxStaticText( m_panel1, wxID_ANY, _("Default pin length:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText52->Wrap( -1 ); + fgSizer1->Add( m_staticText52, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 3 ); + + m_spinPinLength = new wxSpinCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, 50, 1000, 100 ); + fgSizer1->Add( m_spinPinLength, 0, wxALIGN_CENTER|wxALL|wxEXPAND, 3 ); + + m_staticPinLengthUnits = new wxStaticText( m_panel1, wxID_ANY, _("mils"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticPinLengthUnits->Wrap( -1 ); + fgSizer1->Add( m_staticPinLengthUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 3 ); + m_staticText7 = new wxStaticText( m_panel1, wxID_ANY, _("Default text &size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText7->Wrap( -1 ); fgSizer1->Add( m_staticText7, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 3 ); @@ -236,7 +247,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText15, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName1 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName1->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName1, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText161 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 2"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -244,7 +254,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText161, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName2 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName2->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName2, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText17 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 3"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -252,7 +261,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText17, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName3 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName3->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName3, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText18 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 4"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -260,7 +268,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText18, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName4 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName4->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName4, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText19 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 5"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -268,7 +275,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName5 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName5->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName5, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText20 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 6"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -276,7 +282,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName6 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName6->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName6, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText21 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 7"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -284,7 +289,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText21, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName7 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName7->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName7, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); m_staticText22 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 8"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -292,7 +296,6 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx fgSizer2->Add( m_staticText22, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 ); m_fieldName8 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_fieldName8->SetMaxLength( 0 ); fgSizer2->Add( m_fieldName8, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); diff --git a/eeschema/dialogs/dialog_eeschema_options_base.fbp b/eeschema/dialogs/dialog_eeschema_options_base.fbp index 921c443c25..b8e18ad1a9 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.fbp +++ b/eeschema/dialogs/dialog_eeschema_options_base.fbp @@ -288,7 +288,7 @@ fgSizer1 wxFLEX_GROWMODE_SPECIFIED none - 10 + 11 0 3 @@ -1231,6 +1231,259 @@ + + 3 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Default pin length: + + 0 + + + 0 + + 1 + m_staticText52 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 100 + 1000 + + 0 + + 50 + + 0 + + 1 + m_spinPinLength + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS|wxSP_WRAP + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mils + + 0 + + + 0 + + 1 + m_staticPinLengthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + 3 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT diff --git a/eeschema/dialogs/dialog_eeschema_options_base.h b/eeschema/dialogs/dialog_eeschema_options_base.h index 0b0581e117..4ed5cb762a 100644 --- a/eeschema/dialogs/dialog_eeschema_options_base.h +++ b/eeschema/dialogs/dialog_eeschema_options_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,8 +11,6 @@ #include #include #include -class DIALOG_SHIM; - #include "dialog_shim.h" #include #include @@ -69,6 +67,9 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM wxStaticText* m_staticText5; wxSpinCtrl* m_spinLineWidth; wxStaticText* m_staticLineWidthUnits; + wxStaticText* m_staticText52; + wxSpinCtrl* m_spinPinLength; + wxStaticText* m_staticPinLengthUnits; wxStaticText* m_staticText7; wxSpinCtrl* m_spinTextSize; wxStaticText* m_staticTextSizeUnits; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 2a0cccf33b..aca02062da 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -84,7 +84,7 @@ int GetDefaultLineThickness() return s_drawDefaultLineThickness; } -void SetDefaultLineThickness( int aThickness) +void SetDefaultLineThickness( int aThickness ) { if( aThickness >=1 ) s_drawDefaultLineThickness = aThickness; @@ -92,6 +92,21 @@ void SetDefaultLineThickness( int aThickness) s_drawDefaultLineThickness = 1; } +/* + * Default pin length + */ +static int s_defaultPinLength; + +int GetDefaultPinLength() +{ + return s_defaultPinLength; +} + +void SetDefaultPinLength( int aLength ) +{ + s_defaultPinLength = aLength; +} + EDA_COLOR_T GetLayerColor( LayerNumber aLayer ) { return s_layerColor[aLayer]; @@ -269,6 +284,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event ) dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() ); dlg.SetBusWidth( GetDefaultBusThickness() ); dlg.SetLineWidth( GetDefaultLineThickness() ); + dlg.SetPinLength( GetDefaultPinLength() ); dlg.SetTextSize( GetDefaultLabelSize() ); dlg.SetRepeatHorizontal( g_RepeatStep.x ); dlg.SetRepeatVertical( g_RepeatStep.y ); @@ -317,6 +333,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event ) SetDefaultBusThickness( dlg.GetBusWidth() ); SetDefaultLineThickness( dlg.GetLineWidth() ); + SetDefaultPinLength( dlg.GetPinLength() ); SetDefaultLabelSize( dlg.GetTextSize() ); g_RepeatStep.x = dlg.GetRepeatHorizontal(); g_RepeatStep.y = dlg.GetRepeatVertical(); @@ -477,6 +494,7 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) static const wxChar DefaultBusWidthEntry[] = wxT( "DefaultBusWidth" ); static const wxChar DefaultDrawLineWidthEntry[] = wxT( "DefaultDrawLineWidth" ); +static const wxChar DefaultPinLengthEntry[] = wxT( "DefaultPinLength" ); static const wxChar ShowHiddenPinsEntry[] = wxT( "ShowHiddenPins" ); static const wxChar HorzVertLinesOnlyEntry[] = wxT( "HorizVertLinesOnly" ); static const wxChar PreviewFramePositionXEntry[] = wxT( "PreviewFramePositionX" ); @@ -602,6 +620,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) SetDefaultBusThickness( aCfg->Read( DefaultBusWidthEntry, 12l ) ); SetDefaultLineThickness( aCfg->Read( DefaultDrawLineWidthEntry, 6l ) ); + SetDefaultPinLength( aCfg->Read( DefaultPinLengthEntry, 300l ) ); aCfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false ); aCfg->Read( HorzVertLinesOnlyEntry, &m_forceHVLines, true ); @@ -691,6 +710,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) aCfg->Write( DefaultBusWidthEntry, (long) GetDefaultBusThickness() ); aCfg->Write( DefaultDrawLineWidthEntry, (long) GetDefaultLineThickness() ); + aCfg->Write( DefaultPinLengthEntry, (long) GetDefaultPinLength() ); aCfg->Write( ShowHiddenPinsEntry, m_showAllPins ); aCfg->Write( HorzVertLinesOnlyEntry, GetForceHVLines() ); diff --git a/eeschema/general.h b/eeschema/general.h index 9c60345d0c..83d50569b3 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -74,7 +74,13 @@ extern SCH_SHEET* g_RootSheet; * default thickness line value (i.e. = 0 ). */ int GetDefaultLineThickness(); -void SetDefaultLineThickness( int aThickness); +void SetDefaultLineThickness( int aThickness ); + +/** + * Default length for new pins in module editor + */ +int GetDefaultPinLength(); +void SetDefaultPinLength( int aLength ); /** * Default line thickness used to draw/plot busses. diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 29c4aee929..f980e02984 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -185,7 +185,7 @@ const wxChar* MsgPinElectricType[] = LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) : LIB_ITEM( LIB_PIN_T, aParent ) { - m_length = DEFAULT_PIN_LENGTH; // default Pin len + m_length = GetDefaultPinLength(); // default Pin len m_orientation = PIN_RIGHT; // Pin orient: Up, Down, Left, Right m_shape = NONE; // Pin shape, bitwise. m_type = PIN_UNSPECIFIED; // electrical type of pin diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index dd85740de6..a6fb715bfb 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -33,7 +33,6 @@ #define TARGET_PIN_RADIUS 12 // Circle diameter drawn at the active end of pins -#define DEFAULT_PIN_LENGTH 300 // Default Length of a pin when it is created. // pins: special symbols sizes #define INVERT_PIN_RADIUS 30 // Radius of inverted pin circle. diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 202a7d691f..287f9c5233 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -59,13 +59,22 @@ static wxPoint PinPreviousPos; static int LastPinType = PIN_INPUT; static int LastPinOrient = PIN_RIGHT; static int LastPinShape = NONE; -static int LastPinLength = DEFAULT_PIN_LENGTH; static int LastPinNameSize = DEFAULT_TEXT_SIZE; static int LastPinNumSize = DEFAULT_TEXT_SIZE; static bool LastPinCommonConvert = false; static bool LastPinCommonUnit = false; static bool LastPinVisible = true; +// The -1 is a non-valid value to trigger delayed initialization +static int LastPinLength = -1; + +static int GetLastPinLength() +{ + if( LastPinLength == -1 ) + LastPinLength = GetDefaultPinLength(); + + return LastPinLength; +} void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) { @@ -136,7 +145,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) pin->SetNumber( dlg.GetPadName() ); pin->SetNumberTextSize( LastPinNumSize ); pin->SetOrientation( LastPinOrient ); - pin->SetLength( LastPinLength ); + pin->SetLength( GetLastPinLength() ); pin->SetType( LastPinType ); pin->SetShape( LastPinShape ); pin->SetConversion( ( LastPinCommonConvert ) ? 0 : m_convert ); @@ -389,7 +398,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) pin->SetFlags( IS_LINKED ); pin->Move( GetCrossHairPosition( true ) ); - pin->SetLength( LastPinLength ); + pin->SetLength( GetLastPinLength() ); pin->SetOrientation( LastPinOrient ); pin->SetType( LastPinType ); pin->SetShape( LastPinShape );