KiCad PCB EDA Suite
CADSTAR_ARCHIVE_PARSER Class Reference

Helper functions and common structures for CADSTAR PCB and Schematic archive files. More...

#include <cadstar_archive_parser.h>

Inheritance diagram for CADSTAR_ARCHIVE_PARSER:
CADSTAR_PCB_ARCHIVE_PARSER CADSTAR_SCH_ARCHIVE_PARSER CADSTAR_PCB_ARCHIVE_LOADER CADSTAR_SCH_ARCHIVE_LOADER

Classes

struct  ATTRCOL
 
struct  ATTRCOLORS
 
struct  ATTRIBUTE_LOCATION
 
struct  ATTRIBUTE_VALUE
 
struct  ATTRNAME
 NOTE from CADSTAR help: To convert a Part Definition Attribute into a hyperlink, prefix the attribute name with "Link ". More...
 
struct  CADSTAR_NETCLASS
 
struct  CODEDEFS
 
struct  CUTOUT
 Represents a cutout in a closed shape (e.g. More...
 
struct  DFLTSETTINGS
 
struct  DOCUMENTATION_SYMBOL
 
struct  EVALUE
 Represents a floating value in E notation. More...
 
struct  FIGURE
 
struct  FONT
 
struct  FORMAT
 
struct  GRID
 
struct  GRIDS
 
struct  GROUP
 
struct  HATCH
 
struct  HATCHCODE
 
struct  HEADER
 
struct  LINECODE
 
struct  LONGPOINT
 
struct  NET
 
struct  PARSER
 
struct  PARSER_CONTEXT
 
struct  PART
 
struct  PARTNAMECOL
 
struct  PARTS
 
struct  POINT
 Represents a point in x,y coordinates. More...
 
struct  REUSEBLOCK
 
struct  REUSEBLOCKREF
 References an element from a design reuse block. More...
 
struct  ROUTECODE
 
struct  ROUTEREASSIGN
 
struct  SETTINGS
 
struct  SHAPE
 
struct  SPCCLASSNAME
 
struct  SYMDEF
 
struct  TEXT
 
struct  TEXT_LOCATION
 Corresponds to CADSTAR "origin". More...
 
struct  TEXTCODE
 
struct  TIMESTAMP
 
struct  VARIANT
 < Nodename = "VARIANT" or "VMASTER" (master variant More...
 
struct  VARIANT_HIERARCHY
 
struct  VERTEX
 Represents a vertex in a shape. More...
 

Public Types

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
 

Static Public Member Functions

static wxString ParseTextFields (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)
 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 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)
 

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 Attributes

PARSER_CONTEXT m_context
 

Detailed Description

Helper functions and common structures for CADSTAR PCB and Schematic archive files.

Definition at line 84 of file cadstar_archive_parser.h.

Member Typedef Documentation

◆ ATTRIBUTE_ID

Definition at line 95 of file cadstar_archive_parser.h.

◆ COLOR_ID

Definition at line 109 of file cadstar_archive_parser.h.

◆ DOCUMENTATION_SYMBOL_ID

◆ FIGURE_ID

Definition at line 103 of file cadstar_archive_parser.h.

◆ GATE_ID

Definition at line 98 of file cadstar_archive_parser.h.

◆ GROUP_ID

Definition at line 104 of file cadstar_archive_parser.h.

◆ HATCHCODE_ID

Definition at line 88 of file cadstar_archive_parser.h.

◆ LAYER_ID

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

Definition at line 93 of file cadstar_archive_parser.h.

◆ LINECODE_ID

Definition at line 87 of file cadstar_archive_parser.h.

◆ NET_ID

Definition at line 106 of file cadstar_archive_parser.h.

◆ NETCLASS_ID

Definition at line 90 of file cadstar_archive_parser.h.

◆ NETELEMENT_ID

Definition at line 107 of file cadstar_archive_parser.h.

◆ PART_DEFINITION_PIN_ID

Pin identifier in the part definition.

Definition at line 100 of file cadstar_archive_parser.h.

◆ PART_ID

Definition at line 97 of file cadstar_archive_parser.h.

◆ PART_PIN_ID

Pin identifier in the part.

Definition at line 101 of file cadstar_archive_parser.h.

◆ REUSEBLOCK_ID

Definition at line 105 of file cadstar_archive_parser.h.

◆ ROUTECODE_ID

Definition at line 89 of file cadstar_archive_parser.h.

◆ SPACING_CLASS_ID

Definition at line 91 of file cadstar_archive_parser.h.

◆ SYMDEF_ID

Definition at line 96 of file cadstar_archive_parser.h.

◆ TERMINAL_ID

Terminal is the pin identifier in the schematic.

Definition at line 99 of file cadstar_archive_parser.h.

◆ TEXT_ID

Definition at line 102 of file cadstar_archive_parser.h.

◆ TEXTCODE_ID

Definition at line 92 of file cadstar_archive_parser.h.

◆ VARIANT_ID

Definition at line 94 of file cadstar_archive_parser.h.

Member Enumeration Documentation

◆ ALIGNMENT

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 566 of file cadstar_archive_parser.h.

567  {
568  NO_ALIGNMENT,
569  TOPLEFT,
570  TOPCENTER,
571  TOPRIGHT,
572  CENTERLEFT,
573  CENTERCENTER,
574  CENTERRIGHT,
575  BOTTOMLEFT,
576  BOTTOMCENTER,
577  BOTTOMRIGHT
578  };

◆ ANGUNITS

Enumerator
DEGREES 
RADIANS 

Definition at line 476 of file cadstar_archive_parser.h.

477  {
478  DEGREES,
479  RADIANS
480  };

◆ ATTROWNER

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 620 of file cadstar_archive_parser.h.

621  {
622  ALL_ITEMS,
623  AREA,
624  BOARD,
625  COMPONENT,
626  CONNECTION,
627  COPPER,
628  DOCSYMBOL,
629  FIGURE,
630  NET,
631  NETCLASS,
632  PART,
633  PART_DEFINITION,
634  PIN,
635  SIGNALREF,
636  SYMBOL,
637  SYMDEF,
638  TEMPLATE,
639  TESTPOINT
640  };
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:190

◆ ATTRUSAGE

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 643 of file cadstar_archive_parser.h.

644  {
645  BOTH,
646  COMPONENT,
648  PART_DEFINITION,
649  PART_LIBRARY,
651  SYMBOL,
652  UNDEFINED
654  };
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84

◆ GRID_TYPE

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 486 of file cadstar_archive_parser.h.

487  {
488  FRACTIONALGRID,
489  STEPGRID
491  };

◆ 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 592 of file cadstar_archive_parser.h.

◆ LINESTYLE

Enumerator
SOLID 
DASH 
DASHDOT 
DASHDOTDOT 
DOT 

Definition at line 270 of file cadstar_archive_parser.h.

◆ 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 610 of file cadstar_archive_parser.h.

611  {
612  BOTTOM_TO_TOP,
613  TOP_TO_BOTTOM
614  };

◆ RESOLUTION

Enumerator
HUNDREDTH_MICRON 

Definition at line 232 of file cadstar_archive_parser.h.

233  {
234  HUNDREDTH_MICRON
235  };

◆ SHAPE_TYPE

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 440 of file cadstar_archive_parser.h.

441  {
442  OPENSHAPE,
443  OUTLINE,
444  SOLID,
445  HATCHED
446  };

◆ SWAP_RULE

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 800 of file cadstar_archive_parser.h.

801  {
802  NO_SWAP,
803  USE_SWAP_LAYER,
804  BOTH
805  };

◆ 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 Title@>"

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 130 of file cadstar_archive_parser.h.

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

◆ UNITS

Enumerator
DESIGN 

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

THOU 
INCH 
MICROMETRE 
MM 
CENTIMETER 
METER 

Definition at line 461 of file cadstar_archive_parser.h.

462  {
463  DESIGN,
464  THOU,
465  INCH,
466  MICROMETRE,
467  MM,
468  CENTIMETER,
469  METER
470  };
Definition: rs274x.cpp:62

◆ VERTEX_TYPE

Enumerator
POINT 
CLOCKWISE_ARC 
CLOCKWISE_SEMICIRCLE 
ANTICLOCKWISE_ARC 
ANTICLOCKWISE_SEMICIRCLE 

Definition at line 406 of file cadstar_archive_parser.h.

407  {
408  POINT,
409  CLOCKWISE_ARC,
410  CLOCKWISE_SEMICIRCLE,
411  ANTICLOCKWISE_ARC,
412  ANTICLOCKWISE_SEMICIRCLE
413  };

Member Function Documentation

◆ CheckNoChildNodes()

◆ CheckNoNextNodes()

void CADSTAR_ARCHIVE_PARSER::CheckNoNextNodes ( XNODE aNode)
static

◆ FixTextPositionNoAlignment()

void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment ( EDA_TEXT aKiCadTextItem)
static

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 2540 of file cadstar_archive_parser.cpp.

2541 {
2542  if( !aKiCadTextItem->GetText().IsEmpty() )
2543  {
2544  int txtAngleDecideg = aKiCadTextItem->GetTextAngleDegrees() * 10.0;
2545  wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
2546  RotatePoint( &positionOffset, txtAngleDecideg );
2547 
2548  EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
2549 
2550  if( textEdaItem &&
2551  ( textEdaItem->Type() == LIB_TEXT_T || textEdaItem->Type() == LIB_FIELD_T ) )
2552  {
2553  // Y coordinate increases upwards in the symbol editor
2554  positionOffset.y = -positionOffset.y;
2555  }
2556 
2557  //Count num of additional lines
2558  wxString text = aKiCadTextItem->GetText();
2559  int numExtraLines = text.Replace( "\n", "\n" );
2560  numExtraLines -= text.at( text.size() - 1 ) == '\n'; // Ignore new line character at end
2561  positionOffset.x *= numExtraLines;
2562  positionOffset.y *= numExtraLines;
2563 
2564  aKiCadTextItem->Offset( positionOffset );
2565  }
2566 }
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:259
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:223
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
double GetTextAngleDegrees() const
Definition: eda_text.h:183
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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 
)
inlinestatic

