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( wxString aFilename ) :
40 KiCadUnitDivider( 10 ), m_rootNode( nullptr )
41 {
42 }
43
45 {
46 if( m_rootNode )
47 delete m_rootNode;
48 }
49
55 void Parse();
56
57
58 typedef wxString TERMINALCODE_ID;
59 typedef wxString SYMBOL_ID;
60 typedef wxString BUS_ID;
61 typedef wxString BLOCK_ID;
62 typedef wxString SHEET_NAME;
63
64
66 {
67 ANNULUS,
68 BOX,
69 BULLET,
70 CIRCLE,
71 CROSS,
72 DIAMOND,
73 FINGER,
74 OCTAGON,
75 PLUS,
76 POINTER,
79 SQUARE,
80 STAR,
83 };
84
85
86 static TERMINAL_SHAPE_TYPE ParseTermShapeType( const wxString& aShapeStr );
87
88
90 {
93 // Note in the CADSTAR GUI, it only talks about "length", but the file seems to
94 // split it in "left length" and "right length" (similar to PADCODE in the PCB)
95 // for some terminal shapes such as RECTANGLE but not for others, such as TRIANGLE
99 long OrientAngle = 0;
100
101 static bool IsTermShape( XNODE* aNode );
102 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
103 };
104
105
107 {
109 wxString Name;
111 bool Filled = false;
112
113 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
114 };
115
116
118 {
119 std::map<TERMINALCODE_ID, TERMINALCODE> TerminalCodes;
120
121 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
122 };
123
124
126 {
130 bool NetclassEditAttributeSettings = false; //< Unclear what this does
131 bool SpacingclassEditAttributeSettings = false; //< Unclear what this does
132
133 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
134 };
135
136
138 {
142 long OrientAngle = 0;
143
144 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
145 };
146
147
149 {
151
152 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
153 };
154
155
157 {
158 std::map<TERMINAL_ID, TERMINAL> Terminals;
159 std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinLabelLocations;
160 std::map<TERMINAL_ID, PIN_NUM_LABEL_LOC> PinNumberLocations;
161
162
163 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
164 };
165
166
168 {
169 std::map<SYMDEF_ID, SYMDEF_SCM> SymbolDefinitions;
170
171 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
172 };
173
174
175 struct SHEETS : PARSER
176 {
177 std::map<LAYER_ID, SHEET_NAME> SheetNames;
178 std::vector<LAYER_ID> SheetOrder;
180
181 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
182 };
183
184
185 struct COMP : PARSER
186 {
187 wxString Designator = wxEmptyString;
188 bool ReadOnly = false;
189 bool HasLocation = false;
191
192 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
193 };
194
195
197 {
198 PART_ID RefID = wxEmptyString;
199 bool ReadOnly = false;
200 bool HasLocation = false;
202
203 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
204 };
205
206
208 {
210 std::vector<ATTRIBUTE_VALUE> Attributes;
211
212 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
213 };
214
215
217 {
219 wxString NameOrLabel;
220 bool HasLocation = false;
222
223 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
224 };
225
226
228 {
229 enum class TYPE
230 {
232 SIGNALREF,
234 //TODO: there might be others
235 };
236
238 wxString Reference = wxEmptyString;
239
240 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
241 };
242
243
245 {
246 wxString Text;
248
249 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
250 };
251
252
253 struct SYMBOL : PARSER
254 {
256 {
258 long PinNum;
259 bool HasLocation = false;
261
262 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
263 };
264
269 GROUP_ID GroupID = wxEmptyString;
271 long OrientAngle = 0;
272 bool Mirror = false;
273 bool Fixed = false;
277
278 bool IsComponent = false;
280 bool HasPartRef = false;
282 bool PartNameVisible = true;
284
285 bool IsSymbolVariant = false;
290
292 VARIANT_ID VariantID = wxEmptyString;
293
294 std::map<TERMINAL_ID, TERMATTR> TerminalAttributes;
295 std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinLabels;
296 std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinNames;
298 std::map<TERMINAL_ID, PIN_NUM> PinNumbers;
301 std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
302
303 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
304 };
305
306
311 {
312 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
313 };
314
315
316 struct BUS : PARSER
317 {
322 wxString Name = wxEmptyString;
323 bool HasBusLabel = false;
325
326 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
327 };
328
329
330 struct BLOCK : PARSER
331 {
332 enum class TYPE
333 {
334 CLONE,
335 PARENT,
336 CHILD
337 };
338
341 LAYER_ID LayerID = wxEmptyString;
342 LAYER_ID AssocLayerID = wxEmptyString;
343 wxString Name = wxEmptyString;
344 bool HasBlockLabel = false;
346
347 std::map<TERMINAL_ID, TERMINAL> Terminals;
348 std::map<FIGURE_ID, FIGURE> Figures;
349
350 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
351 };
352
353
355 {
357 {
359 bool HasNetLabel = false;
361
362 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
363 };
364
365 struct SYM_TERM : PARSER
366 {
370 bool HasNetLabel = false;
372
373 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
374 };
375
376 struct BUS_TERM : PARSER
377 {
382 bool HasNetLabel = false;
384
385 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
386 };
387
389 {
393 bool HasNetLabel = false;
395
396 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
397 };
398
399
400 struct DANGLER : PARSER
401 {
406 bool HasNetLabel = false;
408
409 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
410 };
411
413 {
415 std::vector<POINT> Path;
416 GROUP_ID GroupID = wxEmptyString;
419
420 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
421 };
422
423 std::map<NETELEMENT_ID, JUNCTION_SCH> Junctions;
424 std::map<NETELEMENT_ID, SYM_TERM> Terminals;
425 std::map<NETELEMENT_ID, BUS_TERM> BusTerminals;
426 std::map<NETELEMENT_ID, BLOCK_TERM> BlockTerminals;
427 std::map<NETELEMENT_ID, DANGLER> Danglers;
428 std::vector<CONNECTION_SCH> Connections;
429
430 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
431 };
432
433
435 {
436 std::map<GROUP_ID, GROUP> Groups;
437 std::map<REUSEBLOCK_ID, REUSEBLOCK> ReuseBlocks;
438 std::map<FIGURE_ID, FIGURE> Figures;
439 std::map<SYMBOL_ID, SYMBOL> Symbols;
440 std::map<BUS_ID, BUS> Buses;
441 std::map<BLOCK_ID, BLOCK> Blocks;
442 std::map<NET_ID, NET_SCH> Nets;
443 std::map<TEXT_ID, TEXT> Texts;
444 std::map<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> DocumentationSymbols;
446 std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
447
448 void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
449 };
450
451
452 wxString Filename;
461
463
464private:
465 XNODE* m_rootNode; // Currently parsed root node
466
467}; //CADSTAR_SCH_ARCHIVE_PARSER
468
469#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)
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)
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.