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 <zones.h>
28
29using namespace kiapi::board;
30
31template<>
32types::PadStackShape ToProtoEnum( PAD_SHAPE aValue )
33{
34 switch( aValue )
35 {
36 case PAD_SHAPE::CIRCLE: return types::PadStackShape::PSS_CIRCLE;
37 case PAD_SHAPE::RECTANGLE: return types::PadStackShape::PSS_RECTANGLE;
38 case PAD_SHAPE::OVAL: return types::PadStackShape::PSS_OVAL;
39 case PAD_SHAPE::TRAPEZOID: return types::PadStackShape::PSS_TRAPEZOID;
40 case PAD_SHAPE::ROUNDRECT: return types::PadStackShape::PSS_ROUNDRECT;
41 case PAD_SHAPE::CHAMFERED_RECT: return types::PadStackShape::PSS_CHAMFEREDRECT;
42 case PAD_SHAPE::CUSTOM: return types::PadStackShape::PSS_CUSTOM;
43
44 default:
45 wxCHECK_MSG( false, types::PadStackShape::PSS_UNKNOWN,
46 "Unhandled case in ToProtoEnum<PAD_SHAPE>");
47 }
48}
49
50
51template<>
52PAD_SHAPE FromProtoEnum( types::PadStackShape aValue )
53{
54 switch( aValue )
55 {
56 case types::PadStackShape::PSS_CIRCLE: return PAD_SHAPE::CIRCLE;
57 case types::PadStackShape::PSS_RECTANGLE: return PAD_SHAPE::RECTANGLE;
58 case types::PadStackShape::PSS_OVAL: return PAD_SHAPE::OVAL;
59 case types::PadStackShape::PSS_TRAPEZOID: return PAD_SHAPE::TRAPEZOID;
60 case types::PadStackShape::PSS_ROUNDRECT: return PAD_SHAPE::ROUNDRECT;
61 case types::PadStackShape::PSS_CHAMFEREDRECT: return PAD_SHAPE::CHAMFERED_RECT;
62 case types::PadStackShape::PSS_CUSTOM: return PAD_SHAPE::CUSTOM;
63
64 default:
65 wxCHECK_MSG( false, PAD_SHAPE::CIRCLE,
66 "Unhandled case in FromProtoEnum<types::PadStackShape>" );
67 }
68}
69
70
71template<>
72types::ZoneConnectionStyle ToProtoEnum( ZONE_CONNECTION aValue )
73{
74 switch( aValue )
75 {
76 case ZONE_CONNECTION::INHERITED: return types::ZoneConnectionStyle::ZCS_INHERITED;
77 case ZONE_CONNECTION::NONE: return types::ZoneConnectionStyle::ZCS_NONE;
78 case ZONE_CONNECTION::THERMAL: return types::ZoneConnectionStyle::ZCS_THERMAL;
79 case ZONE_CONNECTION::FULL: return types::ZoneConnectionStyle::ZCS_FULL;
80 case ZONE_CONNECTION::THT_THERMAL: return types::ZoneConnectionStyle::ZCS_PTH_THERMAL;
81
82 default:
83 wxCHECK_MSG( false, types::ZoneConnectionStyle::ZCS_UNKNOWN,
84 "Unhandled case in ToProtoEnum<ZONE_CONNECTION>");
85 }
86}
87
88
89template<>
90ZONE_CONNECTION FromProtoEnum( types::ZoneConnectionStyle aValue )
91{
92 switch( aValue )
93 {
94 case types::ZoneConnectionStyle::ZCS_UNKNOWN: return ZONE_CONNECTION::INHERITED;
95 case types::ZoneConnectionStyle::ZCS_INHERITED: return ZONE_CONNECTION::INHERITED;
96 case types::ZoneConnectionStyle::ZCS_NONE: return ZONE_CONNECTION::NONE;
97 case types::ZoneConnectionStyle::ZCS_THERMAL: return ZONE_CONNECTION::THERMAL;
98 case types::ZoneConnectionStyle::ZCS_FULL: return ZONE_CONNECTION::FULL;
99 case types::ZoneConnectionStyle::ZCS_PTH_THERMAL: return ZONE_CONNECTION::THT_THERMAL;
100
101 default:
102 wxCHECK_MSG( false, ZONE_CONNECTION::INHERITED,
103 "Unhandled case in FromProtoEnum<types::ZoneConnectionStyle>" );
104 }
105}
106
107
108template<>
109types::UnconnectedLayerRemoval ToProtoEnum( PADSTACK::UNCONNECTED_LAYER_MODE aValue )
110{
111 switch( aValue )
112 {
114 return types::UnconnectedLayerRemoval::ULR_KEEP;
115
117 return types::UnconnectedLayerRemoval::ULR_REMOVE;
118
120 return types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END;
121
122 default:
123 wxCHECK_MSG( false, types::UnconnectedLayerRemoval::ULR_UNKNOWN,
124 "Unhandled case in ToProtoEnum<PADSTACK::UNCONNECTED_LAYER_MODE>");
125 }
126}
127
128
129template<>
130PADSTACK::UNCONNECTED_LAYER_MODE FromProtoEnum( types::UnconnectedLayerRemoval aValue )
131{
132 switch( aValue )
133 {
134 case types::UnconnectedLayerRemoval::ULR_KEEP:
136
137 case types::UnconnectedLayerRemoval::ULR_REMOVE:
139
140 case types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END:
142
143 default:
145 "Unhandled case in FromProtoEnum<types::UnconnectedLayerRemoval>");
146 }
147}
types::PadStackShape ToProtoEnum(PAD_SHAPE aValue)
PAD_SHAPE FromProtoEnum(types::PadStackShape aValue)
UNCONNECTED_LAYER_MODE
! Whether or not to remove the copper shape for unconnected layers
Definition: padstack.h:135
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition: padstack.h:44
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