Definition at line 1378 of file cadstar_archive_parser.h.

1379  {
1380  return aRefName
1381  + ( ( aAlternateName.size() > 0 ) ? ( wxT( " (" ) + aAlternateName + wxT( ")" ) )
1382  : wxT( "" ) );
1383  }

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary().

◆ GetXmlAttributeIDLong()

long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong ( XNODE aNode,
unsigned int  aID,
bool  aIsRequired = true 
)
static
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 2412 of file cadstar_archive_parser.cpp.

2414 {
2415  long retVal;
2416  bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
2417 
2418  if( !success )
2419  {
2420  if( aIsRequired )
2421  THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
2422  else
2423  return UNDEFINED_VALUE;
2424  }
2425 
2426  return retVal;
2427 }
#define THROW_PARSING_IO_ERROR(param, location)
static const long UNDEFINED_VALUE
static wxString GetXmlAttributeIDString(XNODE *aNode, unsigned int aID, bool aIsRequired=true)

References GetXmlAttributeIDString(), THROW_PARSING_IO_ERROR, and 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_ARCHIVE_PARSER::FORMAT::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::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_ARCHIVE_PARSER::TEXTCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPCCLASSSPACE::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_ARCHIVE_PARSER::PART::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::COPPER_TERM::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 
)
static
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 2393 of file cadstar_archive_parser.cpp.

