KiCad PCB EDA Suite
cadstar_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 <roberto.fer.bau@gmail.com>
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_ARCHIVE_PARSER_H_
27 #define CADSTAR_ARCHIVE_PARSER_H_
28 
29 #include <richio.h>
30 #include <wx/gdicmn.h>
31 #include <map>
32 #include <set>
33 #include <vector>
34 #include <xnode.h>
35 
36 // THROW_IO_ERROR definitions to ensure consistent wording is used in the error messages
37 
38 #define THROW_MISSING_NODE_IO_ERROR( nodename, location ) \
39  THROW_IO_ERROR( wxString::Format( _( "Missing node '%s' in '%s'" ), nodename, location ) )
40 
41 #define THROW_UNKNOWN_NODE_IO_ERROR( nodename, location ) \
42  THROW_IO_ERROR( wxString::Format( _( "Unknown node '%s' in '%s'" ), nodename, location ) )
43 
44 #define THROW_MISSING_PARAMETER_IO_ERROR( param, location ) \
45  THROW_IO_ERROR( wxString::Format( _( "Missing Parameter '%s' in '%s'" ), param, location ) )
46 
47 #define THROW_UNKNOWN_PARAMETER_IO_ERROR( param, location ) \
48  THROW_IO_ERROR( wxString::Format( _( "Unknown Parameter '%s' in '%s'" ), param, location ) )
49 
50 #define THROW_PARSING_IO_ERROR( param, location ) \
51  THROW_IO_ERROR( wxString::Format( _( "Unable to parse '%s' in '%s'" ), param, location ) )
52 
53 //=================================
54 // MACRO DEFINITIONS
55 //=================================
56 #define UNDEFINED_LAYER_ID ( LAYER_ID ) wxEmptyString
57 
58 
62 #define COMPONENT_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME__" )
63 
68 #define COMPONENT_NAME_2_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME_2__" )
69 
73 #define SYMBOL_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__SYMBOL_NAME__" )
74 #define LINK_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__LINK_ORIGIN__" )
75 #define SIGNALNAME_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__SIGNALNAME_ORIGIN__" )
76 #define PART_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__PART_NAME__" )
77 
78 class EDA_TEXT;
79 class wxXmlAttribute;
80 
85 {
86 public:
87  typedef wxString LINECODE_ID;
88  typedef wxString HATCHCODE_ID;
89  typedef wxString ROUTECODE_ID;
90  typedef wxString NETCLASS_ID;
91  typedef wxString SPACING_CLASS_ID;
92  typedef wxString TEXTCODE_ID;
93  typedef wxString LAYER_ID;
94  typedef wxString VARIANT_ID;
95  typedef wxString ATTRIBUTE_ID;
96  typedef wxString SYMDEF_ID;
97  typedef wxString PART_ID;
98  typedef wxString GATE_ID;
99  typedef long TERMINAL_ID;
100  typedef long PART_DEFINITION_PIN_ID;
101  typedef long PART_PIN_ID;
102  typedef wxString TEXT_ID;
103  typedef wxString FIGURE_ID;
104  typedef wxString GROUP_ID;
105  typedef wxString REUSEBLOCK_ID;
106  typedef wxString NET_ID;
107  typedef wxString NETELEMENT_ID;
108  typedef wxString DOCUMENTATION_SYMBOL_ID;
109  typedef wxString COLOR_ID;
110 
111  static const long UNDEFINED_VALUE = -1;
112 
124  static const double TXT_HEIGHT_RATIO;
125 
130  enum class TEXT_FIELD_NAME
131  {
132  DESIGN_TITLE,
134  LONG_JOBNAME,
136  SHEET_NUMBER,
137  SHEET_NAME,
138  VARIANT_NAME,
140  REG_USER,
141  COMPANY_NAME,
142  CURRENT_USER,
143  DATE,
144  TIME,
145  MACHINE_NAME,
146  FROM_FILE,
147  DISTANCE,
148  UNITS_SHORT,
149  UNITS_ABBREV,
150  UNITS_FULL,
151  HYPERLINK,
152  NONE
153  };
154 
159  static const std::map<TEXT_FIELD_NAME, wxString> CADSTAR_TO_KICAD_FIELDS;
160 
161 
163  {
169  std::map<wxString, wxString> FilenamesToTextMap;
170 
175  std::map<wxString, wxString> TextToHyperlinksMap;
176 
181  std::map<TEXT_FIELD_NAME, wxString> TextFieldToValuesMap;
182 
187  std::set<TEXT_FIELD_NAME> InconsistentTextFields;
188  };
189 
197  static wxString ParseTextFields( wxString aTextString, PARSER_CONTEXT* aParserContext );
198 
199 
200  struct PARSER
201  {
202  virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) = 0;
203 
204  virtual ~PARSER() {};
205  };
206 
207 
208  struct FORMAT : PARSER
209  {
210  wxString Type;
211  long SomeInt;
212  long Version;
213  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
216  };
217 
218 
219  struct TIMESTAMP : PARSER
220  {
221  long Year;
222  long Month;
223  long Day;
224  long Hour;
225  long Minute;
226  long Second;
227 
228  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
229  };
230 
231  //Note: there are possibly several other resolutions, but HUNDREDTH MICRON is only one known
232  enum class RESOLUTION
233  {
235  };
236 
237 
238  struct HEADER : PARSER
239  {
241  wxString JobFile;
242  wxString JobTitle;
243  wxString Generator;
246 
247  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
248  };
249 
250 
251  struct VARIANT : PARSER
252  {
253  VARIANT_ID ID = wxEmptyString;
254  VARIANT_ID ParentID = wxEmptyString;
255  wxString Name = wxEmptyString;
256  wxString Description = wxEmptyString;
257 
258  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
259  };
260 
261 
263  {
264  std::map<VARIANT_ID, VARIANT> Variants;
265 
266  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
267  };
268 
269 
270  enum class LINESTYLE
271  {
272  SOLID,
273  DASH,
274  DASHDOT,
275  DASHDOTDOT,
276  DOT
277  };
278 
279 
280  struct LINECODE : PARSER
281  {
283  wxString Name;
284  long Width;
286 
287  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
288  };
289 
290 
291  struct HATCH : PARSER
292  {
293  long Step;
294  long LineWidth;
295  long OrientAngle;
296 
297  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
298  };
299 
300 
301  struct HATCHCODE : PARSER
302  {
304  wxString Name;
305  std::vector<HATCH> Hatches;
306 
307  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
308  };
309 
310 
311  static const long FONT_NORMAL = 400;
312  static const long FONT_BOLD = 700;
313 
314 
315  struct FONT : PARSER
316  {
317  wxString Name = wxT( "CADSTAR" );
319  long Modifier2 = 0;
321  false;
322  bool Italic = false;
325 
326  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
327  };
328 
329 
330  struct TEXTCODE : PARSER
331  {
333  wxString Name;
334  long LineWidth;
335  long Height;
336  long Width;
337  FONT Font;
340 
341  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
342  };
343 
344 
346  {
349  long MinWidth;
350  long MaxWidth;
352 
353  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
354  };
355 
356 
357  struct ROUTECODE : PARSER
358  {
360  wxString Name;
362  long MinWidth;
363  long MaxWidth;
365 
366  std::vector<ROUTEREASSIGN> RouteReassigns;
367 
368  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
369  };
370 
371 
375  struct EVALUE : PARSER
376  {
377  long Base = 0;
378  long Exponent = 0;
379 
380  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
381  double GetDouble();
382  };
383 
387  struct POINT : wxPoint, PARSER
388  {
390  {
391  }
392 
393  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
394  };
395 
396 
397  struct LONGPOINT : PARSER
398  {
401 
402  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
403  };
404 
405 
406  enum class VERTEX_TYPE
407  {
408  POINT,
413  };
414 
419  struct VERTEX : PARSER
420  {
424 
425  static bool IsVertex( XNODE* aNode );
426  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
427  };
428 
432  struct CUTOUT : PARSER
433  {
434  std::vector<VERTEX> Vertices;
435 
436  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
437  };
438 
439 
440  enum class SHAPE_TYPE
441  {
442  OPENSHAPE,
443  OUTLINE,
444  SOLID,
445  HATCHED
446  };
447 
448 
449  struct SHAPE : PARSER
450  {
452  std::vector<VERTEX> Vertices;
453  std::vector<CUTOUT> Cutouts;
454  wxString HatchCodeID;
455 
456  static bool IsShape( XNODE* aNode );
457  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
458  };
459 
460 
461  enum class UNITS
462  {
463  DESIGN,
464  THOU,
465  INCH,
466  MICROMETRE,
467  MM,
468  CENTIMETER,
469  METER
470  };
471 
472 
473  static UNITS ParseUnits( XNODE* aNode );
474 
475 
476  enum class ANGUNITS
477  {
478  DEGREES,
479  RADIANS
480  };
481 
482 
483  static ANGUNITS ParseAngunits( XNODE* aNode );
484 
485 
486  enum class GRID_TYPE
487  {
489  STEPGRID
491  };
492 
493 
494  struct GRID : PARSER
495  {
497  wxString Name;
498  long Param1;
499  long Param2;
501 
503  static bool IsGrid( XNODE* aNode );
504  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
505  };
506 
507 
508  struct GRIDS : PARSER
509  {
512  std::vector<GRID> UserGrids;
520 
521  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
522  };
523 
524 
525  struct SETTINGS : PARSER
526  {
530  long BarlineGap;
533  bool AllowBarredText = false;
537 
539  std::pair<POINT, POINT> DesignArea;
542 
543  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
544  virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
545  };
546 
547 
548 
566  enum class ALIGNMENT
567  {
568  NO_ALIGNMENT,
569  TOPLEFT,
570  TOPCENTER,
571  TOPRIGHT,
572  CENTERLEFT,
573  CENTERCENTER,
574  CENTERRIGHT,
575  BOTTOMLEFT,
576  BOTTOMCENTER,
578  };
579 
580 
581  static ALIGNMENT ParseAlignment( XNODE* aNode );
582 
592  enum class JUSTIFICATION
593  {
594  LEFT,
595  CENTER,
596  RIGHT
597  };
598 
599 
600  static JUSTIFICATION ParseJustification( XNODE* aNode );
601 
610  enum class READABILITY
611  {
612  BOTTOM_TO_TOP,
614  };
615 
616 
617  static READABILITY ParseReadability( XNODE* aNode );
618 
619 
620  enum class ATTROWNER
621  {
622  ALL_ITEMS,
623  AREA,
624  BOARD,
625  COMPONENT,
626  CONNECTION,
627  COPPER,
628  DOCSYMBOL,
629  FIGURE,
630  NET,
631  NETCLASS,
632  PART,
634  PIN,
635  SIGNALREF,
636  SYMBOL,
637  SYMDEF,
638  TEMPLATE,
639  TESTPOINT
640  };
641 
642 
643  enum class ATTRUSAGE
644  {
645  BOTH,
646  COMPONENT,
649  PART_LIBRARY,
651  SYMBOL,
652  UNDEFINED
654  };
657 
658 
660  {
664  long OrientAngle = 0;
665  bool Mirror = false;
666  bool Fixed = false;
671 
675  void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
676  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
677  virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
678  };
679 
680 
685  struct ATTRNAME : PARSER
686  {
688  {
689  long ID;
690  long Order;
691 
692  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
693  };
694 
695 
697  {
698  long ID;
699  long Width;
700 
701  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
702  };
703 
705  wxString Name;
711  bool NoTransfer = false;
712  std::vector<COLUMNORDER> ColumnOrders;
719  std::vector<COLUMNWIDTH> ColumnWidths;
720  bool ColumnInvisible = false;
721 
722  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
723  };
724 
725 
727  {
729  wxString Value;
730  bool ReadOnly = false;
731  bool HasLocation = false;
734 
735  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
736  };
737 
738 
745  {
747  {
748  // The default alignment for TEXT_LOCATION (when "NO_ALIGNMENT" is selected) is
749  // Bottom left, matching CADSTAR's default behaviour
751  }
753 
754  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
755  };
756 
757 
759  {
761  wxString Name;
762  std::vector<ATTRIBUTE_VALUE> Attributes;
763 
764  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
765  };
766 
767 
769  {
771  wxString Name;
772 
773  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
774  };
775 
776 
777  struct CODEDEFS : PARSER
778  {
779  std::map<LINECODE_ID, LINECODE> LineCodes;
780  std::map<HATCHCODE_ID, HATCHCODE> HatchCodes;
781  std::map<TEXTCODE_ID, TEXTCODE> TextCodes;
782  std::map<ROUTECODE_ID, ROUTECODE> RouteCodes;
783  std::map<ATTRIBUTE_ID, ATTRNAME> AttributeNames;
784  std::map<NETCLASS_ID, CADSTAR_NETCLASS> NetClasses;
785  std::map<SPACING_CLASS_ID, SPCCLASSNAME> SpacingClassNames;
786 
787  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
788  };
789 
800  enum class SWAP_RULE
801  {
802  NO_SWAP,
804  BOTH
805  };
806 
807 
808  static SWAP_RULE ParseSwapRule( XNODE* aNode );
809 
810 
812  {
814  wxString Name;
815  wxString FileName;
816  bool Mirror = false;
817  long OrientAngle = 0;
818 
819  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
820  };
821 
822 
827  {
828  REUSEBLOCK_ID ReuseBlockID = wxEmptyString;
829  wxString ItemReference = wxEmptyString;
830 
834  bool IsEmpty();
835  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
836  };
837 
838 
839  struct GROUP : PARSER
840  {
842  wxString Name;
843  bool Fixed = false;
844  bool Transfer = false;
845  GROUP_ID GroupID = wxEmptyString;
848 
849  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
850  };
851 
852 
853  struct FIGURE : PARSER
854  {
858  SHAPE Shape; //< Uses the component's coordinate frame if within a component
859  //< definition, otherwise uses the design's coordinate frame.
860  GROUP_ID GroupID = wxEmptyString;
863  bool Fixed = false;
864  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
865 
866  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
867  };
868 
869 
870  struct TEXT : PARSER
871  {
873  wxString Text; //TODO: Need to lex/parse to identify design fields and hyperlinks
877  long OrientAngle = 0;
878  bool Mirror = false;
879  bool Fixed = false;
885  GROUP_ID GroupID = wxEmptyString;
890 
891  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
892  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext, bool aParseFields );
893  };
894 
895 
896  struct SYMDEF : PARSER
897  {
899  wxString ReferenceName;
900  wxString Alternate;
902  POINT Origin;
904  bool Stub = false;
906  long Version = UNDEFINED_VALUE;
912 
914  std::map<FIGURE_ID, FIGURE> Figures;
915  std::map<TEXT_ID, TEXT> Texts;
916  std::map<ATTRIBUTE_ID, TEXT_LOCATION> TextLocations;
917  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
920 
922  void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
923  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
924  };
925 
926 
927  struct PART : PARSER
928  {
929  enum class PIN_TYPE
930  {
931  UNCOMMITTED,
932  INPUT,
933  OUTPUT_OR,
934  OUTPUT_NOT_OR,
936  POWER,
937  GROUND,
941  };
942 
943 
944  static PIN_TYPE GetPinType( XNODE* aNode );
945 
946 
947  struct DEFINITION : PARSER
948  {
949  struct GATE : PARSER
950  {
952  wxString Name;
953  wxString Alternate;
954  long PinCount;
955 
956  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
957  };
958 
959 
960  struct PIN : PARSER
961  {
965  enum class POSITION
966  {
967  TOP_RIGHT = 0,
968  TOP_LEFT = 1,
969  BOTTOM_LEFT = 2,
970  BOTTOM_RIGHT = 3
971  };
972 
974 
975  wxString Identifier = wxEmptyString;
976  wxString Name = wxEmptyString;
981  wxString Label = wxEmptyString;
986  wxString Signal = wxEmptyString;
1006  POSITION Position =
1011 
1014  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1015  };
1016 
1017 
1019  {
1020  std::vector<PART_DEFINITION_PIN_ID> PinIDs;
1021 
1024  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1025  };
1026 
1027 
1028  struct SWAP_GATE : PARSER
1029  {
1030  std::vector<PART_DEFINITION_PIN_ID> PinIDs;
1031 
1033  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1034  };
1035 
1036 
1038  {
1039  wxString GateName =
1040  wxEmptyString;
1041 
1044  bool External = false;
1045 
1052  std::vector<SWAP_GATE> SwapGates;
1053 
1058  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1059  };
1060 
1061  wxString Name;
1063  false;
1064 
1069  UNDEFINED_VALUE;
1070 
1076  std::map<GATE_ID, GATE> GateSymbols;
1077  std::map<PART_DEFINITION_PIN_ID, PIN> Pins;
1078  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
1079  std::vector<PIN_EQUIVALENCE> PinEquivalences;
1083  std::vector<SWAP_GROUP> SwapGroups;
1084 
1085  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1086  };
1087 
1088 
1089  struct PART_PIN : PARSER
1090  {
1092  wxString Name = wxEmptyString;
1094  wxString Identifier = wxEmptyString;
1095 
1096  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1097  };
1098 
1099 
1101  wxString Name;
1102  long Version;
1104  std::map<PART_PIN_ID, PART_PIN> PartPins;
1105 
1110  bool HidePinNames = false;
1111 
1113  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
1114 
1118  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1119  };
1120 
1121 
1122  struct PARTS : PARSER
1123  {
1124  std::map<PART_ID, PART> PartDefinitions;
1125 
1126  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1127  };
1128 
1129 
1130  struct NET : PARSER
1131  {
1132  struct JUNCTION : PARSER
1133  {
1137  GROUP_ID GroupID = wxEmptyString;
1140  bool Fixed = false;
1141 
1142  void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
1143  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
1144  virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1145  };
1146 
1147 
1148  struct CONNECTION : PARSER
1149  {
1153 
1154  bool Fixed = false;
1155  bool Hidden = false;
1156  GROUP_ID GroupID = wxEmptyString;
1158 
1159  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
1160  void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
1163  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
1164 
1165  virtual ~CONNECTION() {}
1166  };
1167 
1169  ROUTECODE_ID RouteCodeID = wxEmptyString;
1171  wxString Name = wxEmptyString;
1173  bool Highlight = false;
1175 
1176  std::map<NETELEMENT_ID, JUNCTION> Junctions;
1177  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
1178 
1180  wxEmptyString;
1183  wxEmptyString;
1184 
1186  void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
1187  bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
1188  };
1189 
1190 
1192  {
1194 
1196  LAYER_ID LayerID;
1201 
1203  GROUP_ID GroupID = wxEmptyString;
1205  long OrientAngle = 0;
1206  bool Mirror = false;
1207  bool Fixed = false;
1209 
1211  long ScaleRatioDenominator = 1;
1213 
1215  std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
1216 
1217  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1218  };
1219 
1220 
1222  {
1224  bool IsVisible = true;
1225 
1226  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1227  };
1228 
1229 
1230  struct ATTRCOL : PARSER
1231  {
1234  bool IsVisible = true;
1235  bool IsPickable = true;
1236 
1237  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1238  };
1239 
1240 
1242  {
1244  std::map<ATTRIBUTE_ID, ATTRCOL> AttributeColors;
1245 
1246  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1247  };
1248 
1249 
1251  {
1253  bool IsVisible = true;
1254  bool IsPickable = true;
1255 
1256  void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
1257  };
1258 
1260  // HELPER FUNCTIONS: //
1262 
1263 
1264  static void InsertAttributeAtEnd( XNODE* aNode, wxString aValue );
1265 
1276  static XNODE* LoadArchiveFile( const wxString& aFileName, const wxString& aFileTypeIdentifier );
1277 
1283  static bool IsValidAttribute( wxXmlAttribute* aAttribute );
1284 
1293  static wxString GetXmlAttributeIDString(
1294  XNODE* aNode, unsigned int aID, bool aIsRequired = true );
1295 
1304  static long GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID, bool aIsRequired = true );
1305 
1311  static void CheckNoChildNodes( XNODE* aNode );
1312 
1318  static void CheckNoNextNodes( XNODE* aNode );
1319 
1326  static void ParseChildEValue( XNODE* aNode, PARSER_CONTEXT* aContext, EVALUE& aValueToParse );
1327 
1340  static std::vector<POINT> ParseAllChildPoints( XNODE* aNode, PARSER_CONTEXT* aContext,
1341  bool aTestAllChildNodes = false, int aExpectedNumPoints = UNDEFINED_VALUE );
1342 
1354  static std::vector<VERTEX> ParseAllChildVertices(
1355  XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
1356 
1368  static std::vector<CUTOUT> ParseAllChildCutouts(
1369  XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
1370 
1376  static void FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextItem );
1377 
1378  static wxString generateLibName( const wxString& aRefName, const wxString& aAlternateName )
1379  {
1380  return aRefName
1381  + ( ( aAlternateName.size() > 0 ) ? ( wxT( " (" ) + aAlternateName + wxT( ")" ) )
1382  : wxT( "" ) );
1383  }
1384 
1385 protected:
1387 
1388 
1389 }; // class CADSTAR_ARCHIVE_PARSER
1390 
1391 #endif // CADSTAR_ARCHIVE_PARSER_H_
long PART_DEFINITION_PIN_ID
Pin identifier in the part definition.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
READABILITY
Sets the readability direction of text.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
wxString Label
This Can be empty (subnode= "PINLABEL") From CADSTAR Help: "Pin Labels are an optional replacement fo...
long PART_PIN_ID
Pin identifier in the part.
LAYER_ID LayerID
Move all objects in the Symdef to this layer.
Note: It seems that some attribute have no "ATTRUSAGE" defined.
From CADSTAR Help: Assigned to Parts library Definitions and displayed by the Library searcher.
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes
long Load
The electrical current expected on the pin (It is unclear what the units are, but only accepted value...
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
bool Transfer
If true, the group is transferred to PCB.
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< PART_DEFINITION_PIN_ID, PIN > Pins
virtual void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::pair< POINT, POINT > DesignArea
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString ReferenceName
This is the name which identifies the symbol in the library Multiple components may exist with the sa...
long Modifier2
It seems this is always 0 regardless of settings.
GRID ScreenGrid
From CADSTAR Help: "There is one Screen Grid, which is visible as dots on the screen.
long SignalNum
This is undefined if the net has been given a name.
std::map< ATTRIBUTE_ID, ATTRNAME > AttributeNames
GROUP_ID GroupID
If not empty, this FIGURE is part of a group.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static ANGUNITS ParseAngunits(XNODE *aNode)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
long ScaleRatioNumerator
Documentation symbols can be arbitrarily scaled when added to a design.
static JUSTIFICATION ParseJustification(XNODE *aNode)
TEXT_FIELD_NAME
These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NA...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
Helper functions and common structures for CADSTAR PCB and Schematic archive files.
LONGPOINT DesignRef
Appears to be 0,0 always.
static PIN_TYPE GetPinType(XNODE *aNode)
std::map< LINECODE_ID, LINECODE > LineCodes
bool External
Determines if this swap group is external (and internal) or internal only.
virtual void Parse(XNODE *aNode, PARSER_CONTEXT *aContext)=0
wxString ItemReference
For Components, this references the designator in the reuse file.
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
void ParseIdentifiers(XNODE *aNode, PARSER_CONTEXT *aContext)
bool HidePinNames
This seems to be a duplicate of DEFINITION::HidePinNames Possibly only used in older file formats?
Filled closed shape (hatch fill).
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static bool IsValidAttribute(wxXmlAttribute *aAttribute)
std::map< NETELEMENT_ID, JUNCTION > Junctions
From CADSTAR Help: Assigned to Schematic Symbols and displayed on Schematic Designs.
long AngularPrecision
Number of decimal points to display for angular dimensions.
std::map< FIGURE_ID, FIGURE > Figures
long ScaleRatioDenominator
Documentation symbols can be arbitrarily scaled when added to a design.
std::vector< COLUMNWIDTH > ColumnWidths
Param1 = X Step, Param2 = Y Step. A standard x,y grid.
std::vector< PIN_EQUIVALENCE > PinEquivalences
bool HasLocation
Flag to know if this ATTRIBUTE_VALUE has a location i.e.
From CADSTAR Help: Only used by non-Cadstar applications.
static SWAP_RULE ParseSwapRule(XNODE *aNode)
long PinCount
Number of pins (terminals) in the symbol.
bool NoTransfer
True="All Design Types", False="Current Design Type" "All Design Types" Description from CADSTAR Help...
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
Always display (Mirrored and Unmirrored)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString Alternate
Symbol alternate name in the symbol library.
TERMINAL_ID TerminalPin
(subnode="PINTERM", param1)
POSITION
Positioning of pin names can be in one of four quadrants.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< wxString, wxString > FilenamesToTextMap
CADSTAR doesn't have user defined text fields but does allow loading text from a file.
long Modifier1
It seems this is related to weight. 400=Normal, 700=Bold.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static void CheckNoChildNodes(XNODE *aNode)
void ParseIdentifiers(XNODE *aNode, PARSER_CONTEXT *aContext)
virtual void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
wxString FileName
Filename of the reuse block (usually a .pcb). Used for reloading.
wxString Name
This name can be different to the PART name.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
UNITS Units
Units to display for linear dimensions.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static bool IsGrid(XNODE *aNode)
GROUP_ID GroupID
If not empty, this component is part of a group.
GROUP_ID GroupID
If not empty, this connection is part of a group.
std::vector< GRID > UserGrids
List of predefined grids created by the user.
wxString HatchCodeID
Only Applicable for HATCHED Type.
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
Some attributes are defined within the part definition, whilst others are defined in the part itself.
std::set< TEXT_FIELD_NAME > InconsistentTextFields
Text fields need to be updated in CADSTAR and it is possible that they are not consistent across text...
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
GROUP_ID GroupID
If not empty, this FIGURE is part of a group.
std::map< wxString, wxString > TextToHyperlinksMap
KiCad doesn't support hyperlinks but we use this map to display warning messages after import.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
long UnitDisplPrecision
Number of decimal points to display for linear dimensions.
std::vector< PART_DEFINITION_PIN_ID > PinIDs
The pins in this vector describe a "gate".
VARIANT_ID ParentID
if empty, then this one is the master
GROUP_ID GroupID
If not empty, this JUCTION is part of a group.
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::vector< SWAP_GATE > SwapGates
Each of the elements in this vector can be swapped with each other - i.e.
long SomeInt
It is unclear what this parameter is used for.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
Inherits from design units (assumed Assignments->Technology->Units)
POSITION Position
The pin names will use these positions when the symbol is added to a schematic design subnode="PINPOS...
Represents a point in x,y coordinates.
ALIGNMENT
From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all ...
Represents a floating value in E notation.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static XNODE * LoadArchiveFile(const wxString &aFileName, const wxString &aFileTypeIdentifier)
Reads a CADSTAR Archive file (S-parameter format)
std::map< ATTRIBUTE_ID, ATTRCOL > AttributeColors
long TERMINAL_ID
Terminal is the pin identifier in the schematic.
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
std::map< PART_ID, PART > PartDefinitions
References an element from a design reuse block.
GROUP_ID GroupID
If not empty, this GROUP is part of another GROUP.
bool IsEmpty()
Determines if this is empty (i.e. no design reuse associated)
bool Stub
When the CADSTAR Archive file is exported without the component library, if components on the board a...
long Width
Defaults to 0 if using system fonts or, if using CADSTAR font, default to equal height (1:1 aspect ra...
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
ROUTECODE_ID RouteCodeID
"NETCODE" subnode
static std::vector< VERTEX > ParseAllChildVertices(XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false)
if no children are present, it just returns an empty vector (without throwing an exception)
void ParseIdentifiers(XNODE *aNode, PARSER_CONTEXT *aContext)
When text is vertical, show it rotated 90 degrees clockwise.
long MaxPinCount
Optional parameter which is used for specifying the number of electrical pins on the PCB component sy...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
bool AllowBarredText
Specifies if barring is allowed in the design.
static std::vector< CUTOUT > ParseAllChildCutouts(XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false)
if no children are present, it just returns an empty vector (without throwing an exception)
std::map< NETCLASS_ID, CADSTAR_NETCLASS > NetClasses
std::vector< COLUMNORDER > ColumnOrders
SWAP_RULE
Corresponds to "Display when" Item property.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
virtual void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
SYMDEF_ID SymdefID
Normally documentation symbols only have TEXT, FIGURE and TEXT_LOCATION objects which are all drawn o...
std::vector< ROUTEREASSIGN > RouteReassigns
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.
long InterlineGap
For CADSTAR font only, distance between lines of text, expressed as a percentage of the text height (...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
long Param1
Either Units or X step, depending on Type (see GRID_TYPE for more details)
long BarlineGap
For CADSTAR font only, distance between top bar and character, expressed as a percentage of the text ...
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
std::vector< PART_DEFINITION_PIN_ID > PinIDs
All the pins in this vector are equivalent and can be swapped with each other.
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
These attributes might also have a location.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
static const long UNDEFINED_VALUE
Corresponds to CADSTAR "origin".
< Nodename = "VARIANT" or "VMASTER" (master variant
std::map< PART_PIN_ID, PART_PIN > PartPins
It is unclear why there are two "Pin" structures in CPA files...
static long GetXmlAttributeIDLong(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
NOTE from CADSTAR help: To convert a Part Definition Attribute into a hyperlink, prefix the attribute...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString Identifier
This should match a pad identifier in the component footprint subnode="PINIDENTIFIER".
static wxString generateLibName(const wxString &aRefName, const wxString &aAlternateName)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
wxString Name
Parenthesis aren't permitted in user attributes in CADSTAR.
Hold an XML or S-expression element.
Definition: xnode.h:43
JUSTIFICATION Justification
Note: Justification has no effect on single lines of text.
bool HidePinNames
Specifies whether to display the pin names/identifier in the schematic symbol or not.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
JUSTIFICATION
From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.
wxString Name
Symbol name in the symbol library.
std::vector< CUTOUT > Cutouts
Not Applicable to OPENSHAPE Type.
std::map< TEXTCODE_ID, TEXTCODE > TextCodes
static READABILITY ParseReadability(XNODE *aNode)
Param1 = Units, Param2 = Divisor.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static void CheckNoNextNodes(XNODE *aNode)
< "SWAPGATE" Node name (represents an "Element")
std::map< SPACING_CLASS_ID, SPCCLASSNAME > SpacingClassNames
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static void ParseChildEValue(XNODE *aNode, PARSER_CONTEXT *aContext, EVALUE &aValueToParse)
wxString Name
This is undefined (wxEmptyString) if the net is unnamed.
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
void ParseIdentifiers(XNODE *aNode, PARSER_CONTEXT *aContext)
long Param2
Either Divisor or Y step, depending on Type (see GRID_TYPE for more details)
std::map< HATCHCODE_ID, HATCHCODE > HatchCodes
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
JUSTIFICATION Justification
Note: Justification has no effect on single lines of text.
long Version
Version is a sequential integer number to identify discrepancies between the library and the design.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString Signal
Usually for Power/Ground pins, (subnode="PINSIGNAL")
static void InsertAttributeAtEnd(XNODE *aNode, wxString aValue)
Unfilled open shape. Cannot have cutouts.
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
Some attributes are defined within the part definition, whilst others are defined in the part.
std::map< ATTRIBUTE_ID, TEXT_LOCATION > TextLocations
This contains location of any attributes, including designator position.
static UNITS ParseUnits(XNODE *aNode)
void ParseIdentifiers(XNODE *aNode, PARSER_CONTEXT *aContext)
wxString Alternate
This is in addition to ReferenceName.
From CADSTAR Help: Assigned to PCB components and displayed on PCB designs.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
long Version
Archive version number (e.g.
NETELEMENT_ID ID
First character is "J".
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
bool KerningPairs
From CADSTAR Help: "Kerning Pairs is for causing the system to automatically reduce the spacing betwe...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
NETCLASS_ID NetClassID
The net might not have a net class, in which case it will be wxEmptyString ("NETCLASSREF" subnode)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static wxString ParseTextFields(wxString aTextString, PARSER_CONTEXT *aParserContext)
Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
static ALIGNMENT ParseAlignment(XNODE *aNode)
NO_ALIGNMENT has different meaning depending on the object type.
SPACING_CLASS_ID SpacingClassID
The net might not have a spacing class, in which case it will be wxEmptyString ("SPACINGCLASS" subnod...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
Filled closed shape (solid fill).
std::map< TEXT_FIELD_NAME, wxString > TextFieldToValuesMap
Values for the text field elements used in the CADSTAR design extracted from the text element instanc...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static std::vector< POINT > ParseAllChildPoints(XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false, int aExpectedNumPoints=UNDEFINED_VALUE)
if no children are present, it just returns an empty vector (without throwing an exception)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
bool ParseSubNode(XNODE *aChildNode, PARSER_CONTEXT *aContext)
static const std::map< TEXT_FIELD_NAME, wxString > CADSTAR_TO_KICAD_FIELDS
Map between CADSTAR fields and KiCad text variables.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
It is possible to add attributes solely to a particular connection.
GATE_ID TerminalGate
(subnode="PINTERM", param0)
Represents a cutout in a closed shape (e.g.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
SWAP_RULE SwapRule
Only applicable to Figures in Components.
From CADSTAR Help: Assigned to both Schematic symbols and PCB components, and displayed on Schematic ...
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
Represents a vertex in a shape.
When text is vertical, show it rotated 90 degrees anticlockwise.