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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
22#include <widgets/ui_common.h>
26
27
28#define MIN_GRID 25
29
31 UNITS_PROVIDER* aUnitsProvider,
32 wxWindow* aEventSource ) :
34 m_lineWidth( aUnitsProvider, aEventSource, m_lineWidthLabel, m_lineWidthCtrl,
36 m_textSize( aUnitsProvider, aEventSource, m_textSizeLabel, m_textSizeCtrl,
38 m_pinLength( aUnitsProvider, aEventSource, m_pinLengthLabel, m_pinLengthCtrl,
40 m_pinNameSize( aUnitsProvider, aEventSource ,m_pinNameSizeLabel, m_pinNameSizeCtrl,
42 m_pinNumberSize( aUnitsProvider, aEventSource, m_pinNumSizeLabel, m_pinNumSizeCtrl,
44 m_pinPitch( aUnitsProvider, aEventSource, m_pinPitchLabel, m_pinPitchCtrl, m_pinPitchUnits )
45{
46 m_widthHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
47}
48
49
51{
52 m_lineWidth.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.line_width ) );
53 m_textSize.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.text_size ) );
54 m_pinLength.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.pin_length ) );
55 m_pinNumberSize.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.pin_num_size ) );
56 m_pinNameSize.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.pin_name_size ) );
57 m_pinPitch.SetValue( schIUScale.MilsToIU( aCfg->m_Repeat.pin_step ) );
58 m_spinRepeatLabel->SetValue( aCfg->m_Repeat.label_delta );
60}
61
62
68
69
71{
73 {
74 cfg->m_Defaults.line_width = schIUScale.IUToMils( m_lineWidth.GetIntValue() );
75 cfg->m_Defaults.text_size = schIUScale.IUToMils( m_textSize.GetIntValue() );
76 cfg->m_Defaults.pin_length = schIUScale.IUToMils( m_pinLength.GetIntValue() );
77 cfg->m_Defaults.pin_num_size = schIUScale.IUToMils( m_pinNumberSize.GetIntValue() );
78 cfg->m_Defaults.pin_name_size = schIUScale.IUToMils( m_pinNameSize.GetIntValue() );
79 cfg->m_Repeat.label_delta = m_spinRepeatLabel->GetValue();
80 cfg->m_Repeat.pin_step = schIUScale.IUToMils( m_pinPitch.GetIntValue() );
81 cfg->m_dragPinsAlongWithEdges = m_dragPinsWithEdges->GetValue();
82
83 // Force pin_step to a grid multiple
84 cfg->m_Repeat.pin_step = KiROUND( double( cfg->m_Repeat.pin_step ) / MIN_GRID ) * MIN_GRID;
85 }
86
87 return true;
88}
89
90
92{
93 int pitch_mils = schIUScale.IUToMils( m_pinPitch.GetIntValue() );
94
95 // Force pin_step to a grid multiple
96 pitch_mils = KiROUND( double( pitch_mils ) / MIN_GRID ) * MIN_GRID;
97
98 m_pinPitch.SetValue( schIUScale.MilsToIU( pitch_mils ) );
99
100 aEvent.Skip();
101}
102
103
105{
107 cfg.Load(); // Loading without a file will init to defaults
108
109 loadSymEditorSettings( &cfg );
110}
111
112
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
PANEL_SYM_EDITING_OPTIONS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
#define MIN_GRID
see class PGM_BASE
T * GetAppSettings(const char *aFilename)
Functions to provide common constants and other functions to assist in making a consistent UI.