2395 {
2396  wxString attrName, retVal;
2397  attrName = "attr";
2398  attrName << aID;
2399 
2400  if( !aNode->GetAttribute( attrName, &retVal ) )
2401  {
2402  if( aIsRequired )
2403  THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
2404  else
2405  return wxEmptyString;
2406  }
2407 
2408  return retVal;
2409 }
#define THROW_MISSING_PARAMETER_IO_ERROR(param, location)

References THROW_MISSING_PARAMETER_IO_ERROR.

Referenced by CADSTAR_ARCHIVE_PARSER::PART::GetPinType(), 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_ARCHIVE_PARSER::FORMAT::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse(), CADSTAR_ARCHIVE_PARSER::TIMESTAMP::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SIGNALREFERENCELINK::Parse(), CADSTAR_ARCHIVE_PARSER::HEADER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::Parse(), CADSTAR_ARCHIVE_PARSER::VARIANT::Parse(), CADSTAR_ARCHIVE_PARSER::LINECODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADREASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SIGLOC::Parse(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::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_ARCHIVE_PARSER::TEXTCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::JUNCTION_SCH::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPCCLASSSPACE::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_ARCHIVE_PARSER::EVALUE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::RULESET::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::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_ARCHIVE_PARSER::GROUP::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::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(), ParseAlignment(), 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(), ParseJustification(), ParseReadability(), CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseSubNode(), CADSTAR_ARCHIVE_PARSER::NET::ParseSubNode(), ParseSwapRule(), CADSTAR_PCB_ARCHIVE_PARSER::ParseTestlandSide(), and ParseUnits().

◆ InsertAttributeAtEnd()

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

Definition at line 2284 of file cadstar_archive_parser.cpp.

2285 {
2286  wxString result;
2287  int numAttributes = 0;
2288 
2289  if( aNode->GetAttribute( wxT( "numAttributes" ), &result ) )
2290  {
2291  numAttributes = wxAtoi( result );
2292  aNode->DeleteAttribute( wxT( "numAttributes" ) );
2293  ++numAttributes;
2294  }
2295 
2296  aNode->AddAttribute( wxT( "numAttributes" ), wxString::Format( wxT( "%i" ), numAttributes ) );
2297 
2298  wxString paramName = wxT( "attr" );
2299  paramName << numAttributes;
2300 
2301  aNode->AddAttribute( paramName, aValue );
2302 }
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 LoadArchiveFile().

◆ IsValidAttribute()

◆ LoadArchiveFile()

XNODE * CADSTAR_ARCHIVE_PARSER::LoadArchiveFile ( const wxString &  aFileName,
const wxString &  aFileTypeIdentifier 
)
static

Reads a CADSTAR Archive file (S-parameter format)

Parameters
aFileName
aFileTypeIdentifierIdentifier of the first node in the file to check against. E.g. "CADSTARPCB"
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 2305 of file cadstar_archive_parser.cpp.

2307 {
2308  KEYWORD emptyKeywords[1] = {};
2309  XNODE * iNode = NULL, *cNode = NULL;
2310  int tok;
2311  bool cadstarFileCheckDone = false;
2312  wxString str;
2313  wxCSConv win1252( wxT( "windows-1252" ) );
2314  wxMBConv* conv = &win1252; // Initial testing suggests file encoding to be Windows-1252
2315  // More samples required.
2316  FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
2317 
2318  if( !fp )
2319  THROW_IO_ERROR( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
2320 
2321  DSNLEXER lexer( emptyKeywords, 0, fp, aFileName );
2322 
2323  while( ( tok = lexer.NextTok() ) != DSN_EOF )
2324  {
2325  if( tok == DSN_RIGHT )
2326  {
2327  cNode = iNode;
2328  if( cNode )
2329  {
2330  iNode = cNode->GetParent();
2331  }
2332  else
2333  {
2334  //too many closing brackets
2335  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2336  }
2337  }
2338  else if( tok == DSN_LEFT )
2339  {
2340  tok = lexer.NextTok();
2341  str = wxString( lexer.CurText(), *conv );
2342  cNode = new XNODE( wxXML_ELEMENT_NODE, str );
2343 
2344  if( iNode )
2345  {
2346  //we will add it as attribute as well as child node
2347  InsertAttributeAtEnd( iNode, str );
2348  iNode->AddChild( cNode );
2349  }
2350  else if( !cadstarFileCheckDone )
2351  {
2352  if( cNode->GetName() != aFileTypeIdentifier )
2353  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2354 
2355  cadstarFileCheckDone = true;
2356  }
2357 
2358  iNode = cNode;
2359  }
2360  else if( iNode )
2361  {
2362  str = wxString( lexer.CurText(), *conv );
2363  //Insert even if string is empty
2364  InsertAttributeAtEnd( iNode, str );
2365  }
2366  else
2367  {
2368  //not enough closing brackets
2369  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2370  }
2371  }
2372 
2373  // Not enough closing brackets
2374  if( iNode != NULL )
2375  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2376 
2377  // Throw if no data was parsed
2378  if( cNode )
2379  return cNode;
2380  else
2381  THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2382 
2383  return NULL;
2384 }
#define NULL
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)
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

References _, DSNLEXER::CurText(), DSN_EOF, DSN_LEFT, DSN_RIGHT, Format(), XNODE::GetParent(), InsertAttributeAtEnd(), DSNLEXER::NextTok(), NULL, and THROW_IO_ERROR.

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

◆ ParseAlignment()

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

Definition at line 935 of file cadstar_archive_parser.cpp.

936 {
937  wxASSERT( aNode->GetName() == wxT( "ALIGN" ) );
938 
939  wxString alignmentStr = GetXmlAttributeIDString( aNode, 0 );
940 
941  if( alignmentStr == wxT( "BOTTOMCENTER" ) )
943  else if( alignmentStr == wxT( "BOTTOMLEFT" ) )
944  return ALIGNMENT::BOTTOMLEFT;
945  else if( alignmentStr == wxT( "BOTTOMRIGHT" ) )
946  return ALIGNMENT::BOTTOMRIGHT;
947  else if( alignmentStr == wxT( "CENTERCENTER" ) )
949  else if( alignmentStr == wxT( "CENTERLEFT" ) )
950  return ALIGNMENT::CENTERLEFT;
951  else if( alignmentStr == wxT( "CENTERRIGHT" ) )
952  return ALIGNMENT::CENTERRIGHT;
953  else if( alignmentStr == wxT( "TOPCENTER" ) )
954  return ALIGNMENT::TOPCENTER;
955  else if( alignmentStr == wxT( "TOPLEFT" ) )
956  return ALIGNMENT::TOPLEFT;
957  else if( alignmentStr == wxT( "TOPRIGHT" ) )
958  return ALIGNMENT::TOPRIGHT;
959  else
960  THROW_UNKNOWN_PARAMETER_IO_ERROR( alignmentStr, wxT( "ALIGN" ) );
961 
962  //shouldn't be here but avoids compiler warning
964 }
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 BOTTOMCENTER, BOTTOMLEFT, BOTTOMRIGHT, CENTERCENTER, CENTERLEFT, CENTERRIGHT, GetXmlAttributeIDString(), NO_ALIGNMENT, THROW_UNKNOWN_PARAMETER_IO_ERROR, TOPCENTER, TOPLEFT, and 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 
)
static

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 2514 of file cadstar_archive_parser.cpp.

