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 enum SCOPE : int
36 {
39 };
40 
41 
42 enum PAD_ACTION : int
43 {
46 };
47 
48 
50  const PCB_SELECTION& aItems,
51  COMMIT& aCommit )
52  : DIALOG_UNUSED_PAD_LAYERS_BASE( aParent ),
53  m_frame( aParent ),
54  m_items( aItems ),
55  m_commit( aCommit )
56 {
57  m_StdButtonsOK->SetDefault();
59 
60  // Set keep Through Hole pads on external layers ON by default.
61  // Because such a pad does not allow soldering/unsoldering, disable this option
62  // is probably not frequent
63  m_cbPreservePads->SetValue( true );
64 
65  // Now all widgets have the size fixed, call FinishDialogSettings
67 }
68 
69 
70 void DIALOG_UNUSED_PAD_LAYERS::syncImages( wxCommandEvent& aEvent )
71 {
72  if( m_rbAction->GetSelection() == PAD_ACTION_RESET )
74  else if( m_cbPreservePads->IsChecked() )
76  else
78 }
79 
80 
82 {
83  if( m_cbSelectedOnly->IsChecked() )
84  {
85  for( EDA_ITEM* item : m_items )
86  {
87  m_commit.Modify( item );
88 
89  if( item->Type() == PCB_VIA_T && m_rbScope->GetSelection() == SCOPE_VIAS )
90  {
91  PCB_VIA* via = static_cast<PCB_VIA*>( item );
92  via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
93  via->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
94  }
95 
96  if( item->Type() == PCB_FOOTPRINT_T && m_rbScope->GetSelection() == SCOPE_PADS )
97  {
98  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
99 
100  for( PAD* pad : footprint->Pads() )
101  {
102  pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
103  pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
104  }
105  }
106 
107  if( item->Type() == PCB_PAD_T && m_rbScope->GetSelection() == SCOPE_PADS )
108  {
109  PAD* pad = static_cast<PAD*>( item );
110 
111  pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
112  pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
113  }
114  }
115  }
116  else
117  {
118  if( m_rbScope->GetSelection() == SCOPE_PADS )
119  {
120  for( FOOTPRINT* footprint : m_frame->GetBoard()->Footprints() )
121  {
122  m_commit.Modify( footprint );
123 
124  for( PAD* pad : footprint->Pads() )
125  {
126  pad->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
127  pad->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
128  }
129  }
130  }
131  else
132  {
133  for( PCB_TRACK* item : m_frame->GetBoard()->Tracks() )
134  {
135  if( item->Type() != PCB_VIA_T )
136  continue;
137 
138  m_commit.Modify( item );
139  PCB_VIA* via = static_cast<PCB_VIA*>( item );
140  via->SetRemoveUnconnected( m_rbAction->GetSelection() == PAD_ACTION_REMOVE );
141  via->SetKeepTopBottom( m_cbPreservePads->IsChecked() );
142  }
143  }
144  }
145 
146  m_commit.Push( _( "Set Unused Pad Properties" ) );
147  return true;
148 }
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
DIALOG_UNUSED_PAD_LAYERS(PCB_BASE_FRAME *aParent, const PCB_SELECTION &aItems, COMMIT &aCommit)
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:71
class PAD, a pad in a footprint
Definition: typeinfo.h:89
Class DIALOG_UNUSED_PAD_LAYERS_BASE.
PADS & Pads()
Definition: footprint.h:159
FOOTPRINTS & Footprints()
Definition: board.h:233
#define _(s)
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
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void syncImages(wxCommandEvent &aEvent) override
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true)=0
Revert the commit by restoring the modified items state.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
BOARD * GetBoard() const
Definition: pad.h:57
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: board.h:230