2015-07-09 11:35:51 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 CERN
|
2023-03-13 16:03:48 +00:00
|
|
|
* Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-07-09 11:35:51 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-12-27 16:35:07 +00:00
|
|
|
#include <core/kicad_algo.h>
|
2015-07-09 11:35:51 +00:00
|
|
|
#include <dialogs/dialog_track_via_properties.h>
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <footprint.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2015-07-09 11:35:51 +00:00
|
|
|
#include <confirm.h>
|
2018-10-12 06:17:15 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
2020-04-24 23:44:09 +00:00
|
|
|
#include <macros.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent,
|
2023-06-27 15:52:50 +00:00
|
|
|
const PCB_SELECTION& aItems ) :
|
2018-02-03 09:09:53 +00:00
|
|
|
DIALOG_TRACK_VIA_PROPERTIES_BASE( aParent ),
|
2018-08-19 16:11:58 +00:00
|
|
|
m_frame( aParent ),
|
|
|
|
m_items( aItems ),
|
2023-05-12 21:03:54 +00:00
|
|
|
m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, nullptr ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
|
2023-05-12 21:03:54 +00:00
|
|
|
m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, nullptr ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit ),
|
2023-05-12 21:03:54 +00:00
|
|
|
m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, nullptr ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit ),
|
|
|
|
m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit ),
|
2023-05-12 21:03:54 +00:00
|
|
|
m_teardropHDPercent( aParent, m_stHDRatio, m_tcHDRatio, m_stHDRatioUnits ),
|
|
|
|
m_teardropLenPercent( aParent, m_stLenPercentLabel, m_tcLenPercent, m_stLenPercentUnits ),
|
|
|
|
m_teardropMaxLen( aParent, m_stMaxLen, m_tcTdMaxLen, m_stMaxLenUnits ),
|
|
|
|
m_teardropHeightPercent( aParent, m_stHeightPercentLabel, m_tcHeightPercent, m_stHeightPercentUnits ),
|
|
|
|
m_teardropMaxHeight( aParent, m_stMaxHeight, m_tcMaxHeight, m_stMaxHeightUnits ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_tracks( false ),
|
|
|
|
m_vias( false )
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2021-01-07 00:45:32 +00:00
|
|
|
m_useCalculatedSize = true;
|
|
|
|
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( !m_items.Empty() );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2023-10-21 18:56:19 +00:00
|
|
|
m_legacyTeardropsIcon->SetBitmap( KiBitmapBundle( BITMAPS::dialog_warning ) );
|
2023-05-12 21:03:54 +00:00
|
|
|
m_legacyTeardropsWarning->Show( m_frame->GetBoard()->LegacyTeardrops() );
|
|
|
|
|
2023-10-21 18:56:19 +00:00
|
|
|
m_bitmapTeardrop->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_sizes ) );
|
2023-05-12 21:03:54 +00:00
|
|
|
|
|
|
|
m_teardropHDPercent.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_teardropLenPercent.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_teardropHeightPercent.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
|
|
|
|
m_minTrackWidthHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
|
|
|
|
|
2020-07-06 14:41:29 +00:00
|
|
|
// Configure display origin transforms
|
|
|
|
m_trackStartX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
|
|
|
|
m_trackStartY.SetCoordType( ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
|
|
|
m_trackEndX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
|
|
|
|
m_trackEndY.SetCoordType( ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
|
|
|
m_viaX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
|
|
|
|
m_viaY.SetCoordType( ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
VIATYPE viaType = VIATYPE::NOT_DEFINED;
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2018-07-20 19:26:50 +00:00
|
|
|
m_TrackLayerCtrl->SetLayersHotkeys( false );
|
|
|
|
m_TrackLayerCtrl->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
|
|
|
|
m_TrackLayerCtrl->SetBoardFrame( aParent );
|
|
|
|
m_TrackLayerCtrl->Resync();
|
|
|
|
|
|
|
|
m_ViaStartLayer->SetLayersHotkeys( false );
|
|
|
|
m_ViaStartLayer->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
|
|
|
|
m_ViaStartLayer->SetBoardFrame( aParent );
|
|
|
|
m_ViaStartLayer->Resync();
|
|
|
|
|
|
|
|
m_ViaEndLayer->SetLayersHotkeys( false );
|
|
|
|
m_ViaEndLayer->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
|
|
|
|
m_ViaEndLayer->SetBoardFrame( aParent );
|
|
|
|
m_ViaEndLayer->Resync();
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
bool nets = false;
|
|
|
|
int net = 0;
|
2023-11-18 12:17:44 +00:00
|
|
|
bool tracksMatchNetclassValues = true;
|
|
|
|
bool viasMatchNetclassValues = true;
|
2016-08-15 15:16:48 +00:00
|
|
|
bool hasLocked = false;
|
|
|
|
bool hasUnlocked = false;
|
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
// Start and end layers of vias
|
|
|
|
// if at least 2 vias do not have the same start or the same end layer
|
|
|
|
// the layers will be set as undefined
|
|
|
|
int selection_first_layer = -1;
|
|
|
|
int selection_last_layer = -1;
|
|
|
|
|
|
|
|
// The selection layer for tracks
|
|
|
|
int track_selection_layer = -1;
|
|
|
|
|
2021-08-14 00:44:23 +00:00
|
|
|
auto getAnnularRingSelection =
|
|
|
|
[]( const PCB_VIA* via ) -> int
|
|
|
|
{
|
|
|
|
if( !via->GetRemoveUnconnected() )
|
|
|
|
return 0;
|
2022-11-23 13:43:31 +00:00
|
|
|
else if( via->GetKeepStartEnd() )
|
2021-08-14 00:44:23 +00:00
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 2;
|
|
|
|
};
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
// Look for values that are common for every item that is selected
|
2020-05-05 15:40:18 +00:00
|
|
|
for( EDA_ITEM* item : m_items )
|
2017-07-03 17:14:35 +00:00
|
|
|
{
|
2018-08-19 16:11:58 +00:00
|
|
|
if( !nets )
|
2017-07-03 17:14:35 +00:00
|
|
|
{
|
2018-08-19 16:11:58 +00:00
|
|
|
net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode();
|
|
|
|
nets = true;
|
|
|
|
}
|
|
|
|
else if( net != static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode() )
|
|
|
|
{
|
|
|
|
net = -1;
|
2017-07-03 17:14:35 +00:00
|
|
|
}
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
const PCB_TRACK* t = static_cast<const PCB_TRACK*>( item );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
|
|
|
if( !m_tracks ) // first track in the list
|
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
m_trackStartX.SetValue( t->GetStart().x );
|
|
|
|
m_trackStartY.SetValue( t->GetStart().y );
|
|
|
|
m_trackEndX.SetValue( t->GetEnd().x );
|
|
|
|
m_trackEndY.SetValue( t->GetEnd().y );
|
|
|
|
m_trackWidth.SetValue( t->GetWidth() );
|
2023-10-21 18:10:38 +00:00
|
|
|
m_trackDesignRules->SetValue( false );
|
2021-11-24 16:36:10 +00:00
|
|
|
track_selection_layer = t->GetLayer();
|
2018-08-19 16:11:58 +00:00
|
|
|
m_tracks = true;
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
else // check if values are the same for every selected track
|
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackStartX.GetValue() != t->GetStart().x )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackStartX.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackStartY.GetValue() != t->GetStart().y )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackStartY.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackEndX.GetValue() != t->GetEnd().x )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackEndX.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackEndY.GetValue() != t->GetEnd().y )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackEndY.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackWidth.GetValue() != t->GetWidth() )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_trackWidth.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
if( track_selection_layer != t->GetLayer() )
|
|
|
|
track_selection_layer = UNDEFINED_LAYER;
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
if( tracksMatchNetclassValues )
|
|
|
|
{
|
|
|
|
MINOPTMAX<int> constraint = t->GetWidthConstraint();
|
|
|
|
|
|
|
|
if( constraint.HasOpt() )
|
|
|
|
tracksMatchNetclassValues &= constraint.Opt() == t->GetWidth();
|
|
|
|
else if( constraint.Min() > 0 )
|
|
|
|
tracksMatchNetclassValues &= constraint.Min() == t->GetWidth();
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( t->IsLocked() )
|
2016-08-15 15:16:48 +00:00
|
|
|
hasLocked = true;
|
|
|
|
else
|
|
|
|
hasUnlocked = true;
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_VIA_T:
|
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
PCB_VIA* v = static_cast<PCB_VIA*>( item );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
|
|
|
if( !m_vias ) // first via in the list
|
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
m_viaX.SetValue( v->GetPosition().x );
|
|
|
|
m_viaY.SetValue( v->GetPosition().y );
|
|
|
|
m_viaDiameter.SetValue( v->GetWidth() );
|
|
|
|
m_viaDrill.SetValue( v->GetDrillValue() );
|
2015-07-09 11:35:51 +00:00
|
|
|
m_vias = true;
|
2018-01-06 22:32:22 +00:00
|
|
|
viaType = v->GetViaType();
|
2020-12-20 21:29:43 +00:00
|
|
|
m_viaNotFree->SetValue( !v->GetIsFree() );
|
2021-08-14 00:44:23 +00:00
|
|
|
m_annularRingsCtrl->SetSelection( getAnnularRingSelection( v ) );
|
2021-11-24 16:36:10 +00:00
|
|
|
selection_first_layer = v->TopLayer();
|
|
|
|
selection_last_layer = v->BottomLayer();
|
2023-05-12 21:03:54 +00:00
|
|
|
|
|
|
|
m_cbTeardrops->SetValue( v->GetTeardropParams().m_Enabled );
|
|
|
|
m_cbTeardropsUseNextTrack->SetValue( v->GetTeardropParams().m_AllowUseTwoTracks );
|
|
|
|
m_teardropMaxLen.SetValue( v->GetTeardropParams().m_TdMaxLen );
|
|
|
|
m_teardropMaxHeight.SetValue( v->GetTeardropParams().m_TdMaxWidth );
|
|
|
|
m_teardropLenPercent.SetDoubleValue( v->GetTeardropParams().m_BestLengthRatio*100.0 );
|
|
|
|
m_teardropHeightPercent.SetDoubleValue( v->GetTeardropParams().m_BestWidthRatio*100.0 );
|
|
|
|
m_teardropHDPercent.SetDoubleValue( v->GetTeardropParams().m_WidthtoSizeFilterRatio*100.0 );
|
2023-05-23 16:45:26 +00:00
|
|
|
m_curvedEdges->SetValue( v->GetTeardropParams().IsCurved() );
|
|
|
|
m_curvePointsCtrl->SetValue( v->GetTeardropParams().m_CurveSegCount );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
else // check if values are the same for every selected via
|
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaX.GetValue() != v->GetPosition().x )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_viaX.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaY.GetValue() != v->GetPosition().y )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_viaY.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaDiameter.GetValue() != v->GetWidth() )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_viaDiameter.SetValue( INDETERMINATE_STATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaDrill.GetValue() != v->GetDrillValue() )
|
2020-05-05 15:40:18 +00:00
|
|
|
m_viaDrill.SetValue( INDETERMINATE_STATE );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
|
|
|
if( viaType != v->GetViaType() )
|
2019-12-28 00:55:11 +00:00
|
|
|
viaType = VIATYPE::NOT_DEFINED;
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2020-12-20 21:29:43 +00:00
|
|
|
if( v->GetIsFree() != !m_viaNotFree->GetValue() )
|
|
|
|
m_viaNotFree->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
if( selection_first_layer != v->TopLayer() )
|
|
|
|
selection_first_layer = UNDEFINED_LAYER;
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
if( selection_last_layer != v->BottomLayer() )
|
|
|
|
selection_last_layer = UNDEFINED_LAYER;
|
2021-08-14 00:44:23 +00:00
|
|
|
|
|
|
|
if( m_annularRingsCtrl->GetSelection() != getAnnularRingSelection( v ) )
|
|
|
|
{
|
|
|
|
if( m_annularRingsCtrl->GetStrings().size() < 4 )
|
|
|
|
m_annularRingsCtrl->AppendString( INDETERMINATE_STATE );
|
|
|
|
|
|
|
|
m_annularRingsCtrl->SetSelection( 3 );
|
|
|
|
}
|
2023-05-12 21:03:54 +00:00
|
|
|
|
|
|
|
if( m_cbTeardrops->GetValue() != v->GetTeardropParams().m_Enabled )
|
|
|
|
m_cbTeardrops->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
|
|
|
|
if( m_cbTeardropsUseNextTrack->GetValue() != v->GetTeardropParams().m_AllowUseTwoTracks )
|
|
|
|
m_cbTeardropsUseNextTrack->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
|
|
|
|
if( m_teardropMaxLen.GetValue() != v->GetTeardropParams().m_TdMaxLen )
|
|
|
|
m_teardropMaxLen.SetValue( INDETERMINATE_STATE );
|
|
|
|
|
|
|
|
if( m_teardropMaxHeight.GetValue() != v->GetTeardropParams().m_TdMaxWidth )
|
|
|
|
m_teardropMaxHeight.SetValue( INDETERMINATE_STATE );
|
|
|
|
|
|
|
|
if( m_teardropLenPercent.GetDoubleValue() != v->GetTeardropParams().m_BestLengthRatio *100.0 )
|
|
|
|
m_teardropLenPercent.SetValue( INDETERMINATE_STATE );
|
|
|
|
|
|
|
|
if( m_teardropHeightPercent.GetDoubleValue() != v->GetTeardropParams().m_BestWidthRatio *100.0 )
|
|
|
|
m_teardropHeightPercent.SetValue( INDETERMINATE_STATE );
|
|
|
|
|
|
|
|
if( m_teardropHDPercent.GetDoubleValue() != v->GetTeardropParams().m_WidthtoSizeFilterRatio*100.0 )
|
|
|
|
m_teardropHDPercent.SetValue( INDETERMINATE_STATE );
|
|
|
|
|
2023-05-23 16:45:26 +00:00
|
|
|
if( m_curvePointsCtrl->GetValue() != v->GetTeardropParams().m_CurveSegCount )
|
|
|
|
{
|
|
|
|
m_curvedEdges->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
m_curvePointsCtrl->SetValue( 5 );
|
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
if( viasMatchNetclassValues )
|
|
|
|
{
|
|
|
|
MINOPTMAX<int> constraint = v->GetWidthConstraint();
|
|
|
|
|
|
|
|
if( constraint.HasOpt() )
|
|
|
|
viasMatchNetclassValues &= constraint.Opt() == v->GetWidth();
|
|
|
|
else if( constraint.Min() > 0 )
|
|
|
|
viasMatchNetclassValues &= constraint.Min() == v->GetWidth();
|
|
|
|
|
|
|
|
constraint = v->GetDrillConstraint();
|
|
|
|
|
|
|
|
if( constraint.HasOpt() )
|
|
|
|
viasMatchNetclassValues &= constraint.Opt() == v->GetDrillValue();
|
|
|
|
else if( constraint.Min() > 0 )
|
|
|
|
viasMatchNetclassValues &= constraint.Min() == v->GetDrillValue();
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( v->IsLocked() )
|
2016-08-15 15:16:48 +00:00
|
|
|
hasLocked = true;
|
|
|
|
else
|
|
|
|
hasUnlocked = true;
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2018-01-06 22:32:22 +00:00
|
|
|
{
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( false );
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
2018-01-06 22:32:22 +00:00
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
if( m_tracks )
|
|
|
|
{
|
|
|
|
// Set the track layer selection state:
|
|
|
|
if( track_selection_layer == UNDEFINED_LAYER )
|
|
|
|
{
|
|
|
|
m_TrackLayerCtrl->SetUndefinedLayerName( INDETERMINATE_STATE );
|
|
|
|
m_TrackLayerCtrl->Resync();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_TrackLayerCtrl->SetLayerSelection( track_selection_layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the vias layers selections state:
|
|
|
|
if( m_vias )
|
|
|
|
{
|
|
|
|
if( selection_first_layer == UNDEFINED_LAYER )
|
|
|
|
{
|
|
|
|
m_ViaStartLayer->SetUndefinedLayerName( INDETERMINATE_STATE );
|
|
|
|
m_ViaStartLayer->Resync();
|
|
|
|
}
|
2022-11-24 18:05:37 +00:00
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
m_ViaStartLayer->SetLayerSelection( selection_first_layer );
|
|
|
|
|
|
|
|
if( selection_last_layer == UNDEFINED_LAYER )
|
|
|
|
{
|
|
|
|
m_ViaEndLayer->SetUndefinedLayerName( INDETERMINATE_STATE );
|
|
|
|
m_ViaEndLayer->Resync();
|
|
|
|
}
|
2022-11-24 18:05:37 +00:00
|
|
|
|
2021-11-24 16:36:10 +00:00
|
|
|
m_ViaEndLayer->SetLayerSelection( selection_last_layer );
|
|
|
|
}
|
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
m_netSelector->SetBoard( aParent->GetBoard() );
|
|
|
|
m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if ( net >= 0 )
|
2020-05-05 15:40:18 +00:00
|
|
|
{
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->SetSelectedNetcode( net );
|
2020-05-05 15:40:18 +00:00
|
|
|
}
|
2018-08-19 16:11:58 +00:00
|
|
|
else
|
2020-05-05 15:40:18 +00:00
|
|
|
{
|
|
|
|
m_netSelector->SetIndeterminateString( INDETERMINATE_STATE );
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->SetIndeterminate();
|
2020-05-05 15:40:18 +00:00
|
|
|
}
|
2018-08-19 16:11:58 +00:00
|
|
|
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( m_tracks || m_vias );
|
2015-07-15 12:08:50 +00:00
|
|
|
|
|
|
|
if( m_vias )
|
|
|
|
{
|
2022-09-20 10:36:44 +00:00
|
|
|
if( m_viaNotFree->GetValue() && !m_tracks )
|
2021-01-06 15:35:25 +00:00
|
|
|
{
|
2022-09-20 10:36:44 +00:00
|
|
|
// Disable net selector to re-inforce meaning of "Automatically update via nets",
|
|
|
|
// but not when tracks are also selected as then things get harder if you want to
|
|
|
|
// update all the nets to match.
|
2021-01-06 15:35:25 +00:00
|
|
|
m_netSelectorLabel->Disable();
|
|
|
|
m_netSelector->Disable();
|
|
|
|
}
|
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
m_DesignRuleViasUnit->SetLabel( EDA_UNIT_UTILS::GetLabel( m_frame->GetUserUnits() ) );
|
2017-09-18 08:28:08 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
if( viasMatchNetclassValues )
|
|
|
|
{
|
|
|
|
m_viaDesignRules->SetValue( true );
|
2017-09-18 08:28:08 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
m_DesignRuleVias->Enable( false );
|
|
|
|
m_DesignRuleViasCtrl->Enable( false );
|
|
|
|
m_DesignRuleViasUnit->Enable( false );
|
|
|
|
m_viaDiameter.Enable( false );
|
|
|
|
m_viaDrill.Enable( false );
|
|
|
|
}
|
|
|
|
else
|
2017-09-18 08:28:08 +00:00
|
|
|
{
|
2023-11-18 12:17:44 +00:00
|
|
|
int viaSelection = wxNOT_FOUND;
|
|
|
|
|
|
|
|
// 0 is the netclass place-holder
|
|
|
|
for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
|
2017-09-18 08:28:08 +00:00
|
|
|
{
|
2023-11-18 12:17:44 +00:00
|
|
|
VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
|
|
|
|
wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
|
|
|
|
+ wxT( " / " )
|
|
|
|
+ m_frame->StringFromValue( viaDimension->m_Drill );
|
|
|
|
m_DesignRuleViasCtrl->Append( msg, viaDimension );
|
|
|
|
|
|
|
|
if( viaSelection == wxNOT_FOUND
|
|
|
|
&& m_viaDiameter.GetValue() == viaDimension->m_Diameter
|
|
|
|
&& m_viaDrill.GetValue() == viaDimension->m_Drill )
|
|
|
|
{
|
|
|
|
viaSelection = ii - 1;
|
|
|
|
}
|
2017-09-18 08:28:08 +00:00
|
|
|
}
|
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
m_DesignRuleViasCtrl->SetSelection( viaSelection );
|
|
|
|
}
|
2017-09-18 08:28:08 +00:00
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
m_ViaTypeChoice->Enable();
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
switch( viaType )
|
|
|
|
{
|
2021-08-14 00:44:23 +00:00
|
|
|
case VIATYPE::THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
|
|
|
|
case VIATYPE::MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
|
|
|
|
case VIATYPE::BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
|
|
|
|
case VIATYPE::NOT_DEFINED: m_ViaTypeChoice->SetSelection( wxNOT_FOUND ); break;
|
2018-08-19 16:11:58 +00:00
|
|
|
}
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH );
|
|
|
|
m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH );
|
2022-11-24 18:05:37 +00:00
|
|
|
|
|
|
|
m_annularRingsLabel->Show( getLayerDepth() > 1 );
|
|
|
|
m_annularRingsCtrl->Show( getLayerDepth() > 1 );
|
2015-07-15 12:08:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-06 15:35:25 +00:00
|
|
|
m_viaNotFree->Hide();
|
2015-08-18 16:15:57 +00:00
|
|
|
m_MainSizer->Hide( m_sbViaSizer, true );
|
2015-07-15 12:08:50 +00:00
|
|
|
}
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
if( m_tracks )
|
|
|
|
{
|
2022-09-19 09:25:20 +00:00
|
|
|
m_DesignRuleWidthsUnits->SetLabel( EDA_UNIT_UTILS::GetLabel( m_frame->GetUserUnits() ) );
|
2018-08-16 19:58:24 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
if( tracksMatchNetclassValues )
|
2017-08-25 14:46:49 +00:00
|
|
|
{
|
2023-11-18 12:17:44 +00:00
|
|
|
m_trackDesignRules->SetValue( true );
|
2018-08-16 19:58:24 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
m_DesignRuleWidths->Enable( false );
|
|
|
|
m_DesignRuleWidthsCtrl->Enable( false );
|
|
|
|
m_DesignRuleWidthsUnits->Enable( false );
|
|
|
|
m_trackWidth.Enable( false );
|
2017-08-25 14:46:49 +00:00
|
|
|
}
|
2023-11-18 12:17:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
int widthSelection = wxNOT_FOUND;
|
|
|
|
|
|
|
|
// 0 is the netclass place-holder
|
|
|
|
for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
|
|
|
|
{
|
|
|
|
int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
|
|
|
|
wxString msg = m_frame->StringFromValue( width );
|
|
|
|
m_DesignRuleWidthsCtrl->Append( msg );
|
2017-08-25 14:46:49 +00:00
|
|
|
|
2023-11-18 12:17:44 +00:00
|
|
|
if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
|
|
|
|
widthSelection = ii - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_DesignRuleWidthsCtrl->SetSelection( widthSelection );
|
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-18 16:15:57 +00:00
|
|
|
m_MainSizer->Hide( m_sbTrackSizer, true );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( hasLocked && hasUnlocked )
|
2016-08-15 15:16:48 +00:00
|
|
|
m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED );
|
2016-08-15 15:16:53 +00:00
|
|
|
else if( hasLocked )
|
2016-08-15 15:16:48 +00:00
|
|
|
m_lockedCbox->Set3StateValue( wxCHK_CHECKED );
|
|
|
|
else
|
|
|
|
m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2021-11-15 13:02:18 +00:00
|
|
|
if( m_tracks )
|
|
|
|
SetInitialFocus( m_TrackWidthCtrl );
|
|
|
|
else if( m_netSelector->IsEnabled() )
|
|
|
|
SetInitialFocus( m_netSelector );
|
|
|
|
else
|
|
|
|
SetInitialFocus( m_ViaDiameterCtrl );
|
2018-03-06 05:33:04 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
m_frame->Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
|
2022-09-20 10:36:44 +00:00
|
|
|
m_netSelector->Bind( NET_SELECTED, &DIALOG_TRACK_VIA_PROPERTIES::onNetSelector, this );
|
2021-12-23 13:11:26 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-23 13:11:26 +00:00
|
|
|
DIALOG_TRACK_VIA_PROPERTIES::~DIALOG_TRACK_VIA_PROPERTIES()
|
|
|
|
{
|
2023-03-13 16:03:48 +00:00
|
|
|
m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
|
2021-12-23 13:11:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_vias )
|
|
|
|
{
|
|
|
|
int viaSel = m_DesignRuleViasCtrl->GetSelection();
|
|
|
|
|
|
|
|
m_DesignRuleViasCtrl->Clear();
|
|
|
|
|
|
|
|
// 0 is the netclass place-holder
|
|
|
|
for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
|
|
|
|
{
|
|
|
|
VIA_DIMENSION* viaDimension = &m_frame->GetDesignSettings().m_ViasDimensionsList[ii];
|
2022-09-19 09:25:20 +00:00
|
|
|
wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
|
|
|
|
+ wxT( " / " )
|
|
|
|
+ m_frame->StringFromValue( viaDimension->m_Drill );
|
2021-12-23 13:11:26 +00:00
|
|
|
m_DesignRuleViasCtrl->Append( msg, viaDimension );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_DesignRuleViasCtrl->SetSelection( viaSel );
|
2022-09-19 09:25:20 +00:00
|
|
|
m_DesignRuleViasUnit->SetLabel( EDA_UNIT_UTILS::GetLabel( m_frame->GetUserUnits() ) );
|
2021-12-23 13:11:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_tracks )
|
|
|
|
{
|
|
|
|
int trackSel = m_DesignRuleWidthsCtrl->GetSelection();
|
|
|
|
|
|
|
|
m_DesignRuleWidthsCtrl->Clear();
|
|
|
|
|
|
|
|
// 0 is the netclass place-holder
|
|
|
|
for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
|
|
|
|
{
|
2022-09-19 09:25:20 +00:00
|
|
|
int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
|
|
|
|
wxString msg = m_frame->StringFromValue( width );
|
2021-12-23 13:11:26 +00:00
|
|
|
m_DesignRuleWidthsCtrl->Append( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_DesignRuleWidthsCtrl->SetSelection( trackSel );
|
2022-09-19 09:25:20 +00:00
|
|
|
m_DesignRuleWidthsUnits->SetLabel( EDA_UNIT_UTILS::GetLabel( m_frame->GetUserUnits() ) );
|
2021-12-23 13:11:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
2018-08-29 21:42:10 +00:00
|
|
|
if( changingPads.size() == 1 )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* pad = *changingPads.begin();
|
2020-12-27 16:35:07 +00:00
|
|
|
msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
|
2023-06-24 18:54:50 +00:00
|
|
|
pad->GetParentFootprint()->GetReference(),
|
2021-08-23 23:10:21 +00:00
|
|
|
pad->GetNumber(),
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->GetValue() );
|
|
|
|
}
|
2018-08-29 21:42:10 +00:00
|
|
|
else if( changingPads.size() == 2 )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* pad1 = *changingPads.begin();
|
|
|
|
PAD* pad2 = *( ++changingPads.begin() );
|
2020-12-27 16:35:07 +00:00
|
|
|
msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
|
2023-06-24 18:54:50 +00:00
|
|
|
pad1->GetParentFootprint()->GetReference(),
|
2021-08-23 23:10:21 +00:00
|
|
|
pad1->GetNumber(),
|
2023-06-24 18:54:50 +00:00
|
|
|
pad2->GetParentFootprint()->GetReference(),
|
2021-08-23 23:10:21 +00:00
|
|
|
pad2->GetNumber(),
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->GetValue() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-27 16:35:07 +00:00
|
|
|
msg.Printf( _( "Changing the net will also update %lu connected pads to %s." ),
|
2019-06-23 23:40:24 +00:00
|
|
|
static_cast<unsigned long>( changingPads.size() ),
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
|
2020-12-27 16:35:07 +00:00
|
|
|
dlg.SetOKCancelLabels( _( "Change Nets" ), _( "Leave Nets Unchanged" ) );
|
2018-08-29 22:37:20 +00:00
|
|
|
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
|
2018-08-19 16:11:58 +00:00
|
|
|
|
|
|
|
return dlg.ShowModal() == wxID_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow()
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2022-11-24 18:05:37 +00:00
|
|
|
// Check for malformed data ONLY; design rules and constraints are the business of DRC.
|
2018-02-03 09:09:53 +00:00
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if( m_vias )
|
|
|
|
{
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_viaDiameter.Validate( GEOMETRY_MIN_SIZE, INT_MAX )
|
|
|
|
|| !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
|
2023-05-12 21:03:54 +00:00
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
return false;
|
2023-05-12 21:03:54 +00:00
|
|
|
}
|
2018-02-03 09:09:53 +00:00
|
|
|
|
2018-08-31 23:44:00 +00:00
|
|
|
if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
|
|
|
|
&& m_ViaDrillCtrl->IsEnabled() && !m_viaDrill.IsIndeterminate()
|
|
|
|
&& m_viaDiameter.GetValue() <= m_viaDrill.GetValue() )
|
2018-02-03 09:09:53 +00:00
|
|
|
{
|
2021-01-11 13:46:00 +00:00
|
|
|
DisplayError( GetParent(), _( "Via hole size must be smaller than via diameter" ) );
|
2018-02-03 09:09:53 +00:00
|
|
|
m_ViaDrillCtrl->SelectAll();
|
|
|
|
m_ViaDrillCtrl->SetFocus();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-20 19:26:50 +00:00
|
|
|
if( m_ViaStartLayer->GetLayerSelection() != UNDEFINED_LAYER &&
|
|
|
|
m_ViaStartLayer->GetLayerSelection() == m_ViaEndLayer->GetLayerSelection() )
|
2018-02-03 09:09:53 +00:00
|
|
|
{
|
|
|
|
DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_tracks )
|
|
|
|
{
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
|
2018-02-03 09:09:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we survived that, then save the changes:
|
2020-12-27 16:35:07 +00:00
|
|
|
//
|
|
|
|
// We don't bother with updating the nets at this point as it will be useless (any connected
|
|
|
|
// pads will simply drive their existing nets back onto the track segments and vias).
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
|
|
|
|
bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
|
2016-08-15 15:16:48 +00:00
|
|
|
|
2020-11-10 22:07:30 +00:00
|
|
|
for( EDA_ITEM* item : m_items )
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( item );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TRACE_T:
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( m_tracks );
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackStartX.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
t->SetStart( VECTOR2I( m_trackStartX.GetIntValue(), t->GetStart().y ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackStartY.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
t->SetStart( VECTOR2I( t->GetStart().x, m_trackStartY.GetIntValue() ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackEndX.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
t->SetEnd( VECTOR2I( m_trackEndX.GetIntValue(), t->GetEnd().y ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackEndY.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
t->SetEnd( VECTOR2I( t->GetEnd().x, m_trackEndY.GetIntValue() ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2023-10-21 18:10:38 +00:00
|
|
|
if( m_trackDesignRules->IsChecked() )
|
2023-03-06 03:34:32 +00:00
|
|
|
{
|
|
|
|
MINOPTMAX<int> constraint = t->GetWidthConstraint();
|
|
|
|
|
|
|
|
if( constraint.HasOpt() )
|
|
|
|
t->SetWidth( constraint.Opt() );
|
2023-10-21 18:10:38 +00:00
|
|
|
else if( constraint.Min() > 0 )
|
2023-03-06 03:34:32 +00:00
|
|
|
t->SetWidth( constraint.Min() );
|
|
|
|
}
|
2018-02-03 09:09:53 +00:00
|
|
|
else if( !m_trackWidth.IsIndeterminate() )
|
2023-03-06 03:34:32 +00:00
|
|
|
{
|
2023-05-12 21:03:54 +00:00
|
|
|
t->SetWidth( m_trackWidth.GetIntValue() );
|
2023-03-06 03:34:32 +00:00
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
int layer = m_TrackLayerCtrl->GetLayerSelection();
|
2015-07-09 11:35:51 +00:00
|
|
|
|
|
|
|
if( layer != UNDEFINED_LAYER )
|
2017-03-13 03:19:33 +00:00
|
|
|
t->SetLayer( (PCB_LAYER_ID) layer );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2016-08-15 15:16:48 +00:00
|
|
|
if( changeLock )
|
|
|
|
t->SetLocked( setLock );
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_VIA_T:
|
|
|
|
{
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( m_vias );
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* v = static_cast<PCB_VIA*>( item );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-07-21 13:04:30 +00:00
|
|
|
if( !m_viaX.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
v->SetPosition( VECTOR2I( m_viaX.GetIntValue(), v->GetPosition().y ) );
|
2018-07-21 13:04:30 +00:00
|
|
|
|
|
|
|
if( !m_viaY.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
v->SetPosition( VECTOR2I( v->GetPosition().x, m_viaY.GetIntValue() ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2020-12-20 21:29:43 +00:00
|
|
|
if( m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
v->SetIsFree( !m_viaNotFree->GetValue() );
|
|
|
|
|
2020-03-01 19:29:41 +00:00
|
|
|
switch( m_ViaTypeChoice->GetSelection() )
|
2018-01-06 22:32:22 +00:00
|
|
|
{
|
2020-03-01 19:29:41 +00:00
|
|
|
case 0:
|
|
|
|
v->SetViaType( VIATYPE::THROUGH );
|
|
|
|
v->SanitizeLayers();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
v->SetViaType( VIATYPE::MICROVIA );
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
v->SetViaType( VIATYPE::BLIND_BURIED );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2018-01-06 22:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto startLayer = static_cast<PCB_LAYER_ID>( m_ViaStartLayer->GetLayerSelection() );
|
|
|
|
auto endLayer = static_cast<PCB_LAYER_ID>( m_ViaEndLayer->GetLayerSelection() );
|
|
|
|
|
|
|
|
if (startLayer != UNDEFINED_LAYER )
|
|
|
|
v->SetTopLayer( startLayer );
|
|
|
|
|
|
|
|
if (endLayer != UNDEFINED_LAYER )
|
|
|
|
v->SetBottomLayer( endLayer );
|
|
|
|
|
2021-08-14 00:44:23 +00:00
|
|
|
switch( m_annularRingsCtrl->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
v->SetRemoveUnconnected( false );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
v->SetRemoveUnconnected( true );
|
2022-11-23 13:43:31 +00:00
|
|
|
v->SetKeepStartEnd( true );
|
2021-08-14 00:44:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
v->SetRemoveUnconnected( true );
|
2022-11-23 13:43:31 +00:00
|
|
|
v->SetKeepStartEnd( false );
|
2021-08-14 00:44:23 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
v->SanitizeLayers();
|
|
|
|
|
2023-10-21 18:10:38 +00:00
|
|
|
if( m_viaDesignRules->IsChecked() )
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2023-10-21 18:10:38 +00:00
|
|
|
MINOPTMAX<int> constraint = v->GetWidthConstraint();
|
2022-08-14 11:03:18 +00:00
|
|
|
|
2023-10-21 18:10:38 +00:00
|
|
|
if( constraint.HasOpt() )
|
|
|
|
v->SetWidth( constraint.Opt() );
|
|
|
|
else if( constraint.Min() > 0 )
|
|
|
|
v->SetWidth( constraint.Min() );
|
|
|
|
|
|
|
|
constraint = v->GetDrillConstraint();
|
|
|
|
|
|
|
|
if( constraint.HasOpt() )
|
|
|
|
v->SetDrill( constraint.Opt() );
|
|
|
|
else if( constraint.Min() > 0 )
|
|
|
|
v->SetDrill( constraint.Min() );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_viaDiameter.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
v->SetWidth( m_viaDiameter.GetIntValue() );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_viaDrill.IsIndeterminate() )
|
2023-05-12 21:03:54 +00:00
|
|
|
v->SetDrill( m_viaDrill.GetIntValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
TEARDROP_PARAMETERS* targetParams = &v->GetTeardropParams();
|
|
|
|
|
|
|
|
if( m_cbTeardrops->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
targetParams->m_Enabled = m_cbTeardrops->GetValue();
|
|
|
|
|
|
|
|
if( m_cbTeardropsUseNextTrack->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
targetParams->m_AllowUseTwoTracks = m_cbTeardropsUseNextTrack->GetValue();
|
|
|
|
|
|
|
|
if( !m_teardropMaxLen.IsIndeterminate() )
|
|
|
|
targetParams->m_TdMaxLen = m_teardropMaxLen.GetIntValue();
|
|
|
|
|
|
|
|
if( !m_teardropMaxHeight.IsIndeterminate() )
|
|
|
|
targetParams->m_TdMaxWidth = m_teardropMaxHeight.GetIntValue();
|
|
|
|
|
|
|
|
if( !m_teardropLenPercent.IsIndeterminate() )
|
|
|
|
targetParams->m_BestLengthRatio = m_teardropLenPercent.GetDoubleValue() / 100.0;
|
|
|
|
|
|
|
|
if( !m_teardropHeightPercent.IsIndeterminate() )
|
|
|
|
targetParams->m_BestWidthRatio = m_teardropHeightPercent.GetDoubleValue() / 100.0;
|
|
|
|
|
|
|
|
if( !m_teardropHDPercent.IsIndeterminate() )
|
|
|
|
targetParams->m_WidthtoSizeFilterRatio = m_teardropHDPercent.GetDoubleValue() / 100.0;
|
|
|
|
|
2023-05-23 16:45:26 +00:00
|
|
|
if( m_curvedEdges->Get3StateValue() != wxCHK_UNDETERMINED )
|
2023-05-12 21:03:54 +00:00
|
|
|
{
|
2023-05-23 16:45:26 +00:00
|
|
|
if( m_curvedEdges->GetValue() )
|
|
|
|
targetParams->m_CurveSegCount = m_curvePointsCtrl->GetValue();
|
|
|
|
else
|
|
|
|
targetParams->m_CurveSegCount = 0;
|
2017-07-03 17:14:35 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:48 +00:00
|
|
|
if( changeLock )
|
|
|
|
v->SetLocked( setLock );
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( false );
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Edit track/via properties" ) );
|
2020-12-27 16:35:07 +00:00
|
|
|
|
|
|
|
// Pushing the commit will have updated the connectivity so we can now test to see if we
|
|
|
|
// need to update any pad nets.
|
|
|
|
|
|
|
|
auto connectivity = m_frame->GetBoard()->GetConnectivity();
|
|
|
|
int newNetCode = m_netSelector->GetSelectedNetcode();
|
|
|
|
bool updateNets = false;
|
|
|
|
std::vector<PAD*> changingPads;
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if ( !m_netSelector->IsIndeterminate() )
|
|
|
|
{
|
2020-12-27 16:35:07 +00:00
|
|
|
updateNets = true;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : m_items )
|
|
|
|
{
|
|
|
|
BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
|
2022-03-03 23:49:05 +00:00
|
|
|
auto connectedItems = connectivity->GetConnectedItems( boardItem,
|
|
|
|
{ PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_VIA_T, PCB_FOOTPRINT_T }, true );
|
2020-12-27 16:35:07 +00:00
|
|
|
|
|
|
|
for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
|
|
|
|
{
|
|
|
|
if( citem->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
PAD* pad = static_cast<PAD*>( citem );
|
|
|
|
|
|
|
|
if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
|
|
|
|
changingPads.push_back( pad );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( changingPads.size() && !confirmPadChange( changingPads ) )
|
|
|
|
updateNets = false;
|
|
|
|
|
|
|
|
if( updateNets )
|
|
|
|
{
|
|
|
|
for( EDA_ITEM* item : m_items )
|
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( item );
|
2020-12-27 16:35:07 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_ARC_T:
|
2021-06-11 21:07:02 +00:00
|
|
|
static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
|
2020-12-27 16:35:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_VIA_T:
|
2021-06-11 21:07:02 +00:00
|
|
|
static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
|
2020-12-27 16:35:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxASSERT( false );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : changingPads )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Modify( pad );
|
2020-12-27 16:35:07 +00:00
|
|
|
pad->SetNetCode( newNetCode );
|
2018-08-19 16:11:58 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 15:52:50 +00:00
|
|
|
commit.Push( _( "Updating nets" ) );
|
2020-12-27 16:35:07 +00:00
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
return true;
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-20 10:36:44 +00:00
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onNetSelector( wxCommandEvent& aEvent )
|
2021-01-06 15:35:25 +00:00
|
|
|
{
|
2022-09-20 10:36:44 +00:00
|
|
|
m_viaNotFree->SetValue( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onViaNotFreeClicked( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( !m_tracks )
|
|
|
|
{
|
|
|
|
m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
|
|
|
|
m_netSelector->Enable( !m_viaNotFree->GetValue() );
|
|
|
|
}
|
2021-01-06 15:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onTrackNetclassCheck( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
bool enableNC = aEvent.IsChecked();
|
|
|
|
|
2018-08-16 19:58:24 +00:00
|
|
|
m_DesignRuleWidths->Enable( !enableNC );
|
|
|
|
m_DesignRuleWidthsCtrl->Enable( !enableNC );
|
|
|
|
m_DesignRuleWidthsUnits->Enable( !enableNC );
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_trackWidth.Enable( !enableNC );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-16 19:58:24 +00:00
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_TrackWidthCtrl->ChangeValue( m_DesignRuleWidthsCtrl->GetStringSelection() );
|
2019-08-25 10:06:01 +00:00
|
|
|
m_TrackWidthCtrl->SelectAll();
|
2018-08-16 19:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
|
|
|
|
{
|
2019-08-25 10:06:01 +00:00
|
|
|
m_DesignRuleWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
|
2018-08-16 19:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onViaNetclassCheck( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
bool enableNC = aEvent.IsChecked();
|
|
|
|
|
2017-09-18 08:28:08 +00:00
|
|
|
m_DesignRuleVias->Enable( !enableNC );
|
|
|
|
m_DesignRuleViasCtrl->Enable( !enableNC );
|
|
|
|
m_DesignRuleViasUnit->Enable( !enableNC );
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_viaDiameter.Enable( !enableNC );
|
|
|
|
m_viaDrill.Enable( !enableNC );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-18 08:28:08 +00:00
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
|
|
|
|
|
2018-10-09 18:11:19 +00:00
|
|
|
m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
|
|
|
|
m_viaDrill.ChangeValue( viaDimension->m_Drill );
|
2017-09-18 08:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-24 18:05:37 +00:00
|
|
|
int DIALOG_TRACK_VIA_PROPERTIES::getLayerDepth()
|
|
|
|
{
|
|
|
|
int viaType = m_ViaTypeChoice->GetSelection();
|
|
|
|
|
|
|
|
if( viaType <= 0 )
|
|
|
|
return m_frame->GetBoard()->GetCopperLayerCount() - 1;
|
|
|
|
|
|
|
|
int startLayer = m_ViaStartLayer->GetLayerSelection();
|
|
|
|
int endLayer = m_ViaEndLayer->GetLayerSelection();
|
|
|
|
|
|
|
|
if( startLayer < 0 || endLayer < 0 )
|
|
|
|
return m_frame->GetBoard()->GetCopperLayerCount() - 1;
|
|
|
|
else
|
|
|
|
return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-18 08:28:08 +00:00
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_DesignRuleViasCtrl->SetSelection( wxNOT_FOUND );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
|
|
|
if( m_vias )
|
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
|
2018-01-06 22:32:22 +00:00
|
|
|
{
|
|
|
|
m_ViaStartLayer->Enable();
|
|
|
|
m_ViaEndLayer->Enable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ViaStartLayer->SetLayerSelection( F_Cu );
|
|
|
|
m_ViaEndLayer->SetLayerSelection( B_Cu );
|
|
|
|
|
|
|
|
m_ViaStartLayer->Enable( false );
|
|
|
|
m_ViaEndLayer->Enable( false );
|
|
|
|
}
|
2022-11-24 18:05:37 +00:00
|
|
|
|
|
|
|
m_annularRingsLabel->Show( getLayerDepth() > 1 );
|
|
|
|
m_annularRingsCtrl->Show( getLayerDepth() > 1 );
|
2018-01-06 22:32:22 +00:00
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
2023-05-12 21:03:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onTeardropsUpdateUi( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
event.Enable( !m_frame->GetBoard()->LegacyTeardrops() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onCurvedEdgesUpdateUi( wxUpdateUIEvent& event )
|
|
|
|
{
|
2023-05-23 16:45:26 +00:00
|
|
|
event.Enable( !m_frame->GetBoard()->LegacyTeardrops()
|
|
|
|
&& m_curvedEdges->Get3StateValue() == wxCHK_CHECKED );
|
2023-10-21 18:56:19 +00:00
|
|
|
}
|