KiCad PCB EDA Suite
CADSTAR_PCB_ARCHIVE_PARSER Class Reference

Represents a CADSTAR PCB Archive (CPA) file. More...

#include <cadstar_pcb_archive_parser.h>

Inheritance diagram for CADSTAR_PCB_ARCHIVE_PARSER:
CADSTAR_ARCHIVE_PARSER CADSTAR_PCB_ARCHIVE_LOADER

Classes

struct  AREA
 From CADSTAR Help: "Area is for creating areas within which, and nowhere else, certain operations are carried out (e.g. More...
 
struct  ASSIGNMENTS
 
struct  CADSTAR_BOARD
 
struct  CADSTAR_PAD_SHAPE
 
struct  CODEDEFS_PCB
 
struct  COMPONENT
 
struct  COMPONENT_AREA
 From CADSTAR Help: "Area is for creating areas within which, and nowhere else, certain operations are carried out (e.g. More...
 
struct  COMPONENT_COPPER
 A shape of copper in the component footprint. More...
 
struct  COMPONENT_PAD
 
struct  COPPER
 
struct  COPPERCODE
 
struct  COPREASSIGN
 
struct  DIMENSION
 Linear, leader (radius/diameter) or angular dimension. More...
 
struct  DRILL_TABLE
 
struct  LAYER
 
struct  LAYERDEFS
 
struct  LAYERPAIR
 
struct  LAYOUT
 
struct  LIBRARY
 
struct  MATERIAL
 
struct  NET_PCB
 
struct  PAD_EXITS
 From CADSTAR help: "For specifying the directions in which routes can enter or exit the pad. More...
 
struct  PADCODE
 
struct  PADEXCEPTION
 
struct  PADREASSIGN
 
struct  PIN_ATTRIBUTE
 
struct  RULESET
 
struct  SPACINGCODE
 
struct  SPCCLASSSPACE
 
struct  SYMDEF_PCB
 
struct  TECHNOLOGY_SECTION
 
struct  TEMPLATE
 Templates are CADSTAR's equivalent to a "filled zone". More...
 
struct  TRUNK
 
struct  VIACODE
 
struct  VIAREASSIGN
 

Public Types

enum  MATERIAL_LAYER_TYPE { MATERIAL_LAYER_TYPE::CONSTRUCTION, MATERIAL_LAYER_TYPE::ELECTRICAL, MATERIAL_LAYER_TYPE::NON_ELECTRICAL }
 Type of layer appropriate for the material being set up. More...
 
enum  LAYER_TYPE {
  LAYER_TYPE::UNDEFINED, LAYER_TYPE::ALLLAYER, LAYER_TYPE::ALLELEC, LAYER_TYPE::ALLDOC,
  LAYER_TYPE::NOLAYER, LAYER_TYPE::ASSCOMPCOPP, LAYER_TYPE::JUMPERLAYER, LAYER_TYPE::ELEC,
  LAYER_TYPE::POWER, LAYER_TYPE::NONELEC, LAYER_TYPE::CONSTRUCTION, LAYER_TYPE::DOC
}
 
enum  LAYER_SUBTYPE {
  LAYER_SUBTYPE::LAYERSUBTYPE_NONE, LAYER_SUBTYPE::LAYERSUBTYPE_SILKSCREEN, LAYER_SUBTYPE::LAYERSUBTYPE_PLACEMENT, LAYER_SUBTYPE::LAYERSUBTYPE_ASSEMBLY,
  LAYER_SUBTYPE::LAYERSUBTYPE_SOLDERRESIST, LAYER_SUBTYPE::LAYERSUBTYPE_PASTE, LAYER_SUBTYPE::LAYERSUBTYPE_CLEARANCE, LAYER_SUBTYPE::LAYERSUBTYPE_ROUT
}
 
enum  ROUTING_BIAS {
  ROUTING_BIAS::UNBIASED, ROUTING_BIAS::X, ROUTING_BIAS::Y, ROUTING_BIAS::ANTI_ROUTE,
  ROUTING_BIAS::OBSTACLE
}
 
enum  EMBEDDING { EMBEDDING::NONE, EMBEDDING::ABOVE, EMBEDDING::BELOW }
 
enum  PAD_SHAPE_TYPE {
  PAD_SHAPE_TYPE::ANNULUS, PAD_SHAPE_TYPE::BULLET, PAD_SHAPE_TYPE::CIRCLE, PAD_SHAPE_TYPE::DIAMOND,
  PAD_SHAPE_TYPE::FINGER, PAD_SHAPE_TYPE::OCTAGON, PAD_SHAPE_TYPE::RECTANGLE, PAD_SHAPE_TYPE::ROUNDED_RECT,
  PAD_SHAPE_TYPE::SQUARE
}
 
enum  PAD_SIDE { PAD_SIDE::MINIMUM, PAD_SIDE::MAXIMUM, PAD_SIDE::THROUGH_HOLE }
 From CADSTAR Help: "This parameter indicates the physical layers on which the selected pad is placed. More...
 
enum  SYMDEF_TYPE { SYMDEF_TYPE::COMPONENT, SYMDEF_TYPE::JUMPER, SYMDEF_TYPE::STARPOINT, SYMDEF_TYPE::TESTPOINT }
 A symbol definition can represent a number of different objects in CADSTAR. More...
 
enum  TESTLAND_SIDE { TESTLAND_SIDE::NONE, TESTLAND_SIDE::MAX, TESTLAND_SIDE::MIN, TESTLAND_SIDE::BOTH }
 
enum  NETSYNCH { NETSYNCH::UNDEFINED, NETSYNCH::WARNING, NETSYNCH::FULL }
 
typedef wxString MATERIAL_ID
 
typedef long PHYSICAL_LAYER_ID
 
typedef wxString COPPERCODE_ID
 
typedef wxString PADCODE_ID
 
typedef wxString VIACODE_ID
 
typedef wxString SPACINGCODE_ID
 
typedef wxString LAYERPAIR_ID
 
typedef wxString RULESET_ID
 
typedef wxString COMP_AREA_ID
 
typedef long PAD_ID
 Pad identifier (pin) in the PCB. More...
 
typedef wxString DIMENSION_ID
 
typedef wxString BOARD_ID
 
typedef wxString AREA_ID
 
typedef wxString COMPONENT_ID
 
typedef wxString TEMPLATE_ID
 
typedef long COPPER_TERM_ID
 
typedef wxString COPPER_ID
 
typedef wxString DRILL_TABLE_ID
 
typedef wxString TRUNK_ID
 
enum  TEXT_FIELD_NAME {
  TEXT_FIELD_NAME::DESIGN_TITLE, TEXT_FIELD_NAME::SHORT_JOBNAME, TEXT_FIELD_NAME::LONG_JOBNAME, TEXT_FIELD_NAME::NUM_OF_SHEETS,
  TEXT_FIELD_NAME::SHEET_NUMBER, TEXT_FIELD_NAME::SHEET_NAME, TEXT_FIELD_NAME::VARIANT_NAME, TEXT_FIELD_NAME::VARIANT_DESCRIPTION,
  TEXT_FIELD_NAME::REG_USER, TEXT_FIELD_NAME::COMPANY_NAME, TEXT_FIELD_NAME::CURRENT_USER, TEXT_FIELD_NAME::DATE,
  TEXT_FIELD_NAME::TIME, TEXT_FIELD_NAME::MACHINE_NAME, TEXT_FIELD_NAME::FROM_FILE, TEXT_FIELD_NAME::DISTANCE,
  TEXT_FIELD_NAME::UNITS_SHORT, TEXT_FIELD_NAME::UNITS_ABBREV, TEXT_FIELD_NAME::UNITS_FULL, TEXT_FIELD_NAME::HYPERLINK,
  TEXT_FIELD_NAME::NONE
}
 These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NAME][FIELD_VALUE]>. More...
 
enum  RESOLUTION { RESOLUTION::HUNDREDTH_MICRON }
 
enum  LINESTYLE {
  LINESTYLE::SOLID, LINESTYLE::DASH, LINESTYLE::DASHDOT, LINESTYLE::DASHDOTDOT,
  LINESTYLE::DOT
}
 
enum  VERTEX_TYPE {
  VERTEX_TYPE::POINT, VERTEX_TYPE::CLOCKWISE_ARC, VERTEX_TYPE::CLOCKWISE_SEMICIRCLE, VERTEX_TYPE::ANTICLOCKWISE_ARC,
  VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE
}
 
enum  SHAPE_TYPE { SHAPE_TYPE::OPENSHAPE, SHAPE_TYPE::OUTLINE, SHAPE_TYPE::SOLID, SHAPE_TYPE::HATCHED }
 
enum  UNITS {
  UNITS::DESIGN, UNITS::THOU, UNITS::INCH, UNITS::MICROMETRE,
  UNITS::MM, UNITS::CENTIMETER, UNITS::METER
}
 
enum  ANGUNITS { ANGUNITS::DEGREES, ANGUNITS::RADIANS }
 
enum  GRID_TYPE { GRID_TYPE::FRACTIONALGRID, GRID_TYPE::STEPGRID }
 
enum  ALIGNMENT {
  ALIGNMENT::NO_ALIGNMENT, ALIGNMENT::TOPLEFT, ALIGNMENT::TOPCENTER, ALIGNMENT::TOPRIGHT,
  ALIGNMENT::CENTERLEFT, ALIGNMENT::CENTERCENTER, ALIGNMENT::CENTERRIGHT, ALIGNMENT::BOTTOMLEFT,
  ALIGNMENT::BOTTOMCENTER, ALIGNMENT::BOTTOMRIGHT
}
 From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all text items in CADSTAR. More...
 
enum  JUSTIFICATION { JUSTIFICATION::LEFT, JUSTIFICATION::CENTER, JUSTIFICATION::RIGHT }
 From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right. More...
 
enum  READABILITY { READABILITY::BOTTOM_TO_TOP, READABILITY::TOP_TO_BOTTOM }
 Sets the readability direction of text. More...
 
enum  ATTROWNER {
  ATTROWNER::ALL_ITEMS, ATTROWNER::AREA, ATTROWNER::BOARD, ATTROWNER::COMPONENT,
  ATTROWNER::CONNECTION, ATTROWNER::COPPER, ATTROWNER::DOCSYMBOL, ATTROWNER::FIGURE,
  ATTROWNER::NET, ATTROWNER::NETCLASS, ATTROWNER::PART, ATTROWNER::PART_DEFINITION,
  ATTROWNER::PIN, ATTROWNER::SIGNALREF, ATTROWNER::SYMBOL, ATTROWNER::SYMDEF,
  ATTROWNER::TEMPLATE, ATTROWNER::TESTPOINT
}
 
enum  ATTRUSAGE {
  ATTRUSAGE::BOTH, ATTRUSAGE::COMPONENT, ATTRUSAGE::PART_DEFINITION, ATTRUSAGE::PART_LIBRARY,
  ATTRUSAGE::SYMBOL, ATTRUSAGE::UNDEFINED
}
 
enum  SWAP_RULE { SWAP_RULE::NO_SWAP, SWAP_RULE::USE_SWAP_LAYER, SWAP_RULE::BOTH }
 Corresponds to "Display when" Item property. More...
 
typedef wxString LINECODE_ID
 
typedef wxString HATCHCODE_ID
 
typedef wxString ROUTECODE_ID
 
typedef wxString NETCLASS_ID
 
typedef wxString SPACING_CLASS_ID
 
typedef wxString TEXTCODE_ID
 
typedef wxString LAYER_ID
 ID of a Sheet (if schematic) or board Layer (if PCB) More...
 
typedef wxString VARIANT_ID
 
typedef wxString ATTRIBUTE_ID
 
typedef wxString SYMDEF_ID
 
typedef wxString PART_ID
 
typedef wxString GATE_ID
 
typedef long TERMINAL_ID
 Terminal is the pin identifier in the schematic. More...
 
typedef long PART_DEFINITION_PIN_ID
 Pin identifier in the part definition. More...
 
typedef long PART_PIN_ID
 Pin identifier in the part. More...
 
typedef wxString TEXT_ID
 
typedef wxString FIGURE_ID
 
typedef wxString GROUP_ID
 
typedef wxString REUSEBLOCK_ID
 
typedef wxString NET_ID
 
typedef wxString NETELEMENT_ID
 
typedef wxString DOCUMENTATION_SYMBOL_ID
 
typedef wxString COLOR_ID
 

Public Member Functions

 CADSTAR_PCB_ARCHIVE_PARSER (const wxString &aFilename)
 
void Parse ()
 Parses the file. More...
 

Static Public Member Functions

static PAD_SIDE GetPadSide (const wxString &aPadSideString)
 
static TESTLAND_SIDE ParseTestlandSide (XNODE *aNode)
 
static wxString ParseTextFields (const wxString &aTextString, PARSER_CONTEXT *aParserContext)
 Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext. More...
 
static UNITS ParseUnits (XNODE *aNode)
 
static ANGUNITS ParseAngunits (XNODE *aNode)
 
static ALIGNMENT ParseAlignment (XNODE *aNode)
 
static JUSTIFICATION ParseJustification (XNODE *aNode)
 
static READABILITY ParseReadability (XNODE *aNode)
 
static SWAP_RULE ParseSwapRule (XNODE *aNode)
 
static void InsertAttributeAtEnd (XNODE *aNode, wxString aValue)
 
static XNODELoadArchiveFile (const wxString &aFileName, const wxString &aFileTypeIdentifier, PROGRESS_REPORTER *aProgressReporter=nullptr)
 Reads a CADSTAR Archive file (S-parameter format) More...
 
static bool IsValidAttribute (wxXmlAttribute *aAttribute)
 
static wxString GetXmlAttributeIDString (XNODE *aNode, unsigned int aID, bool aIsRequired=true)
 
static long GetXmlAttributeIDLong (XNODE *aNode, unsigned int aID, bool aIsRequired=true)
 
static void CheckNoChildNodes (XNODE *aNode)
 
static void CheckNoNextNodes (XNODE *aNode)
 
static void ParseChildEValue (XNODE *aNode, PARSER_CONTEXT *aContext, EVALUE &aValueToParse)
 
static std::vector< POINTParseAllChildPoints (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) More...
 
static std::vector< VERTEXParseAllChildVertices (XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false)
 if no children are present, it just returns an empty vector (without throwing an exception) More...
 
static std::vector< CUTOUTParseAllChildCutouts (XNODE *aNode, PARSER_CONTEXT *aContext, bool aTestAllChildNodes=false)
 if no children are present, it just returns an empty vector (without throwing an exception) More...
 
static long GetNumberOfChildNodes (XNODE *aNode)
 
static long GetNumberOfStepsForReporting (XNODE *aRootNode, std::vector< wxString > aSubNodeChildrenToCount)
 
static wxString HandleTextOverbar (wxString aCadstarString)
 Convert a string with CADSTAR overbar characters to equivalent in KiCad. More...
 
static void FixTextPositionNoAlignment (EDA_TEXT *aKiCadTextItem)
 Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR. More...
 
static wxString generateLibName (const wxString &aRefName, const wxString &aAlternateName)
 

Public Attributes

wxString Filename
 
HEADER Header
 
ASSIGNMENTS Assignments
 
LIBRARY Library
 
PARTS Parts
 
LAYOUT Layout
 
int KiCadUnitMultiplier
 Use this value to convert units in this CPA file to KiCad units. More...
 

Static Public Attributes

static const long UNDEFINED_VALUE = -1
 
static const double TXT_HEIGHT_RATIO = ( 24.0 - 5.0 ) / 24.0
 CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24. More...
 
static const std::map< TEXT_FIELD_NAME, wxString > CADSTAR_TO_KICAD_FIELDS
 Map between CADSTAR fields and KiCad text variables. More...
 
static const long FONT_NORMAL = 400
 
static const long FONT_BOLD = 700
 

Protected Member Functions

void checkPoint ()
 Updates m_progressReporter or throws if user cancelled. More...
 

Protected Attributes

PARSER_CONTEXT m_context
 
PROGRESS_REPORTERm_progressReporter
 

Detailed Description

Represents a CADSTAR PCB Archive (CPA) file.

Definition at line 42 of file cadstar_pcb_archive_parser.h.

Member Typedef Documentation

◆ AREA_ID

Definition at line 70 of file cadstar_pcb_archive_parser.h.

◆ ATTRIBUTE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_ID
inherited

Definition at line 100 of file cadstar_archive_parser.h.

◆ BOARD_ID

Definition at line 69 of file cadstar_pcb_archive_parser.h.

◆ COLOR_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::COLOR_ID
inherited

Definition at line 114 of file cadstar_archive_parser.h.

◆ COMP_AREA_ID

Definition at line 66 of file cadstar_pcb_archive_parser.h.

◆ COMPONENT_ID

Definition at line 71 of file cadstar_pcb_archive_parser.h.

◆ COPPER_ID

Definition at line 74 of file cadstar_pcb_archive_parser.h.

◆ COPPER_TERM_ID

◆ COPPERCODE_ID

Definition at line 60 of file cadstar_pcb_archive_parser.h.

◆ DIMENSION_ID

Definition at line 68 of file cadstar_pcb_archive_parser.h.

◆ DOCUMENTATION_SYMBOL_ID

Definition at line 113 of file cadstar_archive_parser.h.

◆ DRILL_TABLE_ID

Definition at line 75 of file cadstar_pcb_archive_parser.h.

◆ FIGURE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::FIGURE_ID
inherited

Definition at line 108 of file cadstar_archive_parser.h.

◆ GATE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::GATE_ID
inherited

Definition at line 103 of file cadstar_archive_parser.h.

◆ GROUP_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::GROUP_ID
inherited

Definition at line 109 of file cadstar_archive_parser.h.

◆ HATCHCODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::HATCHCODE_ID
inherited

Definition at line 93 of file cadstar_archive_parser.h.

◆ LAYER_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::LAYER_ID
inherited

ID of a Sheet (if schematic) or board Layer (if PCB)

Definition at line 98 of file cadstar_archive_parser.h.

◆ LAYERPAIR_ID

Definition at line 64 of file cadstar_pcb_archive_parser.h.

◆ LINECODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::LINECODE_ID
inherited

Definition at line 92 of file cadstar_archive_parser.h.

◆ MATERIAL_ID

Definition at line 58 of file cadstar_pcb_archive_parser.h.

◆ NET_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NET_ID
inherited

Definition at line 111 of file cadstar_archive_parser.h.

◆ NETCLASS_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NETCLASS_ID
inherited

Definition at line 95 of file cadstar_archive_parser.h.

◆ NETELEMENT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NETELEMENT_ID
inherited

Definition at line 112 of file cadstar_archive_parser.h.

◆ PAD_ID

Pad identifier (pin) in the PCB.

Definition at line 67 of file cadstar_pcb_archive_parser.h.

◆ PADCODE_ID

Definition at line 61 of file cadstar_pcb_archive_parser.h.

◆ PART_DEFINITION_PIN_ID

Pin identifier in the part definition.

Definition at line 105 of file cadstar_archive_parser.h.

◆ PART_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::PART_ID
inherited

Definition at line 102 of file cadstar_archive_parser.h.

◆ PART_PIN_ID

typedef long CADSTAR_ARCHIVE_PARSER::PART_PIN_ID
inherited

Pin identifier in the part.

Definition at line 106 of file cadstar_archive_parser.h.

◆ PHYSICAL_LAYER_ID

◆ REUSEBLOCK_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::REUSEBLOCK_ID
inherited

Definition at line 110 of file cadstar_archive_parser.h.

◆ ROUTECODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::ROUTECODE_ID
inherited

Definition at line 94 of file cadstar_archive_parser.h.

◆ RULESET_ID

Definition at line 65 of file cadstar_pcb_archive_parser.h.

◆ SPACING_CLASS_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::SPACING_CLASS_ID
inherited

Definition at line 96 of file cadstar_archive_parser.h.

◆ SPACINGCODE_ID

Definition at line 63 of file cadstar_pcb_archive_parser.h.

◆ SYMDEF_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::SYMDEF_ID
inherited

Definition at line 101 of file cadstar_archive_parser.h.

◆ TEMPLATE_ID

Definition at line 72 of file cadstar_pcb_archive_parser.h.

◆ TERMINAL_ID

typedef long CADSTAR_ARCHIVE_PARSER::TERMINAL_ID
inherited

Terminal is the pin identifier in the schematic.

Definition at line 104 of file cadstar_archive_parser.h.

◆ TEXT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::TEXT_ID
inherited

Definition at line 107 of file cadstar_archive_parser.h.

◆ TEXTCODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::TEXTCODE_ID
inherited

Definition at line 97 of file cadstar_archive_parser.h.

◆ TRUNK_ID

Definition at line 76 of file cadstar_pcb_archive_parser.h.

◆ VARIANT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::VARIANT_ID
inherited

Definition at line 99 of file cadstar_archive_parser.h.

◆ VIACODE_ID

Definition at line 62 of file cadstar_pcb_archive_parser.h.

Member Enumeration Documentation

◆ ALIGNMENT

enum CADSTAR_ARCHIVE_PARSER::ALIGNMENT
stronginherited

From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all text items in CADSTAR.

The alignment origin is a point on or within the text boundary and defines how the text is displayed.

For example, with an alignment of bottom-right the origin will be positioned at the bottom right of the text boundary. This makes it easier to right-align several text items regardless of the length of text displayed.

Text Alignment applies to all CADSTAR text. [...]

Note: Unaligned text operates in the way CADSTAR text always has. In most cases this behaves as Bottom Left alignment, but there are a few exceptions, e.g. pin names. Also unaligned multiline text has an origin Bottom Left of the first line."

See also JUSTIFICATION

Enumerator
NO_ALIGNMENT 

NO_ALIGNMENT has different meaning depending on the object type.

TOPLEFT 
TOPCENTER 
TOPRIGHT 
CENTERLEFT 
CENTERCENTER 
CENTERRIGHT 
BOTTOMLEFT 
BOTTOMCENTER 
BOTTOMRIGHT 

Definition at line 576 of file cadstar_archive_parser.h.

577  {
578  NO_ALIGNMENT,
579  TOPLEFT,
580  TOPCENTER,
581  TOPRIGHT,
582  CENTERLEFT,
583  CENTERCENTER,
584  CENTERRIGHT,
585  BOTTOMLEFT,
586  BOTTOMCENTER,
587  BOTTOMRIGHT
588  };

◆ ANGUNITS

enum CADSTAR_ARCHIVE_PARSER::ANGUNITS
stronginherited
Enumerator
DEGREES 
RADIANS 

Definition at line 486 of file cadstar_archive_parser.h.

487  {
488  DEGREES,
489  RADIANS
490  };

◆ ATTROWNER

enum CADSTAR_ARCHIVE_PARSER::ATTROWNER
stronginherited
Enumerator
ALL_ITEMS 
AREA 
BOARD 
COMPONENT 
CONNECTION 
COPPER 
DOCSYMBOL 
FIGURE 
NET 
NETCLASS 
PART 

Only library Attributes.

PART_DEFINITION 

Only library Attributes.

PIN 
SIGNALREF 
SYMBOL 
SYMDEF 
TEMPLATE 
TESTPOINT 

Definition at line 630 of file cadstar_archive_parser.h.

631  {
632  ALL_ITEMS,
633  AREA,
634  BOARD,
635  COMPONENT,
636  CONNECTION,
637  COPPER,
638  DOCSYMBOL,
639  FIGURE,
640  NET,
641  NETCLASS,
642  PART,
643  PART_DEFINITION,
644  PIN,
645  SIGNALREF,
646  SYMBOL,
647  SYMDEF,
648  TEMPLATE,
649  TESTPOINT
650  };
a test point pad
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
This item represents a net.
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191

◆ ATTRUSAGE

enum CADSTAR_ARCHIVE_PARSER::ATTRUSAGE
stronginherited
Enumerator
BOTH 

