2014-10-23 17:53:38 +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) 2007-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-08-18 14:17:16 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-23 17:53:38 +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
|
|
|
|
*/
|
|
|
|
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2019-05-28 23:23:58 +00:00
|
|
|
#include <pcbnew_id.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-08-31 22:32:11 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2023-04-09 21:59:01 +00:00
|
|
|
#include <wx/choice.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
void PCB_EDIT_FRAME::SetTrackSegmentWidth( PCB_TRACK* aTrackItem,
|
2020-08-31 15:50:24 +00:00
|
|
|
PICKED_ITEMS_LIST* aItemsListPicker,
|
|
|
|
bool aUseNetclassValue )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-12-08 12:30:07 +00:00
|
|
|
int initial_width;
|
|
|
|
int new_width;
|
|
|
|
int initial_drill = -1;
|
|
|
|
int new_drill = -1;
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
initial_width = aTrackItem->GetWidth();
|
2010-12-05 16:24:08 +00:00
|
|
|
|
2020-12-08 12:30:07 +00:00
|
|
|
if( aUseNetclassValue )
|
2022-08-14 11:03:18 +00:00
|
|
|
new_width = aTrackItem->GetEffectiveNetClass()->GetTrackWidth();
|
2009-10-10 17:27:53 +00:00
|
|
|
else
|
2014-05-13 09:22:51 +00:00
|
|
|
new_width = GetDesignSettings().GetCurrentTrackWidth();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( aTrackItem->Type() == PCB_VIA_T )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
const PCB_VIA *via = static_cast<const PCB_VIA*>( aTrackItem );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2020-12-08 12:30:07 +00:00
|
|
|
// Get the drill value, regardless it is default or specific
|
2015-06-18 13:19:30 +00:00
|
|
|
initial_drill = via->GetDrillValue();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2022-12-16 00:08:29 +00:00
|
|
|
if( via->GetViaType() == VIATYPE::MICROVIA )
|
|
|
|
{
|
|
|
|
new_width = aTrackItem->GetEffectiveNetClass()->GetuViaDiameter();
|
|
|
|
new_drill = aTrackItem->GetEffectiveNetClass()->GetuViaDrill();
|
|
|
|
}
|
|
|
|
else if( aUseNetclassValue )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2022-08-14 11:03:18 +00:00
|
|
|
new_width = aTrackItem->GetEffectiveNetClass()->GetViaDiameter();
|
|
|
|
new_drill = aTrackItem->GetEffectiveNetClass()->GetViaDrill();
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2009-10-10 17:27:53 +00:00
|
|
|
else
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
2014-05-13 09:22:51 +00:00
|
|
|
new_width = GetDesignSettings().GetCurrentViaSize();
|
|
|
|
new_drill = GetDesignSettings().GetCurrentViaDrill();
|
2009-10-30 17:58:15 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
// Old versions set a drill value <= 0, when the default netclass it used but it could
|
|
|
|
// be better to set the drill value to the actual value to avoid issues for existing vias,
|
|
|
|
// if the default drill value is modified in the netclass, and not in current vias.
|
2015-06-19 08:55:37 +00:00
|
|
|
if( via->GetDrill() <= 0 ) // means default netclass drill value used
|
2015-06-18 13:19:30 +00:00
|
|
|
initial_drill = -1; // Force drill vias re-initialization
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-11 16:21:43 +00:00
|
|
|
if( initial_width != new_width || initial_drill != new_drill )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
|
|
|
if( aItemsListPicker )
|
|
|
|
{
|
2013-01-13 00:04:00 +00:00
|
|
|
aTrackItem->SetWidth( initial_width );
|
2020-08-26 18:04:32 +00:00
|
|
|
ITEM_PICKER picker( nullptr, aTrackItem, UNDO_REDO::CHANGED );
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetLink( aTrackItem->Clone() );
|
2009-08-08 06:07:08 +00:00
|
|
|
aItemsListPicker->PushItem( picker );
|
2013-01-13 00:04:00 +00:00
|
|
|
aTrackItem->SetWidth( new_width );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( aTrackItem->Type() == PCB_VIA_T )
|
2010-12-05 16:24:08 +00:00
|
|
|
{
|
|
|
|
// Set new drill value. Note: currently microvias have only a default drill value
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA *via = static_cast<PCB_VIA*>( aTrackItem );
|
2020-12-08 12:30:07 +00:00
|
|
|
|
2010-12-05 16:24:08 +00:00
|
|
|
if( new_drill > 0 )
|
2014-04-25 06:00:04 +00:00
|
|
|
via->SetDrill( new_drill );
|
2010-12-05 16:24:08 +00:00
|
|
|
else
|
2014-04-25 06:00:04 +00:00
|
|
|
via->SetDrillDefault();
|
2010-12-05 16:24:08 +00:00
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-05-28 23:23:58 +00:00
|
|
|
int ii;
|
|
|
|
int id = event.GetId();
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
switch( id )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2019-05-28 23:23:58 +00:00
|
|
|
case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH:
|
2021-12-09 23:07:05 +00:00
|
|
|
{
|
|
|
|
if( GetDesignSettings().UseCustomTrackViaSize() )
|
|
|
|
{
|
|
|
|
GetDesignSettings().UseCustomTrackViaSize( false );
|
|
|
|
GetDesignSettings().m_UseConnectedTrackWidth = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetDesignSettings().m_UseConnectedTrackWidth =
|
|
|
|
not GetDesignSettings().m_UseConnectedTrackWidth;
|
|
|
|
}
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
break;
|
2021-12-09 23:07:05 +00:00
|
|
|
}
|
2019-05-28 23:23:58 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES:
|
|
|
|
GetDesignSettings().m_UseConnectedTrackWidth = false;
|
|
|
|
GetDesignSettings().SetTrackWidthIndex( 0 );
|
|
|
|
GetDesignSettings().SetViaSizeIndex( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_SELECT_AUTO_WIDTH:
|
|
|
|
GetDesignSettings().m_UseConnectedTrackWidth = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH1: // this is the default Netclass selection
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH2: // this is a custom value selection
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH3:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH4:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH5:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH6:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH7:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH8:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH9:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH10:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH11:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH12:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH13:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH14:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH15:
|
|
|
|
case ID_POPUP_PCB_SELECT_WIDTH16:
|
|
|
|
GetDesignSettings().m_UseConnectedTrackWidth = false;
|
|
|
|
ii = id - ID_POPUP_PCB_SELECT_WIDTH1;
|
|
|
|
GetDesignSettings().SetTrackWidthIndex( ii );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE1: // this is the default Netclass selection
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE2: // this is a custom value selection
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE3:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE4:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE5:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE6:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE7:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE8:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE9:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE10:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE11:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE12:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE13:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE14:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE15:
|
|
|
|
case ID_POPUP_PCB_SELECT_VIASIZE16:
|
|
|
|
// select the new current value for via size (via diameter)
|
|
|
|
ii = id - ID_POPUP_PCB_SELECT_VIASIZE1;
|
|
|
|
GetDesignSettings().SetViaSizeIndex( ii );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH:
|
|
|
|
ii = m_SelTrackWidthBox->GetSelection();
|
|
|
|
|
|
|
|
if( ii == int( m_SelTrackWidthBox->GetCount() - 2 ) )
|
|
|
|
{
|
|
|
|
// this is the separator
|
2023-01-20 17:12:39 +00:00
|
|
|
m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
|
2019-05-28 23:23:58 +00:00
|
|
|
}
|
|
|
|
else if( ii == int( m_SelTrackWidthBox->GetCount() - 1 ) )
|
|
|
|
{
|
|
|
|
m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
|
2021-02-17 10:43:57 +00:00
|
|
|
ShowBoardSetupDialog( _( "Pre-defined Sizes" ) );
|
2019-05-28 23:23:58 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2019-05-28 23:23:58 +00:00
|
|
|
GetDesignSettings().SetTrackWidthIndex( ii );
|
2021-12-15 15:48:34 +00:00
|
|
|
GetDesignSettings().m_TempOverrideTrackWidth = true;
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2022-03-21 17:10:07 +00:00
|
|
|
// Needed on Windows because the canvas loses focus after clicking on m_SelTrackWidthBox:
|
|
|
|
GetCanvas()->SetFocus();
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
break;
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
case ID_AUX_TOOLBAR_PCB_VIA_SIZE:
|
|
|
|
ii = m_SelViaSizeBox->GetSelection();
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
if( ii == int( m_SelViaSizeBox->GetCount() - 2 ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
2019-05-28 23:23:58 +00:00
|
|
|
// this is the separator
|
|
|
|
m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
2019-05-28 23:23:58 +00:00
|
|
|
else if( ii == int( m_SelViaSizeBox->GetCount() - 1 ) )
|
|
|
|
{
|
|
|
|
m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
|
2021-02-17 10:43:57 +00:00
|
|
|
ShowBoardSetupDialog( _( "Pre-defined Sizes" ) );
|
2019-05-28 23:23:58 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-10 18:29:41 +00:00
|
|
|
{
|
2019-05-28 23:23:58 +00:00
|
|
|
GetDesignSettings().SetViaSizeIndex( ii );
|
2020-10-10 18:29:41 +00:00
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2022-03-21 17:10:07 +00:00
|
|
|
// Needed on Windows because the canvas loses focus after clicking on m_SelViaSizeBox:
|
|
|
|
GetCanvas()->SetFocus();
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2020-08-31 22:32:11 +00:00
|
|
|
|
|
|
|
m_toolManager->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|