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
|
2018-08-19 16:11:58 +00:00
|
|
|
* Copyright (C) 2018 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <dialogs/dialog_track_via_properties.h>
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
2015-07-09 11:35:51 +00:00
|
|
|
#include <tools/selection_tool.h>
|
|
|
|
#include <class_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>
|
2018-08-19 16:11:58 +00:00
|
|
|
#include <class_module.h>
|
|
|
|
#include <widgets/net_selector.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent,
|
2019-06-09 21:57:23 +00:00
|
|
|
const PCBNEW_SELECTION& aItems,
|
2018-02-03 09:09:53 +00:00
|
|
|
COMMIT& aCommit ) :
|
|
|
|
DIALOG_TRACK_VIA_PROPERTIES_BASE( aParent ),
|
2018-08-19 16:11:58 +00:00
|
|
|
m_frame( aParent ),
|
|
|
|
m_items( aItems ),
|
|
|
|
m_commit( aCommit ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, m_TrackStartXUnit ),
|
|
|
|
m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
|
|
|
|
m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, m_TrackEndXUnit ),
|
|
|
|
m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
|
2018-11-29 18:59:38 +00:00
|
|
|
m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit, true ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, m_ViaXUnit ),
|
|
|
|
m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
|
2018-11-29 18:59:38 +00:00
|
|
|
m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit, true ),
|
|
|
|
m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit, true ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_tracks( false ),
|
|
|
|
m_vias( false )
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( !m_items.Empty() );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
VIATYPE_T viaType = VIA_NOT_DEFINED;
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
|
2017-07-03 17:14:35 +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;
|
2016-08-15 15:16:48 +00:00
|
|
|
bool hasLocked = false;
|
|
|
|
bool hasUnlocked = false;
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
// Look for values that are common for every item that is selected
|
2017-07-03 17:14:35 +00:00
|
|
|
for( auto& item : m_items )
|
|
|
|
{
|
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:
|
|
|
|
{
|
|
|
|
const TRACK* t = static_cast<const TRACK*>( item );
|
|
|
|
|
|
|
|
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() );
|
|
|
|
m_TrackLayerCtrl->SetLayerSelection( 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 )
|
|
|
|
m_trackStartX.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackStartY.GetValue() != t->GetStart().y )
|
|
|
|
m_trackStartY.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackEndX.GetValue() != t->GetEnd().x )
|
|
|
|
m_trackEndX.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackEndY.GetValue() != t->GetEnd().y )
|
|
|
|
m_trackEndY.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_trackWidth.GetValue() != t->GetWidth() )
|
|
|
|
m_trackWidth.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_TrackLayerCtrl->GetLayerSelection() != t->GetLayer() )
|
|
|
|
m_TrackLayerCtrl->SetLayerSelection( UNDEFINED_LAYER );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
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:
|
|
|
|
{
|
|
|
|
const VIA* v = static_cast<const VIA*>( item );
|
|
|
|
|
|
|
|
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();
|
2018-02-03 09:09:53 +00:00
|
|
|
m_ViaStartLayer->SetLayerSelection( v->TopLayer() );
|
|
|
|
m_ViaEndLayer->SetLayerSelection( v->BottomLayer() );
|
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 )
|
|
|
|
m_viaX.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaY.GetValue() != v->GetPosition().y )
|
|
|
|
m_viaY.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaDiameter.GetValue() != v->GetWidth() )
|
|
|
|
m_viaDiameter.SetValue( INDETERMINATE );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_viaDrill.GetValue() != v->GetDrillValue() )
|
|
|
|
m_viaDrill.SetValue( INDETERMINATE );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
|
|
|
if( viaType != v->GetViaType() )
|
|
|
|
viaType = VIA_NOT_DEFINED;
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_ViaStartLayer->GetLayerSelection() != v->TopLayer() )
|
|
|
|
m_ViaStartLayer->SetLayerSelection( UNDEFINED_LAYER );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_ViaEndLayer->GetLayerSelection() != v->BottomLayer() )
|
|
|
|
m_ViaEndLayer->SetLayerSelection( UNDEFINED_LAYER );
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
2016-08-15 15:16:48 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if ( net >= 0 )
|
|
|
|
m_netSelector->SetSelectedNetcode( net );
|
|
|
|
else
|
|
|
|
m_netSelector->SetIndeterminate();
|
|
|
|
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( m_tracks || m_vias );
|
2015-07-15 12:08:50 +00:00
|
|
|
|
|
|
|
if( m_vias )
|
|
|
|
{
|
2018-09-15 21:45:20 +00:00
|
|
|
m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_units, true ) );
|
2017-09-18 08:28:08 +00:00
|
|
|
|
|
|
|
int viaSelection = wxNOT_FOUND;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
|
|
|
|
{
|
|
|
|
VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
|
2018-07-22 16:02:24 +00:00
|
|
|
wxString msg = StringFromValue( m_units, viaDimension->m_Diameter, false, true )
|
|
|
|
+ " / " + StringFromValue( m_units, viaDimension->m_Drill, false, true );
|
2017-09-18 08:28:08 +00:00
|
|
|
m_DesignRuleViasCtrl->Append( msg, viaDimension );
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( viaSelection == wxNOT_FOUND
|
|
|
|
&& m_viaDiameter.GetValue() == viaDimension->m_Diameter
|
|
|
|
&& m_viaDrill.GetValue() == viaDimension->m_Drill )
|
2017-09-18 08:28:08 +00:00
|
|
|
{
|
|
|
|
viaSelection = ii;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_DesignRuleViasCtrl->SetSelection( viaSelection );
|
|
|
|
|
|
|
|
m_DesignRuleViasCtrl->Connect( wxEVT_CHOICE, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onViaSelect ), NULL, this );
|
|
|
|
m_ViaDiameterCtrl->Connect( wxEVT_TEXT, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onViaEdit ), NULL, this );
|
|
|
|
m_ViaDrillCtrl->Connect( wxEVT_TEXT, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onViaEdit ), NULL, this );
|
2018-01-06 22:32:22 +00:00
|
|
|
m_ViaTypeChoice->Connect( wxEVT_CHOICE, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onViaEdit ), NULL, this );
|
2017-09-18 08:28:08 +00:00
|
|
|
|
2018-07-20 19:26:50 +00:00
|
|
|
SetInitialFocus( m_ViaDiameterCtrl );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
|
|
|
m_ViaTypeChoice->Enable();
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
switch( viaType )
|
|
|
|
{
|
|
|
|
case VIA_THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
|
|
|
|
case VIA_MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
|
|
|
|
case VIA_BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
|
|
|
|
case VIA_NOT_DEFINED: m_ViaTypeChoice->SetSelection( 3 ); break;
|
|
|
|
}
|
2018-01-06 22:32:22 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_ViaStartLayer->Enable( viaType != VIA_THROUGH );
|
|
|
|
m_ViaEndLayer->Enable( viaType != VIA_THROUGH );
|
2015-07-15 12:08:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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 )
|
|
|
|
{
|
2018-09-15 21:45:20 +00:00
|
|
|
m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units, true ) );
|
2018-08-16 19:58:24 +00:00
|
|
|
|
|
|
|
int widthSelection = wxNOT_FOUND;
|
|
|
|
|
2017-08-25 14:46:49 +00:00
|
|
|
for( unsigned ii = 0; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
|
|
|
|
{
|
|
|
|
int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
|
2018-07-22 16:02:24 +00:00
|
|
|
wxString msg = StringFromValue( m_units, width, false, true );
|
2018-08-16 19:58:24 +00:00
|
|
|
m_DesignRuleWidthsCtrl->Append( msg );
|
|
|
|
|
|
|
|
if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
|
|
|
|
widthSelection = ii;
|
2017-08-25 14:46:49 +00:00
|
|
|
}
|
|
|
|
|
2018-08-16 19:58:24 +00:00
|
|
|
m_DesignRuleWidthsCtrl->SetSelection( widthSelection );
|
|
|
|
|
|
|
|
m_DesignRuleWidthsCtrl->Connect( wxEVT_CHOICE, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect ), NULL, this );
|
|
|
|
m_TrackWidthCtrl->Connect( wxEVT_TEXT, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit ), NULL, this );
|
|
|
|
|
2018-07-20 19:26:50 +00:00
|
|
|
SetInitialFocus( m_TrackWidthCtrl );
|
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
|
|
|
|
2019-03-28 16:52:23 +00:00
|
|
|
SetInitialFocus( m_tracks ? m_TrackWidthCtrl : m_ViaDiameterCtrl );
|
2018-03-06 05:33:04 +00:00
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
m_StdButtonsOK->SetDefault();
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-29 21:42:10 +00:00
|
|
|
bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<D_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
|
|
|
{
|
2018-08-29 21:42:10 +00:00
|
|
|
D_PAD* pad = *changingPads.begin();
|
2018-08-19 16:11:58 +00:00
|
|
|
msg.Printf( _( "This will change the net assigned to %s pad %s to %s.\n"
|
|
|
|
"Do you wish to continue?" ),
|
|
|
|
pad->GetParent()->GetReference(),
|
|
|
|
pad->GetName(),
|
|
|
|
m_netSelector->GetValue() );
|
|
|
|
}
|
2018-08-29 21:42:10 +00:00
|
|
|
else if( changingPads.size() == 2 )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
2018-08-29 21:42:10 +00:00
|
|
|
D_PAD* pad1 = *changingPads.begin();
|
|
|
|
D_PAD* pad2 = *( ++changingPads.begin() );
|
2018-08-19 16:11:58 +00:00
|
|
|
msg.Printf( _( "This will change the net assigned to %s pad %s and %s pad %s to %s.\n"
|
|
|
|
"Do you wish to continue?" ),
|
|
|
|
pad1->GetParent()->GetReference(),
|
|
|
|
pad1->GetName(),
|
|
|
|
pad2->GetParent()->GetReference(),
|
|
|
|
pad2->GetName(),
|
|
|
|
m_netSelector->GetValue() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.Printf( _( "This will change the net assigned to %d connected pads to %s.\n"
|
|
|
|
"Do you wish to continue?" ),
|
2018-08-29 21:42:10 +00:00
|
|
|
changingPads.size(),
|
2018-08-19 16:11:58 +00:00
|
|
|
m_netSelector->GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
|
|
|
|
dlg.SetOKLabel( _( "Continue" ) );
|
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
|
|
|
{
|
2018-08-19 16:11:58 +00:00
|
|
|
auto connectivity = m_frame->GetBoard()->GetConnectivity();
|
2018-08-29 21:42:10 +00:00
|
|
|
int newNetCode = m_netSelector->GetSelectedNetcode();
|
|
|
|
std::vector<D_PAD*> changingPads;
|
2018-08-19 16:11:58 +00:00
|
|
|
|
|
|
|
if ( !m_netSelector->IsIndeterminate() )
|
|
|
|
{
|
2018-08-29 21:42:10 +00:00
|
|
|
std::set<D_PAD*> connectedPads;
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
for( auto& item : m_items )
|
|
|
|
{
|
2019-01-18 01:50:50 +00:00
|
|
|
const KICAD_T ourTypes[] = { PCB_TRACE_T, PCB_PAD_T, PCB_VIA_T, PCB_MODULE_T, EOT };
|
|
|
|
auto connectedItems = connectivity->GetConnectedItems( static_cast<BOARD_CONNECTED_ITEM*>( item ), ourTypes, true );
|
|
|
|
for ( auto citem : connectedItems )
|
|
|
|
{
|
|
|
|
if( citem->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
connectedPads.insert( static_cast<D_PAD*>( citem ) );
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 16:11:58 +00:00
|
|
|
}
|
2018-08-29 21:42:10 +00:00
|
|
|
|
|
|
|
for( D_PAD* pad : connectedPads )
|
|
|
|
{
|
|
|
|
if( pad->GetNetCode() != newNetCode )
|
|
|
|
changingPads.push_back( pad );
|
|
|
|
}
|
2018-08-19 16:11:58 +00:00
|
|
|
}
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
// Run validations:
|
|
|
|
|
2018-08-29 21:42:10 +00:00
|
|
|
if( changingPads.size() )
|
2018-02-03 09:09:53 +00:00
|
|
|
{
|
2018-08-29 21:42:10 +00:00
|
|
|
if( !confirmPadChange( changingPads ) )
|
2018-02-03 09:09:53 +00:00
|
|
|
return false;
|
2018-08-19 16:11:58 +00:00
|
|
|
}
|
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 ) )
|
2018-02-03 09:09:53 +00:00
|
|
|
return false;
|
|
|
|
|
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
|
|
|
{
|
|
|
|
DisplayError( GetParent(), _( "Via drill size must be smaller than via diameter" ) );
|
|
|
|
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:
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2016-08-15 15:16:48 +00:00
|
|
|
bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
|
|
|
|
bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
for( auto item : m_items )
|
2015-07-09 11:35:51 +00:00
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
m_commit.Modify( item );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_TRACE_T:
|
|
|
|
{
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( m_tracks );
|
2015-07-09 11:35:51 +00:00
|
|
|
TRACK* t = static_cast<TRACK*>( item );
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackStartX.IsIndeterminate() )
|
|
|
|
t->SetStart( wxPoint( m_trackStartX.GetValue(), t->GetStart().y ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackStartY.IsIndeterminate() )
|
|
|
|
t->SetStart( wxPoint( t->GetStart().x, m_trackStartY.GetValue() ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackEndX.IsIndeterminate() )
|
|
|
|
t->SetEnd( wxPoint( m_trackEndX.GetValue(), t->GetEnd().y ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_trackEndY.IsIndeterminate() )
|
|
|
|
t->SetEnd( wxPoint( t->GetEnd().x, m_trackEndY.GetValue() ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
|
|
|
if( m_trackNetclass->IsChecked() )
|
|
|
|
t->SetWidth( t->GetNetClass()->GetTrackWidth() );
|
2018-02-03 09:09:53 +00:00
|
|
|
else if( !m_trackWidth.IsIndeterminate() )
|
2015-07-09 11:35:51 +00:00
|
|
|
t->SetWidth( m_trackWidth.GetValue() );
|
|
|
|
|
|
|
|
LAYER_NUM layer = m_TrackLayerCtrl->GetLayerSelection();
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if ( !m_netSelector->IsIndeterminate() )
|
|
|
|
t->SetNetCode( m_netSelector->GetSelectedNetcode() );
|
2017-07-03 17:14:35 +00:00
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PCB_VIA_T:
|
|
|
|
{
|
2017-08-11 09:38:06 +00:00
|
|
|
wxASSERT( m_vias );
|
2015-07-09 11:35:51 +00:00
|
|
|
VIA* v = static_cast<VIA*>( item );
|
|
|
|
|
2018-07-21 13:04:30 +00:00
|
|
|
if( !m_viaX.IsIndeterminate() )
|
|
|
|
v->SetPosition( wxPoint( m_viaX.GetValue(), v->GetPosition().y ) );
|
|
|
|
|
|
|
|
if( !m_viaY.IsIndeterminate() )
|
|
|
|
v->SetPosition( wxPoint( v->GetPosition().x, m_viaY.GetValue() ) );
|
2015-07-09 11:35:51 +00:00
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
if( m_ViaTypeChoice->GetSelection() != 3)
|
|
|
|
{
|
|
|
|
switch( m_ViaTypeChoice->GetSelection() )
|
|
|
|
{
|
2018-08-19 16:11:58 +00:00
|
|
|
default:
|
|
|
|
case 0: v->SetViaType( VIA_THROUGH ); v->SanitizeLayers(); break;
|
|
|
|
case 1: v->SetViaType( VIA_MICROVIA ); break;
|
|
|
|
case 2: v->SetViaType( VIA_BLIND_BURIED ); 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 );
|
|
|
|
|
|
|
|
v->SanitizeLayers();
|
|
|
|
|
2015-07-09 11:35:51 +00:00
|
|
|
if( m_viaNetclass->IsChecked() )
|
|
|
|
{
|
2016-08-25 00:28:57 +00:00
|
|
|
switch( v->GetViaType() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG("Unhandled via type");
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case VIA_THROUGH:
|
|
|
|
case VIA_BLIND_BURIED:
|
|
|
|
v->SetWidth( v->GetNetClass()->GetViaDiameter() );
|
|
|
|
v->SetDrill( v->GetNetClass()->GetViaDrill() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_MICROVIA:
|
|
|
|
v->SetWidth( v->GetNetClass()->GetuViaDiameter() );
|
|
|
|
v->SetDrill( v->GetNetClass()->GetuViaDrill() );
|
|
|
|
break;
|
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_viaDiameter.IsIndeterminate() )
|
2015-07-09 11:35:51 +00:00
|
|
|
v->SetWidth( m_viaDiameter.GetValue() );
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !m_viaDrill.IsIndeterminate() )
|
2015-07-09 11:35:51 +00:00
|
|
|
v->SetDrill( m_viaDrill.GetValue() );
|
2017-07-03 17:14:35 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if ( !m_netSelector->IsIndeterminate() )
|
|
|
|
v->SetNetCode( m_netSelector->GetSelectedNetcode() );
|
2015-07-09 11:35:51 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
if ( !m_netSelector->IsIndeterminate() )
|
|
|
|
{
|
|
|
|
// Commit::Push() will rebuild connectivitiy propagating nets from connected pads
|
|
|
|
// outwards. We therefore have to update the connected pads in order for the net
|
|
|
|
// change to "stick".
|
2018-08-29 21:42:10 +00:00
|
|
|
for( D_PAD* pad : changingPads )
|
2018-08-19 16:11:58 +00:00
|
|
|
{
|
|
|
|
m_commit.Modify( pad );
|
|
|
|
pad->SetNetCode( m_netSelector->GetSelectedNetcode() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_commit.Push( _( "Edit track/via properties" ) );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_DesignRuleWidthsCtrl->SetSelection( wxNOT_FOUND );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_DesignRuleViasCtrl->SetSelection( wxNOT_FOUND );
|
2018-01-06 22:32:22 +00:00
|
|
|
|
|
|
|
if( m_vias )
|
|
|
|
{
|
|
|
|
if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isnt through.
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
2015-07-09 11:35:51 +00:00
|
|
|
}
|