From CADSTAR Help: Assigned to both Schematic symbols and PCB components, and displayed on Schematic and PCB designs.

COMPONENT 

From CADSTAR Help: Assigned to PCB components and displayed on PCB designs.

PART_DEFINITION 

From CADSTAR Help: Assigned to Parts library Definitions and displayed by the Library searcher.

PART_LIBRARY 

From CADSTAR Help: Only used by non-Cadstar applications.

SYMBOL 

From CADSTAR Help: Assigned to Schematic Symbols and displayed on Schematic Designs.

UNDEFINED 

Note: It seems that some attribute have no "ATTRUSAGE" defined.

It appears that the attributes that fall under this category are the ones associated with the design itself (i.e. not inherited from the library)

Definition at line 653 of file cadstar_archive_parser.h.

654  {
655  BOTH,
656  COMPONENT,
658  PART_DEFINITION,
659  PART_LIBRARY,
661  SYMBOL,
662  UNDEFINED
664  };
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84

◆ EMBEDDING

Enumerator
NONE 
ABOVE 
BELOW 

Definition at line 142 of file cadstar_pcb_archive_parser.h.

143  {
144  NONE,
145  ABOVE,
146  BELOW
147  };
No updates are required.
Definition: view_item.h:46

◆ GRID_TYPE

enum CADSTAR_ARCHIVE_PARSER::GRID_TYPE
stronginherited
Enumerator
FRACTIONALGRID 

Param1 = Units, Param2 = Divisor.

The grid is equal in X and Y dimensions with a step size equal to Param1/Param2

STEPGRID 

Param1 = X Step, Param2 = Y Step. A standard x,y grid.

Definition at line 496 of file cadstar_archive_parser.h.

497  {
498  FRACTIONALGRID,
499  STEPGRID
501  };

◆ JUSTIFICATION

From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.

This does not affect the text alignment. Note: Justification of single line text has no effect."

This only affects multiline text

See also ALIGNMENT

Enumerator
LEFT 
CENTER 
RIGHT 

Definition at line 602 of file cadstar_archive_parser.h.

◆ LAYER_SUBTYPE

Enumerator
LAYERSUBTYPE_NONE 
LAYERSUBTYPE_SILKSCREEN 
LAYERSUBTYPE_PLACEMENT 
LAYERSUBTYPE_ASSEMBLY 
LAYERSUBTYPE_SOLDERRESIST 
LAYERSUBTYPE_PASTE 
LAYERSUBTYPE_CLEARANCE 
LAYERSUBTYPE_ROUT 

Definition at line 119 of file cadstar_pcb_archive_parser.h.

120  {
121  LAYERSUBTYPE_NONE,
122  LAYERSUBTYPE_SILKSCREEN,
123  LAYERSUBTYPE_PLACEMENT,
124  LAYERSUBTYPE_ASSEMBLY,
125  LAYERSUBTYPE_SOLDERRESIST,
126  LAYERSUBTYPE_PASTE,
127  LAYERSUBTYPE_CLEARANCE,
128  LAYERSUBTYPE_ROUT,
129  };

◆ LAYER_TYPE

Enumerator
UNDEFINED 

Only used for error detection.

ALLLAYER 

Inbuilt layer type (cannot be assigned to user layers)

ALLELEC 

Inbuilt layer type (cannot be assigned to user layers)

ALLDOC 

Inbuilt layer type (cannot be assigned to user layers)

NOLAYER 

Inbuilt layer type (cannot be assigned to user layers)

ASSCOMPCOPP 

Inbuilt layer type (cannot be assigned to user layers)

JUMPERLAYER 

Inbuilt layer type (cannot be assigned to user layers)

ELEC 
POWER 
NONELEC 

This type has subtypes.

CONSTRUCTION 
DOC 

Definition at line 102 of file cadstar_pcb_archive_parser.h.

103  {
104  UNDEFINED,
105  ALLLAYER,
106  ALLELEC,
107  ALLDOC,
108  NOLAYER,
109  ASSCOMPCOPP,
110  JUMPERLAYER,
111  ELEC,
112  POWER,
113  NONELEC,
114  CONSTRUCTION,
115  DOC
116  };

◆ LINESTYLE

enum CADSTAR_ARCHIVE_PARSER::LINESTYLE
stronginherited
Enumerator
SOLID 
DASH 
DASHDOT 
DASHDOTDOT 
DOT 

Definition at line 280 of file cadstar_archive_parser.h.

◆ MATERIAL_LAYER_TYPE

Type of layer appropriate for the material being set up.

Enumerator
CONSTRUCTION 
ELECTRICAL 

Either.

See also
LAYER_TYPE::ELEC or
LAYER_TYPE::POWER
NON_ELECTRICAL 

Definition at line 81 of file cadstar_pcb_archive_parser.h.

82  {
83  CONSTRUCTION,
84  ELECTRICAL,
85  NON_ELECTRICAL
86  };

◆ NETSYNCH

Enumerator
UNDEFINED 
WARNING 
FULL 

Definition at line 1153 of file cadstar_pcb_archive_parser.h.

1154  {
1155  UNDEFINED,
1156  WARNING,
1157  FULL
1158  };
pads are covered by copper

◆ PAD_SHAPE_TYPE

Enumerator
ANNULUS 
BULLET 
CIRCLE 

Keyword "ROUND".

DIAMOND 
FINGER 
OCTAGON 
RECTANGLE 
ROUNDED_RECT 

Keyword "ROUNDED".

SQUARE 

Definition at line 259 of file cadstar_pcb_archive_parser.h.

260  {
261  ANNULUS,
262  BULLET,
263  CIRCLE,
264  DIAMOND,
265  FINGER,
266  OCTAGON,
267  RECTANGLE,
268  ROUNDED_RECT,
269  SQUARE
270  };
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:32

◆ PAD_SIDE

From CADSTAR Help: "This parameter indicates the physical layers on which the selected pad is placed.

Note: When you change the Side parameter in PCB Design, the Side assigned to the pad in the library is not overwritten."

Enumerator
MINIMUM 

PHYSICAL_LAYER_ID 1 (i.e.

front / top side). Normally used for surface mount devices.

MAXIMUM 

The highest PHYSICAL_LAYER_ID currently defined (i.e.

back / bottom side). Normally used for surface mount devices.

THROUGH_HOLE 

All physical layers currently defined.

Definition at line 480 of file cadstar_pcb_archive_parser.h.

481  {
482  MINIMUM,
483  MAXIMUM,
485  THROUGH_HOLE
487  };

◆ READABILITY

Sets the readability direction of text.

From CADSTAR Help: "Horizontal text will always be displayed from left to right (i.e. never upside down). Vertical text can be set as readable from either the left or right edge of the design."

I.e. Vertical text can either be rotated 90 degrees clockwise or 90 degrees anticlockwise from horizontal. This does not impact vertical text

Enumerator
BOTTOM_TO_TOP 

When text is vertical, show it rotated 90 degrees anticlockwise.

TOP_TO_BOTTOM 

When text is vertical, show it rotated 90 degrees clockwise.

Definition at line 620 of file cadstar_archive_parser.h.

621  {
622  BOTTOM_TO_TOP,
623  TOP_TO_BOTTOM
624  };

◆ RESOLUTION

enum CADSTAR_ARCHIVE_PARSER::RESOLUTION
stronginherited
Enumerator
HUNDREDTH_MICRON 

Definition at line 242 of file cadstar_archive_parser.h.

243  {
244  HUNDREDTH_MICRON
245  };

◆ ROUTING_BIAS

Enumerator
UNBIASED 

Keyword "UNBIASED" (default)

Keyword "X_BIASED".

Keyword "Y_BIASED".

ANTI_ROUTE 

Keyword "ANTITRACK".

OBSTACLE 

Keyword "OBSTACLE".

Definition at line 132 of file cadstar_pcb_archive_parser.h.

133  {
134  UNBIASED,
135  X,
136  Y,
137  ANTI_ROUTE,
138  OBSTACLE
139  };

◆ SHAPE_TYPE

enum CADSTAR_ARCHIVE_PARSER::SHAPE_TYPE
stronginherited
Enumerator
OPENSHAPE 

Unfilled open shape. Cannot have cutouts.

OUTLINE 

Unfilled closed shape.

SOLID 

Filled closed shape (solid fill).

HATCHED 

Filled closed shape (hatch fill).

Definition at line 450 of file cadstar_archive_parser.h.

451  {
452  OPENSHAPE,
453  OUTLINE,
454  SOLID,
455  HATCHED
456  };

◆ SWAP_RULE

enum CADSTAR_ARCHIVE_PARSER::SWAP_RULE
stronginherited

Corresponds to "Display when" Item property.

From CADSTAR Help: "This parameter enables you to make the visibility of a component outline/area (or an area of component copper, or a string of component text) dependent on the current mirror status of the component.

For example, you may require a string of component text to be displayed only when the component is mirrored."

Enumerator
NO_SWAP 

Display when Unmirrored.

USE_SWAP_LAYER 

Display when Mirrored.

BOTH 

Always display (Mirrored and Unmirrored)

Definition at line 810 of file cadstar_archive_parser.h.

811  {
812  NO_SWAP,
813  USE_SWAP_LAYER,
814  BOTH
815  };

◆ SYMDEF_TYPE

A symbol definition can represent a number of different objects in CADSTAR.

SYMDEF_TYPE is used in cadstar2kicadplugin to simplify identification of each type.

Enumerator
COMPONENT 

Standard PCB Component definition.

JUMPER 

From CADSTAR Help: "Jumpers are components used primarily for the purpose of routing.

A jumper's two pins are connected with a wire, joining together the nets on either side. Typically, a jumper is used to bridge across other routes where a routing problem is particularly difficult or to make a small modification to a design when most of the routing has been finalised.

In CADSTAR, components are designated as jumpers in the component footprint. If the footprint has two pins and the first eight letters of the reference name spell "JUMPERNF" then the component will be treated as a jumper.

From CADSTAR 8.0 archive format onwards, jumpers are saved as jumpers. For older archive formats and for most other export formats and post processing, jumpers are treated just as components. When CADSTAR saves a PCB design in an old archive format, the implied connection between the jumper's pins is added as an actual connection. When an old archive or binary PCB design is opened in the latest CADSTAR, any component footprint with two pins and whose first eight letters spell "JUMPERNF" will be treated as a jumper footprint automatically. If there is an actual connection between the pins, it will be removed and one implied from then on. If there isn't an actual connection, the nets connected to the pins will be merged. If a merge is needed and if each net has a user-supplied name (not $...), you will be asked to choose which name to use."

STARPOINT 

From CADSTAR Help: "Starpoints are special symbols/components that can be used to electrically connect different nets together, whilst avoiding any of the standard design rule error codes that would normally occur.

If the first eleven letters of the reference name spell "STARPOINTNF" then the component will be treated as a starpoint.

For a starpoint component to be valid:

  • There must be at least two pads
  • All pads must have the same position
  • All pads must have the same orientation
  • All pads must be on the same side
  • All pad codes must be the same
  • All pads must have the same exit direction
  • All pads must have the same PCB Only Pad setting

If a starpoint component is not valid you will get an error message when trying to add it to the PCB component library."

TESTPOINT 

From CADSTAR Help: "A testpoint is an area of copper connected to a net.

It allows a test probe to investigate the electrical properties of that net. The Testpoint Symbols provided in the CADSTAR libraries are the Alternates for a pre-defined symbol called TESTPOINT."

If the ReferenceName equals "TESTPOINT", then the component is treated as such. Note that the library manager does not permit adding a component with the name "TESTPOINT" if it has more than one pad defined.

Definition at line 720 of file cadstar_pcb_archive_parser.h.

721  {
722  COMPONENT,
723  JUMPER,
724  STARPOINT,
746  TESTPOINT
764  };
a test point pad
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84

◆ TESTLAND_SIDE

Enumerator
NONE 
MAX 

The highest PHYSICAL_LAYER_ID currently defined (i.e. back / bottom side).

MIN 

The lowest PHYSICAL_LAYER_ID currently defined (i.e. front / top side).

