2011-09-23 09:57:12 -04:00
|
|
|
/**
|
|
|
|
* @file sel_layer.cpp
|
2019-07-28 12:54:59 +02:00
|
|
|
* @brief minor dialogs for one layer selection and a layer pair selection.
|
2013-08-30 21:28:31 +02: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
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2013-08-30 21:28:31 +02:00
|
|
|
*
|
2019-07-28 12:54:59 +02: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 21:28:31 +02:00
|
|
|
*
|
2019-07-28 12:54:59 +02: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 21:28:31 +02:00
|
|
|
*
|
2019-07-28 12:54:59 +02: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 09:57:12 -04:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
#include <wx/bitmap.h>
|
2013-08-30 21:28:31 +02:00
|
|
|
|
2023-09-18 06:13:09 +03:00
|
|
|
#include <kiplatform/ui.h>
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <confirm.h>
|
2024-07-08 20:58:47 -07:00
|
|
|
#include <lset.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2024-07-24 13:32:21 +08:00
|
|
|
#include <pgm_base.h>
|
2024-07-24 13:28:46 +08:00
|
|
|
#include <project.h>
|
2024-07-24 13:32:21 +08:00
|
|
|
#include <pcb_base_frame.h>
|
|
|
|
#include <pcb_layer_presentation.h>
|
|
|
|
#include <footprint_editor_settings.h>
|
2024-07-24 13:28:46 +08:00
|
|
|
#include <layer_pairs.h>
|
2013-08-30 21:28:31 +02:00
|
|
|
#include <dialogs/dialog_layer_selection_base.h>
|
2024-07-24 13:28:46 +08:00
|
|
|
#include <project/project_file.h>
|
2019-06-03 21:06:58 +01:00
|
|
|
#include <router/router_tool.h>
|
2024-07-24 13:32:21 +08:00
|
|
|
#include <settings/settings_manager.h>
|
2020-01-12 20:44:19 -05:00
|
|
|
#include <settings/color_settings.h>
|
2023-07-05 08:10:48 +03:00
|
|
|
#include <tools/pcb_actions.h>
|
2024-07-24 13:28:46 +08:00
|
|
|
#include <widgets/grid_icon_text_helpers.h>
|
|
|
|
#include <widgets/grid_text_helpers.h>
|
|
|
|
#include <widgets/layer_box_selector.h>
|
|
|
|
#include <widgets/wx_grid.h>
|
|
|
|
#include <widgets/wx_grid_autosizer.h>
|
2024-12-31 13:07:26 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2024-07-24 13:28:46 +08:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2018-06-30 21:22:01 +01:00
|
|
|
// Column position by function:
|
2024-07-24 13:28:46 +08:00
|
|
|
#define SELECT_COLNUM 0
|
|
|
|
#define COLOR_COLNUM 1
|
|
|
|
#define LAYERNAME_COLNUM 2
|
|
|
|
#define LAYER_HK_COLUMN 3
|
2018-06-30 21:22:01 +01:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2024-07-24 13:32:21 +08:00
|
|
|
PCB_LAYER_PRESENTATION::PCB_LAYER_PRESENTATION( PCB_BASE_FRAME* aFrame ) : m_boardFrame( aFrame )
|
|
|
|
{
|
|
|
|
}
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:32:21 +08:00
|
|
|
COLOR4D PCB_LAYER_PRESENTATION::getLayerColor( int aLayer ) const
|
|
|
|
{
|
|
|
|
if( m_boardFrame )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:32:21 +08:00
|
|
|
return m_boardFrame->GetColorSettings()->GetColor( aLayer );
|
2013-08-30 21:28:31 +02:00
|
|
|
}
|
2024-07-24 13:32:21 +08:00
|
|
|
else
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2025-06-14 19:35:35 +01:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" );
|
|
|
|
COLOR_SETTINGS* current = ::GetColorSettings( cfg ? cfg->m_ColorTheme : DEFAULT_THEME );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2024-07-24 13:32:21 +08:00
|
|
|
return current->GetColor( aLayer );
|
2013-08-30 21:28:31 +02:00
|
|
|
}
|
2024-07-24 13:32:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString PCB_LAYER_PRESENTATION::getLayerName( int aLayer ) const
|
|
|
|
{
|
|
|
|
if( m_boardFrame )
|
|
|
|
return m_boardFrame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
|
|
|
|
else
|
|
|
|
return BOARD::GetStandardLayerName( ToLAYER_ID( aLayer ) );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
LSEQ PCB_LAYER_PRESENTATION::getOrderedEnabledLayers() const
|
|
|
|
{
|
|
|
|
return m_boardFrame->GetBoard()->GetEnabledLayers().UIOrder();
|
|
|
|
}
|
|
|
|
|
2024-07-31 19:31:07 +08:00
|
|
|
wxString PCB_LAYER_PRESENTATION::getLayerPairName( const LAYER_PAIR& aPair ) const
|
|
|
|
{
|
|
|
|
const wxString layerAName = getLayerName( aPair.GetLayerA() );
|
|
|
|
const wxString layerBName = getLayerName( aPair.GetLayerB() );
|
|
|
|
|
|
|
|
return layerAName + wxT( " / " ) + layerBName;
|
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
/**
|
|
|
|
* Display a PCB layers list in a dialog to select one layer from this list.
|
2007-10-07 03:08:24 +00:00
|
|
|
*/
|
2024-07-24 13:32:21 +08:00
|
|
|
class PCB_ONE_LAYER_SELECTOR : public DIALOG_LAYER_SELECTION_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-30 21:28:31 +02:00
|
|
|
public:
|
2024-07-24 13:28:46 +08:00
|
|
|
PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, PCB_LAYER_ID aDefaultLayer,
|
2021-09-22 15:48:54 -07:00
|
|
|
LSET aNotAllowedLayersMask, bool aHideCheckBoxes = false );
|
2021-02-17 20:47:28 +01:00
|
|
|
~PCB_ONE_LAYER_SELECTOR();
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
int GetLayerSelection() { return m_layerSelected; }
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2013-08-30 21:28:31 +02:00
|
|
|
private:
|
|
|
|
// Event handlers
|
2021-09-22 15:48:54 -07:00
|
|
|
void OnLeftGridCellClick( wxGridEvent& aEvent ) override;
|
|
|
|
void OnRightGridCellClick( wxGridEvent& aEvent ) override;
|
|
|
|
void OnMouseMove( wxUpdateUIEvent& aEvent ) override;
|
2011-03-14 15:17:42 -04:00
|
|
|
|
2021-02-17 20:47:28 +01:00
|
|
|
// Will close the dialog on ESC key
|
|
|
|
void onCharHook( wxKeyEvent& event );
|
|
|
|
|
2023-07-05 08:10:48 +03:00
|
|
|
wxString getLayerHotKey( PCB_LAYER_ID aLayer ) const
|
|
|
|
{
|
|
|
|
int code = PCB_ACTIONS::LayerIDToAction( aLayer )->GetHotKey();
|
|
|
|
return AddHotkeyName( wxS( "" ), code, IS_COMMENT );
|
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
void buildList();
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2024-07-24 13:32:21 +08:00
|
|
|
PCB_LAYER_PRESENTATION m_layerPresentation;
|
2021-07-21 17:37:49 -04:00
|
|
|
PCB_LAYER_ID m_layerSelected;
|
|
|
|
LSET m_notAllowedLayersMask;
|
|
|
|
std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
|
|
|
|
std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
|
2013-08-30 21:28:31 +02:00
|
|
|
};
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, PCB_LAYER_ID aDefaultLayer,
|
2024-07-24 13:32:21 +08:00
|
|
|
LSET aNotAllowedLayersMask, bool aHideCheckBoxes ) :
|
|
|
|
DIALOG_LAYER_SELECTION_BASE( aParent ), m_layerPresentation( aParent )
|
2013-09-25 21:09:57 +02:00
|
|
|
{
|
2021-01-07 00:45:32 +00:00
|
|
|
m_useCalculatedSize = true;
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
m_layerSelected = aDefaultLayer;
|
2013-09-25 21:09:57 +02:00
|
|
|
m_notAllowedLayersMask = aNotAllowedLayersMask;
|
2018-06-30 21:22:01 +01:00
|
|
|
|
|
|
|
m_leftGridLayers->SetCellHighlightPenWidth( 0 );
|
|
|
|
m_rightGridLayers->SetCellHighlightPenWidth( 0 );
|
|
|
|
m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
|
|
|
|
m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
|
2023-07-05 08:10:48 +03:00
|
|
|
|
|
|
|
m_leftGridLayers->AppendCols( 1 );
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
buildList();
|
2018-06-30 21:22:01 +01:00
|
|
|
|
2021-09-22 15:48:54 -07:00
|
|
|
if( aHideCheckBoxes )
|
|
|
|
{
|
|
|
|
m_leftGridLayers->HideCol( SELECT_COLNUM );
|
|
|
|
m_rightGridLayers->HideCol( SELECT_COLNUM );
|
|
|
|
}
|
|
|
|
|
2021-02-17 20:47:28 +01:00
|
|
|
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
|
|
|
|
|
2013-09-25 21:09:57 +02:00
|
|
|
Layout();
|
2014-06-24 11:17:18 -05:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2013-09-25 21:09:57 +02:00
|
|
|
SetFocus();
|
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2021-02-17 20:47:28 +01:00
|
|
|
PCB_ONE_LAYER_SELECTOR::~PCB_ONE_LAYER_SELECTOR()
|
|
|
|
{
|
|
|
|
Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-22 15:48:54 -07:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::OnMouseMove( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
/// We have to assign this in UpdateUI events because the wxGrid is not properly receiving
|
|
|
|
/// MouseMove events. It seems to only get them on the edges. So, for now we use this
|
|
|
|
/// workaround
|
|
|
|
|
2023-09-18 06:13:09 +03:00
|
|
|
wxPoint mouse_pos = KIPLATFORM::UI::GetMousePosition();
|
2021-09-22 15:48:54 -07:00
|
|
|
wxPoint left_pos = m_leftGridLayers->ScreenToClient( mouse_pos );
|
|
|
|
wxPoint right_pos = m_rightGridLayers->ScreenToClient( mouse_pos );
|
|
|
|
|
|
|
|
if( m_leftGridLayers->HitTest( left_pos ) == wxHT_WINDOW_INSIDE )
|
|
|
|
{
|
|
|
|
int row = m_leftGridLayers->YToRow( left_pos.y );
|
|
|
|
|
|
|
|
if( row != wxNOT_FOUND && row < static_cast<int>( m_layersIdLeftColumn.size() ) )
|
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
m_layerSelected = m_layersIdLeftColumn[row];
|
2023-07-05 08:10:48 +03:00
|
|
|
m_leftGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYER_HK_COLUMN );
|
2021-09-22 15:48:54 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_rightGridLayers->HitTest( right_pos ) == wxHT_WINDOW_INSIDE )
|
|
|
|
{
|
|
|
|
int row = m_rightGridLayers->YToRow( right_pos.y );
|
|
|
|
|
|
|
|
if( row == wxNOT_FOUND || row >= static_cast<int>( m_layersIdRightColumn.size() ) )
|
|
|
|
return;
|
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_layerSelected = m_layersIdRightColumn[row];
|
|
|
|
m_rightGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYERNAME_COLNUM );
|
2021-09-22 15:48:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-17 20:47:28 +01:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetKeyCode() == WXK_ESCAPE )
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::buildList()
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:32:21 +08:00
|
|
|
wxColour bg = m_layerPresentation.getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
|
2018-06-30 21:22:01 +01:00
|
|
|
int left_row = 0;
|
|
|
|
int right_row = 0;
|
|
|
|
wxString layername;
|
2013-08-30 21:28:31 +02:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
for( PCB_LAYER_ID layerid : m_layerPresentation.getOrderedEnabledLayers() )
|
2014-06-24 11:17:18 -05:00
|
|
|
{
|
|
|
|
if( m_notAllowedLayersMask[layerid] )
|
2013-08-30 21:28:31 +02:00
|
|
|
continue;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2024-07-24 13:32:21 +08:00
|
|
|
wxColour fg = m_layerPresentation.getLayerColor( layerid ).ToColour();
|
2018-06-30 21:22:01 +01: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 ) );
|
|
|
|
|
2024-07-24 13:32:21 +08:00
|
|
|
layername = wxT( " " ) + m_layerPresentation.getLayerName( layerid );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
if( IsCopperLayer( layerid ) )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
|
|
|
if( left_row )
|
|
|
|
m_leftGridLayers->AppendRows( 1 );
|
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_leftGridLayers->SetCellBackgroundColour( left_row, COLOR_COLNUM, color );
|
2018-06-30 21:22:01 +01:00
|
|
|
m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
|
2023-07-05 08:10:48 +03:00
|
|
|
m_leftGridLayers->SetCellValue( left_row, LAYER_HK_COLUMN, getLayerHotKey( layerid ) );
|
2013-08-30 21:28:31 +02:00
|
|
|
|
|
|
|
if( m_layerSelected == layerid )
|
2022-02-04 22:44:59 +00:00
|
|
|
m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, wxT( "1" ) );
|
2013-08-30 21:28:31 +02:00
|
|
|
|
2013-09-03 21:37:52 +02:00
|
|
|
m_layersIdLeftColumn.push_back( layerid );
|
2013-08-30 21:28:31 +02:00
|
|
|
left_row++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( right_row )
|
|
|
|
m_rightGridLayers->AppendRows( 1 );
|
|
|
|
|
2018-06-30 21:22:01 +01:00
|
|
|
m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
|
|
|
|
m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
|
2013-08-30 21:28:31 +02:00
|
|
|
|
|
|
|
if( m_layerSelected == layerid )
|
2022-02-04 22:44:59 +00:00
|
|
|
m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, wxT( "1" ) );
|
2013-08-30 21:28:31 +02:00
|
|
|
|
2013-09-03 21:37:52 +02:00
|
|
|
m_layersIdRightColumn.push_back( layerid );
|
2013-08-30 21:28:31 +02:00
|
|
|
right_row++;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-30 21:28:31 +02:00
|
|
|
// Show only populated lists:
|
|
|
|
if( left_row <= 0 )
|
|
|
|
m_leftGridLayers->Show( false );
|
2011-09-19 18:29:46 +02:00
|
|
|
|
2013-08-30 21:28:31 +02:00
|
|
|
if( right_row <= 0 )
|
|
|
|
m_rightGridLayers->Show( false );
|
2019-07-28 12:54:59 +02:00
|
|
|
|
2021-04-29 19:56:40 -04: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 11:17:18 -05:00
|
|
|
|
2013-09-11 17:30:21 +02:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
m_layerSelected = m_layersIdLeftColumn[event.GetRow()];
|
2021-07-21 17:37:49 -04:00
|
|
|
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( 1 );
|
|
|
|
else
|
|
|
|
EndDialog( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2013-09-11 17:30:21 +02:00
|
|
|
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
m_layerSelected = m_layersIdRightColumn[event.GetRow()];
|
2021-07-21 17:37:49 -04:00
|
|
|
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( 2 );
|
|
|
|
else
|
|
|
|
EndDialog( 2 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2025-03-23 20:33:22 +00:00
|
|
|
PCB_LAYER_ID PCB_BASE_FRAME::SelectOneLayer( PCB_LAYER_ID aDefaultLayer,
|
|
|
|
const LSET& aNotAllowedLayersMask,
|
2021-02-17 20:47:28 +01:00
|
|
|
wxPoint aDlgPosition )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
PCB_ONE_LAYER_SELECTOR dlg( this, aDefaultLayer, aNotAllowedLayersMask, true );
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2013-09-25 21:09:57 +02:00
|
|
|
if( aDlgPosition != wxDefaultPosition )
|
|
|
|
{
|
|
|
|
wxSize dlgSize = dlg.GetSize();
|
2024-07-24 13:28:46 +08:00
|
|
|
aDlgPosition.x -= dlgSize.x / 2;
|
|
|
|
aDlgPosition.y -= dlgSize.y / 2;
|
2013-09-25 21:09:57 +02:00
|
|
|
dlg.SetPosition( aDlgPosition );
|
|
|
|
}
|
2014-06-24 11:17:18 -05: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 21:28:31 +02:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
/**
|
2024-07-24 13:28:46 +08:00
|
|
|
* Class that manages the UI for the copper layer pair presets list
|
|
|
|
* based on an injected layer pair store.
|
2013-08-30 21:28:31 +02:00
|
|
|
*/
|
2024-07-24 13:28:46 +08:00
|
|
|
class COPPER_LAYERS_PAIR_PRESETS_UI
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
enum class COLNUMS
|
|
|
|
{
|
|
|
|
ENABLED,
|
|
|
|
SWATCH,
|
|
|
|
LAYERNAMES,
|
|
|
|
USERNAME,
|
|
|
|
};
|
|
|
|
|
2013-08-30 21:28:31 +02:00
|
|
|
public:
|
2024-07-24 13:28:46 +08:00
|
|
|
COPPER_LAYERS_PAIR_PRESETS_UI( WX_GRID& aGrid, PCB_LAYER_PRESENTATION& aPresentation,
|
|
|
|
LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
|
|
|
|
m_layerPresentation( aPresentation ), m_grid( aGrid ),
|
|
|
|
m_layerPairSettings( aLayerPairSettings )
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_grid.GetNumberRows() == 0, "Grid should be empty at controller start" );
|
|
|
|
|
|
|
|
configureGrid();
|
|
|
|
fillGridFromStore();
|
|
|
|
|
|
|
|
m_grid.Bind( wxEVT_GRID_CELL_CHANGED,
|
|
|
|
[this]( wxGridEvent& aEvent )
|
|
|
|
{
|
|
|
|
const int col = aEvent.GetCol();
|
|
|
|
const int row = aEvent.GetRow();
|
|
|
|
if( col == (int) COLNUMS::USERNAME )
|
|
|
|
{
|
|
|
|
onUserNameChanged( row, m_grid.GetCellValue( row, col ) );
|
|
|
|
}
|
|
|
|
else if( col == (int) COLNUMS::ENABLED )
|
|
|
|
{
|
|
|
|
onEnableChanged( row, m_grid.GetCellValue( row, col ) == wxS( "1" ) );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_grid.Bind( wxEVT_GRID_CELL_LEFT_DCLICK,
|
|
|
|
[&]( wxGridEvent& aEvent )
|
|
|
|
{
|
|
|
|
const int row = aEvent.GetRow();
|
|
|
|
const int col = aEvent.GetCol();
|
|
|
|
|
|
|
|
if( col == (int) COLNUMS::LAYERNAMES || col == (int) COLNUMS::SWATCH )
|
|
|
|
{
|
|
|
|
onPairActivated( row );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_autosizer =
|
|
|
|
std::make_unique<WX_GRID_AUTOSIZER>( m_grid,
|
|
|
|
WX_GRID_AUTOSIZER::COL_MIN_WIDTHS{
|
|
|
|
{ (int) COLNUMS::LAYERNAMES, 72 },
|
|
|
|
{ (int) COLNUMS::USERNAME, 72 },
|
|
|
|
},
|
|
|
|
(int) COLNUMS::USERNAME );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void OnLayerPairAdded( const LAYER_PAIR& aLayerPair )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
LAYER_PAIR_INFO layerPairInfo{ aLayerPair, true, std::nullopt };
|
|
|
|
|
2024-08-23 09:54:29 +02:00
|
|
|
const bool added = m_layerPairSettings.AddLayerPair( layerPairInfo );
|
2024-07-24 13:28:46 +08:00
|
|
|
|
|
|
|
if( added )
|
|
|
|
{
|
|
|
|
m_grid.AppendRows( 1 );
|
|
|
|
fillRowFromLayerPair( m_grid.GetNumberRows() - 1, layerPairInfo );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnDeleteSelectedLayerPairs()
|
|
|
|
{
|
2025-07-24 17:55:00 +01:00
|
|
|
m_grid.OnDeleteRows(
|
|
|
|
[&]( int row )
|
|
|
|
{
|
|
|
|
const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[row];
|
|
|
|
|
|
|
|
if( m_layerPairSettings.RemoveLayerPair( layerPairInfo.GetLayerPair() ) )
|
|
|
|
m_grid.DeleteRows( row );
|
|
|
|
} );
|
2013-08-30 21:28:31 +02:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
private:
|
2024-07-24 13:28:46 +08:00
|
|
|
void configureGrid()
|
|
|
|
{
|
|
|
|
m_grid.UseNativeColHeader( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_grid.SetCellHighlightPenWidth( 0 );
|
|
|
|
m_grid.SetColFormatBool( (int) COLNUMS::ENABLED );
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_grid.SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_grid.AutoSizeColumn( (int) COLNUMS::USERNAME );
|
|
|
|
}
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void fillGridFromStore()
|
|
|
|
{
|
|
|
|
std::span<const LAYER_PAIR_INFO> storePairs = m_layerPairSettings.GetLayerPairs();
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_grid.AppendRows( storePairs.size() );
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
int row = 0;
|
|
|
|
for( const LAYER_PAIR_INFO& layerPairInfo : storePairs )
|
|
|
|
{
|
|
|
|
fillRowFromLayerPair( row, layerPairInfo );
|
|
|
|
row++;
|
|
|
|
}
|
|
|
|
}
|
2013-08-30 21:28:31 +02:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void fillRowFromLayerPair( int aRow, const LAYER_PAIR_INFO& aLayerPairInfo )
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( aRow < m_grid.GetNumberRows(), "Row index out of bounds" );
|
|
|
|
|
|
|
|
const LAYER_PAIR& layerPair = aLayerPairInfo.GetLayerPair();
|
|
|
|
|
2024-07-31 19:31:07 +08:00
|
|
|
const wxString layerNames = m_layerPresentation.getLayerPairName( layerPair );
|
2024-07-24 13:28:46 +08:00
|
|
|
|
|
|
|
m_grid.SetCellValue( aRow, (int) COLNUMS::LAYERNAMES, layerNames );
|
|
|
|
|
|
|
|
const std::optional<wxString> userName = aLayerPairInfo.GetName();
|
|
|
|
if( userName )
|
|
|
|
{
|
|
|
|
m_grid.SetCellValue( aRow, (int) COLNUMS::USERNAME, *userName );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_grid.SetCellValue( aRow, (int) COLNUMS::ENABLED,
|
|
|
|
aLayerPairInfo.IsEnabled() ? wxT( "1" ) : wxT( "0" ) );
|
|
|
|
|
|
|
|
// Set the color swatch
|
2024-08-07 05:42:18 +08:00
|
|
|
std::unique_ptr<wxBitmap>& swatch =
|
|
|
|
m_swatches.emplace_back( m_layerPresentation.CreateLayerPairIcon(
|
|
|
|
layerPair.GetLayerA(), layerPair.GetLayerB(), KiIconScale( &m_grid ) ) );
|
2024-07-24 13:28:46 +08:00
|
|
|
|
|
|
|
m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH,
|
|
|
|
new GRID_CELL_ICON_RENDERER( *swatch ) );
|
|
|
|
|
|
|
|
m_grid.SetReadOnly( aRow, (int) COLNUMS::SWATCH );
|
|
|
|
m_grid.SetReadOnly( aRow, (int) COLNUMS::LAYERNAMES );
|
2013-08-30 21:28:31 +02:00
|
|
|
}
|
2019-06-03 21:06:58 +01:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void onUserNameChanged( int aRow, const wxString& aNewValue )
|
|
|
|
{
|
|
|
|
LAYER_PAIR_INFO& changedPair = m_layerPairSettings.GetLayerPairs()[aRow];
|
|
|
|
changedPair.SetName( aNewValue );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void onEnableChanged( int aRow, bool aNewValue )
|
|
|
|
{
|
|
|
|
LAYER_PAIR_INFO& changedPair = m_layerPairSettings.GetLayerPairs()[aRow];
|
|
|
|
changedPair.SetEnabled( aNewValue );
|
|
|
|
}
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void onPairActivated( int aRow )
|
|
|
|
{
|
|
|
|
const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[aRow];
|
|
|
|
const LAYER_PAIR& layerPair = layerPairInfo.GetLayerPair();
|
2018-06-30 21:22:01 +01:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_layerPairSettings.SetCurrentLayerPair( layerPair );
|
|
|
|
}
|
2018-06-30 21:22:01 +01:00
|
|
|
|
2024-07-31 19:31:07 +08:00
|
|
|
PCB_LAYER_PRESENTATION& m_layerPresentation;
|
|
|
|
WX_GRID& m_grid;
|
|
|
|
LAYER_PAIR_SETTINGS& m_layerPairSettings;
|
2018-06-30 21:22:01 +01:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
// Lifetime managment of the swatches
|
|
|
|
std::vector<std::unique_ptr<wxBitmap>> m_swatches;
|
|
|
|
|
|
|
|
std::unique_ptr<WX_GRID_AUTOSIZER> m_autosizer;
|
|
|
|
};
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
/**
|
|
|
|
* Class that manages the UI for the copper layer pair selection
|
|
|
|
* (left and right grids).
|
|
|
|
*/
|
|
|
|
class COPPER_LAYERS_PAIR_SELECTION_UI
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
enum class CU_LAYER_COLNUMS
|
|
|
|
{
|
|
|
|
SELECT = 0,
|
|
|
|
COLOR = 1,
|
|
|
|
LAYERNAME = 2,
|
|
|
|
};
|
2013-09-03 21:37:52 +02:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
public:
|
|
|
|
COPPER_LAYERS_PAIR_SELECTION_UI( wxGrid& aLeftGrid, wxGrid& aRightGrid,
|
|
|
|
PCB_LAYER_PRESENTATION& aPresentation,
|
|
|
|
LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
|
|
|
|
m_layerPresentation( aPresentation ), m_layerPairSettings( aLayerPairSettings ),
|
|
|
|
m_leftGrid( aLeftGrid ), m_rightGrid( aRightGrid )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
configureGrid( m_leftGrid );
|
|
|
|
configureGrid( m_rightGrid );
|
2011-03-14 11:17:18 -04:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
for( const PCB_LAYER_ID& layerId : m_layerPresentation.getOrderedEnabledLayers() )
|
|
|
|
{
|
|
|
|
if( IsCopperLayer( layerId ) )
|
|
|
|
m_layersId.push_back( layerId );
|
|
|
|
}
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
fillLayerGrid( m_leftGrid );
|
|
|
|
fillLayerGrid( m_rightGrid );
|
|
|
|
|
|
|
|
m_leftGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
|
|
|
|
[this]( wxGridEvent& aEvent )
|
|
|
|
{
|
|
|
|
onLeftGridRowSelected( aEvent.GetRow() );
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_rightGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
|
|
|
|
[this]( wxGridEvent& aEvent )
|
|
|
|
{
|
|
|
|
onRightGridRowSelected( aEvent.GetRow() );
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_layerPairSettings.Bind( PCB_CURRENT_LAYER_PAIR_CHANGED,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
2025-07-27 20:54:36 +01:00
|
|
|
const LAYER_PAIR& newPair = m_layerPairSettings.GetCurrentLayerPair();
|
2024-07-24 13:28:46 +08:00
|
|
|
setCurrentSelection( rowForLayer( newPair.GetLayerA() ),
|
|
|
|
rowForLayer( newPair.GetLayerB() ) );
|
|
|
|
} );
|
|
|
|
}
|
2011-03-14 11:17:18 -04:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
private:
|
|
|
|
void configureGrid( wxGrid& aGrid )
|
|
|
|
{
|
|
|
|
aGrid.SetCellHighlightPenWidth( 0 );
|
|
|
|
aGrid.SetColFormatBool( (int) CU_LAYER_COLNUMS::SELECT );
|
|
|
|
}
|
2013-09-03 21:37:52 +02:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void fillLayerGrid( wxGrid& aGrid )
|
|
|
|
{
|
|
|
|
const wxColour bg = m_layerPresentation.getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
|
2011-03-14 11:17:18 -04:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
aGrid.AppendRows( m_layersId.size() - 1 );
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
for( const PCB_LAYER_ID& layerId : m_layersId )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
const wxColour fg = m_layerPresentation.getLayerColor( layerId ).ToColour();
|
2025-07-27 20:54:36 +01:00
|
|
|
const 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 ) );
|
2024-07-24 13:28:46 +08:00
|
|
|
|
|
|
|
const wxString layerName = wxT( " " ) + m_layerPresentation.getLayerName( layerId );
|
|
|
|
|
|
|
|
aGrid.SetCellBackgroundColour( row, (int) CU_LAYER_COLNUMS::COLOR, color );
|
|
|
|
aGrid.SetCellValue( row, (int) CU_LAYER_COLNUMS::LAYERNAME, layerName );
|
|
|
|
|
|
|
|
row++;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Now fix min grid layer name column size (it also sets a minimal size)
|
|
|
|
aGrid.AutoSizeColumn( (int) CU_LAYER_COLNUMS::LAYERNAME );
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_LAYER_ID layerForRow( int aRow ) { return m_layersId.at( aRow ); }
|
|
|
|
|
|
|
|
int rowForLayer( PCB_LAYER_ID aLayerId )
|
|
|
|
{
|
|
|
|
for( unsigned i = 0; i < m_layersId.size(); ++i )
|
|
|
|
{
|
|
|
|
if( m_layersId[i] == aLayerId )
|
|
|
|
return i;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
wxASSERT_MSG( false, wxString::Format( "Unknown layer in grid: %d", aLayerId ) );
|
|
|
|
return 0;
|
|
|
|
}
|
2018-06-30 21:22:01 +01:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
void onLeftGridRowSelected( int aRow )
|
|
|
|
{
|
|
|
|
LAYER_PAIR newPair{
|
|
|
|
layerForRow( aRow ),
|
|
|
|
layerForRow( m_rightCurrRow ),
|
|
|
|
};
|
|
|
|
setCurrentSelection( aRow, m_rightCurrRow );
|
|
|
|
m_layerPairSettings.SetCurrentLayerPair( newPair );
|
|
|
|
}
|
|
|
|
|
|
|
|
void onRightGridRowSelected( int aRow )
|
|
|
|
{
|
|
|
|
LAYER_PAIR newPair{
|
|
|
|
layerForRow( m_leftCurrRow ),
|
|
|
|
layerForRow( aRow ),
|
|
|
|
};
|
|
|
|
setCurrentSelection( m_leftCurrRow, aRow );
|
|
|
|
m_layerPairSettings.SetCurrentLayerPair( newPair );
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
/**
|
|
|
|
* Set the current layer selection.
|
|
|
|
*
|
|
|
|
* The layer pair must be copper layers that the selector this class
|
|
|
|
* was constructed with knows about.
|
|
|
|
*/
|
|
|
|
void setCurrentSelection( int aLeftRow, int aRightRow )
|
|
|
|
{
|
2024-08-07 00:51:17 +03:00
|
|
|
const auto selectGridRow = []( wxGrid& aGrid, int aRow, bool aSelect )
|
2024-07-24 13:28:46 +08:00
|
|
|
{
|
|
|
|
// At start, there is no old row
|
|
|
|
if( aRow < 0 )
|
|
|
|
return;
|
2025-07-27 20:54:36 +01:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
const wxString val = aSelect ? wxT( "1" ) : wxEmptyString;
|
|
|
|
aGrid.SetCellValue( aRow, (int) CU_LAYER_COLNUMS::SELECT, val );
|
|
|
|
aGrid.SetGridCursor( aRow, (int) CU_LAYER_COLNUMS::COLOR );
|
|
|
|
};
|
|
|
|
|
|
|
|
if( m_leftCurrRow != aLeftRow )
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
selectGridRow( m_leftGrid, m_leftCurrRow, false );
|
|
|
|
selectGridRow( m_leftGrid, aLeftRow, true );
|
|
|
|
m_leftCurrRow = aLeftRow;
|
2013-08-30 21:28:31 +02:00
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
if( m_rightCurrRow != aRightRow )
|
|
|
|
{
|
|
|
|
selectGridRow( m_rightGrid, m_rightCurrRow, false );
|
|
|
|
selectGridRow( m_rightGrid, aRightRow, true );
|
|
|
|
m_rightCurrRow = aRightRow;
|
|
|
|
}
|
2013-08-30 21:28:31 +02:00
|
|
|
}
|
2019-07-28 12:54:59 +02:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
PCB_LAYER_PRESENTATION& m_layerPresentation;
|
|
|
|
LAYER_PAIR_SETTINGS& m_layerPairSettings;
|
|
|
|
std::vector<PCB_LAYER_ID> m_layersId;
|
|
|
|
wxGrid& m_leftGrid;
|
|
|
|
wxGrid& m_rightGrid;
|
|
|
|
|
|
|
|
int m_leftCurrRow = -1;
|
|
|
|
int m_rightCurrRow = -1;
|
|
|
|
};
|
2013-09-20 12:52:33 +02:00
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
/**
|
|
|
|
* Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
|
|
|
|
*
|
|
|
|
* This is a higher level class that mostly glues together other controller classes and UI
|
|
|
|
* elements.
|
|
|
|
*/
|
|
|
|
class SELECT_COPPER_LAYERS_PAIR_DIALOG : public DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE
|
2013-08-30 21:28:31 +02:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
public:
|
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME& aParent,
|
|
|
|
LAYER_PAIR_SETTINGS& aBoardSettings ) :
|
|
|
|
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( &aParent ),
|
|
|
|
m_boardPairSettings( aBoardSettings ), m_dialogPairSettings( aBoardSettings ),
|
|
|
|
m_layerPresentation( &aParent ),
|
|
|
|
m_pairSelectionController( *m_leftGridLayers, *m_rightGridLayers, m_layerPresentation,
|
|
|
|
m_dialogPairSettings ),
|
|
|
|
m_presetsGridController( *m_presetsGrid, m_layerPresentation, m_dialogPairSettings )
|
|
|
|
{
|
|
|
|
m_addToPresetsButton->SetBitmap( KiBitmapBundle( BITMAPS::right ) );
|
2024-12-31 13:07:26 +00:00
|
|
|
m_deleteRowButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
2024-07-24 13:28:46 +08:00
|
|
|
|
|
|
|
m_addToPresetsButton->Bind( wxEVT_BUTTON,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
2025-07-27 20:54:36 +01:00
|
|
|
const LAYER_PAIR newPair = m_dialogPairSettings.GetCurrentLayerPair();
|
2024-07-24 13:28:46 +08:00
|
|
|
m_presetsGridController.OnLayerPairAdded( newPair );
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_deleteRowButton->Bind( wxEVT_BUTTON,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_presetsGridController.OnDeleteSelectedLayerPairs();
|
|
|
|
} );
|
|
|
|
|
|
|
|
SetFocus();
|
|
|
|
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Center();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TransferDataToWindow() override
|
|
|
|
{
|
|
|
|
m_presetsGrid->Freeze();
|
|
|
|
m_leftGridLayers->Freeze();
|
|
|
|
m_rightGridLayers->Freeze();
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_dialogPairSettings.SetCurrentLayerPair( m_boardPairSettings.GetCurrentLayerPair() );
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
m_rightGridLayers->Thaw();
|
|
|
|
m_leftGridLayers->Thaw();
|
|
|
|
m_presetsGrid->Thaw();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TransferDataFromWindow() override
|
|
|
|
{
|
|
|
|
// Pull out the dialog's stored pairs
|
|
|
|
std::span<const LAYER_PAIR_INFO> storePairs = m_dialogPairSettings.GetLayerPairs();
|
|
|
|
|
|
|
|
m_boardPairSettings.SetLayerPairs( storePairs );
|
|
|
|
m_boardPairSettings.SetCurrentLayerPair( m_dialogPairSettings.GetCurrentLayerPair() );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// The BOARD's pair store to be updated
|
|
|
|
LAYER_PAIR_SETTINGS& m_boardPairSettings;
|
|
|
|
// A local copy while we modify it
|
|
|
|
LAYER_PAIR_SETTINGS m_dialogPairSettings;
|
|
|
|
// Information about the layer presentation (colors, etc)
|
|
|
|
PCB_LAYER_PRESENTATION m_layerPresentation;
|
|
|
|
// UI controllers
|
|
|
|
COPPER_LAYERS_PAIR_SELECTION_UI m_pairSelectionController;
|
|
|
|
COPPER_LAYERS_PAIR_PRESETS_UI m_presetsGridController;
|
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
int ROUTER_TOOL::SelectCopperLayerPair( const TOOL_EVENT& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2024-07-24 13:28:46 +08:00
|
|
|
LAYER_PAIR_SETTINGS* const boardSettings = frame()->GetLayerPairSettings();
|
|
|
|
|
|
|
|
if( !boardSettings )
|
|
|
|
{
|
|
|
|
// Should only be used for suitable frame types with layer pairs
|
|
|
|
wxASSERT_MSG( false, "Could not access layer pair settings" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( *frame(), *boardSettings );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
const LAYER_PAIR layerPair = boardSettings->GetCurrentLayerPair();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2024-07-24 13:28:46 +08: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( layerPair.GetLayerA() == layerPair.GetLayerB() )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
|
|
|
|
}
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2024-07-24 13:28:46 +08:00
|
|
|
return 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|