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 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, 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 m_stHint1->SetFont( KIUI::GetInfoFont( this ).Italic() );
47 m_stHint2->SetFont( KIUI::GetInfoFont( this ).Italic() );
48
49#ifdef __WXOSX_MAC__
50 m_mouseCmdsOSX->Show( true );
51 m_mouseCmdsWinLin->Show( false );
52 // Disable highlight net option for footprint editor
54#else
55 m_mouseCmdsWinLin->Show( true );
56 m_mouseCmdsOSX->Show( false );
57 // Disable highlight net option for footprint editor
59#endif
60
61 m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
62}
63
64
66{
69 m_arcEditMode->SetSelection( (int) aCfg->m_ArcEditMode );
70 m_trackMouseDragCtrl->SetSelection( (int) aCfg->m_TrackDragAction );
71
72 if( aCfg->m_FlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
73 m_rbFlipLeftRight->SetValue( true );
74 else
75 m_rbFlipTopBottom->SetValue( true );
76
77 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
79 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
80
81 m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
82 m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
84
85 /* Set display options */
89
90#ifdef __WXOSX_MAC__
91 m_rbCtrlClickActionMac->SetSelection( aCfg->m_CtrlClickHighlight );
92#else
93 m_rbCtrlClickAction->SetSelection( aCfg->m_CtrlClickHighlight );
94#endif
95
97 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
99}
100
101
103{
105 m_magneticPads->SetValue( aCfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
107 m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45Limit );
108 m_arcEditMode->SetSelection(
109 aCfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS ? 0 : 1 );
110}
111
112
114{
116
118 {
120
121 loadFPSettings( cfg );
122 }
123 else
124 {
125 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
126
127 loadPCBSettings( cfg );
128 }
129
130 return true;
131}
132
133
135{
137
139 {
141
143
144 cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
145 : MAGNETIC_OPTIONS::NO_EFFECT;
147
148 cfg->m_Use45Limit = m_cbConstrainHV45Mode->GetValue();
149 cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
150 }
151 else
152 {
153 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
154
158
159 cfg->m_Use45DegreeLimit = m_cbConstrainHV45Mode->GetValue();
161 cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
163
164 cfg->m_FlipDirection = m_rbFlipLeftRight->GetValue() ? FLIP_DIRECTION::LEFT_RIGHT
165 : FLIP_DIRECTION::TOP_BOTTOM;
166
167 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
169 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
170
171 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
172 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
173 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
174
176 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
178
179
180#ifdef __WXOSX_MAC__
181 cfg->m_CtrlClickHighlight = m_rbCtrlClickActionMac->GetSelection();
182#else
183 cfg->m_CtrlClickHighlight = m_rbCtrlClickAction->GetSelection();
184#endif
185 }
186
187 return true;
188}
189
190
192{
194 {
196 cfg.Load(); // Loading without a file will init to defaults
197
198 loadFPSettings( &cfg );
199 }
200 else
201 {
202 PCBNEW_SETTINGS cfg;
203 cfg.Load(); // Loading without a file will init to defaults
204
205 loadPCBSettings( &cfg );
206 }
207}
208
209
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.
wxCheckBox * m_OptDisplayCurvedRatsnestLines
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
LOCKING_OPTIONS m_LockingOptions
bool m_ShowCourtyardCollisions
MAGNETIC_SETTINGS m_MagneticItems
FLIP_DIRECTION m_FlipDirection
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
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)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:155
MAGNETIC_OPTIONS
TRACK_DRAG_ACTION
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1073
see class PGM_BASE
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads