KiCad PCB EDA Suite
panel_gerbview_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) 2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <pgm_base.h>
21#include <layer_ids.h>
24#include <gerbview_settings.h>
25#include <gerbview_frame.h>
27
28#include <wx/log.h>
30 PANEL_COLOR_SETTINGS( aParent )
31{
32 m_colorNamespace = "gerbview";
33
34 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
36 COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
37
38 // Colors can also be modified from the LayersManager, so collect last settings if exist
39 // (They can be no yet saved on disk)
40 GERBVIEW_FRAME* gbr_mainframe = dynamic_cast<GERBVIEW_FRAME*>(
41 wxWindow::FindWindowByName( GERBVIEW_FRAME_NAME ) );
42 if( gbr_mainframe )
43 {
44 gbr_mainframe->m_LayersManager->CollectCurrentColorSettings( current );
45 }
46
47 // Saved theme doesn't exist? Reset to default
48 if( current->GetFilename() != app_settings->m_ColorTheme )
49 app_settings->m_ColorTheme = current->GetFilename();
50
51 createThemeList( app_settings->m_ColorTheme );
52
53
54 // Currently this only applies to eeschema
55 m_optOverrideColors->Hide();
56
57
58 m_currentSettings = new COLOR_SETTINGS( *current );
59
61 m_validLayers.push_back( i );
62
63 for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
64 m_validLayers.push_back( i );
65
67}
68
69
71{
72 delete m_currentSettings;
73}
74
75
77{
78 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
81
82 return true;
83}
84
85
87{
88 return true;
89}
90
91
93{
94 wxString layerName;
95
96 for( int layer : m_validLayers )
97 {
98 switch( layer )
99 {
100 case LAYER_DCODES: layerName = _( "DCodes" ); break;
101 case LAYER_NEGATIVE_OBJECTS: layerName = _( "Negative Objects" ); break;
102 case LAYER_GERBVIEW_GRID: layerName = _( "Grid" ); break;
103 case LAYER_GERBVIEW_AXES: layerName = _( "Axes" ); break;
104 case LAYER_GERBVIEW_DRAWINGSHEET: layerName = _( "Drawing Sheet" ); break;
105 case LAYER_GERBVIEW_PAGE_LIMITS: layerName = _( "Page Limits" ); break;
106 case LAYER_GERBVIEW_BACKGROUND: layerName = _( "Background" ); break;
107
108 default:
109 layerName = wxString::Format( _( "Graphic Layer %d" ), layer + 1 - GERBVIEW_LAYER_ID_START );
110 break;
111 }
112
113 createSwatch( layer, layerName );
114 }
115
116 Layout();
117}
118
119
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:187
Color settings are a bit different than most of the settings objects in that there can be more than o...
void CollectCurrentColorSettings(COLOR_SETTINGS *aColorSettings)
Collect the current color settings and put it in aColorSettings.
GERBER_LAYER_WIDGET * m_LayersManager
wxString GetFilename() const
Definition: json_settings.h:73
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
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
#define _(s)
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition: layer_ids.h:417
@ GERBVIEW_LAYER_ID_START
Definition: layer_ids.h:407
@ LAYER_GERBVIEW_BACKGROUND
Definition: layer_ids.h:416
@ LAYER_DCODES
Definition: layer_ids.h:412
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:413
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition: layer_ids.h:418
@ GERBVIEW_LAYER_ID_END
Definition: layer_ids.h:420
@ LAYER_GERBVIEW_AXES
Definition: layer_ids.h:415
@ LAYER_GERBVIEW_GRID
Definition: layer_ids.h:414
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:402
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111