KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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 GERBVIEW_SETTINGS* cfg = GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
36
37 // Colors can also be modified from the LayersManager, so collect last settings if exist
38 // (They can be no yet saved on disk)
39 if( GERBVIEW_FRAME* frame = dynamic_cast<GERBVIEW_FRAME*>( wxWindow::FindWindowByName( GERBVIEW_FRAME_NAME ) ) )
40 frame->m_LayersManager->CollectCurrentColorSettings( current );
41
42 // Saved theme doesn't exist? Reset to default
43 if( cfg && current->GetFilename() != cfg->m_ColorTheme )
44 cfg->m_ColorTheme = current->GetFilename();
45
47
48 // Currently this only applies to eeschema
49 m_optOverrideColors->Hide();
50
51 m_currentSettings = new COLOR_SETTINGS( *current );
52
54 m_validLayers.push_back( i );
55
56 for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
57 m_validLayers.push_back( i );
58
60}
61
62
64{
65 delete m_currentSettings;
66}
67
68
70{
71 if( GERBVIEW_SETTINGS* cfg = GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" ) )
72 cfg->m_ColorTheme = m_currentSettings->GetFilename();
73
74 return true;
75}
76
77
79{
80 return true;
81}
82
83
85{
86 wxString layerName;
87
88 for( int layer : m_validLayers )
89 {
90 switch( layer )
91 {
92 case LAYER_DCODES: layerName = _( "DCodes" ); break;
93 case LAYER_NEGATIVE_OBJECTS: layerName = _( "Negative Objects" ); break;
94 case LAYER_GERBVIEW_GRID: layerName = _( "Grid" ); break;
95 case LAYER_GERBVIEW_AXES: layerName = _( "Axes" ); break;
96 case LAYER_GERBVIEW_DRAWINGSHEET: layerName = _( "Drawing Sheet" ); break;
97 case LAYER_GERBVIEW_PAGE_LIMITS: layerName = _( "Page Limits" ); break;
98 case LAYER_GERBVIEW_BACKGROUND: layerName = _( "Background" ); break;
99
100 default:
101 layerName = wxString::Format( _( "Graphic Layer %d" ), layer + 1 - GERBVIEW_LAYER_ID_START );
102 break;
103 }
104
105 createSwatch( layer, layerName );
106 }
107
108 Layout();
109}
110
111
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:235
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxString GetFilename() const
Definition: json_settings.h:81
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
#define _(s)
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition: layer_ids.h:522
@ GERBVIEW_LAYER_ID_START
Definition: layer_ids.h:512
@ LAYER_GERBVIEW_BACKGROUND
Definition: layer_ids.h:521
@ LAYER_DCODES
Definition: layer_ids.h:517
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:518
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition: layer_ids.h:523
@ GERBVIEW_LAYER_ID_END
Definition: layer_ids.h:525
@ LAYER_GERBVIEW_AXES
Definition: layer_ids.h:520
@ LAYER_GERBVIEW_GRID
Definition: layer_ids.h:519
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
Definition: layer_ids.h:507
see class PGM_BASE
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)