BOTH 

Definition at line 858 of file cadstar_pcb_archive_parser.h.

859  {
860  NONE,
861  MAX,
862  MIN,
863  BOTH
864  };
No updates are required.
Definition: view_item.h:46

◆ TEXT_FIELD_NAME

These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NAME][FIELD_VALUE]>.

For example: "<@DESIGN TITLEProject [email protected]>"

Enumerator
DESIGN_TITLE 
SHORT_JOBNAME 
LONG_JOBNAME 
NUM_OF_SHEETS 
SHEET_NUMBER 
SHEET_NAME 
VARIANT_NAME 
VARIANT_DESCRIPTION 
REG_USER 
COMPANY_NAME 
CURRENT_USER 
DATE 
TIME 
MACHINE_NAME 
FROM_FILE 
DISTANCE 
UNITS_SHORT 
UNITS_ABBREV 
UNITS_FULL 
HYPERLINK 
NONE 

Synthetic for flagging.

Definition at line 135 of file cadstar_archive_parser.h.

136  {
137  DESIGN_TITLE,
138  SHORT_JOBNAME,
139  LONG_JOBNAME,
140  NUM_OF_SHEETS,
141  SHEET_NUMBER,
142  SHEET_NAME,
143  VARIANT_NAME,
144  VARIANT_DESCRIPTION,
145  REG_USER,
146  COMPANY_NAME,
147  CURRENT_USER,
148  DATE,
149  TIME,
150  MACHINE_NAME,
151  FROM_FILE,
152  DISTANCE,
153  UNITS_SHORT,
154  UNITS_ABBREV,
155  UNITS_FULL,
156  HYPERLINK,
157  NONE
158  };
Display value expressed in distance units (mm/inch)
Definition: property.h:53
No updates are required.
Definition: view_item.h:46

◆ UNITS

enum CADSTAR_ARCHIVE_PARSER::UNITS
stronginherited
Enumerator
DESIGN 

Inherits from design units (assumed Assignments->Technology->Units)

THOU 
INCH 
MICROMETRE 
MM 
CENTIMETER 
METER 

Definition at line 471 of file cadstar_archive_parser.h.

472  {
473  DESIGN,
474  THOU,
475  INCH,
476  MICROMETRE,
477  MM,
478  CENTIMETER,
479  METER
480  };
Definition: rs274x.cpp:63

◆ VERTEX_TYPE

Enumerator
POINT 
CLOCKWISE_ARC 
CLOCKWISE_SEMICIRCLE 
ANTICLOCKWISE_ARC 
ANTICLOCKWISE_SEMICIRCLE 

Definition at line 416 of file cadstar_archive_parser.h.

417  {
418  POINT,
419  CLOCKWISE_ARC,
420  CLOCKWISE_SEMICIRCLE,
421  ANTICLOCKWISE_ARC,
422  ANTICLOCKWISE_SEMICIRCLE
423  };

Constructor & Destructor Documentation

◆ CADSTAR_PCB_ARCHIVE_PARSER()

CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PCB_ARCHIVE_PARSER ( const wxString &  aFilename)
inlineexplicit

Definition at line 45 of file cadstar_pcb_archive_parser.h.

46  : Filename( aFilename ), Header(), Assignments(), CADSTAR_ARCHIVE_PARSER()
47  {
48  KiCadUnitMultiplier = 10; // assume hundredth micron
49  }
int KiCadUnitMultiplier
Use this value to convert units in this CPA file to KiCad units.

References KiCadUnitMultiplier.

Member Function Documentation

◆ CheckNoChildNodes()

◆ CheckNoNextNodes()

void CADSTAR_ARCHIVE_PARSER::CheckNoNextNodes ( XNODE aNode)
staticinherited

◆ checkPoint()

void CADSTAR_ARCHIVE_PARSER::checkPoint ( )
protectedinherited

Updates m_progressReporter or throws if user cancelled.

Definition at line 2645 of file cadstar_archive_parser.cpp.

2646 {
2647  if( m_progressReporter )
2648  {
2650 
2652  THROW_IO_ERROR( _( "File import cancelled by user." ) );
2653  }
2654 }
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).
#define _(s)
PROGRESS_REPORTER * m_progressReporter
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, PROGRESS_REPORTER::AdvanceProgress(), PROGRESS_REPORTER::KeepRefreshing(), CADSTAR_ARCHIVE_PARSER::m_progressReporter, and THROW_IO_ERROR.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::calculateZonePriorities(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers(), CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary(), CADSTAR_SCH_ARCHIVE_PARSER::Parse(), and Parse().

◆ FixTextPositionNoAlignment()

void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment ( EDA_TEXT aKiCadTextItem)
staticinherited

Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.

Assumes that the provided text element has been initialised with a position and orientation.

Parameters
aKiCadTextItema Kicad item to correct

Definition at line 2617 of file cadstar_archive_parser.cpp.

2618 {
2619  if( !aKiCadTextItem->GetText().IsEmpty() )
2620  {
2621  int txtAngleDecideg = aKiCadTextItem->GetTextAngleDegrees() * 10.0;
2622  wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
2623  RotatePoint( &positionOffset, txtAngleDecideg );
2624 
2625  EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
2626 
2627  if( textEdaItem &&
2628  ( textEdaItem->Type() == LIB_TEXT_T || textEdaItem->Type() == LIB_FIELD_T ) )
2629  {
2630  // Y coordinate increases upwards in the symbol editor
2631  positionOffset.y = -positionOffset.y;
2632  }
2633 
2634  //Count num of additional lines
2635  wxString text = aKiCadTextItem->GetText();
2636  int numExtraLines = text.Replace( wxT( "\n" ), wxT( "\n" ) );
2637  numExtraLines -= text.at( text.size() - 1 ) == '\n'; // Ignore new line character at end
2638  positionOffset.x *= numExtraLines;
2639  positionOffset.y *= numExtraLines;
2640 
2641  aKiCadTextItem->Offset( positionOffset );
2642  }
2643 }
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:273
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:233
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
double GetTextAngleDegrees() const
Definition: eda_text.h:197
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References EDA_TEXT::GetInterline(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleDegrees(), LIB_FIELD_T, LIB_TEXT_T, EDA_TEXT::Offset(), RotatePoint(), text, and EDA_ITEM::Type().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), and CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText().

◆ generateLibName()

static wxString CADSTAR_ARCHIVE_PARSER::generateLibName ( const wxString &  aRefName,
const wxString &  aAlternateName 
)
inlinestaticinherited

Definition at line 1402 of file cadstar_archive_parser.h.

1403  {
1404  return aRefName
1405  + ( ( aAlternateName.size() > 0 ) ? ( wxT( " (" ) + aAlternateName + wxT( ")" ) )
1406  : wxString() );
1407  }

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary().

◆ GetNumberOfChildNodes()

long CADSTAR_ARCHIVE_PARSER::GetNumberOfChildNodes ( XNODE aNode)
staticinherited

Definition at line 2575 of file cadstar_archive_parser.cpp.

2576 {
2577  XNODE* childNodes = aNode->GetChildren();
2578  long retval = 0;
2579 
2580  for( ; childNodes; childNodes = childNodes->GetNext() )
2581  retval++;
2582 
2583  return retval;
2584 }
XNODE * GetChildren() const
Definition: xnode.h:62
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67

References XNODE::GetChildren(), and XNODE::GetNext().

Referenced by CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting().

◆ GetNumberOfStepsForReporting()

long CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting ( XNODE aRootNode,
std::vector< wxString >  aSubNodeChildrenToCount 
)
staticinherited

Definition at line 2587 of file cadstar_archive_parser.cpp.

2588 {
2589  XNODE* level1Node = aRootNode->GetChildren();
2590  long retval = 0;
2591 
2592  for( ; level1Node; level1Node = level1Node->GetNext() )
2593  {
2594  for( wxString childNodeName : aSubNodeChildrenToCount )
2595  {
2596  if( level1Node->GetName() == childNodeName )
2597  retval += GetNumberOfChildNodes( level1Node );
2598  }
2599 
2600  retval++;
2601  }
2602 
2603  return retval;
2604 }
static long GetNumberOfChildNodes(XNODE *aNode)
XNODE * GetChildren() const
Definition: xnode.h:62
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67

References XNODE::GetChildren(), XNODE::GetNext(), and CADSTAR_ARCHIVE_PARSER::GetNumberOfChildNodes().

Referenced by CADSTAR_SCH_ARCHIVE_PARSER::Parse(), and Parse().

◆ GetPadSide()

CADSTAR_PCB_ARCHIVE_PARSER::PAD_SIDE CADSTAR_PCB_ARCHIVE_PARSER::GetPadSide ( const wxString &  aPadSideString)
static

Definition at line 1004 of file cadstar_pcb_archive_parser.cpp.

1006 {
1007  if( aPadSideString == wxT( "THRU" ) )
1008  return PAD_SIDE::THROUGH_HOLE;
1009  else if( aPadSideString == wxT( "BOTTOM" ) )
1010  return PAD_SIDE::MAXIMUM;
1011  else if( aPadSideString == wxT( "TOP" ) )
1012  return PAD_SIDE::MINIMUM;
1013  else
1014  return PAD_SIDE::THROUGH_HOLE; // Assume through hole as default
1015 }
The highest PHYSICAL_LAYER_ID currently defined (i.e.
All physical layers currently defined.

References MAXIMUM, MINIMUM, and THROUGH_HOLE.

Referenced by CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Parse(), and CADSTAR_PCB_ARCHIVE_PARSER::PADEXCEPTION::Parse().

◆ GetXmlAttributeIDLong()

long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong ( XNODE aNode,
unsigned int  aID,
bool  aIsRequired = true 
)
staticinherited
Parameters
aNode
aID
aIsRequiredPrevents exception throwing if false.
Returns
returns the value (long) of attribute "attrX" in aNode where 'X' is aID
Exceptions
IO_ERRORif attribute does not exist

Definition at line 2447 of file cadstar_archive_parser.cpp.

2449 {
2450  long retVal;
2451  bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
2452 
2453  if( !success )
2454  {
2455  if( aIsRequired )
2456  THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
2457  else
2458  return UNDEFINED_VALUE;
2459  }
2460 
2461  return retVal;
2462 }
#define THROW_PARSING_IO_ERROR(param, location)
static const long UNDEFINED_VALUE
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)

References CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), THROW_PARSING_IO_ERROR, and CADSTAR_ARCHIVE_PARSER::UNDEFINED_VALUE.

Referenced by CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::PIN_NUM_LABEL_LOC::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPREASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPERCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMATTR::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::REASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse(), CADSTAR_ARCHIVE_PARSER::FORMAT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::PIN_NUM::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_ARCHIVE_PARSER::HATCH::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Parse(), CADSTAR_ARCHIVE_PARSER::FONT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIACODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), CADSTAR_ARCHIVE_PARSER::TEXTCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPCCLASSSPACE::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse(), CADSTAR_ARCHIVE_PARSER::POINT::Parse(), CADSTAR_ARCHIVE_PARSER::LONGPOINT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TECHNOLOGY_SECTION::Parse(), CADSTAR_ARCHIVE_PARSER::GRID::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::ARROW::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::TEXTFORMAT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::LINE::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRNAME::COLUMNORDER::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRNAME::COLUMNWIDTH::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SYMDEF_PCB::Parse(), CADSTAR_ARCHIVE_PARSER::REUSEBLOCK::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PIN_ATTRIBUTE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADEXCEPTION::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::GATE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::COPPER_TERMINAL::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE_VERTEX::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::POURING::Parse(), CADSTAR_ARCHIVE_PARSER::PART::PART_PIN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::COPPER_TERM::Parse(), CADSTAR_ARCHIVE_PARSER::PART::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DRILL_TABLE::Parse(), CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse(), CADSTAR_ARCHIVE_PARSER::SETTINGS::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::SYMDEF::ParseSubNode(), and CADSTAR_ARCHIVE_PARSER::NET::ParseSubNode().

◆ GetXmlAttributeIDString()

wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString ( XNODE aNode,
unsigned int  aID,
bool  aIsRequired = true 
)
staticinherited
Parameters
aNode
aID
aIsRequiredPrevents exception throwing if false.
Returns
returns the value (wxString) of attribute "attrX" in aNode where 'X' is aID
Exceptions
IO_ERRORif attribute does not exist

Definition at line 2428 of file cadstar_archive_parser.cpp.

2430 {
2431  wxString attrName, retVal;
2432  attrName = wxT( "attr" );
2433  attrName << aID;
2434 
2435  if( !aNode->GetAttribute( attrName, &retVal ) )
2436  {
2437  if( aIsRequired )
2438  THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
2439  else
2440  return wxEmptyString;
2441  }
2442 
2443  return retVal;
2444 }
#define THROW_MISSING_PARAMETER_IO_ERROR(param, location)

References THROW_MISSING_PARAMETER_IO_ERROR.

Referenced by CADSTAR_ARCHIVE_PARSER::PART::GetPinType(), CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong(), CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINALCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::PIN_NUM_LABEL_LOC::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SHEETS::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERDEFS::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::COMP::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPREASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::PARTREF::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPERCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::REASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse(), CADSTAR_ARCHIVE_PARSER::FORMAT::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse(), CADSTAR_ARCHIVE_PARSER::TIMESTAMP::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SIGNALREFERENCELINK::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::Parse(), CADSTAR_ARCHIVE_PARSER::HEADER::Parse(), CADSTAR_ARCHIVE_PARSER::VARIANT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADREASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_ARCHIVE_PARSER::LINECODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SIGLOC::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Parse(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::BUS::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIAREASSIGN::Parse(), CADSTAR_ARCHIVE_PARSER::FONT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIACODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), CADSTAR_ARCHIVE_PARSER::TEXTCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::JUNCTION_SCH::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPCCLASSSPACE::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BUS_TERM::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::RULESET::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse(), CADSTAR_ARCHIVE_PARSER::EVALUE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::DANGLER::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::CONNECTION_SCH::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_COPPER::Parse(), CADSTAR_ARCHIVE_PARSER::SHAPE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_AREA::Parse(), CADSTAR_ARCHIVE_PARSER::GRID::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::ARROW::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::TEXTFORMAT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::LINE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRNAME::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_VALUE::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse(), CADSTAR_ARCHIVE_PARSER::CADSTAR_NETCLASS::Parse(), CADSTAR_ARCHIVE_PARSER::SPCCLASSNAME::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_BOARD::Parse(), CADSTAR_ARCHIVE_PARSER::REUSEBLOCK::Parse(), CADSTAR_ARCHIVE_PARSER::REUSEBLOCKREF::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Parse(), CADSTAR_ARCHIVE_PARSER::GROUP::Parse(), CADSTAR_ARCHIVE_PARSER::FIGURE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADEXCEPTION::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TRUNK::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::PIN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::JUNCTION_PCB::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::GATE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::VIA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::COPPER_TERMINAL::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::CONNECTION_PCB::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::POURING::Parse(), CADSTAR_ARCHIVE_PARSER::PART::PART_PIN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::Parse(), CADSTAR_ARCHIVE_PARSER::PART::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DRILL_TABLE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Parse(), CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse(), CADSTAR_ARCHIVE_PARSER::DFLTSETTINGS::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRCOL::Parse(), CADSTAR_ARCHIVE_PARSER::PARTNAMECOL::Parse(), CADSTAR_ARCHIVE_PARSER::ParseAlignment(), CADSTAR_ARCHIVE_PARSER::ParseAngunits(), CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseIdentifiers(), CADSTAR_ARCHIVE_PARSER::SYMDEF::ParseIdentifiers(), CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseIdentifiers(), CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseIdentifiers(), CADSTAR_ARCHIVE_PARSER::NET::ParseIdentifiers(), CADSTAR_ARCHIVE_PARSER::ParseJustification(), CADSTAR_ARCHIVE_PARSER::ParseReadability(), CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::NET::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::ParseSwapRule(), ParseTestlandSide(), and CADSTAR_ARCHIVE_PARSER::ParseUnits().

◆ HandleTextOverbar()

wxString CADSTAR_ARCHIVE_PARSER::HandleTextOverbar ( wxString  aCadstarString)
staticinherited

Convert a string with CADSTAR overbar characters to equivalent in KiCad.

Parameters
aCadstarStringInput string
Returns
KiCad string with overbar characters

Definition at line 2607 of file cadstar_archive_parser.cpp.

2608 {
2609  wxString escapedText = aCadstarString;
2610 
2611  escapedText.Replace( wxT( "'" ), wxT( "~" ) );
2612 
2613  return ConvertToNewOverbarNotation( escapedText );
2614 }
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.

References ConvertToNewOverbarNotation().

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CADSTAR_SCH_ARCHIVE_LOADER::loadBusses(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), and CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary().

◆ InsertAttributeAtEnd()

void CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd ( XNODE aNode,
wxString  aValue 
)
staticinherited

Definition at line 2297 of file cadstar_archive_parser.cpp.

2298 {
2299  wxString result;
2300  int numAttributes = 0;
2301 
2302  if( aNode->GetAttribute( wxT( "numAttributes" ), &result ) )
2303  {
2304  numAttributes = wxAtoi( result );
2305  aNode->DeleteAttribute( wxT( "numAttributes" ) );
2306  ++numAttributes;
2307  }
2308 
2309  aNode->AddAttribute( wxT( "numAttributes" ), wxString::Format( wxT( "%i" ), numAttributes ) );
2310 
2311  wxString paramName = wxT( "attr" );
2312  paramName << numAttributes;
2313 
2314  aNode->AddAttribute( paramName, aValue );
2315 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format().

Referenced by CADSTAR_ARCHIVE_PARSER::LoadArchiveFile().

◆ IsValidAttribute()

bool CADSTAR_ARCHIVE_PARSER::IsValidAttribute ( wxXmlAttribute *  aAttribute)
staticinherited

◆ LoadArchiveFile()

XNODE * CADSTAR_ARCHIVE_PARSER::LoadArchiveFile ( const wxString &  aFileName,
const wxString &  aFileTypeIdentifier,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
staticinherited

Reads a CADSTAR Archive file (S-parameter format)

Parameters
aFileName
aFileTypeIdentifierIdentifier of the first node in the file to check against. E.g. "CADSTARPCB"
aProgressReporterPointer to a Progress Reporter to report progress to.
Returns
XNODE pointing to the top of the tree for further parsing. Each node has the first element as the node's name and subsequent elements as node attributes ("attr0", "attr1", "attr2", etc.). Caller is responsible for deleting to avoid memory leaks.
Exceptions
IO_ERROR

Definition at line 2318 of file cadstar_archive_parser.cpp.

2320 {
2321  KEYWORD emptyKeywords[1] = {};
2322  XNODE * iNode = nullptr, *cNode = nullptr;
2323  int tok;
2324  bool cadstarFileCheckDone = false;
2325  wxString str;
2326  wxCSConv win1252( wxT( "windows-1252" ) );
2327  wxMBConv* conv = &win1252; // Initial testing suggests file encoding to be Windows-1252
2328  // More samples required.
2329 
2330  // Open the file and get the file size
2331  FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
2332 
2333  if( !fp )
2334  THROW_IO_ERROR( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
2335 
2336  fseek( fp, 0L, SEEK_END );
2337  long fileSize = ftell( fp );
2338  rewind( fp );
2339 
2340  DSNLEXER lexer( emptyKeywords, 0, fp, aFileName );
2341 
2342  auto currentProgress = [&]() -> double
2343  {
2344  return static_cast<double>( ftell( fp ) ) / fileSize;
2345  };
2346 
2347  double previousReportedProgress = -1.0;
2348 
2349  while( ( tok = lexer.NextTok() ) != DSN_EOF )
2350  {
2351  if( aProgressReporter && ( currentProgress() - previousReportedProgress ) > 0.01 )
2352  {
2353  if( !aProgressReporter->KeepRefreshing() )
2354  THROW_IO_ERROR( _( "File import cancelled by user." ) );
2355 
2356  aProgressReporter->SetCurrentProgress( currentProgress() );
2357  previousReportedProgress = currentProgress();
2358  }
2359 
2360  if( tok == DSN_RIGHT )
2361  {
2362  cNode = iNode;
2363  if( cNode )
2364  {
2365  iNode = cNode->GetParent();
2366  }
2367  else
2368  {
2369  //too many closing brackets
2370  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2371  }
2372  }
2373  else if( tok == DSN_LEFT )
2374  {
2375  tok = lexer.NextTok();
2376  str = wxString( lexer.CurText(), *conv );
2377  cNode = new XNODE( wxXML_ELEMENT_NODE, str );
2378 
2379  if( iNode )
2380  {
2381  //we will add it as attribute as well as child node
2382  InsertAttributeAtEnd( iNode, str );
2383  iNode->AddChild( cNode );
2384  }
2385  else if( !cadstarFileCheckDone )
2386  {
2387  if( cNode->GetName() != aFileTypeIdentifier )
2388  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2389 
2390  cadstarFileCheckDone = true;
2391  }
2392 
2393  iNode = cNode;
2394  }
2395  else if( iNode )
2396  {
2397  str = wxString( lexer.CurText(), *conv );
2398  //Insert even if string is empty
2399  InsertAttributeAtEnd( iNode, str );
2400  }
2401  else
2402  {
2403  //not enough closing brackets
2404  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2405  }
2406  }
2407 
2408  // Not enough closing brackets
2409  if( iNode != nullptr )
2410  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2411 
2412  // Throw if no data was parsed
2413  if( cNode )
2414  return cNode;
2415  else
2416  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2417 
2418  return nullptr;
2419 }
XNODE * GetParent() const
Definition: xnode.h:72
#define _(s)
Hold an XML or S-expression element.
Definition: xnode.h:43
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static void InsertAttributeAtEnd(XNODE *aNode, wxString aValue)
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
Hold a keyword string and its unique integer token.
Definition: dsnlexer.h:39
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:78
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).

References _, DSNLEXER::CurText(), DSN_EOF, DSN_LEFT, DSN_RIGHT, Format(), XNODE::GetParent(), CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd(), PROGRESS_REPORTER::KeepRefreshing(), DSNLEXER::NextTok(), PROGRESS_REPORTER::SetCurrentProgress(), and THROW_IO_ERROR.

Referenced by CADSTAR_SCH_ARCHIVE_PARSER::Parse(), and Parse().

◆ Parse()

void CADSTAR_PCB_ARCHIVE_PARSER::Parse ( )

Parses the file.

Exceptions
IO_ERRORif file could not be opened or there was an error while parsing

Definition at line 33 of file cadstar_pcb_archive_parser.cpp.

34 {
35  if( m_progressReporter )
36  m_progressReporter->BeginPhase( 0 ); // Read file
37 
38  XNODE* fileRootNode = LoadArchiveFile( Filename, wxT( "CADSTARPCB" ), m_progressReporter );
39 
40  if( m_progressReporter )
41  {
42  m_progressReporter->BeginPhase( 1 ); // Parse File
43 
44  std::vector<wxString> subNodeChildrenToCount = { wxT( "LIBRARY" ), wxT( "PARTS" ),
45  wxT( "LAYOUT" ) };
46 
47  long numOfSteps = GetNumberOfStepsForReporting( fileRootNode, subNodeChildrenToCount );
48  m_progressReporter->SetMaxProgress( numOfSteps );
49  }
50 
52 
53  XNODE* cNode = fileRootNode->GetChildren();
54 
55  if( !cNode )
56  THROW_MISSING_NODE_IO_ERROR( wxT( "HEADER" ), wxT( "CADSTARPCB" ) );
57 
58  for( ; cNode; cNode = cNode->GetNext() )
59  {
60  if( cNode->GetName() == wxT( "HEADER" ) )
61  {
62  Header.Parse( cNode, &m_context );
63 
64  switch( Header.Resolution )
65  {
68  break;
69 
70  default:
71  wxASSERT_MSG( true, wxT( "Unknown File Resolution" ) );
72  break;
73  }
74 
75  if( Header.Format.Type != wxT( "LAYOUT" ) )
76  {
77  if( Header.Format.Type == wxT( "LIBRARY" ) )
78  {
79  THROW_IO_ERROR( wxT( "The selected file is a CADSTAR library file (as opposed "
80  "to a layout file). CADSTAR libraries cannot yet be "
81  "imported into KiCad." ) );
82  }
83  else
84  {
85  THROW_IO_ERROR( wxT( "The selected file is an unknown CADSTAR format so "
86  "cannot be imported into KiCad." ) );
87  }
88  }
89  }
90  else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) )
91  {
92  Assignments.Parse( cNode, &m_context );
93  }
94  else if( cNode->GetName() == wxT( "LIBRARY" ) )
95  {
96  Library.Parse( cNode, &m_context );
97  }
98  else if( cNode->GetName() == wxT( "DEFAULTS" ) )
99  {
100  // No design information here (no need to parse)
101  // Only contains CADSTAR configuration data such as default shapes, text and units
102  // In future some of this could be converted to KiCad but limited value
103  }
104  else if( cNode->GetName() == wxT( "PARTS" ) )
105  {
106  Parts.Parse( cNode, &m_context );
107  }
108  else if( cNode->GetName() == wxT( "LAYOUT" ) )
109  {
110  Layout.Parse( cNode, &m_context );
111  }
112  else if( cNode->GetName() == wxT( "DISPLAY" ) )
113  {
114  // No design information here (no need to parse)
115  // Contains CADSTAR Display settings such as layer/element colours and visibility.
116  // In the future these settings could be converted to KiCad
117  }
118  else
119  {
120  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "[root]" ) );
121  }
122 
123  checkPoint();
124  }
125 
126  delete fileRootNode;
127 }
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
virtual void BeginPhase(int aPhase)=0
Initialize the aPhase virtual zone of the dialog progress bar.
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
std::function< void()> CheckPointCallback
Callback function to report progress.
XNODE * GetChildren() const
Definition: xnode.h:62
constexpr double PCB_IU_PER_MM
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
#define THROW_MISSING_NODE_IO_ERROR(nodename, location)
void checkPoint()
Updates m_progressReporter or throws if user cancelled.
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
PROGRESS_REPORTER * m_progressReporter
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
#define THROW_UNKNOWN_NODE_IO_ERROR(nodename, location)
void Parse(XNODE *aNode, PARSER_CONTEXT *aContext) override
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
static long GetNumberOfStepsForReporting(XNODE *aRootNode, std::vector< wxString > aSubNodeChildrenToCount)
int KiCadUnitMultiplier
Use this value to convert units in this CPA file to KiCad units.

