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
92
94{
96 m_magneticPads->SetValue( aCfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
98 m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45Limit );
99 m_arcEditMode->SetSelection(
100 aCfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS ? 0 : 1 );
101}
102
103
105{
107
109 {
111
112 loadFPSettings( cfg );
113 }
114 else
115 {
117
118 loadPCBSettings( cfg );
119 }
120
121 return true;
122}
123
124
126{
128
130 {
132
134
135 cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
136 : MAGNETIC_OPTIONS::NO_EFFECT;
138
139 cfg->m_Use45Limit = m_cbConstrainHV45Mode->GetValue();
140 cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
141 }
142 else
143 {
145
149
150 cfg->m_Use45DegreeLimit = m_cbConstrainHV45Mode->GetValue();
152 cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
154 cfg->m_FlipLeftRight = m_flipLeftRight->GetValue();
155 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
156 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
157
158 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
159 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
160 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
161
163 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
165
166
167#ifdef __WXOSX_MAC__
168 cfg->m_CtrlClickHighlight = m_rbCtrlClickActionMac->GetSelection();
169#else
170 cfg->m_CtrlClickHighlight = m_rbCtrlClickAction->GetSelection();
171#endif
172 }
173
174 return true;
175}
176
177
179{
181 {
183 cfg.Load(); // Loading without a file will init to defaults
184
185 loadFPSettings( &cfg );
186 }
187 else
188 {
189 PCBNEW_SETTINGS cfg;
190 cfg.Load(); // Loading without a file will init to defaults
191
192 loadPCBSettings( &cfg );
193 }
194}
195
196
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_ShowCourtyardCollisions
MAGNETIC_SETTINGS m_MagneticItems
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
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
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads