KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_fp_editor_color_settings.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) 2020 Jon Evans <[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 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>
25#include <layer_ids.h>
27
28
30 PANEL_COLOR_SETTINGS( aParent )
31{
32 // Currently this only applies to eeschema
33 m_optOverrideColors->Hide();
34
35 m_colorNamespace = "board";
36
39
40 // Store the current settings before reloading below
41 current->Store();
42 Pgm().GetSettingsManager().SaveColorSettings( current, "board" );
43
44 m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
45
46 m_currentSettings = new COLOR_SETTINGS( *current );
47
50
51 m_validLayers.push_back( F_Cu );
52 m_validLayers.push_back( In1_Cu ); // "Internal Layers"
53 m_validLayers.push_back( B_Cu );
54
55 for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; id++ )
56 {
57 if( id == LAYER_VIAS
58 || id == LAYER_VIA_HOLES
59 || id == LAYER_VIA_HOLEWALLS
61 || id == LAYER_PAD_HOLEWALLS )
62 {
63 continue;
64 }
65
66 m_validLayers.push_back( id );
67 }
68
70}
71
72
77
78
80{
82 cfg->m_ColorTheme = m_currentSettings->GetFilename();
83
84 return true;
85}
86
87
92
93
95{
96 std::vector<GAL_LAYER_ID> galLayers;
97
98 // Sort the gal layers by name
99 for( int i : m_validLayers )
100 {
101 if( i >= GAL_LAYER_ID_START && m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED )
102 galLayers.push_back( (GAL_LAYER_ID) i );
103 }
104
105 std::sort( galLayers.begin(), galLayers.end(),
106 []( int a, int b )
107 {
108 return LayerName( a ) < LayerName( b );
109 } );
110
112 createSwatch( In1_Cu, _( "Internal Layers" ) );
114
115 for( GAL_LAYER_ID layer : galLayers )
116 createSwatch( layer, LayerName( layer ) );
117
118 Layout();
119}
wxString m_ColorTheme
Active color theme name.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:402
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool GetOverrideSchItemColors() const
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
void createThemeList(const wxString &aCurrent)
Builds the theme listbox and sets the selection to the current theme.
void createSwatch(int aLayer, const wxString &aName)
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
COLOR_SETTINGS * m_currentSettings
PANEL_COLOR_SETTINGS(wxWindow *aParent)
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:131
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
void ReloadColorSettings()
Re-scan the color themes directory, reloading any changes it finds.
#define _(s)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition layer_id.cpp:31
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
@ GAL_LAYER_ID_START
Definition layer_ids.h:229
@ LAYER_VIA_HOLEWALLS
Definition layer_ids.h:298
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:281
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition layer_ids.h:271
@ GAL_LAYER_ID_END
Definition layer_ids.h:360
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
Definition layer_ids.h:274
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition layer_ids.h:232
@ LAYER_PAD_HOLEWALLS
Definition layer_ids.h:297
@ B_Cu
Definition layer_ids.h:65
@ In1_Cu
Definition layer_ids.h:66
@ F_Cu
Definition layer_ids.h:64
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)