KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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( const wxString& aFilename ) :
40 Filename( aFilename ),
41 Header(),
43 KiCadUnitDivider( 10 ),
44 m_rootNode( nullptr )
45 {
46 }
47
49 {
50 delete m_rootNode;
51 }
52
58 void Parse();
59
60
61 typedef wxString TERMINALCODE_ID;
62 typedef wxString SYMBOL_ID;
63 typedef wxString BUS_ID;
64 typedef wxString BLOCK_ID;
65 typedef wxString SHEET_NAME;
66
67
69 {
70 ANNULUS,
71 BOX,
72 BULLET,
73 CIRCLE,
74 CROSS,
75 DIAMOND,
76 FINGER,
77 OCTAGON,
78 PLUS,
79 POINTER,
82 SQUARE,
83 STAR,
86 };
87
88
89 static TERMINAL_SHAPE_TYPE ParseTermShapeType( const wxString& aShapeStr );
90
91
93 {
96 // Note in the CADSTAR GUI, it only talks about "length", but the file seems to
97 // split it in "left length" and "right length" (similar to PADCODE in the PCB)
98 // for some terminal shapes such as RECTANGLE but not for others, such as TRIANGLE
102 long OrientAngle = 0;
103
104 static bool IsTermShape( XNODE* aNode );
105 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
106 };
107
108
110 {
112 wxString Name;
114 bool Filled = false;
115
116 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
117 };
118
119
121 {
122 std::map<TERMINALCODE_ID, TERMINALCODE> TerminalCodes;
123
124 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
125 };
126
127
129 {
133 bool NetclassEditAttributeSettings = false; //< Unclear what this does
134 bool SpacingclassEditAttributeSettings = false; //< Unclear what this does
135
136 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
137 };
138
139
141 {
145 long OrientAngle = 0;
146
147 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
148 };
149
150
152 {
154
155 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
156 };
157
158
160 {
161 std::map<TERMINAL_ID, TERMINAL> Terminals;
162 std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinLabelLocations;
163 std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinNumberLocations;
164
165
166 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
167 };
168
169
171 {
172 std::map<SYMDEF_ID, SYMDEF_SCM> SymbolDefinitions;
173
174 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
175 };
176
177
178 struct SHEETS : PARSER
179 {
180 std::map<LAYER_ID, SHEET_NAME> SheetNames;
181 std::vector<LAYER_ID> SheetOrder;
183
184 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
185 };
186
187
188 struct COMP : PARSER
189 {
190 wxString Designator = wxEmptyString;
191 bool ReadOnly = false;
192 bool HasLocation = false;
194
195 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
196 };
197
198
200 {
201 PART_ID RefID = wxEmptyString;
202 bool ReadOnly = false;
203 bool HasLocation = false;
205
206 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
207 };
208
209
211 {
213 std::vector<ATTRIBUTE_VALUE> Attributes;
214
215 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
216 };
217
218
220 {
222 wxString NameOrLabel;
223 bool HasLocation = false;
225
226 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
227 };
228
229
231 {
232 enum class TYPE
233 {
235 SIGNALREF,
237 //TODO: there might be others
238 };
239
241 wxString Reference = wxEmptyString;
242
243 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
244 };
245
246
248 {
249 wxString Text;
251
252 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
253 };
254
255
256 struct SYMBOL : PARSER
257 {
259 {
261 long PinNum;
262 bool HasLocation = false;
264
265 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
266 };
267
272 GROUP_ID GroupID = wxEmptyString;
274 long OrientAngle = 0;
275 bool Mirror = false;
276 bool Fixed = false;
280
281 bool IsComponent = false;
283 bool HasPartRef = false;
285 bool PartNameVisible = true;
287
288 bool IsSymbolVariant = false;
293
295 VARIANT_ID VariantID = wxEmptyString;
296
297 std::map<TERMINAL_ID, TERMATTR> TerminalAttributes;
298 std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinLabels;
299 std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinNames;
301 std::map<TERMINAL_ID, PIN_NUM> PinNumbers;
304 std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
305
306 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
307 };
308
309
314 {
315 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
316 };
317
318
319 struct BUS : PARSER
320 {
325 wxString Name = wxEmptyString;
326 bool HasBusLabel = false;
328
329 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
330 };
331
332
333 struct BLOCK : PARSER
334 {
335 enum class TYPE
336 {
337 CLONE,
338 PARENT,
339 CHILD
340 };
341
344 LAYER_ID LayerID = wxEmptyString;
345 LAYER_ID AssocLayerID = wxEmptyString;
346 wxString Name = wxEmptyString;
347 bool HasBlockLabel = false;
349
350 std::map<TERMINAL_ID, TERMINAL> Terminals;
351 std::map<FIGURE_ID, FIGURE> Figures;
352
353 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
354 };
355
356
358 {
360 {
362 bool HasNetLabel = false;
364
365 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
366 };
367
368 struct SYM_TERM : PARSER
369 {
373 bool HasNetLabel = false;
375
376 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
377 };
378
379 struct BUS_TERM : PARSER
380 {
385 bool HasNetLabel = false;
387
388 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
389 };
390
392 {
396 bool HasNetLabel = false;
398
399 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
400 };
401
402
403 struct DANGLER : PARSER
404 {
409 bool HasNetLabel = false;
411
412 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
413 };
414
416 {
418 std::vector<POINT> Path;
419 GROUP_ID GroupID = wxEmptyString;
422
423 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
424 };
425
426 std::map<NETELEMENT_ID, JUNCTION_SCH> Junctions;
427 std::map<NETELEMENT_ID, SYM_TERM> Terminals;
428 std::map<NETELEMENT_ID, BUS_TERM> BusTerminals;
429 std::map<NETELEMENT_ID, BLOCK_TERM> BlockTerminals;
430 std::map<NETELEMENT_ID, DANGLER> Danglers;
431 std::vector<CONNECTION_SCH> Connections;
432
433 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
434 };
435
436
438 {
439 std::map<GROUP_ID, GROUP> Groups;
440 std::map<REUSEBLOCK_ID, REUSEBLOCK> ReuseBlocks;
441 std::map<FIGURE_ID, FIGURE> Figures;
442 std::map<SYMBOL_ID, SYMBOL> Symbols;
443 std::map<BUS_ID, BUS> Buses;
444 std::map<BLOCK_ID, BLOCK> Blocks;
445 std::map<NET_ID, NET_SCH> Nets;
446 std::map<TEXT_ID, TEXT> Texts;
447 std::map<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> DocumentationSymbols;
449 std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
450
451 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
452 };
453
454
455 wxString Filename;
464
466
467private:
468 XNODE* m_rootNode; // Currently parsed root node
469
470}; //CADSTAR_SCH_ARCHIVE_PARSER
471
472#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.
@ UNDEFINED
Only used for error checking (not a real shape)
CADSTAR_SCH_ARCHIVE_PARSER(const wxString &aFilename)
int KiCadUnitDivider
Use this value to convert units in this CSA file to KiCad units.
static TERMINAL_SHAPE_TYPE ParseTermShapeType(const wxString &aShapeStr)
Hold an XML or S-expression element.
Definition: xnode.h:44
Represents a point in x,y coordinates.
References an element from a design reuse block.
@ CLONE
the block is referring to the sheet it is on.
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.
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
std::map< SYMDEF_ID, SYMDEF_SCM > SymbolDefinitions
< "BLOCKTERM" nodename (represents a connection to a block)
NETELEMENT_ID ID
First four characters "BLKT".
< "BUSTERM" nodename (represents a connection to a bus)
NETELEMENT_ID ID
First two characters "BT".
LAYER_ID LayerID
Sheet on which the connection is drawn.
< "DANGLER" nodename (represents a dangling wire)
TERMINALCODE_ID TerminalCodeID
Usually a circle, but size can be varied.
< "TERM" nodename (represents a pin in a SCH symbol)
std::map< NETELEMENT_ID, DANGLER > Danglers
std::map< NETELEMENT_ID, SYM_TERM > Terminals
std::map< NETELEMENT_ID, BUS_TERM > BusTerminals
std::map< NETELEMENT_ID, BLOCK_TERM > BlockTerminals
std::map< NETELEMENT_ID, JUNCTION_SCH > Junctions
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
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.
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
std::map< TERMINAL_ID, PIN_NUM_LABEL_LOC > PinLabelLocations
std::map< TERMINAL_ID, PIN_NUM_LABEL_LOC > PinNumberLocations
std::map< TERMINAL_ID, TERMINAL > Terminals
POINT Position
Pad position within the component's coordinate frame.