KiCad PCB EDA Suite
Loading...
Searching...
No Matches
via_protection_ui_mixin.h
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <map>
25#include <wx/string.h>
26#include <wx/translation.h>
27#include "pcb_track.h"
28
29
31{
32protected:
33 enum class IPC4761_SURFACE
34 {
36 NONE = 1,
37 FRONT = 2,
38 BACK = 3,
39 BOTH = 4,
41 };
42
43 enum class IPC4761_DRILL
44 {
47 SET = 2
48 };
49
50 enum class IPC4761_PRESET
51 {
53 NONE = 1,
54 IA = 2,
55 IB = 3,
57 IIA = 5,
58 IIB = 6,
60 IIIA = 8,
61 IIIB = 9,
63 IVA = 11,
64 IVB = 12,
66 V = 14,
67 VIA = 15,
68 VIB = 16,
70 VII = 18,
71 CUSTOM = 19,
72 END = 20
73 };
74
85
86 const std::map<IPC4761_PRESET, IPC4761_CONFIGURATION> m_IPC4761Presets =
87 {
106 { IPC4761_PRESET::V, { .fill = IPC4761_DRILL::SET } },
112 { IPC4761_PRESET::END, {} }
113 };
114
115 const std::map<IPC4761_PRESET, wxString> m_IPC4761Names =
116 {
117 { IPC4761_PRESET::FROM_RULES, _( "From rules" ) },
118 { IPC4761_PRESET::NONE, _( "None" ) },
119 { IPC4761_PRESET::IA, _( "Type I-a (tented top)" ) },
120 { IPC4761_PRESET::IB, _( "Type I-b (tented both sides)" ) },
121 { IPC4761_PRESET::IA_INVERTED, _( "Type I-a (tented bottom)" ) },
122 { IPC4761_PRESET::IIA, _( "Type II-a (covered and tented top)" ) },
123 { IPC4761_PRESET::IIB, _( "Type II-b (covered and tented both sides)" ) },
124 { IPC4761_PRESET::IIA_INVERTED, _( "Type II-a (covered and tented bottom)" ) },
125 { IPC4761_PRESET::IIIA, _( "Type III-a (plugged top)" ) },
126 { IPC4761_PRESET::IIIB, _( "Type III-b (plugged both sides)" ) },
127 { IPC4761_PRESET::IIIA_INVERTED, _( "Type III-a (plugged bottom)" ) },
128 { IPC4761_PRESET::IVA, _( "Type IV-a (plugged and tented top)" ) },
129 { IPC4761_PRESET::IVB, _( "Type IV-b (plugged and tented both sides)" ) },
130 { IPC4761_PRESET::IVA_INVERTED, _( "Type IV-a (plugged and tented bottom)" ) },
131 { IPC4761_PRESET::V, _( "Type V (filled )" ) },
132 { IPC4761_PRESET::VIA, _( "Type VI-a (filled and tented top)" ) },
133 { IPC4761_PRESET::VIB, _( "Type VI-b (filled and tented both sides)" ) },
134 { IPC4761_PRESET::VIA_INVERTED, _( "Type VI-a (filled and tented bottom)" ) },
135 { IPC4761_PRESET::VII, _( "Type VII (filled and capped)" ) },
136 { IPC4761_PRESET::CUSTOM, _( "Custom" ) },
137 { IPC4761_PRESET::END, _( "End" ) }
138 };
139
140 IPC4761_SURFACE getProtectionSurface( const std::optional<bool>& front, const std::optional<bool>& back )
141 {
143
144 if( !front.has_value() )
146 else if( front.value() )
148 else
149 value = IPC4761_SURFACE::NONE;
150
151 if( !back.has_value() )
152 {
153 if( value == IPC4761_SURFACE::FROM_RULES )
155 }
156 else if( back.value() )
157 {
158 if( value == IPC4761_SURFACE::FRONT )
160 else if( value == IPC4761_SURFACE::NONE )
162 }
163 else
164 {
165 if( value == IPC4761_SURFACE::FRONT )
167 else if( value == IPC4761_SURFACE::NONE )
169 }
170
172 };
173
174 IPC4761_DRILL getProtectionDrill( const std::optional<bool>& drill )
175 {
176 if( !drill.has_value() )
178 if( drill.value() )
179 return IPC4761_DRILL::SET;
180
182 };
183
185 {
189
192
195
197
199
200 for( const auto& [preset, configuration] : m_IPC4761Presets )
201 {
202 if( configuration == config )
203 return preset;
204 }
205
207 };
208
209 void setSurfaceProtection( std::optional<bool>& aFront, std::optional<bool>& aBack,
210 IPC4761_SURFACE aProtection )
211 {
212 switch( aProtection )
213 {
215 aFront.reset();
216 aBack.reset();
217 break;
219 aFront = false;
220 aBack = false;
221 break;
223 aFront = true;
224 aBack = false;
225 break;
227 aFront = false;
228 aBack = true;
229 break;
231 aFront = true;
232 aBack = true;
233 break;
235 return;
236 }
237 };
238
239 void setDrillProtection( std::optional<bool>& aDrill, IPC4761_DRILL aProtection )
240 {
241 switch( aProtection )
242 {
243 case IPC4761_DRILL::FROM_RULES: aDrill.reset(); break;
244 case IPC4761_DRILL::NOT_SET: aDrill = false; break;
245 case IPC4761_DRILL::SET: aDrill = true; break;
246 }
247 };
248
249 void setViaConfiguration( PCB_VIA* aVia, const IPC4761_PRESET& aPreset )
250 {
251 if( aPreset < IPC4761_PRESET::CUSTOM ) // Do not change custom feaure list.
252 {
253 const IPC4761_CONFIGURATION config = m_IPC4761Presets.at( aPreset );
254
257 config.tent );
258
261 config.plug );
262
265 config.cover );
266
268
270 }
271 }
272};
MASK_LAYER_PROPS & FrontOuterLayers()
Definition padstack.h:320
DRILL_PROPS & Drill()
Definition padstack.h:308
MASK_LAYER_PROPS & BackOuterLayers()
Definition padstack.h:323
const PADSTACK & Padstack() const
Definition pcb_track.h:463
const std::map< IPC4761_PRESET, IPC4761_CONFIGURATION > m_IPC4761Presets
void setSurfaceProtection(std::optional< bool > &aFront, std::optional< bool > &aBack, IPC4761_SURFACE aProtection)
IPC4761_DRILL getProtectionDrill(const std::optional< bool > &drill)
IPC4761_PRESET getViaConfiguration(const PCB_VIA *aVia)
IPC4761_SURFACE getProtectionSurface(const std::optional< bool > &front, const std::optional< bool > &back)
const std::map< IPC4761_PRESET, wxString > m_IPC4761Names
void setViaConfiguration(PCB_VIA *aVia, const IPC4761_PRESET &aPreset)
void setDrillProtection(std::optional< bool > &aDrill, IPC4761_DRILL aProtection)
#define _(s)
std::optional< bool > is_capped
True if the drill hole should be capped.
Definition padstack.h:251
std::optional< bool > is_filled
True if the drill hole should be filled completely.
Definition padstack.h:250
std::optional< bool > has_covering
True if the pad on this side should have covering.
Definition padstack.h:236
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
Definition padstack.h:234
std::optional< bool > has_plugging
True if the drill hole should be plugged on this side.
Definition padstack.h:237
bool operator==(const IPC4761_CONFIGURATION &other) const