2516 {
2517  std::vector<CUTOUT> retVal;
2518 
2519  XNODE* cNode = aNode->GetChildren();
2520 
2521  for( ; cNode; cNode = cNode->GetNext() )
2522  {
2523  if( cNode->GetName() == wxT( "CUTOUT" ) )
2524  {
2525  CUTOUT cutout;
2526  //TODO try.. catch + throw again with more detailed error information
2527  cutout.Parse( cNode, aContext );
2528  retVal.push_back( cutout );
2529  }
2530  else if( aTestAllChildNodes )
2531  {
2532  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
2533  }
2534  }
2535 
2536  return retVal;
2537 }
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 
)
static

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 2454 of file cadstar_archive_parser.cpp.

2456 {
2457  std::vector<POINT> retVal;
2458 
2459  XNODE* cNode = aNode->GetChildren();
2460 
2461  for( ; cNode; cNode = cNode->GetNext() )
2462  {
2463  if( cNode->GetName() == wxT( "PT" ) )
2464  {
2465  POINT pt;
2466  //TODO try.. catch + throw again with more detailed error information
2467  pt.Parse( cNode, aContext );
2468  retVal.push_back( pt );
2469  }
2470  else if( aTestAllChildNodes )
2471  {
2472  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
2473  }
2474  }
2475 
2476  if( aExpectedNumPoints != UNDEFINED_VALUE
2477  && retVal.size() != static_cast<size_t>( aExpectedNumPoints ) )
2478  {
2480  _( "Unexpected number of points in '%s'. Found %d but expected %d." ),
2481  aNode->GetName(), retVal.size(), aExpectedNumPoints ) );
2482  }
2483 
2484  return retVal;
2485 }
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 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 
)
static

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 2488 of file cadstar_archive_parser.cpp.

