2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file sel_layer.cpp
|
2013-08-30 19:28:31 +00:00
|
|
|
* @brief dialogs for one layer selection and a layer pair selection.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
|
|
|
#include <pcbcommon.h>
|
2013-08-30 19:28:31 +00:00
|
|
|
#include <class_layer_box_selector.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2013-08-30 19:28:31 +00:00
|
|
|
#include <dialogs/dialog_layer_selection_base.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
/* classes to display a layer list using a wxGrid.
|
|
|
|
*/
|
|
|
|
class PCB_LAYER_SELECTOR: public LAYER_SELECTOR
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
BOARD * m_brd;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
2013-08-30 19:28:31 +00:00
|
|
|
PCB_LAYER_SELECTOR( BOARD* aBrd ):LAYER_SELECTOR()
|
|
|
|
{
|
|
|
|
m_brd = aBrd;
|
|
|
|
}
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
protected:
|
|
|
|
// Returns true if the layer id is enabled (i.e. is it should be displayed)
|
|
|
|
bool IsLayerEnabled( LAYER_NUM aLayer ) const
|
|
|
|
{
|
|
|
|
return m_brd->IsLayerEnabled( aLayer );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
// Returns a color index from the layer id
|
|
|
|
// Virtual function
|
|
|
|
EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const
|
|
|
|
{
|
|
|
|
return m_brd->GetLayerColor( aLayer );
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
// Returns the name of the layer id
|
|
|
|
// Virtual function
|
|
|
|
wxString GetLayerName( LAYER_NUM aLayer ) const
|
|
|
|
{
|
|
|
|
return m_brd->GetLayerName( aLayer );
|
|
|
|
}
|
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
/*
|
2013-09-11 15:30:21 +00:00
|
|
|
* This class display a pcb layers list in a dialog,
|
2013-08-30 19:28:31 +00:00
|
|
|
* to select one layer from this list
|
2007-10-07 03:08:24 +00:00
|
|
|
*/
|
2013-08-30 19:28:31 +00:00
|
|
|
class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR,
|
|
|
|
public DIALOG_LAYER_SELECTION_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
LAYER_NUM m_layerSelected;
|
2013-09-11 15:30:21 +00:00
|
|
|
LAYER_MSK m_notAllowedLayersMask;
|
2013-09-03 19:37:52 +00:00
|
|
|
std::vector<LAYER_NUM> m_layersIdLeftColumn;
|
|
|
|
std::vector<LAYER_NUM> m_layersIdRightColumn;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
public:
|
|
|
|
PCB_ONE_LAYER_SELECTOR( wxWindow* aParent, BOARD * aBrd,
|
|
|
|
LAYER_NUM aDefaultLayer,
|
2013-09-25 19:09:57 +00:00
|
|
|
LAYER_MSK aNotAllowedLayersMask );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
LAYER_NUM GetLayerSelection() { return m_layerSelected; }
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
private:
|
|
|
|
// Event handlers
|
2013-09-11 15:30:21 +00:00
|
|
|
void OnLeftGridCellClick( wxGridEvent& event );
|
|
|
|
void OnRightGridCellClick( wxGridEvent& event );
|
2011-03-14 19:17:42 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void BuildList();
|
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( wxWindow* aParent,
|
|
|
|
BOARD * aBrd,
|
|
|
|
LAYER_NUM aDefaultLayer,
|
|
|
|
LAYER_MSK aNotAllowedLayersMask )
|
|
|
|
: PCB_LAYER_SELECTOR( aBrd ), DIALOG_LAYER_SELECTION_BASE( aParent )
|
|
|
|
{
|
|
|
|
m_layerSelected = (int) aDefaultLayer;
|
|
|
|
m_notAllowedLayersMask = aNotAllowedLayersMask;
|
|
|
|
BuildList();
|
|
|
|
Layout();
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
SetFocus();
|
|
|
|
}
|
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
// Build the layers list
|
|
|
|
// Column position by function:
|
|
|
|
#define SELECT_COLNUM 0
|
|
|
|
#define COLOR_COLNUM 1
|
|
|
|
#define LAYERNAME_COLNUM 2
|
|
|
|
static DECLARE_LAYERS_ORDER_LIST( layertranscode );
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::BuildList()
|
|
|
|
{
|
2013-09-03 19:37:52 +00:00
|
|
|
// Hide layerid column which is used only to know the layer id
|
|
|
|
// not to be shown in dialogs
|
2013-08-30 19:28:31 +00:00
|
|
|
m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
|
|
|
|
m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
|
|
|
|
|
|
|
|
int left_row = 0;
|
|
|
|
int right_row = 0;
|
|
|
|
wxString layername;
|
|
|
|
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
|
2007-10-07 03:08:24 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
LAYER_NUM layerid = i;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( m_layerorder )
|
|
|
|
layerid = layertranscode[i];
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( ! IsLayerEnabled( layerid ) )
|
|
|
|
continue;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
if( (m_notAllowedLayersMask & GetLayerMask( layerid )) != 0 )
|
2013-08-30 19:28:31 +00:00
|
|
|
continue;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
wxColour color = MakeColour( GetLayerColor( layerid ) );
|
|
|
|
layername = GetLayerName( layerid );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( layerid <= LAST_COPPER_LAYER )
|
|
|
|
{
|
|
|
|
if( left_row )
|
|
|
|
m_leftGridLayers->AppendRows( 1 );
|
|
|
|
|
|
|
|
m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM,
|
|
|
|
color );
|
|
|
|
m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM,
|
|
|
|
layername );
|
|
|
|
|
|
|
|
if( m_layerSelected == layerid )
|
|
|
|
{
|
|
|
|
m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM,
|
|
|
|
wxT("X") );
|
|
|
|
m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM,
|
|
|
|
color );
|
2013-09-03 19:37:52 +00:00
|
|
|
m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM );
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
|
|
|
|
2013-09-03 19:37:52 +00:00
|
|
|
m_layersIdLeftColumn.push_back( layerid );
|
2013-08-30 19:28:31 +00:00
|
|
|
left_row++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( right_row )
|
|
|
|
m_rightGridLayers->AppendRows( 1 );
|
|
|
|
|
|
|
|
m_rightGridLayers->SetCellBackgroundColour ( right_row, COLOR_COLNUM,
|
|
|
|
color );
|
|
|
|
m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM,
|
|
|
|
layername );
|
|
|
|
|
|
|
|
if( m_layerSelected == layerid )
|
|
|
|
{
|
|
|
|
m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM,
|
|
|
|
wxT("X") );
|
|
|
|
m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM,
|
|
|
|
color );
|
2013-09-03 19:37:52 +00:00
|
|
|
m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM );
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
|
|
|
|
2013-09-03 19:37:52 +00:00
|
|
|
m_layersIdRightColumn.push_back( layerid );
|
2013-08-30 19:28:31 +00:00
|
|
|
right_row++;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
// Show only populated lists:
|
|
|
|
if( left_row <= 0 )
|
|
|
|
m_leftGridLayers->Show( false );
|
2011-09-19 16:29:46 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( right_row <= 0 )
|
|
|
|
m_rightGridLayers->Show( false );
|
2011-09-19 16:29:46 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
|
|
|
|
m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
|
|
|
|
m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
|
|
|
|
m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-03 19:37:52 +00:00
|
|
|
m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ];
|
2013-09-11 15:30:21 +00:00
|
|
|
m_leftGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
|
2013-08-30 19:28:31 +00:00
|
|
|
EndModal( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-03 19:37:52 +00:00
|
|
|
m_layerSelected = m_layersIdRightColumn[ event.GetRow() ];
|
2013-09-11 15:30:21 +00:00
|
|
|
m_rightGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
|
2013-08-30 19:28:31 +00:00
|
|
|
EndModal( 2 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
/** Install the dialog box for layer selection
|
|
|
|
* @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer)
|
2013-09-11 15:30:21 +00:00
|
|
|
* @param aNotAllowedLayers = a layer mask for not allowed layers
|
|
|
|
* (= 0 to show all layers in use)
|
|
|
|
* @return the selected layer id
|
2013-08-30 19:28:31 +00:00
|
|
|
*/
|
|
|
|
LAYER_NUM PCB_BASE_FRAME::SelectLayer( LAYER_NUM aDefaultLayer,
|
2013-09-25 19:09:57 +00:00
|
|
|
LAYER_MSK aNotAllowedLayersMask,
|
|
|
|
wxPoint aDlgPosition )
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
|
|
|
PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(),
|
2013-09-11 15:30:21 +00:00
|
|
|
aDefaultLayer, aNotAllowedLayersMask );
|
2013-09-25 19:09:57 +00:00
|
|
|
if( aDlgPosition != wxDefaultPosition )
|
|
|
|
{
|
|
|
|
wxSize dlgSize = dlg.GetSize();
|
|
|
|
aDlgPosition.x -= dlgSize.x/2;
|
|
|
|
aDlgPosition.y -= dlgSize.y/2;
|
|
|
|
dlg.SetPosition( aDlgPosition );
|
|
|
|
}
|
2013-08-30 19:28:31 +00:00
|
|
|
dlg.ShowModal();
|
|
|
|
LAYER_NUM layer = dlg.GetLayerSelection();
|
|
|
|
return layer;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
/*
|
|
|
|
* This class display a double pcb copper layers list in a dialog,
|
2013-09-20 10:52:33 +00:00
|
|
|
* to select a layer pair from these lists
|
2013-08-30 19:28:31 +00:00
|
|
|
*/
|
|
|
|
class SELECT_COPPER_LAYERS_PAIR_DIALOG: public PCB_LAYER_SELECTOR,
|
|
|
|
public DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
2013-08-30 19:28:31 +00:00
|
|
|
BOARD* m_brd;
|
|
|
|
LAYER_NUM m_frontLayer;
|
|
|
|
LAYER_NUM m_backLayer;
|
|
|
|
int m_leftRowSelected;
|
|
|
|
int m_rightRowSelected;
|
2013-09-03 19:37:52 +00:00
|
|
|
std::vector<LAYER_NUM> m_layersId;
|
2013-08-30 19:28:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG( wxWindow* aParent, BOARD * aPcb,
|
|
|
|
LAYER_NUM aFrontLayer, LAYER_NUM aBackLayer );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void GetLayerPair( LAYER_NUM& aFrontLayer, LAYER_NUM& aBackLayer )
|
|
|
|
{
|
|
|
|
aFrontLayer = m_frontLayer;
|
|
|
|
aBackLayer = m_backLayer;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
private:
|
2013-09-11 15:30:21 +00:00
|
|
|
void OnLeftGridCellClick( wxGridEvent& event );
|
|
|
|
void OnRightGridCellClick( wxGridEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( wxID_OK );
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void BuildList();
|
2013-09-20 10:52:33 +00:00
|
|
|
void SetGridCursor( wxGrid* aGrid, int aRow, bool aEnable );
|
2013-08-30 19:28:31 +00:00
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
/* Display a list of two copper layers to choose a pair of copper layers
|
|
|
|
* the layer pair is used to fast switch between copper layers when placing vias
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2013-09-11 15:30:21 +00:00
|
|
|
void PCB_BASE_FRAME::SelectCopperLayerPair()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
PCB_SCREEN* screen = GetScreen();
|
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( this, GetBoard(),
|
|
|
|
screen->m_Route_Layer_TOP,
|
|
|
|
screen->m_Route_Layer_BOTTOM );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2007-10-07 03:08:24 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
// select the same layer for both layers is allowed (normal in some boards)
|
|
|
|
// but could be a mistake. So display an info message
|
|
|
|
if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
|
|
|
|
DisplayInfoMessage( this,
|
|
|
|
_( "Warning: The Top Layer and Bottom Layer are same." ) );
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG::
|
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG( wxWindow* aParent, BOARD * aPcb,
|
|
|
|
LAYER_NUM aFrontLayer, LAYER_NUM aBackLayer) :
|
|
|
|
PCB_LAYER_SELECTOR( aPcb ),
|
|
|
|
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( aParent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
m_frontLayer = aFrontLayer;
|
|
|
|
m_backLayer = aBackLayer;
|
|
|
|
m_leftRowSelected = 0;
|
|
|
|
m_rightRowSelected = 0;
|
|
|
|
BuildList();
|
|
|
|
SetFocus();
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Center();
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
void SELECT_COPPER_LAYERS_PAIR_DIALOG::BuildList()
|
|
|
|
{
|
|
|
|
m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
|
|
|
|
m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
|
|
|
|
|
|
|
|
// Select a not show cell, to avoid a wrong cell selection for user
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
wxString layername;
|
2013-09-03 19:37:52 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
|
|
|
|
{
|
|
|
|
LAYER_NUM layerid = i;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( m_layerorder )
|
|
|
|
layerid = layertranscode[i];
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( ! IsLayerEnabled( layerid ) )
|
|
|
|
continue;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( layerid > LAST_COPPER_LAYER )
|
|
|
|
continue;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
wxColour color = MakeColour( GetLayerColor( layerid ) );
|
|
|
|
layername = GetLayerName( layerid );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( row )
|
|
|
|
m_leftGridLayers->AppendRows( 1 );
|
2013-09-03 19:37:52 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
m_leftGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM,
|
|
|
|
color );
|
|
|
|
m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM,
|
|
|
|
layername );
|
2013-09-03 19:37:52 +00:00
|
|
|
m_layersId.push_back( layerid );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( m_frontLayer == layerid )
|
|
|
|
{
|
2013-09-20 10:52:33 +00:00
|
|
|
SetGridCursor( m_leftGridLayers, row, true );
|
2013-08-30 19:28:31 +00:00
|
|
|
m_leftRowSelected = row;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( row )
|
|
|
|
m_rightGridLayers->AppendRows( 1 );
|
|
|
|
m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM,
|
|
|
|
color );
|
|
|
|
m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM,
|
|
|
|
layername );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( m_backLayer == layerid )
|
|
|
|
{
|
2013-09-20 10:52:33 +00:00
|
|
|
SetGridCursor( m_rightGridLayers, row, true );
|
2013-08-30 19:28:31 +00:00
|
|
|
m_rightRowSelected = row;
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
row++;
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
|
|
|
|
m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
|
|
|
|
m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
|
|
|
|
m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
|
|
|
|
}
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-09-20 10:52:33 +00:00
|
|
|
void SELECT_COPPER_LAYERS_PAIR_DIALOG::SetGridCursor( wxGrid* aGrid, int aRow,
|
|
|
|
bool aEnable )
|
|
|
|
{
|
|
|
|
if( aEnable )
|
|
|
|
{
|
|
|
|
LAYER_NUM layerid = m_layersId[aRow];
|
|
|
|
wxColour color = MakeColour( GetLayerColor( layerid ) );
|
|
|
|
aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") );
|
|
|
|
aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color );
|
|
|
|
aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aGrid->SetCellValue( aRow, SELECT_COLNUM, wxEmptyString );
|
|
|
|
aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM,
|
|
|
|
aGrid->GetDefaultCellBackgroundColour() );
|
|
|
|
aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridCellClick( wxGridEvent& event )
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
|
|
|
int row = event.GetRow();
|
2013-09-03 19:37:52 +00:00
|
|
|
LAYER_NUM layer = m_layersId[row];
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( m_frontLayer == layer )
|
|
|
|
return;
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-09-20 10:52:33 +00:00
|
|
|
SetGridCursor( m_leftGridLayers, m_leftRowSelected, false );
|
2013-08-30 19:28:31 +00:00
|
|
|
m_frontLayer = layer;
|
|
|
|
m_leftRowSelected = row;
|
2013-09-20 10:52:33 +00:00
|
|
|
SetGridCursor( m_leftGridLayers, m_leftRowSelected, true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnRightGridCellClick( wxGridEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
int row = event.GetRow();
|
2013-09-03 19:37:52 +00:00
|
|
|
LAYER_NUM layer = m_layersId[row];
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
if( m_backLayer == layer )
|
|
|
|
return;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-09-20 10:52:33 +00:00
|
|
|
SetGridCursor( m_rightGridLayers, m_rightRowSelected, false );
|
2013-08-30 19:28:31 +00:00
|
|
|
m_backLayer = layer;
|
|
|
|
m_rightRowSelected = row;
|
2013-09-20 10:52:33 +00:00
|
|
|
SetGridCursor( m_rightGridLayers, m_rightRowSelected, true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|