KiCad PCB EDA Suite
dialog_unused_pad_layers.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 CERN
5 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
26
27#include <bitmaps.h>
28#include <board_commit.h>
29#include <footprint.h>
30#include <pcb_track.h>
31#include <pad.h>
32#include <pcb_edit_frame.h>
34
35
36enum PAD_ACTION : int
37{
40};
41
42
44 const PCB_SELECTION& aItems,
45 COMMIT& aCommit )
47 m_frame( aParent ),
48 m_items( aItems ),
49 m_commit( aCommit )
50{
52
53 // Set keep Through Hole pads on external layers ON by default.
54 // Because such a pad does not allow soldering/unsoldering, disable this option
55 // is probably not frequent
56 m_cbPreservePads->SetValue( true );
57
59
61
62 // Now all widgets have the size fixed, call FinishDialogSettings
64}
65
66
68{
69 if( m_rbAction->GetSelection() == PAD_ACTION_RESET )
71 else if( m_cbPreservePads->IsChecked() )
73 else
75}
76
77
78void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent )
79{
81}
82
83
85{
86 if( m_cbSelectedOnly->IsChecked() )
87 {
88 for( EDA_ITEM* item : m_items )
89 {
90 m_commit.Modify( item );
91
92 if( item->Type() == PCB_VIA_T && m_cbVias->IsChecked() )
93 {
94 PCB_VIA* via = static_cast<PCB_VIA*>( item );
95 via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
96 via->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
97 }
98
99 if( item->Type() == PCB_FOOTPRINT_T && m_cbPads->IsChecked() )
100 {
101 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
102
103 for( PAD* pad : footprint->Pads() )
104 {
105 pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
106 pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
107 }
108 }
109
110 if( item->Type() == PCB_PAD_T && m_cbPads->IsChecked() )
111 {
112 PAD* pad = static_cast<PAD*>( item );
113
114 pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
115 pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
116 }
117 }
118 }
119 else
120 {
121 if( m_cbPads->IsChecked() )
122 {
123 for( FOOTPRINT* footprint : m_frame->GetBoard()->Footprints() )
124 {
125 m_commit.Modify( footprint );
126
127 for( PAD* pad : footprint->Pads() )
128 {
129 pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
130 pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
131 }
132 }
133 }
134
135 if( m_cbVias->IsChecked() )
136 {
137 for( PCB_TRACK* item : m_frame->GetBoard()->Tracks() )
138 {
139 if( item->Type() != PCB_VIA_T )
140 continue;
141
142 m_commit.Modify( item );
143 PCB_VIA* via = static_cast<PCB_VIA*>( item );
144 via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
145 via->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
146 }
147 }
148 }
149
150 m_commit.Push( _( "Set Unused Pad Properties" ) );
151 return true;
152}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ pads_reset_unused
@ pads_remove_unused
@ pads_remove_unused_keep_bottom
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:72
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
virtual void Push(const wxString &aMessage=wxT("A commit"), int aFlags=0)=0
Revert the commit by restoring the modified items state.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_UNUSED_PAD_LAYERS_BASE.
void syncImages(wxCommandEvent &aEvent) override
DIALOG_UNUSED_PAD_LAYERS(PCB_BASE_FRAME *aParent, const PCB_SELECTION &aItems, COMMIT &aCommit)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
PADS & Pads()
Definition: footprint.h:170
Definition: pad.h:59
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard() const
#define _(s)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87