KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_pcb_enums.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) 2024 Jon Evans <[email protected]>
5 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <import_export.h>
22#include <api/api_enums.h>
23#include <api/board/board_types.pb.h>
24#include <wx/wx.h>
25
26#include <padstack.h>
27#include <pcb_track.h>
28#include <zones.h>
29
30using namespace kiapi::board;
31
32template<>
33types::PadType ToProtoEnum( PAD_ATTRIB aValue )
34{
35 switch( aValue )
36 {
37 case PAD_ATTRIB::PTH: return types::PadType::PT_PTH;
38 case PAD_ATTRIB::SMD: return types::PadType::PT_SMD;
39 case PAD_ATTRIB::CONN: return types::PadType::PT_EDGE_CONNECTOR;
40 case PAD_ATTRIB::NPTH: return types::PadType::PT_NPTH;
41
42 default:
43 wxCHECK_MSG( false, types::PadType::PT_UNKNOWN,
44 "Unhandled case in ToProtoEnum<PAD_ATTRIB>");
45 }
46}
47
48
49template<>
50PAD_ATTRIB FromProtoEnum( types::PadType aValue )
51{
52 switch( aValue )
53 {
54 case types::PadType::PT_PTH: return PAD_ATTRIB::PTH;
55 case types::PadType::PT_SMD: return PAD_ATTRIB::SMD;
56 case types::PadType::PT_EDGE_CONNECTOR: return PAD_ATTRIB::CONN;
57 case types::PadType::PT_NPTH: return PAD_ATTRIB::NPTH;
58
59 default:
60 wxCHECK_MSG( false, PAD_ATTRIB::PTH,
61 "Unhandled case in FromProtoEnum<types::PadType>" );
62 }
63}
64
65template<>
66types::DrillShape ToProtoEnum( PAD_DRILL_SHAPE aValue )
67{
68 switch( aValue )
69 {
70 case PAD_DRILL_SHAPE::CIRCLE: return types::DrillShape::DS_CIRCLE;
71 case PAD_DRILL_SHAPE::OBLONG: return types::DrillShape::DS_OBLONG;
72 case PAD_DRILL_SHAPE::UNDEFINED: return types::DrillShape::DS_UNDEFINED;
73 default:
74 wxCHECK_MSG( false, types::DrillShape::DS_UNKNOWN,
75 "Unhandled case in ToProtoEnum<PAD_DRILL_SHAPE>");
76 }
77}
78
79template<>
80PAD_DRILL_SHAPE FromProtoEnum( types::DrillShape aValue )
81{
82 switch( aValue )
83 {
84 case types::DrillShape::DS_CIRCLE: return PAD_DRILL_SHAPE::CIRCLE;
85 case types::DrillShape::DS_OBLONG: return PAD_DRILL_SHAPE::OBLONG;
86 case types::DrillShape::DS_UNDEFINED: return PAD_DRILL_SHAPE::UNDEFINED;
87 default:
88 wxCHECK_MSG( false, PAD_DRILL_SHAPE::UNDEFINED,
89 "Unhandled case in FromProtoEnum<types::DrillShape>" );
90 }
91}
92
93template<>
94types::PadStackShape ToProtoEnum( PAD_SHAPE aValue )
95{
96 switch( aValue )
97 {
98 case PAD_SHAPE::CIRCLE: return types::PadStackShape::PSS_CIRCLE;
99 case PAD_SHAPE::RECTANGLE: return types::PadStackShape::PSS_RECTANGLE;
100 case PAD_SHAPE::OVAL: return types::PadStackShape::PSS_OVAL;
101 case PAD_SHAPE::TRAPEZOID: return types::PadStackShape::PSS_TRAPEZOID;
102 case PAD_SHAPE::ROUNDRECT: return types::PadStackShape::PSS_ROUNDRECT;
103 case PAD_SHAPE::CHAMFERED_RECT: return types::PadStackShape::PSS_CHAMFEREDRECT;
104 case PAD_SHAPE::CUSTOM: return types::PadStackShape::PSS_CUSTOM;
105
106 default:
107 wxCHECK_MSG( false, types::PadStackShape::PSS_UNKNOWN,
108 "Unhandled case in ToProtoEnum<PAD_SHAPE>");
109 }
110}
111
112
113template<>
114PAD_SHAPE FromProtoEnum( types::PadStackShape aValue )
115{
116 switch( aValue )
117 {
118 case types::PadStackShape::PSS_CIRCLE: return PAD_SHAPE::CIRCLE;
119 case types::PadStackShape::PSS_RECTANGLE: return PAD_SHAPE::RECTANGLE;
120 case types::PadStackShape::PSS_OVAL: return PAD_SHAPE::OVAL;
121 case types::PadStackShape::PSS_TRAPEZOID: return PAD_SHAPE::TRAPEZOID;
122 case types::PadStackShape::PSS_ROUNDRECT: return PAD_SHAPE::ROUNDRECT;
123 case types::PadStackShape::PSS_CHAMFEREDRECT: return PAD_SHAPE::CHAMFERED_RECT;
124 case types::PadStackShape::PSS_CUSTOM: return PAD_SHAPE::CUSTOM;
125
126 default:
127 wxCHECK_MSG( false, PAD_SHAPE::CIRCLE,
128 "Unhandled case in FromProtoEnum<types::PadStackShape>" );
129 }
130}
131
132
133template<>
134types::PadStackType ToProtoEnum( PADSTACK::MODE aValue )
135{
136 switch( aValue )
137 {
138 case PADSTACK::MODE::NORMAL: return types::PadStackType::PST_NORMAL;
139 case PADSTACK::MODE::FRONT_INNER_BACK: return types::PadStackType::PST_FRONT_INNER_BACK;
140 case PADSTACK::MODE::CUSTOM: return types::PadStackType::PST_CUSTOM;
141
142 default:
143 wxCHECK_MSG( false, types::PadStackType::PST_UNKNOWN,
144 "Unhandled case in ToProtoEnum<PADSTACK::MODE>");
145 }
146}
147
148
149template<>
150PADSTACK::MODE FromProtoEnum( types::PadStackType aValue )
151{
152 switch( aValue )
153 {
154 case types::PadStackType::PST_NORMAL: return PADSTACK::MODE::NORMAL;
155 case types::PadStackType::PST_FRONT_INNER_BACK: return PADSTACK::MODE::FRONT_INNER_BACK;
156 case types::PadStackType::PST_CUSTOM: return PADSTACK::MODE::CUSTOM;
157
158 default:
159 wxCHECK_MSG( false, PADSTACK::MODE::NORMAL,
160 "Unhandled case in FromProtoEnum<types::PadStackType>" );
161 }
162}
163
164
165template<>
166types::ViaType ToProtoEnum( VIATYPE aValue )
167{
168 switch( aValue )
169 {
170 case VIATYPE::THROUGH: return types::ViaType::VT_THROUGH;
171 case VIATYPE::BLIND_BURIED: return types::ViaType::VT_BLIND_BURIED;
172 case VIATYPE::MICROVIA: return types::ViaType::VT_MICRO;
173
174 default:
175 wxCHECK_MSG( false, types::ViaType::VT_UNKNOWN,
176 "Unhandled case in ToProtoEnum<VIATYPE>");
177 }
178}
179
180
181template<>
182VIATYPE FromProtoEnum( types::ViaType aValue )
183{
184 switch( aValue )
185 {
186 case types::ViaType::VT_THROUGH: return VIATYPE::THROUGH;
187 case types::ViaType::VT_BLIND_BURIED: return VIATYPE::BLIND_BURIED;
188 case types::ViaType::VT_MICRO: return VIATYPE::MICROVIA;
189
190 default:
191 wxCHECK_MSG( false, VIATYPE::THROUGH,
192 "Unhandled case in FromProtoEnum<types::ViaType>" );
193 }
194}
195
196
197template<>
198types::ZoneConnectionStyle ToProtoEnum( ZONE_CONNECTION aValue )
199{
200 switch( aValue )
201 {
202 case ZONE_CONNECTION::INHERITED: return types::ZoneConnectionStyle::ZCS_INHERITED;
203 case ZONE_CONNECTION::NONE: return types::ZoneConnectionStyle::ZCS_NONE;
204 case ZONE_CONNECTION::THERMAL: return types::ZoneConnectionStyle::ZCS_THERMAL;
205 case ZONE_CONNECTION::FULL: return types::ZoneConnectionStyle::ZCS_FULL;
206 case ZONE_CONNECTION::THT_THERMAL: return types::ZoneConnectionStyle::ZCS_PTH_THERMAL;
207
208 default:
209 wxCHECK_MSG( false, types::ZoneConnectionStyle::ZCS_UNKNOWN,
210 "Unhandled case in ToProtoEnum<ZONE_CONNECTION>");
211 }
212}
213
214
215template<>
216ZONE_CONNECTION FromProtoEnum( types::ZoneConnectionStyle aValue )
217{
218 switch( aValue )
219 {
220 case types::ZoneConnectionStyle::ZCS_UNKNOWN: return ZONE_CONNECTION::INHERITED;
221 case types::ZoneConnectionStyle::ZCS_INHERITED: return ZONE_CONNECTION::INHERITED;
222 case types::ZoneConnectionStyle::ZCS_NONE: return ZONE_CONNECTION::NONE;
223 case types::ZoneConnectionStyle::ZCS_THERMAL: return ZONE_CONNECTION::THERMAL;
224 case types::ZoneConnectionStyle::ZCS_FULL: return ZONE_CONNECTION::FULL;
225 case types::ZoneConnectionStyle::ZCS_PTH_THERMAL: return ZONE_CONNECTION::THT_THERMAL;
226
227 default:
228 wxCHECK_MSG( false, ZONE_CONNECTION::INHERITED,
229 "Unhandled case in FromProtoEnum<types::ZoneConnectionStyle>" );
230 }
231}
232
233
234template<>
235types::UnconnectedLayerRemoval ToProtoEnum( PADSTACK::UNCONNECTED_LAYER_MODE aValue )
236{
237 switch( aValue )
238 {
240 return types::UnconnectedLayerRemoval::ULR_KEEP;
241
243 return types::UnconnectedLayerRemoval::ULR_REMOVE;
244
246 return types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END;
247
248 default:
249 wxCHECK_MSG( false, types::UnconnectedLayerRemoval::ULR_UNKNOWN,
250 "Unhandled case in ToProtoEnum<PADSTACK::UNCONNECTED_LAYER_MODE>");
251 }
252}
253
254
255template<>
256PADSTACK::UNCONNECTED_LAYER_MODE FromProtoEnum( types::UnconnectedLayerRemoval aValue )
257{
258 switch( aValue )
259 {
260 case types::UnconnectedLayerRemoval::ULR_KEEP:
262
263 case types::UnconnectedLayerRemoval::ULR_REMOVE:
265
266 case types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END:
268
269 default:
271 "Unhandled case in FromProtoEnum<types::UnconnectedLayerRemoval>");
272 }
273}
types::PadType ToProtoEnum(PAD_ATTRIB aValue)
PAD_ATTRIB FromProtoEnum(types::PadType aValue)
MODE
! Copper geometry mode: controls how many unique copper layer shapes this padstack has
Definition: padstack.h:137
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
UNCONNECTED_LAYER_MODE
! Whether or not to remove the copper shape for unconnected layers
Definition: padstack.h:151
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:69
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: padstack.h:81
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: padstack.h:52
VIATYPE
Definition: pcb_track.h:66
@ BLIND_BURIED
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:47
@ THERMAL
Use thermal relief for pads.
@ THT_THERMAL
Thermal relief only for THT pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper