KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_sch_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 The KiCad Developers, see AUTHORS.txt for contributors.
5 * @author Jon Evans <[email protected]>
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 <api/api_enums.h>
22#include <wx/wx.h>
23
24#include <core/typeinfo.h>
25#include <layer_ids.h>
26#include <lib_symbol.h>
27#include <pin_type.h>
28#include <sch_label.h>
29#include <sch_sheet_pin.h>
30#include <symbol.h>
31#include <api/schematic/schematic_types.pb.h>
32
33using namespace kiapi::schematic;
34
35
36template<>
37types::SchematicLabelShape ToProtoEnum( LABEL_FLAG_SHAPE aValue )
38{
39 switch( aValue )
40 {
41 case LABEL_FLAG_SHAPE::L_INPUT: return types::SchematicLabelShape::SLSH_INPUT;
42 case LABEL_FLAG_SHAPE::L_OUTPUT: return types::SchematicLabelShape::SLSH_OUTPUT;
43 case LABEL_FLAG_SHAPE::L_BIDI: return types::SchematicLabelShape::SLSH_BIDI;
44 case LABEL_FLAG_SHAPE::L_TRISTATE: return types::SchematicLabelShape::SLSH_TRISTATE;
45 case LABEL_FLAG_SHAPE::L_UNSPECIFIED: return types::SchematicLabelShape::SLSH_PASSIVE;
46 case LABEL_FLAG_SHAPE::F_DOT: return types::SchematicLabelShape::SLSH_DOT;
47 case LABEL_FLAG_SHAPE::F_ROUND: return types::SchematicLabelShape::SLSH_CIRCLE;
48 case LABEL_FLAG_SHAPE::F_DIAMOND: return types::SchematicLabelShape::SLSH_DIAMOND;
49 case LABEL_FLAG_SHAPE::F_RECTANGLE: return types::SchematicLabelShape::SLSH_RECTANGLE;
50
51 default:
52 wxCHECK_MSG( false, types::SchematicLabelShape::SLSH_UNKNOWN,
53 "Unhandled case in ToProtoEnum<LABEL_FLAG_SHAPE>" );
54 }
55}
56
57
58template<>
59LABEL_FLAG_SHAPE FromProtoEnum( types::SchematicLabelShape aValue )
60{
61 switch( aValue )
62 {
63 case types::SchematicLabelShape::SLSH_UNKNOWN:
64 case types::SchematicLabelShape::SLSH_PASSIVE: return LABEL_FLAG_SHAPE::L_UNSPECIFIED;
65 case types::SchematicLabelShape::SLSH_INPUT: return LABEL_FLAG_SHAPE::L_INPUT;
66 case types::SchematicLabelShape::SLSH_OUTPUT: return LABEL_FLAG_SHAPE::L_OUTPUT;
67 case types::SchematicLabelShape::SLSH_BIDI: return LABEL_FLAG_SHAPE::L_BIDI;
68 case types::SchematicLabelShape::SLSH_TRISTATE: return LABEL_FLAG_SHAPE::L_TRISTATE;
69 case types::SchematicLabelShape::SLSH_DOT: return LABEL_FLAG_SHAPE::F_DOT;
70 case types::SchematicLabelShape::SLSH_CIRCLE: return LABEL_FLAG_SHAPE::F_ROUND;
71 case types::SchematicLabelShape::SLSH_DIAMOND: return LABEL_FLAG_SHAPE::F_DIAMOND;
72 case types::SchematicLabelShape::SLSH_RECTANGLE: return LABEL_FLAG_SHAPE::F_RECTANGLE;
73
74 default:
75 wxCHECK_MSG( false, LABEL_FLAG_SHAPE::L_UNSPECIFIED,
76 "Unhandled case in FromProtoEnum<types::SchematicLabelShape>" );
77 }
78}
79
80
81template<>
82types::SchematicLabelSpinStyle ToProtoEnum( SPIN_STYLE::SPIN aValue )
83{
84 switch( aValue )
85 {
86 case SPIN_STYLE::SPIN::LEFT: return types::SchematicLabelSpinStyle::SLSS_LEFT;
87 case SPIN_STYLE::SPIN::UP: return types::SchematicLabelSpinStyle::SLSS_UP;
88 case SPIN_STYLE::SPIN::RIGHT: return types::SchematicLabelSpinStyle::SLSS_RIGHT;
89 case SPIN_STYLE::SPIN::BOTTOM: return types::SchematicLabelSpinStyle::SLSS_BOTTOM;
90
91 default:
92 wxCHECK_MSG( false, types::SchematicLabelSpinStyle::SLSS_UNKNOWN,
93 "Unhandled case in ToProtoEnum<SPIN_STYLE::SPIN>" );
94 }
95}
96
97
98template<>
99SPIN_STYLE::SPIN FromProtoEnum( types::SchematicLabelSpinStyle aValue )
100{
101 switch( aValue )
102 {
103 case types::SchematicLabelSpinStyle::SLSS_UNKNOWN:
104 case types::SchematicLabelSpinStyle::SLSS_LEFT: return SPIN_STYLE::SPIN::LEFT;
105 case types::SchematicLabelSpinStyle::SLSS_UP: return SPIN_STYLE::SPIN::UP;
106 case types::SchematicLabelSpinStyle::SLSS_RIGHT: return SPIN_STYLE::SPIN::RIGHT;
107 case types::SchematicLabelSpinStyle::SLSS_BOTTOM: return SPIN_STYLE::SPIN::BOTTOM;
108
109 default:
110 wxCHECK_MSG( false, SPIN_STYLE::SPIN::LEFT,
111 "Unhandled case in FromProtoEnum<types::SchematicLabelSpinStyle>" );
112 }
113}
114
115
116template<>
117types::SheetSide ToProtoEnum( SHEET_SIDE aValue )
118{
119 switch( aValue )
120 {
121 case SHEET_SIDE::LEFT: return types::SheetSide::SHS_LEFT;
122 case SHEET_SIDE::RIGHT: return types::SheetSide::SHS_RIGHT;
123 case SHEET_SIDE::TOP: return types::SheetSide::SHS_TOP;
124 case SHEET_SIDE::BOTTOM: return types::SheetSide::SHS_BOTTOM;
125
126 default:
127 wxCHECK_MSG( false, types::SheetSide::SHS_UNKNOWN,
128 "Unhandled case in ToProtoEnum<SHEET_SIDE>" );
129 }
130}
131
132
133template<>
134SHEET_SIDE FromProtoEnum( types::SheetSide aValue )
135{
136 switch( aValue )
137 {
138 case types::SheetSide::SHS_UNKNOWN: return SHEET_SIDE::UNDEFINED;
139 case types::SheetSide::SHS_LEFT: return SHEET_SIDE::LEFT;
140 case types::SheetSide::SHS_RIGHT: return SHEET_SIDE::RIGHT;
141 case types::SheetSide::SHS_TOP: return SHEET_SIDE::TOP;
142 case types::SheetSide::SHS_BOTTOM: return SHEET_SIDE::BOTTOM;
143
144 default:
145 wxCHECK_MSG( false, SHEET_SIDE::UNDEFINED,
146 "Unhandled case in FromProtoEnum<types::SheetSide>" );
147 }
148}
149
150
151template<>
152types::SchematicSymbolType ToProtoEnum( LIBRENTRYOPTIONS aValue )
153{
154 switch( aValue )
155 {
156 case LIBRENTRYOPTIONS::ENTRY_NORMAL: return types::SchematicSymbolType::SST_NORMAL;
157 case LIBRENTRYOPTIONS::ENTRY_GLOBAL_POWER: return types::SchematicSymbolType::SST_GLOBAL_POWER;
158 case LIBRENTRYOPTIONS::ENTRY_LOCAL_POWER: return types::SchematicSymbolType::SST_LOCAL_POWER;
159
160 default:
161 wxCHECK_MSG( false, types::SchematicSymbolType::SST_UNKNOWN,
162 "Unhandled case in ToProtoEnum<SHEET_SIDE>" );
163 }
164}
165
166
167template<>
168LIBRENTRYOPTIONS FromProtoEnum( types::SchematicSymbolType aValue )
169{
170 switch( aValue )
171 {
172 case types::SchematicSymbolType::SST_NORMAL: return LIBRENTRYOPTIONS::ENTRY_NORMAL;
173 case types::SchematicSymbolType::SST_GLOBAL_POWER: return LIBRENTRYOPTIONS::ENTRY_GLOBAL_POWER;
174 case types::SchematicSymbolType::SST_LOCAL_POWER: return LIBRENTRYOPTIONS::ENTRY_LOCAL_POWER;
175
176 default:
177 wxCHECK_MSG( false, LIBRENTRYOPTIONS::ENTRY_NORMAL,
178 "Unhandled case in FromProtoEnum<types::SchematicSymbolType>" );
179 }
180}
181
182
183template<>
184types::SchematicSymbolOrientation ToProtoEnum( SYMBOL_ORIENTATION_PROP aValue )
185{
186 switch( aValue )
187 {
188 case SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0: return types::SchematicSymbolOrientation::SSO_0;
189 case SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90: return types::SchematicSymbolOrientation::SSO_90;
190 case SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180: return types::SchematicSymbolOrientation::SSO_180;
191 case SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270: return types::SchematicSymbolOrientation::SSO_270;
192
193 default:
194 wxCHECK_MSG( false, types::SchematicSymbolOrientation::SSO_UNKNOWN,
195 "Unhandled case in ToProtoEnum<SYMBOL_ORIENTATION_PROP>" );
196 }
197}
198
199
200template<>
201SYMBOL_ORIENTATION_PROP FromProtoEnum( types::SchematicSymbolOrientation aValue )
202{
203 switch( aValue )
204 {
205 case types::SchematicSymbolOrientation::SSO_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
206 case types::SchematicSymbolOrientation::SSO_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
207 case types::SchematicSymbolOrientation::SSO_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
208 case types::SchematicSymbolOrientation::SSO_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
209
210 default:
211 wxCHECK_MSG( false, SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0,
212 "Unhandled case in FromProtoEnum<types::SchematicSymbolOrientation>" );
213 }
214}
215
216
217template<>
218types::SchematicPinOrientation ToProtoEnum( PIN_ORIENTATION aValue )
219{
220 switch( aValue )
221 {
222 case PIN_ORIENTATION::PIN_RIGHT: return types::SchematicPinOrientation::SPO_RIGHT;
223 case PIN_ORIENTATION::PIN_LEFT: return types::SchematicPinOrientation::SPO_LEFT;
224 case PIN_ORIENTATION::PIN_UP: return types::SchematicPinOrientation::SPO_UP;
225 case PIN_ORIENTATION::PIN_DOWN: return types::SchematicPinOrientation::SPO_DOWN;
226
227 default:
228 wxCHECK_MSG( false, types::SchematicPinOrientation::SPO_UNKNOWN,
229 "Unhandled case in ToProtoEnum<PIN_ORIENTATION>" );
230 }
231}
232
233
234template<>
235PIN_ORIENTATION FromProtoEnum( types::SchematicPinOrientation aValue )
236{
237 switch( aValue )
238 {
239 case types::SchematicPinOrientation::SPO_RIGHT: return PIN_ORIENTATION::PIN_RIGHT;
240 case types::SchematicPinOrientation::SPO_LEFT: return PIN_ORIENTATION::PIN_LEFT;
241 case types::SchematicPinOrientation::SPO_UP: return PIN_ORIENTATION::PIN_UP;
242 case types::SchematicPinOrientation::SPO_DOWN: return PIN_ORIENTATION::PIN_DOWN;
243
244 default:
245 wxCHECK_MSG( false, PIN_ORIENTATION::PIN_LEFT,
246 "Unhandled case in FromProtoEnum<types::SheetSide>" );
247 }
248}
249
250
251template<>
252types::SchematicPinShape ToProtoEnum( GRAPHIC_PINSHAPE aValue )
253{
254 switch( aValue )
255 {
256 case GRAPHIC_PINSHAPE::LINE: return types::SchematicPinShape::SPS_LINE;
257 case GRAPHIC_PINSHAPE::INVERTED: return types::SchematicPinShape::SPS_INVERTED;
258 case GRAPHIC_PINSHAPE::CLOCK: return types::SchematicPinShape::SPS_CLOCK;
259 case GRAPHIC_PINSHAPE::INVERTED_CLOCK: return types::SchematicPinShape::SPS_INVERTED_CLOCK;
260 case GRAPHIC_PINSHAPE::INPUT_LOW: return types::SchematicPinShape::SPS_INPUT_LOW;
261 case GRAPHIC_PINSHAPE::CLOCK_LOW: return types::SchematicPinShape::SPS_CLOCK_LOW;
262 case GRAPHIC_PINSHAPE::OUTPUT_LOW: return types::SchematicPinShape::SPS_OUTPUT_LOW;
263 case GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK: return types::SchematicPinShape::SPS_FALLING_EDGE_CLOCK;
264 case GRAPHIC_PINSHAPE::NONLOGIC: return types::SchematicPinShape::SPS_NONLOGIC;
265
266 default:
267 wxCHECK_MSG( false, types::SchematicPinShape::SPS_UNKNOWN,
268 "Unhandled case in ToProtoEnum<GRAPHIC_PINSHAPE>" );
269 }
270}
271
272
273template<>
274GRAPHIC_PINSHAPE FromProtoEnum( types::SchematicPinShape aValue )
275{
276 switch( aValue )
277 {
278 case types::SchematicPinShape::SPS_LINE: return GRAPHIC_PINSHAPE::LINE;
279 case types::SchematicPinShape::SPS_INVERTED: return GRAPHIC_PINSHAPE::INVERTED;
280 case types::SchematicPinShape::SPS_CLOCK: return GRAPHIC_PINSHAPE::CLOCK;
281 case types::SchematicPinShape::SPS_INVERTED_CLOCK: return GRAPHIC_PINSHAPE::INVERTED_CLOCK;
282 case types::SchematicPinShape::SPS_INPUT_LOW: return GRAPHIC_PINSHAPE::INPUT_LOW;
283 case types::SchematicPinShape::SPS_CLOCK_LOW: return GRAPHIC_PINSHAPE::CLOCK_LOW;
284 case types::SchematicPinShape::SPS_OUTPUT_LOW: return GRAPHIC_PINSHAPE::OUTPUT_LOW;
285 case types::SchematicPinShape::SPS_FALLING_EDGE_CLOCK: return GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK;
286 case types::SchematicPinShape::SPS_NONLOGIC: return GRAPHIC_PINSHAPE::NONLOGIC;
287
288 default:
289 wxCHECK_MSG( false, GRAPHIC_PINSHAPE::LINE,
290 "Unhandled case in FromProtoEnum<types::SchematicPinShape>" );
291 }
292}
types::SchematicLabelShape ToProtoEnum(LABEL_FLAG_SHAPE aValue)
LABEL_FLAG_SHAPE FromProtoEnum(types::SchematicLabelShape aValue)
LIBRENTRYOPTIONS
Definition lib_symbol.h:58
@ ENTRY_NORMAL
Definition lib_symbol.h:59
@ ENTRY_LOCAL_POWER
Definition lib_symbol.h:61
@ ENTRY_GLOBAL_POWER
Definition lib_symbol.h:60
PIN_ORIENTATION
The symbol library pin object orientations.
Definition pin_type.h:105
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
Definition pin_type.h:127
@ PIN_RIGHT
The pin extends rightwards from the connection point.
Definition pin_type.h:111
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
Definition pin_type.h:118
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
Definition pin_type.h:135
GRAPHIC_PINSHAPE
Definition pin_type.h:84
LABEL_FLAG_SHAPE
Definition sch_label.h:101
@ L_BIDI
Definition sch_label.h:104
@ L_TRISTATE
Definition sch_label.h:105
@ L_UNSPECIFIED
Definition sch_label.h:106
@ F_DOT
Definition sch_label.h:109
@ F_ROUND
Definition sch_label.h:110
@ L_OUTPUT
Definition sch_label.h:103
@ F_DIAMOND
Definition sch_label.h:111
@ L_INPUT
Definition sch_label.h:102
@ F_RECTANGLE
Definition sch_label.h:112
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
SYMBOL_ORIENTATION_PROP
Definition symbol.h:51
@ SYMBOL_ANGLE_180
Definition symbol.h:54
@ SYMBOL_ANGLE_0
Definition symbol.h:52
@ SYMBOL_ANGLE_90
Definition symbol.h:53
@ SYMBOL_ANGLE_270
Definition symbol.h:55