2490 {
2491  std::vector<VERTEX> retVal;
2492 
2493  XNODE* cNode = aNode->GetChildren();
2494 
2495  for( ; cNode; cNode = cNode->GetNext() )
2496  {
2497  if( VERTEX::IsVertex( cNode ) )
2498  {
2499  VERTEX vertex;
2500  //TODO try.. catch + throw again with more detailed error information
2501  vertex.Parse( cNode, aContext );
2502  retVal.push_back( vertex );
2503  }
2504  else if( aTestAllChildNodes )
2505  {
2506  THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
2507  }
2508  }
2509 
2510  return retVal;
2511 }
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)
static

Definition at line 574 of file cadstar_archive_parser.cpp.

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

References DEGREES, GetXmlAttributeIDString(), 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 
)
static
Parameters
aNodewith a child node containing an EVALUE
aValueToParse
Exceptions
IO_ERRORif unable to parse or node is not an EVALUE

Definition at line 2444 of file cadstar_archive_parser.cpp.

2446 {
2447  if( aNode->GetChildren()->GetName() == wxT( "E" ) )
2448  aValueToParse.Parse( aNode->GetChildren(), aContext );
2449  else
2450  THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
2451 }
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)
static

Definition at line 967 of file cadstar_archive_parser.cpp.

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

