KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_sym_editing_options.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2009 Wayne Stambaugh <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <pgm_base.h>
26#include <widgets/ui_common.h>
30
31
32#define MIN_GRID 25
33
35 UNITS_PROVIDER* aUnitsProvider,
36 wxWindow* aEventSource ) :
38 m_lineWidth( aUnitsProvider, aEventSource, m_lineWidthLabel, m_lineWidthCtrl,
39 m_lineWidthUnits ),
40 m_textSize( aUnitsProvider, aEventSource, m_textSizeLabel, m_textSizeCtrl,
41 m_textSizeUnits ),
42 m_pinLength( aUnitsProvider, aEventSource, m_pinLengthLabel, m_pinLengthCtrl,
43 m_pinLengthUnits ),
44 m_pinNameSize( aUnitsProvider, aEventSource ,m_pinNameSizeLabel, m_pinNameSizeCtrl,
45 m_pinNameSizeUnits ),
46 m_pinNumberSize( aUnitsProvider, aEventSource, m_pinNumSizeLabel, m_pinNumSizeCtrl,
47 m_pinNumSizeUnits ),
48 m_pinPitch( aUnitsProvider, aEventSource, m_pinPitchLabel, m_pinPitchCtrl, m_pinPitchUnits )
49{
50 m_widthHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
51}
52
53
55{
62 m_spinRepeatLabel->SetValue( aCfg->m_Repeat.label_delta );
64}
65
66
68{
69 loadSymEditorSettings( GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) );
70 return true;
71}
72
73
75{
76 if( SYMBOL_EDITOR_SETTINGS* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" ) )
77 {
78 cfg->m_Defaults.line_width = schIUScale.IUToMils( m_lineWidth.GetIntValue() );
79 cfg->m_Defaults.text_size = schIUScale.IUToMils( m_textSize.GetIntValue() );
80 cfg->m_Defaults.pin_length = schIUScale.IUToMils( m_pinLength.GetIntValue() );
81 cfg->m_Defaults.pin_num_size = schIUScale.IUToMils( m_pinNumberSize.GetIntValue() );
82 cfg->m_Defaults.pin_name_size = schIUScale.IUToMils( m_pinNameSize.GetIntValue() );
83 cfg->m_Repeat.label_delta = m_spinRepeatLabel->GetValue();
84 cfg->m_Repeat.pin_step = schIUScale.IUToMils( m_pinPitch.GetIntValue() );
85 cfg->m_dragPinsAlongWithEdges = m_dragPinsWithEdges->GetValue();
86
87 // Force pin_step to a grid multiple
88 cfg->m_Repeat.pin_step = KiROUND( double( cfg->m_Repeat.pin_step ) / MIN_GRID ) * MIN_GRID;
89 }
90
91 return true;
92}
93
94
96{
97 int pitch_mils = schIUScale.IUToMils( m_pinPitch.GetIntValue() );
98
99 // Force pin_step to a grid multiple
100 pitch_mils = KiROUND( double( pitch_mils ) / MIN_GRID ) * MIN_GRID;
101
102 m_pinPitch.SetValue( schIUScale.MilsToIU( pitch_mils ) );
103
104 aEvent.Skip();
105}
106
107
109{
111 cfg.Load(); // Loading without a file will init to defaults
112
113 loadSymEditorSettings( &cfg );
114}
115
116
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
Class PANEL_SYM_EDITING_OPTIONS_BASE.
PANEL_SYM_EDITING_OPTIONS(wxWindow *aWindow, UNITS_PROVIDER *aUnitsProvider, wxWindow *aEventSource)
void onKillFocusPinPitch(wxFocusEvent &aEvent) override
void ResetPanel() override
Reset the contents of this panel.
void loadSymEditorSettings(SYMBOL_EDITOR_SETTINGS *aCfg)
int GetIntValue()
Definition: unit_binder.h:134
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156
#define MIN_GRID
see class PGM_BASE
constexpr int IUToMils(int iu) const
Definition: base_units.h:103
constexpr int MilsToIU(int mils) const
Definition: base_units.h:97
Functions to provide common constants and other functions to assist in making a consistent UI.