References Assignments, PROGRESS_REPORTER::BeginPhase(), CADSTAR_ARCHIVE_PARSER::checkPoint(), CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::CheckPointCallback, Filename, CADSTAR_ARCHIVE_PARSER::HEADER::Format, XNODE::GetChildren(), XNODE::GetNext(), CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting(), Header, CADSTAR_ARCHIVE_PARSER::HUNDREDTH_MICRON, KiCadUnitMultiplier, Layout, Library, CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(), CADSTAR_ARCHIVE_PARSER::m_context, CADSTAR_ARCHIVE_PARSER::m_progressReporter, CADSTAR_ARCHIVE_PARSER::HEADER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LIBRARY::Parse(), CADSTAR_ARCHIVE_PARSER::PARTS::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Parse(), Parts, PCB_IU_PER_MM, CADSTAR_ARCHIVE_PARSER::HEADER::Resolution, PROGRESS_REPORTER::SetMaxProgress(), THROW_IO_ERROR, THROW_MISSING_NODE_IO_ERROR, THROW_UNKNOWN_NODE_IO_ERROR, and CADSTAR_ARCHIVE_PARSER::FORMAT::Type.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::Load().

◆ ParseAlignment()

CADSTAR_ARCHIVE_PARSER::ALIGNMENT CADSTAR_ARCHIVE_PARSER::ParseAlignment ( XNODE aNode)
staticinherited

Definition at line 937 of file cadstar_archive_parser.cpp.

938 {
939  wxASSERT( aNode->GetName() == wxT( "ALIGN" ) );
940 
941  wxString alignmentStr = GetXmlAttributeIDString( aNode, 0 );
942 
943  if( alignmentStr == wxT( "BOTTOMCENTER" ) )
945  else if( alignmentStr == wxT( "BOTTOMLEFT" ) )
946  return ALIGNMENT::BOTTOMLEFT;
947  else if( alignmentStr == wxT( "BOTTOMRIGHT" ) )
948  return ALIGNMENT::BOTTOMRIGHT;
949  else if( alignmentStr == wxT( "CENTERCENTER" ) )
951  else if( alignmentStr == wxT( "CENTERLEFT" ) )
952  return ALIGNMENT::CENTERLEFT;
953  else if( alignmentStr == wxT( "CENTERRIGHT" ) )
954  return ALIGNMENT::CENTERRIGHT;
955  else if( alignmentStr == wxT( "TOPCENTER" ) )
956  return ALIGNMENT::TOPCENTER;
957  else if( alignmentStr == wxT( "TOPLEFT" ) )
958  return ALIGNMENT::TOPLEFT;
959  else if( alignmentStr == wxT( "TOPRIGHT" ) )
960  return ALIGNMENT::TOPRIGHT;
961  else
962  THROW_UNKNOWN_PARAMETER_IO_ERROR( alignmentStr, wxT( "ALIGN" ) );
963 
964  //shouldn't be here but avoids compiler warning
966 }
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
NO_ALIGNMENT has different meaning depending on the object type.
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)

References CADSTAR_ARCHIVE_PARSER::BOTTOMCENTER, CADSTAR_ARCHIVE_PARSER::BOTTOMLEFT, CADSTAR_ARCHIVE_PARSER::BOTTOMRIGHT, CADSTAR_ARCHIVE_PARSER::CENTERCENTER, CADSTAR_ARCHIVE_PARSER::CENTERLEFT, CADSTAR_ARCHIVE_PARSER::CENTERRIGHT, CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), CADSTAR_ARCHIVE_PARSER::NO_ALIGNMENT, THROW_UNKNOWN_PARAMETER_IO_ERROR, CADSTAR_ARCHIVE_PARSER::TOPCENTER, CADSTAR_ARCHIVE_PARSER::TOPLEFT, and CADSTAR_ARCHIVE_PARSER::TOPRIGHT.

Referenced by CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT::Parse(), and CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode().

◆ ParseAllChildCutouts()

std::vector< CADSTAR_ARCHIVE_PARSER::CUTOUT > CADSTAR_ARCHIVE_PARSER::ParseAllChildCutouts ( XNODE aNode,
PARSER_CONTEXT aContext,
bool  aTestAllChildNodes = false 
)
staticinherited

if no children are present, it just returns an empty vector (without throwing an exception)

Parameters
aNodecontaining a series of CUTOUT objects
aTestAllChildNodes
aExpectedNumPointsif -1, this is check is disabled
Returns
std::vector containing all CUTOUT objects
Exceptions
IO_ERRORif one of the following:
  • Unable to parse a CUTOUT object
  • aTestAllChildNodes is true and one of the child nodes is not a valid CUTOUT object

Definition at line 2549 of file cadstar_archive_parser.cpp.

2551 {
2552  std::vector<CUTOUT> retVal;
2553 
2554  XNODE* cNode = aNode->GetChildren();
2555 
2556  for( ; cNode; cNode = cNode->GetNext() )
2557  {
2558  if( cNode->GetName() == wxT( "CUTOUT" ) )
2559  {
2560  CUTOUT cutout;
2561  //TODO try.. catch + throw again with more detailed error information
2562  cutout.Parse( cNode, aContext );
2563  retVal.push_back( cutout );
2564  }
2565  else if( aTestAllChildNodes )
2566  {
2567  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
2568  }
2569  }
2570 
2571  return retVal;
2572 }
XNODE * GetChildren() const
Definition: xnode.h:62
Make a cutout to an existing zone.
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67
#define THROW_UNKNOWN_NODE_IO_ERROR(nodename, location)

References XNODE::GetChildren(), XNODE::GetNext(), CADSTAR_ARCHIVE_PARSER::CUTOUT::Parse(), and THROW_UNKNOWN_NODE_IO_ERROR.

Referenced by CADSTAR_ARCHIVE_PARSER::SHAPE::Parse().

◆ ParseAllChildPoints()

std::vector< CADSTAR_ARCHIVE_PARSER::POINT > CADSTAR_ARCHIVE_PARSER::ParseAllChildPoints ( XNODE aNode,
PARSER_CONTEXT aContext,
bool  aTestAllChildNodes = false,
int  aExpectedNumPoints = UNDEFINED_VALUE 
)
staticinherited

if no children are present, it just returns an empty vector (without throwing an exception)

Parameters
aNodecontaining a series of POINT objects
aTestAllChildNodes
aExpectedNumPointsif UNDEFINED_VALUE (i.e. -1), this is check is disabled
Returns
std::vector containing all POINT objects
Exceptions
IO_ERRORif one of the following:
  • Unable to parse a POINT object
  • aTestAllChildNodes is true and one of the child nodes is not a valid POINT object
  • aExpectedNumPoints is non-negative and the number of POINT objects found is different

Definition at line 2489 of file cadstar_archive_parser.cpp.

2491 {
2492  std::vector<POINT> retVal;
2493 
2494  XNODE* cNode = aNode->GetChildren();
2495 
2496  for( ; cNode; cNode = cNode->GetNext() )
2497  {
2498  if( cNode->GetName() == wxT( "PT" ) )
2499  {
2500  POINT pt;
2501  //TODO try.. catch + throw again with more detailed error information
2502  pt.Parse( cNode, aContext );
2503  retVal.push_back( pt );
2504  }
2505  else if( aTestAllChildNodes )
2506  {
2507  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
2508  }
2509  }
2510 
2511  if( aExpectedNumPoints != UNDEFINED_VALUE
2512  && retVal.size() != static_cast<size_t>( aExpectedNumPoints ) )
2513  {
2515  _( "Unexpected number of points in '%s'. Found %d but expected %d." ),
2516  aNode->GetName(), retVal.size(), aExpectedNumPoints ) );
2517  }
2518 
2519  return retVal;
2520 }
XNODE * GetChildren() const
Definition: xnode.h:62
#define _(s)
static const long UNDEFINED_VALUE
Hold an XML or S-expression element.
Definition: xnode.h:43
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
XNODE * GetNext() const
Definition: xnode.h:67
#define THROW_UNKNOWN_NODE_IO_ERROR(nodename, location)
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), XNODE::GetChildren(), XNODE::GetNext(), CADSTAR_ARCHIVE_PARSER::POINT::Parse(), THROW_IO_ERROR, THROW_UNKNOWN_NODE_IO_ERROR, and CADSTAR_ARCHIVE_PARSER::UNDEFINED_VALUE.

Referenced by CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::CONNECTION_SCH::Parse(), CADSTAR_ARCHIVE_PARSER::VERTEX::Parse(), and CADSTAR_ARCHIVE_PARSER::SETTINGS::ParseSubNode().

◆ ParseAllChildVertices()

std::vector< CADSTAR_ARCHIVE_PARSER::VERTEX > CADSTAR_ARCHIVE_PARSER::ParseAllChildVertices ( XNODE aNode,
PARSER_CONTEXT aContext,
bool  aTestAllChildNodes = false 
)
staticinherited

if no children are present, it just returns an empty vector (without throwing an exception)

Parameters
aNodecontaining a series of VERTEX objects
aTestAllChildNodes
aExpectedNumPointsif -1, this is check is disabled
Returns
std::vector containing all VERTEX objects
Exceptions
IO_ERRORif one of the following:
  • Unable to parse a VERTEX object
  • aTestAllChildNodes is true and one of the child nodes is not a valid VERTEX object

Definition at line 2523 of file cadstar_archive_parser.cpp.

