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::PadStackShape ToProtoEnum( PAD_SHAPE aValue )
67{
68 switch( aValue )
69 {
70 case PAD_SHAPE::CIRCLE: return types::PadStackShape::PSS_CIRCLE;
71 case PAD_SHAPE::RECTANGLE: return types::PadStackShape::PSS_RECTANGLE;
72 case PAD_SHAPE::OVAL: return types::PadStackShape::PSS_OVAL;
73 case PAD_SHAPE::TRAPEZOID: return types::PadStackShape::PSS_TRAPEZOID;
74 case PAD_SHAPE::ROUNDRECT: return types::PadStackShape::PSS_ROUNDRECT;
75 case PAD_SHAPE::CHAMFERED_RECT: return types::PadStackShape::PSS_CHAMFEREDRECT;
76 case PAD_SHAPE::CUSTOM: return types::PadStackShape::PSS_CUSTOM;
77
78 default:
79 wxCHECK_MSG( false, types::PadStackShape::PSS_UNKNOWN,
80 "Unhandled case in ToProtoEnum<PAD_SHAPE>");
81 }
82}
83
84
85template<>
86PAD_SHAPE FromProtoEnum( types::PadStackShape aValue )
87{
88 switch( aValue )
89 {
90 case types::PadStackShape::PSS_CIRCLE: return PAD_SHAPE::CIRCLE;
91 case types::PadStackShape::PSS_RECTANGLE: return PAD_SHAPE::RECTANGLE;
92 case types::PadStackShape::PSS_OVAL: return PAD_SHAPE::OVAL;
93 case types::PadStackShape::PSS_TRAPEZOID: return PAD_SHAPE::TRAPEZOID;
94 case types::PadStackShape::PSS_ROUNDRECT: return PAD_SHAPE::ROUNDRECT;
95 case types::PadStackShape::PSS_CHAMFEREDRECT: return PAD_SHAPE::CHAMFERED_RECT;
96 case types::PadStackShape::PSS_CUSTOM: return PAD_SHAPE::CUSTOM;
97
98 default:
99 wxCHECK_MSG( false, PAD_SHAPE::CIRCLE,
100 "Unhandled case in FromProtoEnum<types::PadStackShape>" );
101 }
102}
103
104
105template<>
106types::PadStackType ToProtoEnum( PADSTACK::MODE aValue )
107{
108 switch( aValue )
109 {
110 case PADSTACK::MODE::NORMAL: return types::PadStackType::PST_NORMAL;
111 case PADSTACK::MODE::TOP_INNER_BOTTOM: return types::PadStackType::PST_TOP_INNER_BOTTOM;
112 case PADSTACK::MODE::CUSTOM: return types::PadStackType::PST_CUSTOM;
113
114 default:
115 wxCHECK_MSG( false, types::PadStackType::PST_UNKNOWN,
116 "Unhandled case in ToProtoEnum<PADSTACK::MODE>");
117 }
118}
119
120
121template<>
122PADSTACK::MODE FromProtoEnum( types::PadStackType aValue )
123{
124 switch( aValue )
125 {
126 case types::PadStackType::PST_NORMAL: return PADSTACK::MODE::NORMAL;
127 case types::PadStackType::PST_TOP_INNER_BOTTOM: return PADSTACK::MODE::TOP_INNER_BOTTOM;
128 case types::PadStackType::PST_CUSTOM: return PADSTACK::MODE::CUSTOM;
129
130 default:
131 wxCHECK_MSG( false, PADSTACK::MODE::NORMAL,
132 "Unhandled case in FromProtoEnum<types::PadStackType>" );
133 }
134}
135
136
137template<>
138types::ViaType ToProtoEnum( VIATYPE aValue )
139{
140 switch( aValue )
141 {
142 case VIATYPE::THROUGH: return types::ViaType::VT_THROUGH;
143 case VIATYPE::BLIND_BURIED: return types::ViaType::VT_BLIND_BURIED;
144 case VIATYPE::MICROVIA: return types::ViaType::VT_MICRO;
145
146 default:
147 wxCHECK_MSG( false, types::ViaType::VT_UNKNOWN,
148 "Unhandled case in ToProtoEnum<VIATYPE>");
149 }
150}
151
152
153template<>
154VIATYPE FromProtoEnum( types::ViaType aValue )
155{
156 switch( aValue )
157 {
158 case types::ViaType::VT_THROUGH: return VIATYPE::THROUGH;
159 case types::ViaType::VT_BLIND_BURIED: return VIATYPE::BLIND_BURIED;
160 case types::ViaType::VT_MICRO: return VIATYPE::MICROVIA;
161
162 default:
163 wxCHECK_MSG( false, VIATYPE::THROUGH,
164 "Unhandled case in FromProtoEnum<types::ViaType>" );
165 }
166}
167
168
169template<>
170types::ZoneConnectionStyle ToProtoEnum( ZONE_CONNECTION aValue )
171{
172 switch( aValue )
173 {
174 case ZONE_CONNECTION::INHERITED: return types::ZoneConnectionStyle::ZCS_INHERITED;
175 case ZONE_CONNECTION::NONE: return types::ZoneConnectionStyle::ZCS_NONE;
176 case ZONE_CONNECTION::THERMAL: return types::ZoneConnectionStyle::ZCS_THERMAL;
177 case ZONE_CONNECTION::FULL: return types::ZoneConnectionStyle::ZCS_FULL;
178 case ZONE_CONNECTION::THT_THERMAL: return types::ZoneConnectionStyle::ZCS_PTH_THERMAL;
179
180 default:
181 wxCHECK_MSG( false, types::ZoneConnectionStyle::ZCS_UNKNOWN,
182 "Unhandled case in ToProtoEnum<ZONE_CONNECTION>");
183 }
184}
185
186
187template<>
188ZONE_CONNECTION FromProtoEnum( types::ZoneConnectionStyle aValue )
189{
190 switch( aValue )
191 {
192 case types::ZoneConnectionStyle::ZCS_UNKNOWN: return ZONE_CONNECTION::INHERITED;
193 case types::ZoneConnectionStyle::ZCS_INHERITED: return ZONE_CONNECTION::INHERITED;
194 case types::ZoneConnectionStyle::ZCS_NONE: return ZONE_CONNECTION::NONE;
195 case types::ZoneConnectionStyle::ZCS_THERMAL: return ZONE_CONNECTION::THERMAL;
196 case types::ZoneConnectionStyle::ZCS_FULL: return ZONE_CONNECTION::FULL;
197 case types::ZoneConnectionStyle::ZCS_PTH_THERMAL: return ZONE_CONNECTION::THT_THERMAL;
198
199 default:
200 wxCHECK_MSG( false, ZONE_CONNECTION::INHERITED,
201 "Unhandled case in FromProtoEnum<types::ZoneConnectionStyle>" );
202 }
203}
204
205
206template<>
207types::UnconnectedLayerRemoval ToProtoEnum( PADSTACK::UNCONNECTED_LAYER_MODE aValue )
208{
209 switch( aValue )
210 {
212 return types::UnconnectedLayerRemoval::ULR_KEEP;
213
215 return types::UnconnectedLayerRemoval::ULR_REMOVE;
216
218 return types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END;
219
220 default:
221 wxCHECK_MSG( false, types::UnconnectedLayerRemoval::ULR_UNKNOWN,
222 "Unhandled case in ToProtoEnum<PADSTACK::UNCONNECTED_LAYER_MODE>");
223 }
224}
225
226
227template<>
228PADSTACK::UNCONNECTED_LAYER_MODE FromProtoEnum( types::UnconnectedLayerRemoval aValue )
229{
230 switch( aValue )
231 {
232 case types::UnconnectedLayerRemoval::ULR_KEEP:
234
235 case types::UnconnectedLayerRemoval::ULR_REMOVE:
237
238 case types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END:
240
241 default:
243 "Unhandled case in FromProtoEnum<types::UnconnectedLayerRemoval>");
244 }
245}
types::PadType ToProtoEnum(PAD_ATTRIB aValue)
PAD_ATTRIB FromProtoEnum(types::PadType aValue)
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ TOP_INNER_BOTTOM
Up to three shapes can be defined (top, inner, bottom)
UNCONNECTED_LAYER_MODE
! Whether or not to remove the copper shape for unconnected layers
Definition: padstack.h:137
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: padstack.h:74
@ 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:46
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