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 (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
35 GERBVIEW_SETTINGS* app_settings = mgr.GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
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{
79 GERBVIEW_SETTINGS* cfg = mgr.GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
80
82
83 return true;
84}
85
86
88{
89 return true;
90}
91
92
94{
95 wxString layerName;
96
97 for( int layer : m_validLayers )
98 {
99 switch( layer )
100 {
101 case LAYER_DCODES: layerName = _( "DCodes" ); break;
102 case LAYER_NEGATIVE_OBJECTS: layerName = _( "Negative Objects" ); break;
103 case LAYER_GERBVIEW_GRID: layerName = _( "Grid" ); break;
104 case LAYER_GERBVIEW_AXES: layerName = _( "Axes" ); break;
105 case LAYER_GERBVIEW_DRAWINGSHEET: layerName = _( "Drawing Sheet" ); break;
106 case LAYER_GERBVIEW_PAGE_LIMITS: layerName = _( "Page Limits" ); break;
107 case LAYER_GERBVIEW_BACKGROUND: layerName = _( "Background" ); break;
108
109 default:
110 layerName = wxString::Format( _( "Graphic Layer %d" ), layer + 1 - GERBVIEW_LAYER_ID_START );
111 break;
112 }
113
114 createSwatch( layer, layerName );
115 }
116
117 Layout();
118}
119
120
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:197
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:80
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
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
#define _(s)
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition: layer_ids.h:435
@ GERBVIEW_LAYER_ID_START
Definition: layer_ids.h:425
@ LAYER_GERBVIEW_BACKGROUND
Definition: layer_ids.h:434
@ LAYER_DCODES
Definition: layer_ids.h:430
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:431
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition: layer_ids.h:436
@ GERBVIEW_LAYER_ID_END
Definition: layer_ids.h:438
@ LAYER_GERBVIEW_AXES
Definition: layer_ids.h:433
@ LAYER_GERBVIEW_GRID
Definition: layer_ids.h:432
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:420
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE