KiCad PCB EDA Suite
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
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{
65 m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
66 m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
68 m_flipLeftRight->SetValue( aCfg->m_FlipLeftRight );
71 m_arcEditMode->SetSelection(
73
74 /* Set display options */
77
78 switch( aCfg->m_TrackDragAction )
79 {
80 case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break;
81 case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break;
82 case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break;
83 }
84
85#ifdef __WXOSX_MAC__
86 m_rbCtrlClickActionMac->SetSelection( aCfg->m_CtrlClickHighlight );
87#else
88 m_rbCtrlClickAction->SetSelection( aCfg->m_CtrlClickHighlight );
89#endif
90
91 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
92 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
93 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
94
96}
97
98
100{
104 m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45Limit );
105 m_arcEditMode->SetSelection(
107}
108
109
111{
112 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
113
115 {
117
118 loadFPSettings( cfg );
119 }
120 else
121 {
123
124 loadPCBSettings( cfg );
125 }
126
127 return true;
128}
129
130
132{
133 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
134
136 {
138
140
144
145 cfg->m_Use45Limit = m_cbConstrainHV45Mode->GetValue();
146
147 cfg->m_ArcEditMode = m_arcEditMode->GetSelection() == 0
150 }
151 else
152 {
154
157
159
160 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
161 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
162 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
163
164 cfg->m_FlipLeftRight = m_flipLeftRight->GetValue();
166 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
167 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
168 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
169
170 if( m_rbTrackDragMove->GetValue() )
172 else if( m_rbTrackDrag45->GetValue() )
174 else if( m_rbTrackDragFree->GetValue() )
176
177#ifdef __WXOSX_MAC__
178 cfg->m_CtrlClickHighlight = m_rbCtrlClickActionMac->GetSelection();
179#else
180 cfg->m_CtrlClickHighlight = m_rbCtrlClickAction->GetSelection();
181#endif
182
183 cfg->m_Use45DegreeLimit = m_cbConstrainHV45Mode->GetValue();
185
186 cfg->m_ArcEditMode = m_arcEditMode->GetSelection() == 0
189 }
190
191 return true;
192}
193
194
196{
198 {
200 cfg.Load(); // Loading without a file will init to defaults
201
202 loadFPSettings( &cfg );
203 }
204 else
205 {
206 PCBNEW_SETTINGS cfg;
207 cfg.Load(); // Loading without a file will init to defaults
208
209 loadPCBSettings( &cfg );
210 }
211}
212
213
@ KEEP_ENDPOINTS_OR_START_DIRECTION
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
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
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
T * GetAppSettings(bool aLoadNow=true)
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
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads