KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_eeschema_editing_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 Wayne Stambaugh <[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 <layer_ids.h>
25#include <eeschema_settings.h>
27#include <widgets/ui_common.h>
28
29
31{
32 switch( aMode )
33 {
35 return 0;
37 return 1;
39 return 2;
40 default:
41 wxFAIL_MSG( "Invalid ARC_EDIT_MODE" );
42 return 0;
43 }
44};
45
46
47static ARC_EDIT_MODE arcEditModeToEnum( int aIndex )
48{
49 switch( aIndex )
50 {
51 case 0:
53 case 1:
55 case 2:
57 default:
58 wxFAIL_MSG( wxString::Format( "Invalid index for ARC_EDIT_MODE: %d", aIndex ) );
60 }
61};
62
63
65 UNITS_PROVIDER* aUnitsProvider,
66 wxWindow* aEventSource ) :
68 m_hPitch( aUnitsProvider, aEventSource, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ),
69 m_vPitch( aUnitsProvider, aEventSource, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits )
70{
71 // Make the color swatch show "Clear Color" instead
72 m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
74
75 wxFont helpFont = KIUI::GetSmallInfoFont( this ).Italic();
76 m_hint1->SetFont( helpFont );
77 m_hint2->SetFont( helpFont );
78
79 m_spinLabelRepeatStep->SetRange( -100000, 100000 );
80 m_spinLabelRepeatStep->SetIncrement( 1 );
81
82#ifdef __WXOSX_MAC__
83 m_leftClickCmdsBook->SetSelection( 1 );
84#else
85 m_leftClickCmdsBook->SetSelection( 0 );
86#endif
87}
88
89
91{
92 m_hPitch.SetValue( schIUScale.MilsToIU( aCfg->m_Drawing.default_repeat_offset_x ) );
93 m_vPitch.SetValue( schIUScale.MilsToIU( aCfg->m_Drawing.default_repeat_offset_y ) );
95
97 COLOR4D schematicBackground = settings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
98
99 m_borderColorSwatch->SetSwatchBackground( schematicBackground );
100 m_borderColorSwatch->SetDefaultColor( settings->GetDefaultColor( LAYER_SHEET ) );
101 m_borderColorSwatch->SetSwatchColor( aCfg->m_Drawing.default_sheet_border_color, false );
102
103 m_backgroundColorSwatch->SetSwatchBackground( schematicBackground );
104 m_backgroundColorSwatch->SetDefaultColor( settings->GetDefaultColor( LAYER_SHEET_BACKGROUND ) );
106
107 m_choiceLineMode->SetSelection( aCfg->m_Drawing.line_mode );
110 m_neverShowRescue->SetValue( aCfg->m_RescueNeverShow );
111
115
116 m_mouseDragIsDrag->SetValue( !aCfg->m_Input.drag_is_move );
117
122
123 m_choicePower->SetSelection( static_cast<int>( aCfg->m_Drawing.new_power_symbols ) );
124}
125
126
132
133
135{
137 {
138 cfg->m_Drawing.new_power_symbols = static_cast<POWER_SYMBOLS>( m_choicePower->GetSelection() );
139
140 cfg->m_Drawing.default_sheet_border_color = m_borderColorSwatch->GetSwatchColor();
141 cfg->m_Drawing.default_sheet_background_color = m_backgroundColorSwatch->GetSwatchColor();
142
143 cfg->m_Drawing.default_repeat_offset_x = schIUScale.IUToMils( m_hPitch.GetIntValue() );
144 cfg->m_Drawing.default_repeat_offset_y = schIUScale.IUToMils( m_vPitch.GetIntValue() );
145 cfg->m_Drawing.repeat_label_increment = m_spinLabelRepeatStep->GetValue();
146
147 cfg->m_Drawing.line_mode = m_choiceLineMode->GetSelection();
148 cfg->m_Drawing.arc_edit_mode = arcEditModeToEnum( m_choiceArcMode->GetSelection() );
149 cfg->m_Appearance.footprint_preview = m_footprintPreview->GetValue();
150 cfg->m_RescueNeverShow = m_neverShowRescue->GetValue();
151
152 cfg->m_AutoplaceFields.enable = m_checkAutoplaceFields->GetValue();
153 cfg->m_AutoplaceFields.allow_rejustify = m_checkAutoplaceJustify->GetValue();
154 cfg->m_AutoplaceFields.align_to_grid = m_checkAutoplaceAlign->GetValue();
155
156 cfg->m_Input.drag_is_move = !m_mouseDragIsDrag->GetValue();
157
158 cfg->m_Drawing.auto_start_wires = m_cbAutoStartWires->GetValue();
159 cfg->m_Input.esc_clears_net_highlight = m_escClearsNetHighlight->GetValue();
160 cfg->m_AnnotatePanel.automatic = m_checkAutoAnnotate->GetValue();
161 cfg->m_Input.allow_unconstrained_pin_swaps = m_checkAllowUnconstrainedPinSwaps->GetValue();
162 }
163
164 return true;
165}
166
167
169{
171 cfg.Load(); // Loading without a file will init to defaults
172
173 loadEEschemaSettings( &cfg );
174}
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.
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
COLOR4D GetDefaultColor(int aLayer)
PANEL_ANNOTATE m_AnnotatePanel
AUTOPLACE_FIELDS m_AutoplaceFields
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
PANEL_EESCHEMA_EDITING_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)
void loadEEschemaSettings(EESCHEMA_SETTINGS *aCfg)
PANEL_EESCHEMA_EDITING_OPTIONS(wxWindow *aWindow, UNITS_PROVIDER *aUnitsProvider, wxWindow *aEventSource)
void ResetPanel() override
Reset the contents of this panel.
POWER_SYMBOLS
@ LAYER_SHEET_BACKGROUND
Definition layer_ids.h:483
@ LAYER_SHEET
Definition layer_ids.h:469
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:486
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
static ARC_EDIT_MODE arcEditModeToEnum(int aIndex)
static int arcEditModeToComboIndex(ARC_EDIT_MODE aMode)
see class PGM_BASE
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
Functions to provide common constants and other functions to assist in making a consistent UI.