2014-10-23 17:53:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-03-28 13:30:11 +00:00
|
|
|
* Copyright (C) 2007-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-23 17:53:38 +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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file swap_layers.cpp
|
2018-03-28 13:30:11 +00:00
|
|
|
* @brief Dialog to move board items between layers.
|
2010-02-19 13:23:58 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2013-02-22 20:03:00 +00:00
|
|
|
#include <dialog_shim.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
2018-08-30 16:44:27 +00:00
|
|
|
#include <class_zone.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawsegment.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-03-28 13:30:11 +00:00
|
|
|
#include <board_commit.h>
|
2007-11-20 10:08:07 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <wx/statline.h>
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
#define NO_CHANGE PCB_LAYER_ID(-3)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
|
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,
|
2017-03-13 03:19:33 +00:00
|
|
|
ID_TEXT_0 = ID_BUTTON_0 + PCB_LAYER_ID_COUNT
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
class MOVE_SWAP_LAYER_DIALOG : public DIALOG_SHIM
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
public:
|
2018-03-28 10:45:54 +00:00
|
|
|
MOVE_SWAP_LAYER_DIALOG( PCB_BASE_FRAME* parent, PCB_LAYER_ID* aArray );
|
|
|
|
// ~MOVE_SWAP_LAYER_DIALOG() { };
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
private:
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* m_Parent;
|
2018-03-28 13:30:11 +00:00
|
|
|
wxBoxSizer* m_outerBoxSizer;
|
|
|
|
wxBoxSizer* m_mainBoxSizer;
|
2007-11-02 05:33:31 +00:00
|
|
|
wxFlexGridSizer* FlexColumnBoxSizer;
|
|
|
|
wxStdDialogButtonSizer* StdDialogButtonSizer;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID* m_callers_nlayers; // DIM() is PCB_LAYER_ID_COUNT
|
|
|
|
wxStaticText* layer_list[PCB_LAYER_ID_COUNT];
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
void Sel_Layer( wxCommandEvent& event );
|
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
BEGIN_EVENT_TABLE( MOVE_SWAP_LAYER_DIALOG, wxDialog )
|
2017-03-13 03:19:33 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + PCB_LAYER_ID_COUNT - 1,
|
2018-03-28 10:45:54 +00:00
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED, MOVE_SWAP_LAYER_DIALOG::Sel_Layer )
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
EVT_BUTTON( wxID_OK, MOVE_SWAP_LAYER_DIALOG::OnOkClick )
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
EVT_BUTTON( wxID_CANCEL, MOVE_SWAP_LAYER_DIALOG::OnCancelClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
MOVE_SWAP_LAYER_DIALOG::MOVE_SWAP_LAYER_DIALOG( PCB_BASE_FRAME* parent, PCB_LAYER_ID* aArray ) :
|
|
|
|
DIALOG_SHIM( parent, -1, _( "Move Layers:" ), wxPoint( -1, -1 ),
|
2014-06-24 16:17:18 +00:00
|
|
|
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
|
|
|
|
m_callers_nlayers( aArray )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
memset( layer_list, 0, sizeof( layer_list ) );
|
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
BOARD* board = parent->GetBoard();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
m_outerBoxSizer = NULL;
|
|
|
|
m_mainBoxSizer = NULL;
|
2007-11-02 05:33:31 +00:00
|
|
|
FlexColumnBoxSizer = NULL;
|
|
|
|
StdDialogButtonSizer = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
int item_ID;
|
2007-11-02 05:33:31 +00:00
|
|
|
wxSize goodSize;
|
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
/* 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-05-01 18:06:03 +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
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
m_outerBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
SetSizer( m_outerBoxSizer );
|
2009-05-01 18:06:03 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
m_mainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
m_outerBoxSizer->Add( m_mainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( unsigned layer = 0; layer < DIM( layer_list ); ++layer )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2007-11-02 05:33:31 +00:00
|
|
|
// Provide a vertical line to separate the two FlexGrid sizers
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layer == 32 )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2018-03-28 13:30:11 +00:00
|
|
|
wxStaticLine* line = new wxStaticLine( this, -1, wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxLI_VERTICAL );
|
|
|
|
m_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
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layer % 16 == 0 )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2009-05-01 18:06:03 +00:00
|
|
|
/* Each layer has an associated static text string (to identify
|
|
|
|
* that layer), a button (for invoking a child dialog box to
|
|
|
|
* change which layer that the layer is mapped to), and a second
|
|
|
|
* static text string (to depict which layer that the 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 fuchsia or blue (to respectively indicate whether the
|
|
|
|
* layer has been swapped to another layer or is not being swapped
|
|
|
|
* at all). (Experimentation has shown that if a text control is
|
|
|
|
* used to depict which layer that each 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 sixteen rows and three columns.
|
|
|
|
*/
|
|
|
|
FlexColumnBoxSizer = new wxFlexGridSizer( 16, 3, 0, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Specify that all of the rows can be expanded.
|
|
|
|
for( int jj = 0; jj < 16; jj++ )
|
|
|
|
{
|
2009-05-01 18:06:03 +00:00
|
|
|
FlexColumnBoxSizer->AddGrowableRow( jj );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Specify that (just) the right-hand column can be expanded.
|
2009-05-01 18:06:03 +00:00
|
|
|
FlexColumnBoxSizer->AddGrowableCol( 2 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
m_mainBoxSizer->Add( FlexColumnBoxSizer, 1, wxGROW | wxTOP, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
/* Provide a text string to identify this layer (with trailing spaces
|
|
|
|
* within that string being purged).
|
|
|
|
*/
|
2018-03-28 13:30:11 +00:00
|
|
|
wxStaticText* label = new wxStaticText( this, wxID_STATIC,
|
|
|
|
board->GetLayerName( ToLAYER_ID( layer ) ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxALIGN_RIGHT );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
FlexColumnBoxSizer->Add( label, 0,
|
|
|
|
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
|
|
|
|
wxLEFT | wxBOTTOM,
|
|
|
|
5 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
// Provide a button for this layer (which will invoke a child dialog box)
|
2014-06-24 16:17:18 +00:00
|
|
|
item_ID = ID_BUTTON_0 + layer;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
wxButton* Button = new wxButton( this, item_ID, wxT( "..." ), wxDefaultPosition,
|
|
|
|
wxSize( w, h ), 0 );
|
2009-05-01 18:06:03 +00:00
|
|
|
FlexColumnBoxSizer->Add( Button, 0,
|
|
|
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
|
|
wxLEFT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
/* Provide another text string to specify which layer that this layer
|
|
|
|
* is mapped to, set the initial text to "No Change" (to indicate that
|
|
|
|
* this layer is currently unmapped to any other layer), and set the
|
|
|
|
* foreground color of the text to blue (which also indicates that the
|
|
|
|
* layer is currently unmapped to any other layer).
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
item_ID = ID_TEXT_0 + layer;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
/* When the first of these text strings is being added, determine
|
2013-09-11 15:30:21 +00:00
|
|
|
* what size is necessary to to be able to display the longest
|
|
|
|
* string without truncation. Then use that size as the
|
|
|
|
* minimum size for all text strings. (If the minimum
|
|
|
|
* size is not this size, strings can be truncated after
|
|
|
|
* some other layer is selected.)
|
2009-05-01 18:06:03 +00:00
|
|
|
*/
|
2018-03-28 13:30:11 +00:00
|
|
|
wxStaticText* text;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layer == 0 )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2018-03-28 13:30:11 +00:00
|
|
|
text = new wxStaticText( this, item_ID,
|
|
|
|
board->GetLayerName( PCB_LAYER_ID( 0 ) ),
|
2009-05-01 18:06:03 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
goodSize = text->GetSize();
|
2009-05-01 18:06:03 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( unsigned jj = 1; jj < DIM( layer_list ); ++jj )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2014-06-29 13:05:51 +00:00
|
|
|
text->SetLabel( board->GetLayerName( ToLAYER_ID( jj ) ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
if( goodSize.x < text->GetSize().x )
|
|
|
|
goodSize.x = text->GetSize().x;
|
|
|
|
}
|
2009-05-01 18:06:03 +00:00
|
|
|
|
|
|
|
text->SetLabel( _( "No Change" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
if( goodSize.x < text->GetSize().x )
|
|
|
|
goodSize.x = text->GetSize().x;
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2009-05-01 18:06:03 +00:00
|
|
|
text = new wxStaticText( this, item_ID, _( "No Change" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
text->SetMinSize( goodSize );
|
2009-05-01 18:06:03 +00:00
|
|
|
FlexColumnBoxSizer->Add( text, 1,
|
|
|
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
|
|
wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
2014-06-24 16:17:18 +00:00
|
|
|
layer_list[layer] = text;
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
2009-05-01 18:06:03 +00:00
|
|
|
/* Provide spacers to occupy otherwise blank cells within the second
|
2018-03-28 10:45:54 +00:00
|
|
|
* FlexGrid sizer. (Because there are three columns, three spacers
|
2013-09-11 15:30:21 +00:00
|
|
|
* are thus required for each unused row.)
|
2013-03-31 13:27:46 +00:00
|
|
|
for( int ii = 3 * NB_PCB_LAYERS; ii < 96; ii++ )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2009-05-01 18:06:03 +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
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
2007-08-23 04:28:46 +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)
|
2018-03-28 13:30:11 +00:00
|
|
|
wxStaticLine* line = new wxStaticLine( this, -1, wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxLI_HORIZONTAL );
|
|
|
|
m_outerBoxSizer->Add( line, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
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;
|
2018-03-28 13:30:11 +00:00
|
|
|
m_outerBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
wxButton* Button = new wxButton( this, wxID_OK, _( "&OK" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2011-03-14 19:17:42 +00:00
|
|
|
Button->SetDefault();
|
2009-05-01 18:06:03 +00:00
|
|
|
StdDialogButtonSizer->AddButton( Button );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-05-01 18:06:03 +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();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
// Resize the dialog
|
2018-03-28 10:45:54 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2013-09-25 19:09:57 +00:00
|
|
|
|
|
|
|
Center();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
void MOVE_SWAP_LAYER_DIALOG::Sel_Layer( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
int ii;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
ii = event.GetId();
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( ii < ID_BUTTON_0 || ii >= ID_BUTTON_0 + PCB_LAYER_ID_COUNT )
|
2007-11-02 05:33:31 +00:00
|
|
|
return;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-11-02 05:33:31 +00:00
|
|
|
ii = event.GetId() - ID_BUTTON_0;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = m_callers_nlayers[ii];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET notallowed_mask = IsCopperLayer( ii ) ? LSET::AllNonCuMask() : LSET::AllCuMask();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
layer = m_Parent->SelectLayer( layer == NO_CHANGE ? ToLAYER_ID( ii ): layer, notallowed_mask );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
if( !IsValidLayer( layer ) )
|
2007-11-02 05:33:31 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layer != m_callers_nlayers[ii] )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_callers_nlayers[ii] = layer;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layer == NO_CHANGE || layer == ii )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2007-11-02 05:33:31 +00:00
|
|
|
layer_list[ii]->SetLabel( _( "No Change" ) );
|
2009-05-01 18:06:03 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Change the text color to blue (to highlight
|
|
|
|
// that this layer is *not* being swapped)
|
|
|
|
layer_list[ii]->SetForegroundColour( *wxBLUE );
|
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
else
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2013-09-25 19:09:57 +00:00
|
|
|
layer_list[ii]->SetLabel( m_Parent->GetBoard()->GetLayerName( layer ) );
|
2009-05-01 18:06:03 +00:00
|
|
|
|
|
|
|
// Change the text color to fuchsia (to highlight
|
2007-11-05 06:14:55 +00:00
|
|
|
// that this layer *is* being swapped)
|
2009-05-01 18:06:03 +00:00
|
|
|
layer_list[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2018-03-28 10:45:54 +00:00
|
|
|
|
|
|
|
layer_list[ii]->Refresh();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
void MOVE_SWAP_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2018-03-28 10:45:54 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
void MOVE_SWAP_LAYER_DIALOG::OnOkClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2018-03-28 10:45:54 +00:00
|
|
|
EndModal( wxID_OK );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID new_layer[PCB_LAYER_ID_COUNT];
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( unsigned i = 0; i < DIM( new_layer ); ++i )
|
|
|
|
new_layer[i] = NO_CHANGE;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
MOVE_SWAP_LAYER_DIALOG dlg( this, new_layer );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 10:45:54 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2014-06-24 16:17:18 +00:00
|
|
|
return; // (Canceled dialog box returns -1 instead)
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
bool hasChanges = false;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Change traces.
|
|
|
|
for( TRACK* segm = GetBoard()->m_Track; segm; segm = segm->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( segm->Type() == PCB_VIA_T )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
VIA* via = (VIA*) segm;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( via->GetViaType() == VIA_THROUGH )
|
2007-08-23 04:28:46 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID top_layer, bottom_layer;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
via->LayerPair( &top_layer, &bottom_layer );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( new_layer[bottom_layer] != NO_CHANGE )
|
|
|
|
bottom_layer = new_layer[bottom_layer];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( new_layer[top_layer] != NO_CHANGE )
|
|
|
|
top_layer = new_layer[top_layer];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
commit.Modify( via );
|
|
|
|
hasChanges = true;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
via->SetLayerPair( top_layer, bottom_layer );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
int jj = segm->GetLayer();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( new_layer[jj] != NO_CHANGE )
|
2018-03-28 13:30:11 +00:00
|
|
|
{
|
|
|
|
commit.Modify( segm );
|
|
|
|
hasChanges = true;
|
2014-06-24 16:17:18 +00:00
|
|
|
segm->SetLayer( new_layer[jj] );
|
2018-03-28 13:30:11 +00:00
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 16:44:27 +00:00
|
|
|
// Change zones
|
|
|
|
for( auto zone : GetBoard()->Zones() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2018-08-30 16:44:27 +00:00
|
|
|
int jj = zone->GetLayer();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( new_layer[jj] != NO_CHANGE )
|
2018-08-30 16:44:27 +00:00
|
|
|
zone->SetLayer( new_layer[jj] );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Change other segments.
|
2016-09-27 18:04:30 +00:00
|
|
|
for( auto item : GetBoard()->Drawings() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( item->Type() == PCB_LINE_T )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
DRAWSEGMENT* drawsegm = (DRAWSEGMENT*) item;
|
|
|
|
int jj = drawsegm->GetLayer();
|
|
|
|
|
|
|
|
if( new_layer[jj] != NO_CHANGE )
|
2018-03-28 13:30:11 +00:00
|
|
|
{
|
|
|
|
commit.Modify( drawsegm );
|
|
|
|
hasChanges = true;
|
2014-06-24 16:17:18 +00:00
|
|
|
drawsegm->SetLayer( new_layer[jj] );
|
2018-03-28 13:30:11 +00:00
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 13:30:11 +00:00
|
|
|
if( hasChanges )
|
|
|
|
commit.Push( "Layers moved" );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|