2007-11-02 05:33:31 +00:00
|
|
|
/*******************************************************/
|
|
|
|
/* Dialog frame to choose gerber layers and pcb layers */
|
|
|
|
/*******************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
/* select_layers_to_pcb.cpp */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2007-05-28 18:09:49 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "gerbview.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2010-10-06 17:28:07 +00:00
|
|
|
#include "class_GERBER.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
#include "wx/statline.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
#define LAYER_UNSELECTED NB_LAYERS
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
static int ButtonTable[32]; // Indexes buttons to Gerber layers
|
|
|
|
static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers
|
|
|
|
wxStaticText* layer_list[32]; // Indexes text strings to buttons
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
enum swap_layer_id {
|
2007-11-02 05:33:31 +00:00
|
|
|
ID_WINEDA_SWAPLAYERFRAME = 1800,
|
|
|
|
ID_BUTTON_0,
|
|
|
|
ID_TEXT_0 = ID_BUTTON_0 + 32
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
class SWAP_LAYERS_DIALOG : public wxDialog
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
private:
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME* m_Parent;
|
2007-11-02 05:33:31 +00:00
|
|
|
wxBoxSizer* OuterBoxSizer;
|
|
|
|
wxBoxSizer* MainBoxSizer;
|
|
|
|
wxFlexGridSizer* FlexColumnBoxSizer;
|
|
|
|
wxStaticText* label;
|
|
|
|
wxButton* Button;
|
|
|
|
wxStaticText* text;
|
|
|
|
wxStaticLine* Line;
|
|
|
|
wxStdDialogButtonSizer* StdDialogButtonSizer;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent );
|
|
|
|
~SWAP_LAYERS_DIALOG() {};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2009-04-29 17:09:00 +00:00
|
|
|
void OnSelectLayer( wxCommandEvent& event );
|
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
BEGIN_EVENT_TABLE( SWAP_LAYERS_DIALOG, wxDialog )
|
2007-11-22 00:40:17 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
|
2007-11-02 05:33:31 +00:00
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED,
|
2011-03-12 09:50:21 +00:00
|
|
|
SWAP_LAYERS_DIALOG::OnSelectLayer )
|
|
|
|
EVT_BUTTON( wxID_OK, SWAP_LAYERS_DIALOG::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, SWAP_LAYERS_DIALOG::OnCancelClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/* Install a dialog frame to choose the equivalence
|
2007-10-07 03:08:24 +00:00
|
|
|
* between gerber layers and pcbnew layers
|
|
|
|
* return the "lookup table" if ok, or NULL
|
|
|
|
*/
|
2011-03-12 09:50:21 +00:00
|
|
|
int* GERBVIEW_FRAME::InstallDialogLayerPairChoice( )
|
2009-11-09 14:00:22 +00:00
|
|
|
{
|
2011-03-12 09:50:21 +00:00
|
|
|
SWAP_LAYERS_DIALOG* frame = new SWAP_LAYERS_DIALOG( this );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
int ii = frame->ShowModal();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
frame->Destroy();
|
|
|
|
if( ii >= 0 )
|
|
|
|
return LayerLookUpTable;
|
|
|
|
else
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ) :
|
2009-04-29 17:09:00 +00:00
|
|
|
wxDialog( parent, -1, _( "Layer selection:" ), wxPoint( -1, -1 ),
|
|
|
|
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-02 05:33:31 +00:00
|
|
|
OuterBoxSizer = NULL;
|
2009-04-29 17:09:00 +00:00
|
|
|
MainBoxSizer = NULL;
|
2007-11-02 05:33:31 +00:00
|
|
|
FlexColumnBoxSizer = NULL;
|
2009-04-29 17:09:00 +00:00
|
|
|
label = NULL;
|
2007-11-02 05:33:31 +00:00
|
|
|
Button = NULL;
|
2009-04-29 17:09:00 +00:00
|
|
|
text = NULL;
|
|
|
|
Line = NULL;
|
2007-11-02 05:33:31 +00:00
|
|
|
StdDialogButtonSizer = NULL;
|
|
|
|
|
|
|
|
m_Parent = parent;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
int item_ID, ii, nb_items;
|
2007-11-02 05:33:31 +00:00
|
|
|
wxString msg;
|
2009-04-29 17:09:00 +00:00
|
|
|
wxSize goodSize;
|
|
|
|
|
|
|
|
// Experimentation has shown that buttons in the Windows version can be 20
|
|
|
|
// pixels wide and 20 pixels high, but that they need to be 26 pixels wide
|
|
|
|
// and 26 pixels high in the Linux version. (And although the dimensions
|
|
|
|
// of those buttons could be set to 26 pixels wide and 26 pixels high in
|
|
|
|
// both of those versions, that would result in a dialog box which would
|
|
|
|
// be excessively high in the Windows version.)
|
2007-11-02 05:33:31 +00:00
|
|
|
#ifdef __WINDOWS__
|
|
|
|
int w = 20;
|
|
|
|
int h = 20;
|
|
|
|
#else
|
|
|
|
int w = 26;
|
|
|
|
int h = 26;
|
|
|
|
#endif
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
// As currently implemented, the dimensions of the buttons in the Mac
|
|
|
|
// version are also 26 pixels wide and 26 pixels high. If appropriate,
|
|
|
|
// the above code should be modified as required in the event that those
|
|
|
|
// buttons should be some other size in that version.
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Compute a reasonable number of copper layers
|
2009-10-28 11:48:47 +00:00
|
|
|
int pcb_layer_number = 0;
|
2007-11-02 05:33:31 +00:00
|
|
|
for( ii = 0; ii < 32; ii++ )
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
if( g_GERBER_List[ii] != NULL )
|
2009-10-28 11:48:47 +00:00
|
|
|
pcb_layer_number++;
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Specify the default value for each member of these arrays.
|
|
|
|
ButtonTable[ii] = -1;
|
2009-04-29 17:09:00 +00:00
|
|
|
LayerLookUpTable[ii] = LAYER_UNSELECTED;
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
2010-01-31 20:01:46 +00:00
|
|
|
m_Parent->GetBoard()->SetCopperLayerCount(pcb_layer_number);
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
pcb_layer_number = 0;
|
2007-11-02 05:33:31 +00:00
|
|
|
for( nb_items = 0, ii = 0; ii < 32; ii++ )
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
if( g_GERBER_List[ii] == NULL )
|
2007-11-02 05:33:31 +00:00
|
|
|
continue;
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( (pcb_layer_number == m_Parent->GetBoard()->GetCopperLayerCount() - 1)
|
|
|
|
&& (m_Parent->GetBoard()->GetCopperLayerCount() > 1) )
|
2009-12-07 03:46:13 +00:00
|
|
|
pcb_layer_number = LAYER_N_FRONT;
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
ButtonTable[nb_items] = ii;
|
2009-04-29 17:09:00 +00:00
|
|
|
LayerLookUpTable[ii] = pcb_layer_number;
|
2007-11-02 05:33:31 +00:00
|
|
|
nb_items++;
|
|
|
|
pcb_layer_number++;
|
|
|
|
}
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
SetSizer( OuterBoxSizer );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
for( ii = 0; ii < nb_items; ii++ )
|
|
|
|
{
|
|
|
|
// If more than 16 Gerber layers are used, provide a vertical line to
|
|
|
|
// separate the two FlexGrid sizers
|
|
|
|
if( (nb_items > 16) && (ii == 16) )
|
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxLI_VERTICAL );
|
|
|
|
MainBoxSizer->Add( Line, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Provide a separate FlexGrid sizer for every sixteen sets of controls
|
|
|
|
if( ii % 16 == 0 )
|
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
// Each Gerber layer has an associated static text string (to
|
|
|
|
// identify that layer), a button (for invoking a child dialog
|
|
|
|
// box to change which pcbnew layer that the Gerber layer is
|
|
|
|
// mapped to), and a second static text string (to depict which
|
|
|
|
// pcbnew layer that the Gerber layer has been mapped to). Each
|
|
|
|
// of those items are placed into the left hand column, middle
|
|
|
|
// column, and right hand column (respectively) of the Flexgrid
|
|
|
|
// sizer, and the color of the second text string is set to
|
2009-11-09 14:00:22 +00:00
|
|
|
// fuchsia or blue (to respectively indicate whether the Gerber
|
2009-04-29 17:09:00 +00:00
|
|
|
// layer has been mapped to a pcbnew layer or is not being
|
|
|
|
// exported at all). (Experimentation has shown that if a text
|
|
|
|
// control is used to depict which pcbnew layer that each Gerber
|
|
|
|
// layer is mapped to (instead of a static text string), then
|
|
|
|
// those controls do not behave in a fully satisfactory manner
|
|
|
|
// in the Linux version. Even when the read-only attribute is
|
|
|
|
// specified for all of those controls, they can still be selected
|
|
|
|
// when the arrow keys or Tab key is used to step through all of
|
|
|
|
// the controls within the dialog box, and directives to set the
|
|
|
|
// foreground color of the text of each such control to blue (to
|
|
|
|
// indicate that the text is of a read-only nature) are disregarded.
|
|
|
|
// Specify a FlexGrid sizer with an appropriate number of rows
|
|
|
|
// and three columns. If nb_items < 16, then the number of rows
|
|
|
|
// is nb_items; otherwise, the number of rows is 16 (with two
|
|
|
|
// separate columns of controls being used if nb_items > 16).
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
if( nb_items < 16 )
|
2009-04-29 17:09:00 +00:00
|
|
|
FlexColumnBoxSizer = new wxFlexGridSizer( nb_items, 4, 0, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
else
|
2009-04-29 17:09:00 +00:00
|
|
|
FlexColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Specify that all of the rows can be expanded.
|
2009-04-29 17:09:00 +00:00
|
|
|
for( int jj = 0; jj < MIN( nb_items, 16 ); jj++ )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
FlexColumnBoxSizer->AddGrowableRow( jj );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Specify that (just) the right-hand column can be expanded.
|
2009-04-29 17:09:00 +00:00
|
|
|
FlexColumnBoxSizer->AddGrowableCol( 2 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
MainBoxSizer->Add( FlexColumnBoxSizer, 1, wxGROW | wxTOP, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Provide a text string to identify the Gerber layer
|
2009-04-29 17:09:00 +00:00
|
|
|
msg = _( "Layer " );
|
2007-11-02 05:33:31 +00:00
|
|
|
msg << ButtonTable[ii] + 1;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
label = new wxStaticText( this, wxID_STATIC, msg, wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxALIGN_RIGHT );
|
|
|
|
FlexColumnBoxSizer->Add( label, 0,
|
|
|
|
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
|
|
|
|
wxALL, 5 );
|
|
|
|
|
|
|
|
/* Add file name and extension without path. */
|
|
|
|
wxFileName fn( g_GERBER_List[ii]->m_FileName );
|
|
|
|
label = new wxStaticText( this, wxID_STATIC, fn.GetFullName(),
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
FlexColumnBoxSizer->Add( label, 0,
|
|
|
|
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
|
|
|
|
wxALL, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Provide a button for this layer (which will invoke a child dialog box)
|
|
|
|
item_ID = ID_BUTTON_0 + ii;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
Button = new wxButton( this, item_ID, wxT( "..." ),
|
|
|
|
wxDefaultPosition, wxSize( w, h ), 0 );
|
|
|
|
|
|
|
|
FlexColumnBoxSizer->Add( Button, 0,
|
|
|
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
|
|
wxALL, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Provide another text string to specify which pcbnew layer that this
|
|
|
|
// Gerber layer is initially mapped to, and set the initial text to
|
|
|
|
// specify the appropriate pcbnew layer, and set the foreground color
|
2009-11-09 14:00:22 +00:00
|
|
|
// of the text to fuchsia (to indicate that the layer is being exported).
|
2007-11-02 05:33:31 +00:00
|
|
|
item_ID = ID_TEXT_0 + ii;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
// When the first of these text strings is being added, determine what
|
|
|
|
// size is necessary to to be able to display any possible string
|
|
|
|
// without it being truncated. Then specify that size as the minimum
|
|
|
|
// size for all of these text strings. (If this minimum size is not
|
|
|
|
// determined in this fashion, then it is possible for the display of
|
|
|
|
// one or more of these strings to be truncated after different pcbnew
|
|
|
|
// layers are selected.)
|
2007-11-02 05:33:31 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
msg = _( "Do not export" );
|
2009-04-29 17:09:00 +00:00
|
|
|
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
goodSize = text->GetSize();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
for( int jj = 0; jj < NB_LAYERS; jj++ )
|
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
text->SetLabel( BOARD::GetDefaultLayerName( jj ) );
|
2007-11-02 05:33:31 +00:00
|
|
|
if( goodSize.x < text->GetSize().x )
|
|
|
|
goodSize.x = text->GetSize().x;
|
|
|
|
}
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
msg = BOARD::GetDefaultLayerName( LayerLookUpTable[ButtonTable[ii]] );
|
2007-11-02 05:33:31 +00:00
|
|
|
text->SetLabel( msg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
msg = BOARD::GetDefaultLayerName( LayerLookUpTable[ButtonTable[ii]] );
|
2009-04-29 17:09:00 +00:00
|
|
|
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
text->SetMinSize( goodSize );
|
2009-04-29 17:09:00 +00:00
|
|
|
FlexColumnBoxSizer->Add( text, 1,
|
|
|
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,
|
|
|
|
5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
layer_list[ii] = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If required, provide spacers to occupy otherwise blank cells within the
|
|
|
|
// second FlexGrid sizer. (As it incorporates three columns, three spacers
|
|
|
|
// are thus required for each otherwise unused row.)
|
|
|
|
if( 16 < nb_items && nb_items < 32 )
|
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
for( ii = 4 * nb_items; ii < 96; ii++ )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
FlexColumnBoxSizer->Add( 5, h, 0,
|
|
|
|
wxALIGN_CENTER_HORIZONTAL |
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxLEFT |
|
|
|
|
wxRIGHT | wxBOTTOM, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
// Provide a line to separate the controls which have been provided so far
|
|
|
|
// from the OK and Cancel buttons (which will be provided after this line)
|
2009-04-29 17:09:00 +00:00
|
|
|
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxLI_HORIZONTAL );
|
|
|
|
OuterBoxSizer->Add( Line, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Provide a StdDialogButtonSizer to accommodate the OK and Cancel buttons;
|
|
|
|
// using that type of sizer results in those buttons being automatically
|
|
|
|
// located in positions appropriate for each (OS) version of KiCad.
|
|
|
|
StdDialogButtonSizer = new wxStdDialogButtonSizer;
|
2009-04-29 17:09:00 +00:00
|
|
|
OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
Button = new wxButton( this, wxID_OK, _( "&OK" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
StdDialogButtonSizer->AddButton( Button );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "&Cancel" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
StdDialogButtonSizer->AddButton( Button );
|
2007-11-02 05:33:31 +00:00
|
|
|
StdDialogButtonSizer->Realize();
|
|
|
|
|
|
|
|
// Resize the dialog
|
2007-10-07 03:08:24 +00:00
|
|
|
if( GetSizer() )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void SWAP_LAYERS_DIALOG::OnSelectLayer( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-02 05:33:31 +00:00
|
|
|
int ii, jj;
|
|
|
|
|
|
|
|
ii = event.GetId();
|
|
|
|
|
|
|
|
if( ii < ID_BUTTON_0 || ii >= ID_BUTTON_0 + 32 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ii = event.GetId() - ID_BUTTON_0;
|
|
|
|
|
|
|
|
jj = LayerLookUpTable[ButtonTable[ii]];
|
2009-04-29 17:09:00 +00:00
|
|
|
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
|
2007-11-02 05:33:31 +00:00
|
|
|
jj = 0; // (Defaults to "Copper" layer.)
|
2009-04-29 17:09:00 +00:00
|
|
|
jj = m_Parent->SelectLayer( jj, -1, -1, true );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
|
2007-11-02 05:33:31 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( jj != LayerLookUpTable[ButtonTable[ii]] )
|
|
|
|
{
|
|
|
|
LayerLookUpTable[ButtonTable[ii]] = jj;
|
2007-11-22 00:40:17 +00:00
|
|
|
if( jj == LAYER_UNSELECTED )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2007-11-02 05:33:31 +00:00
|
|
|
layer_list[ii]->SetLabel( _( "Do not export" ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Change the text color to blue (to highlight
|
|
|
|
// that this layer is *not* being exported)
|
|
|
|
layer_list[ii]->SetForegroundColour( *wxBLUE );
|
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
else
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
layer_list[ii]->SetLabel( BOARD::GetDefaultLayerName( jj ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// Change the text color to fuchsia (to highlight
|
2007-11-05 06:14:55 +00:00
|
|
|
// that this layer *is* being exported)
|
2009-04-29 17:09:00 +00:00
|
|
|
layer_list[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void SWAP_LAYERS_DIALOG::OnCancelClick( wxCommandEvent& event )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void SWAP_LAYERS_DIALOG::OnOkClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
int ii;
|
2008-03-04 04:22:27 +00:00
|
|
|
bool AsCmpLayer = false;
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
/* Compute the number of copper layers
|
|
|
|
* this is the max layer number + 1 (if some internal layers exist)
|
|
|
|
*/
|
2009-10-28 11:48:47 +00:00
|
|
|
int layers_count = 1;
|
2007-11-02 05:33:31 +00:00
|
|
|
for( ii = 0; ii < 32; ii++ )
|
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
if( LayerLookUpTable[ii] == LAYER_N_FRONT )
|
2007-11-02 05:33:31 +00:00
|
|
|
AsCmpLayer = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( LayerLookUpTable[ii] >= LAST_COPPER_LAYER )
|
|
|
|
continue; // not a copper layer
|
2009-10-28 11:48:47 +00:00
|
|
|
if( LayerLookUpTable[ii] >= layers_count )
|
|
|
|
layers_count++;
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( AsCmpLayer )
|
2009-10-28 11:48:47 +00:00
|
|
|
layers_count++;
|
|
|
|
if( layers_count > NB_COPPER_LAYERS ) // should not occur.
|
|
|
|
layers_count = NB_COPPER_LAYERS;
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
m_Parent->GetBoard()->SetCopperLayerCount( layers_count );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( 1 );
|
|
|
|
}
|