KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_edit_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 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 1992-2022 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 <string_utils.h>
28#include <pcbnew_settings.h>
30#include <panel_edit_options.h>
31
32
33PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider,
34 wxWindow* aEventSource, bool isFootprintEditor ) :
35 PANEL_EDIT_OPTIONS_BASE( aParent ),
36 m_isFootprintEditor( isFootprintEditor ),
37 m_rotationAngle( aUnitsProvider, aEventSource, m_rotationAngleLabel, m_rotationAngleCtrl,
38 m_rotationAngleUnits )
39{
43
44 m_rotationAngle.SetUnits( EDA_UNITS::DEGREES );
45
46#ifdef __WXOSX_MAC__
47 m_mouseCmdsOSX->Show( true );
48 m_mouseCmdsWinLin->Show( false );
49 // Disable highlight net option for footprint editor
51#else
52 m_mouseCmdsWinLin->Show( true );
53 m_mouseCmdsOSX->Show( false );
54 // Disable highlight net option for footprint editor
56#endif
57
58 m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
59}
60
61
63{
66 m_arcEditMode->SetSelection( (int) aCfg->m_ArcEditMode );
67 m_trackMouseDragCtrl->SetSelection( (int) aCfg->m_TrackDragAction );
68 m_flipLeftRight->SetValue( aCfg->m_FlipLeftRight );
69 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
70 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
71
72 m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
73 m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
75
76 /* Set display options */
80
81#ifdef __WXOSX_MAC__
82 m_rbCtrlClickActionMac->SetSelection( aCfg->m_CtrlClickHighlight );
83#else
84 m_rbCtrlClickAction->SetSelection( aCfg->m_CtrlClickHighlight );
85#endif
86
88 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
90
91 m_styleFields->SetValue( aCfg->m_StyleFootprintFields );
93}
94
95
97{
99 m_magneticPads->SetValue( aCfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
101 m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45Limit );
102 m_arcEditMode->SetSelection(
103 aCfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS ? 0 : 1 );
104}
105
106
108{
109 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
110
112 {
114
115 loadFPSettings( cfg );
116 }
117 else
118 {
120
121 loadPCBSettings( cfg );
122 }
123
124 return true;
125}
126
127
129{
130 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
131
133 {
135
137
138 cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
139 : MAGNETIC_OPTIONS::NO_EFFECT;
141
142 cfg->m_Use45Limit = m_cbConstrainHV45Mode->GetValue();
143 cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
144 }
145 else
146 {
148
152
153 cfg->m_Use45DegreeLimit = m_cbConstrainHV45Mode->GetValue();
155 cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
157 cfg->m_FlipLeftRight = m_flipLeftRight->GetValue();
158 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
159 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
160
161 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
162 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
163 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
164
166 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
168
169 cfg->m_StyleFootprintFields = m_styleFields->GetValue();
171
172
173#ifdef __WXOSX_MAC__
174 cfg->m_CtrlClickHighlight = m_rbCtrlClickActionMac->GetSelection();
175#else
176 cfg->m_CtrlClickHighlight = m_rbCtrlClickAction->GetSelection();
177#endif
178 }
179
180 return true;
181}
182
183
185{
187 {
189 cfg.Load(); // Loading without a file will init to defaults
190
191 loadFPSettings( &cfg );
192 }
193 else
194 {
195 PCBNEW_SETTINGS cfg;
196 cfg.Load(); // Loading without a file will init to defaults
197
198 loadPCBSettings( &cfg );
199 }
200}
201
202
ARC_EDIT_MODE
Settings for arc editing.
Definition: app_settings.h:52
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
Class PANEL_EDIT_OPTIONS_BASE.
wxStaticBoxSizer * m_mouseCmdsWinLin
wxCheckBox * m_OptDisplayCurvedRatsnestLines
wxStaticBoxSizer * m_mouseCmdsOSX
wxSpinCtrlDouble * m_ratsnestThickness
void loadFPSettings(FOOTPRINT_EDITOR_SETTINGS *aCfg)
PANEL_EDIT_OPTIONS(wxWindow *aParent, UNITS_PROVIDER *aUnitsProvider, wxWindow *aEventSource, bool isFootprintEditor)
bool TransferDataToWindow() override
void ResetPanel() override
Reset the contents of this panel.
void loadPCBSettings(PCBNEW_SETTINGS *aCfg)
bool TransferDataFromWindow() override
UNIT_BINDER m_rotationAngle
DISPLAY_OPTIONS m_Display
EDA_ANGLE m_RotationAngle
ARC_EDIT_MODE m_ArcEditMode
TRACK_DRAG_ACTION m_TrackDragAction
bool m_StyleFootprintTextAndGraphics
bool m_ShowCourtyardCollisions
MAGNETIC_SETTINGS m_MagneticItems
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
virtual EDA_ANGLE GetAngleValue()
virtual void SetAngleValue(const EDA_ANGLE &aValue)
MAGNETIC_OPTIONS
TRACK_DRAG_ACTION
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads