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>
|
2015-02-28 16:48:39 +00:00
|
|
|
* Copyright (C) 2009 - 2015 KiCad Developers, see change_log.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 <fctsys.h>
|
|
|
|
#include <macros.h>
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.h>
|
2014-06-24 16:17:18 +00:00
|
|
|
#include <invoke_pcb_dialog.h>
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_layers_setup_base.h>
|
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
|
2010-03-10 14:05:52 +00:00
|
|
|
// if not displays always 1=the full set (16 layers)
|
2010-03-13 22:28:34 +00:00
|
|
|
#define HIDE_INACTIVE_LAYERS
|
2010-03-10 14:05:52 +00:00
|
|
|
|
2010-03-13 22:28:34 +00:00
|
|
|
// if defined, use the layer manager copper layers order (from FRONT to BACK)
|
|
|
|
// to display inner layers.
|
2010-03-10 14:05:52 +00:00
|
|
|
// if not, use the default order (from BACK to FRONT)
|
2010-03-13 22:28:34 +00:00
|
|
|
#define USE_LAYER_MANAGER_COPPER_LAYERS_ORDER
|
2010-03-10 14:05:52 +00:00
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
/**
|
|
|
|
* Struct CTLs
|
|
|
|
* holds the 3 ui control pointers for a single board layer.
|
|
|
|
*/
|
|
|
|
struct CTLs
|
|
|
|
{
|
2010-03-10 14:05:52 +00:00
|
|
|
CTLs( wxControl* aName, wxCheckBox* aCheckBox, wxControl* aChoiceOrDesc, wxPanel * aPanel = NULL)
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
name = aName;
|
|
|
|
checkbox = aCheckBox;
|
|
|
|
choice = aChoiceOrDesc;
|
2010-03-13 22:28:34 +00:00
|
|
|
panel = aPanel;
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxControl* name;
|
|
|
|
wxCheckBox* checkbox;
|
|
|
|
wxControl* choice;
|
2010-03-07 17:51:10 +00:00
|
|
|
wxPanel * panel;
|
2009-12-20 22:44:31 +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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
// layers that are put out into the dialog UI, coordinate with wxformbuilder and
|
|
|
|
// getCTLs( LAYER_NUM aLayerNumber )
|
|
|
|
static const 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,
|
|
|
|
};
|
|
|
|
|
|
|
|
return LSEQ( layers, layers + DIM( layers ) );
|
|
|
|
}
|
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
class DIALOG_LAYERS_SETUP : public DIALOG_LAYERS_SETUP_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_LAYERS_SETUP( wxTopLevelWindow* aCaller, BOARD* aBoard );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
private:
|
|
|
|
int m_copperLayerCount;
|
|
|
|
LSET m_enabledLayers;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
BOARD* m_pcb;
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
wxStaticText* m_nameStaticText;
|
|
|
|
wxStaticText* m_enabledStaticText;
|
|
|
|
wxStaticText* m_typeStaticText;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
void setLayerCheckBox( LAYER_NUM layer, bool isChecked );
|
2009-12-20 22:44:31 +00:00
|
|
|
void setCopperLayerCheckBoxes( int copperCount );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void showCopperChoice( int copperCount );
|
|
|
|
void showBoardLayerNames();
|
2014-06-24 16:17:18 +00:00
|
|
|
void showSelectedLayerCheckBoxes( LSET enableLayerMask );
|
2009-12-20 22:44:31 +00:00
|
|
|
void showLayerTypes();
|
2014-06-24 16:17:18 +00:00
|
|
|
void showPresets( LSET enabledLayerMask );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
/** return the selected layer mask within the UI checkboxes */
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET getUILayerMask();
|
2013-03-31 13:27:46 +00:00
|
|
|
wxString getLayerName( LAYER_NUM layer );
|
|
|
|
int getLayerTypeIndex( LAYER_NUM layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void OnCancelButtonClick( wxCommandEvent& event );
|
|
|
|
void OnOkButtonClick( wxCommandEvent& event );
|
|
|
|
void OnCheckBox( wxCommandEvent& event );
|
|
|
|
void DenyChangeCheckBox( wxCommandEvent& event );
|
|
|
|
void OnPresetsChoice( wxCommandEvent& event );
|
|
|
|
void OnCopperLayersChoice( wxCommandEvent& event );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
bool testLayerNames();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
/**
|
|
|
|
* Function getCTLs
|
|
|
|
* maps \a aLayerNumber to the wx IDs for that layer which are
|
|
|
|
* the layer name control ID, checkbox control ID, and choice control ID
|
|
|
|
*/
|
2013-03-31 13:27:46 +00:00
|
|
|
CTLs getCTLs( LAYER_NUM aLayerNumber );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
wxControl* getName( LAYER_NUM aLayer )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
return getCTLs( aLayer ).name;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
wxCheckBox* getCheckBox( LAYER_NUM aLayer )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
return getCTLs( aLayer ).checkbox;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
wxChoice* getChoice( LAYER_NUM aLayer )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
return (wxChoice*) getCTLs( aLayer ).choice;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-21 01:15:01 +00:00
|
|
|
void moveTitles()
|
|
|
|
{
|
|
|
|
wxArrayInt widths = m_LayerListFlexGridSizer->GetColWidths();
|
|
|
|
|
|
|
|
int offset = 0;
|
|
|
|
wxSize txtz;
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
txtz = m_nameStaticText->GetSize();
|
|
|
|
m_nameStaticText->Move( offset + (widths[0] - txtz.x)/2, 5 );
|
2009-12-21 01:15:01 +00:00
|
|
|
offset += widths[0];
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
txtz = m_enabledStaticText->GetSize();
|
|
|
|
m_enabledStaticText->Move( offset + (widths[1] - txtz.x)/2, 5 );
|
2009-12-21 01:15:01 +00:00
|
|
|
offset += widths[1];
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
txtz = m_typeStaticText->GetSize();
|
|
|
|
m_typeStaticText->Move( offset + (widths[2] - txtz.x)/2, 5 );
|
2009-12-21 01:15:01 +00:00
|
|
|
}
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
void OnSize( wxSizeEvent& event );
|
2009-10-19 13:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// Layer bit masks for each defined "Preset Layer Grouping"
|
2014-06-24 16:17:18 +00:00
|
|
|
static const LSET presets[] =
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET(), // shift the array index up by one, matches with "Custom".
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Two layers, parts on Front only"
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET( 2, F_Cu, B_Cu ) | LSET::FrontTechMask() | LSET::UserMask(),
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Two layers, parts on Back only",
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET( 2, F_Cu, B_Cu ) | LSET::BackTechMask() | LSET::UserMask(),
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Two layers, parts on Front and Back",
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET( 2, F_Cu, B_Cu ) | LSET::FrontTechMask() | LSET::BackTechMask() | LSET::UserMask(),
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Four layers, parts on Front only"
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET( 4, F_Cu, B_Cu, In1_Cu, In2_Cu ) | LSET::FrontTechMask() | LSET::UserMask(),
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Four layers, parts on Front and Back"
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET( 4, F_Cu, B_Cu, In1_Cu, In2_Cu ) | LSET::FrontTechMask() | LSET::BackTechMask() | LSET::UserMask(),
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "All layers on",
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET().set(),
|
2009-10-19 13:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
CTLs DIALOG_LAYERS_SETUP::getCTLs( LAYER_NUM aLayerNumber )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2010-03-10 14:05:52 +00:00
|
|
|
#define RETCOP(x) return CTLs( x##Name, x##CheckBox, x##Choice, x##Panel );
|
|
|
|
#define RETAUX(x) return CTLs( x##Name, x##CheckBox, x##StaticText, x##Panel );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
switch( aLayerNumber )
|
|
|
|
{
|
2014-09-14 15:34:37 +00:00
|
|
|
case F_CrtYd: RETAUX( m_CrtYdFront );
|
|
|
|
case F_Fab: RETAUX( m_FabFront );
|
2014-06-24 16:17:18 +00:00
|
|
|
case F_Adhes: RETAUX( m_AdhesFront );
|
|
|
|
case F_Paste: RETAUX( m_SoldPFront );
|
|
|
|
case F_SilkS: RETAUX( m_SilkSFront );
|
|
|
|
case F_Mask: RETAUX( m_MaskFront );
|
|
|
|
case F_Cu: RETCOP( m_Front );
|
|
|
|
|
|
|
|
case In1_Cu: RETCOP( m_In1 );
|
|
|
|
case In2_Cu: RETCOP( m_In2 );
|
|
|
|
case In3_Cu: RETCOP( m_In3 );
|
|
|
|
case In4_Cu: RETCOP( m_In4 );
|
|
|
|
case In5_Cu: RETCOP( m_In5 );
|
|
|
|
case In6_Cu: RETCOP( m_In6 );
|
|
|
|
case In7_Cu: RETCOP( m_In7 );
|
|
|
|
case In8_Cu: RETCOP( m_In8 );
|
|
|
|
case In9_Cu: RETCOP( m_In9 );
|
|
|
|
case In10_Cu: RETCOP( m_In10 );
|
|
|
|
case In11_Cu: RETCOP( m_In11 );
|
|
|
|
case In12_Cu: RETCOP( m_In12 );
|
|
|
|
case In13_Cu: RETCOP( m_In13 );
|
|
|
|
case In14_Cu: RETCOP( m_In14 );
|
|
|
|
case In15_Cu: RETCOP( m_In15 );
|
|
|
|
|
|
|
|
case In16_Cu: RETCOP( m_In16 );
|
|
|
|
case In17_Cu: RETCOP( m_In17 );
|
|
|
|
case In18_Cu: RETCOP( m_In18 );
|
|
|
|
case In19_Cu: RETCOP( m_In19 );
|
|
|
|
case In20_Cu: RETCOP( m_In20 );
|
|
|
|
case In21_Cu: RETCOP( m_In21 );
|
|
|
|
case In22_Cu: RETCOP( m_In22 );
|
|
|
|
case In23_Cu: RETCOP( m_In23 );
|
|
|
|
case In24_Cu: RETCOP( m_In24 );
|
|
|
|
case In25_Cu: RETCOP( m_In25 );
|
|
|
|
case In26_Cu: RETCOP( m_In26 );
|
|
|
|
case In27_Cu: RETCOP( m_In27 );
|
|
|
|
case In28_Cu: RETCOP( m_In28 );
|
|
|
|
case In29_Cu: RETCOP( m_In29 );
|
|
|
|
case In30_Cu: RETCOP( m_In30 );
|
|
|
|
|
|
|
|
case B_Cu: RETCOP( m_Back );
|
|
|
|
case B_Mask: RETAUX( m_MaskBack );
|
|
|
|
case B_SilkS: RETAUX( m_SilkSBack );
|
|
|
|
case B_Paste: RETAUX( m_SoldPBack );
|
|
|
|
case B_Adhes: RETAUX( m_AdhesBack );
|
2014-09-14 15:34:37 +00:00
|
|
|
case B_Fab: RETAUX( m_FabBack );
|
|
|
|
case B_CrtYd: RETAUX( m_CrtYdBack );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
case Edge_Cuts: RETAUX( m_PCBEdges );
|
|
|
|
case Margin: RETAUX( m_Margin );
|
|
|
|
case Eco2_User: RETAUX( m_Eco2 );
|
|
|
|
case Eco1_User: RETAUX( m_Eco1 );
|
|
|
|
case Cmts_User: RETAUX( m_Comments );
|
|
|
|
case Dwgs_User: RETAUX( m_Drawings );
|
2009-12-20 22:44:31 +00:00
|
|
|
default:
|
2014-06-24 16:17:18 +00:00
|
|
|
wxASSERT_MSG( 0, wxT( "bad layer id" ) );
|
2009-12-20 22:44:31 +00:00
|
|
|
return CTLs( 0, 0, 0 );
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
#undef RETCOP
|
|
|
|
#undef RETAUX
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoard ) :
|
|
|
|
DIALOG_LAYERS_SETUP_BASE( aParent )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2015-04-19 11:09:35 +00:00
|
|
|
m_pcb = aBoard;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_copperLayerCount = m_pcb->GetCopperLayerCount();
|
|
|
|
showCopperChoice( m_copperLayerCount );
|
|
|
|
setCopperLayerCheckBoxes( m_copperLayerCount );
|
2015-04-20 16:48:31 +00:00
|
|
|
m_staticTextBrdThicknessUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
|
|
|
PutValueInLocalUnits( *m_textCtrlBrdThickness,
|
|
|
|
m_pcb->GetDesignSettings().GetBoardThickness() );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
|
|
|
showBoardLayerNames();
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_enabledLayers = m_pcb->GetEnabledLayers();
|
|
|
|
showSelectedLayerCheckBoxes( m_enabledLayers );
|
|
|
|
showPresets( m_enabledLayers );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
|
|
|
showLayerTypes();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
SetAutoLayout( true );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
|
|
|
// these 3 controls are handled outside wxformbuilder so that we can add
|
|
|
|
// them without a sizer. Then we position them manually based on the column
|
2009-12-21 17:26:11 +00:00
|
|
|
// widths from m_LayerListFlexGridSizer->GetColWidths()
|
2015-04-19 11:09:35 +00:00
|
|
|
m_nameStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_enabledStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_typeStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2009-12-21 04:46:29 +00:00
|
|
|
// set the height of the title panel to be the size of any wxStaticText object
|
|
|
|
// plus 10 so we can have a border of 5 on both top and bottom.
|
2009-12-21 01:15:01 +00:00
|
|
|
m_TitlePanel->SetMinSize( wxSize( -1, m_AdhesFrontName->GetSize().y+10 ) );
|
|
|
|
|
2015-02-28 16:48:39 +00:00
|
|
|
m_LayersListPanel->ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
Layout();
|
2014-02-21 16:38:29 +00:00
|
|
|
Fit();
|
2015-04-19 11:09:35 +00:00
|
|
|
moveTitles();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
Center();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_sdbSizerOK->SetFocus();
|
|
|
|
m_sdbSizerOK->SetDefault();
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::OnSize( wxSizeEvent& event )
|
|
|
|
{
|
|
|
|
moveTitles();
|
|
|
|
event.Skip();
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::showCopperChoice( int copperCount )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-29 18:09:32 +00:00
|
|
|
if( copperCount > MAX_CU_LAYERS )
|
|
|
|
copperCount = MAX_CU_LAYERS;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-29 18:09:32 +00:00
|
|
|
if( copperCount < 2 )
|
|
|
|
copperCount = 2;
|
|
|
|
|
|
|
|
for( int lyrCnt = 2; lyrCnt <= MAX_CU_LAYERS; lyrCnt += 2 )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
// note this will change a one layer board to 2:
|
2014-06-29 18:09:32 +00:00
|
|
|
if( copperCount <= lyrCnt )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2014-06-29 18:09:32 +00:00
|
|
|
int idx = lyrCnt/2 - 1;
|
|
|
|
m_CopperLayersChoice->SetSelection(idx);
|
2009-12-20 22:44:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::showBoardLayerNames()
|
|
|
|
{
|
|
|
|
// Establish all the board's layer names into the dialog presentation, by
|
|
|
|
// obtaining them from BOARD::GetLayerName() which calls
|
2013-03-20 04:46:32 +00:00
|
|
|
// 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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxControl* ctl = getName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxASSERT( ctl );
|
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
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
//D(printf("layerName[%d]=%s\n", layer, TO_UTF8( lname ) );)
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( ctl->IsKindOf( CLASSINFO(wxTextCtrl) ) )
|
|
|
|
((wxTextCtrl*)ctl)->SetValue( lname ); // wxTextCtrl
|
|
|
|
else
|
|
|
|
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
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::showSelectedLayerCheckBoxes( LSET enabledLayers )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
// the check boxes
|
|
|
|
for( LSEQ seq = dlg_layers(); seq; ++seq )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::showPresets( LSET enabledLayers )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
int presetsNdx = 0; // the "Custom" setting, matches nothing
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
for( unsigned i=1; i<DIM(presets); ++i )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
if( enabledLayers == presets[i] )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
presetsNdx = i;
|
|
|
|
break;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
m_PresetsChoice->SetSelection( presetsNdx );
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::showLayerTypes()
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID cu_layer = *seq;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET DIALOG_LAYERS_SETUP::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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
|
|
|
wxCheckBox* ctl = getCheckBox( layer );
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( ctl->GetValue() )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMaskResult.set( layer );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::setLayerCheckBox( LAYER_NUM aLayer, bool isChecked )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
wxCheckBox* ctl = getCheckBox( aLayer );
|
|
|
|
ctl->SetValue( isChecked );
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::setCopperLayerCheckBoxes( int copperCount )
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
|
|
|
bool state = copperCount > 0;
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2010-03-10 14:05:52 +00:00
|
|
|
#ifdef HIDE_INACTIVE_LAYERS
|
2010-03-13 22:28:34 +00:00
|
|
|
// This code hides non-active copper layers, or redisplays hidden
|
|
|
|
// layers which are now needed.
|
|
|
|
CTLs ctl = getCTLs( layer );
|
|
|
|
|
2010-03-09 09:51:22 +00:00
|
|
|
ctl.name->Show( state );
|
|
|
|
ctl.checkbox->Show( state );
|
|
|
|
ctl.choice->Show( state );
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2010-03-10 14:05:52 +00:00
|
|
|
if( ctl.panel )
|
|
|
|
ctl.panel->Show( state );
|
|
|
|
#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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::OnCheckBox( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2015-04-19 11:09:35 +00:00
|
|
|
m_enabledLayers = getUILayerMask();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
showPresets( m_enabledLayers );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::DenyChangeCheckBox( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
// user may not change copper layer checkboxes from anything other than
|
2009-12-20 22:55:13 +00:00
|
|
|
// either presets choice or the copper layer choice controls.
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2010-03-13 22:28:34 +00:00
|
|
|
// I tried to simply disable the copper CheckBoxes but they look like crap,
|
2009-12-20 22:44:31 +00:00
|
|
|
// so leave them enabled and reverse the user's attempt to toggle them.
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
setCopperLayerCheckBoxes( m_copperLayerCount );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::OnPresetsChoice( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
unsigned presetNdx = m_PresetsChoice->GetCurrentSelection();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( presetNdx == 0 ) // the Custom setting controls nothing.
|
2009-10-19 13:49:19 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( presetNdx < DIM(presets) )
|
|
|
|
{
|
2015-04-19 11:09:35 +00:00
|
|
|
m_enabledLayers = presets[ presetNdx ];
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
LSET copperSet = m_enabledLayers & LSET::AllCuMask();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
int copperCount = copperSet.count();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_copperLayerCount = copperCount;
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
showCopperChoice( m_copperLayerCount );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
showSelectedLayerCheckBoxes( m_enabledLayers );
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
setCopperLayerCheckBoxes( m_copperLayerCount );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::OnCopperLayersChoice( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2015-04-19 11:09:35 +00:00
|
|
|
m_copperLayerCount = m_CopperLayersChoice->GetCurrentSelection() * 2 + 2;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
setCopperLayerCheckBoxes( m_copperLayerCount );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_enabledLayers = getUILayerMask();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
showPresets( m_enabledLayers );
|
2009-12-20 22:55:13 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
|
|
|
|
void DIALOG_LAYERS_SETUP::OnCancelButtonClick( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::OnOkButtonClick( wxCommandEvent& event )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
if( testLayerNames() )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
wxString name;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_enabledLayers = getUILayerMask();
|
|
|
|
m_pcb->SetEnabledLayers( m_enabledLayers );
|
2012-02-06 07:14:51 +00:00
|
|
|
|
2009-12-21 12:05:36 +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
|
|
|
|
*/
|
2015-04-19 11:09:35 +00:00
|
|
|
m_pcb->SetVisibleLayers( m_enabledLayers );
|
2009-10-19 13:49:19 +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
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
if( m_enabledLayers[layer] )
|
2009-12-20 22:44:31 +00:00
|
|
|
{
|
|
|
|
name = getLayerName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_pcb->SetLayerName( layer, name );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_T t = (LAYER_T) getLayerTypeIndex( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
m_pcb->SetLayerType( layer, t );
|
2009-12-20 22:44:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-20 16:48:31 +00:00
|
|
|
int thickness = ValueFromTextCtrl( *m_textCtrlBrdThickness );
|
|
|
|
|
|
|
|
// Clamp the value between reasonable values
|
|
|
|
|
2015-06-14 18:18:34 +00:00
|
|
|
thickness = Clamp( Millimeter2iu( 0.1 ), thickness, Millimeter2iu( 10.0 ) );
|
2015-04-20 16:48:31 +00:00
|
|
|
m_pcb->GetDesignSettings().SetBoardThickness( thickness );
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
EndModal( wxID_OK );
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
2009-12-20 22:44:31 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
int DIALOG_LAYERS_SETUP::getLayerTypeIndex( LAYER_NUM aLayer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
wxChoice* ctl = getChoice( aLayer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
int ret = ctl->GetCurrentSelection(); // indices must have same sequence as LAYER_T
|
2009-10-19 13:49:19 +00:00
|
|
|
|
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
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
wxString DIALOG_LAYERS_SETUP::getLayerName( LAYER_NUM aLayer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
wxString ret;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2013-04-09 16:00:46 +00:00
|
|
|
wxASSERT( IsCopperLayer( aLayer ) );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxTextCtrl* ctl = (wxTextCtrl*) getName( aLayer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
ret = ctl->GetValue().Trim();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
return ret;
|
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 )
|
|
|
|
if( str.Find( chars[i] ) != wxNOT_FOUND )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
bool DIALOG_LAYERS_SETUP::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
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
|
|
|
|
2015-04-19 11:09:35 +00:00
|
|
|
// we _can_ rely on m_enabledLayers being current here:
|
|
|
|
if( !m_enabledLayers[layer] )
|
2009-12-20 22:44:31 +00:00
|
|
|
continue;
|
2009-10-25 15:54:00 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxString name = getLayerName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
//D(printf("name[%d]=%s\n", layer, TO_UTF8(name) );)
|
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
|
|
|
|
2009-12-20 22:44:31 +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.
|
2012-06-14 19:10:32 +00:00
|
|
|
// 6) cannot have illegal chars in filenames ( some filenames are built from layer names )
|
2012-12-11 05:39:36 +00:00
|
|
|
static const wxString badchars( wxT("%$\" /\\") );
|
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
|
|
|
{
|
|
|
|
DisplayError( this, _("Layer name may not be empty" ) );
|
|
|
|
ctl->SetFocus(); // on the bad name
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( hasOneOf( name, badchars ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _("Layer name has an illegal character, one of: '") + badchars + wxT("'") );
|
|
|
|
ctl->SetFocus(); // on the bad name
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( name == wxT("signal") )
|
|
|
|
{
|
|
|
|
DisplayError( this, _("'signal' is a reserved layer name") );
|
|
|
|
ctl->SetFocus(); // on the bad name
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( std::vector<wxString>::iterator it = names.begin(); it != names.end(); ++it )
|
|
|
|
{
|
|
|
|
if( name == *it )
|
|
|
|
{
|
|
|
|
DisplayError( this, _("Layer name is a duplicate of another") );
|
|
|
|
ctl->SetFocus(); // on the bad name
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
names.push_back( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
bool InvokeLayerSetup( wxTopLevelWindow* aCaller, BOARD* aBoard )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
DIALOG_LAYERS_SETUP dlg( aCaller, aBoard );
|
2011-03-01 19:26:17 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
return dlg.ShowModal() == wxID_OK;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|