2009-12-20 22:44:31 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2009-12-20 22:44:31 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br
|
|
|
|
* Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-06-03 15:41:26 +00:00
|
|
|
* Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2009-12-20 22:44:31 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2020-10-24 12:53:11 +00:00
|
|
|
#include <core/kicad_algo.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-03-27 08:18:20 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2017-09-28 17:00:24 +00:00
|
|
|
#include <collectors.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <panel_setup_layers.h>
|
2021-02-24 02:31:12 +00:00
|
|
|
#include <board_stackup_manager/panel_board_stackup.h>
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2021-01-25 15:18:28 +00:00
|
|
|
#include <wx/choicdlg.h>
|
2021-06-03 15:41:26 +00:00
|
|
|
#include <wx/treebook.h>
|
2021-08-03 00:11:11 +00:00
|
|
|
#include <eda_list_dialog.h>
|
2021-01-25 15:18:28 +00:00
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2010-03-10 14:05:52 +00:00
|
|
|
// some define to choose how copper layers widgets are shown
|
|
|
|
|
2010-03-13 22:28:34 +00:00
|
|
|
// if defined, display only active copper layers
|
2015-10-20 18:03:07 +00:00
|
|
|
// if not displays always 1=the full set (32 copper layers)
|
2010-03-13 22:28:34 +00:00
|
|
|
#define HIDE_INACTIVE_LAYERS
|
2010-03-10 14:05:52 +00:00
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSEQ dlg_layers()
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2020-08-07 17:08:45 +00:00
|
|
|
// Layers that are put out into the dialog UI, coordinate with wxformbuilder and
|
2021-07-21 23:14:56 +00:00
|
|
|
// getCTLs( int aLayerNumber )
|
2017-03-13 03:19:33 +00:00
|
|
|
static const PCB_LAYER_ID layers[] = {
|
2014-09-14 15:34:37 +00:00
|
|
|
F_CrtYd,
|
|
|
|
F_Fab,
|
2014-06-24 16:17:18 +00:00
|
|
|
F_Adhes,
|
|
|
|
F_Paste,
|
|
|
|
F_SilkS,
|
|
|
|
F_Mask,
|
|
|
|
F_Cu,
|
|
|
|
|
2014-06-29 18:09:32 +00:00
|
|
|
In1_Cu,
|
2014-06-24 16:17:18 +00:00
|
|
|
In2_Cu,
|
|
|
|
In3_Cu,
|
|
|
|
In4_Cu,
|
|
|
|
In5_Cu,
|
|
|
|
In6_Cu,
|
|
|
|
In7_Cu,
|
|
|
|
In8_Cu,
|
|
|
|
In9_Cu,
|
|
|
|
In10_Cu,
|
|
|
|
In11_Cu,
|
|
|
|
In12_Cu,
|
|
|
|
In13_Cu,
|
|
|
|
In14_Cu,
|
|
|
|
In15_Cu,
|
|
|
|
|
|
|
|
In16_Cu,
|
|
|
|
In17_Cu,
|
|
|
|
In18_Cu,
|
|
|
|
In19_Cu,
|
|
|
|
In20_Cu,
|
|
|
|
In21_Cu,
|
|
|
|
In22_Cu,
|
|
|
|
In23_Cu,
|
|
|
|
In24_Cu,
|
|
|
|
In25_Cu,
|
|
|
|
In26_Cu,
|
|
|
|
In27_Cu,
|
|
|
|
In28_Cu,
|
|
|
|
In29_Cu,
|
|
|
|
In30_Cu,
|
|
|
|
|
|
|
|
B_Cu,
|
|
|
|
B_Mask,
|
|
|
|
B_SilkS,
|
|
|
|
B_Paste,
|
|
|
|
B_Adhes,
|
2014-09-14 15:34:37 +00:00
|
|
|
B_Fab,
|
|
|
|
B_CrtYd,
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
Edge_Cuts,
|
|
|
|
Margin,
|
|
|
|
Eco2_User,
|
|
|
|
Eco1_User,
|
|
|
|
Cmts_User,
|
|
|
|
Dwgs_User,
|
2020-09-22 21:50:59 +00:00
|
|
|
|
|
|
|
User_1,
|
|
|
|
User_2,
|
|
|
|
User_3,
|
|
|
|
User_4,
|
|
|
|
User_5,
|
|
|
|
User_6,
|
|
|
|
User_7,
|
|
|
|
User_8,
|
|
|
|
User_9,
|
2014-06-24 16:17:18 +00:00
|
|
|
};
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
return LSEQ( layers, layers + arrayDim( layers ) );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
|
2018-07-15 23:15:48 +00:00
|
|
|
PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ),
|
2021-02-25 03:55:11 +00:00
|
|
|
m_parentDialog( aParent ),
|
|
|
|
m_frame( aFrame ),
|
|
|
|
m_physicalStackup( nullptr )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
|
|
|
m_pcb = aFrame->GetBoard();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
PANEL_SETUP_LAYERS_CTLs PANEL_SETUP_LAYERS::getCTLs( int aLayerNumber )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2021-08-25 00:29:03 +00:00
|
|
|
#define RETURN_COPPER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Choice )
|
|
|
|
#define RETURN_AUX( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##StaticText )
|
|
|
|
#define RETURN_MANDATORY( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, nullptr, x##StaticText )
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
switch( aLayerNumber )
|
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
case F_CrtYd: RETURN_MANDATORY( m_CrtYdFront );
|
|
|
|
case F_Fab: RETURN_AUX( m_FabFront );
|
|
|
|
case F_Adhes: RETURN_AUX( m_AdhesFront );
|
|
|
|
case F_Paste: RETURN_AUX( m_SoldPFront );
|
|
|
|
case F_SilkS: RETURN_AUX( m_SilkSFront );
|
|
|
|
case F_Mask: RETURN_AUX( m_MaskFront );
|
|
|
|
case F_Cu: RETURN_COPPER( m_Front );
|
|
|
|
|
|
|
|
case In1_Cu: RETURN_COPPER( m_In1 );
|
|
|
|
case In2_Cu: RETURN_COPPER( m_In2 );
|
|
|
|
case In3_Cu: RETURN_COPPER( m_In3 );
|
|
|
|
case In4_Cu: RETURN_COPPER( m_In4 );
|
|
|
|
case In5_Cu: RETURN_COPPER( m_In5 );
|
|
|
|
case In6_Cu: RETURN_COPPER( m_In6 );
|
|
|
|
case In7_Cu: RETURN_COPPER( m_In7 );
|
|
|
|
case In8_Cu: RETURN_COPPER( m_In8 );
|
|
|
|
case In9_Cu: RETURN_COPPER( m_In9 );
|
|
|
|
case In10_Cu: RETURN_COPPER( m_In10 );
|
|
|
|
case In11_Cu: RETURN_COPPER( m_In11 );
|
|
|
|
case In12_Cu: RETURN_COPPER( m_In12 );
|
|
|
|
case In13_Cu: RETURN_COPPER( m_In13 );
|
|
|
|
case In14_Cu: RETURN_COPPER( m_In14 );
|
|
|
|
case In15_Cu: RETURN_COPPER( m_In15 );
|
|
|
|
|
|
|
|
case In16_Cu: RETURN_COPPER( m_In16 );
|
|
|
|
case In17_Cu: RETURN_COPPER( m_In17 );
|
|
|
|
case In18_Cu: RETURN_COPPER( m_In18 );
|
|
|
|
case In19_Cu: RETURN_COPPER( m_In19 );
|
|
|
|
case In20_Cu: RETURN_COPPER( m_In20 );
|
|
|
|
case In21_Cu: RETURN_COPPER( m_In21 );
|
|
|
|
case In22_Cu: RETURN_COPPER( m_In22 );
|
|
|
|
case In23_Cu: RETURN_COPPER( m_In23 );
|
|
|
|
case In24_Cu: RETURN_COPPER( m_In24 );
|
|
|
|
case In25_Cu: RETURN_COPPER( m_In25 );
|
|
|
|
case In26_Cu: RETURN_COPPER( m_In26 );
|
|
|
|
case In27_Cu: RETURN_COPPER( m_In27 );
|
|
|
|
case In28_Cu: RETURN_COPPER( m_In28 );
|
|
|
|
case In29_Cu: RETURN_COPPER( m_In29 );
|
|
|
|
case In30_Cu: RETURN_COPPER( m_In30 );
|
|
|
|
|
|
|
|
case B_Cu: RETURN_COPPER( m_Back );
|
|
|
|
case B_Mask: RETURN_AUX( m_MaskBack );
|
|
|
|
case B_SilkS: RETURN_AUX( m_SilkSBack );
|
|
|
|
case B_Paste: RETURN_AUX( m_SoldPBack );
|
|
|
|
case B_Adhes: RETURN_AUX( m_AdhesBack );
|
|
|
|
case B_Fab: RETURN_AUX( m_FabBack );
|
|
|
|
case B_CrtYd: RETURN_MANDATORY( m_CrtYdBack );
|
|
|
|
|
|
|
|
case Edge_Cuts: RETURN_MANDATORY( m_PCBEdges );
|
|
|
|
case Margin: RETURN_MANDATORY( m_Margin );
|
|
|
|
case Eco2_User: RETURN_AUX( m_Eco2 );
|
|
|
|
case Eco1_User: RETURN_AUX( m_Eco1 );
|
|
|
|
case Cmts_User: RETURN_AUX( m_Comments );
|
|
|
|
case Dwgs_User: RETURN_AUX( m_Drawings );
|
|
|
|
|
|
|
|
case User_1: RETURN_AUX( m_User1 );
|
|
|
|
case User_2: RETURN_AUX( m_User2 );
|
|
|
|
case User_3: RETURN_AUX( m_User3 );
|
|
|
|
case User_4: RETURN_AUX( m_User4 );
|
|
|
|
case User_5: RETURN_AUX( m_User5 );
|
|
|
|
case User_6: RETURN_AUX( m_User6 );
|
|
|
|
case User_7: RETURN_AUX( m_User7 );
|
|
|
|
case User_8: RETURN_AUX( m_User8 );
|
|
|
|
case User_9: RETURN_AUX( m_User9 );
|
2020-09-22 21:50:59 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
default:
|
2014-06-24 16:17:18 +00:00
|
|
|
wxASSERT_MSG( 0, wxT( "bad layer id" ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
return PANEL_SETUP_LAYERS_CTLs( nullptr, nullptr, nullptr );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
wxControl* PANEL_SETUP_LAYERS::getName( int aLayer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
return getCTLs( aLayer ).name;
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
wxCheckBox* PANEL_SETUP_LAYERS::getCheckBox( int aLayer )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
return getCTLs( aLayer ).checkbox;
|
|
|
|
}
|
2015-02-28 16:48:39 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
wxChoice* PANEL_SETUP_LAYERS::getChoice( int aLayer )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
|
|
|
return (wxChoice*) getCTLs( aLayer ).choice;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
bool PANEL_SETUP_LAYERS::TransferDataToWindow()
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
m_enabledLayers = m_pcb->GetEnabledLayers();
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2020-09-30 23:04:31 +00:00
|
|
|
// Rescue may be enabled, but should not be shown in this dialog
|
|
|
|
m_enabledLayers.reset( Rescue );
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
setCopperLayerCheckBoxes( m_pcb->GetCopperLayerCount() );
|
2017-09-28 17:00:24 +00:00
|
|
|
|
|
|
|
showBoardLayerNames();
|
|
|
|
showSelectedLayerCheckBoxes( m_enabledLayers );
|
2021-02-24 02:31:12 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
showLayerTypes();
|
2018-05-30 15:21:14 +00:00
|
|
|
setMandatoryLayerCheckBoxes();
|
2020-09-22 21:50:59 +00:00
|
|
|
setUserDefinedLayerCheckBoxes();
|
2017-09-28 17:00:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-24 02:31:12 +00:00
|
|
|
void PANEL_SETUP_LAYERS::SyncCopperLayers( int aNumCopperLayers )
|
|
|
|
{
|
|
|
|
setCopperLayerCheckBoxes( aNumCopperLayers );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::setMandatoryLayerCheckBoxes()
|
2015-04-19 11:09:35 +00:00
|
|
|
{
|
2018-05-30 15:21:14 +00:00
|
|
|
for( int layer : { F_CrtYd, B_CrtYd, Edge_Cuts, Margin } )
|
|
|
|
setLayerCheckBox( layer, true );
|
2015-04-19 11:09:35 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
void PANEL_SETUP_LAYERS::setUserDefinedLayerCheckBoxes()
|
|
|
|
{
|
|
|
|
for( LSEQ seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID layer = *seq;
|
2021-07-21 23:14:56 +00:00
|
|
|
bool state = m_pcb->IsLayerEnabled( layer );
|
2020-09-22 21:50:59 +00:00
|
|
|
|
|
|
|
#ifdef HIDE_INACTIVE_LAYERS
|
2021-04-03 09:30:38 +00:00
|
|
|
// This code hides inactive copper layers, or redisplays hidden layers which are now needed.
|
2020-09-22 21:50:59 +00:00
|
|
|
PANEL_SETUP_LAYERS_CTLs ctl = getCTLs( layer );
|
|
|
|
|
2021-08-25 00:29:03 +00:00
|
|
|
// All user-defined layers should have a checkbox
|
|
|
|
wxASSERT( ctl.checkbox );
|
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
ctl.name->Show( state );
|
|
|
|
ctl.checkbox->Show( state );
|
|
|
|
ctl.choice->Show( state );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
setLayerCheckBox( layer, state );
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HIDE_INACTIVE_LAYERS
|
|
|
|
// Send an size event to force sizers to be updated,
|
|
|
|
// because the number of copper layers can have changed.
|
|
|
|
wxSizeEvent evt_size( m_LayersListPanel->GetSize() );
|
|
|
|
m_LayersListPanel->GetEventHandler()->ProcessEvent( evt_size );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::showBoardLayerNames()
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2018-05-30 15:21:14 +00:00
|
|
|
// Set all the board's layer names into the dialog by calling BOARD::GetLayerName(),
|
|
|
|
// which will call BOARD::GetStandardLayerName() for non-coppers.
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = dlg_layers(); seq; ++seq )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2018-05-30 15:21:14 +00:00
|
|
|
wxControl* ctl = getName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( ctl )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2015-04-19 11:09:35 +00:00
|
|
|
wxString lname = m_pcb->GetLayerName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2020-01-13 01:39:08 +00:00
|
|
|
if( auto textCtl = dynamic_cast<wxTextCtrl*>( ctl ) )
|
2021-12-19 09:09:27 +00:00
|
|
|
textCtl->ChangeValue( lname ); // wxTextCtrl
|
2009-12-20 22:44:31 +00:00
|
|
|
else
|
2020-01-13 01:39:08 +00:00
|
|
|
ctl->SetLabel( lname ); // wxStaticText
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::showSelectedLayerCheckBoxes( LSET enabledLayers )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2020-08-07 17:08:45 +00:00
|
|
|
// The check boxes
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = dlg_layers(); seq; ++seq )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2014-06-24 16:17:18 +00:00
|
|
|
setLayerCheckBox( layer, enabledLayers[layer] );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::showLayerTypes()
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID cu_layer = *seq;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
wxChoice* ctl = getChoice( cu_layer );
|
2015-04-19 11:09:35 +00:00
|
|
|
ctl->SetSelection( m_pcb->GetLayerType( cu_layer ) );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
LSET PANEL_SETUP_LAYERS::GetUILayerMask()
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layerMaskResult;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = dlg_layers(); seq; ++seq )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-05-30 15:21:14 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
|
|
|
wxCheckBox* ctl = getCheckBox( layer );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-08-25 00:29:03 +00:00
|
|
|
if( !ctl || ctl->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMaskResult.set( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
return layerMaskResult;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
void PANEL_SETUP_LAYERS::setLayerCheckBox( int aLayer, bool isChecked )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
PANEL_SETUP_LAYERS_CTLs ctl = getCTLs( aLayer );
|
|
|
|
|
2021-08-25 00:29:03 +00:00
|
|
|
if( !ctl.checkbox )
|
|
|
|
return;
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
ctl.checkbox->SetValue( isChecked );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::setCopperLayerCheckBoxes( int copperCount )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
if( copperCount > 0 )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
setLayerCheckBox( F_Cu, true );
|
2009-12-20 22:44:31 +00:00
|
|
|
--copperCount;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( copperCount > 0 )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
setLayerCheckBox( B_Cu, true );
|
2009-12-20 22:44:31 +00:00
|
|
|
--copperCount;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = LSET::InternalCuMask().Seq(); seq; ++seq, --copperCount )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2014-06-24 16:17:18 +00:00
|
|
|
bool state = copperCount > 0;
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2010-03-10 14:05:52 +00:00
|
|
|
#ifdef HIDE_INACTIVE_LAYERS
|
2021-04-03 09:30:38 +00:00
|
|
|
// This code hides inactive copper layers, or redisplays hidden layers which are now needed.
|
2018-04-28 15:22:25 +00:00
|
|
|
PANEL_SETUP_LAYERS_CTLs ctl = getCTLs( layer );
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2021-08-25 00:29:03 +00:00
|
|
|
// Inner layers should have a checkbox
|
|
|
|
wxASSERT( ctl.checkbox );
|
|
|
|
|
2010-03-09 09:51:22 +00:00
|
|
|
ctl.name->Show( state );
|
|
|
|
ctl.checkbox->Show( state );
|
|
|
|
ctl.choice->Show( state );
|
2010-03-10 14:05:52 +00:00
|
|
|
#endif
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2010-03-07 17:51:10 +00:00
|
|
|
setLayerCheckBox( layer, state );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
2010-03-09 09:51:22 +00:00
|
|
|
|
2010-03-10 14:05:52 +00:00
|
|
|
#ifdef HIDE_INACTIVE_LAYERS
|
2010-03-09 09:51:22 +00:00
|
|
|
// Send an size event to force sizers to be updated,
|
|
|
|
// because the number of copper layers can have changed.
|
2014-06-24 16:17:18 +00:00
|
|
|
wxSizeEvent evt_size( m_LayersListPanel->GetSize() );
|
2010-03-09 09:51:22 +00:00
|
|
|
m_LayersListPanel->GetEventHandler()->ProcessEvent( evt_size );
|
2010-03-10 14:05:52 +00:00
|
|
|
#endif
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::OnCheckBox( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2019-07-27 19:09:43 +00:00
|
|
|
m_enabledLayers = GetUILayerMask();
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::DenyChangeCheckBox( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-05-30 15:21:14 +00:00
|
|
|
wxObject* source = event.GetEventObject();
|
2018-04-28 15:22:25 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
|
2018-05-30 15:21:14 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
wxCheckBox* copper = getCheckBox( *seq );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( source == copper )
|
2018-05-30 15:21:14 +00:00
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
DisplayError( this, _( "Use the Physical Stackup page to change the number of "
|
|
|
|
"copper layers." ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
copper->SetValue( true );
|
|
|
|
return;
|
2018-05-30 15:21:14 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
bool PANEL_SETUP_LAYERS::TransferDataFromWindow()
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
if( !testLayerNames() )
|
2018-05-30 15:21:14 +00:00
|
|
|
return false;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2021-02-25 03:55:11 +00:00
|
|
|
wxASSERT( m_physicalStackup );
|
|
|
|
|
2021-02-24 02:31:12 +00:00
|
|
|
// Make sure we have the latest copper layer count
|
|
|
|
SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() );
|
|
|
|
|
2018-05-30 15:21:14 +00:00
|
|
|
wxString msg;
|
2020-10-13 22:05:15 +00:00
|
|
|
bool modified = false;
|
2017-09-28 17:00:24 +00:00
|
|
|
|
|
|
|
// Check for removed layers with items which will get deleted from the board.
|
|
|
|
LSEQ removedLayers = getRemovedLayersWithItems();
|
2012-02-06 07:14:51 +00:00
|
|
|
|
2020-08-07 17:08:45 +00:00
|
|
|
// Check for non-copper layers in use in footprints, and therefore not removable.
|
2018-03-27 08:18:20 +00:00
|
|
|
LSEQ notremovableLayers = getNonRemovableLayers();
|
|
|
|
|
|
|
|
if( !notremovableLayers.empty() )
|
|
|
|
{
|
|
|
|
for( unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
|
2022-02-04 22:44:59 +00:00
|
|
|
msg << m_pcb->GetLayerName( notremovableLayers[ii] ) << wxT( "\n" );
|
2018-03-27 08:18:20 +00:00
|
|
|
|
|
|
|
if( !IsOK( this, wxString::Format( _( "Footprints have some items on removed layers:\n"
|
|
|
|
"%s\n"
|
|
|
|
"These items will be no longer accessible\n"
|
|
|
|
"Do you wish to continue?" ), msg ) ) )
|
2020-10-13 22:05:15 +00:00
|
|
|
{
|
2018-03-27 08:18:20 +00:00
|
|
|
return false;
|
2020-10-13 22:05:15 +00:00
|
|
|
}
|
2018-03-27 08:18:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
if( !removedLayers.empty()
|
|
|
|
&& !IsOK( this, _( "Items have been found on removed layers. This operation will "
|
|
|
|
"delete all items from removed layers and cannot be undone.\n"
|
|
|
|
"Do you wish to continue?" ) ) )
|
|
|
|
{
|
2017-09-28 17:00:24 +00:00
|
|
|
return false;
|
2020-10-13 22:05:15 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
// Delete all objects on layers that have been removed. Leaving them in copper layers
|
|
|
|
// can (will?) result in DRC errors and it pollutes the board file with cruft.
|
2018-03-27 08:18:20 +00:00
|
|
|
bool hasRemovedBoardItems = false;
|
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
if( !removedLayers.empty() )
|
|
|
|
{
|
|
|
|
PCB_LAYER_COLLECTOR collector;
|
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
for( PCB_LAYER_ID layer_id : removedLayers )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2017-09-28 17:00:24 +00:00
|
|
|
collector.SetLayerId( layer_id );
|
|
|
|
collector.Collect( m_pcb, GENERAL_COLLECTOR::BoardLevelItems );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-08-07 17:08:45 +00:00
|
|
|
// Bye-bye items on removed layer.
|
2020-08-09 11:22:09 +00:00
|
|
|
for( int i = 0; i < collector.GetCount(); i++ )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2020-08-09 11:22:09 +00:00
|
|
|
BOARD_ITEM* item = collector[i];
|
|
|
|
LSET layers = item->GetLayerSet();
|
|
|
|
|
|
|
|
layers.reset( layer_id );
|
2018-03-27 08:18:20 +00:00
|
|
|
hasRemovedBoardItems = true;
|
2020-10-13 22:05:15 +00:00
|
|
|
modified = true;
|
2018-03-27 08:18:20 +00:00
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
if( layers.any() )
|
|
|
|
{
|
|
|
|
item->SetLayerSet( layers );
|
|
|
|
}
|
|
|
|
else
|
2018-03-27 08:18:20 +00:00
|
|
|
{
|
|
|
|
m_pcb->Remove( item );
|
|
|
|
delete item;
|
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
m_enabledLayers = GetUILayerMask();
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2022-06-08 03:00:32 +00:00
|
|
|
LSET previousEnabled = m_pcb->GetEnabledLayers();
|
|
|
|
|
|
|
|
if( m_enabledLayers != previousEnabled )
|
2018-07-24 17:43:17 +00:00
|
|
|
{
|
|
|
|
m_pcb->SetEnabledLayers( m_enabledLayers );
|
|
|
|
|
2022-06-08 03:00:32 +00:00
|
|
|
LSET changedLayers = m_enabledLayers ^ previousEnabled;
|
|
|
|
|
2018-07-24 17:43:17 +00:00
|
|
|
/* Ensure enabled layers are also visible
|
|
|
|
* This is mainly to avoid mistakes if some enabled
|
|
|
|
* layers are not visible when exiting this dialog
|
|
|
|
*/
|
2022-06-08 03:00:32 +00:00
|
|
|
m_pcb->SetVisibleLayers( m_pcb->GetVisibleLayers() | changedLayers );
|
2020-10-13 22:05:15 +00:00
|
|
|
|
|
|
|
modified = true;
|
2018-07-24 17:43:17 +00:00
|
|
|
}
|
2015-04-20 16:48:31 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
|
|
|
PCB_LAYER_ID layer = *seq;
|
2015-04-20 16:48:31 +00:00
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
if( m_enabledLayers[layer] )
|
|
|
|
{
|
2020-10-13 22:05:15 +00:00
|
|
|
const wxString& newLayerName = GetLayerName( layer );
|
|
|
|
|
|
|
|
if( m_pcb->GetLayerName( layer ) != newLayerName )
|
|
|
|
{
|
|
|
|
m_pcb->SetLayerName( layer, newLayerName );
|
|
|
|
modified = true;
|
|
|
|
}
|
2020-09-22 21:50:59 +00:00
|
|
|
|
|
|
|
// Only copper layers have a definable type.
|
|
|
|
if( LSET::AllCuMask().Contains( layer ) )
|
|
|
|
{
|
|
|
|
LAYER_T t = (LAYER_T) getLayerTypeIndex( layer );
|
2020-10-13 22:05:15 +00:00
|
|
|
|
|
|
|
if( m_pcb->GetLayerType( layer ) != t )
|
|
|
|
{
|
|
|
|
m_pcb->SetLayerType( layer, t );
|
|
|
|
modified = true;
|
|
|
|
}
|
2020-09-22 21:50:59 +00:00
|
|
|
}
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2017-09-28 17:00:24 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
for( LSEQ seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
|
|
|
|
{
|
2020-10-13 22:05:15 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
|
|
|
const wxString& newLayerName = GetLayerName( layer );
|
|
|
|
|
|
|
|
if( m_enabledLayers[ layer ] && m_pcb->GetLayerName( layer ) != newLayerName )
|
|
|
|
{
|
|
|
|
m_pcb->SetLayerName( layer, newLayerName );
|
|
|
|
modified = true;
|
|
|
|
}
|
2020-09-22 21:50:59 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 17:08:45 +00:00
|
|
|
// If some board items are deleted: Rebuild the connectivity,
|
|
|
|
// because it is likely some tracks and vias were removed
|
2018-03-27 08:18:20 +00:00
|
|
|
if( hasRemovedBoardItems )
|
|
|
|
{
|
|
|
|
// Rebuild list of nets (full ratsnest rebuild)
|
|
|
|
m_pcb->BuildConnectivity();
|
2020-06-16 18:18:52 +00:00
|
|
|
m_frame->Compile_Ratsnest( true );
|
2018-03-27 08:18:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
if( modified )
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
return true;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
int PANEL_SETUP_LAYERS::getLayerTypeIndex( int aLayer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2020-08-07 17:08:45 +00:00
|
|
|
wxChoice* ctl = getChoice( aLayer );
|
|
|
|
int ret = ctl->GetCurrentSelection(); // Indices must have same sequence as LAYER_T
|
2009-12-20 22:44:31 +00:00
|
|
|
return ret;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
wxString PANEL_SETUP_LAYERS::GetLayerName( int aLayer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-05-30 15:21:14 +00:00
|
|
|
wxControl* control = getName( aLayer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2020-01-13 14:00:45 +00:00
|
|
|
if( auto textCtl = dynamic_cast<wxTextCtrl*>( control ) )
|
|
|
|
return textCtl->GetValue().Trim();
|
2018-05-30 15:21:14 +00:00
|
|
|
else
|
2020-01-13 14:00:45 +00:00
|
|
|
return control->GetLabel();
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
static bool hasOneOf( const wxString& str, const wxString& chars )
|
|
|
|
{
|
|
|
|
for( unsigned i=0; i<chars.Len(); ++i )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
if( str.Find( chars[i] ) != wxNOT_FOUND )
|
|
|
|
return true;
|
2017-09-28 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
bool PANEL_SETUP_LAYERS::testLayerNames()
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
std::vector<wxString> names;
|
|
|
|
wxTextCtrl* ctl;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
// we _can_ rely on m_enabledLayers being current here:
|
2020-08-07 17:08:45 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
if( !m_enabledLayers[layer] )
|
2009-12-20 22:44:31 +00:00
|
|
|
continue;
|
2009-10-25 15:54:00 +00:00
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
wxString name = GetLayerName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
ctl = (wxTextCtrl*) getName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2020-08-07 17:08:45 +00:00
|
|
|
// Check name for legality:
|
|
|
|
// 1) Cannot be blank.
|
|
|
|
// 2) Cannot have blanks.
|
|
|
|
// 3) Cannot have " chars
|
|
|
|
// 4) Cannot be 'signal'
|
|
|
|
// 5) Must be unique.
|
|
|
|
// 6) Cannot have illegal chars in filenames ( some filenames are built from layer names )
|
2015-10-20 18:03:07 +00:00
|
|
|
// like : % $ \ " / :
|
2017-09-28 17:00:24 +00:00
|
|
|
wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
|
2015-10-20 18:03:07 +00:00
|
|
|
badchars.Append( '%' );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !name )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2021-02-24 02:31:12 +00:00
|
|
|
m_parentDialog->SetError( _( "Layer must have a name." ), this, ctl );
|
2009-12-20 22:44:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( hasOneOf( name, badchars ) )
|
|
|
|
{
|
2021-06-28 23:44:07 +00:00
|
|
|
wxString msg = wxString::Format(_( "%s are forbidden in layer names." ), badchars );
|
2021-02-24 02:31:12 +00:00
|
|
|
m_parentDialog->SetError( msg, this, ctl );
|
2009-12-20 22:44:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-28 17:00:24 +00:00
|
|
|
if( name == wxT( "signal" ) )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2021-02-24 02:31:12 +00:00
|
|
|
m_parentDialog->SetError( _( "Layer name \"signal\" is reserved." ), this, ctl );
|
2009-12-20 22:44:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
for( const wxString& existingName : names )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
if( name == existingName )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2021-06-28 23:44:07 +00:00
|
|
|
wxString msg = wxString::Format(_( "Layer name '%s' already in use." ), name );
|
2021-02-24 02:31:12 +00:00
|
|
|
m_parentDialog->SetError( msg, this, ctl );
|
2009-12-20 22:44:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
names.push_back( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
LSEQ PANEL_SETUP_LAYERS::getRemovedLayersWithItems()
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
|
|
|
LSEQ removedLayers;
|
2019-07-27 19:09:43 +00:00
|
|
|
LSET newLayers = GetUILayerMask();
|
2017-09-28 17:00:24 +00:00
|
|
|
LSET curLayers = m_pcb->GetEnabledLayers();
|
|
|
|
|
2020-08-07 17:08:45 +00:00
|
|
|
if( newLayers == curLayers ) // Return an empty list if no change
|
2017-09-28 17:00:24 +00:00
|
|
|
return removedLayers;
|
|
|
|
|
|
|
|
PCB_LAYER_COLLECTOR collector;
|
|
|
|
LSEQ newLayerSeq = newLayers.Seq();
|
|
|
|
|
2020-09-26 11:40:32 +00:00
|
|
|
for( PCB_LAYER_ID layer_id : curLayers.Seq() )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
2020-09-26 13:42:40 +00:00
|
|
|
if( !alg::contains( newLayerSeq, layer_id ) )
|
2017-09-28 17:00:24 +00:00
|
|
|
{
|
|
|
|
collector.SetLayerId( layer_id );
|
|
|
|
collector.Collect( m_pcb, GENERAL_COLLECTOR::BoardLevelItems );
|
|
|
|
|
|
|
|
if( collector.GetCount() != 0 )
|
|
|
|
removedLayers.push_back( layer_id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return removedLayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
LSEQ PANEL_SETUP_LAYERS::getNonRemovableLayers()
|
2018-03-27 08:18:20 +00:00
|
|
|
{
|
2020-08-07 17:08:45 +00:00
|
|
|
// Build the list of non-copper layers in use in footprints.
|
2018-03-27 08:18:20 +00:00
|
|
|
LSEQ inUseLayers;
|
2019-07-27 19:09:43 +00:00
|
|
|
LSET newLayers = GetUILayerMask();
|
2018-03-27 08:18:20 +00:00
|
|
|
LSET curLayers = m_pcb->GetEnabledLayers();
|
|
|
|
|
2020-08-07 17:08:45 +00:00
|
|
|
if( newLayers == curLayers ) // Return an empty list if no change
|
2018-03-27 08:18:20 +00:00
|
|
|
return inUseLayers;
|
|
|
|
|
|
|
|
PCB_LAYER_COLLECTOR collector;
|
|
|
|
LSEQ newLayerSeq = newLayers.Seq();
|
|
|
|
|
|
|
|
for( auto layer_id : curLayers.Seq() )
|
|
|
|
{
|
2020-08-07 17:08:45 +00:00
|
|
|
if( IsCopperLayer( layer_id ) ) // Copper layers are not taken into account here
|
2018-03-27 08:18:20 +00:00
|
|
|
continue;
|
|
|
|
|
2020-09-26 13:42:40 +00:00
|
|
|
if( !alg::contains( newLayerSeq, layer_id ) )
|
2018-03-27 08:18:20 +00:00
|
|
|
{
|
|
|
|
collector.SetLayerId( layer_id );
|
2020-11-14 19:16:42 +00:00
|
|
|
collector.Collect( m_pcb, GENERAL_COLLECTOR::FootprintItems );
|
2018-03-27 08:18:20 +00:00
|
|
|
|
|
|
|
if( collector.GetCount() != 0 )
|
|
|
|
inUseLayers.push_back( layer_id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return inUseLayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void PANEL_SETUP_LAYERS::ImportSettingsFrom( BOARD* aBoard )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
BOARD* savedBoard = m_pcb;
|
2011-03-01 19:26:17 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
m_pcb = aBoard;
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
m_pcb = savedBoard;
|
2018-09-04 10:28:52 +00:00
|
|
|
}
|
2020-08-07 17:08:45 +00:00
|
|
|
|
|
|
|
|
2020-09-20 12:42:43 +00:00
|
|
|
bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aImportedBoard )
|
2020-08-07 17:08:45 +00:00
|
|
|
{
|
2020-09-20 12:42:43 +00:00
|
|
|
/*
|
|
|
|
* This function warns users if they are going to delete inner copper layers because
|
|
|
|
* they're importing settings from a board with less copper layers than the board
|
|
|
|
* already loaded. We want to return "true" as default on the assumption no layer will
|
|
|
|
* actually be deleted.
|
|
|
|
*/
|
2020-08-07 17:08:45 +00:00
|
|
|
bool okToDeleteCopperLayers = true;
|
|
|
|
|
|
|
|
// Get the number of copper layers in the loaded board and the "import settings" board
|
|
|
|
int currNumLayers = aWorkingBoard->GetCopperLayerCount();
|
|
|
|
int newNumLayers = aImportedBoard->GetCopperLayerCount();
|
|
|
|
|
|
|
|
if( newNumLayers < currNumLayers )
|
|
|
|
{
|
2020-08-09 11:22:09 +00:00
|
|
|
wxString msg = wxString::Format( _( "Imported settings have fewer copper layers than "
|
|
|
|
"the current board (%i instead of %i).\n\n"
|
|
|
|
"Continue and delete the extra inner copper layers "
|
|
|
|
"from the current board?" ),
|
|
|
|
newNumLayers,
|
|
|
|
currNumLayers );
|
|
|
|
|
|
|
|
wxMessageDialog dlg( this, msg, _( "Inner Layers To Be Deleted" ),
|
|
|
|
wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
|
2020-08-07 17:08:45 +00:00
|
|
|
|
|
|
|
if( wxID_NO == dlg.ShowModal() )
|
|
|
|
okToDeleteCopperLayers = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return okToDeleteCopperLayers;
|
2020-09-22 21:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent )
|
|
|
|
{
|
2021-06-26 23:33:12 +00:00
|
|
|
wxArrayString headers;
|
|
|
|
headers.Add( _( "Layers" ) );
|
2020-09-22 21:50:59 +00:00
|
|
|
|
2021-06-26 23:33:12 +00:00
|
|
|
// Build the available user-defined layers list:
|
|
|
|
std::vector<wxArrayString> list;
|
2020-09-22 21:50:59 +00:00
|
|
|
|
2021-06-26 23:33:12 +00:00
|
|
|
for( LSEQ seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
|
|
|
|
{
|
|
|
|
wxCheckBox* checkBox = getCheckBox( *seq );
|
2020-09-22 21:50:59 +00:00
|
|
|
|
2021-06-26 23:33:12 +00:00
|
|
|
if( checkBox && checkBox->IsShown() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wxArrayString available_user_layer;
|
|
|
|
available_user_layer.Add( LayerName( *seq ) );
|
|
|
|
|
|
|
|
list.emplace_back( available_user_layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( list.empty() )
|
|
|
|
{
|
|
|
|
DisplayErrorMessage( m_parentDialog,
|
|
|
|
_( "All user-defined layers have already been added." ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add User-defined Layer" ), headers, list );
|
|
|
|
dlg.SetListLabel( _( "Select layer to add:" ) );
|
|
|
|
dlg.HideFilter();
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetTextSelection().IsEmpty() )
|
2020-09-22 21:50:59 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-26 23:33:12 +00:00
|
|
|
LSEQ seq;
|
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
for( seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
|
|
|
|
{
|
2021-06-26 23:33:12 +00:00
|
|
|
if( LayerName( *seq ) == dlg.GetTextSelection() )
|
2020-09-22 21:50:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxCHECK( *seq >= User_1 && *seq <= User_9, /* void */ );
|
|
|
|
|
|
|
|
LSET newLayer( *seq );
|
|
|
|
|
|
|
|
m_enabledLayers |= newLayer;
|
|
|
|
|
|
|
|
PANEL_SETUP_LAYERS_CTLs ctl = getCTLs( *seq );
|
|
|
|
|
2021-08-25 00:29:03 +00:00
|
|
|
// All user-defined layers should have a checkbox
|
|
|
|
wxASSERT( ctl.checkbox );
|
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ctl.name );
|
|
|
|
|
|
|
|
wxCHECK( textCtrl, /* void */ );
|
|
|
|
textCtrl->ChangeValue( LSET::Name( *seq ) );
|
|
|
|
ctl.name->Show( true );
|
|
|
|
ctl.checkbox->Show( true );
|
|
|
|
ctl.choice->Show( true );
|
|
|
|
|
|
|
|
wxSizeEvent evt_size( m_LayersListPanel->GetSize() );
|
|
|
|
m_LayersListPanel->GetEventHandler()->ProcessEvent( evt_size );
|
|
|
|
|
|
|
|
setLayerCheckBox( *seq, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|