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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <map>
21#include <wx/string.h>
22#include <wx/translation.h>
23#include "pcb_track.h"
24
25
27{
28protected:
29 enum class IPC4761_SURFACE
30 {
32 NONE = 1,
33 FRONT = 2,
34 BACK = 3,
35 BOTH = 4,
37 };
38
39 enum class IPC4761_DRILL
40 {
43 SET = 2
44 };
45
46 enum class IPC4761_PRESET
47 {
49 NONE = 1,
50 IA = 2,
51 IB = 3,
53 IIA = 5,
54 IIB = 6,
56 IIIA = 8,
57 IIIB = 9,
59 IVA = 11,
60 IVB = 12,
62 V = 14,
63 VIA = 15,
64 VIB = 16,
66 VII = 18,
67 CUSTOM = 19,
68 END = 20
69 };
70
81
82 const std::map<IPC4761_PRESET, IPC4761_CONFIGURATION> m_IPC4761Presets =
83 {
102 { IPC4761_PRESET::V, { .fill = IPC4761_DRILL::SET } },
108 { IPC4761_PRESET::END, {} }
109 };
110
111 const std::map<IPC4761_PRESET, wxString> m_IPC4761Names =
112 {
113 { IPC4761_PRESET::FROM_BOARD, _( "From rules" ) },
114 { IPC4761_PRESET::NONE, _( "None" ) },
115 { IPC4761_PRESET::IA, _( "Type I-a (tented top)" ) },
116 { IPC4761_PRESET::IB, _( "Type I-b (tented both sides)" ) },
117 { IPC4761_PRESET::IA_INVERTED, _( "Type I-a (tented bottom)" ) },
118 { IPC4761_PRESET::IIA, _( "Type II-a (covered and tented top)" ) },
119 { IPC4761_PRESET::IIB, _( "Type II-b (covered and tented both sides)" ) },
120 { IPC4761_PRESET::IIA_INVERTED, _( "Type II-a (covered and tented bottom)" ) },
121 { IPC4761_PRESET::IIIA, _( "Type III-a (plugged top)" ) },
122 { IPC4761_PRESET::IIIB, _( "Type III-b (plugged both sides)" ) },
123 { IPC4761_PRESET::IIIA_INVERTED, _( "Type III-a (plugged bottom)" ) },
124 { IPC4761_PRESET::IVA, _( "Type IV-a (plugged and tented top)" ) },
125 { IPC4761_PRESET::IVB, _( "Type IV-b (plugged and tented both sides)" ) },
126 { IPC4761_PRESET::IVA_INVERTED, _( "Type IV-a (plugged and tented bottom)" ) },
127 { IPC4761_PRESET::V, _( "Type V (filled)" ) },
128 { IPC4761_PRESET::VIA, _( "Type VI-a (filled and tented top)" ) },
129 { IPC4761_PRESET::VIB, _( "Type VI-b (filled and tented both sides)" ) },
130 { IPC4761_PRESET::VIA_INVERTED, _( "Type VI-a (filled and tented bottom)" ) },
131 { IPC4761_PRESET::VII, _( "Type VII (filled and capped)" ) },
132 { IPC4761_PRESET::CUSTOM, _( "Custom" ) },
133 { IPC4761_PRESET::END, _( "End" ) }
134 };
135
136 IPC4761_SURFACE getProtectionSurface( const std::optional<bool>& front, const std::optional<bool>& back )
137 {
139
140 if( !front.has_value() )
142 else if( front.value() )
144 else
145 value = IPC4761_SURFACE::NONE;
146
147 if( !back.has_value() )
148 {
149 if( value == IPC4761_SURFACE::FROM_BOARD )
151 }
152 else if( back.value() )
153 {
154 if( value == IPC4761_SURFACE::FRONT )
156 else if( value == IPC4761_SURFACE::NONE )
158 }
159 else
160 {
161 if( value == IPC4761_SURFACE::FRONT )
163 else if( value == IPC4761_SURFACE::NONE )
165 }
166
168 };
169
170 IPC4761_DRILL getProtectionDrill( const std::optional<bool>& drill )
171 {
172 if( !drill.has_value() )
174 if( drill.value() )
175 return IPC4761_DRILL::SET;
176
178 };
179
181 {
185
188
191
193
195
196 for( const auto& [preset, configuration] : m_IPC4761Presets )
197 {
198 if( configuration == config )
199 return preset;
200 }
201
203 };
204
205 void setSurfaceProtection( std::optional<bool>& aFront, std::optional<bool>& aBack,
206 IPC4761_SURFACE aProtection )
207 {
208 switch( aProtection )
209 {
211 aFront.reset();
212 aBack.reset();
213 break;
215 aFront = false;
216 aBack = false;
217 break;
219 aFront = true;
220 aBack = false;
221 break;
223 aFront = false;
224 aBack = true;
225 break;
227 aFront = true;
228 aBack = true;
229 break;
231 return;
232 }
233 };
234
235 void setDrillProtection( std::optional<bool>& aDrill, IPC4761_DRILL aProtection )
236 {
237 switch( aProtection )
238 {
239 case IPC4761_DRILL::FROM_BOARD: aDrill.reset(); break;
240 case IPC4761_DRILL::NOT_SET: aDrill = false; break;
241 case IPC4761_DRILL::SET: aDrill = true; break;
242 }
243 };
244
245 void setViaConfiguration( PCB_VIA* aVia, const IPC4761_PRESET& aPreset )
246 {
247 if( aPreset < IPC4761_PRESET::CUSTOM ) // Do not change custom feaure list.
248 {
249 const IPC4761_CONFIGURATION config = m_IPC4761Presets.at( aPreset );
250
253 config.tent );
254
257 config.plug );
258
261 config.cover );
262
264
266 }
267 }
268};
MASK_LAYER_PROPS & FrontOuterLayers()
Definition padstack.h:372
DRILL_PROPS & Drill()
Definition padstack.h:351
MASK_LAYER_PROPS & BackOuterLayers()
Definition padstack.h:375
const PADSTACK & Padstack() const
Definition pcb_track.h:402
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:273
std::optional< bool > is_filled
True if the drill hole should be filled completely.
Definition padstack.h:272
std::optional< bool > has_covering
True if the pad on this side should have covering.
Definition padstack.h:257
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
Definition padstack.h:255
std::optional< bool > has_plugging
True if the drill hole should be plugged on this side.
Definition padstack.h:258
bool operator==(const IPC4761_CONFIGURATION &other) const