KiCad PCB EDA Suite
cadstar_sch_archive_parser.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-2021 Roberto Fernandez Bautista <[email protected]>
5 * Copyright (C) 2020-2021 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
26#ifndef CADSTAR_SCH_ARCHIVE_PARSER_H_
27#define CADSTAR_SCH_ARCHIVE_PARSER_H_
28
30
31
36{
37public:
38 explicit CADSTAR_SCH_ARCHIVE_PARSER( wxString aFilename )
40 {
41 }
42
48 void Parse();
49
50
51 typedef wxString TERMINALCODE_ID;
52 typedef wxString SYMBOL_ID;
53 typedef wxString BUS_ID;
54 typedef wxString BLOCK_ID;
55 typedef wxString SHEET_NAME;
56
57
59 {
60 ANNULUS,
61 BOX,
62 BULLET,
63 CIRCLE,
64 CROSS,
65 DIAMOND,
66 FINGER,
67 OCTAGON,
68 PLUS,
69 POINTER,
71 ROUNDED_RECT,
72 SQUARE,
73 STAR,
76 };
77
78
79 static TERMINAL_SHAPE_TYPE ParseTermShapeType( const wxString& aShapeStr );
80
81
83 {
86 // Note in the CADSTAR GUI, it only talks about "length", but the file seems to
87 // split it in "left length" and "right length" (similar to PADCODE in the PCB)
88 // for some terminal shapes such as RECTANGLE but not for others, such as TRIANGLE
92 long OrientAngle = 0;
93
94 static bool IsTermShape( XNODE* aNode );
95 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
96 };
97
98
100 {
102 wxString Name;
104 bool Filled = false;
105
106 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
107 };
108
109
111 {
112 std::map<TERMINALCODE_ID, TERMINALCODE> TerminalCodes;
113
114 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
115 };
116
117
119 {
123 bool NetclassEditAttributeSettings = false; //< Unclear what this does
124 bool SpacingclassEditAttributeSettings = false; //< Unclear what this does
125
126 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
127 };
128
129
131 {
135 long OrientAngle = 0;
136
137 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
138 };
139
140
142 {
144
145 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
146 };
147
148
150 {
151 std::map<TERMINAL_ID, TERMINAL> Terminals;
152 std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinLabelLocations;
153 std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinNumberLocations;
154
155
156 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
157 };
158
159
161 {
162 std::map<SYMDEF_ID, SYMDEF_SCM> SymbolDefinitions;
163
164 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
165 };
166
167
168 struct SHEETS : PARSER
169 {
170 std::map<LAYER_ID, SHEET_NAME> SheetNames;
171 std::vector<LAYER_ID> SheetOrder;
173
174 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
175 };
176
177
178 struct COMP : PARSER
179 {
180 wxString Designator = wxEmptyString;
181 bool ReadOnly = false;
182 bool HasLocation = false;
184
185 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
186 };
187
188
190 {
191 PART_ID RefID = wxEmptyString;
192 bool ReadOnly = false;
193 bool HasLocation = false;
195
196 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
197 };
198
199
201 {
204
205 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
206 };
207
208
210 {
212 wxString NameOrLabel;
213 bool HasLocation = false;
215
216 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
217 };
218
219
221 {
222 enum class TYPE
223 {
224 GLOBALSIGNAL,
225 SIGNALREF,
227 //TODO: there might be others
228 };
229
231 wxString Reference = wxEmptyString;
232
233 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
234 };
235
236
238 {
239 wxString Text;
241
242 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
243 };
244
245
246 struct SYMBOL : PARSER
247 {
249 {
251 long PinNum;
252 bool HasLocation = false;
254
255 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
256 };
257
262 GROUP_ID GroupID = wxEmptyString;
264 long OrientAngle = 0;
265 bool Mirror = false;
266 bool Fixed = false;
270
271 bool IsComponent = false;
273 bool HasPartRef = false;
275 bool PartNameVisible = true;
277
278 bool IsSymbolVariant = false;
283
285 VARIANT_ID VariantID = wxEmptyString;
286
287 std::map<TERMINAL_ID, TERMATTR> TerminalAttributes;
288 std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinLabels;
289 std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinNames;
291 std::map<TERMINAL_ID, PIN_NUM> PinNumbers;
294 std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
295
296 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
297 };
298
299
304 {
305 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
306 };
307
308
309 struct BUS : PARSER
310 {
315 wxString Name = wxEmptyString;
316 bool HasBusLabel = false;
318
319 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
320 };
321
322
323 struct BLOCK : PARSER
324 {
325 enum class TYPE
326 {
327 CLONE,
328 PARENT,
329 CHILD
330 };
331
334 LAYER_ID LayerID = wxEmptyString;
335 LAYER_ID AssocLayerID = wxEmptyString;
336 wxString Name = wxEmptyString;
337 bool HasBlockLabel = false;
339
340 std::map<TERMINAL_ID, TERMINAL> Terminals;
341 std::map<FIGURE_ID, FIGURE> Figures;
342
343 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
344 };
345
346
348 {
350 {
352 bool HasNetLabel = false;
354
355 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
356 };
357
358 struct SYM_TERM : PARSER
359 {
363 bool HasNetLabel = false;
365
366 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
367 };
368
369 struct BUS_TERM : PARSER
370 {
375 bool HasNetLabel = false;
377
378 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
379 };
380
382 {
386 bool HasNetLabel = false;
388
389 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
390 };
391
392
393 struct DANGLER : PARSER
394 {
399 bool HasNetLabel = false;
401
402 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
403 };
404
406 {
408 std::vector<POINT> Path;
409 GROUP_ID GroupID = wxEmptyString;
412
413 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
414 };
415
416 std::map<NETELEMENT_ID, JUNCTION_SCH> Junctions;
417 std::map<NETELEMENT_ID, SYM_TERM> Terminals;
418 std::map<NETELEMENT_ID, BUS_TERM> BusTerminals;
419 std::map<NETELEMENT_ID, BLOCK_TERM> BlockTerminals;
420 std::map<NETELEMENT_ID, DANGLER> Danglers;
421 std::vector<CONNECTION_SCH> Connections;
422
423 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
424 };
425
426
428 {
429 std::map<GROUP_ID, GROUP> Groups;
430 std::map<REUSEBLOCK_ID, REUSEBLOCK> ReuseBlocks;
431 std::map<FIGURE_ID, FIGURE> Figures;
432 std::map<SYMBOL_ID, SYMBOL> Symbols;
433 std::map<BUS_ID, BUS> Buses;
434 std::map<BLOCK_ID, BLOCK> Blocks;
435 std::map<NET_ID, NET_SCH> Nets;
436 std::map<TEXT_ID, TEXT> Texts;
437 std::map<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> DocumentationSymbols;
439 std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
440
441 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
442 };
443
444
445 wxString Filename;
454
456
457}; //CADSTAR_SCH_ARCHIVE_PARSER
458
459#endif // CADSTAR_SCH_ARCHIVE_PARSER_H_
Helper functions and common defines between schematic and PCB Archive files.
Helper functions and common structures for CADSTAR PCB and Schematic archive files.
READABILITY
Sets the readability direction of text.
@ BOTTOM_TO_TOP
When text is vertical, show it rotated 90 degrees anticlockwise.
long TERMINAL_ID
Terminal is the pin identifier in the schematic.
static const long UNDEFINED_VALUE
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
Represents a CADSTAR Schematic Archive (*.csa) file.
int KiCadUnitDivider
Use this value to convert units in this CSA file to KiCad units.
static TERMINAL_SHAPE_TYPE ParseTermShapeType(const wxString &aShapeStr)
CADSTAR_SCH_ARCHIVE_PARSER(wxString aFilename)
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:33
A triangle object.
Definition: triangle_3d.h:43
Hold an XML or S-expression element.
Definition: xnode.h:44
@ TESTPOINT
a test point pad
Represents a point in x,y coordinates.
References an element from a design reuse block.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
TYPE Type
Determines what the associated layer is, whether parent, child or clone.
LAYER_ID LayerID
The sheet block is on (TODO: verify this is true)
LAYER_ID AssocLayerID
Parent or Child linked sheet.
std::map< TERMINAL_ID, TERMINAL > Terminals
LAYER_ID LayerID
Sheet on which bus is located.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< REUSEBLOCK_ID, REUSEBLOCK > ReuseBlocks
std::map< DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL > DocumentationSymbols
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
std::map< TERMINALCODE_ID, TERMINALCODE > TerminalCodes
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< SYMDEF_ID, SYMDEF_SCM > SymbolDefinitions
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
< "BLOCKTERM" nodename (represents a connection to a block)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
NETELEMENT_ID ID
First four characters "BLKT".
< "BUSTERM" nodename (represents a connection to a bus)
NETELEMENT_ID ID
First two characters "BT".
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
LAYER_ID LayerID
Sheet on which the connection is drawn.
< "DANGLER" nodename (represents a dangling wire)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
TERMINALCODE_ID TerminalCodeID
Usually a circle, but size can be varied.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
< "TERM" nodename (represents a pin in a SCH symbol)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< NETELEMENT_ID, DANGLER > Danglers
std::map< NETELEMENT_ID, SYM_TERM > Terminals
std::map< NETELEMENT_ID, BUS_TERM > BusTerminals
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< NETELEMENT_ID, BLOCK_TERM > BlockTerminals
std::map< NETELEMENT_ID, JUNCTION_SCH > Junctions
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::vector< LAYER_ID > SheetOrder
A vector to also store the order in which sheets are to be displayed.
std::map< LAYER_ID, SHEET_NAME > SheetNames
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
GROUP_ID GroupID
If not empty, this symbol is part of a group.
LAYER_ID LayerID
Sheet on which symbol is located.
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
GATE_ID GateID
The gate this symbol represents within the associated Part.
long ScaleRatioNumerator
Symbols can be arbitrarily scaled in CADSTAR.
SIGNALREFERENCELINK SigRefLink
Signal References (a special form of global signal) have annotations showing the location of all the ...
std::map< TERMINAL_ID, SYMPINNAME_LABEL > PinNames
Identifier of the pin in the PCB Equivalent to KiCad's Pin Number.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< TERMINAL_ID, SYMPINNAME_LABEL > PinLabels
Equivalent to KiCad's Pin Name.
std::map< TERMINAL_ID, PIN_NUM > PinNumbers
This seems to only appear in older designs and is similar to PinNames but only allowing numerical val...
std::map< TERMINAL_ID, TERMATTR > TerminalAttributes
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< TERMINAL_ID, PIN_NUM_LABEL_LOC > PinLabelLocations
std::map< TERMINAL_ID, PIN_NUM_LABEL_LOC > PinNumberLocations
std::map< TERMINAL_ID, TERMINAL > Terminals
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
POINT Position
Pad position within the component's coordinate frame.