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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
22#include <string_utils.h>
24#include <pcbnew_settings.h>
26#include <panel_edit_options.h>
28
29
30PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider,
31 wxWindow* aEventSource, bool isFootprintEditor ) :
32 PANEL_EDIT_OPTIONS_BASE( aParent ),
33 m_isFootprintEditor( isFootprintEditor ),
34 m_rotationAngle( aUnitsProvider, aEventSource, m_rotationAngleLabel, m_rotationAngleCtrl,
36{
40
42
43 m_stHint1->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
44 m_stHint2->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
45
46#ifdef __WXOSX_MAC__
47 m_mouseCmdsOSX->Show( true );
48 m_mouseCmdsWinLin->Show( false );
49
50 // Disable highlight net option for footprint editor
52 {
53 m_rbToggleSelMac->SetValue( true );
54 m_rbHighlightNetMac->Show( false );
55 }
56#else
57 m_mouseCmdsWinLin->Show( true );
58 m_mouseCmdsOSX->Show( false );
59
60 // Disable highlight net option for footprint editor
62 {
63 m_rbToggleSel->SetValue( true );
64 m_rbHighlightNet->Show( false );
65 }
66#endif
67
68 m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
69}
70
71
73{
74 switch( aMode )
75 {
79 default: wxFAIL_MSG( "Invalid ARC_EDIT_MODE" ); return 0;
80 }
81};
82
83
84static ARC_EDIT_MODE arcEditModeToEnum( int aIndex )
85{
86 switch( aIndex )
87 {
91
92 default:
93 wxFAIL_MSG( wxString::Format( "Invalid index for ARC_EDIT_MODE: %d", aIndex ) );
95 }
96};
97
98
100{
102 m_rotationAngle.SetAngleValue( aCfg->m_RotationAngle );
103 m_arcEditMode->SetSelection( arcEditModeToComboIndex( aCfg->m_ArcEditMode ) );
104 m_trackMouseDragCtrl->SetSelection( (int) aCfg->m_TrackDragAction );
105
107 m_rbFlipLeftRight->SetValue( true );
108 else
109 m_rbFlipTopBottom->SetValue( true );
110
111 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
112 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
113
114 m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
115 m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
116 m_magneticGraphicsChoice->SetSelection( !aCfg->m_MagneticItems.graphics );
117
118 /* Set display options */
122
123#ifdef __WXOSX_MAC__
124 if( aCfg->m_CtrlClickHighlight )
125 m_rbHighlightNetMac->SetValue( true );
126 else
127 m_rbToggleSelMac->SetValue( true );
128#else
129 if( aCfg->m_CtrlClickHighlight )
130 m_rbHighlightNet->SetValue( true );
131 else
132 m_rbToggleSel->SetValue( true );
133#endif
134
136 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
138}
139
140
149
150
160
161
163{
165 {
167 {
168 cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
169
170 cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
172 cfg->m_MagneticItems.graphics = m_magneticGraphics->GetValue();
173
174 cfg->m_AngleSnapMode = m_cbConstrainHV45Mode->GetValue() ? LEADER_MODE::DEG45
176 cfg->m_ArcEditMode = arcEditModeToEnum( m_arcEditMode->GetSelection() );
177 }
178 }
179 else
180 {
181 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
182 {
183 cfg->m_Display.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
184 cfg->m_Display.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
185 cfg->m_Display.m_RatsnestThickness = m_ratsnestThickness->GetValue();
186
187 cfg->m_AngleSnapMode = m_cbConstrainHV45Mode->GetValue() ? LEADER_MODE::DEG45
189 cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
190 cfg->m_ArcEditMode = arcEditModeToEnum( m_arcEditMode->GetSelection() );
191 cfg->m_TrackDragAction = (TRACK_DRAG_ACTION) m_trackMouseDragCtrl->GetSelection();
192
193 cfg->m_FlipDirection = m_rbFlipLeftRight->GetValue() ? FLIP_DIRECTION::LEFT_RIGHT
195
196 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
197 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
198
199 cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
200 cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
201 cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
202
203 cfg->m_ESCClearsNetHighlight = m_escClearsNetHighlight->GetValue();
204 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
205 cfg->m_ShowCourtyardCollisions = m_cbCourtyardCollisions->GetValue();
206
207#ifdef __WXOSX_MAC__
208 cfg->m_CtrlClickHighlight = m_rbHighlightNetMac->GetValue();
209#else
210 cfg->m_CtrlClickHighlight = m_rbHighlightNet->GetValue();
211#endif
212 }
213 }
214
215 return true;
216}
217
218
220{
222 {
224 cfg.Load(); // Loading without a file will init to defaults
225
226 loadFPSettings( &cfg );
227 }
228 else
229 {
230 PCBNEW_SETTINGS cfg;
231 cfg.Load(); // Loading without a file will init to defaults
232
233 loadPCBSettings( &cfg );
234 }
235}
ARC_EDIT_MODE
Settings for arc editing.
@ 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.
PANEL_EDIT_OPTIONS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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
DISPLAY_OPTIONS m_Display
EDA_ANGLE m_RotationAngle
ARC_EDIT_MODE m_ArcEditMode
TRACK_DRAG_ACTION m_TrackDragAction
LEADER_MODE m_AngleSnapMode
MAGNETIC_SETTINGS m_MagneticItems
FLIP_DIRECTION m_FlipDirection
a few functions useful in geometry calculations.
@ DEG45
45 Degree only
@ DIRECT
Unconstrained point-to-point.
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:24
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:25
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
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
T * GetAppSettings(const char *aFilename)
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads