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 The 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 <api/board/board_commands.pb.h>
25#include <wx/wx.h>
26
28#include <padstack.h>
29#include <pcb_dimension.h>
30#include <pcb_track.h>
31#include <zones.h>
32#include <zone_settings.h>
34
35// Adding something new here? Add it to test_api_enums.cpp!
36
37using namespace kiapi::board;
38
39template<>
40types::PadType ToProtoEnum( PAD_ATTRIB aValue )
41{
42 switch( aValue )
43 {
44 case PAD_ATTRIB::PTH: return types::PadType::PT_PTH;
45 case PAD_ATTRIB::SMD: return types::PadType::PT_SMD;
46 case PAD_ATTRIB::CONN: return types::PadType::PT_EDGE_CONNECTOR;
47 case PAD_ATTRIB::NPTH: return types::PadType::PT_NPTH;
48
49 default:
50 wxCHECK_MSG( false, types::PadType::PT_UNKNOWN,
51 "Unhandled case in ToProtoEnum<PAD_ATTRIB>");
52 }
53}
54
55
56template<>
57PAD_ATTRIB FromProtoEnum( types::PadType aValue )
58{
59 switch( aValue )
60 {
61 case types::PadType::PT_UNKNOWN:
62 case types::PadType::PT_PTH: return PAD_ATTRIB::PTH;
63 case types::PadType::PT_SMD: return PAD_ATTRIB::SMD;
64 case types::PadType::PT_EDGE_CONNECTOR: return PAD_ATTRIB::CONN;
65 case types::PadType::PT_NPTH: return PAD_ATTRIB::NPTH;
66
67 default:
68 wxCHECK_MSG( false, PAD_ATTRIB::PTH,
69 "Unhandled case in FromProtoEnum<types::PadType>" );
70 }
71}
72
73template<>
74types::DrillShape ToProtoEnum( PAD_DRILL_SHAPE aValue )
75{
76 switch( aValue )
77 {
78 case PAD_DRILL_SHAPE::CIRCLE: return types::DrillShape::DS_CIRCLE;
79 case PAD_DRILL_SHAPE::OBLONG: return types::DrillShape::DS_OBLONG;
80 case PAD_DRILL_SHAPE::UNDEFINED: return types::DrillShape::DS_UNDEFINED;
81 default:
82 wxCHECK_MSG( false, types::DrillShape::DS_UNKNOWN,
83 "Unhandled case in ToProtoEnum<PAD_DRILL_SHAPE>");
84 }
85}
86
87template<>
88PAD_DRILL_SHAPE FromProtoEnum( types::DrillShape aValue )
89{
90 switch( aValue )
91 {
92 case types::DrillShape::DS_CIRCLE: return PAD_DRILL_SHAPE::CIRCLE;
93 case types::DrillShape::DS_OBLONG: return PAD_DRILL_SHAPE::OBLONG;
94 case types::DrillShape::DS_UNKNOWN:
95 case types::DrillShape::DS_UNDEFINED: return PAD_DRILL_SHAPE::UNDEFINED;
96 default:
97 wxCHECK_MSG( false, PAD_DRILL_SHAPE::UNDEFINED,
98 "Unhandled case in FromProtoEnum<types::DrillShape>" );
99 }
100}
101
102template<>
103types::PadStackShape ToProtoEnum( PAD_SHAPE aValue )
104{
105 switch( aValue )
106 {
107 case PAD_SHAPE::CIRCLE: return types::PadStackShape::PSS_CIRCLE;
108 case PAD_SHAPE::RECTANGLE: return types::PadStackShape::PSS_RECTANGLE;
109 case PAD_SHAPE::OVAL: return types::PadStackShape::PSS_OVAL;
110 case PAD_SHAPE::TRAPEZOID: return types::PadStackShape::PSS_TRAPEZOID;
111 case PAD_SHAPE::ROUNDRECT: return types::PadStackShape::PSS_ROUNDRECT;
112 case PAD_SHAPE::CHAMFERED_RECT: return types::PadStackShape::PSS_CHAMFEREDRECT;
113 case PAD_SHAPE::CUSTOM: return types::PadStackShape::PSS_CUSTOM;
114
115 default:
116 wxCHECK_MSG( false, types::PadStackShape::PSS_UNKNOWN,
117 "Unhandled case in ToProtoEnum<PAD_SHAPE>");
118 }
119}
120
121
122template<>
123PAD_SHAPE FromProtoEnum( types::PadStackShape aValue )
124{
125 switch( aValue )
126 {
127 case types::PadStackShape::PSS_UNKNOWN:
128 case types::PadStackShape::PSS_CIRCLE: return PAD_SHAPE::CIRCLE;
129 case types::PadStackShape::PSS_RECTANGLE: return PAD_SHAPE::RECTANGLE;
130 case types::PadStackShape::PSS_OVAL: return PAD_SHAPE::OVAL;
131 case types::PadStackShape::PSS_TRAPEZOID: return PAD_SHAPE::TRAPEZOID;
132 case types::PadStackShape::PSS_ROUNDRECT: return PAD_SHAPE::ROUNDRECT;
133 case types::PadStackShape::PSS_CHAMFEREDRECT: return PAD_SHAPE::CHAMFERED_RECT;
134 case types::PadStackShape::PSS_CUSTOM: return PAD_SHAPE::CUSTOM;
135
136 default:
137 wxCHECK_MSG( false, PAD_SHAPE::CIRCLE,
138 "Unhandled case in FromProtoEnum<types::PadStackShape>" );
139 }
140}
141
142
143template<>
144types::PadStackType ToProtoEnum( PADSTACK::MODE aValue )
145{
146 switch( aValue )
147 {
148 case PADSTACK::MODE::NORMAL: return types::PadStackType::PST_NORMAL;
149 case PADSTACK::MODE::FRONT_INNER_BACK: return types::PadStackType::PST_FRONT_INNER_BACK;
150 case PADSTACK::MODE::CUSTOM: return types::PadStackType::PST_CUSTOM;
151
152 default:
153 wxCHECK_MSG( false, types::PadStackType::PST_UNKNOWN,
154 "Unhandled case in ToProtoEnum<PADSTACK::MODE>");
155 }
156}
157
158
159template<>
160PADSTACK::MODE FromProtoEnum( types::PadStackType aValue )
161{
162 switch( aValue )
163 {
164 case types::PadStackType::PST_UNKNOWN:
165 case types::PadStackType::PST_NORMAL: return PADSTACK::MODE::NORMAL;
166 case types::PadStackType::PST_FRONT_INNER_BACK: return PADSTACK::MODE::FRONT_INNER_BACK;
167 case types::PadStackType::PST_CUSTOM: return PADSTACK::MODE::CUSTOM;
168
169 default:
170 wxCHECK_MSG( false, PADSTACK::MODE::NORMAL,
171 "Unhandled case in FromProtoEnum<types::PadStackType>" );
172 }
173}
174
175
176template<>
177types::ViaType ToProtoEnum( VIATYPE aValue )
178{
179 switch( aValue )
180 {
181 case VIATYPE::THROUGH: return types::ViaType::VT_THROUGH;
182 case VIATYPE::BLIND_BURIED: return types::ViaType::VT_BLIND_BURIED;
183 case VIATYPE::MICROVIA: return types::ViaType::VT_MICRO;
184
185 default:
186 wxCHECK_MSG( false, types::ViaType::VT_UNKNOWN,
187 "Unhandled case in ToProtoEnum<VIATYPE>");
188 }
189}
190
191
192template<>
193VIATYPE FromProtoEnum( types::ViaType aValue )
194{
195 switch( aValue )
196 {
197 case types::ViaType::VT_UNKNOWN:
198 case types::ViaType::VT_THROUGH: return VIATYPE::THROUGH;
199 case types::ViaType::VT_BLIND_BURIED: return VIATYPE::BLIND_BURIED;
200 case types::ViaType::VT_MICRO: return VIATYPE::MICROVIA;
201
202 default:
203 wxCHECK_MSG( false, VIATYPE::THROUGH,
204 "Unhandled case in FromProtoEnum<types::ViaType>" );
205 }
206}
207
208
209template<>
210types::ZoneConnectionStyle ToProtoEnum( ZONE_CONNECTION aValue )
211{
212 switch( aValue )
213 {
214 case ZONE_CONNECTION::INHERITED: return types::ZoneConnectionStyle::ZCS_INHERITED;
215 case ZONE_CONNECTION::NONE: return types::ZoneConnectionStyle::ZCS_NONE;
216 case ZONE_CONNECTION::THERMAL: return types::ZoneConnectionStyle::ZCS_THERMAL;
217 case ZONE_CONNECTION::FULL: return types::ZoneConnectionStyle::ZCS_FULL;
218 case ZONE_CONNECTION::THT_THERMAL: return types::ZoneConnectionStyle::ZCS_PTH_THERMAL;
219
220 default:
221 wxCHECK_MSG( false, types::ZoneConnectionStyle::ZCS_UNKNOWN,
222 "Unhandled case in ToProtoEnum<ZONE_CONNECTION>");
223 }
224}
225
226
227template<>
228ZONE_CONNECTION FromProtoEnum( types::ZoneConnectionStyle aValue )
229{
230 switch( aValue )
231 {
232 case types::ZoneConnectionStyle::ZCS_UNKNOWN: return ZONE_CONNECTION::INHERITED;
233 case types::ZoneConnectionStyle::ZCS_INHERITED: return ZONE_CONNECTION::INHERITED;
234 case types::ZoneConnectionStyle::ZCS_NONE: return ZONE_CONNECTION::NONE;
235 case types::ZoneConnectionStyle::ZCS_THERMAL: return ZONE_CONNECTION::THERMAL;
236 case types::ZoneConnectionStyle::ZCS_FULL: return ZONE_CONNECTION::FULL;
237 case types::ZoneConnectionStyle::ZCS_PTH_THERMAL: return ZONE_CONNECTION::THT_THERMAL;
238
239 default:
240 wxCHECK_MSG( false, ZONE_CONNECTION::INHERITED,
241 "Unhandled case in FromProtoEnum<types::ZoneConnectionStyle>" );
242 }
243}
244
245
246template<>
247types::UnconnectedLayerRemoval ToProtoEnum( PADSTACK::UNCONNECTED_LAYER_MODE aValue )
248{
249 switch( aValue )
250 {
252 return types::UnconnectedLayerRemoval::ULR_KEEP;
253
255 return types::UnconnectedLayerRemoval::ULR_REMOVE;
256
258 return types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END;
259
260 default:
261 wxCHECK_MSG( false, types::UnconnectedLayerRemoval::ULR_UNKNOWN,
262 "Unhandled case in ToProtoEnum<PADSTACK::UNCONNECTED_LAYER_MODE>");
263 }
264}
265
266
267template<>
268PADSTACK::UNCONNECTED_LAYER_MODE FromProtoEnum( types::UnconnectedLayerRemoval aValue )
269{
270 switch( aValue )
271 {
272 case types::UnconnectedLayerRemoval::ULR_UNKNOWN:
273 case types::UnconnectedLayerRemoval::ULR_KEEP:
275
276 case types::UnconnectedLayerRemoval::ULR_REMOVE:
278
279 case types::UnconnectedLayerRemoval::ULR_REMOVE_EXCEPT_START_AND_END:
281
282 default:
284 "Unhandled case in FromProtoEnum<types::UnconnectedLayerRemoval>");
285 }
286}
287
288
289template<>
290types::IslandRemovalMode ToProtoEnum( ISLAND_REMOVAL_MODE aValue )
291{
292 switch( aValue )
293 {
294 case ISLAND_REMOVAL_MODE::ALWAYS: return types::IslandRemovalMode::IRM_ALWAYS;
295 case ISLAND_REMOVAL_MODE::NEVER: return types::IslandRemovalMode::IRM_NEVER;
296 case ISLAND_REMOVAL_MODE::AREA: return types::IslandRemovalMode::IRM_AREA;
297
298 default:
299 wxCHECK_MSG( false, types::IslandRemovalMode::IRM_UNKNOWN,
300 "Unhandled case in ToProtoEnum<ISLAND_REMOVAL_MODE>");
301 }
302}
303
304
305template<>
306ISLAND_REMOVAL_MODE FromProtoEnum( types::IslandRemovalMode aValue )
307{
308 switch( aValue )
309 {
310 case types::IslandRemovalMode::IRM_UNKNOWN:
311 case types::IslandRemovalMode::IRM_ALWAYS: return ISLAND_REMOVAL_MODE::ALWAYS;
312 case types::IslandRemovalMode::IRM_NEVER: return ISLAND_REMOVAL_MODE::NEVER;
313 case types::IslandRemovalMode::IRM_AREA: return ISLAND_REMOVAL_MODE::AREA;
314
315 default:
316 wxCHECK_MSG( false, ISLAND_REMOVAL_MODE::ALWAYS,
317 "Unhandled case in FromProtoEnum<types::IslandRemovalMode>" );
318 }
319}
320
321
322template<>
323types::ZoneFillMode ToProtoEnum( ZONE_FILL_MODE aValue )
324{
325 switch( aValue )
326 {
327 case ZONE_FILL_MODE::POLYGONS: return types::ZoneFillMode::ZFM_SOLID;
328 case ZONE_FILL_MODE::HATCH_PATTERN: return types::ZoneFillMode::ZFM_HATCHED;
329
330 default:
331 wxCHECK_MSG( false, types::ZoneFillMode::ZFM_UNKNOWN,
332 "Unhandled case in ToProtoEnum<ZONE_FILL_MODE>");
333 }
334}
335
336
337template<>
338ZONE_FILL_MODE FromProtoEnum( types::ZoneFillMode aValue )
339{
340 switch( aValue )
341 {
342 case types::ZoneFillMode::ZFM_UNKNOWN:
343 case types::ZoneFillMode::ZFM_SOLID: return ZONE_FILL_MODE::POLYGONS;
344 case types::ZoneFillMode::ZFM_HATCHED: return ZONE_FILL_MODE::HATCH_PATTERN;
345
346 default:
347 wxCHECK_MSG( false, ZONE_FILL_MODE::POLYGONS,
348 "Unhandled case in FromProtoEnum<types::ZoneFillMode>" );
349 }
350}
351
352
353template<>
354types::ZoneBorderStyle ToProtoEnum( ZONE_BORDER_DISPLAY_STYLE aValue )
355{
356 switch( aValue )
357 {
358 case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: return types::ZoneBorderStyle::ZBS_SOLID;
359 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: return types::ZoneBorderStyle::ZBS_DIAGONAL_FULL;
360 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: return types::ZoneBorderStyle::ZBS_DIAGONAL_EDGE;
361 case ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER: return types::ZoneBorderStyle::ZBS_INVISIBLE;
362
363 default:
364 wxCHECK_MSG( false, types::ZoneBorderStyle::ZBS_UNKNOWN,
365 "Unhandled case in ToProtoEnum<ZONE_BORDER_DISPLAY_STYLE>");
366 }
367}
368
369
370template<>
371ZONE_BORDER_DISPLAY_STYLE FromProtoEnum( types::ZoneBorderStyle aValue )
372{
373 switch( aValue )
374 {
375 case types::ZoneBorderStyle::ZBS_SOLID: return ZONE_BORDER_DISPLAY_STYLE::NO_HATCH;
376 case types::ZoneBorderStyle::ZBS_DIAGONAL_FULL: return ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL;
377 case types::ZoneBorderStyle::ZBS_UNKNOWN:
378 case types::ZoneBorderStyle::ZBS_DIAGONAL_EDGE: return ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE;
379 case types::ZoneBorderStyle::ZBS_INVISIBLE: return ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER;
380
381 default:
383 "Unhandled case in FromProtoEnum<types::ZoneHatchBorderMode>" );
384 }
385}
386
387
388template<>
389types::PlacementRuleSourceType ToProtoEnum( RULE_AREA_PLACEMENT_SOURCE_TYPE aValue )
390{
391 switch( aValue )
392 {
394 return types::PlacementRuleSourceType::PRST_SHEET_NAME;
395
397 return types::PlacementRuleSourceType::PRST_COMPONENT_CLASS;
398
399 default:
400 wxCHECK_MSG( false, types::PlacementRuleSourceType::PRST_UNKNOWN,
401 "Unhandled case in ToProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE>");
402 }
403}
404
405
406template<>
407RULE_AREA_PLACEMENT_SOURCE_TYPE FromProtoEnum( types::PlacementRuleSourceType aValue )
408{
409 switch( aValue )
410 {
411 case types::PlacementRuleSourceType::PRST_UNKNOWN:
412 case types::PlacementRuleSourceType::PRST_SHEET_NAME:
414
415 case types::PlacementRuleSourceType::PRST_COMPONENT_CLASS:
417
418 default:
420 "Unhandled case in FromProtoEnum<types::PlacementRuleSourceType>" );
421 }
422}
423
424
425template<>
426types::TeardropType ToProtoEnum( TEARDROP_TYPE aValue )
427{
428 switch( aValue )
429 {
430 case TEARDROP_TYPE::TD_NONE: return types::TeardropType::TDT_NONE;
431 case TEARDROP_TYPE::TD_UNSPECIFIED: return types::TeardropType::TDT_UNSPECIFIED;
432 case TEARDROP_TYPE::TD_VIAPAD: return types::TeardropType::TDT_VIA_PAD;
433 case TEARDROP_TYPE::TD_TRACKEND: return types::TeardropType::TDT_TRACK_END;
434
435 default:
436 wxCHECK_MSG( false, types::TeardropType::TDT_UNKNOWN,
437 "Unhandled case in ToProtoEnum<TEARDROP_TYPE>");
438 }
439}
440
441
442template<>
443TEARDROP_TYPE FromProtoEnum( types::TeardropType aValue )
444{
445 switch( aValue )
446 {
447 case types::TeardropType::TDT_UNKNOWN:
448 case types::TeardropType::TDT_NONE: return TEARDROP_TYPE::TD_NONE;
449 case types::TeardropType::TDT_UNSPECIFIED: return TEARDROP_TYPE::TD_UNSPECIFIED;
450 case types::TeardropType::TDT_VIA_PAD: return TEARDROP_TYPE::TD_VIAPAD;
451 case types::TeardropType::TDT_TRACK_END: return TEARDROP_TYPE::TD_TRACKEND;
452
453 default:
454 wxCHECK_MSG( false, TEARDROP_TYPE::TD_NONE,
455 "Unhandled case in FromProtoEnum<types::ZoneHatchBorderMode>" );
456 }
457}
458
459
460template<>
461types::DimensionTextBorderStyle ToProtoEnum( DIM_TEXT_BORDER aValue )
462{
463 switch( aValue )
464 {
465 case DIM_TEXT_BORDER::NONE: return types::DimensionTextBorderStyle::DTBS_NONE;
466 case DIM_TEXT_BORDER::RECTANGLE: return types::DimensionTextBorderStyle::DTBS_RECTANGLE;
467 case DIM_TEXT_BORDER::CIRCLE: return types::DimensionTextBorderStyle::DTBS_CIRCLE;
468 case DIM_TEXT_BORDER::ROUNDRECT: return types::DimensionTextBorderStyle::DTBS_ROUNDRECT;
469
470 default:
471 wxCHECK_MSG( false, types::DimensionTextBorderStyle::DTBS_UNKNOWN,
472 "Unhandled case in ToProtoEnum<DIM_TEXT_BORDER>");
473 }
474}
475
476
477template<>
478DIM_TEXT_BORDER FromProtoEnum( types::DimensionTextBorderStyle aValue )
479{
480 switch( aValue )
481 {
482 case types::DimensionTextBorderStyle::DTBS_UNKNOWN:
483 case types::DimensionTextBorderStyle::DTBS_NONE: return DIM_TEXT_BORDER::NONE;
484 case types::DimensionTextBorderStyle::DTBS_RECTANGLE: return DIM_TEXT_BORDER::RECTANGLE;
485 case types::DimensionTextBorderStyle::DTBS_CIRCLE: return DIM_TEXT_BORDER::CIRCLE;
486 case types::DimensionTextBorderStyle::DTBS_ROUNDRECT: return DIM_TEXT_BORDER::ROUNDRECT;
487
488 default:
489 wxCHECK_MSG( false, DIM_TEXT_BORDER::NONE,
490 "Unhandled case in FromProtoEnum<types::DimensionTextBorderStyle>" );
491 }
492}
493
494
495template<>
496types::DimensionUnitFormat ToProtoEnum( DIM_UNITS_FORMAT aValue )
497{
498 switch( aValue )
499 {
500 case DIM_UNITS_FORMAT::NO_SUFFIX: return types::DimensionUnitFormat::DUF_NO_SUFFIX;
501 case DIM_UNITS_FORMAT::BARE_SUFFIX: return types::DimensionUnitFormat::DUF_BARE_SUFFIX;
502 case DIM_UNITS_FORMAT::PAREN_SUFFIX: return types::DimensionUnitFormat::DUF_PAREN_SUFFIX;
503
504 default:
505 wxCHECK_MSG( false, types::DimensionUnitFormat::DUF_UNKNOWN,
506 "Unhandled case in ToProtoEnum<DIM_UNITS_FORMAT>");
507 }
508}
509
510
511template<>
512DIM_UNITS_FORMAT FromProtoEnum( types::DimensionUnitFormat aValue )
513{
514 switch( aValue )
515 {
516 case types::DimensionUnitFormat::DUF_UNKNOWN:
517 case types::DimensionUnitFormat::DUF_NO_SUFFIX: return DIM_UNITS_FORMAT::NO_SUFFIX;
518 case types::DimensionUnitFormat::DUF_BARE_SUFFIX: return DIM_UNITS_FORMAT::BARE_SUFFIX;
519 case types::DimensionUnitFormat::DUF_PAREN_SUFFIX: return DIM_UNITS_FORMAT::PAREN_SUFFIX;
520
521 default:
522 wxCHECK_MSG( false, DIM_UNITS_FORMAT::NO_SUFFIX,
523 "Unhandled case in FromProtoEnum<types::DimensionUnitFormat>" );
524 }
525}
526
527
528template<>
529types::DimensionArrowDirection ToProtoEnum( DIM_ARROW_DIRECTION aValue )
530{
531 switch( aValue )
532 {
533 case DIM_ARROW_DIRECTION::INWARD: return types::DimensionArrowDirection::DAD_INWARD;
534 case DIM_ARROW_DIRECTION::OUTWARD: return types::DimensionArrowDirection::DAD_OUTWARD;
535
536 default:
537 wxCHECK_MSG( false, types::DimensionArrowDirection::DAD_UNKNOWN,
538 "Unhandled case in ToProtoEnum<DIM_ARROW_DIRECTION>");
539 }
540}
541
542
543template<>
544DIM_ARROW_DIRECTION FromProtoEnum( types::DimensionArrowDirection aValue )
545{
546 switch( aValue )
547 {
548 case types::DimensionArrowDirection::DAD_INWARD: return DIM_ARROW_DIRECTION::INWARD;
549 case types::DimensionArrowDirection::DAD_UNKNOWN:
550 case types::DimensionArrowDirection::DAD_OUTWARD: return DIM_ARROW_DIRECTION::OUTWARD;
551
552 default:
553 wxCHECK_MSG( false, DIM_ARROW_DIRECTION::OUTWARD,
554 "Unhandled case in FromProtoEnum<types::DimensionArrowDirection>" );
555 }
556}
557
558
559template<>
560types::DimensionPrecision ToProtoEnum( DIM_PRECISION aValue )
561{
562 switch( aValue )
563 {
564 case DIM_PRECISION::X: return types::DimensionPrecision::DP_FIXED_0;
565 case DIM_PRECISION::X_X: return types::DimensionPrecision::DP_FIXED_1;
566 case DIM_PRECISION::X_XX: return types::DimensionPrecision::DP_FIXED_2;
567 case DIM_PRECISION::X_XXX: return types::DimensionPrecision::DP_FIXED_3;
568 case DIM_PRECISION::X_XXXX: return types::DimensionPrecision::DP_FIXED_4;
569 case DIM_PRECISION::X_XXXXX: return types::DimensionPrecision::DP_FIXED_5;
570 case DIM_PRECISION::V_VV: return types::DimensionPrecision::DP_SCALED_IN_2;
571 case DIM_PRECISION::V_VVV: return types::DimensionPrecision::DP_SCALED_IN_3;
572 case DIM_PRECISION::V_VVVV: return types::DimensionPrecision::DP_SCALED_IN_4;
573 case DIM_PRECISION::V_VVVVV: return types::DimensionPrecision::DP_SCALED_IN_5;
574
575 default:
576 wxCHECK_MSG( false, types::DimensionPrecision::DP_UNKNOWN,
577 "Unhandled case in ToProtoEnum<DIM_PRECISION>");
578 }
579}
580
581
582template<>
583DIM_PRECISION FromProtoEnum( types::DimensionPrecision aValue )
584{
585 switch( aValue )
586 {
587 case types::DimensionPrecision::DP_FIXED_0: return DIM_PRECISION::X;
588 case types::DimensionPrecision::DP_FIXED_1: return DIM_PRECISION::X_X;
589 case types::DimensionPrecision::DP_FIXED_2: return DIM_PRECISION::X_XX;
590 case types::DimensionPrecision::DP_FIXED_3: return DIM_PRECISION::X_XXX;
591 case types::DimensionPrecision::DP_FIXED_4: return DIM_PRECISION::X_XXXX;
592 case types::DimensionPrecision::DP_FIXED_5: return DIM_PRECISION::X_XXXXX;
593 case types::DimensionPrecision::DP_UNKNOWN:
594 case types::DimensionPrecision::DP_SCALED_IN_2: return DIM_PRECISION::V_VV;
595 case types::DimensionPrecision::DP_SCALED_IN_3: return DIM_PRECISION::V_VVV;
596 case types::DimensionPrecision::DP_SCALED_IN_4: return DIM_PRECISION::V_VVVV;
597 case types::DimensionPrecision::DP_SCALED_IN_5: return DIM_PRECISION::V_VVVVV;
598
599 default:
600 wxCHECK_MSG( false, DIM_PRECISION::V_VV,
601 "Unhandled case in FromProtoEnum<types::DimensionPrecision>" );
602 }
603}
604
605
606template<>
607types::DimensionTextPosition ToProtoEnum( DIM_TEXT_POSITION aValue )
608{
609 switch( aValue )
610 {
611 case DIM_TEXT_POSITION::OUTSIDE: return types::DimensionTextPosition::DTP_OUTSIDE;
612 case DIM_TEXT_POSITION::INLINE: return types::DimensionTextPosition::DTP_INLINE;
613 case DIM_TEXT_POSITION::MANUAL: return types::DimensionTextPosition::DTP_MANUAL;
614
615 default:
616 wxCHECK_MSG( false, types::DimensionTextPosition::DTP_UNKNOWN,
617 "Unhandled case in ToProtoEnum<DIM_TEXT_POSITION>");
618 }
619}
620
621
622template<>
623DIM_TEXT_POSITION FromProtoEnum( types::DimensionTextPosition aValue )
624{
625 switch( aValue )
626 {
627 case types::DimensionTextPosition::DTP_UNKNOWN:
628 case types::DimensionTextPosition::DTP_OUTSIDE: return DIM_TEXT_POSITION::OUTSIDE;
629 case types::DimensionTextPosition::DTP_INLINE: return DIM_TEXT_POSITION::INLINE;
630 case types::DimensionTextPosition::DTP_MANUAL: return DIM_TEXT_POSITION::MANUAL;
631
632 default:
633 wxCHECK_MSG( false, DIM_TEXT_POSITION::OUTSIDE,
634 "Unhandled case in FromProtoEnum<types::DimensionTextPosition>" );
635 }
636}
637
638
639template<>
640types::DimensionUnit ToProtoEnum( DIM_UNITS_MODE aValue )
641{
642 switch( aValue )
643 {
644 case DIM_UNITS_MODE::INCHES: return types::DimensionUnit::DU_INCHES;
645 case DIM_UNITS_MODE::MILS: return types::DimensionUnit::DU_MILS;
646 case DIM_UNITS_MODE::MILLIMETRES: return types::DimensionUnit::DU_MILLIMETERS;
647 case DIM_UNITS_MODE::AUTOMATIC: return types::DimensionUnit::DU_AUTOMATIC;
648
649 default:
650 wxCHECK_MSG( false, types::DimensionUnit::DU_UNKNOWN,
651 "Unhandled case in ToProtoEnum<DIM_UNITS_MODE>");
652 }
653}
654
655
656template<>
657DIM_UNITS_MODE FromProtoEnum( types::DimensionUnit aValue )
658{
659 switch( aValue )
660 {
661 case types::DimensionUnit::DU_INCHES: return DIM_UNITS_MODE::INCHES;
662 case types::DimensionUnit::DU_MILS: return DIM_UNITS_MODE::MILS;
663 case types::DimensionUnit::DU_MILLIMETERS: return DIM_UNITS_MODE::MILLIMETRES;
664 case types::DimensionUnit::DU_UNKNOWN:
665 case types::DimensionUnit::DU_AUTOMATIC: return DIM_UNITS_MODE::AUTOMATIC;
666
667 default:
668 wxCHECK_MSG( false, DIM_UNITS_MODE::AUTOMATIC,
669 "Unhandled case in FromProtoEnum<types::DimensionUnit>" );
670 }
671}
672
673
674template<>
675commands::InactiveLayerDisplayMode ToProtoEnum( HIGH_CONTRAST_MODE aValue )
676{
677 switch( aValue )
678 {
679 case HIGH_CONTRAST_MODE::NORMAL: return commands::InactiveLayerDisplayMode::ILDM_NORMAL;
680 case HIGH_CONTRAST_MODE::DIMMED: return commands::InactiveLayerDisplayMode::ILDM_DIMMED;
681 case HIGH_CONTRAST_MODE::HIDDEN: return commands::InactiveLayerDisplayMode::ILDM_HIDDEN;
682
683 default:
684 wxCHECK_MSG( false, commands::InactiveLayerDisplayMode::ILDM_NORMAL,
685 "Unhandled case in ToProtoEnum<HIGH_CONTRAST_MODE>");
686 }
687}
688
689
690template<>
691HIGH_CONTRAST_MODE FromProtoEnum( commands::InactiveLayerDisplayMode aValue )
692{
693 switch( aValue )
694 {
695 case commands::InactiveLayerDisplayMode::ILDM_DIMMED: return HIGH_CONTRAST_MODE::DIMMED;
696 case commands::InactiveLayerDisplayMode::ILDM_HIDDEN: return HIGH_CONTRAST_MODE::HIDDEN;
697 case commands::InactiveLayerDisplayMode::ILDM_UNKNOWN:
698 case commands::InactiveLayerDisplayMode::ILDM_NORMAL: return HIGH_CONTRAST_MODE::NORMAL;
699
700 default:
701 wxCHECK_MSG( false, HIGH_CONTRAST_MODE::NORMAL,
702 "Unhandled case in FromProtoEnum<commands::InactiveLayerDisplayMode>" );
703 }
704}
705
706
707template<>
708commands::NetColorDisplayMode ToProtoEnum( NET_COLOR_MODE aValue )
709{
710 switch( aValue )
711 {
712 case NET_COLOR_MODE::ALL: return commands::NetColorDisplayMode::NCDM_ALL;
713 case NET_COLOR_MODE::RATSNEST: return commands::NetColorDisplayMode::NCDM_RATSNEST;
714 case NET_COLOR_MODE::OFF: return commands::NetColorDisplayMode::NCDM_OFF;
715
716 default:
717 wxCHECK_MSG( false, commands::NetColorDisplayMode::NCDM_UNKNOWN,
718 "Unhandled case in ToProtoEnum<NET_COLOR_MODE>");
719 }
720}
721
722
723template<>
724NET_COLOR_MODE FromProtoEnum( commands::NetColorDisplayMode aValue )
725{
726 switch( aValue )
727 {
728 case commands::NetColorDisplayMode::NCDM_ALL: return NET_COLOR_MODE::ALL;
729 case commands::NetColorDisplayMode::NCDM_OFF: return NET_COLOR_MODE::OFF;
730 case commands::NetColorDisplayMode::NCDM_UNKNOWN:
731 case commands::NetColorDisplayMode::NCDM_RATSNEST: return NET_COLOR_MODE::RATSNEST;
732
733 default:
734 wxCHECK_MSG( false, NET_COLOR_MODE::RATSNEST,
735 "Unhandled case in FromProtoEnum<commands::NetColorDisplayMode>" );
736 }
737}
738
739
740template<>
741commands::RatsnestDisplayMode ToProtoEnum( RATSNEST_MODE aValue )
742{
743 switch( aValue )
744 {
745 case RATSNEST_MODE::ALL: return commands::RatsnestDisplayMode::RDM_ALL_LAYERS;
746 case RATSNEST_MODE::VISIBLE: return commands::RatsnestDisplayMode::RDM_VISIBLE_LAYERS;
747
748 default:
749 wxCHECK_MSG( false, commands::RatsnestDisplayMode::RDM_UNKNOWN,
750 "Unhandled case in ToProtoEnum<RATSNEST_MODE>");
751 }
752}
753
754
755template<>
756RATSNEST_MODE FromProtoEnum( commands::RatsnestDisplayMode aValue )
757{
758 switch( aValue )
759 {
760 case commands::RatsnestDisplayMode::RDM_VISIBLE_LAYERS: return RATSNEST_MODE::VISIBLE;
761 case commands::RatsnestDisplayMode::RDM_UNKNOWN:
762 case commands::RatsnestDisplayMode::RDM_ALL_LAYERS: return RATSNEST_MODE::ALL;
763
764 default:
765 wxCHECK_MSG( false, RATSNEST_MODE::ALL,
766 "Unhandled case in FromProtoEnum<commands::RatsnestDisplayMode>" );
767 }
768}
769
770
771template<>
772BoardStackupLayerType ToProtoEnum( BOARD_STACKUP_ITEM_TYPE aValue )
773{
774 switch( aValue )
775 {
776 case BS_ITEM_TYPE_UNDEFINED: return BoardStackupLayerType::BSLT_UNDEFINED;
777 case BS_ITEM_TYPE_COPPER: return BoardStackupLayerType::BSLT_COPPER;
778 case BS_ITEM_TYPE_DIELECTRIC: return BoardStackupLayerType::BSLT_DIELECTRIC;
779 case BS_ITEM_TYPE_SOLDERPASTE: return BoardStackupLayerType::BSLT_SOLDERPASTE;
780 case BS_ITEM_TYPE_SOLDERMASK: return BoardStackupLayerType::BSLT_SOLDERMASK;
781 case BS_ITEM_TYPE_SILKSCREEN: return BoardStackupLayerType::BSLT_SILKSCREEN;
782
783 default:
784 wxCHECK_MSG( false, BoardStackupLayerType::BSLT_UNKNOWN,
785 "Unhandled case in ToProtoEnum<BOARD_STACKUP_ITEM_TYPE>");
786 }
787}
788
789
790template<>
791BOARD_STACKUP_ITEM_TYPE FromProtoEnum( BoardStackupLayerType aValue )
792{
793 switch( aValue )
794 {
795 case BoardStackupLayerType::BSLT_UNDEFINED: return BS_ITEM_TYPE_UNDEFINED;
796 case BoardStackupLayerType::BSLT_COPPER: return BS_ITEM_TYPE_COPPER;
797 case BoardStackupLayerType::BSLT_DIELECTRIC: return BS_ITEM_TYPE_DIELECTRIC;
798 case BoardStackupLayerType::BSLT_SOLDERPASTE: return BS_ITEM_TYPE_SOLDERPASTE;
799 case BoardStackupLayerType::BSLT_SOLDERMASK: return BS_ITEM_TYPE_SOLDERMASK;
800 case BoardStackupLayerType::BSLT_SILKSCREEN: return BS_ITEM_TYPE_SILKSCREEN;
801
802 default:
803 wxCHECK_MSG( false, BS_ITEM_TYPE_UNDEFINED,
804 "Unhandled case in FromProtoEnum<BoardStackupLayerType>" );
805 }
806}
807
808// Adding something new here? Add it to test_api_enums.cpp!
types::PadType ToProtoEnum(PAD_ATTRIB aValue)
PAD_ATTRIB FromProtoEnum(types::PadType aValue)
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ ALL
Net/netclass colors are shown on all net copper.
@ OFF
Net (and netclass) colors are not shown.
@ VISIBLE
Ratsnest lines are drawn to items on visible layers only.
@ ALL
Ratsnest lines are drawn to items on all layers (default)
BOARD_STACKUP_ITEM_TYPE
Definition: board_stackup.h:43
@ BS_ITEM_TYPE_UNDEFINED
Definition: board_stackup.h:44
@ BS_ITEM_TYPE_COPPER
Definition: board_stackup.h:45
@ BS_ITEM_TYPE_SILKSCREEN
Definition: board_stackup.h:51
@ BS_ITEM_TYPE_DIELECTRIC
Definition: board_stackup.h:46
@ BS_ITEM_TYPE_SOLDERPASTE
Definition: board_stackup.h:48
@ BS_ITEM_TYPE_SOLDERMASK
Definition: board_stackup.h:49
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
DIM_TEXT_POSITION
Where to place the text on a dimension.
Definition: pcb_dimension.h:62
@ OUTSIDE
Text appears outside the dimension line (default)
@ MANUAL
Text placement is manually set by the user.
@ INLINE
Text appears in line with the dimension line.
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
Definition: pcb_dimension.h:40
DIM_UNITS_MODE
Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it.
Definition: pcb_dimension.h:72
DIM_ARROW_DIRECTION
Used for dimension's arrow.
Definition: pcb_dimension.h:83
DIM_TEXT_BORDER
Frame to show around dimension text.
Definition: pcb_dimension.h:92
DIM_PRECISION
Definition: pcb_dimension.h:47
VIATYPE
Definition: pcb_track.h:66
@ BLIND_BURIED
TEARDROP_TYPE
define the type of a teardrop: on a via or pad, or a track end
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
RULE_AREA_PLACEMENT_SOURCE_TYPE
Definition: zone_settings.h:66
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:59
ZONE_FILL_MODE
Definition: zone_settings.h:42
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:50
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