16 changed files with 746 additions and 317 deletions
-
291common/dialogs/panel_color_settings.cpp
-
76common/dialogs/panel_color_settings.h
-
92common/layer_id.cpp
-
305eeschema/dialogs/panel_eeschema_color_settings.cpp
-
34eeschema/dialogs/panel_eeschema_color_settings.h
-
2eeschema/eeschema_config.cpp
-
7include/layers_id_colors_and_visibility.h
-
1pcbnew/CMakeLists.txt
-
135pcbnew/dialogs/panel_pcbnew_color_settings.cpp
-
70pcbnew/dialogs/panel_pcbnew_color_settings.h
-
2pcbnew/pcb_base_frame.cpp
-
11pcbnew/pcb_draw_panel_gal.cpp
-
14pcbnew/pcb_edit_frame.cpp
-
15pcbnew/pcb_edit_frame.h
-
6pcbnew/pcb_plot_params.cpp
-
2pcbnew/pcbnew_config.cpp
@ -0,0 +1,135 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <regex>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <gal/gal_display_options.h>
|
|||
#include <layers_id_colors_and_visibility.h>
|
|||
#include <panel_pcbnew_color_settings.h>
|
|||
#include <pcbnew_settings.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <pgm_base.h>
|
|||
#include <settings/settings_manager.h>
|
|||
|
|||
|
|||
PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame, |
|||
wxWindow* aParent ) |
|||
: PANEL_COLOR_SETTINGS( aParent ), |
|||
m_frame( aFrame ), |
|||
m_page( nullptr ), |
|||
m_titleBlock( nullptr ), |
|||
m_ws( nullptr ) |
|||
{ |
|||
// Currently this only applies to eeschema
|
|||
m_optOverrideColors->Hide(); |
|||
|
|||
m_colorNamespace = "board"; |
|||
|
|||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); |
|||
|
|||
mgr.ReloadColorSettings(); |
|||
|
|||
PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings<PCBNEW_SETTINGS>(); |
|||
COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); |
|||
|
|||
m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() ); |
|||
|
|||
m_currentSettings = new COLOR_SETTINGS( *current ); |
|||
|
|||
createThemeList( current ); |
|||
|
|||
for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; id++ ) |
|||
m_validLayers.push_back( id ); |
|||
|
|||
for( int id = F_Cu; id < PCB_LAYER_ID_COUNT; id++ ) |
|||
m_validLayers.push_back( id ); |
|||
|
|||
m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 ); |
|||
|
|||
createButtons(); |
|||
} |
|||
|
|||
|
|||
PANEL_PCBNEW_COLOR_SETTINGS::~PANEL_PCBNEW_COLOR_SETTINGS() |
|||
{ |
|||
delete m_page; |
|||
delete m_titleBlock; |
|||
} |
|||
|
|||
|
|||
bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow() |
|||
{ |
|||
m_currentSettings->SetOverrideSchItemColors( m_optOverrideColors->GetValue() ); |
|||
|
|||
if( !saveCurrentTheme( true ) ) |
|||
return false; |
|||
|
|||
m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( m_currentSettings ); |
|||
|
|||
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); |
|||
PCBNEW_SETTINGS* app_settings = settingsMgr.GetAppSettings<PCBNEW_SETTINGS>(); |
|||
app_settings->m_ColorTheme = m_currentSettings->GetFilename(); |
|||
|
|||
m_frame->ReFillLayerWidget(); |
|||
m_frame->SyncRenderStates(); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataToWindow() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
|
|||
void PANEL_PCBNEW_COLOR_SETTINGS::createButtons() |
|||
{ |
|||
std::vector<int> layers; |
|||
|
|||
for( GAL_LAYER_ID i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; ++i ) |
|||
{ |
|||
if( m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED ) |
|||
layers.push_back( i ); |
|||
} |
|||
|
|||
std::sort( layers.begin(), layers.end(), |
|||
[]( int a, int b ) |
|||
{ |
|||
return LayerName( a ) < LayerName( b ); |
|||
} ); |
|||
|
|||
// Don't sort board layers by name
|
|||
for( int i = PCBNEW_LAYER_ID_START; i < PCB_LAYER_ID_COUNT; ++i ) |
|||
layers.insert( layers.begin() + i, i ); |
|||
|
|||
BOARD* board = m_frame->GetBoard(); |
|||
|
|||
for( int layer : layers ) |
|||
{ |
|||
wxString name = LayerName( layer ); |
|||
|
|||
if( board && layer >= PCBNEW_LAYER_ID_START && layer < PCB_LAYER_ID_COUNT ) |
|||
name = board->GetLayerName( static_cast<PCB_LAYER_ID>( layer ) ); |
|||
|
|||
createButton( layer, m_currentSettings->GetColor( layer ), name ); |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com> |
|||
* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef PANEL_PCBNEW_COLOR_SETTINGS_H_ |
|||
#define PANEL_PCBNEW_COLOR_SETTINGS_H_ |
|||
|
|||
#include <gal/color4d.h> |
|||
#include <layers_id_colors_and_visibility.h> |
|||
#include <panel_color_settings.h> |
|||
|
|||
class COLOR_SETTINGS; |
|||
class PAGE_INFO; |
|||
class PCB_EDIT_FRAME; |
|||
class TITLE_BLOCK; |
|||
|
|||
namespace KIGFX |
|||
{ |
|||
class WS_PROXY_VIEW_ITEM; |
|||
} |
|||
|
|||
class PANEL_PCBNEW_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS |
|||
{ |
|||
public: |
|||
PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame, wxWindow* aParent ); |
|||
|
|||
~PANEL_PCBNEW_COLOR_SETTINGS() override; |
|||
|
|||
protected: |
|||
bool TransferDataFromWindow() override; |
|||
|
|||
bool TransferDataToWindow() override; |
|||
|
|||
enum COLOR_CONTEXT_ID |
|||
{ |
|||
ID_COPY = wxID_HIGHEST + 1, |
|||
ID_PASTE, |
|||
ID_REVERT |
|||
}; |
|||
|
|||
private: |
|||
PCB_EDIT_FRAME* m_frame; |
|||
|
|||
PAGE_INFO* m_page; |
|||
|
|||
TITLE_BLOCK* m_titleBlock; |
|||
|
|||
KIGFX::WS_PROXY_VIEW_ITEM* m_ws; |
|||
|
|||
void createButtons(); |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue