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-2021 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, EDA_BASE_FRAME* aUnitsProvider,
34 bool isFootprintEditor ) :
35 PANEL_EDIT_OPTIONS_BASE( aParent ),
36 m_isFootprintEditor( isFootprintEditor ),
37 m_rotationAngle( aUnitsProvider, pcbIUScale, m_rotationAngleLabel, m_rotationAngleCtrl,
38 m_rotationAngleUnits )
39{
44
46
47#ifdef __WXOSX_MAC__
48 m_mouseCmdsOSX->Show( true );
49 m_mouseCmdsWinLin->Show( false );
50 // Disable highlight net option for footprint editor
52#else
53 m_mouseCmdsWinLin->Show( true );
54 m_mouseCmdsOSX->Show( false );
55 // Disable highlight net option for footprint editor
57#endif
58
59 m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
60}
61
62
64{
66 m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
67 m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
69 m_flipLeftRight->SetValue( aCfg->m_FlipLeftRight );
71
72 /* Set display options */
75
76 switch( aCfg->m_TrackDragAction )
77 {
78 case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break;
79 case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break;
80 case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break;
81 }
82
83#ifdef __WXOSX_MAC__
84 m_rbCtrlClickActionMac->SetSelection( aCfg->m_CtrlClickHighlight );
85#else
86 m_rbCtrlClickAction->SetSelection( aCfg->m_CtrlClickHighlight );
87#endif
88
89 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
90 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
91 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
92
94}
95
96
98{
102 m_cbFpGraphic45Mode->SetValue( aCfg->m_Use45Limit );
103}
104
105
107{
108 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
109
111 {
113
114 loadFPSettings( cfg );
115 }
116 else
117 {
119
120 loadPCBSettings( cfg );
121 }
122
123 return true;
124}
125
126
128{
129 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
130
132 {
134
136
140
141 cfg->m_Use45Limit = m_cbFpGraphic45Mode->GetValue();
142 }
143 else
144 {
146
149
151
152 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
153 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
154 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
155
156 cfg->m_FlipLeftRight = m_flipLeftRight->GetValue();
158 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
159 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
160 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
161
162 if( m_rbTrackDragMove->GetValue() )
164 else if( m_rbTrackDrag45->GetValue() )
166 else if( m_rbTrackDragFree->GetValue() )
168
169#ifdef __WXOSX_MAC__
170 cfg->m_CtrlClickHighlight = m_rbCtrlClickActionMac->GetSelection();
171#else
172 cfg->m_CtrlClickHighlight = m_rbCtrlClickAction->GetSelection();
173#endif
174
175 cfg->m_Use45DegreeLimit = m_cbPcbGraphic45Mode->GetValue();
176 }
177
178 return true;
179}
180
181
183{
185 {
187 cfg.Load(); // Loading without a file will init to defaults
188
189 loadFPSettings( &cfg );
190 }
191 else
192 {
193 PCBNEW_SETTINGS cfg;
194 cfg.Load(); // Loading without a file will init to defaults
195
196 loadPCBSettings( &cfg );
197 }
198}
199
200
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
The base frame for deriving all KiCad main window classes.
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)
bool TransferDataToWindow() override
void ResetPanel() override
Reset the contents of this panel.
void loadPCBSettings(PCBNEW_SETTINGS *aCfg)
bool TransferDataFromWindow() override
UNIT_BINDER m_rotationAngle
PANEL_EDIT_OPTIONS(wxWindow *aParent, EDA_BASE_FRAME *aUnitsProvider, bool isFootprintEditor)
DISPLAY_OPTIONS m_Display
EDA_ANGLE m_RotationAngle
TRACK_DRAG_ACTION m_TrackDragAction
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