2525 {
2526  std::vector<VERTEX> retVal;
2527 
2528  XNODE* cNode = aNode->GetChildren();
2529 
2530  for( ; cNode; cNode = cNode->GetNext() )
2531  {
2532  if( VERTEX::IsVertex( cNode ) )
2533  {
2534  VERTEX vertex;
2535  //TODO try.. catch + throw again with more detailed error information
2536  vertex.Parse( cNode, aContext );
2537  retVal.push_back( vertex );
2538  }
2539  else if( aTestAllChildNodes )
2540  {
2541  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
2542  }
2543  }
2544 
2545  return retVal;
2546 }
XNODE * GetChildren() const
Definition: xnode.h:62
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67
#define THROW_UNKNOWN_NODE_IO_ERROR(nodename, location)

References XNODE::GetChildren(), XNODE::GetNext(), CADSTAR_ARCHIVE_PARSER::VERTEX::IsVertex(), CADSTAR_ARCHIVE_PARSER::VERTEX::Parse(), and THROW_UNKNOWN_NODE_IO_ERROR.

Referenced by CADSTAR_ARCHIVE_PARSER::CUTOUT::Parse(), and CADSTAR_ARCHIVE_PARSER::SHAPE::Parse().

◆ ParseAngunits()

CADSTAR_ARCHIVE_PARSER::ANGUNITS CADSTAR_ARCHIVE_PARSER::ParseAngunits ( XNODE aNode)
staticinherited

Definition at line 576 of file cadstar_archive_parser.cpp.

577 {
578  wxASSERT( aNode->GetName() == wxT( "ANGUNITS" ) );
579 
580  wxString angUnitStr = GetXmlAttributeIDString( aNode, 0 );
581 
582  if( angUnitStr == wxT( "DEGREES" ) )
583  return ANGUNITS::DEGREES;
584  else if( angUnitStr == wxT( "RADIANS" ) )
585  return ANGUNITS::RADIANS;
586  else
587  THROW_UNKNOWN_PARAMETER_IO_ERROR( angUnitStr, aNode->GetName() );
588 
589  return ANGUNITS();
590 }
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)

References CADSTAR_ARCHIVE_PARSER::DEGREES, CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), CADSTAR_ARCHIVE_PARSER::RADIANS, and THROW_UNKNOWN_PARAMETER_IO_ERROR.

Referenced by CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse().

◆ ParseChildEValue()

void CADSTAR_ARCHIVE_PARSER::ParseChildEValue ( XNODE aNode,
PARSER_CONTEXT aContext,
EVALUE aValueToParse 
)
staticinherited
Parameters
aNodewith a child node containing an EVALUE
aValueToParse
Exceptions
IO_ERRORif unable to parse or node is not an EVALUE

Definition at line 2479 of file cadstar_archive_parser.cpp.

2481 {
2482  if( aNode->GetChildren()->GetName() == wxT( "E" ) )
2483  aValueToParse.Parse( aNode->GetChildren(), aContext );
2484  else
2485  THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
2486 }
XNODE * GetChildren() const
Definition: xnode.h:62
#define THROW_UNKNOWN_NODE_IO_ERROR(nodename, location)

References XNODE::GetChildren(), CADSTAR_ARCHIVE_PARSER::EVALUE::Parse(), and THROW_UNKNOWN_NODE_IO_ERROR.

Referenced by CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Parse().

◆ ParseJustification()

CADSTAR_ARCHIVE_PARSER::JUSTIFICATION CADSTAR_ARCHIVE_PARSER::ParseJustification ( XNODE aNode)
staticinherited

Definition at line 969 of file cadstar_archive_parser.cpp.

970 {
971  wxASSERT( aNode->GetName() == wxT( "JUSTIFICATION" ) );
972 
973  wxString justificationStr = GetXmlAttributeIDString( aNode, 0 );
974 
975  if( justificationStr == wxT( "LEFT" ) )
976  return JUSTIFICATION::LEFT;
977  else if( justificationStr == wxT( "RIGHT" ) )
978  return JUSTIFICATION::RIGHT;
979  else if( justificationStr == wxT( "CENTER" ) )
980  return JUSTIFICATION::CENTER;
981  else
982  THROW_UNKNOWN_PARAMETER_IO_ERROR( justificationStr, wxT( "JUSTIFICATION" ) );
983 
984  return JUSTIFICATION::LEFT;
985 }
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)

References CADSTAR_ARCHIVE_PARSER::CENTER, CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), CADSTAR_ARCHIVE_PARSER::LEFT, CADSTAR_ARCHIVE_PARSER::RIGHT, and THROW_UNKNOWN_PARAMETER_IO_ERROR.

Referenced by CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT::Parse(), and CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode().

◆ ParseReadability()

CADSTAR_ARCHIVE_PARSER::READABILITY CADSTAR_ARCHIVE_PARSER::ParseReadability ( XNODE aNode)
staticinherited

Definition at line 988 of file cadstar_archive_parser.cpp.

989 {
990  wxASSERT( aNode->GetName() == wxT( "READABILITY" ) );
991 
992  wxString readabilityStr = GetXmlAttributeIDString( aNode, 0 );
993 
994  if( readabilityStr == wxT( "BOTTOM_TO_TOP" ) )
996  else if( readabilityStr == wxT( "TOP_TO_BOTTOM" ) )
998  else
999  THROW_UNKNOWN_PARAMETER_IO_ERROR( readabilityStr, wxT( "READABILITY" ) );
1000 
1002 }
When text is vertical, show it rotated 90 degrees clockwise.
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)
When text is vertical, show it rotated 90 degrees anticlockwise.

References CADSTAR_ARCHIVE_PARSER::BOTTOM_TO_TOP, CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), THROW_UNKNOWN_PARAMETER_IO_ERROR, and CADSTAR_ARCHIVE_PARSER::TOP_TO_BOTTOM.

Referenced by CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DRILL_TABLE::Parse(), and CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse().

◆ ParseSwapRule()

CADSTAR_ARCHIVE_PARSER::SWAP_RULE CADSTAR_ARCHIVE_PARSER::ParseSwapRule ( XNODE aNode)
staticinherited

Definition at line 1400 of file cadstar_archive_parser.cpp.

1401 {
1402  wxASSERT( aNode->GetName() == wxT( "SWAPRULE" ) );
1403 
1404  SWAP_RULE retval;
1405  wxString swapRuleStr = GetXmlAttributeIDString( aNode, 0 );
1406 
1407  if( swapRuleStr == wxT( "NO_SWAP" ) )
1408  retval = SWAP_RULE::NO_SWAP;
1409  else if( swapRuleStr == wxT( "USE_SWAP_LAYER" ) )
1410  retval = SWAP_RULE::USE_SWAP_LAYER;
1411  else
1412  THROW_UNKNOWN_PARAMETER_IO_ERROR( swapRuleStr, wxT( "SWAPRULE" ) );
1413 
1414  return retval;
1415 }
SWAP_RULE
Corresponds to "Display when" Item property.
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)

References CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), CADSTAR_ARCHIVE_PARSER::NO_SWAP, THROW_UNKNOWN_PARAMETER_IO_ERROR, and CADSTAR_ARCHIVE_PARSER::USE_SWAP_LAYER.

Referenced by CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_COPPER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_AREA::Parse(), CADSTAR_ARCHIVE_PARSER::FIGURE::Parse(), and CADSTAR_ARCHIVE_PARSER::TEXT::Parse().

◆ ParseTestlandSide()

CADSTAR_PCB_ARCHIVE_PARSER::TESTLAND_SIDE CADSTAR_PCB_ARCHIVE_PARSER::ParseTestlandSide ( XNODE aNode)
static

Definition at line 1923 of file cadstar_pcb_archive_parser.cpp.

1925 {
1926  wxASSERT( aNode->GetName() == wxT( "TESTLAND" ) );
1927 
1928  wxString side = GetXmlAttributeIDString( aNode, 0 );
1929 
1930  if( side == wxT( "MIN_SIDE" ) )
1931  return TESTLAND_SIDE::MIN;
1932  else if( side == wxT( "MAX_SIDE" ) )
1933  return TESTLAND_SIDE::MAX;
1934  else if( side == wxT( "BOTH_SIDES" ) )
1935  return TESTLAND_SIDE::BOTH;
1936  else
1937  THROW_UNKNOWN_PARAMETER_IO_ERROR( side, aNode->GetName() );
1938 
1939  return TESTLAND_SIDE::NONE;
1940 }
The highest PHYSICAL_LAYER_ID currently defined (i.e. back / bottom side).
The lowest PHYSICAL_LAYER_ID currently defined (i.e. front / top side).
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)

References BOTH, CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), MAX, MIN, NONE, and THROW_UNKNOWN_PARAMETER_IO_ERROR.

Referenced by CADSTAR_PCB_ARCHIVE_PARSER::PIN_ATTRIBUTE::Parse(), and CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::VIA::Parse().

◆ ParseTextFields()

wxString CADSTAR_ARCHIVE_PARSER::ParseTextFields ( const wxString &  aTextString,
PARSER_CONTEXT aParserContext 
)
staticinherited

Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.

Parameters
aTextStringText string to parse
aParserContextPARSER_CONTEXT in which to store the values of the found fields
Returns

Definition at line 743 of file cadstar_archive_parser.cpp.