References CENTER, GetXmlAttributeIDString(), LEFT, 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)
static

Definition at line 986 of file cadstar_archive_parser.cpp.

987 {
988  wxASSERT( aNode->GetName() == wxT( "READABILITY" ) );
989 
990  wxString readabilityStr = GetXmlAttributeIDString( aNode, 0 );
991 
992  if( readabilityStr == wxT( "BOTTOM_TO_TOP" ) )
994  else if( readabilityStr == wxT( "TOP_TO_BOTTOM" ) )
996  else
997  THROW_UNKNOWN_PARAMETER_IO_ERROR( readabilityStr, wxT( "READABILITY" ) );
998 
1000 }
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 BOTTOM_TO_TOP, GetXmlAttributeIDString(), THROW_UNKNOWN_PARAMETER_IO_ERROR, and 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)
static

Definition at line 1396 of file cadstar_archive_parser.cpp.

1397 {
1398  wxASSERT( aNode->GetName() == wxT( "SWAPRULE" ) );
1399 
1400  SWAP_RULE retval;
1401  wxString swapRuleStr = GetXmlAttributeIDString( aNode, 0 );
1402 
1403  if( swapRuleStr == wxT( "NO_SWAP" ) )
1404  retval = SWAP_RULE::NO_SWAP;
1405  else if( swapRuleStr == wxT( "USE_SWAP_LAYER" ) )
1406  retval = SWAP_RULE::USE_SWAP_LAYER;
1407  else
1408  THROW_UNKNOWN_PARAMETER_IO_ERROR( swapRuleStr, wxT( "SWAPRULE" ) );
1409 
1410  return retval;
1411 }
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 GetXmlAttributeIDString(), NO_SWAP, THROW_UNKNOWN_PARAMETER_IO_ERROR, and 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().

