2014-10-27 14:14:39 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-10-14 19:07:04 +00:00
|
|
|
* Copyright (C) 2009-2016 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
|
2022-02-24 16:57:08 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-27 14:14:39 +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
|
|
|
|
*/
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2021-09-04 17:05:57 +00:00
|
|
|
#include <pcb_group.h>
|
2018-10-12 06:17:15 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
2019-05-28 23:23:58 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2019-06-03 20:06:58 +00:00
|
|
|
#include <tools/global_edit_tool.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include "dialog_global_edit_tracks_and_vias_base.h"
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
// Columns of netclasses grid
|
|
|
|
enum {
|
|
|
|
GRID_NAME = 0,
|
|
|
|
GRID_TRACKSIZE,
|
|
|
|
GRID_VIASIZE,
|
|
|
|
GRID_VIADRILL,
|
|
|
|
GRID_uVIASIZE,
|
|
|
|
GRID_uVIADRILL,
|
|
|
|
GRID_DIFF_PAIR_WIDTH, // not currently included in grid
|
|
|
|
GRID_DIFF_PAIR_GAP, // not currently included in grid
|
|
|
|
GRID_DIFF_PAIR_VIA_GAP // not currently included in grid
|
|
|
|
};
|
2009-10-30 17:58:15 +00:00
|
|
|
|
|
|
|
|
2018-10-10 17:42:27 +00:00
|
|
|
// Globals to remember control settings during a session
|
|
|
|
static bool g_modifyTracks = true;
|
|
|
|
static bool g_modifyVias = true;
|
|
|
|
static bool g_filterByNetclass;
|
|
|
|
static wxString g_netclassFilter;
|
|
|
|
static bool g_filterByNet;
|
|
|
|
static wxString g_netFilter;
|
|
|
|
static bool g_filterByLayer;
|
2021-07-21 23:14:56 +00:00
|
|
|
static int g_layerFilter;
|
2021-02-16 03:14:28 +00:00
|
|
|
static bool g_filterSelected = false;
|
2018-10-10 17:42:27 +00:00
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS : public DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
private:
|
|
|
|
PCB_EDIT_FRAME* m_parent;
|
|
|
|
BOARD* m_brd;
|
|
|
|
int* m_originalColWidths;
|
2021-02-16 03:14:28 +00:00
|
|
|
PCB_SELECTION m_selection;
|
2022-02-20 19:07:14 +00:00
|
|
|
std::vector<BOARD_ITEM*> m_items_changed; // a list of modified items
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
public:
|
|
|
|
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT_FRAME* aParent );
|
|
|
|
~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS() override;
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2021-04-07 16:38:07 +00:00
|
|
|
protected:
|
|
|
|
void onSpecifiedValuesUpdateUi( wxUpdateUIEvent& event ) override;
|
|
|
|
void OnSizeNetclassGrid( wxSizeEvent& event ) override;
|
|
|
|
|
|
|
|
void OnNetclassFilterSelect( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_netclassFilterOpt->SetValue( true );
|
|
|
|
}
|
|
|
|
void OnLayerFilterSelect( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_layerFilterOpt->SetValue( true );
|
|
|
|
}
|
|
|
|
|
2021-12-23 13:11:26 +00:00
|
|
|
void onUnitsChanged( wxCommandEvent& aEvent );
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
private:
|
2021-06-11 21:07:02 +00:00
|
|
|
void visitItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem );
|
|
|
|
void processItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem );
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2018-08-19 10:56:18 +00:00
|
|
|
bool TransferDataToWindow() override;
|
2018-04-28 15:22:25 +00:00
|
|
|
bool TransferDataFromWindow() override;
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void AdjustNetclassGridColumns( int aWidth );
|
2013-01-09 18:52:44 +00:00
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
void OnNetFilterSelect( wxCommandEvent& event )
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
m_netFilterOpt->SetValue( true );
|
2009-10-30 17:58:15 +00:00
|
|
|
}
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void buildNetclassesGrid();
|
|
|
|
void buildFilterLists();
|
|
|
|
};
|
2013-01-09 18:52:44 +00:00
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT_FRAME* aParent ) :
|
|
|
|
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE( aParent )
|
|
|
|
{
|
2021-12-23 13:11:26 +00:00
|
|
|
m_parent = aParent;
|
2018-04-28 15:22:25 +00:00
|
|
|
m_brd = m_parent->GetBoard();
|
2009-11-02 20:36:20 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ];
|
2013-01-09 18:52:44 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
for( int i = 0; i < m_netclassGrid->GetNumberCols(); ++i )
|
|
|
|
m_originalColWidths[ i ] = m_netclassGrid->GetColSize( i );
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
buildFilterLists();
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2019-02-08 13:50:20 +00:00
|
|
|
m_parent->UpdateTrackWidthSelectBox( m_trackWidthSelectBox, false );
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackWidthSelectBox->Append( INDETERMINATE_ACTION );
|
2019-02-08 13:50:20 +00:00
|
|
|
m_parent->UpdateViaSizeSelectBox( m_viaSizesSelectBox, false );
|
2020-05-05 15:40:18 +00:00
|
|
|
m_viaSizesSelectBox->Append( INDETERMINATE_ACTION );
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
m_layerBox->SetBoardFrame( m_parent );
|
|
|
|
m_layerBox->SetLayersHotkeys( false );
|
|
|
|
m_layerBox->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
|
2020-05-05 15:40:18 +00:00
|
|
|
m_layerBox->SetUndefinedLayerName( INDETERMINATE_ACTION );
|
2018-04-28 15:22:25 +00:00
|
|
|
m_layerBox->Resync();
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2021-09-11 19:07:33 +00:00
|
|
|
m_netclassGrid->SetDefaultCellFont( KIUI::GetInfoFont( this ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
buildNetclassesGrid();
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
m_netclassGrid->SetCellHighlightPenWidth( 0 );
|
2021-11-16 19:39:58 +00:00
|
|
|
|
|
|
|
SetupStandardButtons();
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
m_netFilter->Connect( NET_SELECTED,
|
|
|
|
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ),
|
|
|
|
nullptr, this );
|
2018-08-19 16:11:58 +00:00
|
|
|
|
2021-12-23 13:11:26 +00:00
|
|
|
m_parent->Bind( UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this );
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS()
|
|
|
|
{
|
2018-10-10 17:42:27 +00:00
|
|
|
g_modifyTracks = m_tracks->GetValue();
|
|
|
|
g_modifyVias = m_vias->GetValue();
|
|
|
|
g_filterByNetclass = m_netclassFilterOpt->GetValue();
|
|
|
|
g_netclassFilter = m_netclassFilter->GetStringSelection();
|
|
|
|
g_filterByNet = m_netFilterOpt->GetValue();
|
|
|
|
g_netFilter = m_netFilter->GetSelectedNetname();
|
|
|
|
g_filterByLayer = m_layerFilterOpt->GetValue();
|
|
|
|
g_layerFilter = m_layerFilter->GetLayerSelection();
|
2021-02-16 03:14:28 +00:00
|
|
|
g_filterSelected = m_selectedItemsFilter->GetValue();
|
2018-10-10 17:42:27 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
m_netFilter->Disconnect( NET_SELECTED,
|
|
|
|
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ),
|
|
|
|
nullptr, this );
|
2018-08-19 16:11:58 +00:00
|
|
|
|
2021-12-23 13:11:26 +00:00
|
|
|
m_parent->Unbind( UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this );
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
delete[] m_originalColWidths;
|
2016-10-14 19:07:04 +00:00
|
|
|
}
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2021-12-23 13:11:26 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int trackSel = m_trackWidthSelectBox->GetSelection();
|
|
|
|
int viaSel = m_viaSizesSelectBox->GetSelection();
|
|
|
|
|
|
|
|
m_parent->UpdateTrackWidthSelectBox( m_trackWidthSelectBox, false );
|
|
|
|
m_trackWidthSelectBox->Append( INDETERMINATE_ACTION );
|
|
|
|
m_parent->UpdateViaSizeSelectBox( m_viaSizesSelectBox, false );
|
|
|
|
m_viaSizesSelectBox->Append( INDETERMINATE_ACTION );
|
|
|
|
|
|
|
|
m_trackWidthSelectBox->SetSelection( trackSel );
|
|
|
|
m_viaSizesSelectBox->SetSelection( viaSel );
|
|
|
|
|
|
|
|
m_netclassGrid->ClearGrid();
|
|
|
|
buildNetclassesGrid();
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists()
|
2016-10-14 19:07:04 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
// Populate the net filter list with net names
|
2020-03-04 22:07:18 +00:00
|
|
|
m_netFilter->SetBoard( m_brd );
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netFilter->SetNetInfo( &m_brd->GetNetInfo() );
|
2020-05-24 17:30:23 +00:00
|
|
|
|
|
|
|
if( !m_brd->GetHighLightNetCodes().empty() )
|
|
|
|
m_netFilter->SetSelectedNetcode( *m_brd->GetHighLightNetCodes().begin() );
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
// Populate the netclass filter list with netclass names
|
2022-08-14 11:03:18 +00:00
|
|
|
wxArrayString netclassNames;
|
|
|
|
std::shared_ptr<NET_SETTINGS>& settings = m_brd->GetDesignSettings().m_NetSettings;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
netclassNames.push_back( settings->m_DefaultNetClass->GetName() );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
for( const auto& [ name, netclass ] : settings->m_NetClasses )
|
|
|
|
netclassNames.push_back( name );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netclassFilter->Set( netclassNames );
|
|
|
|
m_netclassFilter->SetStringSelection( m_brd->GetDesignSettings().GetCurrentNetClassName() );
|
2016-10-14 19:07:04 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
// Populate the layer filter list
|
|
|
|
m_layerFilter->SetBoardFrame( m_parent );
|
|
|
|
m_layerFilter->SetLayersHotkeys( false );
|
|
|
|
m_layerFilter->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
|
|
|
|
m_layerFilter->Resync();
|
2018-08-19 16:11:58 +00:00
|
|
|
m_layerFilter->SetLayerSelection( m_parent->GetActiveLayer() );
|
2009-10-30 17:58:15 +00:00
|
|
|
}
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid()
|
2016-10-14 19:07:04 +00:00
|
|
|
{
|
2022-09-19 09:25:20 +00:00
|
|
|
int row = 0;
|
2022-08-14 11:03:18 +00:00
|
|
|
|
|
|
|
m_netclassGrid->SetCellValue( row, GRID_TRACKSIZE, _( "Track Width" ) );
|
|
|
|
m_netclassGrid->SetCellValue( row, GRID_VIASIZE, _( "Via Diameter" ) );
|
|
|
|
m_netclassGrid->SetCellValue( row, GRID_VIADRILL, _( "Via Hole" ) );
|
|
|
|
m_netclassGrid->SetCellValue( row, GRID_uVIASIZE, _( "uVia Diameter" ) );
|
|
|
|
m_netclassGrid->SetCellValue( row, GRID_uVIADRILL, _( "uVia Hole" ) );
|
|
|
|
row++;
|
|
|
|
|
|
|
|
auto setNetclassValue =
|
2022-09-19 09:25:20 +00:00
|
|
|
[this]( int aRow, int aCol, int aVal )
|
2022-08-14 11:03:18 +00:00
|
|
|
{
|
2022-09-19 09:25:20 +00:00
|
|
|
m_netclassGrid->SetCellValue( aRow, aCol, m_parent->StringFromValue( aVal, true ) );
|
2022-08-14 11:03:18 +00:00
|
|
|
};
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
auto buildRow =
|
2022-08-15 15:03:30 +00:00
|
|
|
[this, &setNetclassValue]( int aRow, const std::shared_ptr<NETCLASS>& aNc )
|
2022-08-14 11:03:18 +00:00
|
|
|
{
|
2022-08-15 15:03:30 +00:00
|
|
|
m_netclassGrid->SetCellValue( aRow, GRID_NAME, aNc->GetName() );
|
|
|
|
setNetclassValue( aRow, GRID_TRACKSIZE, aNc->GetTrackWidth() );
|
|
|
|
setNetclassValue( aRow, GRID_VIASIZE, aNc->GetViaDiameter() );
|
|
|
|
setNetclassValue( aRow, GRID_VIADRILL, aNc->GetViaDrill() );
|
|
|
|
setNetclassValue( aRow, GRID_uVIASIZE, aNc->GetuViaDiameter() );
|
|
|
|
setNetclassValue( aRow, GRID_uVIADRILL, aNc->GetuViaDrill() );
|
2022-08-14 11:03:18 +00:00
|
|
|
};
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
const std::shared_ptr<NET_SETTINGS>& settings = m_brd->GetDesignSettings().m_NetSettings;
|
2018-08-16 13:27:30 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
m_netclassGrid->AppendRows( 1 );
|
|
|
|
buildRow( row++, settings->m_DefaultNetClass );
|
2018-08-16 13:27:30 +00:00
|
|
|
|
2022-12-16 00:08:29 +00:00
|
|
|
m_netclassGrid->AppendRows( (int) settings->m_NetClasses.size() );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
for( const auto& [ name, netclass ] : settings->m_NetClasses )
|
|
|
|
buildRow( row++, netclass );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2016-10-14 19:07:04 +00:00
|
|
|
|
|
|
|
|
2018-08-19 10:56:18 +00:00
|
|
|
bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
|
|
|
|
{
|
2021-02-16 03:14:28 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
m_selection = selTool->GetSelection();
|
|
|
|
BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( m_selection.Front() );
|
2018-08-19 10:56:18 +00:00
|
|
|
|
2018-10-10 17:42:27 +00:00
|
|
|
m_tracks->SetValue( g_modifyTracks );
|
|
|
|
m_vias->SetValue( g_modifyVias );
|
|
|
|
|
2019-02-21 22:09:54 +00:00
|
|
|
if( g_filterByNetclass && m_netclassFilter->SetStringSelection( g_netclassFilter ) )
|
2018-10-10 17:42:27 +00:00
|
|
|
m_netclassFilterOpt->SetValue( true );
|
|
|
|
else if( item )
|
2022-08-14 11:03:18 +00:00
|
|
|
m_netclassFilter->SetStringSelection( item->GetNet()->GetNetClass()->GetName() );
|
2018-10-10 17:42:27 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( g_filterByNet && m_brd->FindNet( g_netFilter ) != nullptr )
|
2018-10-10 17:42:27 +00:00
|
|
|
{
|
|
|
|
m_netFilter->SetSelectedNet( g_netFilter );
|
|
|
|
m_netFilterOpt->SetValue( true );
|
2018-08-19 10:56:18 +00:00
|
|
|
}
|
2018-10-10 17:42:27 +00:00
|
|
|
else if( item )
|
2020-12-08 13:02:08 +00:00
|
|
|
{
|
2018-10-10 17:42:27 +00:00
|
|
|
m_netFilter->SetSelectedNetcode( item->GetNetCode() );
|
2020-12-08 13:02:08 +00:00
|
|
|
}
|
2018-10-10 17:42:27 +00:00
|
|
|
|
2019-02-21 22:09:54 +00:00
|
|
|
if( g_filterByLayer && m_layerFilter->SetLayerSelection( g_layerFilter ) != wxNOT_FOUND )
|
2022-08-14 11:03:18 +00:00
|
|
|
{
|
2018-10-10 17:42:27 +00:00
|
|
|
m_layerFilterOpt->SetValue( true );
|
2022-08-14 11:03:18 +00:00
|
|
|
}
|
2018-10-10 17:42:27 +00:00
|
|
|
else if( item )
|
2022-02-24 16:57:08 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == PCB_ZONE_T ) // a zone can be on more than one layer
|
|
|
|
m_layerFilter->SetLayerSelection( static_cast<ZONE*>(item)->GetFirstLayer() );
|
|
|
|
else
|
|
|
|
m_layerFilter->SetLayerSelection( item->GetLayer() );
|
|
|
|
}
|
2018-08-19 10:56:18 +00:00
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackWidthSelectBox->SetSelection( (int) m_trackWidthSelectBox->GetCount() - 1 );
|
|
|
|
m_viaSizesSelectBox->SetSelection( (int) m_viaSizesSelectBox->GetCount() - 1 );
|
|
|
|
m_layerBox->SetStringSelection( INDETERMINATE_ACTION );
|
|
|
|
|
2021-02-16 03:14:28 +00:00
|
|
|
m_selectedItemsFilter->SetValue( g_filterSelected );
|
|
|
|
|
2018-08-19 10:56:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-07 16:38:07 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onSpecifiedValuesUpdateUi( wxUpdateUIEvent& event )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-04-07 16:38:07 +00:00
|
|
|
// Enable the items in the use specified values section
|
|
|
|
event.Enable( m_setToSpecifiedValues->GetValue() );
|
2016-10-14 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoList,
|
|
|
|
PCB_TRACK* aItem )
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& brdSettings = m_brd->GetDesignSettings();
|
2020-05-05 15:40:18 +00:00
|
|
|
bool isTrack = aItem->Type() == PCB_TRACE_T;
|
2022-01-11 01:19:11 +00:00
|
|
|
bool isArc = aItem->Type() == PCB_ARC_T;
|
2020-05-05 15:40:18 +00:00
|
|
|
bool isVia = aItem->Type() == PCB_VIA_T;
|
2009-11-02 20:36:20 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( m_setToSpecifiedValues->GetValue() )
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
2022-01-11 01:19:11 +00:00
|
|
|
if( ( isArc || isTrack )
|
|
|
|
&& m_trackWidthSelectBox->GetStringSelection() != INDETERMINATE_ACTION )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
2020-05-05 15:40:18 +00:00
|
|
|
unsigned int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex();
|
2022-01-11 01:19:11 +00:00
|
|
|
int trackWidthIndex = m_trackWidthSelectBox->GetSelection();
|
|
|
|
|
|
|
|
if( trackWidthIndex >= 0 )
|
|
|
|
brdSettings.SetTrackWidthIndex( static_cast<unsigned>( trackWidthIndex ) );
|
2020-05-05 15:40:18 +00:00
|
|
|
|
2020-08-31 15:50:24 +00:00
|
|
|
m_parent->SetTrackSegmentWidth( aItem, aUndoList, false );
|
2020-05-05 15:40:18 +00:00
|
|
|
|
|
|
|
brdSettings.SetTrackWidthIndex( prevTrackWidthIndex );
|
|
|
|
}
|
|
|
|
else if( isVia && m_viaSizesSelectBox->GetStringSelection() != INDETERMINATE_ACTION )
|
|
|
|
{
|
|
|
|
unsigned int prevViaSizeIndex = brdSettings.GetViaSizeIndex();
|
2022-01-11 01:19:11 +00:00
|
|
|
int viaSizeIndex = m_viaSizesSelectBox->GetSelection();
|
|
|
|
|
|
|
|
if( viaSizeIndex >= 0 )
|
|
|
|
brdSettings.SetViaSizeIndex( static_cast<unsigned>( viaSizeIndex ) );
|
2018-12-30 19:35:56 +00:00
|
|
|
|
2020-08-31 15:50:24 +00:00
|
|
|
m_parent->SetTrackSegmentWidth( aItem, aUndoList, false );
|
2020-05-05 15:40:18 +00:00
|
|
|
|
|
|
|
brdSettings.SetViaSizeIndex( prevViaSizeIndex );
|
2018-08-19 16:11:58 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-01-11 01:19:11 +00:00
|
|
|
if( ( isArc || isTrack ) && m_layerBox->GetLayerSelection() != UNDEFINED_LAYER )
|
2009-11-02 20:36:20 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
if( aUndoList->FindItem( aItem ) < 0 )
|
|
|
|
{
|
2020-08-26 18:04:32 +00:00
|
|
|
ITEM_PICKER picker( nullptr, aItem, UNDO_REDO::CHANGED );
|
2018-04-28 15:22:25 +00:00
|
|
|
picker.SetLink( aItem->Clone() );
|
|
|
|
aUndoList->PushItem( picker );
|
|
|
|
}
|
|
|
|
|
|
|
|
aItem->SetLayer( ToLAYER_ID( m_layerBox->GetLayerSelection() ) );
|
|
|
|
m_parent->GetBoard()->GetConnectivity()->Update( aItem );
|
2009-11-02 20:36:20 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-31 15:50:24 +00:00
|
|
|
m_parent->SetTrackSegmentWidth( aItem, aUndoList, true );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2020-04-12 19:29:16 +00:00
|
|
|
|
2022-02-20 19:07:14 +00:00
|
|
|
m_items_changed.push_back( aItem );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-09-04 17:05:57 +00:00
|
|
|
if( m_selectedItemsFilter->GetValue() )
|
|
|
|
{
|
|
|
|
if( !aItem->IsSelected() )
|
|
|
|
{
|
|
|
|
PCB_GROUP* group = aItem->GetParentGroup();
|
|
|
|
|
|
|
|
while( group && !group->IsSelected() )
|
|
|
|
group = group->GetParentGroup();
|
|
|
|
|
|
|
|
if( !group )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if( m_netFilterOpt->GetValue() && m_netFilter->GetSelectedNetcode() >= 0 )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2018-08-19 16:11:58 +00:00
|
|
|
if( aItem->GetNetCode() != m_netFilter->GetSelectedNetcode() )
|
2009-11-02 20:36:20 +00:00
|
|
|
return;
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2009-11-02 20:36:20 +00:00
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if( m_netclassFilterOpt->GetValue() && !m_netclassFilter->GetStringSelection().IsEmpty() )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2022-08-14 11:03:18 +00:00
|
|
|
if( aItem->GetEffectiveNetClass()->GetName() != m_netclassFilter->GetStringSelection() )
|
2009-11-02 20:36:20 +00:00
|
|
|
return;
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
2009-11-02 20:36:20 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( m_layerFilterOpt->GetValue() && m_layerFilter->GetLayerSelection() != UNDEFINED_LAYER )
|
|
|
|
{
|
|
|
|
if( aItem->GetLayer() != m_layerFilter->GetLayerSelection() )
|
2009-11-02 20:36:20 +00:00
|
|
|
return;
|
2009-10-30 17:58:15 +00:00
|
|
|
}
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
processItem( aUndoList, aItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST itemsListPicker;
|
2020-08-31 15:50:24 +00:00
|
|
|
wxBusyCursor dummy;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
// Examine segments
|
2021-11-06 11:28:53 +00:00
|
|
|
for( PCB_TRACK* track : m_brd->Tracks() )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-11-06 11:28:53 +00:00
|
|
|
if( m_tracks->GetValue() && track->Type() == PCB_TRACE_T )
|
|
|
|
visitItem( &itemsListPicker, track );
|
2022-01-11 14:08:04 +00:00
|
|
|
else if ( m_tracks->GetValue() && track->Type() == PCB_ARC_T )
|
2021-11-06 11:28:53 +00:00
|
|
|
visitItem( &itemsListPicker, track );
|
2022-01-11 14:08:04 +00:00
|
|
|
else if ( m_vias->GetValue() && track->Type() == PCB_VIA_T )
|
2022-01-11 01:19:11 +00:00
|
|
|
visitItem( &itemsListPicker, track );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( itemsListPicker.GetCount() > 0 )
|
2016-10-14 19:07:04 +00:00
|
|
|
{
|
2020-08-26 18:04:32 +00:00
|
|
|
m_parent->SaveCopyInUndoList( itemsListPicker, UNDO_REDO::CHANGED );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2021-11-06 11:28:53 +00:00
|
|
|
for( PCB_TRACK* track : m_brd->Tracks() )
|
|
|
|
m_parent->GetCanvas()->GetView()->Update( track );
|
2016-10-14 19:07:04 +00:00
|
|
|
}
|
2009-10-30 17:58:15 +00:00
|
|
|
|
2022-02-20 19:07:14 +00:00
|
|
|
if( m_items_changed.size() )
|
|
|
|
{
|
|
|
|
m_brd->OnItemsChanged( m_items_changed );
|
|
|
|
m_parent->OnModify();
|
|
|
|
}
|
|
|
|
|
2020-08-31 15:50:24 +00:00
|
|
|
return true;
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::AdjustNetclassGridColumns( int aWidth )
|
|
|
|
{
|
|
|
|
for( int i = 1; i < m_netclassGrid->GetNumberCols(); i++ )
|
|
|
|
{
|
|
|
|
m_netclassGrid->SetColSize( i, m_originalColWidths[ i ] );
|
|
|
|
aWidth -= m_originalColWidths[ i ];
|
|
|
|
}
|
|
|
|
|
2022-11-16 12:35:21 +00:00
|
|
|
m_netclassGrid->SetColSize( 0, std::max( 72, aWidth ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnSizeNetclassGrid( wxSizeEvent& event )
|
|
|
|
{
|
|
|
|
AdjustNetclassGridColumns( event.GetSize().GetX() );
|
2016-10-14 19:07:04 +00:00
|
|
|
event.Skip();
|
2009-10-30 17:58:15 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
|
2019-06-03 20:06:58 +00:00
|
|
|
int GLOBAL_EDIT_TOOL::EditTracksAndVias( const TOOL_EVENT& aEvent )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
|
|
|
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( editFrame );
|
2020-10-03 14:40:36 +00:00
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
|
2019-06-03 20:06:58 +00:00
|
|
|
return 0;
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|