From 564f363c572f2d653e418f11fe2fd420625f887f Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 24 Sep 2020 10:18:49 -0400 Subject: [PATCH] Pcbnew: fix user defined layer bugs. --- common/lset.cpp | 18 ++++++++++++ common/settings/color_settings.cpp | 9 ++++++ pcbnew/dialogs/panel_setup_layers.cpp | 33 ++++++++++++++-------- pcbnew/dialogs/panel_setup_layers.h | 2 ++ pcbnew/dialogs/panel_setup_layers_base.cpp | 18 ++++++++++++ pcbnew/dialogs/panel_setup_layers_base.fbp | 9 ++++++ pcbnew/pcb_layer_widget.cpp | 16 ++++++----- pcbnew/widgets/appearance_controls.cpp | 11 +++++++- 8 files changed, 96 insertions(+), 20 deletions(-) diff --git a/common/lset.cpp b/common/lset.cpp index 0075544626..525b4aaa33 100644 --- a/common/lset.cpp +++ b/common/lset.cpp @@ -242,6 +242,15 @@ LSEQ LSET::Users() const Eco2_User, Edge_Cuts, Margin, + User_1, + User_2, + User_3, + User_4, + User_5, + User_6, + User_7, + User_8, + User_9 }; return Seq( sequence, arrayDim( sequence ) ); @@ -269,6 +278,15 @@ LSEQ LSET::TechAndUserUIOrder() const B_CrtYd, F_Fab, B_Fab, + User_1, + User_2, + User_3, + User_4, + User_5, + User_6, + User_7, + User_8, + User_9 }; return Seq( sequence, arrayDim( sequence ) ); diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index 99e91fe665..c77071792c 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -195,6 +195,15 @@ COLOR_SETTINGS::COLOR_SETTINGS( wxString aFilename ) : CLR( "board.f_crtyd", F_CrtYd, COLOR4D( LIGHTGRAY ) ); CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) ); CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) ); + CLR( "board.user_1", User_1, COLOR4D( BLUE ) ); + CLR( "board.user_2", User_2, COLOR4D( BLUE ) ); + CLR( "board.user_3", User_3, COLOR4D( BLUE ) ); + CLR( "board.user_4", User_4, COLOR4D( BLUE ) ); + CLR( "board.user_5", User_5, COLOR4D( BLUE ) ); + CLR( "board.user_6", User_6, COLOR4D( BLUE ) ); + CLR( "board.user_7", User_7, COLOR4D( BLUE ) ); + CLR( "board.user_8", User_8, COLOR4D( BLUE ) ); + CLR( "board.user_9", User_9, COLOR4D( BLUE ) ); // Colors for 3D viewer, which are used as defaults unless overridden by the board CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) ); diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index 4db4ab56dc..37935a0441 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -848,17 +848,7 @@ bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aIm void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent ) { LSEQ seq; - wxArrayString availableUserDefinedLayers; - - for( seq = LSET::UserDefinedLayers().Seq(); seq; ++seq ) - { - wxCheckBox* checkBox = getCheckBox( *seq ); - - if( checkBox && checkBox->IsChecked() ) - continue; - - availableUserDefinedLayers.Add( LayerName( *seq ) ); - } + wxArrayString availableUserDefinedLayers = getAvailableUserDefinedLayers(); wxCHECK( !availableUserDefinedLayers.IsEmpty(), /* void */ ); @@ -899,6 +889,25 @@ void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent ) void PANEL_SETUP_LAYERS::onUpdateAddUserDefinedLayer( wxUpdateUIEvent& event ) { - event.Enable( m_PresetsChoice->GetSelection() == 0 ); + wxArrayString availableUserDefinedLayers = getAvailableUserDefinedLayers(); + + event.Enable( m_PresetsChoice->GetSelection() == 0 && !availableUserDefinedLayers.IsEmpty() ); } + +wxArrayString PANEL_SETUP_LAYERS::getAvailableUserDefinedLayers() +{ + wxArrayString availableUserDefinedLayers; + + for( LSEQ seq = LSET::UserDefinedLayers().Seq(); seq; ++seq ) + { + wxCheckBox* checkBox = getCheckBox( *seq ); + + if( checkBox && checkBox->IsShown() ) + continue; + + availableUserDefinedLayers.Add( LayerName( *seq ) ); + } + + return availableUserDefinedLayers; +} diff --git a/pcbnew/dialogs/panel_setup_layers.h b/pcbnew/dialogs/panel_setup_layers.h index 66ceeae545..3e222ab1ec 100644 --- a/pcbnew/dialogs/panel_setup_layers.h +++ b/pcbnew/dialogs/panel_setup_layers.h @@ -120,6 +120,8 @@ private: */ LSEQ getNonRemovableLayers(); + wxArrayString getAvailableUserDefinedLayers(); + PANEL_SETUP_LAYERS_CTLs getCTLs( LAYER_NUM aLayerNumber ); wxControl* getName( LAYER_NUM aLayer ); wxCheckBox* getCheckBox( LAYER_NUM aLayer ); diff --git a/pcbnew/dialogs/panel_setup_layers_base.cpp b/pcbnew/dialogs/panel_setup_layers_base.cpp index fde59dfb0a..4236f5fcee 100644 --- a/pcbnew/dialogs/panel_setup_layers_base.cpp +++ b/pcbnew/dialogs/panel_setup_layers_base.cpp @@ -886,6 +886,15 @@ PANEL_SETUP_LAYERS_BASE::PANEL_SETUP_LAYERS_BASE( wxWindow* parent, wxWindowID i m_Eco2CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_CommentsCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_DrawingsCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User1CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User2CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User3CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User4CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User5CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User6CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User7CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User8CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User9CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); } PANEL_SETUP_LAYERS_BASE::~PANEL_SETUP_LAYERS_BASE() @@ -945,5 +954,14 @@ PANEL_SETUP_LAYERS_BASE::~PANEL_SETUP_LAYERS_BASE() m_Eco2CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_CommentsCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_DrawingsCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User1CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User2CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User3CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User4CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User5CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User6CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User7CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User8CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); + m_User9CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); } diff --git a/pcbnew/dialogs/panel_setup_layers_base.fbp b/pcbnew/dialogs/panel_setup_layers_base.fbp index 2e60dcf0e4..02de6d7561 100644 --- a/pcbnew/dialogs/panel_setup_layers_base.fbp +++ b/pcbnew/dialogs/panel_setup_layers_base.fbp @@ -10147,6 +10147,7 @@ + OnCheckBox @@ -10336,6 +10337,7 @@ + OnCheckBox @@ -10525,6 +10527,7 @@ + OnCheckBox @@ -10714,6 +10717,7 @@ + OnCheckBox @@ -10903,6 +10907,7 @@ + OnCheckBox @@ -11092,6 +11097,7 @@ + OnCheckBox @@ -11281,6 +11287,7 @@ + OnCheckBox @@ -11470,6 +11477,7 @@ + OnCheckBox @@ -11659,6 +11667,7 @@ + OnCheckBox diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index 0940dcd655..e4e66e5f06 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004-2017 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2010-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2010-2020 KiCad Developers, see change_log.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 @@ -509,9 +509,6 @@ void PCB_LAYER_WIDGET::ReFill() } } - UpdateLayouts(); - - // technical layers are shown in this order: // Because they are static, wxGetTranslation must be explicitly // called for tooltips. @@ -536,7 +533,7 @@ void PCB_LAYER_WIDGET::ReFill() { F_CrtYd, _( "Footprint courtyards on board's front" ) }, { B_CrtYd, _( "Footprint courtyards on board's back" ) }, { F_Fab, _( "Footprint assembly on board's front" ) }, - { B_Fab, _( "Footprint assembly on board's back" ) } + { B_Fab, _( "Footprint assembly on board's back" ) }, }; for( unsigned i=0; iGetLayerName( layer ), layer, myframe->GetColorSettings()->GetColor( layer ), @@ -557,6 +557,8 @@ void PCB_LAYER_WIDGET::ReFill() getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString ); } } + + UpdateLayouts(); } @@ -640,8 +642,10 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal } } else + { if( myframe->GetCanvas() ) myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible ); + } if( isFinal ) myframe->GetCanvas()->Refresh(); @@ -671,7 +675,6 @@ void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor ) myframe->ReCreateHToolbar(); myframe->GetCanvas()->ForceRefresh(); - myframe->GetCanvas()->Refresh(); } @@ -703,7 +706,6 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) myframe->GetCanvas()->GetView()->SetLayerVisible( aId, isEnabled ); myframe->GetCanvas()->Refresh(); - myframe->GetCanvas()->Refresh(); } //----------------------------------------------- diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index a4b63e65f2..0470c3c819 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -1340,7 +1340,16 @@ void APPEARANCE_CONTROLS::rebuildLayers() { F_CrtYd, _( "Footprint courtyards on board's front" ) }, { B_CrtYd, _( "Footprint courtyards on board's back" ) }, { F_Fab, _( "Footprint assembly on board's front" ) }, - { B_Fab, _( "Footprint assembly on board's back" ) } + { B_Fab, _( "Footprint assembly on board's back" ) }, + { User_1, _( "User defined layer 1" ) }, + { User_2, _( "User defined layer 2" ) }, + { User_3, _( "User defined layer 3" ) }, + { User_4, _( "User defined layer 4" ) }, + { User_5, _( "User defined layer 5" ) }, + { User_6, _( "User defined layer 6" ) }, + { User_7, _( "User defined layer 7" ) }, + { User_8, _( "User defined layer 8" ) }, + { User_9, _( "User defined layer 9" ) }, }; for( const auto& entry : non_cu_seq )