2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file sel_layer.cpp
|
2019-07-28 10:54:59 +00:00
|
|
|
* @brief minor dialogs for one layer selection and a layer pair selection.
|
2013-08-30 19:28:31 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* 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
|
2021-07-21 21:37:49 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-08-30 19:28:31 +00:00
|
|
|
*
|
2019-07-28 10:54:59 +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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2013-08-30 19:28:31 +00:00
|
|
|
*
|
2019-07-28 10:54:59 +00:00
|
|
|
* 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.
|
2013-08-30 19:28:31 +00:00
|
|
|
*
|
2019-07-28 10:54:59 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
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 <confirm.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2018-09-22 10:51:18 +00:00
|
|
|
#include <widgets/layer_box_selector.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2013-08-30 19:28:31 +00:00
|
|
|
#include <dialogs/dialog_layer_selection_base.h>
|
2019-06-03 20:06:58 +00:00
|
|
|
#include <router/router_tool.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
// Column position by function:
|
|
|
|
#define SELECT_COLNUM 0
|
|
|
|
#define COLOR_COLNUM 1
|
|
|
|
#define LAYERNAME_COLNUM 2
|
|
|
|
|
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
/*
|
|
|
|
* Display a layer list using a wxGrid.
|
2013-08-30 19:28:31 +00:00
|
|
|
*/
|
|
|
|
class PCB_LAYER_SELECTOR: public LAYER_SELECTOR
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-08-04 12:43:02 +00:00
|
|
|
PCB_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame ) :
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_SELECTOR()
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
m_frame = aFrame;
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
protected:
|
2017-08-04 12:43:02 +00:00
|
|
|
PCB_BASE_FRAME* m_frame;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
///< @return true if the layer id is enabled (i.e. is it should be displayed).
|
2020-05-05 15:40:18 +00:00
|
|
|
bool isLayerEnabled( LAYER_NUM aLayer ) const override
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
return m_frame->GetBoard()->IsLayerEnabled( PCB_LAYER_ID( aLayer ) );
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
// Return the color index from the layer ID.
|
2020-05-05 15:40:18 +00:00
|
|
|
COLOR4D getLayerColor( LAYER_NUM aLayer ) const override
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2020-05-16 17:15:43 +00:00
|
|
|
return m_frame->GetColorSettings()->GetColor( aLayer );
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
// Return the name of the layer ID.
|
2020-05-05 15:40:18 +00:00
|
|
|
wxString getLayerName( LAYER_NUM aLayer ) const override
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
/**
|
|
|
|
* Display a PCB layers list in a dialog to select one layer from this list.
|
2007-10-07 03:08:24 +00:00
|
|
|
*/
|
2021-07-21 21:37:49 +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
|
|
|
public:
|
2018-06-30 20:22:01 +00:00
|
|
|
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer,
|
|
|
|
LSET aNotAllowedLayersMask );
|
2021-02-17 19:47:28 +00:00
|
|
|
~PCB_ONE_LAYER_SELECTOR();
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +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
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnLeftGridCellClick( wxGridEvent& event ) override;
|
|
|
|
void OnRightGridCellClick( wxGridEvent& event ) override;
|
2011-03-14 19:17:42 +00:00
|
|
|
|
2021-02-17 19:47:28 +00:00
|
|
|
// Will close the dialog on ESC key
|
|
|
|
void onCharHook( wxKeyEvent& event );
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void buildList();
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
PCB_LAYER_ID m_layerSelected;
|
|
|
|
LSET m_notAllowedLayersMask;
|
|
|
|
BOARD* m_brd;
|
|
|
|
std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
|
|
|
|
std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
|
2013-08-30 19:28:31 +00:00
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD* aBrd,
|
|
|
|
PCB_LAYER_ID aDefaultLayer,
|
|
|
|
LSET aNotAllowedLayersMask ) :
|
|
|
|
PCB_LAYER_SELECTOR( aParent ),
|
|
|
|
DIALOG_LAYER_SELECTION_BASE( aParent )
|
2013-09-25 19:09:57 +00:00
|
|
|
{
|
2021-01-07 00:45:32 +00:00
|
|
|
m_useCalculatedSize = true;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layerSelected = aDefaultLayer;
|
2013-09-25 19:09:57 +00:00
|
|
|
m_notAllowedLayersMask = aNotAllowedLayersMask;
|
2017-08-04 12:43:02 +00:00
|
|
|
m_brd = aBrd;
|
2018-06-30 20:22:01 +00:00
|
|
|
|
|
|
|
m_leftGridLayers->SetCellHighlightPenWidth( 0 );
|
|
|
|
m_rightGridLayers->SetCellHighlightPenWidth( 0 );
|
|
|
|
m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
|
|
|
|
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
|
2014-06-24 16:17:18 +00:00
|
|
|
buildList();
|
2018-06-30 20:22:01 +00:00
|
|
|
|
2021-02-17 19:47:28 +00:00
|
|
|
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
|
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
Layout();
|
2014-06-24 16:17:18 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2013-09-25 19:09:57 +00:00
|
|
|
SetFocus();
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-02-17 19:47:28 +00:00
|
|
|
PCB_ONE_LAYER_SELECTOR::~PCB_ONE_LAYER_SELECTOR()
|
|
|
|
{
|
|
|
|
Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetKeyCode() == WXK_ESCAPE )
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::buildList()
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2020-05-05 15:40:18 +00:00
|
|
|
wxColour bg = getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
|
2018-06-30 20:22:01 +00:00
|
|
|
int left_row = 0;
|
|
|
|
int right_row = 0;
|
|
|
|
wxString layername;
|
2013-08-30 19:28:31 +00:00
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layerid = *ui_seq;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_notAllowedLayersMask[layerid] )
|
2013-08-30 19:28:31 +00:00
|
|
|
continue;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
wxColour fg = getLayerColor( layerid ).ToColour();
|
2018-06-30 20:22:01 +00:00
|
|
|
wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
|
|
|
|
wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
|
|
|
|
wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
|
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
layername = wxT( " " ) + getLayerName( layerid );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( layerid ) )
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
|
|
|
if( left_row )
|
|
|
|
m_leftGridLayers->AppendRows( 1 );
|
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM, color );
|
|
|
|
m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
|
2013-08-30 19:28:31 +00:00
|
|
|
|
|
|
|
if( m_layerSelected == layerid )
|
2018-06-30 20:22:01 +00:00
|
|
|
m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, "1" );
|
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 );
|
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
|
|
|
|
m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
|
2013-08-30 19:28:31 +00:00
|
|
|
|
|
|
|
if( m_layerSelected == layerid )
|
2018-06-30 20:22:01 +00:00
|
|
|
m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, "1" );
|
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 );
|
2019-07-28 10:54:59 +00:00
|
|
|
|
2021-04-29 23:56:40 +00:00
|
|
|
// Now fix min grid column size (it also sets a minimal size)
|
|
|
|
m_leftGridLayers->AutoSizeColumns();
|
|
|
|
m_rightGridLayers->AutoSizeColumns();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +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() ];
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( 1 );
|
|
|
|
else
|
|
|
|
EndDialog( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +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() ];
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( 2 );
|
|
|
|
else
|
|
|
|
EndDialog( 2 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-02-18 11:50:37 +00:00
|
|
|
PCB_LAYER_ID PCB_BASE_FRAME::SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask,
|
2021-02-17 19:47:28 +00:00
|
|
|
wxPoint aDlgPosition )
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(), 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 );
|
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-02-18 11:50:37 +00:00
|
|
|
if( dlg.ShowModal() != wxID_CANCEL )
|
|
|
|
return ToLAYER_ID( dlg.GetLayerSelection() );
|
|
|
|
else
|
|
|
|
return UNDEFINED_LAYER;
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2021-07-21 21:37:49 +00:00
|
|
|
* Display a pair PCB copper layers list in a dialog 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
|
|
|
{
|
2013-08-30 19:28:31 +00:00
|
|
|
public:
|
2017-08-04 12:43:02 +00:00
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* aParent, BOARD* aPcb,
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID aFrontLayer, PCB_LAYER_ID aBackLayer );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void GetLayerPair( PCB_LAYER_ID& aFrontLayer, PCB_LAYER_ID& aBackLayer )
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
|
|
|
aFrontLayer = m_frontLayer;
|
|
|
|
aBackLayer = m_backLayer;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
private:
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnLeftGridCellClick( wxGridEvent& event ) override;
|
|
|
|
void OnRightGridCellClick( wxGridEvent& event ) override;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void buildList();
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
BOARD* m_brd;
|
|
|
|
PCB_LAYER_ID m_frontLayer;
|
|
|
|
PCB_LAYER_ID m_backLayer;
|
|
|
|
int m_leftRowSelected;
|
|
|
|
int m_rightRowSelected;
|
|
|
|
|
|
|
|
std::vector<PCB_LAYER_ID> m_layersId;
|
2013-08-30 19:28:31 +00:00
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2019-06-03 20:06:58 +00:00
|
|
|
int ROUTER_TOOL::SelectCopperLayerPair( const TOOL_EVENT& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-06-03 20:06:58 +00:00
|
|
|
PCB_SCREEN* screen = frame()->GetScreen();
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2019-06-03 20:06:58 +00:00
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( frame(), frame()->GetBoard(), screen->m_Route_Layer_TOP,
|
|
|
|
screen->m_Route_Layer_BOTTOM );
|
2013-08-30 19:28:31 +00:00
|
|
|
|
|
|
|
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 )
|
2019-06-03 20:06:58 +00:00
|
|
|
DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
|
2013-08-30 19:28:31 +00:00
|
|
|
}
|
2019-06-03 20:06:58 +00:00
|
|
|
|
|
|
|
return 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG(
|
2017-08-04 12:43:02 +00:00
|
|
|
PCB_BASE_FRAME* aParent, BOARD * aPcb, PCB_LAYER_ID aFrontLayer, PCB_LAYER_ID aBackLayer) :
|
|
|
|
PCB_LAYER_SELECTOR( aParent ),
|
2013-08-30 19:28:31 +00:00
|
|
|
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;
|
2017-08-04 12:43:02 +00:00
|
|
|
m_brd = aPcb;
|
2018-06-30 20:22:01 +00:00
|
|
|
|
|
|
|
m_leftGridLayers->SetCellHighlightPenWidth( 0 );
|
|
|
|
m_rightGridLayers->SetCellHighlightPenWidth( 0 );
|
|
|
|
m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
|
|
|
|
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
|
2014-06-24 16:17:18 +00:00
|
|
|
buildList();
|
2018-06-30 20:22:01 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
SetFocus();
|
2018-06-30 20:22:01 +00:00
|
|
|
|
2013-08-30 19:28:31 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Center();
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList()
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2020-05-05 15:40:18 +00:00
|
|
|
wxColour bg = getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
|
2018-06-30 20:22:01 +00:00
|
|
|
int row = 0;
|
|
|
|
wxString layername;
|
2013-09-03 19:37:52 +00:00
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
|
2013-08-30 19:28:31 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layerid = *ui_seq;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !IsCopperLayer( layerid ) )
|
2018-06-30 20:22:01 +00:00
|
|
|
continue;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
wxColour fg = getLayerColor( layerid ).ToColour();
|
2018-06-30 20:22:01 +00:00
|
|
|
wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
|
|
|
|
wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
|
|
|
|
wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
layername = wxT( " " ) + 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
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color );
|
2014-06-24 16:17:18 +00:00
|
|
|
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 )
|
|
|
|
{
|
2018-06-30 20:22:01 +00:00
|
|
|
m_leftGridLayers->SetCellValue( row, SELECT_COLNUM, "1" );
|
|
|
|
m_leftGridLayers->SetGridCursor( row, COLOR_COLNUM );
|
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 );
|
2018-06-30 20:22:01 +00:00
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2018-06-30 20:22:01 +00:00
|
|
|
m_rightGridLayers->SetCellValue( row, SELECT_COLNUM, "1" );
|
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++;
|
|
|
|
}
|
2019-07-28 10:54:59 +00:00
|
|
|
|
|
|
|
// Now fix min grid layer name column size (it also sets a minimal size)
|
|
|
|
m_leftGridLayers->AutoSizeColumn( LAYERNAME_COLNUM );
|
|
|
|
m_rightGridLayers->AutoSizeColumn( LAYERNAME_COLNUM );
|
2013-09-20 10:52:33 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
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
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
int row = event.GetRow();
|
|
|
|
PCB_LAYER_ID 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
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
m_leftGridLayers->SetCellValue( m_leftRowSelected, SELECT_COLNUM, wxEmptyString );
|
2013-08-30 19:28:31 +00:00
|
|
|
m_frontLayer = layer;
|
|
|
|
m_leftRowSelected = row;
|
2018-06-30 20:22:01 +00:00
|
|
|
m_leftGridLayers->SetCellValue( m_leftRowSelected, SELECT_COLNUM, "1" );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +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
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
int row = event.GetRow();
|
|
|
|
PCB_LAYER_ID layer = m_layersId[row];
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_backLayer == layer )
|
2013-08-30 19:28:31 +00:00
|
|
|
return;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2018-06-30 20:22:01 +00:00
|
|
|
m_rightGridLayers->SetCellValue( m_rightRowSelected, SELECT_COLNUM, wxEmptyString );
|
2013-08-30 19:28:31 +00:00
|
|
|
m_backLayer = layer;
|
|
|
|
m_rightRowSelected = row;
|
2018-06-30 20:22:01 +00:00
|
|
|
m_rightGridLayers->SetCellValue( m_rightRowSelected, SELECT_COLNUM, "1" );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|