2020-07-27 19:41:50 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 CERN
|
|
|
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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 3
|
|
|
|
* 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-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dialog_unused_pad_layers.h"
|
|
|
|
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <board_commit.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <footprint.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <pad.h>
|
2020-07-27 19:41:50 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2020-07-27 19:41:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum PAD_ACTION : int
|
|
|
|
{
|
|
|
|
PAD_ACTION_REMOVE = 0,
|
|
|
|
PAD_ACTION_RESET
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_UNUSED_PAD_LAYERS::DIALOG_UNUSED_PAD_LAYERS( PCB_BASE_FRAME* aParent,
|
2020-12-16 13:31:32 +00:00
|
|
|
const PCB_SELECTION& aItems,
|
2020-07-27 19:41:50 +00:00
|
|
|
COMMIT& aCommit )
|
|
|
|
: DIALOG_UNUSED_PAD_LAYERS_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
|
|
|
m_items( aItems ),
|
|
|
|
m_commit( aCommit )
|
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
m_image->SetBitmap( KiBitmap( BITMAPS::pads_remove_unused ) );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2021-02-10 11:47:11 +00:00
|
|
|
// Set keep Through Hole pads on external layers ON by default.
|
|
|
|
// Because such a pad does not allow soldering/unsoldering, disable this option
|
|
|
|
// is probably not frequent
|
|
|
|
m_cbPreservePads->SetValue( true );
|
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
2022-09-03 08:41:14 +00:00
|
|
|
updateImage();
|
|
|
|
|
2020-07-27 19:41:50 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2020-07-27 19:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-03 08:41:14 +00:00
|
|
|
void DIALOG_UNUSED_PAD_LAYERS::updateImage()
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
if( m_rbAction->GetSelection() == PAD_ACTION_RESET )
|
2021-03-08 02:59:07 +00:00
|
|
|
m_image->SetBitmap( KiBitmap( BITMAPS::pads_reset_unused ) );
|
2020-07-27 19:41:50 +00:00
|
|
|
else if( m_cbPreservePads->IsChecked() )
|
2021-03-08 02:59:07 +00:00
|
|
|
m_image->SetBitmap( KiBitmap( BITMAPS::pads_remove_unused_keep_bottom ) );
|
2020-07-27 19:41:50 +00:00
|
|
|
else
|
2021-03-08 02:59:07 +00:00
|
|
|
m_image->SetBitmap( KiBitmap( BITMAPS::pads_remove_unused ) );
|
2020-07-27 19:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-03 08:41:14 +00:00
|
|
|
void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
updateImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-27 19:41:50 +00:00
|
|
|
bool DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
if( m_cbSelectedOnly->IsChecked() )
|
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
for( EDA_ITEM* item : m_items )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
m_commit.Modify( item );
|
|
|
|
|
2022-09-03 08:41:14 +00:00
|
|
|
if( item->Type() == PCB_VIA_T && m_cbVias->IsChecked() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( item );
|
2020-07-27 19:41:50 +00:00
|
|
|
via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
|
|
|
|
via->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
|
|
|
|
}
|
|
|
|
|
2022-09-03 08:41:14 +00:00
|
|
|
if( item->Type() == PCB_FOOTPRINT_T && m_cbPads->IsChecked() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2020-11-12 23:50:33 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
|
|
|
|
pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 08:41:14 +00:00
|
|
|
if( item->Type() == PCB_PAD_T && m_cbPads->IsChecked() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
PAD* pad = static_cast<PAD*>( item );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
|
|
|
pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
|
|
|
|
pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-03 08:41:14 +00:00
|
|
|
if( m_cbPads->IsChecked() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : m_frame->GetBoard()->Footprints() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
m_commit.Modify( footprint );
|
2020-07-27 19:41:50 +00:00
|
|
|
|
2020-11-12 23:50:33 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
|
|
|
|
pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-03 08:41:14 +00:00
|
|
|
|
|
|
|
if( m_cbVias->IsChecked() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* item : m_frame->GetBoard()->Tracks() )
|
2020-07-27 19:41:50 +00:00
|
|
|
{
|
|
|
|
if( item->Type() != PCB_VIA_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
m_commit.Modify( item );
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( item );
|
2020-07-27 19:41:50 +00:00
|
|
|
via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
|
|
|
|
via->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_commit.Push( _( "Set Unused Pad Properties" ) );
|
|
|
|
return true;
|
|
|
|
}
|