KiCad PCB EDA Suite
altium_parser_sch.h
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) 2020 Thomas Pointhuber <thomas.pointhuber@gmx.at>
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef ALTIUM_PARSER_SCH_H
26 #define ALTIUM_PARSER_SCH_H
27 
28 #include <cstdint>
29 #include <cstring>
30 #include <map>
31 #include <vector>
32 
33 #include <wx/gdicmn.h>
34 #include <wx/string.h>
35 
36 // this constant specifies a item which is not inside an component
37 const int ALTIUM_COMPONENT_NONE = -1;
38 
39 class ALTIUM_PARSER;
40 
42 {
43  wxString filename;
44  std::vector<char> data;
45 
46  explicit ASCH_STORAGE_FILE( ALTIUM_PARSER& aReader );
47 };
48 
49 
51 {
52  HEADER = 0,
53  COMPONENT = 1,
54  PIN = 2,
55  IEEE_SYMBOL = 3,
56  LABEL = 4,
57  BEZIER = 5,
58  POLYLINE = 6,
59  POLYGON = 7,
60  ELLIPSE = 8,
61  PIECHART = 9,
62  ROUND_RECTANGLE = 10,
63  ELLIPTICAL_ARC = 11,
64  ARC = 12,
65  LINE = 13,
66  RECTANGLE = 14,
67  SHEET_SYMBOL = 15,
68  SHEET_ENTRY = 16,
69  POWER_PORT = 17,
70  PORT = 18,
71  NO_ERC = 22,
72  NET_LABEL = 25,
73  BUS = 26,
74  WIRE = 27,
75  TEXT_FRAME = 28,
76  JUNCTION = 29,
77  IMAGE = 30,
78  SHEET = 31,
79  SHEET_NAME = 32,
80  FILE_NAME = 33,
81  DESIGNATOR = 34,
82  BUS_ENTRY = 37,
83  TEMPLATE = 39,
84  PARAMETER = 41,
85  WARNING_SIGN = 43,
87  IMPLEMENTATION = 45,
88  RECORD_46 = 46,
89  RECORD_47 = 47,
90  RECORD_48 = 48,
91  RECORD_209 = 209,
92  RECORD_215 = 215,
93  RECORD_216 = 216,
94  RECORD_217 = 217,
95  RECORD_218 = 218,
96  RECORD_226 = 226,
97 };
98 
99 
101 {
102  RIGHTWARDS = 0,
103  UPWARDS = 1,
104  LEFTWARDS = 2,
105  DOWNWARDS = 3
106 };
107 
108 
110 {
112  wxString libreference;
115 
118  wxPoint location;
119 
123 
124  explicit ASCH_SYMBOL( const std::map<wxString, wxString>& aProperties );
125 };
126 
127 
129 {
130  UNKNOWN = -1,
131  NO_SYMBOL = 0,
133  ANALOG_SIGNAL_IN = 5,
135  DIGITAL_SIGNAL_IN = 25,
137  BIDI_SIGNAL_FLOW = 34
138 };
139 
140 
142 {
143  UNKNOWN = -1,
144  NO_SYMBOL = 0,
145  POSPONED_OUTPUT = 8,
146  OPEN_COLLECTOR = 9,
147  HIZ = 10,
148  HIGH_CURRENT = 11,
149  PULSE = 12,
150  SCHMITT = 13,
152  OPEN_EMITTER = 23,
154  SHIFT_LEFT = 30,
155  OPEN_OUTPUT = 32
156 };
157 
158 
160 {
161  UNKNOWN = -1,
162  NO_SYMBOL = 0,
163  NEGATED = 1,
164  LOW_INPUT = 4,
165  LOW_OUTPUT = 17
166 };
167 
168 
170 {
171  UNKNOWN = -1,
172  NO_SYMBOL = 0,
173  CLOCK = 3,
174 };
175 
176 
178 {
179  UNKNOWN = -1,
180 
181  INPUT = 0,
182  BIDI = 1,
183  OUTPUT = 2,
184  OPEN_COLLECTOR = 3,
185  PASSIVE = 4,
186  TRISTATE = 5,
187  OPEN_EMITTER = 6,
188  POWER = 7
189 };
190 
191 
192 struct ASCH_PIN
193 {
197 
198  wxString name;
199  wxString text;
200  wxString designator;
201 
204 
207 
210 
211  wxPoint location;
213 
214  wxPoint kicadLocation; // location of pin in KiCad without rounding error
215 
218 
219  explicit ASCH_PIN( const std::map<wxString, wxString>& aProperties );
220 };
221 
222 
224 {
225  UNKNOWN = -1,
226 
227  BOTTOM_LEFT = 0,
228  BOTTOM_CENTER = 1,
229  BOTTOM_RIGHT = 2,
230  CENTER_LEFT = 3,
231  CENTER_CENTER = 4,
232  CENTER_RIGHT = 5,
233  TOP_LEFT = 6,
234  TOP_CENTER = 7,
235  TOP_RIGHT = 8
236 };
237 
238 
240 {
243 
244  wxPoint location;
245 
246  wxString text;
247 
248  int fontId;
250 
252 
253  explicit ASCH_LABEL( const std::map<wxString, wxString>& aProperties );
254 };
255 
256 
258 {
262 
263  std::vector<wxPoint> points;
264 
266 
267  explicit ASCH_BEZIER( const std::map<wxString, wxString>& aProperties );
268 };
269 
270 
272 {
273  SOLID = 0,
274  DASHED = 1,
275  DOTTED = 2,
276  DASH_DOTTED = 3
277 };
278 
279 
281 {
285 
286  std::vector<wxPoint> points;
287 
289 
291 
292  explicit ASCH_POLYLINE( const std::map<wxString, wxString>& aProperties );
293 };
294 
295 
297 {
301 
302  std::vector<wxPoint> points;
303 
305  bool isSolid;
306 
307  int color;
309 
310  explicit ASCH_POLYGON( const std::map<wxString, wxString>& aProperties );
311 };
312 
313 
315 {
319 
320  wxPoint bottomLeft;
321  wxPoint topRight;
322 
323  wxSize cornerradius;
324 
326  bool isSolid;
328 
329  int color;
331 
332  explicit ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProperties );
333 };
334 
335 
336 struct ASCH_ARC
337 {
341 
342  wxPoint center;
343  int radius;
344  double startAngle;
345  double endAngle;
346 
348 
349  explicit ASCH_ARC( const std::map<wxString, wxString>& aProperties );
350 };
351 
352 
353 struct ASCH_LINE
354 {
358 
359  wxPoint point1;
360  wxPoint point2;
361 
363 
364  explicit ASCH_LINE( const std::map<wxString, wxString>& aProperties );
365 };
366 
367 
369 {
373 
374  wxPoint bottomLeft;
375  wxPoint topRight;
376 
378  bool isSolid;
380 
381  int color;
383 
384  explicit ASCH_RECTANGLE( const std::map<wxString, wxString>& aProperties );
385 };
386 
387 
389 {
390  wxPoint location;
391  wxSize size;
392 
393  bool isSolid;
394 
395  int color;
397 
398  explicit ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProperties );
399 };
400 
401 
403 {
404  LEFT = 0,
405  RIGHT = 1,
406  TOP = 2,
407  BOTTOM = 3
408 };
409 
410 
412 {
413  UNSPECIFIED = 0,
414  OUTPUT = 1,
415  INPUT = 2,
416  BIDI = 3,
417 };
418 
419 
420 enum class ASCH_PORT_STYLE
421 {
422  NONE_HORIZONTAL = 0,
423  LEFT = 1,
424  RIGHT = 2,
425  LEFT_RIGHT = 3,
426  NONE_VERTICAL = 4,
427  TOP = 5,
428  BOTTOM = 6,
429  TOP_BOTTOM = 7
430 };
431 
432 
434 {
437 
439 
443 
444  wxString name;
445 
446  explicit ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProperties );
447 };
448 
449 
451 {
452  UNKNOWN = -1,
453 
454  CIRCLE = 0,
455  ARROW = 1,
456  BAR = 2,
457  WAVE = 3,
458  POWER_GROUND = 4,
459  SIGNAL_GROUND = 5,
460  EARTH = 6,
461  GOST_ARROW = 7,
462  GOST_POWER_GROUND = 8,
463  GOST_EARTH = 9,
464  GOST_BAR = 10
465 };
466 
467 
469 {
471 
472  wxString text;
474 
475  wxPoint location;
478 
479  explicit ASCH_POWER_PORT( const std::map<wxString, wxString>& aProperties );
480 };
481 
482 
483 struct ASCH_PORT
484 {
486 
487  wxString name;
488 
489  wxPoint location;
490  int width;
491  int height;
492 
495 
496  explicit ASCH_PORT( const std::map<wxString, wxString>& aProperties );
497 };
498 
499 
501 {
502  wxPoint location;
503 
504  bool isActive;
506 
507  explicit ASCH_NO_ERC( const std::map<wxString, wxString>& aProperties );
508 };
509 
510 
512 {
513  wxString text;
514 
515  wxPoint location;
516 
518 
519  explicit ASCH_NET_LABEL( const std::map<wxString, wxString>& aProperties );
520 };
521 
522 
523 struct ASCH_BUS
524 {
527 
528  std::vector<wxPoint> points;
529 
530  explicit ASCH_BUS( const std::map<wxString, wxString>& aProperties );
531 };
532 
533 
534 struct ASCH_WIRE
535 {
538 
539  std::vector<wxPoint> points;
540 
541  explicit ASCH_WIRE( const std::map<wxString, wxString>& aProperties );
542 };
543 
544 
546 {
548 
549  wxPoint location;
550 
551  explicit ASCH_JUNCTION( const std::map<wxString, wxString>& aProperties );
552 };
553 
554 
556 {
559 
560  wxString filename;
561  wxPoint location;
562  wxPoint corner;
563 
566 
567  explicit ASCH_IMAGE( const std::map<wxString, wxString>& aProperties );
568 };
569 
570 
572 {
573  wxString fontname;
574 
575  int size;
576  int rotation;
577 
578  bool italic;
579  bool bold;
580  bool underline;
581 
582  explicit ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProperties, int aId );
583 };
584 
585 
586 enum class ASCH_SHEET_SIZE
587 {
588  UNKNOWN = -1, // use A4
589 
590  A4 = 0, // 1150 × 760
591  A3 = 1, // 1550 × 1110
592  A2 = 2, // 2230 × 1570
593  A1 = 3, // 3150 × 2230
594  A0 = 4, // 4460 × 3150
595  A = 5, // 950 × 750
596  B = 6, // 1500 × 950
597  C = 7, // 2000 × 1500
598  D = 8, // 3200 × 2000
599  E = 9, // 4200 × 3200
600  LETTER = 10, // 1100 × 850
601  LEGAL = 11, // 1400 × 850
602  TABLOID = 12, // 1700 × 1100
603  ORCAD_A = 13, // 990 × 790
604  ORCAD_B = 14, // 1540 × 990
605  ORCAD_C = 15, // 2060 × 1560
606  ORCAD_D = 16, // 3260 × 2060
607  ORCAD_E = 17 // 4280 × 3280
608 };
609 
610 wxPoint ASchSheetGetSize( ASCH_SHEET_SIZE aSheetSize );
611 
612 
614 {
615  LANDSCAPE = 0,
616  PORTRAIT = 1
617 };
618 
619 
621 {
622  std::vector<ASCH_SHEET_FONT> fonts;
623 
626 
627  explicit ASCH_SHEET( const std::map<wxString, wxString>& aProperties );
628 };
629 
630 
632 {
635 
636  wxString text;
637 
639  wxPoint location;
640 
641  bool isHidden;
642 
643  explicit ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProperties );
644 };
645 
646 
648 {
651 
652  wxString text;
653 
655  wxPoint location;
656 
657  bool isHidden;
658 
659  explicit ASCH_FILE_NAME( const std::map<wxString, wxString>& aProperties );
660 };
661 
662 
664 {
667 
668  wxString name;
669  wxString text;
670 
672  wxPoint location;
673 
674  explicit ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProperties );
675 };
676 
677 
679 {
680  wxPoint location;
681  wxPoint corner;
682 
683  explicit ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProperties );
684 };
685 
686 
688 {
691 
692  wxPoint location;
694 
695  wxString name;
696  wxString text;
697 
698  bool isHidden;
701 
702  explicit ASCH_PARAMETER( const std::map<wxString, wxString>& aProperties );
703 };
704 
705 #endif //ALTIUM_PARSER_SCH_H
wxPoint location
wxString sourcelibraryname
ASCH_SHEET_NAME(const std::map< wxString, wxString > &aProperties)
ASCH_PORT_IOTYPE
ASCH_SHEET_SYMBOL(const std::map< wxString, wxString > &aProperties)
wxString text
ASCH_RECORD_ORIENTATION orientation
ASCH_POLYGON(const std::map< wxString, wxString > &aProperties)
ASCH_RECTANGLE(const std::map< wxString, wxString > &aProperties)
std::vector< char > data
int distanceFromTop
ASCH_JUNCTION(const std::map< wxString, wxString > &aProperties)
ASCH_BUS(const std::map< wxString, wxString > &aProperties)
ASCH_IMAGE(const std::map< wxString, wxString > &aProperties)
ASCH_DESIGNATOR(const std::map< wxString, wxString > &aProperties)
ASCH_PORT_IOTYPE iotype
std::vector< wxPoint > points
ASCH_LABEL_JUSTIFICATION
ASCH_SYMBOL(const std::map< wxString, wxString > &aProperties)
ASCH_LABEL_JUSTIFICATION justification
int ownerpartdisplaymode
wxString filename
ASCH_PARAMETER(const std::map< wxString, wxString > &aProperties)
ASCH_PIN_SYMBOL_OUTER
ASCH_POWER_PORT_STYLE style
ASCH_PORT_STYLE style
wxPoint corner
ASCH_POLYLINE_LINESTYLE
std::chrono::steady_clock CLOCK
wxPoint kicadLocation
ASCH_NO_ERC(const std::map< wxString, wxString > &aProperties)
ASCH_RECORD_ORIENTATION orientation
ASCH_STORAGE_FILE(ALTIUM_PARSER &aReader)
wxPoint location
int ownerpartid
ASCH_ROUND_RECTANGLE(const std::map< wxString, wxString > &aProperties)
ASCH_RECORD_ORIENTATION orientation
ASCH_PIN_SYMBOL_OUTEREDGE
ASCH_SHEET_ENTRY(const std::map< wxString, wxString > &aProperties)
ASCH_RECORD_ORIENTATION orientation
ASCH_WIRE(const std::map< wxString, wxString > &aProperties)
wxString libreference
int ownerindex
ASCH_RECORD_ORIENTATION
std::vector< wxPoint > points
ASCH_FILE_NAME(const std::map< wxString, wxString > &aProperties)
ASCH_PIN(const std::map< wxString, wxString > &aProperties)
Class Circle Represents basic circle geometry with utility geometry functions.
Definition: circle.h:33
int ownerpartdisplaymode
ASCH_RECORD_ORIENTATION orientation
ASCH_PIN_ELECTRICAL
ASCH_SHEET(const std::map< wxString, wxString > &aProperties)
wxString name
std::vector< wxPoint > points
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
ASCH_BEZIER(const std::map< wxString, wxString > &aProperties)
wxString designator
ASCH_SHEET_WORKSPACEORIENTATION
ASCH_PORT_IOTYPE iotype
ASCH_SHEET_FONT(const std::map< wxString, wxString > &aProperties, int aId)
ASCH_PIN_SYMBOL_INNER
ASCH_PORT_STYLE
ASCH_LABEL(const std::map< wxString, wxString > &aProperties)
ASCH_SHEET_SIZE sheetSize
ASCH_SHEET_ENTRY_SIDE side
ASCH_RECORD_ORIENTATION orientation
double startAngle
ASCH_PIN_SYMBOL_OUTEREDGE symbolOuterEdge
Manage an 8-bit channel image.
Definition: image.h:89
std::vector< ASCH_SHEET_FONT > fonts
ASCH_POLYLINE_LINESTYLE linestyle
ASCH_PIN_SYMBOL_INNER symbolInner
ASCH_RECORD_ORIENTATION orientation
wxPoint location
ASCH_BUS_ENTRY(const std::map< wxString, wxString > &aProperties)
const int ALTIUM_COMPONENT_NONE
std::vector< wxPoint > points
ASCH_POWER_PORT_STYLE
ASCH_SHEET_SIZE
ASCH_PIN_SYMBOL_INNEREDGE
int ownerpartdisplaymode
ASCH_PORT_STYLE style
ASCH_PORT(const std::map< wxString, wxString > &aProperties)
ASCH_PIN_ELECTRICAL electrical
wxPoint center
ASCH_ARC(const std::map< wxString, wxString > &aProperties)
wxPoint ASchSheetGetSize(ASCH_SHEET_SIZE aSheetSize)
ASCH_PIN_SYMBOL_OUTER symbolOuter
ASCH_NET_LABEL(const std::map< wxString, wxString > &aProperties)
ASCH_PIN_SYMBOL_INNEREDGE symbolInnerEdge
ALTIUM_SCH_RECORD
ASCH_SHEET_WORKSPACEORIENTATION sheetOrientation
wxString componentdescription
ASCH_LINE(const std::map< wxString, wxString > &aProperties)
ASCH_POLYLINE(const std::map< wxString, wxString > &aProperties)
This item represents a bus vector.
ASCH_SHEET_ENTRY_SIDE
std::vector< wxPoint > points
wxString name
ASCH_POWER_PORT(const std::map< wxString, wxString > &aProperties)