745 {
746  static const std::map<TEXT_FIELD_NAME, wxString> txtTokens =
747  {
748  { TEXT_FIELD_NAME::DESIGN_TITLE, wxT( "DESIGN TITLE" ) },
749  { TEXT_FIELD_NAME::SHORT_JOBNAME, wxT( "SHORT_JOBNAME" ) },
750  { TEXT_FIELD_NAME::LONG_JOBNAME, wxT( "LONG_JOBNAME" ) },
751  { TEXT_FIELD_NAME::NUM_OF_SHEETS, wxT( "NUM_OF_SHEETS" ) },
752  { TEXT_FIELD_NAME::SHEET_NUMBER, wxT( "SHEET_NUMBER" ) },
753  { TEXT_FIELD_NAME::SHEET_NAME, wxT( "SHEET_NAME" ) },
754  { TEXT_FIELD_NAME::VARIANT_NAME, wxT( "VARIANT_NAME" ) },
755  { TEXT_FIELD_NAME::VARIANT_DESCRIPTION, wxT( "VARIANT_DESCRIPTION" ) },
756  { TEXT_FIELD_NAME::REG_USER, wxT( "REG_USER" ) },
757  { TEXT_FIELD_NAME::COMPANY_NAME, wxT( "COMPANY_NAME" ) },
758  { TEXT_FIELD_NAME::CURRENT_USER, wxT( "CURRENT_USER" ) },
759  { TEXT_FIELD_NAME::DATE, wxT( "DATE" ) },
760  { TEXT_FIELD_NAME::TIME, wxT( "TIME" ) },
761  { TEXT_FIELD_NAME::MACHINE_NAME, wxT( "MACHINE_NAME" ) },
762  { TEXT_FIELD_NAME::FROM_FILE, wxT( "FROM_FILE" ) },
763  { TEXT_FIELD_NAME::DISTANCE, wxT( "DISTANCE" ) },
764  { TEXT_FIELD_NAME::UNITS_SHORT, wxT( "UNITS SHORT" ) },
765  { TEXT_FIELD_NAME::UNITS_ABBREV, wxT( "UNITS ABBREV" ) },
766  { TEXT_FIELD_NAME::UNITS_FULL, wxT( "UNITS FULL" ) },
767  { TEXT_FIELD_NAME::HYPERLINK, wxT( "HYPERLINK" ) }
768  };
769 
770  wxString remainingStr = aTextString;
771  wxString returnStr;
772 
773  while( remainingStr.size() > 0 )
774  {
775  //Find the start token
776  size_t startpos = remainingStr.Find( wxT( "<@" ) );
777 
778  if( static_cast<int>( startpos ) == wxNOT_FOUND )
779  {
780  // No more fields to parse, add to return string
781  returnStr += remainingStr;
782  break;
783  }
784 
785  if( startpos > 0 )
786  returnStr += remainingStr.SubString( 0, startpos - 1 );
787 
788  if( ( startpos + 2 ) >= remainingStr.size() )
789  break;
790 
791  remainingStr = remainingStr.Mid( startpos + 2 );
792 
793  //Find the expected token for the field
795 
796  for( std::pair<TEXT_FIELD_NAME, wxString> txtF : txtTokens )
797  {
798  if( remainingStr.StartsWith( txtF.second ) )
799  {
800  foundField = txtF.first;
801  break;
802  }
803  }
804 
805  if( foundField == TEXT_FIELD_NAME::NONE )
806  {
807  // Not a valid field, lets keep looking
808  returnStr += wxT( "<@" );
809  continue;
810  }
811 
812  //Now lets find the end token
813  size_t endpos = remainingStr.Find( wxT( "@>" ) );
814 
815  if( static_cast<int>( endpos ) == wxNOT_FOUND )
816  {
817  // The field we found isn't valid as it doesn't have a termination
818  // Lets append the whole thing as plain text
819  returnStr += wxT( "<@" ) + remainingStr;
820  break;
821  }
822 
823  size_t valueStart = txtTokens.at( foundField ).size();
824  wxString fieldValue = remainingStr.SubString( valueStart, endpos - 1 );
825  wxString address;
826 
827  if( foundField == TEXT_FIELD_NAME::FROM_FILE || foundField == TEXT_FIELD_NAME::HYPERLINK )
828  {
829  // The first character should always be a double quotation mark
830  wxASSERT_MSG( fieldValue.at( 0 ) == '"', "Expected '\"' as the first character" );
831 
832  size_t splitPos = fieldValue.find_first_of( '"', 1 );
833  address = fieldValue.SubString( 1, splitPos - 1 );
834 
835  if( foundField == TEXT_FIELD_NAME::HYPERLINK )
836  {
837  // Assume the last two characters are "@>"
838  wxASSERT_MSG( remainingStr.EndsWith( wxT( "@>" ) ),
839  wxT( "Expected '@>' at the end of a hyperlink" ) );
840 
841  fieldValue = remainingStr.SubString( valueStart + splitPos + 1,
842  remainingStr.Length() - 3 );
843 
844  remainingStr = wxEmptyString;
845  }
846  else
847  {
848  fieldValue = fieldValue.Mid( splitPos + 1 );
849  }
850  }
851 
852  switch( foundField )
853  {
865 
866  if( aContext->TextFieldToValuesMap.find( foundField )
867  != aContext->TextFieldToValuesMap.end() )
868  {
869  aContext->InconsistentTextFields.insert( foundField );
870  }
871  else
872  {
873  aContext->TextFieldToValuesMap.insert( { foundField, fieldValue } );
874  }
875 
877 
881  returnStr += wxT( "${" ) + CADSTAR_TO_KICAD_FIELDS.at( foundField ) + wxT( "}" );
882  break;
883 
888  // Just flatten the text for distances
889  returnStr += fieldValue;
890  break;
891 
893  {
894  wxFileName fn( address );
895  wxString fieldFmt = wxT( "FROM_FILE_%s_%s" );
896  wxString fieldName = wxString::Format( fieldFmt, fn.GetName(), fn.GetExt() );
897 
898  int version = 1;
899 
900  while(
901  aContext->FilenamesToTextMap.find( fieldName )
902  != aContext->FilenamesToTextMap.end()
903  && aContext->FilenamesToTextMap.at( fieldName ) != fieldValue )
904  {
905  fieldName = wxString::Format( fieldFmt, fn.GetName(), fn.GetExt() )
906  + wxString::Format( wxT( "_%d" ), version++ );
907  }
908 
909  aContext->FilenamesToTextMap[fieldName] = fieldValue;
910  returnStr += wxT( "${" ) + fieldName + wxT( "}" );
911  }
912  break;
913 
915  {
916  aContext->TextToHyperlinksMap[fieldValue] = address;
917  returnStr += ParseTextFields( fieldValue, aContext );
918  }
919  break;
920 
922  wxFAIL_MSG( "We should have already covered this scenario above" );
923  break;
924  }
925 
926 
927  if( ( endpos + 2 ) >= remainingStr.size() )
928  break;
929 
930  remainingStr = remainingStr.Mid( endpos + 2 );
931  }
932 
933  return returnStr;
934 }
TEXT_FIELD_NAME
These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NA...
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
static wxString ParseTextFields(const wxString &aTextString, PARSER_CONTEXT *aParserContext)
Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static const std::map< TEXT_FIELD_NAME, wxString > CADSTAR_TO_KICAD_FIELDS
Map between CADSTAR fields and KiCad text variables.

References CADSTAR_ARCHIVE_PARSER::CADSTAR_TO_KICAD_FIELDS, CADSTAR_ARCHIVE_PARSER::COMPANY_NAME, CADSTAR_ARCHIVE_PARSER::CURRENT_USER, CADSTAR_ARCHIVE_PARSER::DATE, CADSTAR_ARCHIVE_PARSER::DESIGN_TITLE, CADSTAR_ARCHIVE_PARSER::DISTANCE, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::FilenamesToTextMap, Format(), CADSTAR_ARCHIVE_PARSER::FROM_FILE, CADSTAR_ARCHIVE_PARSER::HYPERLINK, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::InconsistentTextFields, KI_FALLTHROUGH, CADSTAR_ARCHIVE_PARSER::LONG_JOBNAME, CADSTAR_ARCHIVE_PARSER::MACHINE_NAME, CADSTAR_ARCHIVE_PARSER::NONE, CADSTAR_ARCHIVE_PARSER::NUM_OF_SHEETS, CADSTAR_ARCHIVE_PARSER::REG_USER, CADSTAR_ARCHIVE_PARSER::SHEET_NAME, CADSTAR_ARCHIVE_PARSER::SHEET_NUMBER, CADSTAR_ARCHIVE_PARSER::SHORT_JOBNAME, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::TextFieldToValuesMap, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::TextToHyperlinksMap, CADSTAR_ARCHIVE_PARSER::TIME, CADSTAR_ARCHIVE_PARSER::UNITS_ABBREV, CADSTAR_ARCHIVE_PARSER::UNITS_FULL, CADSTAR_ARCHIVE_PARSER::UNITS_SHORT, CADSTAR_ARCHIVE_PARSER::VARIANT_DESCRIPTION, and CADSTAR_ARCHIVE_PARSER::VARIANT_NAME.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), and CADSTAR_ARCHIVE_PARSER::TEXT::Parse().

◆ ParseUnits()

CADSTAR_ARCHIVE_PARSER::UNITS CADSTAR_ARCHIVE_PARSER::ParseUnits ( XNODE aNode)
staticinherited

Definition at line 549 of file cadstar_archive_parser.cpp.

550 {
551  wxASSERT( aNode->GetName() == wxT( "UNITS" ) );
552 
553  wxString unit = GetXmlAttributeIDString( aNode, 0 );
554 
555  if( unit == wxT( "CENTIMETER" ) )
556  return UNITS::CENTIMETER;
557  else if( unit == wxT( "INCH" ) )
558  return UNITS::INCH;
559  else if( unit == wxT( "METER" ) )
560  return UNITS::METER;
561  else if( unit == wxT( "MICROMETRE" ) )
562  return UNITS::MICROMETRE;
563  else if( unit == wxT( "MM" ) )
564  return UNITS::MM;
565  else if( unit == wxT( "THOU" ) )
566  return UNITS::THOU;
567  else if( unit == wxT( "DESIGN" ) )
568  return UNITS::DESIGN;
569  else
570  THROW_UNKNOWN_PARAMETER_IO_ERROR( unit, wxT( "UNITS" ) );
571 
572  return UNITS();
573 }
Inherits from design units (assumed Assignments->Technology->Units)
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)
#define THROW_UNKNOWN_PARAMETER_IO_ERROR(param, location)

References CADSTAR_ARCHIVE_PARSER::CENTIMETER, CADSTAR_ARCHIVE_PARSER::DESIGN, CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(), CADSTAR_ARCHIVE_PARSER::INCH, CADSTAR_ARCHIVE_PARSER::METER, CADSTAR_ARCHIVE_PARSER::MICROMETRE, CADSTAR_ARCHIVE_PARSER::MM, CADSTAR_ARCHIVE_PARSER::THOU, and THROW_UNKNOWN_PARAMETER_IO_ERROR.

Referenced by CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse(), and CADSTAR_ARCHIVE_PARSER::SETTINGS::ParseSubNode().

Member Data Documentation

◆ Assignments

◆ CADSTAR_TO_KICAD_FIELDS

const std::map< CADSTAR_ARCHIVE_PARSER::TEXT_FIELD_NAME, wxString > CADSTAR_ARCHIVE_PARSER::CADSTAR_TO_KICAD_FIELDS
staticinherited
Initial value:
=
{ { TEXT_FIELD_NAME::DESIGN_TITLE, wxT( "DESIGN_TITLE" ) },
{ TEXT_FIELD_NAME::SHORT_JOBNAME, wxT( "SHORT_JOBNAME" ) },
{ TEXT_FIELD_NAME::LONG_JOBNAME, wxT( "LONG_JOBNAME" ) },
{ TEXT_FIELD_NAME::SHEET_NAME, wxT( "SHEETNAME" ) },
{ TEXT_FIELD_NAME::VARIANT_NAME, wxT( "VARIANT_NAME" ) },
{ TEXT_FIELD_NAME::VARIANT_DESCRIPTION, wxT( "VARIANT_DESCRIPTION" ) },
{ TEXT_FIELD_NAME::REG_USER, wxT( "REG_USER" ) },
{ TEXT_FIELD_NAME::COMPANY_NAME, wxT( "COMPANY_NAME" ) },
{ TEXT_FIELD_NAME::CURRENT_USER, wxT( "CURRENT_USER" ) },
{ TEXT_FIELD_NAME::DATE, wxT( "DATE" ) },
{ TEXT_FIELD_NAME::TIME, wxT( "TIME" ) },
{ TEXT_FIELD_NAME::MACHINE_NAME, wxT( "MACHINE_NAME" ) } }

Map between CADSTAR fields and KiCad text variables.

This is used as a lookup table when parsing CADSTAR text fields. Most variables have a similar name in KiCad as in CADSTAR.

Definition at line 164 of file cadstar_archive_parser.h.

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadTextVariables(), CADSTAR_PCB_ARCHIVE_LOADER::loadTextVariables(), and CADSTAR_ARCHIVE_PARSER::ParseTextFields().

◆ Filename

wxString CADSTAR_PCB_ARCHIVE_PARSER::Filename

Definition at line 1204 of file cadstar_pcb_archive_parser.h.

Referenced by Parse().

◆ FONT_BOLD

const long CADSTAR_ARCHIVE_PARSER::FONT_BOLD = 700
staticinherited

◆ FONT_NORMAL

const long CADSTAR_ARCHIVE_PARSER::FONT_NORMAL = 400
staticinherited

Definition at line 321 of file cadstar_archive_parser.h.

◆ Header

◆ KiCadUnitMultiplier

int CADSTAR_PCB_ARCHIVE_PARSER::KiCadUnitMultiplier

◆ Layout

◆ Library

◆ m_context

◆ m_progressReporter

◆ Parts

PARTS CADSTAR_PCB_ARCHIVE_PARSER::Parts

◆ TXT_HEIGHT_RATIO

const double CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO = ( 24.0 - 5.0 ) / 24.0
staticinherited

CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.

The characters can each specify a width of between 12 and 24, but the height is fixed at 24.

The default CADSTAR font uses y=5 as the starting point for capital letters, leaving space for the tails of letters such as "g", "p", "y", "q", etc.

The font height in CADSTAR corresponds to the full 24 point height. In KiCad it only corresponds to the height above the guide line, meaning the overall text height will be larger in KiCad.

Definition at line 129 of file cadstar_archive_parser.h.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), and CADSTAR_SCH_ARCHIVE_LOADER::getTextHeightFromTextCode().

◆ UNDEFINED_VALUE


The documentation for this class was generated from the following files: