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{
38
40
41 m_stHint1->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
42 m_stHint2->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
43
44#ifdef __WXOSX_MAC__
45 m_mouseCmdsOSX->Show( true );
46 m_mouseCmdsWinLin->Show( false );
47
48 // Disable highlight net option for footprint editor
50 {
51 m_rbToggleSelMac->SetValue( true );
52 m_rbHighlightNetMac->Show( false );
53 }
54#else
55 m_mouseCmdsWinLin->Show( true );
56 m_mouseCmdsOSX->Show( false );
57
58 // Disable highlight net option for footprint editor
60 {
61 m_rbToggleSel->SetValue( true );
62 m_rbHighlightNet->Show( false );
63 }
64#endif
65
66 m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
67 Layout();
68}
69
70
72{
73 switch( aMode )
74 {
78 default: wxFAIL_MSG( "Invalid ARC_EDIT_MODE" ); return 0;
79 }
80};
81
82
83static ARC_EDIT_MODE arcEditModeToEnum( int aIndex )
84{
85 switch( aIndex )
86 {
90
91 default:
92 wxFAIL_MSG( wxString::Format( "Invalid index for ARC_EDIT_MODE: %d", aIndex ) );
94 }
95};
96
97
99{
101 m_rotationAngle.SetAngleValue( aCfg->m_RotationAngle );
102 m_arcEditMode->SetSelection( arcEditModeToComboIndex( aCfg->m_ArcEditMode ) );
103 m_trackMouseDragCtrl->SetSelection( (int) aCfg->m_TrackDragAction );
104
106 m_rbFlipLeftRight->SetValue( true );
107 else
108 m_rbFlipTopBottom->SetValue( true );
109
110 m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
111 m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
112
113
114 /* Set display options */
118
119#ifdef __WXOSX_MAC__
120 if( aCfg->m_CtrlClickHighlight )
121 m_rbHighlightNetMac->SetValue( true );
122 else
123 m_rbToggleSelMac->SetValue( true );
124#else
125 if( aCfg->m_CtrlClickHighlight )
126 m_rbHighlightNet->SetValue( true );
127 else
128 m_rbToggleSel->SetValue( true );
129#endif
130
132 m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
134}
135
136
143
144
154
155
157{
159 {
161 {
162 cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
163
164 cfg->m_AngleSnapMode = m_cbConstrainHV45Mode->GetValue() ? LEADER_MODE::DEG45
166 cfg->m_ArcEditMode = arcEditModeToEnum( m_arcEditMode->GetSelection() );
167 }
168 }
169 else
170 {
171 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
172 {
173 cfg->m_Display.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
174 cfg->m_Display.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
175 cfg->m_Display.m_RatsnestThickness = m_ratsnestThickness->GetValue();
176
177 cfg->m_AngleSnapMode = m_cbConstrainHV45Mode->GetValue() ? LEADER_MODE::DEG45
179 cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
180 cfg->m_ArcEditMode = arcEditModeToEnum( m_arcEditMode->GetSelection() );
181 cfg->m_TrackDragAction = (TRACK_DRAG_ACTION) m_trackMouseDragCtrl->GetSelection();
182
183 cfg->m_FlipDirection = m_rbFlipLeftRight->GetValue() ? FLIP_DIRECTION::LEFT_RIGHT
185
186 cfg->m_AllowFreePads = m_allowFreePads->GetValue();
187 cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
188
189 cfg->m_ESCClearsNetHighlight = m_escClearsNetHighlight->GetValue();
190 cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
191 cfg->m_ShowCourtyardCollisions = m_cbCourtyardCollisions->GetValue();
192
193#ifdef __WXOSX_MAC__
194 cfg->m_CtrlClickHighlight = m_rbHighlightNetMac->GetValue();
195#else
196 cfg->m_CtrlClickHighlight = m_rbHighlightNet->GetValue();
197#endif
198 }
199 }
200
201 return true;
202}
203
204
206{
208 {
210 cfg.Load(); // Loading without a file will init to defaults
211
212 loadFPSettings( &cfg );
213 }
214 else
215 {
216 PCBNEW_SETTINGS cfg;
217 cfg.Load(); // Loading without a file will init to defaults
218
219 loadPCBSettings( &cfg );
220 }
221}
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
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)
TRACK_DRAG_ACTION
see class PGM_BASE
T * GetAppSettings(const char *aFilename)