26 #ifndef CADSTAR_ARCHIVE_PARSER_H_ 27 #define CADSTAR_ARCHIVE_PARSER_H_ 30 #include <wx/gdicmn.h> 39 #define THROW_MISSING_NODE_IO_ERROR( nodename, location ) \ 40 THROW_IO_ERROR( wxString::Format( _( "Missing node '%s' in '%s'" ), nodename, location ) ) 42 #define THROW_UNKNOWN_NODE_IO_ERROR( nodename, location ) \ 43 THROW_IO_ERROR( wxString::Format( _( "Unknown node '%s' in '%s'" ), nodename, location ) ) 45 #define THROW_MISSING_PARAMETER_IO_ERROR( param, location ) \ 46 THROW_IO_ERROR( wxString::Format( _( "Missing Parameter '%s' in '%s'" ), param, location ) ) 48 #define THROW_UNKNOWN_PARAMETER_IO_ERROR( param, location ) \ 49 THROW_IO_ERROR( wxString::Format( _( "Unknown Parameter '%s' in '%s'" ), param, location ) ) 51 #define THROW_PARSING_IO_ERROR( param, location ) \ 52 THROW_IO_ERROR( wxString::Format( _( "Unable to parse '%s' in '%s'" ), param, location ) ) 57 #define UNDEFINED_LAYER_ID ( LAYER_ID ) wxEmptyString 63 #define COMPONENT_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME__" ) 69 #define COMPONENT_NAME_2_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME_2__" ) 74 #define SYMBOL_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__SYMBOL_NAME__" ) 75 #define LINK_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__LINK_ORIGIN__" ) 76 #define SIGNALNAME_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__SIGNALNAME_ORIGIN__" ) 77 #define PART_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__PART_NAME__" ) 207 static wxString
ParseTextFields(
const wxString& aTextString, PARSER_CONTEXT* aParserContext );
327 wxString
Name = wxT(
"CADSTAR" );
986 wxString
Name = wxEmptyString;
991 wxString
Label = wxEmptyString;
996 wxString
Signal = wxEmptyString;
1087 std::map<PART_DEFINITION_PIN_ID, PIN>
Pins;
1181 wxString
Name = wxEmptyString;
1306 XNODE* aNode,
unsigned int aID,
bool aIsRequired =
true );
1353 bool aTestAllChildNodes =
false,
int aExpectedNumPoints =
UNDEFINED_VALUE );
1386 std::vector<wxString> aSubNodeChildrenToCount );
1402 static wxString
generateLibName(
const wxString& aRefName,
const wxString& aAlternateName )
1405 + ( ( aAlternateName.size() > 0 ) ? ( wxT(
" (" ) + aAlternateName + wxT(
")" ) )
1419 #endif // CADSTAR_ARCHIVE_PARSER_H_
long PART_DEFINITION_PIN_ID
Pin identifier in the part definition.
std::vector< VERTEX > Vertices
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.
wxString SPACING_CLASS_ID
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes
static long GetNumberOfChildNodes(XNODE *aNode)
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
static XNODE * LoadArchiveFile(const wxString &aFileName, const wxString &aFileTypeIdentifier, PROGRESS_REPORTER *aProgressReporter=nullptr)
Reads a CADSTAR Archive file (S-parameter format)
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.
std::vector< HATCH > Hatches
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< GATE_ID, GATE > GateSymbols
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...
REUSEBLOCKREF ReuseBlockRef
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
std::vector< ATTRIBUTE_VALUE > Attributes
std::map< VARIANT_ID, VARIANT > Variants
std::vector< SWAP_GROUP > SwapGroups
wxString GateName
Optional.
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.
A progress reporter interface for use in multi-threaded environments.
virtual void Parse(XNODE *aNode, PARSER_CONTEXT *aContext)=0
wxString ItemReference
For Components, this references the designator in the reuse file.
Uncommitted pin (default)
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).
< "GATEDEFINITION" node name
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.
< "PARTDEFINITION" node name
std::map< FIGURE_ID, FIGURE > Figures
REUSEBLOCK_ID ReuseBlockID
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.
PART_DEFINITION_PIN_ID ID
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.
REUSEBLOCKREF ReuseBlockRef
TERMINAL_ID TerminalPin
(subnode="PINTERM", param1)
POSITION
Positioning of pin names can be in one of four quadrants.
std::map< TEXT_ID, TEXT > Texts
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...
< "PARTDEFINITIONPIN" node name
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
long OrientAngle
1/1000 of a Degree
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.
ATTRIBUTE_LOCATION AttributeLocation
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,...
static const long FONT_BOLD
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
std::function< void()> CheckPointCallback
Callback function to report progress.
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.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString DOCUMENTATION_SYMBOL_ID
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
std::map< ATTRIBUTE_ID, ATTRCOL > AttributeColors
long TERMINAL_ID
Terminal is the pin identifier in the schematic.
DOCUMENTATION_SYMBOL_ID ID
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
Output pin not normally OR tieable.
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
static bool IsShape(XNODE *aNode)
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.
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...
REUSEBLOCKREF ReuseBlockRef
PIN_TYPE Type
subnode="PINTYPE"
std::vector< ROUTEREASSIGN > RouteReassigns
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
REUSEBLOCKREF ReuseBlockRef
< "PINEQUIVALENCE" Node name
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)
static bool IsVertex(XNODE *aNode)
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)
static wxString ParseTextFields(const wxString &aTextString, PARSER_CONTEXT *aParserContext)
Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.
static const long FONT_NORMAL
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
Output pin not OR tieable.
Corresponds to CADSTAR "origin".
std::vector< VERTEX > Vertices
< 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.
void checkPoint()
Updates m_progressReporter or throws if user cancelled.
Hold an XML or S-expression element.
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
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
PROGRESS_REPORTER * m_progressReporter
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)
DFLTSETTINGS DefaultSettings
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
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
static wxString HandleTextOverbar(wxString aCadstarString)
Convert a string with CADSTAR overbar characters to equivalent in KiCad.
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
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
wxString Name
Can be empty.
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...
Tristate bi-directional driver pin.
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
GATE_ID ID
Usually "A", "B", "C", etc.
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
static long GetNumberOfStepsForReporting(XNODE *aRootNode, std::vector< wxString > aSubNodeChildrenToCount)
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
REUSEBLOCKREF ReuseBlockRef
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
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.