2018-07-17 06:52:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-03-13 16:03:48 +00:00
|
|
|
* Copyright (C) 2018-2023 KiCad Developers, see change_log.txt for contributors.
|
2018-07-17 06:52:33 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <board_design_settings.h>
|
2018-08-27 19:38:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-07-17 06:52:33 +00:00
|
|
|
#include <widgets/wx_grid.h>
|
2022-12-13 20:47:28 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2021-06-03 15:41:26 +00:00
|
|
|
#include <wx/treebook.h>
|
2019-03-04 11:02:12 +00:00
|
|
|
#include <grid_tricks.h>
|
2018-07-17 06:52:33 +00:00
|
|
|
|
|
|
|
#include <panel_setup_tracks_and_vias.h>
|
|
|
|
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
enum TRACK_VAR_GRID_COLUMNS
|
|
|
|
{
|
|
|
|
TR_WIDTH_COL = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
enum VIA_VAR_GRID_COLUMNS
|
|
|
|
{
|
|
|
|
VIA_SIZE_COL = 0,
|
|
|
|
VIA_DRILL_COL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DIFF_VAR_GRID_COLUMNS
|
|
|
|
{
|
|
|
|
DP_WIDTH_COL = 0,
|
|
|
|
DP_GAP_COL,
|
|
|
|
DP_VIA_GAP_COL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS( PAGED_DIALOG* aParent,
|
2022-08-18 16:56:36 +00:00
|
|
|
PCB_EDIT_FRAME* aFrame ) :
|
2018-07-17 06:52:33 +00:00
|
|
|
PANEL_SETUP_TRACKS_AND_VIAS_BASE( aParent->GetTreebook() )
|
|
|
|
{
|
|
|
|
m_Parent = aParent;
|
|
|
|
m_Frame = aFrame;
|
|
|
|
m_Pcb = m_Frame->GetBoard();
|
|
|
|
m_BrdSettings = &m_Pcb->GetDesignSettings();
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
m_trackWidthsAddButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
2022-07-15 18:15:06 +00:00
|
|
|
m_trackWidthsSortButton->SetBitmap( KiBitmap( BITMAPS::small_sort_desc ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
m_trackWidthsRemoveButton->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
|
|
|
|
m_viaSizesAddButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
2022-07-15 18:15:06 +00:00
|
|
|
m_viaSizesSortButton->SetBitmap( KiBitmap( BITMAPS::small_sort_desc ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
m_viaSizesRemoveButton->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
|
|
|
|
m_diffPairsAddButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
2022-07-15 18:15:06 +00:00
|
|
|
m_diffPairsSortButton->SetBitmap( KiBitmap( BITMAPS::small_sort_desc ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
m_diffPairsRemoveButton->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
|
2018-08-27 19:38:39 +00:00
|
|
|
|
2018-07-17 06:52:33 +00:00
|
|
|
// Membership combobox editors require a bit more room, so increase the row size of
|
|
|
|
// all our grids for consistency
|
|
|
|
m_trackWidthsGrid->SetDefaultRowSize( m_trackWidthsGrid->GetDefaultRowSize() + 4 );
|
|
|
|
m_viaSizesGrid->SetDefaultRowSize( m_viaSizesGrid->GetDefaultRowSize() + 4 );
|
|
|
|
m_diffPairsGrid->SetDefaultRowSize( m_diffPairsGrid->GetDefaultRowSize() + 4 );
|
2018-08-27 19:38:39 +00:00
|
|
|
|
2022-09-09 11:18:05 +00:00
|
|
|
m_trackWidthsGrid->PushEventHandler( new GRID_TRICKS( m_trackWidthsGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddTrackWidthsClick( aEvent );
|
|
|
|
} ) );
|
|
|
|
m_viaSizesGrid->PushEventHandler( new GRID_TRICKS( m_viaSizesGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddViaSizesClick( aEvent );
|
|
|
|
} ) );
|
|
|
|
m_diffPairsGrid->PushEventHandler( new GRID_TRICKS( m_diffPairsGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddDiffPairsClick( aEvent );
|
|
|
|
} ) );
|
2018-08-27 19:38:39 +00:00
|
|
|
|
|
|
|
m_trackWidthsGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
|
|
|
|
m_viaSizesGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
|
|
|
|
m_diffPairsGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
|
2021-04-23 08:58:59 +00:00
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
m_trackWidthsGrid->SetUnitsProvider( m_Frame );
|
|
|
|
m_viaSizesGrid->SetUnitsProvider( m_Frame );
|
|
|
|
m_diffPairsGrid->SetUnitsProvider( m_Frame );
|
|
|
|
|
|
|
|
m_trackWidthsGrid->SetAutoEvalCols( { 0 } );
|
|
|
|
m_viaSizesGrid->SetAutoEvalCols( { 0, 1 } );
|
|
|
|
m_diffPairsGrid->SetAutoEvalCols( { 0, 1, 2 } );
|
|
|
|
|
2021-04-23 08:58:59 +00:00
|
|
|
// Ensure width of columns is enough to enter any reasonable value
|
|
|
|
WX_GRID* grid_list[] = { m_trackWidthsGrid, m_viaSizesGrid, m_diffPairsGrid, nullptr };
|
2022-02-04 22:44:59 +00:00
|
|
|
int min_linesize = m_trackWidthsGrid->GetTextExtent( wxT( "000.000000 mm " ) ).x;
|
2021-04-23 08:58:59 +00:00
|
|
|
|
|
|
|
for( int ii = 0; grid_list[ii]; ii++ )
|
|
|
|
{
|
|
|
|
WX_GRID* curr_grid = grid_list[ii];
|
|
|
|
|
|
|
|
for( int col = 0; col < curr_grid->GetNumberCols(); col++ )
|
|
|
|
{
|
|
|
|
int min_w = curr_grid->GetVisibleWidth( col, true, true, true );
|
|
|
|
int best_w = std::max( min_linesize, min_w );
|
|
|
|
curr_grid->SetColMinimalWidth( col, best_w );
|
|
|
|
curr_grid->SetColSize( col,best_w );
|
|
|
|
}
|
|
|
|
}
|
2021-12-22 21:43:41 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
m_Frame->Bind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_TRACKS_AND_VIAS::onUnitsChanged, this );
|
2018-07-17 06:52:33 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 21:43:41 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
PANEL_SETUP_TRACKS_AND_VIAS::~PANEL_SETUP_TRACKS_AND_VIAS()
|
|
|
|
{
|
|
|
|
// Delete the GRID_TRICKS.
|
|
|
|
m_trackWidthsGrid->PopEventHandler( true );
|
|
|
|
m_viaSizesGrid->PopEventHandler( true );
|
|
|
|
m_diffPairsGrid->PopEventHandler( true );
|
2021-12-22 21:43:41 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
m_Frame->Unbind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_TRACKS_AND_VIAS::onUnitsChanged, this );
|
2021-12-22 21:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-15 18:15:06 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnSortTrackWidthsClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
std::vector<int> trackWidths;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
wxGridUpdateLocker lock( m_trackWidthsGrid );
|
|
|
|
|
|
|
|
for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
|
|
|
msg = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL );
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
2022-10-05 16:42:03 +00:00
|
|
|
trackWidths.push_back( m_Frame->ValueFromString( msg ) );
|
2022-07-15 18:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::sort( trackWidths.begin(), trackWidths.end() );
|
|
|
|
m_trackWidthsGrid->DeleteRows(0, m_trackWidthsGrid->GetNumberRows(), false);
|
|
|
|
|
|
|
|
for( int width : trackWidths )
|
|
|
|
AppendTrackWidth( width );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnSortViaSizesClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
std::vector<VIA_DIMENSION> vias;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
wxGridUpdateLocker lock( m_viaSizesGrid );
|
|
|
|
|
|
|
|
for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
|
|
|
msg = m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL );
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
|
|
|
VIA_DIMENSION via_dim;
|
2022-10-05 16:42:03 +00:00
|
|
|
via_dim.m_Diameter = m_Frame->ValueFromString( msg );
|
2022-07-15 18:15:06 +00:00
|
|
|
|
|
|
|
msg = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL );
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
2022-10-05 16:42:03 +00:00
|
|
|
via_dim.m_Drill = m_Frame->ValueFromString( msg );
|
2022-07-15 18:15:06 +00:00
|
|
|
|
|
|
|
vias.push_back( via_dim );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort( vias.begin(), vias.end() );
|
|
|
|
m_viaSizesGrid->DeleteRows(0, m_viaSizesGrid->GetNumberRows(), false );
|
|
|
|
|
|
|
|
for( const VIA_DIMENSION& via : vias )
|
|
|
|
AppendViaSize( via.m_Diameter, via.m_Drill );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnSortDiffPairsClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
std::vector<DIFF_PAIR_DIMENSION> diffPairs;
|
|
|
|
|
|
|
|
wxGridUpdateLocker lock( m_diffPairsGrid );
|
|
|
|
|
|
|
|
for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
|
|
|
msg = m_diffPairsGrid->GetCellValue( row, DP_WIDTH_COL );
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
|
|
|
DIFF_PAIR_DIMENSION diffPair_dim;
|
2022-10-05 16:42:03 +00:00
|
|
|
diffPair_dim.m_Width = m_Frame->ValueFromString( msg );
|
2022-07-15 18:15:06 +00:00
|
|
|
|
|
|
|
msg = m_diffPairsGrid->GetCellValue( row, DP_GAP_COL );
|
2022-10-05 16:42:03 +00:00
|
|
|
diffPair_dim.m_Gap = m_Frame->ValueFromString( msg );
|
2022-07-15 18:15:06 +00:00
|
|
|
|
|
|
|
msg = m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL );
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
2022-10-05 16:42:03 +00:00
|
|
|
diffPair_dim.m_ViaGap = m_Frame->ValueFromString( msg );
|
2022-07-15 18:15:06 +00:00
|
|
|
|
|
|
|
diffPairs.push_back( diffPair_dim );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort( diffPairs.begin(), diffPairs.end() );
|
|
|
|
m_diffPairsGrid->DeleteRows(0, m_diffPairsGrid->GetNumberRows(), false );
|
|
|
|
|
|
|
|
for( const DIFF_PAIR_DIMENSION& dp : diffPairs )
|
|
|
|
AppendDiffPairs( dp.m_Width, dp.m_Gap, dp.m_ViaGap );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-22 21:43:41 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::onUnitsChanged( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
BOARD_DESIGN_SETTINGS tempBDS( nullptr, "dummy" );
|
|
|
|
BOARD_DESIGN_SETTINGS* saveBDS = m_BrdSettings;
|
|
|
|
|
|
|
|
m_BrdSettings = &tempBDS; // No, address of stack var does not escape function
|
|
|
|
|
|
|
|
TransferDataFromWindow();
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
m_BrdSettings = saveBDS;
|
|
|
|
|
|
|
|
aEvent.Skip();
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
2018-07-17 06:52:33 +00:00
|
|
|
|
2021-12-22 21:43:41 +00:00
|
|
|
|
2018-07-17 06:52:33 +00:00
|
|
|
bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataToWindow()
|
|
|
|
{
|
2021-08-10 11:59:53 +00:00
|
|
|
m_trackWidthsGrid->ClearRows();
|
|
|
|
m_viaSizesGrid->ClearRows();
|
|
|
|
m_diffPairsGrid->ClearRows();
|
2018-07-17 06:52:33 +00:00
|
|
|
|
|
|
|
// Skip the first item, which is the current netclass value
|
|
|
|
for( unsigned ii = 1; ii < m_BrdSettings->m_TrackWidthList.size(); ii++ )
|
|
|
|
{
|
2018-08-27 19:38:39 +00:00
|
|
|
AppendTrackWidth( m_BrdSettings->m_TrackWidthList[ii] );
|
2018-07-17 06:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip the first item, which is the current netclass value
|
|
|
|
for( unsigned ii = 1; ii < m_BrdSettings->m_ViasDimensionsList.size(); ii++ )
|
|
|
|
{
|
2018-08-27 19:38:39 +00:00
|
|
|
AppendViaSize( m_BrdSettings->m_ViasDimensionsList[ii].m_Diameter,
|
|
|
|
m_BrdSettings->m_ViasDimensionsList[ii].m_Drill );
|
2018-07-17 06:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip the first item, which is the current netclass value
|
|
|
|
for( unsigned ii = 1; ii < m_BrdSettings->m_DiffPairDimensionsList.size(); ii++ )
|
|
|
|
{
|
2018-08-27 19:38:39 +00:00
|
|
|
AppendDiffPairs( m_BrdSettings->m_DiffPairDimensionsList[ii].m_Width,
|
|
|
|
m_BrdSettings->m_DiffPairDimensionsList[ii].m_Gap,
|
|
|
|
m_BrdSettings->m_DiffPairDimensionsList[ii].m_ViaGap );
|
2018-07-17 06:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow()
|
|
|
|
{
|
2021-02-12 03:19:46 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
2018-07-17 06:52:33 +00:00
|
|
|
return false;
|
2021-02-12 03:19:46 +00:00
|
|
|
}
|
2018-07-17 06:52:33 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
std::vector<int> trackWidths;
|
|
|
|
std::vector<VIA_DIMENSION> vias;
|
|
|
|
std::vector<DIFF_PAIR_DIMENSION> diffPairs;
|
|
|
|
|
2021-03-16 14:28:01 +00:00
|
|
|
// Test ONLY for malformed data. Design rules and constraints are the business of DRC.
|
|
|
|
|
2018-07-17 06:52:33 +00:00
|
|
|
for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
2022-10-11 17:01:47 +00:00
|
|
|
if( !m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL ).IsEmpty() )
|
|
|
|
trackWidths.push_back( m_trackWidthsGrid->GetUnitValue( row, TR_WIDTH_COL ) );
|
2018-07-17 06:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
2022-10-11 17:01:47 +00:00
|
|
|
if( !m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL ).IsEmpty() )
|
2018-07-17 06:52:33 +00:00
|
|
|
{
|
|
|
|
VIA_DIMENSION via_dim;
|
2022-10-11 17:01:47 +00:00
|
|
|
via_dim.m_Diameter = m_viaSizesGrid->GetUnitValue( row, VIA_SIZE_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
if( !m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL ).IsEmpty() )
|
|
|
|
via_dim.m_Drill = m_viaSizesGrid->GetUnitValue( row, VIA_DRILL_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
|
|
|
vias.push_back( via_dim );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row )
|
2018-07-17 06:52:33 +00:00
|
|
|
{
|
2022-10-11 17:01:47 +00:00
|
|
|
if( !m_diffPairsGrid->GetCellValue( row, DP_WIDTH_COL ).IsEmpty() )
|
2018-07-17 06:52:33 +00:00
|
|
|
{
|
|
|
|
DIFF_PAIR_DIMENSION diffPair_dim;
|
2022-10-11 17:01:47 +00:00
|
|
|
diffPair_dim.m_Width = m_diffPairsGrid->GetUnitValue( row, DP_WIDTH_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
if( !m_diffPairsGrid->GetCellValue( row, DP_GAP_COL ).IsEmpty() )
|
|
|
|
diffPair_dim.m_Gap = m_diffPairsGrid->GetUnitValue( row, DP_GAP_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
if( !m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL ).IsEmpty() )
|
|
|
|
diffPair_dim.m_ViaGap = m_diffPairsGrid->GetUnitValue( row, DP_VIA_GAP_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
|
|
|
diffPairs.push_back( diffPair_dim );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort lists by increasing value
|
|
|
|
sort( trackWidths.begin(), trackWidths.end() );
|
|
|
|
sort( vias.begin(), vias.end() );
|
|
|
|
sort( diffPairs.begin(), diffPairs.end() );
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
// These are all stored in project file, not board, so no need for OnModify()
|
|
|
|
|
2020-10-10 23:50:56 +00:00
|
|
|
trackWidths.insert( trackWidths.begin(), 0 ); // dummy value for "use netclass"
|
2018-07-17 06:52:33 +00:00
|
|
|
m_BrdSettings->m_TrackWidthList = trackWidths;
|
|
|
|
|
2020-10-10 23:50:56 +00:00
|
|
|
vias.insert( vias.begin(), { 0, 0 } ); // dummy value for "use netclass"
|
2018-07-17 06:52:33 +00:00
|
|
|
m_BrdSettings->m_ViasDimensionsList = vias;
|
|
|
|
|
2020-10-10 23:50:56 +00:00
|
|
|
diffPairs.insert( diffPairs.begin(), { 0, 0, 0 } ); // dummy value for "use netclass"
|
2018-07-17 06:52:33 +00:00
|
|
|
m_BrdSettings->m_DiffPairDimensionsList = diffPairs;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-12 03:19:46 +00:00
|
|
|
bool PANEL_SETUP_TRACKS_AND_VIAS::Validate()
|
2018-07-17 06:52:33 +00:00
|
|
|
{
|
2018-08-19 16:10:14 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
2018-08-27 19:38:39 +00:00
|
|
|
{
|
2018-08-19 16:10:14 +00:00
|
|
|
return false;
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
2018-07-17 06:52:33 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
// Test vias
|
|
|
|
for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
2018-08-27 19:38:39 +00:00
|
|
|
wxString viaDia = m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL );
|
|
|
|
wxString viaDrill = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
2021-03-16 14:28:01 +00:00
|
|
|
if( !viaDia.IsEmpty() && viaDrill.IsEmpty() )
|
2018-07-17 06:52:33 +00:00
|
|
|
{
|
2021-02-12 03:19:46 +00:00
|
|
|
msg = _( "No via hole size defined." );
|
2018-08-27 19:38:39 +00:00
|
|
|
m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL );
|
2018-07-17 06:52:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-01 13:01:42 +00:00
|
|
|
// Test diff pairs
|
|
|
|
for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row )
|
|
|
|
{
|
2021-03-16 14:28:01 +00:00
|
|
|
wxString dpWidth = m_diffPairsGrid->GetCellValue( row, 0 );
|
|
|
|
wxString dpGap = m_diffPairsGrid->GetCellValue( row, 1 );
|
2018-09-01 13:01:42 +00:00
|
|
|
|
2021-03-16 14:28:01 +00:00
|
|
|
if( !dpWidth.IsEmpty() && dpGap.IsEmpty() )
|
2018-09-01 13:01:42 +00:00
|
|
|
{
|
|
|
|
msg = _( "No differential pair gap defined." );
|
|
|
|
m_Parent->SetError( msg, this, m_diffPairsGrid, row, 1 );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 06:52:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth( const int aWidth )
|
|
|
|
{
|
|
|
|
int i = m_trackWidthsGrid->GetNumberRows();
|
|
|
|
|
|
|
|
m_trackWidthsGrid->AppendRows( 1 );
|
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
m_trackWidthsGrid->SetUnitValue( i, TR_WIDTH_COL, aWidth );
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize( int aSize, int aDrill )
|
2018-08-27 19:38:39 +00:00
|
|
|
{
|
|
|
|
int i = m_viaSizesGrid->GetNumberRows();
|
|
|
|
|
|
|
|
m_viaSizesGrid->AppendRows( 1 );
|
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
m_viaSizesGrid->SetUnitValue( i, VIA_SIZE_COL, aSize );
|
2018-08-27 19:38:39 +00:00
|
|
|
|
|
|
|
if( aDrill > 0 )
|
2022-10-11 17:01:47 +00:00
|
|
|
m_viaSizesGrid->SetUnitValue( i, VIA_DRILL_COL, aDrill );
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs( int aWidth, int aGap, int aViaGap )
|
2018-08-27 19:38:39 +00:00
|
|
|
{
|
|
|
|
int i = m_diffPairsGrid->GetNumberRows();
|
|
|
|
|
|
|
|
m_diffPairsGrid->AppendRows( 1 );
|
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
m_diffPairsGrid->SetUnitValue( i, DP_WIDTH_COL, aWidth );
|
2018-08-27 19:38:39 +00:00
|
|
|
|
|
|
|
if( aGap > 0 )
|
2022-10-11 17:01:47 +00:00
|
|
|
m_diffPairsGrid->SetUnitValue( i, DP_GAP_COL, aGap );
|
2018-08-27 19:38:39 +00:00
|
|
|
|
|
|
|
if( aViaGap > 0 )
|
2022-10-11 17:01:47 +00:00
|
|
|
m_diffPairsGrid->SetUnitValue( i, DP_VIA_GAP_COL, aViaGap );
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
|
|
|
|
2022-08-18 16:56:36 +00:00
|
|
|
|
2022-07-16 11:06:19 +00:00
|
|
|
void removeSelectedRows( WX_GRID* aGrid )
|
|
|
|
{
|
|
|
|
wxArrayInt selectedRows = aGrid->GetSelectedRows();
|
|
|
|
int curRow = aGrid->GetGridCursorRow();
|
|
|
|
|
|
|
|
if( selectedRows.empty() && curRow >= 0 && curRow < aGrid->GetNumberRows() )
|
|
|
|
selectedRows.Add( curRow );
|
|
|
|
|
|
|
|
for( int ii = selectedRows.Count() - 1; ii >= 0; --ii )
|
|
|
|
{
|
|
|
|
int row = selectedRows.Item( ii );
|
|
|
|
aGrid->DeleteRows( row, 1 );
|
|
|
|
curRow = std::min( curRow, row );
|
|
|
|
}
|
|
|
|
|
|
|
|
curRow = std::max( 0, curRow - 1 );
|
|
|
|
aGrid->MakeCellVisible( curRow, aGrid->GetGridCursorCol() );
|
|
|
|
aGrid->SetGridCursor( curRow, aGrid->GetGridCursorCol() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddTrackWidthsClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
2022-08-18 16:56:36 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
AppendTrackWidth( 0 );
|
2018-07-17 06:52:33 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
m_trackWidthsGrid->MakeCellVisible( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL );
|
|
|
|
m_trackWidthsGrid->SetGridCursor( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL );
|
|
|
|
|
|
|
|
m_trackWidthsGrid->EnableCellEditControl( true );
|
|
|
|
m_trackWidthsGrid->ShowCellEditControl();
|
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveTrackWidthsClick( wxCommandEvent& event )
|
|
|
|
{
|
2022-08-18 16:56:36 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-16 11:06:19 +00:00
|
|
|
removeSelectedRows( m_trackWidthsGrid );
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick( wxCommandEvent& event )
|
|
|
|
{
|
2022-08-18 16:56:36 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
AppendViaSize( 0, 0 );
|
|
|
|
|
|
|
|
m_viaSizesGrid->MakeCellVisible( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL );
|
|
|
|
m_viaSizesGrid->SetGridCursor( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL );
|
|
|
|
|
|
|
|
m_viaSizesGrid->EnableCellEditControl( true );
|
|
|
|
m_viaSizesGrid->ShowCellEditControl();
|
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveViaSizesClick( wxCommandEvent& event )
|
|
|
|
{
|
2022-08-18 16:56:36 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-16 11:06:19 +00:00
|
|
|
removeSelectedRows( m_viaSizesGrid );
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick( wxCommandEvent& event )
|
|
|
|
{
|
2022-08-18 16:56:36 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
AppendDiffPairs( 0, 0, 0 );
|
|
|
|
|
|
|
|
m_diffPairsGrid->MakeCellVisible( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL );
|
|
|
|
m_diffPairsGrid->SetGridCursor( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL );
|
|
|
|
|
|
|
|
m_diffPairsGrid->EnableCellEditControl( true );
|
|
|
|
m_diffPairsGrid->ShowCellEditControl();
|
|
|
|
}
|
|
|
|
|
2019-03-07 04:55:14 +00:00
|
|
|
|
2018-08-27 19:38:39 +00:00
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveDiffPairsClick( wxCommandEvent& event )
|
|
|
|
{
|
2022-08-18 16:56:36 +00:00
|
|
|
if( !m_trackWidthsGrid->CommitPendingChanges()
|
|
|
|
|| !m_viaSizesGrid->CommitPendingChanges()
|
|
|
|
|| !m_diffPairsGrid->CommitPendingChanges() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-16 11:06:19 +00:00
|
|
|
removeSelectedRows( m_diffPairsGrid );
|
2018-08-27 19:38:39 +00:00
|
|
|
}
|
2019-03-07 04:55:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom( BOARD* aBoard )
|
|
|
|
{
|
|
|
|
m_trackWidthsGrid->CommitPendingChanges( true );
|
|
|
|
m_viaSizesGrid->CommitPendingChanges( true );
|
|
|
|
m_diffPairsGrid->CommitPendingChanges( true );
|
|
|
|
|
|
|
|
// Note: do not change the board, as we need to get the current nets from it for
|
|
|
|
// netclass memberships. All the netclass definitions and dimension lists are in
|
|
|
|
// the BOARD_DESIGN_SETTINGS.
|
|
|
|
|
|
|
|
BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
|
|
|
|
|
|
|
|
m_BrdSettings = &aBoard->GetDesignSettings();
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
m_BrdSettings = savedSettings;
|
|
|
|
}
|
|
|
|
|