KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_pcb_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-2023 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|wxRIGHT, 15 );
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 );
59 m_live3Drefresh->SetValue( aCfg->m_Display.m_Live3DRefresh );
64}
65
66
68{
69 if( m_isPCBEdit )
70 {
72 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
73
74 loadPCBSettings( cfg );
75 }
76
78
79 return true;
80}
81
82
83/*
84 * Update variables with new options
85 */
87{
89
90 if( m_isPCBEdit )
91 {
93 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
94
95 int i = m_OptDisplayTracksClearance->GetSelection();
97
100 cfg->m_Display.m_NetNames = m_ShowNetNamesOption->GetSelection();
102 cfg->m_Display.m_Live3DRefresh = m_live3Drefresh->GetValue();
107 }
108
109 return true;
110}
111
112
114{
115 PCBNEW_SETTINGS cfg;
116 cfg.Load(); // Loading without a file will init to defaults
117
118 if( m_isPCBEdit )
119 loadPCBSettings( &cfg );
120
121 m_galOptsPanel->ResetPanel( &cfg );
122}
123
124
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:176
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_PCB_DISPLAY_OPTIONS_BASE.
PANEL_PCB_DISPLAY_OPTIONS(wxWindow *aParent, APP_SETTINGS_BASE *aAppSettings)
void ResetPanel() override
Reset the contents of this panel.
void loadPCBSettings(PCBNEW_SETTINGS *aCfg)
DISPLAY_OPTIONS m_Display
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings(const wxString &aFilename)
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
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
bool on_selection
Synchronize the selection for multiple items too.
Definition: app_settings.h:33
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:35
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:34
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:36
TRACK_CLEARANCE_MODE m_TrackClearance