KiCad PCB EDA Suite
panel_display_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) 2015 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
5 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
23#include <pcbnew_settings.h>
24#include <config_map.h>
27
28
30{
31 { SHOW_WITH_VIA_WHILE_ROUTING, 2 }, // Default
33 { SHOW_WHILE_ROUTING, 1 },
36};
37
38
41 m_isPCBEdit( dynamic_cast<PCBNEW_SETTINGS*>( aAppSettings ) != nullptr )
42{
43 m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings );
44 m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
45
46 m_optionsBook->SetSelection( m_isPCBEdit ? 1 : 0 );
47}
48
49
51{
53 m_OptDisplayTracksClearance->SetSelection( i );
54
57 m_ShowNetNamesOption->SetSelection( aCfg->m_Display.m_NetNames );
58 m_live3Drefresh->SetValue( aCfg->m_Display.m_Live3DRefresh );
63}
64
65
67{
68 if( m_isPCBEdit )
69 {
70 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
72
73 loadPCBSettings( cfg );
74 }
75
77
78 return true;
79}
80
81
82/*
83 * Update variables with new options
84 */
86{
88
89 if( m_isPCBEdit )
90 {
91 PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
92
93 int i = m_OptDisplayTracksClearance->GetSelection();
95
98 cfg->m_Display.m_NetNames = m_ShowNetNamesOption->GetSelection();
99 cfg->m_Display.m_Live3DRefresh = m_live3Drefresh->GetValue();
104 }
105
106 return true;
107}
108
109
111{
112 PCBNEW_SETTINGS cfg;
113 cfg.Load(); // Loading without a file will init to defaults
114
115 if( m_isPCBEdit )
116 loadPCBSettings( &cfg );
117
118 m_galOptsPanel->ResetPanel( &cfg );
119}
120
121
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:101
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:170
bool ResetPanel(APP_SETTINGS_BASE *aAppSettings)
bool TransferDataToWindow() override
Load the panel controls from the given opt.
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
Class PANEL_DISPLAY_OPTIONS_BASE.
void loadPCBSettings(PCBNEW_SETTINGS *aCfg)
PANEL_DISPLAY_OPTIONS(wxWindow *aParent, APP_SETTINGS_BASE *aAppSettings)
GAL_OPTIONS_PANEL * m_galOptsPanel
void ResetPanel() override
Reset the contents of this panel.
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
DISPLAY_OPTIONS m_Display
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
std::vector< std::pair< T, long > > CFG_MAP
A config value table is a list of native values (usually enums) to a different set of values,...
Definition: config_map.h:49
static long GetConfigForVal(const MAP &aMap, CFG_NATIVE_VAL< MAP > aVal)
Get the mapped config value (the one to write to file, or use in an index) from the given native (pro...
Definition: config_map.h:69
static CFG_NATIVE_VAL< MAP > GetValFromConfig(const MAP &aMap, long aConf)
Get the native value corresponding to the config value (read from file or UI, probably) and find it i...
Definition: config_map.h:96
static const UTIL::CFG_MAP< TRACK_CLEARANCE_MODE > clearanceModeMap
@ SHOW_WITH_VIA_WHILE_ROUTING_OR_DRAGGING
@ DO_NOT_SHOW_CLEARANCE
@ SHOW_WHILE_ROUTING
@ SHOW_WITH_VIA_ALWAYS
@ SHOW_WITH_VIA_WHILE_ROUTING
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
bool on_selection
Synchronize the selection for multiple items too.
Definition: app_settings.h:32
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:34
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:33
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:35
TRACK_CLEARANCE_MODE m_TrackClearance