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::GetSmallInfoFont( this ).Italic() );
47 m_stHint2->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
48
49#ifdef __WXOSX_MAC__
50 m_mouseCmdsOSX->Show( true );
51 m_mouseCmdsWinLin->Show( false );
52
53 // Disable highlight net option for footprint editor
55 {
56 m_rbToggleSelMac->SetValue( true );
57 m_rbHighlightNetMac->Show( false );
58 }
59#else
60 m_mouseCmdsWinLin->Show( true );
61 m_mouseCmdsOSX->Show( false );
62
63 // Disable highlight net option for footprint editor
65 {
66 m_rbToggleSel->SetValue( true );
67 m_rbHighlightNet->Show( false );
68 }
69#endif
70
71 m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
72}
73
74
76{
77 switch( aMode )
78 {
82
83 default:
84 wxFAIL_MSG( "Invalid ARC_EDIT_MODE" );
85 return 0;
86 }
87};
88
89
90static ARC_EDIT_MODE arcEditModeToEnum( int aIndex )
91{
92 switch( aIndex )
93 {
97
98 default:
99 wxFAIL_MSG( wxString::Format( "Invalid index for ARC_EDIT_MODE: %d", aIndex ) );
101 }
102};
103
104
106{
107 m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45DegreeLimit );
109 m_arcEditMode->SetSelection( arcEditModeToComboIndex( aCfg->m_ArcEditMode ) );
110 m_trackMouseDragCtrl->SetSelection( (int) aCfg->m_TrackDragAction );
111
112 if( aCfg->m_FlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
113 m_rbFlipLeftRight->SetValue( true );
114 else
115 m_rbFlipTopBottom->SetValue( true );
116
117 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
119 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
120
121 m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
122 m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
123 m_magneticGraphicsChoice->SetSelection( !aCfg->m_MagneticItems.graphics );
124
125 /* Set display options */
129
130#ifdef __WXOSX_MAC__
131 if( aCfg->m_CtrlClickHighlight )
132 m_rbHighlightNetMac->SetValue( true );
133 else
134 m_rbToggleSelMac->SetValue( true );
135#else
136 if( aCfg->m_CtrlClickHighlight )
137 m_rbHighlightNet->SetValue( true );
138 else
139 m_rbToggleSel->SetValue( true );
140#endif
141
143 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
145}
146
147
149{
151 m_magneticPads->SetValue( aCfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
153 m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45Limit );
154 m_arcEditMode->SetSelection( arcEditModeToComboIndex( aCfg->m_ArcEditMode ) );
155}
156
157
159{
161 loadFPSettings( GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" ) );
162 else
163 loadPCBSettings( GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) );
164
165 return true;
166}
167
168
170{
172 {
173 if( FOOTPRINT_EDITOR_SETTINGS* cfg = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" ) )
174 {
175 cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
176
177 cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
178 : MAGNETIC_OPTIONS::NO_EFFECT;
179 cfg->m_MagneticItems.graphics = m_magneticGraphics->GetValue();
180
181 cfg->m_Use45Limit = m_cbConstrainHV45Mode->GetValue();
182 cfg->m_ArcEditMode = arcEditModeToEnum( m_arcEditMode->GetSelection() );
183 }
184 }
185 else
186 {
187 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
188 {
189 cfg->m_Display.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
190 cfg->m_Display.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
191 cfg->m_Display.m_RatsnestThickness = m_ratsnestThickness->GetValue();
192
193 cfg->m_Use45DegreeLimit = m_cbConstrainHV45Mode->GetValue();
194 cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
195 cfg->m_ArcEditMode = arcEditModeToEnum( m_arcEditMode->GetSelection() );
196 cfg->m_TrackDragAction = (TRACK_DRAG_ACTION) m_trackMouseDragCtrl->GetSelection();
197
198 cfg->m_FlipDirection = m_rbFlipLeftRight->GetValue() ? FLIP_DIRECTION::LEFT_RIGHT
199 : FLIP_DIRECTION::TOP_BOTTOM;
200
201 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
202 cfg->m_LockingOptions.m_sessionSkipPrompts = m_overrideLocks->GetValue();
203 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
204
205 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
206 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
207 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
208
209 cfg->m_ESCClearsNetHighlight = m_escClearsNetHighlight->GetValue();
210 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
211 cfg->m_ShowCourtyardCollisions = m_cbCourtyardCollisions->GetValue();
212
213#ifdef __WXOSX_MAC__
214 cfg->m_CtrlClickHighlight = m_rbHighlightNetMac->GetValue();
215#else
216 cfg->m_CtrlClickHighlight = m_rbHighlightNet->GetValue();
217#endif
218 }
219 }
220
221 return true;
222}
223
224
226{
228 {
230 cfg.Load(); // Loading without a file will init to defaults
231
232 loadFPSettings( &cfg );
233 }
234 else
235 {
236 PCBNEW_SETTINGS cfg;
237 cfg.Load(); // Loading without a file will init to defaults
238
239 loadPCBSettings( &cfg );
240 }
241}
ARC_EDIT_MODE
Settings for arc editing.
Definition: app_settings.h:52
@ KEEP_ENDPOINTS_OR_START_DIRECTION
Whe editing endpoints, the other end remains in place.
@ KEEP_CENTER_ENDS_ADJUST_ANGLE
When editing endpoints, only the angle is adjusted.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
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 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 GetSmallInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:162
static ARC_EDIT_MODE arcEditModeToEnum(int aIndex)
static int arcEditModeToComboIndex(ARC_EDIT_MODE aMode)
static ARC_EDIT_MODE arcEditModeToEnum(int aIndex)
static int arcEditModeToComboIndex(ARC_EDIT_MODE aMode)
MAGNETIC_OPTIONS
TRACK_DRAG_ACTION
see class PGM_BASE
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads