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>
|
2011-09-30 18:15:37 +00:00
|
|
|
* Copyright (C) 2009 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
#include "class_drawpanel.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "macros.h"
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "wxPcbStruct.h"
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "class_board.h"
|
|
|
|
|
2009-12-20 22:44:31 +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
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
class DIALOG_LAYERS_SETUP : public DIALOG_LAYERS_SETUP_BASE
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static wxPoint s_LastPos;
|
|
|
|
static wxSize s_LastSize;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* m_Parent;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
int m_CopperLayerCount;
|
|
|
|
int m_EnabledLayers;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
BOARD* m_Pcb;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-21 01:15:01 +00:00
|
|
|
wxStaticText* m_NameStaticText;
|
|
|
|
wxStaticText* m_EnabledStaticText;
|
|
|
|
wxStaticText* m_TypeStaticText;
|
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void setLayerCheckBox( int layer, bool isChecked );
|
|
|
|
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();
|
|
|
|
void showSelectedLayerCheckBoxes( int enableLayerMask );
|
|
|
|
void showLayerTypes();
|
|
|
|
void showPresets( int 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 */
|
|
|
|
int getUILayerMask();
|
|
|
|
wxString getLayerName( int layer );
|
|
|
|
int getLayerTypeIndex( int 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
|
|
|
|
*/
|
|
|
|
CTLs getCTLs( int aLayerNumber );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxControl* getName( int aLayer )
|
|
|
|
{
|
|
|
|
return getCTLs( aLayer ).name;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxCheckBox* getCheckBox( int aLayer )
|
|
|
|
{
|
|
|
|
return getCTLs( aLayer ).checkbox;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxChoice* getChoice( int aLayer )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
txtz = m_NameStaticText->GetSize();
|
|
|
|
m_NameStaticText->Move( offset + (widths[0] - txtz.x)/2, 5 );
|
|
|
|
offset += widths[0];
|
|
|
|
|
|
|
|
txtz = m_EnabledStaticText->GetSize();
|
|
|
|
m_EnabledStaticText->Move( offset + (widths[1] - txtz.x)/2, 5 );
|
|
|
|
offset += widths[1];
|
|
|
|
|
|
|
|
txtz = m_TypeStaticText->GetSize();
|
|
|
|
m_TypeStaticText->Move( offset + (widths[2] - txtz.x)/2, 5 );
|
|
|
|
}
|
|
|
|
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
public:
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_LAYERS_SETUP( PCB_EDIT_FRAME* parent );
|
2009-12-20 22:44:31 +00:00
|
|
|
~DIALOG_LAYERS_SETUP( ) { };
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
bool Show( bool show ); // overload stock function
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-21 01:15:01 +00:00
|
|
|
/**
|
|
|
|
* Function Layout
|
|
|
|
* overrides the standard Layout() function so that the column titles can
|
|
|
|
* be positioned using information in the flexgridsizer.
|
|
|
|
*/
|
|
|
|
bool Layout()
|
|
|
|
{
|
|
|
|
bool ret = DIALOG_LAYERS_SETUP_BASE::Layout();
|
|
|
|
|
|
|
|
moveTitles();
|
|
|
|
return ret;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// We want our dialog to remember its previous screen position
|
|
|
|
wxPoint DIALOG_LAYERS_SETUP::s_LastPos( -1, -1 );
|
|
|
|
wxSize DIALOG_LAYERS_SETUP::s_LastSize;
|
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"
|
|
|
|
static const int presets[] =
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-21 18:51:37 +00:00
|
|
|
#define FRONT_AUX (SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT | ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT)
|
|
|
|
#define BACK_AUX (SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK | ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK)
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
0, // 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"
|
2009-12-21 13:05:11 +00:00
|
|
|
EDGE_LAYER | LAYER_FRONT | LAYER_BACK | FRONT_AUX,
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Two layers, parts on Back only",
|
2009-12-21 13:05:11 +00:00
|
|
|
EDGE_LAYER | LAYER_FRONT | LAYER_BACK | BACK_AUX,
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Two layers, parts on Front and Back",
|
2009-12-21 13:05:11 +00:00
|
|
|
EDGE_LAYER | LAYER_FRONT | LAYER_BACK | BACK_AUX | FRONT_AUX,
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Four layers, parts on Front only"
|
2009-12-21 13:05:11 +00:00
|
|
|
EDGE_LAYER | LAYER_FRONT | LAYER_BACK | LAYER_2 | LAYER_3 | FRONT_AUX,
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "Four layers, parts on Front and Back"
|
2009-12-21 13:05:11 +00:00
|
|
|
EDGE_LAYER | LAYER_FRONT | LAYER_BACK | LAYER_2 | LAYER_3 | FRONT_AUX | BACK_AUX,
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
// "All layers on",
|
|
|
|
ALL_LAYERS,
|
2009-10-19 13:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
CTLs DIALOG_LAYERS_SETUP::getCTLs( int 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 )
|
|
|
|
{
|
2010-01-09 15:49:48 +00:00
|
|
|
case ADHESIVE_N_FRONT: RETAUX( m_AdhesFront );
|
|
|
|
case SOLDERPASTE_N_FRONT: RETAUX( m_SoldPFront );
|
|
|
|
case SILKSCREEN_N_FRONT: RETAUX( m_SilkSFront );
|
|
|
|
case SOLDERMASK_N_FRONT: RETAUX( m_MaskFront );
|
|
|
|
case LAYER_N_FRONT: RETCOP( m_Front );
|
2010-03-10 14:05:52 +00:00
|
|
|
#ifdef USE_LAYER_MANAGER_COPPER_LAYERS_ORDER
|
|
|
|
case LAYER_N_15: RETCOP( m_Inner2 );
|
|
|
|
case LAYER_N_14: RETCOP( m_Inner3 );
|
|
|
|
case LAYER_N_13: RETCOP( m_Inner4 );
|
|
|
|
case LAYER_N_12: RETCOP( m_Inner5 );
|
|
|
|
case LAYER_N_11: RETCOP( m_Inner6 );
|
|
|
|
case LAYER_N_10: RETCOP( m_Inner7 );
|
|
|
|
case LAYER_N_9: RETCOP( m_Inner8 );
|
|
|
|
case LAYER_N_8: RETCOP( m_Inner9 );
|
|
|
|
case LAYER_N_7: RETCOP( m_Inner10 );
|
|
|
|
case LAYER_N_6: RETCOP( m_Inner11 );
|
|
|
|
case LAYER_N_5: RETCOP( m_Inner12 );
|
|
|
|
case LAYER_N_4: RETCOP( m_Inner13 );
|
|
|
|
case LAYER_N_3: RETCOP( m_Inner14 );
|
|
|
|
case LAYER_N_2: RETCOP( m_Inner15 );
|
|
|
|
#else
|
2010-01-09 15:49:48 +00:00
|
|
|
case LAYER_N_2: RETCOP( m_Inner2 );
|
|
|
|
case LAYER_N_3: RETCOP( m_Inner3 );
|
|
|
|
case LAYER_N_4: RETCOP( m_Inner4 );
|
|
|
|
case LAYER_N_5: RETCOP( m_Inner5 );
|
|
|
|
case LAYER_N_6: RETCOP( m_Inner6 );
|
|
|
|
case LAYER_N_7: RETCOP( m_Inner7 );
|
|
|
|
case LAYER_N_8: RETCOP( m_Inner8 );
|
|
|
|
case LAYER_N_9: RETCOP( m_Inner9 );
|
|
|
|
case LAYER_N_10: RETCOP( m_Inner10 );
|
|
|
|
case LAYER_N_11: RETCOP( m_Inner11 );
|
|
|
|
case LAYER_N_12: RETCOP( m_Inner12 );
|
|
|
|
case LAYER_N_13: RETCOP( m_Inner13 );
|
|
|
|
case LAYER_N_14: RETCOP( m_Inner14 );
|
|
|
|
case LAYER_N_15: RETCOP( m_Inner15 );
|
2010-03-10 14:05:52 +00:00
|
|
|
#endif
|
2010-01-09 15:49:48 +00:00
|
|
|
case LAYER_N_BACK: RETCOP( m_Back );
|
|
|
|
case SOLDERMASK_N_BACK: RETAUX( m_MaskBack );
|
|
|
|
case SILKSCREEN_N_BACK: RETAUX( m_SilkSBack );
|
|
|
|
case SOLDERPASTE_N_BACK: RETAUX( m_SoldPBack );
|
|
|
|
case ADHESIVE_N_BACK: RETAUX( m_AdhesBack );
|
|
|
|
case EDGE_N: RETAUX( m_PCBEdges );
|
|
|
|
case ECO2_N: RETAUX( m_Eco2 );
|
|
|
|
case ECO1_N: RETAUX( m_Eco1 );
|
|
|
|
case COMMENT_N: RETAUX( m_Comments );
|
|
|
|
case DRAW_N: RETAUX( m_Drawings );
|
2009-12-20 22:44:31 +00:00
|
|
|
default:
|
|
|
|
// wxDEBUGMSG( "bad layer id" );
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
/***********************************************************************************/
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( PCB_EDIT_FRAME* parent ) :
|
2009-12-20 22:44:31 +00:00
|
|
|
DIALOG_LAYERS_SETUP_BASE( parent )
|
|
|
|
/***********************************************************************************/
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_Pcb = m_Parent->GetBoard();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-21 01:15:01 +00:00
|
|
|
m_CopperLayerCount = m_Pcb->GetCopperLayerCount();
|
|
|
|
showCopperChoice( m_CopperLayerCount );
|
2010-03-07 17:51:10 +00:00
|
|
|
setCopperLayerCheckBoxes( m_CopperLayerCount );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
|
|
|
showBoardLayerNames();
|
|
|
|
|
|
|
|
m_EnabledLayers = m_Pcb->GetEnabledLayers();
|
|
|
|
showSelectedLayerCheckBoxes( m_EnabledLayers );
|
|
|
|
showPresets( m_EnabledLayers );
|
|
|
|
|
|
|
|
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()
|
2009-12-21 04:46:29 +00:00
|
|
|
m_NameStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2009-12-21 04:46:29 +00:00
|
|
|
m_EnabledStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
|
2009-12-21 01:15:01 +00:00
|
|
|
|
2009-12-21 04:46:29 +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 ) );
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
Layout();
|
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
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
m_sdbSizer2OK->SetFocus();
|
2011-03-14 19:17:42 +00:00
|
|
|
m_sdbSizer2OK->SetDefault();
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
bool DIALOG_LAYERS_SETUP::Show( bool show )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
bool ret;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( show )
|
|
|
|
{
|
|
|
|
if( s_LastPos.x != -1 )
|
|
|
|
{
|
|
|
|
SetSize( s_LastPos.x, s_LastPos.y, s_LastSize.x, s_LastSize.y, 0 );
|
|
|
|
}
|
|
|
|
ret = DIALOG_LAYERS_SETUP_BASE::Show( show );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Save the dialog's position before hiding
|
|
|
|
s_LastPos = GetPosition();
|
|
|
|
s_LastSize = GetSize();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
ret = DIALOG_LAYERS_SETUP_BASE::Show( show );
|
|
|
|
}
|
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
|
|
|
void DIALOG_LAYERS_SETUP::showCopperChoice( int copperCount )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
static const int copperCounts[] = { 2,4,6,8,10,12,14,16 };
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
for( unsigned i = 0; i<sizeof(copperCounts); ++i )
|
|
|
|
{
|
|
|
|
// note this will change a one layer board to 2:
|
|
|
|
if( copperCount <= copperCounts[i] )
|
|
|
|
{
|
|
|
|
m_CopperLayersChoice->SetSelection(i);
|
|
|
|
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
|
|
|
|
// BOARD::GetDefaultLayerName() for non-coppers.
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
for( int layer=0; layer<NB_LAYERS; ++layer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
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
|
|
|
{
|
2009-12-20 22:44:31 +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
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::showSelectedLayerCheckBoxes( int enabledLayers )
|
|
|
|
{
|
|
|
|
for( int layer=0; layer<NB_LAYERS; ++layer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
setLayerCheckBox( layer, (1<<layer) & enabledLayers );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
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::showPresets( int enabledLayers )
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
for( int copperLayer = FIRST_COPPER_LAYER;
|
|
|
|
copperLayer <= LAST_COPPER_LAYER; ++copperLayer )
|
|
|
|
{
|
|
|
|
wxChoice* ctl = getChoice( copperLayer );
|
|
|
|
ctl->SetSelection( m_Pcb->GetLayerType( copperLayer ) );
|
|
|
|
}
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
int DIALOG_LAYERS_SETUP::getUILayerMask()
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
int layerMaskResult = 0;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
for( int layer=0; layer<NB_LAYERS; ++layer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
wxCheckBox* ctl = getCheckBox( layer );
|
|
|
|
if( ctl->GetValue() )
|
|
|
|
{
|
|
|
|
layerMaskResult |= (1 << 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
void DIALOG_LAYERS_SETUP::setLayerCheckBox( int 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
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
setLayerCheckBox( LAYER_N_BACK, true );
|
|
|
|
--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
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
setLayerCheckBox( LAYER_N_FRONT, true );
|
|
|
|
--copperCount;
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
setLayerCheckBox( LAYER_N_FRONT, false );
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
int layer;
|
2010-03-07 17:51:10 +00:00
|
|
|
for( layer=LAYER_N_2; layer < NB_COPPER_LAYERS-1; ++layer, --copperCount )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2010-03-07 17:51:10 +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
|
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.
|
|
|
|
wxSizeEvent evt_size(m_LayersListPanel->GetSize() );
|
|
|
|
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
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
m_EnabledLayers = getUILayerMask();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +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
|
|
|
|
2009-12-20 22:44:31 +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) )
|
|
|
|
{
|
|
|
|
m_EnabledLayers = presets[ presetNdx ];
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
int coppersMask = m_EnabledLayers & ALL_CU_LAYERS;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
int copperCount = 0;
|
|
|
|
while( coppersMask )
|
|
|
|
{
|
|
|
|
if( coppersMask & 1 )
|
|
|
|
++copperCount;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
coppersMask >>= 1;
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
m_CopperLayerCount = copperCount;
|
2010-03-13 22:28:34 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
showCopperChoice( m_CopperLayerCount );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
showSelectedLayerCheckBoxes( m_EnabledLayers );
|
2010-03-13 22:28:34 +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
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
m_CopperLayerCount = m_CopperLayersChoice->GetCurrentSelection() * 2 + 2;
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
setCopperLayerCheckBoxes( m_CopperLayerCount );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:55:13 +00:00
|
|
|
m_EnabledLayers = getUILayerMask();
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:55:13 +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::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
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
m_EnabledLayers = getUILayerMask();
|
|
|
|
m_Pcb->SetEnabledLayers( m_EnabledLayers );
|
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
|
|
|
|
*/
|
|
|
|
m_Pcb->SetVisibleLayers( m_EnabledLayers );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
for( int layer = FIRST_COPPER_LAYER;
|
|
|
|
layer <= LAST_COPPER_LAYER; ++layer )
|
|
|
|
{
|
|
|
|
if( (1<<layer) & m_EnabledLayers )
|
|
|
|
{
|
|
|
|
name = getLayerName( layer );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
m_Pcb->SetLayerName( layer, name );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
LAYER_T t = (LAYER_T) getLayerTypeIndex(layer);
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
m_Pcb->SetLayerType( layer, t );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
m_Parent->OnModify();
|
2009-12-20 22:44:31 +00:00
|
|
|
m_Parent->ReCreateLayerBox( NULL );
|
2010-01-21 20:53:01 +00:00
|
|
|
m_Parent->ReFillLayerWidget();
|
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
|
|
|
|
|
|
|
int DIALOG_LAYERS_SETUP::getLayerTypeIndex( int 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
|
|
|
|
|
|
|
wxString DIALOG_LAYERS_SETUP::getLayerName( int 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
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
wxASSERT( aLayer >= FIRST_COPPER_LAYER && aLayer <= LAST_COPPER_LAYER );
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
for( int layer=0; layer<=LAST_COPPER_LAYER; ++layer )
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2009-12-20 22:44:31 +00:00
|
|
|
// we _can_ rely on m_EnabledLayers being current here:
|
|
|
|
if( !(m_EnabledLayers & (1<<layer)) )
|
|
|
|
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.
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
static const wxString badchars( wxT("%$\" ") );
|
2009-10-19 13:49:19 +00:00
|
|
|
|
2009-12-20 22:44:31 +00:00
|
|
|
if( name == wxEmptyString )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallDialogLayerSetup()
|
2009-10-19 13:49:19 +00:00
|
|
|
{
|
2010-11-18 21:16:28 +00:00
|
|
|
DIALOG_LAYERS_SETUP dlg( this );
|
2011-03-01 19:26:17 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxLogDebug( wxT( "Current layer selected %d." ), getActiveLayer() );
|
|
|
|
|
|
|
|
// If the current active layer was removed, find the next avaiable layer to set as the
|
|
|
|
// active layer.
|
|
|
|
if( ( ( 1 << getActiveLayer() ) & GetBoard()->GetEnabledLayers() ) == 0 )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < LAYER_COUNT; i++ )
|
|
|
|
{
|
|
|
|
int tmp = i;
|
|
|
|
|
|
|
|
if( i >= LAYER_COUNT )
|
|
|
|
tmp = i - LAYER_COUNT;
|
|
|
|
|
|
|
|
if( ( 1 << tmp ) & GetBoard()->GetEnabledLayers() )
|
|
|
|
{
|
|
|
|
wxLogDebug( wxT( "Setting current layer to %d." ), getActiveLayer() );
|
|
|
|
setActiveLayer( tmp, true );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setActiveLayer( getActiveLayer(), true );
|
|
|
|
}
|
2009-10-19 13:49:19 +00:00
|
|
|
}
|