Pcbnew: fix user defined layer bugs.

This commit is contained in:
Wayne Stambaugh 2020-09-24 10:18:49 -04:00
parent 5ad76a237e
commit 564f363c57
8 changed files with 96 additions and 20 deletions

View File

@ -242,6 +242,15 @@ LSEQ LSET::Users() const
Eco2_User, Eco2_User,
Edge_Cuts, Edge_Cuts,
Margin, Margin,
User_1,
User_2,
User_3,
User_4,
User_5,
User_6,
User_7,
User_8,
User_9
}; };
return Seq( sequence, arrayDim( sequence ) ); return Seq( sequence, arrayDim( sequence ) );
@ -269,6 +278,15 @@ LSEQ LSET::TechAndUserUIOrder() const
B_CrtYd, B_CrtYd,
F_Fab, F_Fab,
B_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 ) ); return Seq( sequence, arrayDim( sequence ) );

View File

@ -195,6 +195,15 @@ COLOR_SETTINGS::COLOR_SETTINGS( wxString aFilename ) :
CLR( "board.f_crtyd", F_CrtYd, COLOR4D( LIGHTGRAY ) ); CLR( "board.f_crtyd", F_CrtYd, COLOR4D( LIGHTGRAY ) );
CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) ); CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) );
CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) ); 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 // 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 ) ); CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );

View File

@ -848,17 +848,7 @@ bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aIm
void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent ) void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent )
{ {
LSEQ seq; LSEQ seq;
wxArrayString availableUserDefinedLayers; wxArrayString availableUserDefinedLayers = getAvailableUserDefinedLayers();
for( seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
{
wxCheckBox* checkBox = getCheckBox( *seq );
if( checkBox && checkBox->IsChecked() )
continue;
availableUserDefinedLayers.Add( LayerName( *seq ) );
}
wxCHECK( !availableUserDefinedLayers.IsEmpty(), /* void */ ); wxCHECK( !availableUserDefinedLayers.IsEmpty(), /* void */ );
@ -899,6 +889,25 @@ void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent )
void PANEL_SETUP_LAYERS::onUpdateAddUserDefinedLayer( wxUpdateUIEvent& event ) 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;
}

View File

@ -120,6 +120,8 @@ private:
*/ */
LSEQ getNonRemovableLayers(); LSEQ getNonRemovableLayers();
wxArrayString getAvailableUserDefinedLayers();
PANEL_SETUP_LAYERS_CTLs getCTLs( LAYER_NUM aLayerNumber ); PANEL_SETUP_LAYERS_CTLs getCTLs( LAYER_NUM aLayerNumber );
wxControl* getName( LAYER_NUM aLayer ); wxControl* getName( LAYER_NUM aLayer );
wxCheckBox* getCheckBox( LAYER_NUM aLayer ); wxCheckBox* getCheckBox( LAYER_NUM aLayer );

View File

@ -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_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_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_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() 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_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_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_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 );
} }

View File

@ -10147,6 +10147,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -10336,6 +10337,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -10525,6 +10527,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -10714,6 +10717,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -10903,6 +10907,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -11092,6 +11097,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -11281,6 +11287,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -11470,6 +11477,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -11659,6 +11667,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCheckBox">OnCheckBox</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2004-2017 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr * Copyright (C) 2004-2017 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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: // technical layers are shown in this order:
// Because they are static, wxGetTranslation must be explicitly // Because they are static, wxGetTranslation must be explicitly
// called for tooltips. // called for tooltips.
@ -536,7 +533,7 @@ void PCB_LAYER_WIDGET::ReFill()
{ F_CrtYd, _( "Footprint courtyards on board's front" ) }, { F_CrtYd, _( "Footprint courtyards on board's front" ) },
{ B_CrtYd, _( "Footprint courtyards on board's back" ) }, { B_CrtYd, _( "Footprint courtyards on board's back" ) },
{ F_Fab, _( "Footprint assembly on board's front" ) }, { 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; i<arrayDim( non_cu_seq ); ++i ) for( unsigned i=0; i<arrayDim( non_cu_seq ); ++i )
@ -544,7 +541,10 @@ void PCB_LAYER_WIDGET::ReFill()
PCB_LAYER_ID layer = non_cu_seq[i].layerId; PCB_LAYER_ID layer = non_cu_seq[i].layerId;
if( !enabled[layer] ) if( !enabled[layer] )
{
wxLogDebug( "Layer widget: layer %s not enabled.", LSET::Name( layer ) );
continue; continue;
}
AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer, AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
myframe->GetColorSettings()->GetColor( layer ), myframe->GetColorSettings()->GetColor( layer ),
@ -557,6 +557,8 @@ void PCB_LAYER_WIDGET::ReFill()
getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString ); getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
} }
} }
UpdateLayouts();
} }
@ -640,8 +642,10 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal
} }
} }
else else
{
if( myframe->GetCanvas() ) if( myframe->GetCanvas() )
myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible ); myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
}
if( isFinal ) if( isFinal )
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();
@ -671,7 +675,6 @@ void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
myframe->ReCreateHToolbar(); myframe->ReCreateHToolbar();
myframe->GetCanvas()->ForceRefresh(); 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()->GetView()->SetLayerVisible( aId, isEnabled );
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();
myframe->GetCanvas()->Refresh();
} }
//-----</LAYER_WIDGET callbacks>------------------------------------------ //-----</LAYER_WIDGET callbacks>------------------------------------------

View File

@ -1340,7 +1340,16 @@ void APPEARANCE_CONTROLS::rebuildLayers()
{ F_CrtYd, _( "Footprint courtyards on board's front" ) }, { F_CrtYd, _( "Footprint courtyards on board's front" ) },
{ B_CrtYd, _( "Footprint courtyards on board's back" ) }, { B_CrtYd, _( "Footprint courtyards on board's back" ) },
{ F_Fab, _( "Footprint assembly on board's front" ) }, { 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 ) for( const auto& entry : non_cu_seq )