◆ ParseTextFields()

wxString CADSTAR_ARCHIVE_PARSER::ParseTextFields ( wxString  aTextString,
PARSER_CONTEXT aParserContext 
)
static

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 741 of file cadstar_archive_parser.cpp.

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

References CADSTAR_TO_KICAD_FIELDS, COMPANY_NAME, CURRENT_USER, DATE, DESIGN_TITLE, DISTANCE, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::FilenamesToTextMap, Format(), FROM_FILE, HYPERLINK, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::InconsistentTextFields, KI_FALLTHROUGH, LONG_JOBNAME, MACHINE_NAME, NONE, NUM_OF_SHEETS, REG_USER, SHEET_NAME, SHEET_NUMBER, SHORT_JOBNAME, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::TextFieldToValuesMap, CADSTAR_ARCHIVE_PARSER::PARSER_CONTEXT::TextToHyperlinksMap, TIME, UNITS_ABBREV, UNITS_FULL, UNITS_SHORT, VARIANT_DESCRIPTION, and 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)
static

Definition at line 547 of file cadstar_archive_parser.cpp.

548 {
549  wxASSERT( aNode->GetName() == wxT( "UNITS" ) );
550 
551  wxString unit = GetXmlAttributeIDString( aNode, 0 );
552 
553  if( unit == wxT( "CENTIMETER" ) )
554  return UNITS::CENTIMETER;
555  else if( unit == wxT( "INCH" ) )
556  return UNITS::INCH;
557  else if( unit == wxT( "METER" ) )
558  return UNITS::METER;
559  else if( unit == wxT( "MICROMETRE" ) )
560  return UNITS::MICROMETRE;
561  else if( unit == wxT( "MM" ) )
562  return UNITS::MM;
563  else if( unit == wxT( "THOU" ) )
564  return UNITS::THOU;
565  else if( unit == wxT( "DESIGN" ) )
566  return UNITS::DESIGN;
567  else
568  THROW_UNKNOWN_PARAMETER_IO_ERROR( unit, wxT( "UNITS" ) );
569 
570  return UNITS();
571 }
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 CENTIMETER, DESIGN, GetXmlAttributeIDString(), INCH, METER, MICROMETRE, MM, THOU, and THROW_UNKNOWN_PARAMETER_IO_ERROR.

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

Member Data Documentation

◆ CADSTAR_TO_KICAD_FIELDS

const std::map< CADSTAR_ARCHIVE_PARSER::TEXT_FIELD_NAME, wxString > CADSTAR_ARCHIVE_PARSER::CADSTAR_TO_KICAD_FIELDS
static
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 159 of file cadstar_archive_parser.h.

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

◆ FONT_BOLD

const long CADSTAR_ARCHIVE_PARSER::FONT_BOLD = 700
static

◆ FONT_NORMAL

const long CADSTAR_ARCHIVE_PARSER::FONT_NORMAL = 400
static

Definition at line 311 of file cadstar_archive_parser.h.

◆ m_context

◆ TXT_HEIGHT_RATIO

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

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 124 of file cadstar_archive_parser.h.

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

◆ UNDEFINED_VALUE


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