From b95d9d660dd5d88d4395f1b3559428faddf0f31c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 10 Sep 2022 16:11:24 +0100 Subject: [PATCH] Move gerbview colors to preferences dialog. --- common/eda_base_frame.cpp | 12 +- common/settings/builtin_color_themes.h | 122 ++++++++++++++++++ common/settings/color_settings.cpp | 23 +--- gerbview/CMakeLists.txt | 1 + .../dialogs/panel_gerbview_color_settings.cpp | 105 +++++++++++++++ .../dialogs/panel_gerbview_color_settings.h | 46 +++++++ gerbview/gerbview.cpp | 4 + gerbview/gerbview_painter.cpp | 16 +-- include/frame_type.h | 1 + include/settings/color_settings.h | 7 - .../panel_fp_editor_color_settings.cpp | 12 +- .../dialogs/panel_fp_editor_color_settings.h | 13 +- 12 files changed, 292 insertions(+), 70 deletions(-) create mode 100644 gerbview/dialogs/panel_gerbview_color_settings.cpp create mode 100644 gerbview/dialogs/panel_gerbview_color_settings.h diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index c4ea0eede4..1e4f70c73e 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1078,6 +1078,7 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) ); book->AddSubPage( CREATE_PANEL( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_GBR_COLORS ), _( "Colors" ) ); book->AddSubPage( CREATE_PANEL( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) ); } catch( ... ) @@ -1142,18 +1143,15 @@ bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName, bool aVerbose ) if( fn.IsDir() && !fn.IsDirWritable() ) { - msg.Printf( _( "Insufficient permissions to folder '%s'." ), - fn.GetPath() ); + msg.Printf( _( "Insufficient permissions to folder '%s'." ), fn.GetPath() ); } else if( !fn.FileExists() && !fn.IsDirWritable() ) { - msg.Printf( _( "Insufficient permissions to save file '%s'." ), - fn.GetFullName(), fn.GetPath() ); + msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() ); } else if( fn.FileExists() && !fn.IsFileWritable() ) { - msg.Printf( _( "Insufficient permissions to save file '%s'." ), - fn.GetFullPath() ); + msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() ); } if( !msg.IsEmpty() ) diff --git a/common/settings/builtin_color_themes.h b/common/settings/builtin_color_themes.h index a5ea6889de..cfe444920c 100644 --- a/common/settings/builtin_color_themes.h +++ b/common/settings/builtin_color_themes.h @@ -82,6 +82,67 @@ static const std::map s_defaultTheme = { LAYER_GERBVIEW_DRAWINGSHEET, CSS_COLOR( 0, 0, 132, 1 ) }, { LAYER_GERBVIEW_PAGE_LIMITS, CSS_COLOR( 132, 132, 132, 1 ) }, + { GERBVIEW_LAYER_ID_START, CSS_COLOR( 200, 52, 52, 1 ) }, + { GERBVIEW_LAYER_ID_START + 1, CSS_COLOR( 127, 200, 127, 1 ) }, + { GERBVIEW_LAYER_ID_START + 2, CSS_COLOR( 206, 125, 44, 1 ) }, + { GERBVIEW_LAYER_ID_START + 3, CSS_COLOR( 79, 203, 203, 1 ) }, + { GERBVIEW_LAYER_ID_START + 4, CSS_COLOR( 219, 98, 139, 1 ) }, + { GERBVIEW_LAYER_ID_START + 5, CSS_COLOR( 167, 165, 198, 1 ) }, + { GERBVIEW_LAYER_ID_START + 6, CSS_COLOR( 40, 204, 217, 1 ) }, + { GERBVIEW_LAYER_ID_START + 7, CSS_COLOR( 232, 178, 167, 1 ) }, + { GERBVIEW_LAYER_ID_START + 8, CSS_COLOR( 242, 237, 161, 1 ) }, + { GERBVIEW_LAYER_ID_START + 9, CSS_COLOR( 141, 203, 129, 1 ) }, + { GERBVIEW_LAYER_ID_START + 10, CSS_COLOR( 237, 124, 51, 1 ) }, + { GERBVIEW_LAYER_ID_START + 11, CSS_COLOR( 91, 195, 235, 1 ) }, + { GERBVIEW_LAYER_ID_START + 12, CSS_COLOR( 247, 111, 142, 1 ) }, + { GERBVIEW_LAYER_ID_START + 13, CSS_COLOR( 77, 127, 196, 1 ) }, + { GERBVIEW_LAYER_ID_START + 14, CSS_COLOR( 200, 52, 52, 1 ) }, + { GERBVIEW_LAYER_ID_START + 15, CSS_COLOR( 127, 200, 127, 1 ) }, + { GERBVIEW_LAYER_ID_START + 16, CSS_COLOR( 206, 125, 44, 1 ) }, + { GERBVIEW_LAYER_ID_START + 17, CSS_COLOR( 79, 203, 203, 1 ) }, + { GERBVIEW_LAYER_ID_START + 18, CSS_COLOR( 219, 98, 139, 1 ) }, + { GERBVIEW_LAYER_ID_START + 19, CSS_COLOR( 167, 165, 198, 1 ) }, + { GERBVIEW_LAYER_ID_START + 20, CSS_COLOR( 40, 204, 217, 1 ) }, + { GERBVIEW_LAYER_ID_START + 21, CSS_COLOR( 232, 178, 167, 1 ) }, + { GERBVIEW_LAYER_ID_START + 22, CSS_COLOR( 242, 237, 161, 1 ) }, + { GERBVIEW_LAYER_ID_START + 23, CSS_COLOR( 141, 203, 129, 1 ) }, + { GERBVIEW_LAYER_ID_START + 24, CSS_COLOR( 237, 124, 51, 1 ) }, + { GERBVIEW_LAYER_ID_START + 25, CSS_COLOR( 91, 195, 235, 1 ) }, + { GERBVIEW_LAYER_ID_START + 26, CSS_COLOR( 247, 111, 142, 1 ) }, + { GERBVIEW_LAYER_ID_START + 27, CSS_COLOR( 77, 127, 196, 1 ) }, + { GERBVIEW_LAYER_ID_START + 28, CSS_COLOR( 200, 52, 52, 1 ) }, + { GERBVIEW_LAYER_ID_START + 29, CSS_COLOR( 127, 200, 127, 1 ) }, + { GERBVIEW_LAYER_ID_START + 30, CSS_COLOR( 206, 125, 44, 1 ) }, + { GERBVIEW_LAYER_ID_START + 31, CSS_COLOR( 79, 203, 203, 1 ) }, + { GERBVIEW_LAYER_ID_START + 32, CSS_COLOR( 219, 98, 139, 1 ) }, + { GERBVIEW_LAYER_ID_START + 33, CSS_COLOR( 167, 165, 198, 1 ) }, + { GERBVIEW_LAYER_ID_START + 34, CSS_COLOR( 40, 204, 217, 1 ) }, + { GERBVIEW_LAYER_ID_START + 35, CSS_COLOR( 232, 178, 167, 1 ) }, + { GERBVIEW_LAYER_ID_START + 36, CSS_COLOR( 242, 237, 161, 1 ) }, + { GERBVIEW_LAYER_ID_START + 37, CSS_COLOR( 141, 203, 129, 1 ) }, + { GERBVIEW_LAYER_ID_START + 38, CSS_COLOR( 237, 124, 51, 1 ) }, + { GERBVIEW_LAYER_ID_START + 39, CSS_COLOR( 91, 195, 235, 1 ) }, + { GERBVIEW_LAYER_ID_START + 40, CSS_COLOR( 247, 111, 142, 1 ) }, + { GERBVIEW_LAYER_ID_START + 41, CSS_COLOR( 77, 127, 196, 1 ) }, + { GERBVIEW_LAYER_ID_START + 42, CSS_COLOR( 200, 52, 52, 1 ) }, + { GERBVIEW_LAYER_ID_START + 43, CSS_COLOR( 127, 200, 127, 1 ) }, + { GERBVIEW_LAYER_ID_START + 44, CSS_COLOR( 206, 125, 44, 1 ) }, + { GERBVIEW_LAYER_ID_START + 45, CSS_COLOR( 79, 203, 203, 1 ) }, + { GERBVIEW_LAYER_ID_START + 46, CSS_COLOR( 219, 98, 139, 1 ) }, + { GERBVIEW_LAYER_ID_START + 47, CSS_COLOR( 167, 165, 198, 1 ) }, + { GERBVIEW_LAYER_ID_START + 48, CSS_COLOR( 40, 204, 217, 1 ) }, + { GERBVIEW_LAYER_ID_START + 49, CSS_COLOR( 232, 178, 167, 1 ) }, + { GERBVIEW_LAYER_ID_START + 50, CSS_COLOR( 242, 237, 161, 1 ) }, + { GERBVIEW_LAYER_ID_START + 51, CSS_COLOR( 141, 203, 129, 1 ) }, + { GERBVIEW_LAYER_ID_START + 52, CSS_COLOR( 237, 124, 51, 1 ) }, + { GERBVIEW_LAYER_ID_START + 53, CSS_COLOR( 91, 195, 235, 1 ) }, + { GERBVIEW_LAYER_ID_START + 54, CSS_COLOR( 247, 111, 142, 1 ) }, + { GERBVIEW_LAYER_ID_START + 55, CSS_COLOR( 77, 127, 196, 1 ) }, + { GERBVIEW_LAYER_ID_START + 56, CSS_COLOR( 200, 52, 52, 1 ) }, + { GERBVIEW_LAYER_ID_START + 57, CSS_COLOR( 127, 200, 127, 1 ) }, + { GERBVIEW_LAYER_ID_START + 58, CSS_COLOR( 206, 125, 44, 1 ) }, + { GERBVIEW_LAYER_ID_START + 59, CSS_COLOR( 79, 203, 203, 1 ) }, + { LAYER_ANCHOR, CSS_COLOR( 255, 38, 226, 1 ) }, { LAYER_LOCKED_ITEM_SHADOW, CSS_COLOR( 255, 38, 226, 0.5 ) }, { LAYER_CONFLICTS_SHADOW, CSS_COLOR( 255, 0, 05, 0.5 ) }, @@ -235,6 +296,67 @@ static const std::map s_classicTheme = { LAYER_GERBVIEW_DRAWINGSHEET, COLOR4D( DARKRED ) }, { LAYER_GERBVIEW_PAGE_LIMITS, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 1, COLOR4D( YELLOW ) }, + { GERBVIEW_LAYER_ID_START + 2, COLOR4D( LIGHTMAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 3, COLOR4D( LIGHTRED ) }, + { GERBVIEW_LAYER_ID_START + 4, COLOR4D( CYAN ) }, + { GERBVIEW_LAYER_ID_START + 5, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 6, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 7, COLOR4D( DARKGRAY ) }, + { GERBVIEW_LAYER_ID_START + 8, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 9, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 10, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 11, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 12, COLOR4D( BROWN ) }, + { GERBVIEW_LAYER_ID_START + 13, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 14, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 15, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 16, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 17, COLOR4D( YELLOW ) }, + { GERBVIEW_LAYER_ID_START + 18, COLOR4D( LIGHTMAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 19, COLOR4D( LIGHTRED ) }, + { GERBVIEW_LAYER_ID_START + 20, COLOR4D( CYAN ) }, + { GERBVIEW_LAYER_ID_START + 21, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 22, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 23, COLOR4D( DARKGRAY ) }, + { GERBVIEW_LAYER_ID_START + 24, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 25, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 26, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 27, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 28, COLOR4D( BROWN ) }, + { GERBVIEW_LAYER_ID_START + 29, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 30, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 31, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 32, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 33, COLOR4D( YELLOW ) }, + { GERBVIEW_LAYER_ID_START + 34, COLOR4D( LIGHTMAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 35, COLOR4D( LIGHTRED ) }, + { GERBVIEW_LAYER_ID_START + 36, COLOR4D( CYAN ) }, + { GERBVIEW_LAYER_ID_START + 37, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 38, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 39, COLOR4D( DARKGRAY ) }, + { GERBVIEW_LAYER_ID_START + 40, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 41, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 42, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 43, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 44, COLOR4D( BROWN ) }, + { GERBVIEW_LAYER_ID_START + 45, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 46, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 47, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 48, COLOR4D( RED ) }, + { GERBVIEW_LAYER_ID_START + 49, COLOR4D( YELLOW ) }, + { GERBVIEW_LAYER_ID_START + 50, COLOR4D( LIGHTMAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 51, COLOR4D( LIGHTRED ) }, + { GERBVIEW_LAYER_ID_START + 52, COLOR4D( CYAN ) }, + { GERBVIEW_LAYER_ID_START + 53, COLOR4D( GREEN ) }, + { GERBVIEW_LAYER_ID_START + 54, COLOR4D( BLUE ) }, + { GERBVIEW_LAYER_ID_START + 55, COLOR4D( DARKGRAY ) }, + { GERBVIEW_LAYER_ID_START + 56, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 57, COLOR4D( LIGHTGRAY ) }, + { GERBVIEW_LAYER_ID_START + 58, COLOR4D( MAGENTA ) }, + { GERBVIEW_LAYER_ID_START + 59, COLOR4D( RED ) }, + { LAYER_ANCHOR, COLOR4D( BLUE ) }, { LAYER_LOCKED_ITEM_SHADOW, COLOR4D( BLUE ).WithAlpha( 0.6 ) }, { LAYER_CONFLICTS_SHADOW, COLOR4D( RED ).WithAlpha( 0.5 ) }, diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index 81ef882c66..3dccd08424 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -43,26 +43,6 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) m_params.emplace_back( new PARAM( "meta.name", &m_displayName, "KiCad Default" ) ); - std::vector default_palette = { - CSS_COLOR( 200, 52, 52, 1 ), - CSS_COLOR( 127, 200, 127, 1 ), - CSS_COLOR( 206, 125, 44, 1 ), - CSS_COLOR( 79, 203, 203, 1 ), - CSS_COLOR( 219, 98, 139, 1 ), - CSS_COLOR( 167, 165, 198, 1 ), - CSS_COLOR( 40, 204, 217, 1 ), - CSS_COLOR( 232, 178, 167, 1 ), - CSS_COLOR( 242, 237, 161, 1 ), - CSS_COLOR( 141, 203, 129, 1 ), - CSS_COLOR( 237, 124, 51, 1 ), - CSS_COLOR( 91, 195, 235, 1 ), - CSS_COLOR( 247, 111, 142, 1 ), - CSS_COLOR( 77, 127, 196, 1 ) - }; - - // TODO(JE) in actual usage, how long does the default palette need to be? - m_params.emplace_back( new PARAM_LIST( "palette", &m_Palette, default_palette ) ); - m_params.emplace_back( new PARAM( "schematic.override_item_colors", &m_overrideSchItemColors, false ) ); @@ -127,8 +107,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) id < GERBER_DRAWLAYERS_COUNT + GERBVIEW_LAYER_ID_START; ++i, ++id ) { m_params.emplace_back( new COLOR_MAP_PARAM( "gerbview.layers." + std::to_string( i ), id, - default_palette[ i % default_palette.size() ], - &m_colors ) ); + s_defaultTheme.at( id ), &m_colors ) ); } CLR( "board.anchor", LAYER_ANCHOR ); diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 354077325c..5978633342 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -17,6 +17,7 @@ include_directories( set( DIALOGS_SRCS + dialogs/panel_gerbview_color_settings.cpp dialogs/panel_gerbview_display_options.cpp dialogs/panel_gerbview_display_options_base.cpp dialogs/panel_gerbview_excellon_settings.cpp diff --git a/gerbview/dialogs/panel_gerbview_color_settings.cpp b/gerbview/dialogs/panel_gerbview_color_settings.cpp new file mode 100644 index 0000000000..12e9a3b22d --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_color_settings.cpp @@ -0,0 +1,105 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +PANEL_GERBVIEW_COLOR_SETTINGS::PANEL_GERBVIEW_COLOR_SETTINGS( wxWindow* aParent ) : + PANEL_COLOR_SETTINGS( aParent ) +{ + m_colorNamespace = "gerbview"; + + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + GERBVIEW_SETTINGS* app_settings = mgr.GetAppSettings(); + COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); + + // Saved theme doesn't exist? Reset to default + if( current->GetFilename() != app_settings->m_ColorTheme ) + app_settings->m_ColorTheme = current->GetFilename(); + + createThemeList( app_settings->m_ColorTheme ); + + // Currently this only applies to eeschema + m_optOverrideColors->Hide(); + + m_currentSettings = new COLOR_SETTINGS( *current ); + + for( int i = GERBVIEW_LAYER_ID_START; i < GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT; i++ ) + m_validLayers.push_back( i ); + + for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ ) + m_validLayers.push_back( i ); + + m_backgroundLayer = LAYER_GERBVIEW_BACKGROUND; +} + + +PANEL_GERBVIEW_COLOR_SETTINGS::~PANEL_GERBVIEW_COLOR_SETTINGS() +{ + delete m_currentSettings; +} + + +bool PANEL_GERBVIEW_COLOR_SETTINGS::TransferDataFromWindow() +{ + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + GERBVIEW_SETTINGS* app_settings = mgr.GetAppSettings(); + app_settings->m_ColorTheme = m_currentSettings->GetFilename(); + + return true; +} + + +bool PANEL_GERBVIEW_COLOR_SETTINGS::TransferDataToWindow() +{ + return true; +} + + +void PANEL_GERBVIEW_COLOR_SETTINGS::createSwatches() +{ + wxString layerName; + + for( int layer : m_validLayers ) + { + switch( layer ) + { + case LAYER_DCODES: layerName = _( "DCodes" ); break; + case LAYER_NEGATIVE_OBJECTS: layerName = _( "Negative Objects" ); break; + case LAYER_GERBVIEW_GRID: layerName = _( "Grid" ); break; + case LAYER_GERBVIEW_AXES: layerName = _( "Axes" ); break; + case LAYER_GERBVIEW_DRAWINGSHEET: layerName = _( "Drawing Sheet" ); break; + case LAYER_GERBVIEW_PAGE_LIMITS: layerName = _( "Page Limits" ); break; + case LAYER_GERBVIEW_BACKGROUND: layerName = _( "Background" ); break; + + default: + layerName = wxString::Format( _( "Layer %d" ), layer + 1 - GERBVIEW_LAYER_ID_START ); + break; + } + + createSwatch( layer, layerName ); + } + + Layout(); +} + + diff --git a/gerbview/dialogs/panel_gerbview_color_settings.h b/gerbview/dialogs/panel_gerbview_color_settings.h new file mode 100644 index 0000000000..0c7c95cc3d --- /dev/null +++ b/gerbview/dialogs/panel_gerbview_color_settings.h @@ -0,0 +1,46 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef PANEL_GERBVIEW_COLOR_SETTINGS_H +#define PANEL_GERBVIEW_COLOR_SETTINGS_H + +#include + +class PAGE_INFO; +class FOOTPRINT_PREVIEW_PANEL; +class TITLE_BLOCK; + + +class PANEL_GERBVIEW_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS +{ +public: + PANEL_GERBVIEW_COLOR_SETTINGS( wxWindow* aParent ); + + ~PANEL_GERBVIEW_COLOR_SETTINGS() override; + +protected: + bool TransferDataFromWindow() override; + + bool TransferDataToWindow() override; + + void createSwatches() override; +}; + + +#endif diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index ac0a76738a..4cc2b591e7 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,9 @@ static struct IFACE : public KIFACE_BASE case PANEL_GBR_EXCELLON_OPTIONS: return new PANEL_GERBVIEW_EXCELLON_SETTINGS( aParent ); + case PANEL_GBR_COLORS: + return new PANEL_GERBVIEW_COLOR_SETTINGS( aParent ); + default: ; } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 8aad2dfb4e..8c96fc3cfe 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -57,22 +57,14 @@ GERBVIEW_RENDER_SETTINGS::GERBVIEW_RENDER_SETTINGS() void GERBVIEW_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings ) { - size_t palette_size = aSettings->m_Palette.size(); - size_t palette_idx = 0; - // Layers to draw gerber data read from gerber files: for( int i = GERBVIEW_LAYER_ID_START; i < GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT; i++ ) { - COLOR4D baseColor = aSettings->GetColor( i ); - - if( baseColor == COLOR4D::UNSPECIFIED ) - baseColor = aSettings->m_Palette[ ( palette_idx++ ) % palette_size ]; - - m_layerColors[i] = baseColor; - m_layerColorsHi[i] = baseColor.Brightened( 0.5 ); - m_layerColorsSel[i] = baseColor.Brightened( 0.8 ); - m_layerColorsDark[i] = baseColor.Darkened( 0.25 ); + m_layerColors[i] = aSettings->GetColor( i ); + m_layerColorsHi[i] = m_layerColors[i].Brightened( 0.5 ); + m_layerColorsSel[i] = m_layerColors[i].Brightened( 0.8 ); + m_layerColorsDark[i] = m_layerColors[i].Darkened( 0.25 ); } // Draw layers specific to Gerbview: diff --git a/include/frame_type.h b/include/frame_type.h index fd691766c6..a161289fcc 100644 --- a/include/frame_type.h +++ b/include/frame_type.h @@ -94,6 +94,7 @@ enum FRAME_T PANEL_GBR_DISPLAY_OPTIONS, PANEL_GBR_EDIT_OPTIONS, PANEL_GBR_EXCELLON_OPTIONS, + PANEL_GBR_COLORS, PANEL_DS_DISPLAY_OPTIONS, PANEL_DS_COLORS, diff --git a/include/settings/color_settings.h b/include/settings/color_settings.h index 360c967922..9977e6dd92 100644 --- a/include/settings/color_settings.h +++ b/include/settings/color_settings.h @@ -51,13 +51,6 @@ using KIGFX::COLOR4D; class COLOR_SETTINGS : public JSON_SETTINGS { public: - /** - * m_Pallete stores a list of colors that are used, in order, when a list of colors needs to - * be generated for an application. For example, layer colors in GerbView, or default layer - * colors in PcbNew. - */ - std::vector m_Palette; - explicit COLOR_SETTINGS( const wxString& aFilename = wxT( "user" ), bool aAbsolutePath = false ); diff --git a/pcbnew/dialogs/panel_fp_editor_color_settings.cpp b/pcbnew/dialogs/panel_fp_editor_color_settings.cpp index efa8e541b8..312b4a8a14 100644 --- a/pcbnew/dialogs/panel_fp_editor_color_settings.cpp +++ b/pcbnew/dialogs/panel_fp_editor_color_settings.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -18,21 +18,15 @@ * with this program. If not, see . */ -#include - #include #include #include #include -#include -#include #include PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS( wxWindow* aParent ) : - PANEL_COLOR_SETTINGS( aParent ), - m_page( nullptr ), - m_titleBlock( nullptr ) + PANEL_COLOR_SETTINGS( aParent ) { // Currently this only applies to eeschema m_optOverrideColors->Hide(); @@ -81,8 +75,6 @@ PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS( wxWindow* aParen PANEL_FP_EDITOR_COLOR_SETTINGS::~PANEL_FP_EDITOR_COLOR_SETTINGS() { delete m_currentSettings; - delete m_page; - delete m_titleBlock; } diff --git a/pcbnew/dialogs/panel_fp_editor_color_settings.h b/pcbnew/dialogs/panel_fp_editor_color_settings.h index 35bbaa3e87..f10c4f5b03 100644 --- a/pcbnew/dialogs/panel_fp_editor_color_settings.h +++ b/pcbnew/dialogs/panel_fp_editor_color_settings.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -40,17 +40,6 @@ protected: bool TransferDataToWindow() override; void createSwatches() override; - - enum COLOR_CONTEXT_ID - { - ID_COPY = wxID_HIGHEST + 1, - ID_PASTE, - ID_REVERT - }; - -private: - PAGE_INFO* m_page; - TITLE_BLOCK* m_titleBlock; };