KiCad PCB EDA Suite
CADSTAR_PCB_ARCHIVE_LOADER Class Reference

#include <cadstar_pcb_archive_loader.h>

Inheritance diagram for CADSTAR_PCB_ARCHIVE_LOADER:
CADSTAR_PCB_ARCHIVE_PARSER CADSTAR_ARCHIVE_PARSER

Public Types

enum class  MATERIAL_LAYER_TYPE { CONSTRUCTION , ELECTRICAL , NON_ELECTRICAL }
 Type of layer appropriate for the material being set up. More...
 
enum class  LAYER_TYPE {
  UNDEFINED , ALLLAYER , ALLELEC , ALLDOC ,
  NOLAYER , ASSCOMPCOPP , JUMPERLAYER , ELEC ,
  POWER , NONELEC , CONSTRUCTION , DOC
}
 
enum class  LAYER_SUBTYPE {
  LAYERSUBTYPE_NONE , LAYERSUBTYPE_SILKSCREEN , LAYERSUBTYPE_PLACEMENT , LAYERSUBTYPE_ASSEMBLY ,
  LAYERSUBTYPE_SOLDERRESIST , LAYERSUBTYPE_PASTE , LAYERSUBTYPE_CLEARANCE , LAYERSUBTYPE_ROUT
}
 
enum class  ROUTING_BIAS {
  UNBIASED , X , Y , ANTI_ROUTE ,
  OBSTACLE
}
 
enum class  EMBEDDING { NONE , ABOVE , BELOW }
 
enum class  PAD_SHAPE_TYPE {
  ANNULUS , BULLET , CIRCLE , DIAMOND ,
  FINGER , OCTAGON , RECTANGLE , ROUNDED_RECT ,
  SQUARE
}
 
enum class  PAD_SIDE { MINIMUM , MAXIMUM , THROUGH_HOLE }
 From CADSTAR Help: "This parameter indicates the physical layers on which the selected pad is placed. More...
 
enum class  SYMDEF_TYPE { COMPONENT , JUMPER , STARPOINT , TESTPOINT }
 A symbol definition can represent a number of different objects in CADSTAR. More...
 
enum class  TESTLAND_SIDE { NONE , MAX , MIN , BOTH }
 
enum class  NETSYNCH { UNDEFINED , WARNING , 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 class  TEXT_FIELD_NAME {
  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
}
 These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NAME][FIELD_VALUE]>. More...
 
enum class  RESOLUTION { HUNDREDTH_MICRON }
 
enum class  LINESTYLE {
  SOLID , DASH , DASHDOT , DASHDOTDOT ,
  DOT
}
 
enum class  VERTEX_TYPE {
  POINT , CLOCKWISE_ARC , CLOCKWISE_SEMICIRCLE , ANTICLOCKWISE_ARC ,
  ANTICLOCKWISE_SEMICIRCLE
}
 
enum class  SHAPE_TYPE { OPENSHAPE , OUTLINE , SOLID , HATCHED }
 
enum class  UNITS {
  DESIGN , THOU , INCH , MICROMETRE ,
  MM , CENTIMETER , METER
}
 
enum class  ANGUNITS { DEGREES , RADIANS }
 
enum class  GRID_TYPE { FRACTIONALGRID , STEPGRID }
 
enum class  ALIGNMENT {
  NO_ALIGNMENT , TOPLEFT , TOPCENTER , TOPRIGHT ,
  CENTERLEFT , CENTERCENTER , CENTERRIGHT , BOTTOMLEFT ,
  BOTTOMCENTER , BOTTOMRIGHT
}
 From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all text items in CADSTAR. More...
 
enum class  JUSTIFICATION { LEFT , CENTER , RIGHT }
 From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right. More...
 
enum class  READABILITY { BOTTOM_TO_TOP , TOP_TO_BOTTOM }
 Sets the readability direction of text. More...
 
enum class  ATTROWNER {
  ALL_ITEMS , AREA , BOARD , COMPONENT ,
  CONNECTION , COPPER , DOCSYMBOL , FIGURE ,
  NET , NETCLASS , PART , PART_DEFINITION ,
  PIN , SIGNALREF , SYMBOL , SYMDEF ,
  TEMPLATE , TESTPOINT
}
 
enum class  ATTRUSAGE {
  BOTH , COMPONENT , PART_DEFINITION , PART_LIBRARY ,
  SYMBOL , UNDEFINED
}
 
enum class  SWAP_RULE { NO_SWAP , USE_SWAP_LAYER , 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_LOADER (wxString aFilename, LAYER_MAPPING_HANDLER aLayerMappingHandler, bool aLogLayerWarnings, PROGRESS_REPORTER *aProgressReporter)
 
 ~CADSTAR_PCB_ARCHIVE_LOADER ()
 
void Load (BOARD *aBoard, PROJECT *aProject)
 Loads a CADSTAR PCB Archive file into the KiCad BOARD object given. More...
 
std::vector< FOOTPRINT * > GetLoadedLibraryFootpints () const
 Return a copy of the loaded library footprints (caller owns the objects) More...
 
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
 

Private Types

using ASSOCIATED_COPPER_PADS = std::map< PAD_ID, std::vector< PAD_ID > >
 Map of pad anchor points (first) to copper pads (second). More...
 

Private Member Functions

void loadBoardStackup ()
 
void remapUnsureLayers ()
 Callback m_layerMappingHandler for layers we aren't sure of. More...
 
void loadDesignRules ()
 
void loadComponentLibrary ()
 
void loadGroups ()
 
void loadBoards ()
 
void loadFigures ()
 
void loadTexts ()
 
void loadDimensions ()
 
void loadAreas ()
 
void loadComponents ()
 
void loadDocumentationSymbols ()
 
void loadTemplates ()
 
void loadCoppers ()
 
void loadNets ()
 
void loadTextVariables ()
 
void logBoardStackupWarning (const wxString &aCadstarLayerName, const PCB_LAYER_ID &aKiCadLayer)
 
void logBoardStackupMessage (const wxString &aCadstarLayerName, const PCB_LAYER_ID &aKiCadLayer)
 
void initStackupItem (const LAYER &aCadstarLayer, BOARD_STACKUP_ITEM *aKiCadItem, int aDielectricSublayer)
 
void loadLibraryFigures (const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
 
void loadLibraryCoppers (const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
 
void loadLibraryAreas (const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
 
void loadLibraryPads (const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
 
void loadComponentAttributes (const COMPONENT &aComponent, FOOTPRINT *aFootprint)
 
void loadNetTracks (const NET_ID &aCadstarNetID, const NET_PCB::ROUTE &aCadstarRoute, long aStartWidth=std::numeric_limits< long >::max(), long aEndWidth=std::numeric_limits< long >::max())
 
int loadNetVia (const NET_ID &aCadstarNetID, const NET_PCB::VIA &aCadstarVia)
 Load via and return via size. More...
 
void checkAndLogHatchCode (const HATCHCODE_ID &aCadstarHatchcodeID)
 
void applyDimensionSettings (const DIMENSION &aCadstarDim, PCB_DIMENSION_BASE *aKiCadDim)
 
bool calculateZonePriorities (PCB_LAYER_ID &aLayer)
 Tries to make a best guess as to the zone priorities based on the pour status. More...
 
void drawCadstarText (const TEXT &aCadstarText, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const LAYER_ID &aCadstarLayerOverride=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 
void drawCadstarShape (const SHAPE &aCadstarShape, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, const wxString &aShapeName, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 
void drawCadstarCutoutsAsShapes (const std::vector< CUTOUT > &aCutouts, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 Uses PCB_SHAPEs to draw the cutouts on m_board object. More...
 
void drawCadstarVerticesAsShapes (const std::vector< VERTEX > &aCadstarVertices, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 Uses PCB_SHAPE to draw the vertices on m_board object. More...
 
std::vector< PCB_SHAPE * > getShapesFromVertices (const std::vector< VERTEX > &aCadstarVertices, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 Returns a vector of pointers to PCB_SHAPE objects. More...
 
PCB_SHAPEgetShapeFromVertex (const POINT &aCadstarStartPoint, const VERTEX &aCadstarVertex, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 Returns a pointer to a PCB_SHAPE object. More...
 
ZONEgetZoneFromCadstarShape (const SHAPE &aCadstarShape, const int &aLineThickness, BOARD_ITEM_CONTAINER *aParentContainer)
 
SHAPE_POLY_SET getPolySetFromCadstarShape (const SHAPE &aCadstarShape, const int &aLineThickness=-1, BOARD_ITEM_CONTAINER *aContainer=nullptr, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
 Returns a SHAPE_POLY_SET object from a Cadstar SHAPE. More...
 
SHAPE_LINE_CHAIN getLineChainFromShapes (const std::vector< PCB_SHAPE * > aShapes)
 Returns a SHAPE_LINE_CHAIN object from a series of PCB_SHAPE objects. More...
 
std::vector< PCB_TRACK * > makeTracksFromShapes (const std::vector< PCB_SHAPE * > aShapes, BOARD_ITEM_CONTAINER *aParentContainer, NETINFO_ITEM *aNet=nullptr, PCB_LAYER_ID aLayerOverride=UNDEFINED_LAYER, int aWidthOverride=-1)
 Returns a vector of pointers to TRACK/ARC objects. More...
 
void addAttribute (const ATTRIBUTE_LOCATION &aCadstarAttrLoc, const ATTRIBUTE_ID &aCadstarAttributeID, FOOTPRINT *aFootprint, const wxString &aAttributeValue)
 Adds a CADSTAR Attribute to a KiCad footprint. More...
 
void applyRouteOffset (VECTOR2I *aPointToOffset, const VECTOR2I &aRefPoint, const long &aOffsetAmount)
 CADSTAR's Post Processor does an action called "Route Offset" which is applied when a route is wider than the pad on which it is terminating or when there are different widths of route, in order to reduce overlap. More...
 
int getLineThickness (const LINECODE_ID &aCadstarLineCodeID)
 
COPPERCODE getCopperCode (const COPPERCODE_ID &aCadstaCopperCodeID)
 
HATCHCODE getHatchCode (const HATCHCODE_ID &aCadstarHatchcodeID)
 
LAYERPAIR getLayerPair (const LAYERPAIR_ID &aCadstarLayerPairID)
 
PADCODE getPadCode (const PADCODE_ID &aCadstarPadCodeID)
 
PART getPart (const PART_ID &aCadstarPartID)
 
ROUTECODE getRouteCode (const ROUTECODE_ID &aCadstarRouteCodeID)
 
TEXTCODE getTextCode (const TEXTCODE_ID &aCadstarTextCodeID)
 
VIACODE getViaCode (const VIACODE_ID &aCadstarViaCodeID)
 
wxString getAttributeName (const ATTRIBUTE_ID &aCadstarAttributeID)
 
wxString getAttributeValue (const ATTRIBUTE_ID &aCadstarAttributeID, const std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > &aCadstarAttributeMap)
 
LAYER_TYPE getLayerType (const LAYER_ID aCadstarLayerID)
 
EDA_ANGLE getHatchCodeAngle (const HATCHCODE_ID &aCadstarHatchcodeID)
 
PADgetKiCadPad (const COMPONENT_PAD &aCadstarPad, FOOTPRINT *aParent)
 
PAD *& getPadReference (FOOTPRINT *aFootprint, const PAD_ID aCadstarPadID)
 
FOOTPRINTgetFootprintFromCadstarID (const COMPONENT_ID &aCadstarComponentID)
 
int getKiCadHatchCodeThickness (const HATCHCODE_ID &aCadstarHatchcodeID)
 
int getKiCadHatchCodeGap (const HATCHCODE_ID &aCadstarHatchcodeID)
 
PCB_GROUPgetKiCadGroup (const GROUP_ID &aCadstarGroupID)
 
VECTOR2I getKiCadPoint (const VECTOR2I &aCadstarPoint)
 Scales, offsets and inverts y axis to make the point usable directly in KiCad. More...
 
int getKiCadLength (long long aCadstarLength)
 
double getAngleTenthDegree (const long long &aCadstarAngle)
 
EDA_ANGLE getAngle (const long long &aCadstarAngle)
 
double getAngleDegrees (const long long &aCadstarAngle)
 
NETINFO_ITEMgetKiCadNet (const NET_ID &aCadstarNetID)
 Searches m_netMap and returns the NETINFO_ITEM pointer if exists. More...
 
PCB_LAYER_ID getKiCadCopperLayerID (unsigned int aLayerNum, bool aDetectMaxLayer=true)
 
bool isLayerSet (const LAYER_ID &aCadstarLayerID)
 
PCB_LAYER_ID getKiCadLayer (const LAYER_ID &aCadstarLayerID)
 
LSET getKiCadLayerSet (const LAYER_ID &aCadstarLayerID)
 
bool isFootprint (BOARD_ITEM_CONTAINER *aContainer)
 
void addToGroup (const GROUP_ID &aCadstarGroupID, BOARD_ITEM *aKiCadItem)
 
GROUP_ID createUniqueGroupID (const wxString &aName)
 Adds a new PCB_GROUP* to m_groupMap. More...
 

Private Attributes

LAYER_MAPPING_HANDLER m_layerMappingHandler
 Callback to get layer mapping. More...
 
bool m_logLayerWarnings
 Used in loadBoardStackup() More...
 
BOARDm_board
 
PROJECTm_project
 
std::map< LAYER_ID, PCB_LAYER_IDm_layermap
 Map between Cadstar and KiCad Layers. More...
 
std::map< SYMDEF_ID, FOOTPRINT * > m_libraryMap
 Map between Cadstar and KiCad components in the library. More...
 
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
 Map between Cadstar and KiCad groups. More...
 
std::map< COMPONENT_ID, FOOTPRINT * > m_componentMap
 Map between Cadstar and KiCad components on the board. More...
 
std::map< SYMDEF_ID, ASSOCIATED_COPPER_PADSm_librarycopperpads
 Associated copper pads (if any) for each component library definition. More...
 
std::map< NET_ID, NETINFO_ITEM * > m_netMap
 Map between Cadstar and KiCad Nets. More...
 
std::map< std::tuple< ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID >, std::shared_ptr< NETCLASS > > m_netClassMap
 Map between Cadstar and KiCad classes. More...
 
std::map< TEMPLATE_ID, ZONE * > m_zonesMap
 Map between Cadstar and KiCad zones. More...
 
std::vector< LAYER_IDm_powerPlaneLayers
 List of layers that are marked as power plane in CADSTAR. More...
 
VECTOR2I m_designCenter
 Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canvas. More...
 
std::set< HATCHCODE_IDm_hatchcodesTested
 Used by checkAndLogHatchCode() to avoid multiple duplicate warnings. More...
 
std::set< PADCODE_IDm_padcodesTested
 Used by getKiCadPad() to avoid multiple duplicate warnings. More...
 
bool m_doneCopperWarning
 Used by loadCoppers() to avoid multiple duplicate warnings. More...
 
bool m_doneSpacingClassWarning
 Used by getKiCadNet() to avoid multiple duplicate warnings. More...
 
bool m_doneNetClassWarning
 Used by getKiCadNet() to avoid multiple duplicate warnings. More...
 
bool m_doneTearDropWarning
 
int m_numNets
 Number of nets loaded so far. More...
 
int m_numCopperLayers
 Number of layers in the design. More...
 

Detailed Description

Definition at line 39 of file cadstar_pcb_archive_loader.h.

Member Typedef Documentation

◆ AREA_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::AREA_ID
inherited

Definition at line 70 of file cadstar_pcb_archive_parser.h.

◆ ASSOCIATED_COPPER_PADS

using CADSTAR_PCB_ARCHIVE_LOADER::ASSOCIATED_COPPER_PADS = std::map<PAD_ID, std::vector<PAD_ID> >
private

Map of pad anchor points (first) to copper pads (second).

In the vast majority of designs there is only one copper pad, but just in case, making it a vector

Definition at line 111 of file cadstar_pcb_archive_loader.h.

◆ ATTRIBUTE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_ID
inherited

Definition at line 104 of file cadstar_archive_parser.h.

◆ BOARD_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::BOARD_ID
inherited

Definition at line 69 of file cadstar_pcb_archive_parser.h.

◆ COLOR_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::COLOR_ID
inherited

Definition at line 118 of file cadstar_archive_parser.h.

◆ COMP_AREA_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::COMP_AREA_ID
inherited

Definition at line 66 of file cadstar_pcb_archive_parser.h.

◆ COMPONENT_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_ID
inherited

Definition at line 71 of file cadstar_pcb_archive_parser.h.

◆ COPPER_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::COPPER_ID
inherited

Definition at line 74 of file cadstar_pcb_archive_parser.h.

◆ COPPER_TERM_ID

Definition at line 73 of file cadstar_pcb_archive_parser.h.

◆ COPPERCODE_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::COPPERCODE_ID
inherited

Definition at line 60 of file cadstar_pcb_archive_parser.h.

◆ DIMENSION_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION_ID
inherited

Definition at line 68 of file cadstar_pcb_archive_parser.h.

◆ DOCUMENTATION_SYMBOL_ID

Definition at line 117 of file cadstar_archive_parser.h.

◆ DRILL_TABLE_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::DRILL_TABLE_ID
inherited

Definition at line 75 of file cadstar_pcb_archive_parser.h.

◆ FIGURE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::FIGURE_ID
inherited

Definition at line 112 of file cadstar_archive_parser.h.

◆ GATE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::GATE_ID
inherited

Definition at line 107 of file cadstar_archive_parser.h.

◆ GROUP_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::GROUP_ID
inherited

Definition at line 113 of file cadstar_archive_parser.h.

◆ HATCHCODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::HATCHCODE_ID
inherited

Definition at line 97 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 102 of file cadstar_archive_parser.h.

◆ LAYERPAIR_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR_ID
inherited

Definition at line 64 of file cadstar_pcb_archive_parser.h.

◆ LINECODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::LINECODE_ID
inherited

Definition at line 96 of file cadstar_archive_parser.h.

◆ MATERIAL_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL_ID
inherited

Definition at line 58 of file cadstar_pcb_archive_parser.h.

◆ NET_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NET_ID
inherited

Definition at line 115 of file cadstar_archive_parser.h.

◆ NETCLASS_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NETCLASS_ID
inherited

Definition at line 99 of file cadstar_archive_parser.h.

◆ NETELEMENT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NETELEMENT_ID
inherited

Definition at line 116 of file cadstar_archive_parser.h.

◆ PAD_ID

typedef long CADSTAR_PCB_ARCHIVE_PARSER::PAD_ID
inherited

Pad identifier (pin) in the PCB.

Definition at line 67 of file cadstar_pcb_archive_parser.h.

◆ PADCODE_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::PADCODE_ID
inherited

Definition at line 61 of file cadstar_pcb_archive_parser.h.

◆ PART_DEFINITION_PIN_ID

Pin identifier in the part definition.

Definition at line 109 of file cadstar_archive_parser.h.

◆ PART_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::PART_ID
inherited

Definition at line 106 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 110 of file cadstar_archive_parser.h.

◆ PHYSICAL_LAYER_ID

Definition at line 59 of file cadstar_pcb_archive_parser.h.

◆ REUSEBLOCK_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::REUSEBLOCK_ID
inherited

Definition at line 114 of file cadstar_archive_parser.h.

◆ ROUTECODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::ROUTECODE_ID
inherited

Definition at line 98 of file cadstar_archive_parser.h.

◆ RULESET_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::RULESET_ID
inherited

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

◆ SPACINGCODE_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE_ID
inherited

Definition at line 63 of file cadstar_pcb_archive_parser.h.

◆ SYMDEF_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::SYMDEF_ID
inherited

Definition at line 105 of file cadstar_archive_parser.h.

◆ TEMPLATE_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE_ID
inherited

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

◆ TEXT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::TEXT_ID
inherited

Definition at line 111 of file cadstar_archive_parser.h.

◆ TEXTCODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::TEXTCODE_ID
inherited

Definition at line 101 of file cadstar_archive_parser.h.

◆ TRUNK_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::TRUNK_ID
inherited

Definition at line 76 of file cadstar_pcb_archive_parser.h.

◆ VARIANT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::VARIANT_ID
inherited

Definition at line 103 of file cadstar_archive_parser.h.

◆ VIACODE_ID

typedef wxString CADSTAR_PCB_ARCHIVE_PARSER::VIACODE_ID
inherited

Definition at line 62 of file cadstar_pcb_archive_parser.h.

Member Enumeration Documentation

◆ ALIGNMENT

enum class 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 601 of file cadstar_archive_parser.h.

602 {
603 NO_ALIGNMENT,
604 TOPLEFT,
605 TOPCENTER,
606 TOPRIGHT,
607 CENTERLEFT,
608 CENTERCENTER,
609 CENTERRIGHT,
610 BOTTOMLEFT,
611 BOTTOMCENTER,
612 BOTTOMRIGHT
613 };

◆ ANGUNITS

enum class CADSTAR_ARCHIVE_PARSER::ANGUNITS
stronginherited
Enumerator
DEGREES 
RADIANS 

Definition at line 511 of file cadstar_archive_parser.h.

512 {
513 DEGREES,
514 RADIANS
515 };

◆ ATTROWNER

enum class 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 655 of file cadstar_archive_parser.h.

656 {
657 ALL_ITEMS,
658 AREA,
659 BOARD,
660 COMPONENT,
661 CONNECTION,
662 COPPER,
663 DOCSYMBOL,
664 FIGURE,
665 NET,
666 NETCLASS,
667 PART,
668 PART_DEFINITION,
669 PIN,
670 SIGNALREF,
671 SYMBOL,
672 SYMDEF,
673 TEMPLATE,
675 };
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:85
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:47
@ TESTPOINT
a test point pad
@ NET
This item represents a net.

◆ ATTRUSAGE

enum class 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 678 of file cadstar_archive_parser.h.

679 {
680 BOTH,
682 COMPONENT,
683 PART_DEFINITION,
685 PART_LIBRARY,
686 SYMBOL,
688 UNDEFINED
691 };

◆ EMBEDDING

enum class CADSTAR_PCB_ARCHIVE_PARSER::EMBEDDING
stronginherited
Enumerator
NONE 
ABOVE 
BELOW 

Definition at line 142 of file cadstar_pcb_archive_parser.h.

143 {
144 NONE,
145 ABOVE,
146 BELOW
147 };
@ NONE
Definition: kibis.h:53

◆ GRID_TYPE

enum class 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 521 of file cadstar_archive_parser.h.

522 {
523 FRACTIONALGRID,
525 STEPGRID
526 };

◆ JUSTIFICATION

enum class CADSTAR_ARCHIVE_PARSER::JUSTIFICATION
stronginherited

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

◆ LAYER_SUBTYPE

enum class CADSTAR_PCB_ARCHIVE_PARSER::LAYER_SUBTYPE
stronginherited
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

enum class CADSTAR_PCB_ARCHIVE_PARSER::LAYER_TYPE
stronginherited
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 class CADSTAR_ARCHIVE_PARSER::LINESTYLE
stronginherited
Enumerator
SOLID 
DASH 
DASHDOT 
DASHDOTDOT 
DOT 

Definition at line 284 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

enum class CADSTAR_PCB_ARCHIVE_PARSER::NETSYNCH
stronginherited
Enumerator
UNDEFINED 
WARNING 
FULL 

Definition at line 1157 of file cadstar_pcb_archive_parser.h.

1158 {
1159 UNDEFINED,
1160 WARNING,
1161 FULL
1162 };

◆ PAD_SHAPE_TYPE

enum class CADSTAR_PCB_ARCHIVE_PARSER::PAD_SHAPE_TYPE
stronginherited
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:33

◆ PAD_SIDE

enum class CADSTAR_PCB_ARCHIVE_PARSER::PAD_SIDE
stronginherited

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,
484 MAXIMUM,
486 THROUGH_HOLE
487 };

◆ READABILITY

enum class CADSTAR_ARCHIVE_PARSER::READABILITY
stronginherited

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

646 {
647 BOTTOM_TO_TOP,
648 TOP_TO_BOTTOM
649 };

◆ RESOLUTION

enum class CADSTAR_ARCHIVE_PARSER::RESOLUTION
stronginherited
Enumerator
HUNDREDTH_MICRON 

Definition at line 246 of file cadstar_archive_parser.h.

247 {
248 HUNDREDTH_MICRON
249 };

◆ ROUTING_BIAS

enum class CADSTAR_PCB_ARCHIVE_PARSER::ROUTING_BIAS
stronginherited
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 };
#define X()

◆ SHAPE_TYPE

enum class 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 467 of file cadstar_archive_parser.h.

468 {
469 OPENSHAPE,
470 OUTLINE,
471 SOLID,
472 HATCHED
473 };

◆ SWAP_RULE

enum class 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 835 of file cadstar_archive_parser.h.

836 {
837 NO_SWAP,
838 USE_SWAP_LAYER,
839 BOTH
840 };

◆ SYMDEF_TYPE

enum class CADSTAR_PCB_ARCHIVE_PARSER::SYMDEF_TYPE
stronginherited

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,
745 STARPOINT,
763 TESTPOINT
771 };

◆ TESTLAND_SIDE

enum class CADSTAR_PCB_ARCHIVE_PARSER::TESTLAND_SIDE
stronginherited
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 };
@ MIN
Definition: ibis_parser.h:97
@ MAX
Definition: ibis_parser.h:98

◆ TEXT_FIELD_NAME

enum class CADSTAR_ARCHIVE_PARSER::TEXT_FIELD_NAME
stronginherited

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

140 {
141 DESIGN_TITLE,
142 SHORT_JOBNAME,
143 LONG_JOBNAME,
144 NUM_OF_SHEETS,
145 SHEET_NUMBER,
147 VARIANT_NAME,
148 VARIANT_DESCRIPTION,
149 REG_USER,
150 COMPANY_NAME,
151 CURRENT_USER,
152 DATE,
153 TIME,
154 MACHINE_NAME,
155 FROM_FILE,
156 DISTANCE,
157 UNITS_SHORT,
158 UNITS_ABBREV,
159 UNITS_FULL,
160 HYPERLINK,
161 NONE
162 };

◆ UNITS

enum class CADSTAR_ARCHIVE_PARSER::UNITS
stronginherited
Enumerator
DESIGN 

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

THOU 
INCH 
MICROMETRE 
MM 
CENTIMETER 
METER 

Definition at line 496 of file cadstar_archive_parser.h.

497 {
498 DESIGN,
499 THOU,
500 INCH,
501 MICROMETRE,
502 MM,
504 METER
505 };
@ INCH
Definition: rs274x.cpp:64

◆ VERTEX_TYPE

enum class CADSTAR_ARCHIVE_PARSER::VERTEX_TYPE
stronginherited
Enumerator
POINT 
CLOCKWISE_ARC 
CLOCKWISE_SEMICIRCLE 
ANTICLOCKWISE_ARC 
ANTICLOCKWISE_SEMICIRCLE 

Definition at line 425 of file cadstar_archive_parser.h.

426 {
427 POINT,
428 CLOCKWISE_ARC,
429 CLOCKWISE_SEMICIRCLE,
430 ANTICLOCKWISE_ARC,
431 ANTICLOCKWISE_SEMICIRCLE
432 };

Constructor & Destructor Documentation

◆ CADSTAR_PCB_ARCHIVE_LOADER()

CADSTAR_PCB_ARCHIVE_LOADER::CADSTAR_PCB_ARCHIVE_LOADER ( wxString  aFilename,
LAYER_MAPPING_HANDLER  aLayerMappingHandler,
bool  aLogLayerWarnings,
PROGRESS_REPORTER aProgressReporter 
)
inlineexplicit

Definition at line 42 of file cadstar_pcb_archive_loader.h.

46 : CADSTAR_PCB_ARCHIVE_PARSER( aFilename )
47 {
48 m_layerMappingHandler = aLayerMappingHandler;
49 m_logLayerWarnings = aLogLayerWarnings;
50 m_board = nullptr;
51 m_project = nullptr;
52 m_designCenter.x = 0;
53 m_designCenter.y = 0;
54 m_doneCopperWarning = false;
58 m_numNets = 0;
60 m_progressReporter = aProgressReporter;
61 }
PROGRESS_REPORTER * m_progressReporter
bool m_doneCopperWarning
Used by loadCoppers() to avoid multiple duplicate warnings.
int m_numCopperLayers
Number of layers in the design.
VECTOR2I m_designCenter
Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canv...
bool m_doneSpacingClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
int m_numNets
Number of nets loaded so far.
bool m_logLayerWarnings
Used in loadBoardStackup()
bool m_doneNetClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
LAYER_MAPPING_HANDLER m_layerMappingHandler
Callback to get layer mapping.
CADSTAR_PCB_ARCHIVE_PARSER(const wxString &aFilename)

References m_board, m_designCenter, m_doneCopperWarning, m_doneNetClassWarning, m_doneSpacingClassWarning, m_doneTearDropWarning, m_layerMappingHandler, m_logLayerWarnings, m_numCopperLayers, m_numNets, CADSTAR_ARCHIVE_PARSER::m_progressReporter, m_project, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ ~CADSTAR_PCB_ARCHIVE_LOADER()

CADSTAR_PCB_ARCHIVE_LOADER::~CADSTAR_PCB_ARCHIVE_LOADER ( )
inline

Definition at line 64 of file cadstar_pcb_archive_loader.h.

65 {
66 for( std::pair<SYMDEF_ID, FOOTPRINT*> libItem : m_libraryMap )
67 {
68 FOOTPRINT* footprint = libItem.second;
69
70 if( footprint )
71 delete footprint;
72 }
73 }
std::map< SYMDEF_ID, FOOTPRINT * > m_libraryMap
Map between Cadstar and KiCad components in the library.

References m_libraryMap.

Member Function Documentation

◆ addAttribute()

void CADSTAR_PCB_ARCHIVE_LOADER::addAttribute ( const ATTRIBUTE_LOCATION aCadstarAttrLoc,
const ATTRIBUTE_ID aCadstarAttributeID,
FOOTPRINT aFootprint,
const wxString &  aAttributeValue 
)
private

Adds a CADSTAR Attribute to a KiCad footprint.

Parameters
aCadstarAttrLoc
aCadstarAttributeID
aFootprint
aAttributeValue

Definition at line 3220 of file cadstar_pcb_archive_loader.cpp.

3224{
3225 FP_TEXT* txt;
3226
3227 if( aCadstarAttributeID == COMPONENT_NAME_ATTRID )
3228 {
3229 txt = &aFootprint->Reference(); //text should be set outside this function
3230 }
3231 else if( aCadstarAttributeID == PART_NAME_ATTRID )
3232 {
3233 if( aFootprint->Value().GetText().IsEmpty() )
3234 {
3235 // Use PART_NAME_ATTRID as the value is value field is blank
3236 aFootprint->SetValue( aAttributeValue );
3237 txt = &aFootprint->Value();
3238 }
3239 else
3240 {
3241 txt = new FP_TEXT( aFootprint );
3242 aFootprint->Add( txt );
3243 txt->SetText( aAttributeValue );
3244 }
3245 txt->SetVisible( false ); //make invisible to avoid clutter.
3246 }
3247 else if( aCadstarAttributeID != COMPONENT_NAME_2_ATTRID
3248 && getAttributeName( aCadstarAttributeID ) == wxT( "Value" ) )
3249 {
3250 if( !aFootprint->Value().GetText().IsEmpty() )
3251 {
3252 //copy the object
3253 aFootprint->Add( aFootprint->Value().Duplicate() );
3254 }
3255
3256 aFootprint->SetValue( aAttributeValue );
3257 txt = &aFootprint->Value();
3258 txt->SetVisible( false ); //make invisible to avoid clutter.
3259 }
3260 else
3261 {
3262 txt = new FP_TEXT( aFootprint );
3263 aFootprint->Add( txt );
3264 txt->SetText( aAttributeValue );
3265 txt->SetVisible( false ); //make all user attributes invisible to avoid clutter.
3266 //TODO: Future improvement - allow user to decide what to do with attributes
3267 }
3268
3269 VECTOR2I rotatedTextPos = getKiCadPoint( aCadstarAttrLoc.Position ) - aFootprint->GetPosition();
3270 RotatePoint( rotatedTextPos, -aFootprint->GetOrientation() );
3271
3272 txt->SetTextPos( getKiCadPoint( aCadstarAttrLoc.Position ) );
3273 txt->SetPos0( rotatedTextPos );
3274 txt->SetLayer( getKiCadLayer( aCadstarAttrLoc.LayerID ) );
3275 txt->SetMirrored( aCadstarAttrLoc.Mirror );
3276 txt->SetTextAngle( getAngle( aCadstarAttrLoc.OrientAngle ) - aFootprint->GetOrientation() );
3277
3278 if( aCadstarAttrLoc.Mirror ) // If mirroring, invert angle to match CADSTAR
3279 txt->SetTextAngle( -txt->GetTextAngle() );
3280
3281 TEXTCODE tc = getTextCode( aCadstarAttrLoc.TextCodeID );
3282
3283 txt->SetTextThickness( getKiCadLength( tc.LineWidth ) );
3284
3285 wxSize txtSize;
3286 txtSize.x = getKiCadLength( tc.Width );
3287
3288 // The width is zero for all non-cadstar fonts. Using a width equal to the height seems
3289 // to work well for most fonts.
3290 if( txtSize.x == 0 )
3291 txtSize.x = getKiCadLength( tc.Height );
3292
3293 txtSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
3294 txt->SetTextSize( txtSize );
3295 txt->SetKeepUpright( false ); //Keeping it upright seems to result in incorrect orientation
3296
3297 switch( aCadstarAttrLoc.Alignment )
3298 {
3299 case ALIGNMENT::NO_ALIGNMENT: // Default for Single line text is Bottom Left
3305 break;
3306
3310 break;
3311
3315 break;
3316
3320 break;
3321
3325 break;
3326
3330 break;
3331
3332 case ALIGNMENT::TOPLEFT:
3335 break;
3336
3340 break;
3341
3345 break;
3346
3347 default:
3348 wxFAIL_MSG( wxT( "Unknown Alignment - needs review!" ) );
3349 }
3350
3351 //TODO Handle different font types when KiCad can support it.
3352}
#define COMPONENT_NAME_2_ATTRID
Component Name 2 Attribute ID - typically used for indicating the placement of designators in placeme...
#define COMPONENT_NAME_ATTRID
Component Name Attribute ID - typically used for placement of designators on silk screen.
#define PART_NAME_ATTRID
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:184
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
@ NO_ALIGNMENT
NO_ALIGNMENT has different meaning depending on the object type.
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
int getKiCadLength(long long aCadstarLength)
EDA_ANGLE getAngle(const long long &aCadstarAngle)
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
wxString getAttributeName(const ATTRIBUTE_ID &aCadstarAttributeID)
VECTOR2I getKiCadPoint(const VECTOR2I &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:224
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:185
void SetKeepUpright(bool aKeepUpright)
Definition: eda_text.cpp:256
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
void SetValue(const wxString &aValue)
Definition: footprint.h:555
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:567
VECTOR2I GetPosition() const override
Definition: footprint.h:188
FP_TEXT & Reference()
Definition: footprint.h:568
void SetPos0(const VECTOR2I &aPos)
Definition: fp_text.h:123
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References FOOTPRINT::Add(), CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::Alignment, CADSTAR_ARCHIVE_PARSER::BOTTOMCENTER, CADSTAR_ARCHIVE_PARSER::BOTTOMLEFT, CADSTAR_ARCHIVE_PARSER::BOTTOMRIGHT, CADSTAR_ARCHIVE_PARSER::CENTERCENTER, CADSTAR_ARCHIVE_PARSER::CENTERLEFT, CADSTAR_ARCHIVE_PARSER::CENTERRIGHT, COMPONENT_NAME_2_ATTRID, COMPONENT_NAME_ATTRID, BOARD_ITEM::Duplicate(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), getAngle(), getAttributeName(), getKiCadLayer(), getKiCadLength(), getKiCadPoint(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), getTextCode(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, CADSTAR_ARCHIVE_PARSER::TEXTCODE::Height, KI_FALLTHROUGH, KiROUND(), CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::LayerID, CADSTAR_ARCHIVE_PARSER::TEXTCODE::LineWidth, CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::Mirror, CADSTAR_ARCHIVE_PARSER::NO_ALIGNMENT, CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::OrientAngle, PART_NAME_ATTRID, CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::Position, FOOTPRINT::Reference(), RotatePoint(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetKeepUpright(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), FP_TEXT::SetPos0(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), FOOTPRINT::SetValue(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::TextCodeID, CADSTAR_ARCHIVE_PARSER::TOPCENTER, CADSTAR_ARCHIVE_PARSER::TOPLEFT, CADSTAR_ARCHIVE_PARSER::TOPRIGHT, CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO, FOOTPRINT::Value(), and CADSTAR_ARCHIVE_PARSER::TEXTCODE::Width.

Referenced by loadComponentAttributes().

◆ addToGroup()

void CADSTAR_PCB_ARCHIVE_LOADER::addToGroup ( const GROUP_ID aCadstarGroupID,
BOARD_ITEM aKiCadItem 
)
private

Definition at line 4132 of file cadstar_pcb_archive_loader.cpp.

4134{
4135 wxCHECK( m_groupMap.find( aCadstarGroupID ) != m_groupMap.end(), );
4136
4137 PCB_GROUP* parentGroup = m_groupMap.at( aCadstarGroupID );
4138 parentGroup->AddItem( aKiCadItem );
4139}
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
Map between Cadstar and KiCad groups.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80

References PCB_GROUP::AddItem(), and m_groupMap.

Referenced by drawCadstarShape(), drawCadstarText(), getShapeFromVertex(), and loadBoards().

◆ applyDimensionSettings()

void CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings ( const DIMENSION aCadstarDim,
PCB_DIMENSION_BASE aKiCadDim 
)
private

Definition at line 3613 of file cadstar_pcb_archive_loader.cpp.

3615{
3616 UNITS dimensionUnits = aCadstarDim.LinearUnits;
3617 TEXTCODE txtCode = getTextCode( aCadstarDim.Text.TextCodeID );
3618 int correctedHeight = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( txtCode.Height ) );
3619 wxSize txtSize( getKiCadLength( txtCode.Width ), correctedHeight );
3620 LINECODE linecode = Assignments.Codedefs.LineCodes.at( aCadstarDim.Line.LineCodeID );
3621
3622 aKiCadDim->SetLayer( getKiCadLayer( aCadstarDim.LayerID ) );
3623 aKiCadDim->SetPrecision( aCadstarDim.Precision );
3624 aKiCadDim->SetStart( getKiCadPoint( aCadstarDim.ExtensionLineParams.Start ) );
3625 aKiCadDim->SetEnd( getKiCadPoint( aCadstarDim.ExtensionLineParams.End ) );
3626 aKiCadDim->SetExtensionOffset( getKiCadLength( aCadstarDim.ExtensionLineParams.Offset ) );
3627 aKiCadDim->SetLineThickness( getKiCadLength( linecode.Width ) );
3628 aKiCadDim->Text().SetTextThickness( getKiCadLength( txtCode.LineWidth ) );
3629 aKiCadDim->Text().SetTextSize( txtSize );
3630
3631 // Find prefix and suffix:
3632 wxString prefix = wxEmptyString;
3633 wxString suffix = wxEmptyString;
3634 size_t startpos = aCadstarDim.Text.Text.Find( wxT( "<@DISTANCE" ) );
3635
3636 if( startpos != wxNOT_FOUND )
3637 {
3638 prefix = ParseTextFields( aCadstarDim.Text.Text.SubString( 0, startpos - 1 ), &m_context );
3639 wxString remainingStr = aCadstarDim.Text.Text.Mid( startpos );
3640 size_t endpos = remainingStr.Find( "@>" );
3641 suffix = ParseTextFields( remainingStr.Mid( endpos + 2 ), &m_context );
3642 }
3643
3644 if( suffix.StartsWith( wxT( "mm" ) ) )
3645 {
3647 suffix = suffix.Mid( 2 );
3648 }
3649 else
3650 {
3652 }
3653
3654 aKiCadDim->SetPrefix( prefix );
3655 aKiCadDim->SetSuffix( suffix );
3656
3657 if( aCadstarDim.LinearUnits == UNITS::DESIGN )
3658 {
3659 // For now we will hardcode the units as per the original CADSTAR design.
3660 // TODO: update this when KiCad supports design units
3662 dimensionUnits = Assignments.Technology.Units;
3663 }
3664
3665 switch( dimensionUnits )
3666 {
3667 case UNITS::METER:
3668 case UNITS::CENTIMETER:
3669 case UNITS::MICROMETRE:
3670 wxLogWarning( wxString::Format( _( "Dimension ID %s uses a type of unit that "
3671 "is not supported in KiCad. Millimeters were "
3672 "applied instead." ),
3673 aCadstarDim.ID ) );
3675 case UNITS::MM:
3677 break;
3678
3679 case UNITS::INCH:
3681 break;
3682
3683 case UNITS::THOU:
3684 aKiCadDim->SetUnitsMode( DIM_UNITS_MODE::MILS );
3685 break;
3686
3687 case UNITS::DESIGN:
3688 wxFAIL_MSG( wxT( "We should have handled design units before coming here!" ) );
3689 break;
3690 }
3691}
static wxString ParseTextFields(const wxString &aTextString, PARSER_CONTEXT *aParserContext)
Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.
@ DESIGN
Inherits from design units (assumed Assignments->Technology->Units)
void SetPrecision(int aPrecision)
void SetUnitsFormat(const DIM_UNITS_FORMAT aFormat)
void SetPrefix(const wxString &aPrefix)
void SetExtensionOffset(int aOffset)
PCB_TEXT & Text()
void SetSuffix(const wxString &aSuffix)
void SetLineThickness(int aWidth)
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetUnitsMode(DIM_UNITS_MODE aMode)
#define _(s)
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
std::map< LINECODE_ID, LINECODE > LineCodes
UNITS Units
Units to display for linear dimensions.
long UnitDisplPrecision
Number of decimal points to display for linear dimensions.

References _, CADSTAR_PCB_ARCHIVE_PARSER::Assignments, BARE_SUFFIX, CADSTAR_ARCHIVE_PARSER::CENTIMETER, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, CADSTAR_ARCHIVE_PARSER::DESIGN, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::End, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::ExtensionLineParams, Format(), getKiCadLayer(), getKiCadLength(), getKiCadPoint(), getTextCode(), CADSTAR_ARCHIVE_PARSER::TEXTCODE::Height, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::ID, CADSTAR_ARCHIVE_PARSER::INCH, INCHES, KI_FALLTHROUGH, KiROUND(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::LayerID, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Line, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::LinearUnits, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::LINE::LineCodeID, CADSTAR_ARCHIVE_PARSER::CODEDEFS::LineCodes, CADSTAR_ARCHIVE_PARSER::TEXTCODE::LineWidth, CADSTAR_ARCHIVE_PARSER::m_context, CADSTAR_ARCHIVE_PARSER::METER, CADSTAR_ARCHIVE_PARSER::MICROMETRE, MILLIMETRES, MILS, CADSTAR_ARCHIVE_PARSER::MM, NO_SUFFIX, CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::Offset, CADSTAR_ARCHIVE_PARSER::ParseTextFields(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Precision, PCB_DIMENSION_BASE::SetEnd(), PCB_DIMENSION_BASE::SetExtensionOffset(), PCB_DIMENSION_BASE::SetLayer(), PCB_DIMENSION_BASE::SetLineThickness(), PCB_DIMENSION_BASE::SetPrecision(), PCB_DIMENSION_BASE::SetPrefix(), PCB_DIMENSION_BASE::SetStart(), PCB_DIMENSION_BASE::SetSuffix(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), PCB_DIMENSION_BASE::SetUnitsFormat(), PCB_DIMENSION_BASE::SetUnitsMode(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::EXTENSION_LINE::Start, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Technology, CADSTAR_ARCHIVE_PARSER::TEXT::Text, PCB_DIMENSION_BASE::Text(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Text, CADSTAR_ARCHIVE_PARSER::TEXT::TextCodeID, CADSTAR_ARCHIVE_PARSER::THOU, CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO, CADSTAR_ARCHIVE_PARSER::SETTINGS::UnitDisplPrecision, CADSTAR_ARCHIVE_PARSER::SETTINGS::Units, CADSTAR_ARCHIVE_PARSER::LINECODE::Width, and CADSTAR_ARCHIVE_PARSER::TEXTCODE::Width.

Referenced by loadDimensions().

◆ applyRouteOffset()

void CADSTAR_PCB_ARCHIVE_LOADER::applyRouteOffset ( VECTOR2I aPointToOffset,
const VECTOR2I aRefPoint,
const long &  aOffsetAmount 
)
private

CADSTAR's Post Processor does an action called "Route Offset" which is applied when a route is wider than the pad on which it is terminating or when there are different widths of route, in order to reduce overlap.

Parameters
aPointToOffsetPoint that we want to offset by aOffsetAmount
aRefPointReference point to use for determine the angle of the offset
aOffsetAmount

Definition at line 3355 of file cadstar_pcb_archive_loader.cpp.

3358{
3359 VECTOR2I v( *aPointToOffset - aRefPoint );
3360 int newLength = v.EuclideanNorm() - aOffsetAmount;
3361
3362 if( newLength > 0 )
3363 {
3364 VECTOR2I offsetted = v.Resize( newLength ) + VECTOR2I( aRefPoint );
3365 aPointToOffset->x = offsetted.x;
3366 aPointToOffset->y = offsetted.y;
3367 }
3368 else
3369 {
3370 *aPointToOffset = aRefPoint; // zero length track. Needs to be removed to mimmick
3371 // cadstar behaviour
3372 }
3373}
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:378
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References VECTOR2< T >::EuclideanNorm(), VECTOR2< T >::Resize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by makeTracksFromShapes().

◆ calculateZonePriorities()

bool CADSTAR_PCB_ARCHIVE_LOADER::calculateZonePriorities ( PCB_LAYER_ID aLayer)
private

Tries to make a best guess as to the zone priorities based on the pour status.

Definition at line 3693 of file cadstar_pcb_archive_loader.cpp.

3694{
3695 std::map<TEMPLATE_ID, std::set<TEMPLATE_ID>> winningOverlaps;
3696
3697 auto inflateValue =
3698 [&]( ZONE* aZoneA, ZONE* aZoneB )
3699 {
3700 int extra = getKiCadLength( Assignments.Codedefs.SpacingCodes.at( wxT( "C_C" ) ).Spacing )
3702
3703 int retval = std::max( aZoneA->GetLocalClearance(), aZoneB->GetLocalClearance() );
3704
3705 retval += extra;
3706
3707 return retval;
3708 };
3709
3710 // Find the error in fill area when guessing that aHigherZone gets filled before aLowerZone
3711 auto errorArea =
3712 [&]( ZONE* aLowerZone, ZONE* aHigherZone ) -> double
3713 {
3714 SHAPE_POLY_SET intersectShape( *aHigherZone->Outline() );
3715 intersectShape.Inflate( inflateValue( aLowerZone, aHigherZone ) , 32 );
3716
3717 SHAPE_POLY_SET lowerZoneFill( *aLowerZone->GetFilledPolysList( aLayer ) );
3718 SHAPE_POLY_SET lowerZoneOutline( *aLowerZone->Outline() );
3719
3720 lowerZoneOutline.BooleanSubtract( intersectShape, SHAPE_POLY_SET::PM_FAST );
3721
3722 lowerZoneFill.BooleanSubtract( lowerZoneOutline, SHAPE_POLY_SET::PM_FAST );
3723
3724 double leftOverArea = lowerZoneFill.Area();
3725
3726 return leftOverArea;
3727 };
3728
3729 auto intersectionAreaOfZoneOutlines =
3730 [&]( ZONE* aZoneA, ZONE* aZoneB ) -> double
3731 {
3732 SHAPE_POLY_SET outLineA( *aZoneA->Outline() );
3733 outLineA.Inflate( inflateValue( aZoneA, aZoneB ), 32 );
3734
3735 SHAPE_POLY_SET outLineB( *aZoneA->Outline() );
3736 outLineB.Inflate( inflateValue( aZoneA, aZoneB ), 32 );
3737
3738 outLineA.BooleanIntersection( outLineB, SHAPE_POLY_SET::PM_FAST );
3739
3740 return outLineA.Area();
3741 };
3742
3743 // Lambda to determine if the zone with template ID 'a' is lower priority than 'b'
3744 auto isLowerPriority =
3745 [&]( const TEMPLATE_ID& a, const TEMPLATE_ID& b ) -> bool
3746 {
3747 return winningOverlaps[b].count( a ) > 0;
3748 };
3749
3750 for( std::map<TEMPLATE_ID, ZONE*>::iterator it1 = m_zonesMap.begin();
3751 it1 != m_zonesMap.end(); ++it1 )
3752 {
3753 TEMPLATE& thisTemplate = Layout.Templates.at( it1->first );
3754 ZONE* thisZone = it1->second;
3755
3756 if( !thisZone->GetLayerSet().Contains( aLayer ) )
3757 continue;
3758
3759 for( std::map<TEMPLATE_ID, ZONE*>::iterator it2 = it1;
3760 it2 != m_zonesMap.end(); ++it2 )
3761 {
3762 TEMPLATE& otherTemplate = Layout.Templates.at( it2->first );
3763 ZONE* otherZone = it2->second;
3764
3765 if( thisTemplate.ID == otherTemplate.ID )
3766 continue;
3767
3768 if( !otherZone->GetLayerSet().Contains( aLayer ) )
3769 {
3770 checkPoint();
3771 continue;
3772 }
3773
3774 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) == 0 )
3775 {
3776 checkPoint();
3777 continue; // The zones do not interact in any way
3778 }
3779
3780 SHAPE_POLY_SET thisZonePolyFill = *thisZone->GetFilledPolysList( aLayer );
3781 SHAPE_POLY_SET otherZonePolyFill = *otherZone->GetFilledPolysList( aLayer );
3782
3783 if( thisZonePolyFill.Area() > 0.0 && otherZonePolyFill.Area() > 0.0 )
3784 {
3785 // Test if this zone were lower priority than other zone, what is the error?
3786 double areaThis = errorArea( thisZone, otherZone );
3787 // Vice-versa
3788 double areaOther = errorArea( otherZone, thisZone );
3789
3790 if( areaThis > areaOther )
3791 {
3792 // thisTemplate is filled before otherTemplate
3793 winningOverlaps[thisTemplate.ID].insert( otherTemplate.ID );
3794 }
3795 else
3796 {
3797 // thisTemplate is filled AFTER otherTemplate
3798 winningOverlaps[otherTemplate.ID].insert( thisTemplate.ID );
3799 }
3800 }
3801 else if( thisZonePolyFill.Area() > 0.0 )
3802 {
3803 // The other template is not filled, this one wins
3804 winningOverlaps[thisTemplate.ID].insert( otherTemplate.ID );
3805 }
3806 else if( otherZonePolyFill.Area() > 0.0 )
3807 {
3808 // This template is not filled, the other one wins
3809 winningOverlaps[otherTemplate.ID].insert( thisTemplate.ID );
3810 }
3811 else
3812 {
3813 // Neither of the templates is poured - use zone outlines instead (bigger outlines
3814 // get a lower priority)
3815 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) != 0 )
3816 {
3817 if( thisZone->Outline()->Area() > otherZone->Outline()->Area() )
3818 winningOverlaps[otherTemplate.ID].insert( thisTemplate.ID );
3819 else
3820 winningOverlaps[thisTemplate.ID].insert( otherTemplate.ID );
3821 }
3822 }
3823
3824 checkPoint();
3825 }
3826 }
3827
3828 // Build a set of unique TEMPLATE_IDs of all the zones that intersect with another one
3829 std::set<TEMPLATE_ID> intersectingIDs;
3830
3831 for( const std::pair<TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3832 {
3833 intersectingIDs.insert( idPair.first );
3834 intersectingIDs.insert( idPair.second.begin(), idPair.second.end() );
3835 }
3836
3837 // Now store them in a vector
3838 std::vector<TEMPLATE_ID> sortedIDs;
3839
3840 for( const TEMPLATE_ID& id : intersectingIDs )
3841 {
3842 sortedIDs.push_back( id );
3843 }
3844
3845 // sort by priority
3846 std::sort( sortedIDs.begin(), sortedIDs.end(), isLowerPriority );
3847
3848 TEMPLATE_ID prevID = wxEmptyString;
3849
3850 for( const TEMPLATE_ID& id : sortedIDs )
3851 {
3852 if( prevID.IsEmpty() )
3853 {
3854 prevID = id;
3855 continue;
3856 }
3857
3858 wxASSERT( !isLowerPriority( id, prevID ) );
3859
3860 int newPriority = m_zonesMap.at( prevID )->GetAssignedPriority();
3861
3862 // Only increase priority of the current zone
3863 if( isLowerPriority( prevID, id ) )
3864 newPriority++;
3865
3866 m_zonesMap.at( id )->SetAssignedPriority( newPriority );
3867 prevID = id;
3868 }
3869
3870 // Verify
3871 for( const std::pair<TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3872 {
3873 const TEMPLATE_ID& winningID = idPair.first;
3874
3875 for( const TEMPLATE_ID& losingID : idPair.second )
3876 {
3877 if( m_zonesMap.at( losingID )->GetAssignedPriority()
3878 > m_zonesMap.at( winningID )->GetAssignedPriority() )
3879 {
3880 return false;
3881 }
3882 }
3883 }
3884
3885 return true;
3886}
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:682
void checkPoint()
Updates m_progressReporter or throws if user cancelled.
std::map< TEMPLATE_ID, ZONE * > m_zonesMap
Map between Cadstar and KiCad zones.
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: layer_ids.h:600
Represent a set of closed polygons.
double Area()
Count the number of arc shapes present.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:602
SHAPE_POLY_SET * Outline()
Definition: zone.h:312
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:470
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:122
std::map< SPACINGCODE_ID, SPACINGCODE > SpacingCodes
Spacing Design Rules.
std::map< TEMPLATE_ID, TEMPLATE > Templates

References SHAPE_POLY_SET::Area(), CADSTAR_PCB_ARCHIVE_PARSER::Assignments, SHAPE_POLY_SET::BooleanIntersection(), SHAPE_POLY_SET::BooleanSubtract(), CADSTAR_ARCHIVE_PARSER::checkPoint(), CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, LSET::Contains(), BOARD::GetDesignSettings(), ZONE::GetFilledPolysList(), getKiCadLength(), ZONE::GetLayerSet(), ZONE::GetLocalClearance(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::ID, SHAPE_POLY_SET::Inflate(), CADSTAR_PCB_ARCHIVE_PARSER::Layout, m_board, BOARD_DESIGN_SETTINGS::m_MinClearance, m_zonesMap, ZONE::Outline(), SHAPE_POLY_SET::PM_FAST, CADSTAR_PCB_ARCHIVE_PARSER::CODEDEFS_PCB::SpacingCodes, and CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Templates.

Referenced by Load().

◆ checkAndLogHatchCode()

void CADSTAR_PCB_ARCHIVE_LOADER::checkAndLogHatchCode ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3549 of file cadstar_pcb_archive_loader.cpp.

3550{
3551 if( m_hatchcodesTested.find( aCadstarHatchcodeID ) != m_hatchcodesTested.end() )
3552 {
3553 return; //already checked
3554 }
3555 else
3556 {
3557 HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3558
3559 if( hcode.Hatches.size() != 2 )
3560 {
3561 wxLogWarning( wxString::Format(
3562 _( "The CADSTAR Hatching code '%s' has %d hatches defined. "
3563 "KiCad only supports 2 hatches (crosshatching) 90 degrees apart. "
3564 "The imported hatching is crosshatched." ),
3565 hcode.Name, (int) hcode.Hatches.size() ) );
3566 }
3567 else
3568 {
3569 if( hcode.Hatches.at( 0 ).LineWidth != hcode.Hatches.at( 1 ).LineWidth )
3570 {
3571 wxLogWarning( wxString::Format(
3572 _( "The CADSTAR Hatching code '%s' has different line widths for each "
3573 "hatch. KiCad only supports one width for the hatching. The imported "
3574 "hatching uses the width defined in the first hatch definition, i.e. "
3575 "%.2f mm." ),
3576 hcode.Name,
3577 (double) ( (double) getKiCadLength( hcode.Hatches.at( 0 ).LineWidth ) )
3578 / 1E6 ) );
3579 }
3580
3581 if( hcode.Hatches.at( 0 ).Step != hcode.Hatches.at( 1 ).Step )
3582 {
3583 wxLogWarning( wxString::Format(
3584 _( "The CADSTAR Hatching code '%s' has different step sizes for each "
3585 "hatch. KiCad only supports one step size for the hatching. The imported "
3586 "hatching uses the step size defined in the first hatching definition, "
3587 "i.e. %.2f mm." ),
3588 hcode.Name,
3589 (double) ( (double) getKiCadLength( hcode.Hatches.at( 0 ).Step ) )
3590 / 1E6 ) );
3591 }
3592
3593 if( abs( hcode.Hatches.at( 0 ).OrientAngle - hcode.Hatches.at( 1 ).OrientAngle )
3594 != 90000 )
3595 {
3596 wxLogWarning( wxString::Format(
3597 _( "The hatches in CADSTAR Hatching code '%s' have an angle "
3598 "difference of %.1f degrees. KiCad only supports hatching 90 "
3599 "degrees apart. The imported hatching has two hatches 90 "
3600 "degrees apart, oriented %.1f degrees from horizontal." ),
3601 hcode.Name,
3602 getAngle( abs( hcode.Hatches.at( 0 ).OrientAngle
3603 - hcode.Hatches.at( 1 ).OrientAngle ) ).AsDegrees(),
3604 getAngle( hcode.Hatches.at( 0 ).OrientAngle ).AsDegrees() ) );
3605 }
3606 }
3607
3608 m_hatchcodesTested.insert( aCadstarHatchcodeID );
3609 }
3610}
HATCHCODE getHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
std::set< HATCHCODE_ID > m_hatchcodesTested
Used by checkAndLogHatchCode() to avoid multiple duplicate warnings.
double AsDegrees() const
Definition: eda_angle.h:149
@ E6
Definition: eseries.h:62
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401

References _, std::abs(), EDA_ANGLE::AsDegrees(), E6, Format(), getAngle(), getHatchCode(), getKiCadLength(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Hatches, m_hatchcodesTested, and CADSTAR_ARCHIVE_PARSER::HATCHCODE::Name.

Referenced by getHatchCodeAngle(), getKiCadHatchCodeGap(), and getKiCadHatchCodeThickness().

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

2745{
2746 if( m_progressReporter )
2747 {
2749
2751 THROW_IO_ERROR( _( "File import cancelled by user." ) );
2752 }
2753}
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).
#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 calculateZonePriorities(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), loadCoppers(), CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary(), CADSTAR_SCH_ARCHIVE_PARSER::Parse(), and CADSTAR_PCB_ARCHIVE_PARSER::Parse().

◆ createUniqueGroupID()

CADSTAR_PCB_ARCHIVE_LOADER::GROUP_ID CADSTAR_PCB_ARCHIVE_LOADER::createUniqueGroupID ( const wxString &  aName)
private

Adds a new PCB_GROUP* to m_groupMap.

Parameters
aNameName to give the group. If name already exists, append "_1", "_2", etc. to the end to ensure it is unique
Returns

Definition at line 4142 of file cadstar_pcb_archive_loader.cpp.

4144{
4145 wxString groupName = aName;
4146 int num = 0;
4147
4148 while( m_groupMap.find( groupName ) != m_groupMap.end() )
4149 {
4150 groupName = aName + wxT( "_" ) + wxString::Format( wxT( "%i" ), ++num );
4151 }
4152
4153 PCB_GROUP* docSymGroup = new PCB_GROUP( m_board );
4154 m_board->Add( docSymGroup );
4155 docSymGroup->SetName( groupName );
4156 GROUP_ID groupID( groupName );
4157 m_groupMap.insert( { groupID, docSymGroup } );
4158
4159 return groupID;
4160}
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:750
void SetName(const wxString &aName)
Definition: pcb_group.h:66

References BOARD::Add(), Format(), m_board, m_groupMap, and PCB_GROUP::SetName().

Referenced by loadBoards(), and loadDocumentationSymbols().

◆ drawCadstarCutoutsAsShapes()

void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarCutoutsAsShapes ( const std::vector< CUTOUT > &  aCutouts,
const PCB_LAYER_ID aKiCadLayer,
const int &  aLineThickness,
BOARD_ITEM_CONTAINER aContainer,
const GROUP_ID aCadstarGroupID = wxEmptyString,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private

Uses PCB_SHAPEs to draw the cutouts on m_board object.

Parameters
aVertices
aKiCadLayerKiCad layer to draw on
aLineThicknessThickness of line to draw with
aContainerto draw on (e.g. m_board)
aCadstarGroupIDto add the shapes to
aMoveVectormove shapes by this amount (in KiCad coordinates)
aRotationAnglerotate shapes by this amount (in tenth degrees)
aScalingFactorscale shapes by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, mirrors the shapes

Definition at line 2749 of file cadstar_pcb_archive_loader.cpp.

2759{
2760 for( CUTOUT cutout : aCutouts )
2761 {
2762 drawCadstarVerticesAsShapes( cutout.Vertices, aKiCadLayer, aLineThickness, aContainer,
2763 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2764 aTransformCentre, aMirrorInvert );
2765 }
2766}
void drawCadstarVerticesAsShapes(const std::vector< VERTEX > &aCadstarVertices, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPE to draw the vertices on m_board object.
@ CUTOUT
Make a cutout to an existing zone.

References drawCadstarVerticesAsShapes().

Referenced by drawCadstarShape().

◆ drawCadstarShape()

void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape ( const SHAPE aCadstarShape,
const PCB_LAYER_ID aKiCadLayer,
const int &  aLineThickness,
const wxString &  aShapeName,
BOARD_ITEM_CONTAINER aContainer,
const GROUP_ID aCadstarGroupID = wxEmptyString,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private
Parameters
aCadstarShape
aCadstarLayerIDKiCad layer to draw on
aLineThicknessThickness of line to draw with
aShapeNamefor reporting warnings/errors to the user
aContainerto draw on (e.g. m_board)
aCadstarGroupIDto add the shape to
aMoveVectormove shapes by this amount (in KiCad coordinates)
aRotationAnglerotate shapes by this amount (in tenth degrees)
aScalingFactorscale shapes by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, mirrors the shapes

TODO update this when Polygons in KiCad can be defined with no fill

TODO update this when Polygons in KiCad can be defined with hatch fill

Definition at line 2672 of file cadstar_pcb_archive_loader.cpp.

2683{
2684 auto drawAsOutline = [&]()
2685 {
2686 drawCadstarVerticesAsShapes( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
2687 aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2688 aScalingFactor, aTransformCentre, aMirrorInvert );
2689 drawCadstarCutoutsAsShapes( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness, aContainer,
2690 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2691 aTransformCentre, aMirrorInvert );
2692 };
2693
2694 switch( aCadstarShape.Type )
2695 {
2699 drawAsOutline();
2700 break;
2701
2704 wxLogWarning( wxString::Format(
2705 _( "The shape for '%s' is Hatch filled in CADSTAR, which has no KiCad equivalent. "
2706 "Using solid fill instead." ),
2707 aShapeName ) );
2708
2709 case SHAPE_TYPE::SOLID:
2710 {
2711 // Special case solid shapes that are effectively a single line
2712 if( aCadstarShape.Vertices.size() < 3
2713 || ( aCadstarShape.Vertices.size() == 3
2714 && aCadstarShape.Vertices.at( 0 ).End == aCadstarShape.Vertices.at( 2 ).End ) )
2715 {
2716 drawAsOutline();
2717 break;
2718 }
2719
2720 PCB_SHAPE* shape;
2721
2722 if( isFootprint( aContainer ) )
2723 shape = new FP_SHAPE( (FOOTPRINT*) aContainer, SHAPE_T::POLY );
2724 else
2725 shape = new PCB_SHAPE( aContainer, SHAPE_T::POLY );
2726
2727 shape->SetFilled( true );
2728
2729 SHAPE_POLY_SET shapePolys = getPolySetFromCadstarShape( aCadstarShape, -1, aContainer,
2730 aMoveVector, aRotationAngle,
2731 aScalingFactor, aTransformCentre,
2732 aMirrorInvert );
2733
2734 shapePolys.Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_STRICTLY_SIMPLE );
2735
2736 shape->SetPolyShape( shapePolys );
2737 shape->SetStroke( STROKE_PARAMS( aLineThickness, PLOT_DASH_TYPE::SOLID ) );
2738 shape->SetLayer( aKiCadLayer );
2739 aContainer->Add( shape, ADD_MODE::APPEND );
2740
2741 if( !aCadstarGroupID.IsEmpty() )
2742 addToGroup( aCadstarGroupID, shape );
2743 }
2744 break;
2745 }
2746}
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false)=0
Adds an item to the container.
@ OUTLINE
Unfilled closed shape.
@ OPENSHAPE
Unfilled open shape. Cannot have cutouts.
@ SOLID
Filled closed shape (solid fill).
@ HATCHED
Filled closed shape (hatch fill).
void drawCadstarCutoutsAsShapes(const std::vector< CUTOUT > &aCutouts, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPEs to draw the cutouts on m_board object.
SHAPE_POLY_SET getPolySetFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness=-1, BOARD_ITEM_CONTAINER *aContainer=nullptr, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a SHAPE_POLY_SET object from a Cadstar SHAPE.
bool isFootprint(BOARD_ITEM_CONTAINER *aContainer)
void addToGroup(const GROUP_ID &aCadstarGroupID, BOARD_ITEM *aKiCadItem)
void SetFilled(bool aFlag)
Definition: eda_shape.h:95
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:255
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:72
SHAPE_TYPE Type() const
Return the type of the shape.
Definition: shape.h:95
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88

References _, FOOTPRINT::Add(), addToGroup(), APPEND, CADSTAR_ARCHIVE_PARSER::SHAPE::Cutouts, drawCadstarCutoutsAsShapes(), drawCadstarVerticesAsShapes(), Format(), SHAPE_POLY_SET::Fracture(), getPolySetFromCadstarShape(), CADSTAR_ARCHIVE_PARSER::HATCHED, isFootprint(), CADSTAR_ARCHIVE_PARSER::OPENSHAPE, CADSTAR_ARCHIVE_PARSER::OUTLINE, POLY, EDA_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyShape(), PCB_SHAPE::SetStroke(), CADSTAR_ARCHIVE_PARSER::SOLID, SOLID, CADSTAR_ARCHIVE_PARSER::SHAPE::Type, and CADSTAR_ARCHIVE_PARSER::SHAPE::Vertices.

Referenced by loadBoards(), loadDocumentationSymbols(), loadFigures(), loadLibraryCoppers(), and loadLibraryFigures().

◆ drawCadstarText()

void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText ( const TEXT aCadstarText,
BOARD_ITEM_CONTAINER aContainer,
const GROUP_ID aCadstarGroupID = wxEmptyString,
const LAYER_ID aCadstarLayerOverride = wxEmptyString,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private
Parameters
aCadstarText
aContainerto draw on (e.g. m_board)
aCadstarGroupIDto add the text to
aCadstarLayerOverrideif not empty, overrides the LayerID in aCadstarText
aMoveVectormove text by this amount (in KiCad coordinates)
aRotationAnglerotate text by this amount (in tenth degrees)
aScalingFactorscale text by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, it inverts the Mirror status of aCadstarText

Definition at line 2523 of file cadstar_pcb_archive_loader.cpp.

2528{
2529 PCB_TEXT* txt = new PCB_TEXT( aContainer );
2530 aContainer->Add( txt );
2531 txt->SetText( aCadstarText.Text );
2532
2533 EDA_ANGLE rotationAngle( aRotationAngle, TENTHS_OF_A_DEGREE_T );
2534 VECTOR2I rotatedTextPos = getKiCadPoint( aCadstarText.Position );
2535 RotatePoint( rotatedTextPos, aTransformCentre, rotationAngle );
2536 rotatedTextPos.x =
2537 KiROUND( (double) ( rotatedTextPos.x - aTransformCentre.x ) * aScalingFactor );
2538 rotatedTextPos.y =
2539 KiROUND( (double) ( rotatedTextPos.y - aTransformCentre.y ) * aScalingFactor );
2540 rotatedTextPos += aTransformCentre;
2541 txt->SetTextPos( rotatedTextPos );
2542 txt->SetPosition( rotatedTextPos );
2543
2544 txt->SetTextAngle( getAngle( aCadstarText.OrientAngle ) + rotationAngle );
2545
2546 txt->SetMirrored( aCadstarText.Mirror );
2547
2548 TEXTCODE tc = getTextCode( aCadstarText.TextCodeID );
2549
2550 txt->SetTextThickness( getKiCadLength( tc.LineWidth ) );
2551
2552 wxSize unscaledTextSize;
2553 unscaledTextSize.x = getKiCadLength( tc.Width );
2554
2555 // The width is zero for all non-cadstar fonts. Using a width equal to the height seems
2556 // to work well for most fonts.
2557 if( unscaledTextSize.x == 0 )
2558 unscaledTextSize.x = getKiCadLength( tc.Height );
2559
2560 unscaledTextSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
2561 txt->SetTextSize( unscaledTextSize );
2562
2563 switch( aCadstarText.Alignment )
2564 {
2565 case ALIGNMENT::NO_ALIGNMENT: // Default for Single line text is Bottom Left
2569 break;
2570
2574 break;
2575
2579 break;
2580
2584 break;
2585
2589 break;
2590
2594 break;
2595
2596 case ALIGNMENT::TOPLEFT:
2599 break;
2600
2604 break;
2605
2609 break;
2610
2611 default:
2612 wxFAIL_MSG( wxT( "Unknown Alignment - needs review!" ) );
2613 }
2614
2615 if( aMirrorInvert )
2616 {
2617 txt->Flip( aTransformCentre, true );
2618 }
2619
2620 //scale it after flipping:
2621 if( aScalingFactor != 1.0 )
2622 {
2623 wxSize scaledTextSize;
2624 scaledTextSize.x = KiROUND( (double) unscaledTextSize.x * aScalingFactor );
2625 scaledTextSize.y = KiROUND( (double) unscaledTextSize.y * aScalingFactor );
2626 txt->SetTextSize( scaledTextSize );
2627 txt->SetTextThickness(
2628 KiROUND( (double) getKiCadLength( tc.LineWidth ) * aScalingFactor ) );
2629 }
2630
2631 txt->Move( aMoveVector );
2632
2633 if( aCadstarText.Alignment == ALIGNMENT::NO_ALIGNMENT )
2635
2636 LAYER_ID layersToDrawOn = aCadstarLayerOverride;
2637
2638 if( layersToDrawOn.IsEmpty() )
2639 layersToDrawOn = aCadstarText.LayerID;
2640
2641 if( isLayerSet( layersToDrawOn ) )
2642 {
2643 //Make a copy on each layer
2644
2645 LSEQ layers = getKiCadLayerSet( layersToDrawOn ).Seq();
2646 PCB_TEXT* newtxt;
2647
2648 for( PCB_LAYER_ID layer : layers )
2649 {
2650 txt->SetLayer( layer );
2651 newtxt = static_cast<PCB_TEXT*>( txt->Duplicate() );
2652 m_board->Add( newtxt, ADD_MODE::APPEND );
2653
2654 if( !aCadstarGroupID.IsEmpty() )
2655 addToGroup( aCadstarGroupID, newtxt );
2656 }
2657
2658 m_board->Remove( txt );
2659 delete txt;
2660 }
2661 else
2662 {
2663 txt->SetLayer( getKiCadLayer( layersToDrawOn ) );
2664
2665 if( !aCadstarGroupID.IsEmpty() )
2666 addToGroup( aCadstarGroupID, txt );
2667 }
2668 //TODO Handle different font types when KiCad can support it.
2669}
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:859
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
bool isLayerSet(const LAYER_ID &aCadstarLayerID)
LSET getKiCadLayerSet(const LAYER_ID &aCadstarLayerID)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_text.cpp:218
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_text.h:81
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_text.h:86
@ TENTHS_OF_A_DEGREE_T
Definition: eda_angle.h:30
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59

References BOARD::Add(), BOARD_ITEM_CONTAINER::Add(), addToGroup(), CADSTAR_ARCHIVE_PARSER::TEXT::Alignment, APPEND, CADSTAR_ARCHIVE_PARSER::BOTTOMCENTER, CADSTAR_ARCHIVE_PARSER::BOTTOMLEFT, CADSTAR_ARCHIVE_PARSER::BOTTOMRIGHT, CADSTAR_ARCHIVE_PARSER::CENTERCENTER, CADSTAR_ARCHIVE_PARSER::CENTERLEFT, CADSTAR_ARCHIVE_PARSER::CENTERRIGHT, BOARD_ITEM::Duplicate(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), PCB_TEXT::Flip(), getAngle(), getKiCadLayer(), getKiCadLayerSet(), getKiCadLength(), getKiCadPoint(), getTextCode(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, CADSTAR_ARCHIVE_PARSER::TEXTCODE::Height, isLayerSet(), KiROUND(), CADSTAR_ARCHIVE_PARSER::TEXT::LayerID, CADSTAR_ARCHIVE_PARSER::TEXTCODE::LineWidth, m_board, CADSTAR_ARCHIVE_PARSER::TEXT::Mirror, PCB_TEXT::Move(), CADSTAR_ARCHIVE_PARSER::NO_ALIGNMENT, CADSTAR_ARCHIVE_PARSER::TEXT::OrientAngle, CADSTAR_ARCHIVE_PARSER::TEXT::Position, BOARD::Remove(), RotatePoint(), LSET::Seq(), EDA_TEXT::SetHorizJustify(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), PCB_TEXT::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), TENTHS_OF_A_DEGREE_T, CADSTAR_ARCHIVE_PARSER::TEXT::Text, CADSTAR_ARCHIVE_PARSER::TEXT::TextCodeID, CADSTAR_ARCHIVE_PARSER::TOPCENTER, CADSTAR_ARCHIVE_PARSER::TOPLEFT, CADSTAR_ARCHIVE_PARSER::TOPRIGHT, CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO, CADSTAR_ARCHIVE_PARSER::TEXTCODE::Width, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadDocumentationSymbols(), and loadTexts().

◆ drawCadstarVerticesAsShapes()

void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarVerticesAsShapes ( const std::vector< VERTEX > &  aCadstarVertices,
const PCB_LAYER_ID aKiCadLayer,
const int &  aLineThickness,
BOARD_ITEM_CONTAINER aContainer,
const GROUP_ID aCadstarGroupID = wxEmptyString,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private

Uses PCB_SHAPE to draw the vertices on m_board object.

Parameters
aCadstarVertices
aKiCadLayerKiCad layer to draw on
aLineThicknessThickness of line to draw with
aContainerto draw on (e.g. m_board)
aCadstarGroupIDto add the shape to
aMoveVectormove shape by this amount (in KiCad coordinates)
aRotationAnglerotate shape by this amount (in tenth degrees)
aScalingFactorscale shape by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, mirrors the shape
aCadstarGroupIDto add the shape to

Definition at line 2769 of file cadstar_pcb_archive_loader.cpp.

2779{
2780 std::vector<PCB_SHAPE*> shapes = getShapesFromVertices( aCadstarVertices, aContainer,
2781 aCadstarGroupID, aMoveVector,
2782 aRotationAngle, aScalingFactor,
2783 aTransformCentre, aMirrorInvert );
2784
2785 for( PCB_SHAPE* shape : shapes )
2786 {
2787 shape->SetStroke( STROKE_PARAMS( aLineThickness, PLOT_DASH_TYPE::SOLID ) );
2788 shape->SetLayer( aKiCadLayer );
2789 shape->SetParent( aContainer );
2790 aContainer->Add( shape, ADD_MODE::APPEND );
2791 }
2792}
std::vector< PCB_SHAPE * > getShapesFromVertices(const std::vector< VERTEX > &aCadstarVertices, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a vector of pointers to PCB_SHAPE objects.

References BOARD_ITEM_CONTAINER::Add(), APPEND, getShapesFromVertices(), and SOLID.

Referenced by drawCadstarCutoutsAsShapes(), and drawCadstarShape().

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

2718{
2719 if( !aKiCadTextItem->GetText().IsEmpty() )
2720 {
2721 VECTOR2I positionOffset( 0, aKiCadTextItem->GetInterline() );
2722 RotatePoint( positionOffset, aKiCadTextItem->GetTextAngle() );
2723
2724 EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
2725
2726 if( textEdaItem &&
2727 ( textEdaItem->Type() == LIB_TEXT_T || textEdaItem->Type() == LIB_FIELD_T ) )
2728 {
2729 // Y coordinate increases upwards in the symbol editor
2730 positionOffset.y = -positionOffset.y;
2731 }
2732
2733 //Count num of additional lines
2734 wxString text = aKiCadTextItem->GetText();
2735 int numExtraLines = text.Replace( "\n", "\n" );
2736 numExtraLines -= text.at( text.size() - 1 ) == '\n'; // Ignore new line character at end
2737 positionOffset.x *= numExtraLines;
2738 positionOffset.y *= numExtraLines;
2739
2740 aKiCadTextItem->Offset( positionOffset );
2741 }
2742}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:497
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389
@ LIB_TEXT_T
Definition: typeinfo.h:200
@ LIB_FIELD_T
Definition: typeinfo.h:208

References EDA_TEXT::GetInterline(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), LIB_FIELD_T, LIB_TEXT_T, EDA_TEXT::Offset(), RotatePoint(), text, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ generateLibName()

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

Definition at line 1429 of file cadstar_archive_parser.h.

1430 {
1431 return aRefName
1432 + ( ( aAlternateName.size() > 0 ) ? ( wxT( " (" ) + aAlternateName + wxT( ")" ) )
1433 : wxT( "" ) );
1434 }

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary().

◆ getAngle()

EDA_ANGLE CADSTAR_PCB_ARCHIVE_LOADER::getAngle ( const long long &  aCadstarAngle)
inlineprivate
Parameters
aCadstarAngle
Returns

Definition at line 469 of file cadstar_pcb_archive_loader.h.

470 {
471 // CADSTAR v6 (which outputted Format Version 8) and earlier versions used 1/10 degree
472 // as the unit for angles/orientations. It is assumed that CADSTAR version 7 (i.e. Format
473 // Version 9 and later) is the version that introduced 1/1000 degree for angles.
474 if( Header.Format.Version > 8 )
475 {
476 return EDA_ANGLE( aCadstarAngle / 1000.0, DEGREES_T );
477 }
478 else
479 {
480 return EDA_ANGLE( (int) aCadstarAngle, TENTHS_OF_A_DEGREE_T );
481 }
482 }
@ DEGREES_T
Definition: eda_angle.h:31
long Version
Archive version number (e.g.

References DEGREES_T, CADSTAR_ARCHIVE_PARSER::HEADER::Format, CADSTAR_PCB_ARCHIVE_PARSER::Header, TENTHS_OF_A_DEGREE_T, and CADSTAR_ARCHIVE_PARSER::FORMAT::Version.

Referenced by addAttribute(), checkAndLogHatchCode(), drawCadstarText(), getHatchCodeAngle(), getKiCadPad(), and loadComponents().

◆ getAngleDegrees()

double CADSTAR_PCB_ARCHIVE_LOADER::getAngleDegrees ( const long long &  aCadstarAngle)
inlineprivate
Parameters
aCadstarAngle
Returns

Definition at line 489 of file cadstar_pcb_archive_loader.h.

490 {
491 return getAngleTenthDegree( aCadstarAngle ) / 10.0;
492 }
double getAngleTenthDegree(const long long &aCadstarAngle)

References getAngleTenthDegree().

Referenced by loadDimensions().

◆ getAngleTenthDegree()

double CADSTAR_PCB_ARCHIVE_LOADER::getAngleTenthDegree ( const long long &  aCadstarAngle)
inlineprivate
Parameters
aCadstarAngle
Returns

Definition at line 449 of file cadstar_pcb_archive_loader.h.

450 {
451 // CADSTAR v6 (which outputted Format Version 8) and earlier versions used 1/10 degree
452 // as the unit for angles/orientations. It is assumed that CADSTAR version 7 (i.e. Format
453 // Version 9 and later) is the version that introduced 1/1000 degree for angles.
454 if( Header.Format.Version > 8 )
455 {
456 return (double) aCadstarAngle / 100.0;
457 }
458 else
459 {
460 return (double) aCadstarAngle;
461 }
462 }

References CADSTAR_ARCHIVE_PARSER::HEADER::Format, CADSTAR_PCB_ARCHIVE_PARSER::Header, and CADSTAR_ARCHIVE_PARSER::FORMAT::Version.

Referenced by getAngleDegrees(), and loadDocumentationSymbols().

◆ getAttributeName()

wxString CADSTAR_PCB_ARCHIVE_LOADER::getAttributeName ( const ATTRIBUTE_ID aCadstarAttributeID)
private

Definition at line 3441 of file cadstar_pcb_archive_loader.cpp.

3442{
3443 wxCHECK( Assignments.Codedefs.AttributeNames.find( aCadstarAttributeID )
3445 wxEmptyString );
3446
3447 return Assignments.Codedefs.AttributeNames.at( aCadstarAttributeID ).Name;
3448}
std::map< ATTRIBUTE_ID, ATTRNAME > AttributeNames

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_ARCHIVE_PARSER::CODEDEFS::AttributeNames, and CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs.

Referenced by addAttribute().

◆ getAttributeValue()

wxString CADSTAR_PCB_ARCHIVE_LOADER::getAttributeValue ( const ATTRIBUTE_ID aCadstarAttributeID,
const std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > &  aCadstarAttributeMap 
)
private

Definition at line 3451 of file cadstar_pcb_archive_loader.cpp.

3453{
3454 wxCHECK( aCadstarAttributeMap.find( aCadstarAttributeID ) != aCadstarAttributeMap.end(),
3455 wxEmptyString );
3456
3457 return aCadstarAttributeMap.at( aCadstarAttributeID ).Value;
3458}

Referenced by loadComponentAttributes().

◆ getCopperCode()

CADSTAR_PCB_ARCHIVE_LOADER::COPPERCODE CADSTAR_PCB_ARCHIVE_LOADER::getCopperCode ( const COPPERCODE_ID aCadstaCopperCodeID)
private

Definition at line 3386 of file cadstar_pcb_archive_loader.cpp.

3388{
3389 wxCHECK( Assignments.Codedefs.CopperCodes.find( aCadstaCopperCodeID )
3391 COPPERCODE() );
3392
3393 return Assignments.Codedefs.CopperCodes.at( aCadstaCopperCodeID );
3394}
std::map< COPPERCODE_ID, COPPERCODE > CopperCodes

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_PCB_ARCHIVE_PARSER::CODEDEFS_PCB::CopperCodes.

Referenced by loadCoppers(), loadLibraryCoppers(), and loadTemplates().

◆ getFootprintFromCadstarID()

FOOTPRINT * CADSTAR_PCB_ARCHIVE_LOADER::getFootprintFromCadstarID ( const COMPONENT_ID aCadstarComponentID)
private

Definition at line 3889 of file cadstar_pcb_archive_loader.cpp.

3891{
3892 if( m_componentMap.find( aCadstarComponentID ) == m_componentMap.end() )
3893 return nullptr;
3894 else
3895 return m_componentMap.at( aCadstarComponentID );
3896}
std::map< COMPONENT_ID, FOOTPRINT * > m_componentMap
Map between Cadstar and KiCad components on the board.

References m_componentMap.

Referenced by getKiCadNet(), and loadNets().

◆ getHatchCode()

CADSTAR_PCB_ARCHIVE_LOADER::HATCHCODE CADSTAR_PCB_ARCHIVE_LOADER::getHatchCode ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3493 of file cadstar_pcb_archive_loader.cpp.

3495{
3496 wxCHECK( Assignments.Codedefs.HatchCodes.find( aCadstarHatchcodeID )
3498 HATCHCODE() );
3499
3500 return Assignments.Codedefs.HatchCodes.at( aCadstarHatchcodeID );
3501}
std::map< HATCHCODE_ID, HATCHCODE > HatchCodes

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_ARCHIVE_PARSER::CODEDEFS::HatchCodes.

Referenced by checkAndLogHatchCode(), getHatchCodeAngle(), getKiCadHatchCodeGap(), and getKiCadHatchCodeThickness().

◆ getHatchCodeAngle()

EDA_ANGLE CADSTAR_PCB_ARCHIVE_LOADER::getHatchCodeAngle ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3504 of file cadstar_pcb_archive_loader.cpp.

3505{
3506 checkAndLogHatchCode( aCadstarHatchcodeID );
3507 HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3508
3509 if( hcode.Hatches.size() < 1 )
3511 else
3512 return getAngle( hcode.Hatches.at( 0 ).OrientAngle );
3513}
ZONE_SETTINGS & GetDefaultZoneSettings()
void checkAndLogHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
EDA_ANGLE m_HatchOrientation
Definition: zone_settings.h:88

References checkAndLogHatchCode(), getAngle(), BOARD_DESIGN_SETTINGS::GetDefaultZoneSettings(), BOARD::GetDesignSettings(), getHatchCode(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Hatches, m_board, and ZONE_SETTINGS::m_HatchOrientation.

Referenced by loadCoppers(), and loadTemplates().

◆ getKiCadCopperLayerID()

PCB_LAYER_ID CADSTAR_PCB_ARCHIVE_LOADER::getKiCadCopperLayerID ( unsigned int  aLayerNum,
bool  aDetectMaxLayer = true 
)
private
Parameters
aLayerNumPhysical / logical layer number (starts at 1)
aDetectMaxLayerIf true, returns B.Cu if the requested layer is the maximum layer
Returns
PCB_LAYER_ID

Definition at line 4023 of file cadstar_pcb_archive_loader.cpp.

4025{
4026 if( aDetectMaxLayer && aLayerNum == m_numCopperLayers )
4027 return PCB_LAYER_ID::B_Cu;
4028
4029 switch( aLayerNum )
4030 {
4031 case 1: return PCB_LAYER_ID::F_Cu;
4032 case 2: return PCB_LAYER_ID::In1_Cu;
4033 case 3: return PCB_LAYER_ID::In2_Cu;
4034 case 4: return PCB_LAYER_ID::In3_Cu;
4035 case 5: return PCB_LAYER_ID::In4_Cu;
4036 case 6: return PCB_LAYER_ID::In5_Cu;
4037 case 7: return PCB_LAYER_ID::In6_Cu;
4038 case 8: return PCB_LAYER_ID::In7_Cu;
4039 case 9: return PCB_LAYER_ID::In8_Cu;
4040 case 10: return PCB_LAYER_ID::In9_Cu;
4041 case 11: return PCB_LAYER_ID::In10_Cu;
4042 case 12: return PCB_LAYER_ID::In11_Cu;
4043 case 13: return PCB_LAYER_ID::In12_Cu;
4044 case 14: return PCB_LAYER_ID::In13_Cu;
4045 case 15: return PCB_LAYER_ID::In14_Cu;
4046 case 16: return PCB_LAYER_ID::In15_Cu;
4047 case 17: return PCB_LAYER_ID::In16_Cu;
4048 case 18: return PCB_LAYER_ID::In17_Cu;
4049 case 19: return PCB_LAYER_ID::In18_Cu;
4050 case 20: return PCB_LAYER_ID::In19_Cu;
4051 case 21: return PCB_LAYER_ID::In20_Cu;
4052 case 22: return PCB_LAYER_ID::In21_Cu;
4053 case 23: return PCB_LAYER_ID::In22_Cu;
4054 case 24: return PCB_LAYER_ID::In23_Cu;
4055 case 25: return PCB_LAYER_ID::In24_Cu;
4056 case 26: return PCB_LAYER_ID::In25_Cu;
4057 case 27: return PCB_LAYER_ID::In26_Cu;
4058 case 28: return PCB_LAYER_ID::In27_Cu;
4059 case 29: return PCB_LAYER_ID::In28_Cu;
4060 case 30: return PCB_LAYER_ID::In29_Cu;
4061 case 31: return PCB_LAYER_ID::In30_Cu;
4062 case 32: return PCB_LAYER_ID::B_Cu;
4063 }
4064
4066}
@ In22_Cu
Definition: layer_ids.h:86
@ In11_Cu
Definition: layer_ids.h:75
@ In29_Cu
Definition: layer_ids.h:93
@ In30_Cu
Definition: layer_ids.h:94
@ In17_Cu
Definition: layer_ids.h:81
@ In9_Cu
Definition: layer_ids.h:73
@ In19_Cu
Definition: layer_ids.h:83
@ In7_Cu
Definition: layer_ids.h:71
@ In28_Cu
Definition: layer_ids.h:92
@ In26_Cu
Definition: layer_ids.h:90
@ B_Cu
Definition: layer_ids.h:95
@ In21_Cu
Definition: layer_ids.h:85
@ In23_Cu
Definition: layer_ids.h:87
@ In15_Cu
Definition: layer_ids.h:79
@ In2_Cu
Definition: layer_ids.h:66
@ In10_Cu
Definition: layer_ids.h:74
@ In4_Cu
Definition: layer_ids.h:68
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ In16_Cu
Definition: layer_ids.h:80
@ In24_Cu
Definition: layer_ids.h:88
@ In1_Cu
Definition: layer_ids.h:65
@ In13_Cu
Definition: layer_ids.h:77
@ In8_Cu
Definition: layer_ids.h:72
@ In14_Cu
Definition: layer_ids.h:78
@ In12_Cu
Definition: layer_ids.h:76
@ In27_Cu
Definition: layer_ids.h:91
@ In6_Cu
Definition: layer_ids.h:70
@ In5_Cu
Definition: layer_ids.h:69
@ In3_Cu
Definition: layer_ids.h:67
@ In20_Cu
Definition: layer_ids.h:84
@ F_Cu
Definition: layer_ids.h:64
@ In18_Cu
Definition: layer_ids.h:82
@ In25_Cu
Definition: layer_ids.h:89

References B_Cu, F_Cu, In10_Cu, In11_Cu, In12_Cu, In13_Cu, In14_Cu, In15_Cu, In16_Cu, In17_Cu, In18_Cu, In19_Cu, In1_Cu, In20_Cu, In21_Cu, In22_Cu, In23_Cu, In24_Cu, In25_Cu, In26_Cu, In27_Cu, In28_Cu, In29_Cu, In2_Cu, In30_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu, In7_Cu, In8_Cu, In9_Cu, m_numCopperLayers, and UNDEFINED_LAYER.

Referenced by loadNetVia().

◆ getKiCadGroup()

PCB_GROUP * CADSTAR_PCB_ARCHIVE_LOADER::getKiCadGroup ( const GROUP_ID aCadstarGroupID)
private

Definition at line 3541 of file cadstar_pcb_archive_loader.cpp.

3542{
3543 wxCHECK( m_groupMap.find( aCadstarGroupID ) != m_groupMap.end(), nullptr );
3544
3545 return m_groupMap.at( aCadstarGroupID );
3546}

References m_groupMap.

Referenced by loadBoards().

◆ getKiCadHatchCodeGap()

int CADSTAR_PCB_ARCHIVE_LOADER::getKiCadHatchCodeGap ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3529 of file cadstar_pcb_archive_loader.cpp.

3530{
3531 checkAndLogHatchCode( aCadstarHatchcodeID );
3532 HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3533
3534 if( hcode.Hatches.size() < 1 )
3536 else
3537 return getKiCadLength( hcode.Hatches.at( 0 ).Step );
3538}

References checkAndLogHatchCode(), BOARD_DESIGN_SETTINGS::GetDefaultZoneSettings(), BOARD::GetDesignSettings(), getHatchCode(), getKiCadLength(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Hatches, m_board, and ZONE_SETTINGS::m_HatchGap.

Referenced by loadCoppers(), and loadTemplates().

◆ getKiCadHatchCodeThickness()

int CADSTAR_PCB_ARCHIVE_LOADER::getKiCadHatchCodeThickness ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3516 of file cadstar_pcb_archive_loader.cpp.

3518{
3519 checkAndLogHatchCode( aCadstarHatchcodeID );
3520 HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3521
3522 if( hcode.Hatches.size() < 1 )
3524 else
3525 return getKiCadLength( hcode.Hatches.at( 0 ).LineWidth );
3526}

References checkAndLogHatchCode(), BOARD_DESIGN_SETTINGS::GetDefaultZoneSettings(), BOARD::GetDesignSettings(), getHatchCode(), getKiCadLength(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Hatches, m_board, and ZONE_SETTINGS::m_HatchThickness.

Referenced by loadCoppers(), and loadTemplates().

◆ getKiCadLayer()

PCB_LAYER_ID CADSTAR_PCB_ARCHIVE_LOADER::getKiCadLayer ( const LAYER_ID aCadstarLayerID)
private
Parameters
aCadstarLayerID
Returns
PCB_LAYER_ID

Definition at line 4092 of file cadstar_pcb_archive_loader.cpp.

4093{
4094 if( getLayerType( aCadstarLayerID ) == LAYER_TYPE::NOLAYER )
4095 {
4096 //The "no layer" is common for CADSTAR documentation symbols
4097 //map it to undefined layer for later processing
4099 }
4100
4101 wxCHECK( m_layermap.find( aCadstarLayerID ) != m_layermap.end(),
4103
4104 return m_layermap.at( aCadstarLayerID );
4105}
LAYER_TYPE getLayerType(const LAYER_ID aCadstarLayerID)
std::map< LAYER_ID, PCB_LAYER_ID > m_layermap
Map between Cadstar and KiCad Layers.
@ NOLAYER
Inbuilt layer type (cannot be assigned to user layers)

References getLayerType(), m_layermap, CADSTAR_PCB_ARCHIVE_PARSER::NOLAYER, and UNDEFINED_LAYER.

Referenced by addAttribute(), applyDimensionSettings(), drawCadstarText(), getKiCadLayerSet(), getKiCadPad(), loadAreas(), loadCoppers(), loadFigures(), loadLibraryAreas(), loadLibraryCoppers(), loadLibraryFigures(), loadNetTracks(), and loadTemplates().

◆ getKiCadLayerSet()

LSET CADSTAR_PCB_ARCHIVE_LOADER::getKiCadLayerSet ( const LAYER_ID aCadstarLayerID)
private
Parameters
aCadstarLayerID
Returns
LSET

Definition at line 4108 of file cadstar_pcb_archive_loader.cpp.

4109{
4110 LAYER_TYPE layerType = getLayerType( aCadstarLayerID );
4111
4112 switch( layerType )
4113 {
4114 case LAYER_TYPE::ALLDOC:
4117
4120
4122 return LSET::AllLayersMask()
4124 ^ ( LSET( PCB_LAYER_ID::Rescue ) );
4125
4126 default:
4127 return LSET( getKiCadLayer( aCadstarLayerID ) );
4128 }
4129}
@ ALLELEC
Inbuilt layer type (cannot be assigned to user layers)
@ ALLDOC
Inbuilt layer type (cannot be assigned to user layers)
@ ALLLAYER
Inbuilt layer type (cannot be assigned to user layers)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET AllLayersMask()
Definition: lset.cpp:808
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
#define MAX_CU_LAYERS
Definition: layer_ids.h:140
@ Dwgs_User
Definition: layer_ids.h:109
@ Cmts_User
Definition: layer_ids.h:110
@ Eco1_User
Definition: layer_ids.h:111
@ Eco2_User
Definition: layer_ids.h:112
@ Rescue
Definition: layer_ids.h:133

References LSET::AllCuMask(), CADSTAR_PCB_ARCHIVE_PARSER::ALLDOC, CADSTAR_PCB_ARCHIVE_PARSER::ALLELEC, CADSTAR_PCB_ARCHIVE_PARSER::ALLLAYER, LSET::AllLayersMask(), Cmts_User, Dwgs_User, Eco1_User, Eco2_User, getKiCadLayer(), getLayerType(), m_numCopperLayers, MAX_CU_LAYERS, and Rescue.

Referenced by drawCadstarText(), loadAreas(), loadDocumentationSymbols(), and loadLibraryAreas().

◆ getKiCadLength()

int CADSTAR_PCB_ARCHIVE_LOADER::getKiCadLength ( long long  aCadstarLength)
inlineprivate

◆ getKiCadNet()

NETINFO_ITEM * CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet ( const NET_ID aCadstarNetID)
private

Searches m_netMap and returns the NETINFO_ITEM pointer if exists.

Otherwise creates a new one and adds it to m_board.

Parameters
aCadstarNetID
Returns

Definition at line 3910 of file cadstar_pcb_archive_loader.cpp.

3911{
3912 if( aCadstarNetID.IsEmpty() )
3913 {
3914 return nullptr;
3915 }
3916 else if( m_netMap.find( aCadstarNetID ) != m_netMap.end() )
3917 {
3918 return m_netMap.at( aCadstarNetID );
3919 }
3920 else
3921 {
3922 wxCHECK( Layout.Nets.find( aCadstarNetID ) != Layout.Nets.end(), nullptr );
3923
3924 NET_PCB csNet = Layout.Nets.at( aCadstarNetID );
3925 wxString newName = csNet.Name;
3926
3927 if( csNet.Name.IsEmpty() )
3928 {
3929 if( csNet.Pins.size() > 0 )
3930 {
3931 // Create default KiCad net naming:
3932
3933 NET_PCB::PIN firstPin = ( *csNet.Pins.begin() ).second;
3934 //we should have already loaded the component with loadComponents() :
3935 FOOTPRINT* m = getFootprintFromCadstarID( firstPin.ComponentID );
3936 newName = wxT( "Net-(" );
3937 newName << m->Reference().GetText();
3938 newName << wxT( "-Pad" ) << wxString::Format( wxT( "%ld" ), firstPin.PadID );
3939 newName << wxT( ")" );
3940 }
3941 else
3942 {
3943 wxFAIL_MSG( wxT( "A net with no pins associated?" ) );
3944 newName = wxT( "csNet-" );
3945 newName << wxString::Format( wxT( "%i" ), csNet.SignalNum );
3946 }
3947 }
3948
3949 if( !m_doneNetClassWarning && !csNet.NetClassID.IsEmpty()
3950 && csNet.NetClassID != wxT( "NONE" ) )
3951 {
3952 wxLogMessage( _( "The CADSTAR design contains nets with a 'Net Class' assigned. KiCad "
3953 "does not have an equivalent to CADSTAR's Net Class so these elements "
3954 "were not imported. Note: KiCad's version of 'Net Class' is closer to "
3955 "CADSTAR's 'Net Route Code' (which has been imported for all nets)." ) );
3956 m_doneNetClassWarning = true;
3957 }
3958
3959 if( !m_doneSpacingClassWarning && !csNet.SpacingClassID.IsEmpty()
3960 && csNet.SpacingClassID != wxT( "NONE" ) )
3961 {
3962 wxLogWarning( _( "The CADSTAR design contains nets with a 'Spacing Class' assigned. "
3963 "KiCad does not have an equivalent to CADSTAR's Spacing Class so "
3964 "these elements were not imported. Please review the design rules as "
3965 "copper pours will affected by this." ) );
3967 }
3968
3969 std::shared_ptr<NET_SETTINGS>& netSettings = m_board->GetDesignSettings().m_NetSettings;
3970 NETINFO_ITEM* netInfo = new NETINFO_ITEM( m_board, newName, ++m_numNets );
3971 std::shared_ptr<NETCLASS> netclass;
3972
3973 std::tuple<ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID> key = { csNet.RouteCodeID,
3974 csNet.NetClassID,
3975 csNet.SpacingClassID };
3976
3977 if( m_netClassMap.find( key ) != m_netClassMap.end() )
3978 {
3979 netclass = m_netClassMap.at( key );
3980 }
3981 else
3982 {
3983 wxString netClassName;
3984
3985 ROUTECODE rc = getRouteCode( csNet.RouteCodeID );
3986 netClassName += wxT( "Route code: " ) + rc.Name;
3987
3988 if( !csNet.NetClassID.IsEmpty() )
3989 {
3990 CADSTAR_NETCLASS nc = Assignments.Codedefs.NetClasses.at( csNet.NetClassID );
3991 netClassName += wxT( " | Net class: " ) + nc.Name;
3992 }
3993
3994 if( !csNet.SpacingClassID.IsEmpty() )
3995 {
3996 SPCCLASSNAME sp = Assignments.Codedefs.SpacingClassNames.at( csNet.SpacingClassID );
3997 netClassName += wxT( " | Spacing class: " ) + sp.Name;
3998 }
3999
4000 netclass.reset( new NETCLASS( *netSettings->m_DefaultNetClass ) );
4001 netclass->SetName( netClassName );
4002 netSettings->m_NetClasses[ netClassName ] = netclass;
4003 netclass->SetTrackWidth( getKiCadLength( rc.OptimalWidth ) );
4004 m_netClassMap.insert( { key, netclass } );
4005 }
4006
4007 m_board->GetDesignSettings().m_NetSettings->m_NetClassPatternAssignments.push_back(
4008 {
4009 std::make_unique<EDA_COMBINED_MATCHER>( newName, CTX_NETCLASS ),
4010 netclass->GetName()
4011 } );
4012
4013 netInfo->SetNetClass( netclass );
4014 m_board->Add( netInfo, ADD_MODE::APPEND );
4015 m_netMap.insert( { aCadstarNetID, netInfo } );
4016 return netInfo;
4017 }
4018
4019 return nullptr;
4020}
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::map< std::tuple< ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID >, std::shared_ptr< NETCLASS > > m_netClassMap
Map between Cadstar and KiCad classes.
FOOTPRINT * getFootprintFromCadstarID(const COMPONENT_ID &aCadstarComponentID)
std::map< NET_ID, NETINFO_ITEM * > m_netMap
Map between Cadstar and KiCad Nets.
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
Handle the data for a net.
Definition: netinfo.h:67
void SetNetClass(const std::shared_ptr< NETCLASS > &aNetClass)
@ CTX_NETCLASS
std::map< SPACING_CLASS_ID, SPCCLASSNAME > SpacingClassNames
std::map< NETCLASS_ID, CADSTAR_NETCLASS > NetClasses
std::map< NET_ID, NET_PCB > Nets
Contains tracks and vias.

References _, BOARD::Add(), APPEND, CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, CTX_NETCLASS, Format(), BOARD::GetDesignSettings(), getFootprintFromCadstarID(), getKiCadLength(), getRouteCode(), EDA_TEXT::GetText(), CADSTAR_PCB_ARCHIVE_PARSER::Layout, m_board, m_doneNetClassWarning, m_doneSpacingClassWarning, m_netClassMap, m_netMap, BOARD_DESIGN_SETTINGS::m_NetSettings, m_numNets, CADSTAR_ARCHIVE_PARSER::ROUTECODE::Name, CADSTAR_ARCHIVE_PARSER::CADSTAR_NETCLASS::Name, CADSTAR_ARCHIVE_PARSER::SPCCLASSNAME::Name, CADSTAR_ARCHIVE_PARSER::NET::Name, CADSTAR_ARCHIVE_PARSER::CODEDEFS::NetClasses, CADSTAR_ARCHIVE_PARSER::NET::NetClassID, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Nets, CADSTAR_ARCHIVE_PARSER::ROUTECODE::OptimalWidth, CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::Pins, FOOTPRINT::Reference(), CADSTAR_ARCHIVE_PARSER::NET::RouteCodeID, NETINFO_ITEM::SetNetClass(), CADSTAR_ARCHIVE_PARSER::NET::SignalNum, CADSTAR_ARCHIVE_PARSER::NET::SpacingClassID, and CADSTAR_ARCHIVE_PARSER::CODEDEFS::SpacingClassNames.

Referenced by loadCoppers(), loadNets(), loadNetTracks(), loadNetVia(), and loadTemplates().

◆ getKiCadPad()

PAD * CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad ( const COMPONENT_PAD aCadstarPad,
FOOTPRINT aParent 
)
private

Definition at line 923 of file cadstar_pcb_archive_loader.cpp.

924{
925 PADCODE csPadcode = getPadCode( aCadstarPad.PadCodeID );
926 wxString errorMSG;
927
928 std::unique_ptr<PAD> pad = std::make_unique<PAD>( aParent );
929 LSET padLayerSet;
930
931 switch( aCadstarPad.Side )
932 {
933 case PAD_SIDE::MAXIMUM: //Bottom side
934 padLayerSet |= LSET( 3, B_Cu, B_Paste, B_Mask );
935 break;
936
937 case PAD_SIDE::MINIMUM: //TOP side
938 padLayerSet |= LSET( 3, F_Cu, F_Paste, F_Mask );
939 break;
940
942 padLayerSet = LSET::AllCuMask() | LSET( 4, F_Mask, B_Mask, F_Paste, B_Paste );
943 break;
944
945 default:
946 wxFAIL_MSG( wxT( "Unknown Pad type" ) );
947 }
948
949 pad->SetAttribute( PAD_ATTRIB::SMD ); // assume SMD pad for now
950 pad->SetLocalSolderMaskMargin( 0 );
951 pad->SetLocalSolderPasteMargin( 0 );
952 pad->SetLocalSolderPasteMarginRatio( 0.0 );
953 bool complexPadErrorLogged = false;
954
955 for( auto& reassign : csPadcode.Reassigns )
956 {
957 PCB_LAYER_ID kiLayer = getKiCadLayer( reassign.first );
958 CADSTAR_PAD_SHAPE shape = reassign.second;
959
960 if( shape.Size == 0 )
961 {
962 padLayerSet.reset( kiLayer );
963 }
964 else
965 {
966 int newMargin = getKiCadLength( shape.Size - csPadcode.Shape.Size ) / 2;
967
968 if( kiLayer == F_Mask || kiLayer == B_Mask )
969 {
970 if( std::abs( pad->GetLocalSolderMaskMargin() ) < std::abs( newMargin ) )
971 pad->SetLocalSolderMaskMargin( newMargin );
972 }
973 else if( kiLayer == F_Paste || kiLayer == B_Paste )
974 {
975 if( std::abs( pad->GetLocalSolderPasteMargin() ) < std::abs( newMargin ) )
976 pad->SetLocalSolderPasteMargin( newMargin );
977 }
978 else
979 {
980 //TODO fix properly when KiCad supports full padstacks
981
982 if( !complexPadErrorLogged )
983 {
984 complexPadErrorLogged = true;
985 errorMSG +=
986 wxT( "\n - " )
988 _( "The CADSTAR pad definition '%s' is a complex pad stack, "
989 "which is not supported in KiCad. Please review the "
990 "imported pads as they may require manual correction." ),
991 csPadcode.Name );
992 }
993 }
994 }
995 }
996
997 pad->SetLayerSet( padLayerSet );
998
999 if( aCadstarPad.PCBonlyPad )
1000 {
1001 // PCB Only pads in CADSTAR do not have a representation in the schematic - they are
1002 // purely mechanical pads that have no net associated with them. Make the pad name
1003 // empty to avoid warnings when importing from the schematic
1004 pad->SetNumber( wxT( "" ) );
1005 }
1006 else
1007 {
1008 pad->SetNumber( aCadstarPad.Identifier.IsEmpty()
1009 ? wxString::Format( wxT( "%ld" ), aCadstarPad.ID )
1010 : aCadstarPad.Identifier );
1011 }
1012
1013 if( csPadcode.Shape.Size == 0 )
1014 {
1015 if( csPadcode.DrillDiameter == UNDEFINED_VALUE
1016 && aCadstarPad.Side == PAD_SIDE::THROUGH_HOLE )
1017 {
1018 // Through-hole, zero sized pad?. Lets load this just on the F_Mask for now to
1019 // prevent DRC errors.
1020 // TODO: This could be a custom padstack, update when KiCad supports padstacks
1021 pad->SetAttribute( PAD_ATTRIB::SMD );
1022 pad->SetLayerSet( LSET( 1, F_Mask ) );
1023 }
1024
1025 // zero sized pads seems to break KiCad so lets make it very small instead
1026 csPadcode.Shape.Size = 1;
1027 }
1028
1029 VECTOR2I padOffset = { 0, 0 }; // offset of the pad origin (before rotating)
1030 VECTOR2I drillOffset = { 0, 0 }; // offset of the drill origin w.r.t. the pad (before rotating)
1031
1032 switch( csPadcode.Shape.ShapeType )
1033 {
1035 //todo fix: use custom shape instead (Donught shape, i.e. a circle with a hole)
1036 pad->SetShape( PAD_SHAPE::CIRCLE );
1037 pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1038 getKiCadLength( csPadcode.Shape.Size ) } );
1039 break;
1040
1042 pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1043 pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1044 + (long long) csPadcode.Shape.LeftLength
1045 + (long long) csPadcode.Shape.RightLength ),
1046 getKiCadLength( csPadcode.Shape.Size ) } );
1049 pad->SetRoundRectRadiusRatio( 0.5 );
1050 pad->SetChamferRectRatio( 0.0 );
1051
1052 padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1053 ( (long long) csPadcode.Shape.RightLength / 2 ) );
1054 break;
1055
1057 pad->SetShape( PAD_SHAPE::CIRCLE );
1058 pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1059 getKiCadLength( csPadcode.Shape.Size ) } );
1060 break;
1061
1063 {
1064 // Cadstar diamond shape is a square rotated 45 degrees
1065 // We convert it in KiCad to a square with chamfered edges
1066 int sizeOfSquare = (double) getKiCadLength( csPadcode.Shape.Size ) * sqrt(2.0);
1067 pad->SetShape( PAD_SHAPE::RECT );
1068 pad->SetChamferRectRatio( 0.5 );
1069 pad->SetSize( { sizeOfSquare, sizeOfSquare } );
1070
1071 padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1072 ( (long long) csPadcode.Shape.RightLength / 2 ) );
1073 }
1074 break;
1075
1077 pad->SetShape( PAD_SHAPE::OVAL );
1078 pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1079 + (long long) csPadcode.Shape.LeftLength
1080 + (long long) csPadcode.Shape.RightLength ),
1081 getKiCadLength( csPadcode.Shape.Size ) } );
1082
1083 padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1084 ( (long long) csPadcode.Shape.RightLength / 2 ) );
1085 break;
1086
1088 pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1089 pad->SetChamferPositions( RECT_CHAMFER_POSITIONS::RECT_CHAMFER_ALL );
1090 pad->SetChamferRectRatio( 0.25 );
1091 pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1092 getKiCadLength( csPadcode.Shape.Size ) } );
1093 break;
1094
1096 pad->SetShape( PAD_SHAPE::RECT );
1097 pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1098 + (long long) csPadcode.Shape.LeftLength
1099 + (long long) csPadcode.Shape.RightLength ),
1100 getKiCadLength( csPadcode.Shape.Size ) } );
1101
1102 padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1103 ( (long long) csPadcode.Shape.RightLength / 2 ) );
1104 break;
1105
1107 pad->SetShape( PAD_SHAPE::RECT );
1108 pad->SetRoundRectCornerRadius( getKiCadLength( csPadcode.Shape.InternalFeature ) );
1109 pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1110 + (long long) csPadcode.Shape.LeftLength
1111 + (long long) csPadcode.Shape.RightLength ),
1112 getKiCadLength( csPadcode.Shape.Size ) } );
1113
1114 padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1115 ( (long long) csPadcode.Shape.RightLength / 2 ) );
1116 break;
1117
1118
1120 pad->SetShape( PAD_SHAPE::RECT );
1121 pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1122 getKiCadLength( csPadcode.Shape.Size ) } );
1123 break;
1124
1125 default:
1126 wxFAIL_MSG( wxT( "Unknown Pad Shape" ) );
1127 }
1128
1129 if( csPadcode.ReliefClearance != UNDEFINED_VALUE )
1130 pad->SetThermalGap( getKiCadLength( csPadcode.ReliefClearance ) );
1131
1132 if( csPadcode.ReliefWidth != UNDEFINED_VALUE )
1133 pad->SetThermalSpokeWidth( getKiCadLength( csPadcode.ReliefWidth ) );
1134
1135 if( csPadcode.DrillDiameter != UNDEFINED_VALUE )
1136 {
1137 if( csPadcode.SlotLength != UNDEFINED_VALUE )
1138 {
1140 pad->SetDrillSize( { getKiCadLength( (long long) csPadcode.SlotLength +
1141 (long long) csPadcode.DrillDiameter ),
1142 getKiCadLength( csPadcode.DrillDiameter ) } );
1143 }
1144 else
1145 {
1147 pad->SetDrillSize( { getKiCadLength( csPadcode.DrillDiameter ),
1148 getKiCadLength( csPadcode.DrillDiameter ) } );
1149 }
1150
1151 drillOffset.x = -getKiCadLength( csPadcode.DrillXoffset );
1152 drillOffset.y = getKiCadLength( csPadcode.DrillYoffset );
1153
1154 if( csPadcode.Plated )
1155 pad->SetAttribute( PAD_ATTRIB::PTH );
1156 else
1157 pad->SetAttribute( PAD_ATTRIB::NPTH );
1158 }
1159 else
1160 {
1161 pad->SetDrillSize( { 0, 0 } );
1162 }
1163
1164 if( csPadcode.SlotOrientation != 0 )
1165 {
1166 LSET lset = pad->GetLayerSet();
1167 lset &= LSET::AllCuMask();
1168
1169 if( lset.size() > 0 )
1170 {
1171 SHAPE_POLY_SET padOutline;
1172 PCB_LAYER_ID layer = lset.Seq().at( 0 );
1173 int maxError = m_board->GetDesignSettings().m_MaxError;
1174
1175 pad->SetPosition( { 0, 0 } );
1176 pad->SetPos0( { 0, 0 } );
1177 pad->TransformShapeToPolygon( padOutline, layer, 0, maxError, ERROR_INSIDE );
1178
1179 PCB_SHAPE* padShape = new PCB_SHAPE;
1180 padShape->SetShape( SHAPE_T::POLY );
1181 padShape->SetFilled( true );
1182 padShape->SetPolyShape( padOutline );
1183 padShape->SetStroke( STROKE_PARAMS( 0 ) );
1184 padShape->Move( padOffset - drillOffset );
1185 padShape->Rotate( VECTOR2I( 0, 0 ), ANGLE_180 - getAngle( csPadcode.SlotOrientation ) );
1186
1187 SHAPE_POLY_SET editedPadOutline = padShape->GetPolyShape();
1188
1189 if( editedPadOutline.Contains( { 0, 0 } ) )
1190 {
1191 pad->SetAnchorPadShape( PAD_SHAPE::RECT );
1192 pad->SetSize( wxSize( { 4, 4 } ) );
1193 pad->SetShape( PAD_SHAPE::CUSTOM );
1194 pad->AddPrimitive( padShape );
1195 padOffset = { 0, 0 };
1196 }
1197 else
1198 {
1199 // The CADSTAR pad has the hole shape outside the pad shape
1200 // Lets just put the hole in the center of the pad instead
1201 csPadcode.SlotOrientation = 0;
1202 drillOffset = { 0, 0 };
1203
1204 errorMSG +=
1205 wxT( "\n - " )
1207 _( "The CADSTAR pad definition '%s' has the hole shape outside the "
1208 "pad shape. The hole has been moved to the center of the pad." ),
1209 csPadcode.Name );
1210 }
1211 }
1212 else
1213 {
1214 wxFAIL_MSG( wxT( "No copper layers defined in the pad?" ) );
1215 csPadcode.SlotOrientation = 0;
1216 pad->SetOffset( drillOffset );
1217 }
1218 }
1219 else
1220 {
1221 pad->SetOffset( drillOffset );
1222 }
1223
1224 EDA_ANGLE padOrientation = getAngle( aCadstarPad.OrientAngle )
1225 + getAngle( csPadcode.Shape.OrientAngle );
1226
1227 RotatePoint( padOffset, padOrientation );
1228 RotatePoint( drillOffset, padOrientation );
1229 pad->SetPos0( getKiCadPoint( aCadstarPad.Position ) - aParent->GetPosition() - padOffset
1230 - drillOffset );
1231 pad->SetOrientation( padOrientation + getAngle( csPadcode.SlotOrientation ) );
1232
1233 //TODO handle csPadcode.Reassigns when KiCad supports full padstacks
1234
1235 //log warnings:
1236 if( m_padcodesTested.find( csPadcode.ID ) == m_padcodesTested.end() && !errorMSG.IsEmpty() )
1237 {
1238 wxLogError( _( "The CADSTAR pad definition '%s' has import errors: %s" ),
1239 csPadcode.Name,
1240 errorMSG );
1241
1242 m_padcodesTested.insert( csPadcode.ID );
1243 }
1244
1245 return pad.release();
1246}
static const long UNDEFINED_VALUE
std::set< PADCODE_ID > m_padcodesTested
Used by getKiCadPad() to avoid multiple duplicate warnings.
PADCODE getPadCode(const PADCODE_ID &aCadstarPadCodeID)
@ MAXIMUM
The highest PHYSICAL_LAYER_ID currently defined (i.e.
@ MINIMUM
PHYSICAL_LAYER_ID 1 (i.e.
@ THROUGH_HOLE
All physical layers currently defined.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:247
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:112
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:191
virtual void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:163
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:416
@ ERROR_INSIDE
@ F_Paste
Definition: layer_ids.h:101
@ B_Mask
Definition: layer_ids.h:106
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ NPTH
like PAD_PTH, but not plated
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ PAD_DRILL_SHAPE_CIRCLE
Definition: pad_shapes.h:70
@ PAD_DRILL_SHAPE_OBLONG
Definition: pad_shapes.h:71

References _, std::abs(), LSET::AllCuMask(), ANGLE_180, CADSTAR_PCB_ARCHIVE_PARSER::ANNULUS, B_Cu, B_Mask, B_Paste, CADSTAR_PCB_ARCHIVE_PARSER::BULLET, CHAMFERED_RECT, CIRCLE, CADSTAR_PCB_ARCHIVE_PARSER::CIRCLE, SHAPE_POLY_SET::Contains(), CUSTOM, CADSTAR_PCB_ARCHIVE_PARSER::DIAMOND, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::DrillDiameter, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::DrillXoffset, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::DrillYoffset, ERROR_INSIDE, F_Cu, F_Mask, F_Paste, CADSTAR_PCB_ARCHIVE_PARSER::FINGER, Format(), getAngle(), BOARD::GetDesignSettings(), getKiCadLayer(), getKiCadLength(), getKiCadPoint(), getPadCode(), EDA_SHAPE::GetPolyShape(), FOOTPRINT::GetPosition(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::ID, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::ID, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Identifier, CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::InternalFeature, CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::LeftLength, m_board, BOARD_DESIGN_SETTINGS::m_MaxError, m_padcodesTested, CADSTAR_PCB_ARCHIVE_PARSER::MAXIMUM, CADSTAR_PCB_ARCHIVE_PARSER::MINIMUM, PCB_SHAPE::Move(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Name, NPTH, CADSTAR_PCB_ARCHIVE_PARSER::OCTAGON, CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::OrientAngle, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::OrientAngle, OVAL, pad, PAD_DRILL_SHAPE_CIRCLE, PAD_DRILL_SHAPE_OBLONG, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::PadCodeID, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::PCBonlyPad, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Plated, POLY, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Position, PTH, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Reassigns, RECT, RECT_CHAMFER_ALL, RECT_CHAMFER_BOTTOM_LEFT, RECT_CHAMFER_TOP_LEFT, CADSTAR_PCB_ARCHIVE_PARSER::RECTANGLE, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::ReliefClearance, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::ReliefWidth, CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::RightLength, PCB_SHAPE::Rotate(), RotatePoint(), CADSTAR_PCB_ARCHIVE_PARSER::ROUNDED_RECT, LSET::Seq(), EDA_SHAPE::SetFilled(), EDA_SHAPE::SetPolyShape(), EDA_SHAPE::SetShape(), PCB_SHAPE::SetStroke(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Shape, CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::ShapeType, CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_PAD::Side, CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::Size, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::SlotLength, CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::SlotOrientation, SMD, CADSTAR_PCB_ARCHIVE_PARSER::SQUARE, CADSTAR_PCB_ARCHIVE_PARSER::THROUGH_HOLE, CADSTAR_ARCHIVE_PARSER::UNDEFINED_VALUE, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by loadComponents(), and loadLibraryPads().

◆ getKiCadPoint()

VECTOR2I CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPoint ( const VECTOR2I aCadstarPoint)
private

Scales, offsets and inverts y axis to make the point usable directly in KiCad.

Parameters
aCadstarPoint
Returns

Definition at line 3899 of file cadstar_pcb_archive_loader.cpp.

3900{
3901 VECTOR2I retval;
3902
3903 retval.x = ( aCadstarPoint.x - m_designCenter.x ) * KiCadUnitMultiplier;
3904 retval.y = -( aCadstarPoint.y - m_designCenter.y ) * KiCadUnitMultiplier;
3905
3906 return retval;
3907}

References CADSTAR_PCB_ARCHIVE_PARSER::KiCadUnitMultiplier, m_designCenter, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by addAttribute(), applyDimensionSettings(), drawCadstarText(), getKiCadPad(), getShapeFromVertex(), loadComponentLibrary(), loadComponents(), loadDimensions(), loadDocumentationSymbols(), loadLibraryCoppers(), and loadNetVia().

◆ getLayerPair()

CADSTAR_PCB_ARCHIVE_LOADER::LAYERPAIR CADSTAR_PCB_ARCHIVE_LOADER::getLayerPair ( const LAYERPAIR_ID aCadstarLayerPairID)
private

Definition at line 3430 of file cadstar_pcb_archive_loader.cpp.

3432{
3433 wxCHECK( Assignments.Codedefs.LayerPairs.find( aCadstarLayerPairID )
3435 LAYERPAIR() );
3436
3437 return Assignments.Codedefs.LayerPairs.at( aCadstarLayerPairID );
3438}
std::map< LAYERPAIR_ID, LAYERPAIR > LayerPairs
Default vias to use between pairs of layers.

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_PCB_ARCHIVE_PARSER::CODEDEFS_PCB::LayerPairs.

Referenced by loadNetVia().

◆ getLayerType()

CADSTAR_PCB_ARCHIVE_LOADER::LAYER_TYPE CADSTAR_PCB_ARCHIVE_LOADER::getLayerType ( const LAYER_ID  aCadstarLayerID)
private

◆ getLineChainFromShapes()

SHAPE_LINE_CHAIN CADSTAR_PCB_ARCHIVE_LOADER::getLineChainFromShapes ( const std::vector< PCB_SHAPE * >  aShapes)
private

Returns a SHAPE_LINE_CHAIN object from a series of PCB_SHAPE objects.

Parameters
aShapes
Returns

Definition at line 3013 of file cadstar_pcb_archive_loader.cpp.

3014{
3015 SHAPE_LINE_CHAIN lineChain;
3016
3017 for( PCB_SHAPE* shape : aShapes )
3018 {
3019 switch( shape->GetShape() )
3020 {
3021 case SHAPE_T::ARC:
3022 {
3023 if( shape->GetClass() == wxT( "MGRAPHIC" ) )
3024 {
3025 FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
3026 SHAPE_ARC arc( fp_shape->GetCenter0(), fp_shape->GetStart0(), fp_shape->GetArcAngle() );
3027
3028 if( shape->EndsSwapped() )
3029 arc.Reverse();
3030
3031 lineChain.Append( arc );
3032 }
3033 else
3034 {
3035 SHAPE_ARC arc( shape->GetCenter(), shape->GetStart(), shape->GetArcAngle() );
3036
3037 if( shape->EndsSwapped() )
3038 arc.Reverse();
3039
3040 lineChain.Append( arc );
3041 }
3042 }
3043 break;
3044 case SHAPE_T::SEGMENT:
3045 if( shape->GetClass() == wxT( "MGRAPHIC" ) )
3046 {
3047 FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
3048 lineChain.Append( fp_shape->GetStart0().x, fp_shape->GetStart0().y );
3049 lineChain.Append( fp_shape->GetEnd0().x, fp_shape->GetEnd0().y );
3050 }
3051 else
3052 {
3053 lineChain.Append( shape->GetStartX(), shape->GetStartY() );
3054 lineChain.Append( shape->GetEndX(), shape->GetEndY() );
3055 }
3056 break;
3057
3058 default:
3059 wxFAIL_MSG( wxT( "Drawsegment type is unexpected. Ignored." ) );
3060 }
3061 }
3062
3063 // Shouldn't have less than 3 points to make a closed shape!
3064 wxASSERT( lineChain.PointCount() > 2 );
3065
3066 // Check if it is closed
3067 if( lineChain.GetPoint( 0 ) != lineChain.GetPoint( lineChain.PointCount() - 1 ) )
3068 {
3069 lineChain.Append( lineChain.GetPoint( 0 ) );
3070 }
3071
3072 lineChain.SetClosed( true );
3073
3074 return lineChain;
3075}
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:585
const VECTOR2I & GetEnd0() const
Definition: fp_shape.h:95
VECTOR2I GetCenter0() const
Definition: fp_shape.cpp:144
const VECTOR2I & GetStart0() const
Definition: fp_shape.h:92
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual const VECTOR2I GetPoint(int aIndex) const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.

References SHAPE_LINE_CHAIN::Append(), ARC, EDA_SHAPE::GetArcAngle(), FP_SHAPE::GetCenter0(), FP_SHAPE::GetEnd0(), SHAPE_LINE_CHAIN::GetPoint(), FP_SHAPE::GetStart0(), SHAPE_LINE_CHAIN::PointCount(), SHAPE_ARC::Reverse(), SEGMENT, SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by getPolySetFromCadstarShape().

◆ getLineThickness()

int CADSTAR_PCB_ARCHIVE_LOADER::getLineThickness ( const LINECODE_ID aCadstarLineCodeID)
private

Definition at line 3376 of file cadstar_pcb_archive_loader.cpp.

3377{
3378 wxCHECK( Assignments.Codedefs.LineCodes.find( aCadstarLineCodeID )
3381
3382 return getKiCadLength( Assignments.Codedefs.LineCodes.at( aCadstarLineCodeID ).Width );
3383}
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
@ Edge_Cuts
Definition: layer_ids.h:113

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, Edge_Cuts, BOARD::GetDesignSettings(), getKiCadLength(), BOARD_DESIGN_SETTINGS::GetLineThickness(), CADSTAR_ARCHIVE_PARSER::CODEDEFS::LineCodes, and m_board.

Referenced by loadBoards(), loadDocumentationSymbols(), loadFigures(), and loadLibraryFigures().

◆ GetLoadedLibraryFootpints()

std::vector< FOOTPRINT * > CADSTAR_PCB_ARCHIVE_LOADER::GetLoadedLibraryFootpints ( ) const

Return a copy of the loaded library footprints (caller owns the objects)

Returns
Container with all the footprint definitions that were loaded

Definition at line 174 of file cadstar_pcb_archive_loader.cpp.

175{
176 std::vector<FOOTPRINT*> retval;
177
178 for( std::pair<SYMDEF_ID, FOOTPRINT*> fpPair : m_libraryMap )
179 {
180 retval.push_back( static_cast<FOOTPRINT*>( fpPair.second->Clone() ) );
181 }
182
183 return retval;
184}

References m_libraryMap.

Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN::Load().

◆ GetNumberOfChildNodes()

long CADSTAR_ARCHIVE_PARSER::GetNumberOfChildNodes ( XNODE aNode)
staticinherited

Definition at line 2675 of file cadstar_archive_parser.cpp.

2676{
2677 XNODE* childNodes = aNode->GetChildren();
2678 long retval = 0;
2679
2680 for( ; childNodes; childNodes = childNodes->GetNext() )
2681 retval++;
2682
2683 return retval;
2684}
Hold an XML or S-expression element.
Definition: xnode.h:44

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

2688{
2689 XNODE* level1Node = aRootNode->GetChildren();
2690 long retval = 0;
2691
2692 for( ; level1Node; level1Node = level1Node->GetNext() )
2693 {
2694 for( wxString childNodeName : aSubNodeChildrenToCount )
2695 {
2696 if( level1Node->GetName() == childNodeName )
2697 retval += GetNumberOfChildNodes( level1Node );
2698 }
2699
2700 retval++;
2701 }
2702
2703 return retval;
2704}
static long GetNumberOfChildNodes(XNODE *aNode)

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

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

◆ getPadCode()

CADSTAR_PCB_ARCHIVE_LOADER::PADCODE CADSTAR_PCB_ARCHIVE_LOADER::getPadCode ( const PADCODE_ID aCadstarPadCodeID)
private

Definition at line 3408 of file cadstar_pcb_archive_loader.cpp.

3410{
3411 wxCHECK( Assignments.Codedefs.PadCodes.find( aCadstarPadCodeID )
3412 != Assignments.Codedefs.PadCodes.end(),
3413 PADCODE() );
3414
3415 return Assignments.Codedefs.PadCodes.at( aCadstarPadCodeID );
3416}

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_PCB_ARCHIVE_PARSER::CODEDEFS_PCB::PadCodes.

Referenced by getKiCadPad(), and loadLibraryCoppers().

◆ getPadReference()

PAD *& CADSTAR_PCB_ARCHIVE_LOADER::getPadReference ( FOOTPRINT aFootprint,
const PAD_ID  aCadstarPadID 
)
private

Definition at line 1249 of file cadstar_pcb_archive_loader.cpp.

1251{
1252 size_t index = aCadstarPadID - (long) 1;
1253
1254 if( !( index < aFootprint->Pads().size() ) )
1255 {
1256 THROW_IO_ERROR( wxString::Format( _( "Unable to find pad index '%d' in footprint '%s'." ),
1257 (long) aCadstarPadID,
1258 aFootprint->GetReference() ) );
1259 }
1260
1261 return aFootprint->Pads().at( index );
1262}
PADS & Pads()
Definition: footprint.h:170
const wxString & GetReference() const
Definition: footprint.h:519

References _, Format(), FOOTPRINT::GetReference(), FOOTPRINT::Pads(), and THROW_IO_ERROR.

Referenced by loadComponents(), loadLibraryCoppers(), and loadNets().

◆ GetPadSide()

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

Definition at line 1004 of file cadstar_pcb_archive_parser.cpp.

1006{
1007 if( aPadSideString == wxT( "THRU" ) )
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}

References CADSTAR_PCB_ARCHIVE_PARSER::MAXIMUM, CADSTAR_PCB_ARCHIVE_PARSER::MINIMUM, and CADSTAR_PCB_ARCHIVE_PARSER::THROUGH_HOLE.

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

◆ getPart()

CADSTAR_PCB_ARCHIVE_LOADER::PART CADSTAR_PCB_ARCHIVE_LOADER::getPart ( const PART_ID aCadstarPartID)
private

Definition at line 3473 of file cadstar_pcb_archive_loader.cpp.

3475{
3476 wxCHECK( Parts.PartDefinitions.find( aCadstarPartID ) != Parts.PartDefinitions.end(), PART() );
3477
3478 return Parts.PartDefinitions.at( aCadstarPartID );
3479}
std::map< PART_ID, PART > PartDefinitions

References CADSTAR_ARCHIVE_PARSER::PARTS::PartDefinitions, and CADSTAR_PCB_ARCHIVE_PARSER::Parts.

Referenced by loadComponentAttributes(), and loadComponents().

◆ getPolySetFromCadstarShape()

SHAPE_POLY_SET CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape ( const SHAPE aCadstarShape,
const int &  aLineThickness = -1,
BOARD_ITEM_CONTAINER aContainer = nullptr,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private

Returns a SHAPE_POLY_SET object from a Cadstar SHAPE.

Parameters
aCadstarShape
aLineThicknessThickness of line is used for expanding the polygon by half.
aContainerto draw on (e.g. m_board). Can be nullptr.
aMoveVectormove poly by this amount (in KiCad coordinates)
aRotationAnglerotate poly by this amount (in tenth degrees)
aScalingFactorscale poly by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, mirrors the poly
Returns

Definition at line 2953 of file cadstar_pcb_archive_loader.cpp.

2961{
2962 GROUP_ID noGroup = wxEmptyString;
2963
2964 std::vector<PCB_SHAPE*> outlineShapes = getShapesFromVertices( aCadstarShape.Vertices,
2965 aContainer, noGroup, aMoveVector,
2966 aRotationAngle, aScalingFactor,
2967 aTransformCentre, aMirrorInvert );
2968
2969 SHAPE_POLY_SET polySet( getLineChainFromShapes( outlineShapes ) );
2970
2971 //cleanup
2972 for( PCB_SHAPE* shape : outlineShapes )
2973 delete shape;
2974
2975 for( CUTOUT cutout : aCadstarShape.Cutouts )
2976 {
2977 std::vector<PCB_SHAPE*> cutoutShapes = getShapesFromVertices( cutout.Vertices, aContainer,
2978 noGroup, aMoveVector,
2979 aRotationAngle, aScalingFactor,
2980 aTransformCentre, aMirrorInvert );
2981
2982 polySet.AddHole( getLineChainFromShapes( cutoutShapes ) );
2983
2984 //cleanup
2985 for( PCB_SHAPE* shape : cutoutShapes )
2986 delete shape;
2987 }
2988
2989 polySet.ClearArcs();
2990
2991 if( aLineThickness > 0 )
2992 {
2993 polySet.Inflate( aLineThickness / 2, 32,
2994 SHAPE_POLY_SET::CORNER_STRATEGY::ROUND_ALL_CORNERS );
2995 }
2996
2997#ifdef DEBUG
2998 for( int i = 0; i < polySet.OutlineCount(); ++i )
2999 {
3000 wxASSERT( polySet.Outline( i ).PointCount() > 2 );
3001
3002 for( int j = 0; j < polySet.HoleCount( i ); ++j )
3003 {
3004 wxASSERT( polySet.Hole( i, j ).PointCount() > 2 );
3005 }
3006 }
3007#endif
3008
3009 return polySet;
3010}
SHAPE_LINE_CHAIN getLineChainFromShapes(const std::vector< PCB_SHAPE * > aShapes)
Returns a SHAPE_LINE_CHAIN object from a series of PCB_SHAPE objects.

References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::ClearArcs(), CADSTAR_ARCHIVE_PARSER::SHAPE::Cutouts, getLineChainFromShapes(), getShapesFromVertices(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::HoleCount(), SHAPE_POLY_SET::Inflate(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), CADSTAR_ARCHIVE_PARSER::CUTOUT::Vertices, and CADSTAR_ARCHIVE_PARSER::SHAPE::Vertices.

Referenced by drawCadstarShape(), getZoneFromCadstarShape(), loadCoppers(), and loadLibraryCoppers().

◆ getRouteCode()

CADSTAR_PCB_ARCHIVE_LOADER::ROUTECODE CADSTAR_PCB_ARCHIVE_LOADER::getRouteCode ( const ROUTECODE_ID aCadstarRouteCodeID)
private

Definition at line 3482 of file cadstar_pcb_archive_loader.cpp.

3484{
3485 wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID )
3487 ROUTECODE() );
3488
3489 return Assignments.Codedefs.RouteCodes.at( aCadstarRouteCodeID );
3490}
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_ARCHIVE_PARSER::CODEDEFS::RouteCodes.

Referenced by getKiCadNet().

◆ getShapeFromVertex()

PCB_SHAPE * CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex ( const POINT aCadstarStartPoint,
const VERTEX aCadstarVertex,
BOARD_ITEM_CONTAINER aContainer = nullptr,
const GROUP_ID aCadstarGroupID = wxEmptyString,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private

Returns a pointer to a PCB_SHAPE object.

Caller owns the object.

Parameters
aCadstarStartPoint
aCadstarVertex
aContainerto draw on (e.g. m_board). Can be nullptr.
aCadstarGroupIDto add the shape to
aMoveVectormove shapes by this amount (in KiCad coordinates)
aRotationAnglerotate shapes by this amount (in tenth degrees)
aScalingFactorscale shapes by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, mirrors the shapes
Returns

Definition at line 2827 of file cadstar_pcb_archive_loader.cpp.

2836{
2837 PCB_SHAPE* shape = nullptr;
2838 bool cw = false;
2839
2840 VECTOR2I startPoint = getKiCadPoint( aCadstarStartPoint );
2841 VECTOR2I endPoint = getKiCadPoint( aCadstarVertex.End );
2842 VECTOR2I centerPoint;
2843
2844 if( aCadstarVertex.Type == VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE
2845 || aCadstarVertex.Type == VERTEX_TYPE::CLOCKWISE_SEMICIRCLE )
2846 {
2847 centerPoint = ( startPoint + endPoint ) / 2;
2848 }
2849 else
2850 {
2851 centerPoint = getKiCadPoint( aCadstarVertex.Center );
2852 }
2853
2854 switch( aCadstarVertex.Type )
2855 {
2856
2857 case VERTEX_TYPE::POINT:
2858
2859 if( isFootprint( aContainer ) )
2860 shape = new FP_SHAPE( static_cast<FOOTPRINT*>( aContainer ), SHAPE_T::SEGMENT );
2861 else
2862 shape = new PCB_SHAPE( aContainer, SHAPE_T::SEGMENT );
2863
2864 shape->SetStart( startPoint );
2865 shape->SetEnd( endPoint );
2866 break;
2867
2870 cw = true;
2872
2875 {
2876 if( isFootprint( aContainer ) )
2877 shape = new FP_SHAPE((FOOTPRINT*) aContainer, SHAPE_T::ARC );
2878 else
2879 shape = new PCB_SHAPE( aContainer, SHAPE_T::ARC );
2880
2881 shape->SetCenter( centerPoint );
2882 shape->SetStart( startPoint );
2883
2884 EDA_ANGLE arcStartAngle( startPoint - centerPoint );
2885 EDA_ANGLE arcEndAngle( endPoint - centerPoint );
2886 EDA_ANGLE arcAngle = arcEndAngle - arcStartAngle;
2887 //TODO: detect if we are supposed to draw a circle instead (i.e. two SEMICIRCLEs
2888 // with opposite start/end points and same centre point)
2889
2890 if( cw )
2891 shape->SetArcAngleAndEnd( arcAngle.Normalize() );
2892 else
2893 shape->SetArcAngleAndEnd( -arcAngle.Normalize(), true );
2894
2895 break;
2896 }
2897 }
2898
2899 //Apply transforms
2900 if( aMirrorInvert )
2901 shape->Flip( aTransformCentre, true );
2902
2903 if( aScalingFactor != 1.0 )
2904 {
2905 shape->Move( -1*aTransformCentre );
2906 shape->Scale( aScalingFactor );
2907 shape->Move( aTransformCentre );
2908 }
2909
2910 if( aRotationAngle != 0.0 )
2911 shape->Rotate( aTransformCentre, EDA_ANGLE( aRotationAngle, TENTHS_OF_A_DEGREE_T ) );
2912
2913 if( aMoveVector != VECTOR2I{ 0, 0 } )
2914 shape->Move( aMoveVector );
2915
2916 if( isFootprint( aContainer ) && shape != nullptr )
2917 static_cast<FP_SHAPE*>( shape )->SetLocalCoord();
2918
2919 if( !aCadstarGroupID.IsEmpty() )
2920 addToGroup( aCadstarGroupID, shape );
2921
2922 return shape;
2923}
EDA_ANGLE Normalize()
Definition: eda_angle.h:249
void SetCenter(const VECTOR2I &aCenter)
Definition: eda_shape.cpp:470
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
Definition: eda_shape.cpp:596
virtual void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_shape.cpp:197
void Scale(double aScale)
Definition: pcb_shape.cpp:169

References addToGroup(), CADSTAR_ARCHIVE_PARSER::ANTICLOCKWISE_ARC, CADSTAR_ARCHIVE_PARSER::ANTICLOCKWISE_SEMICIRCLE, ARC, CADSTAR_ARCHIVE_PARSER::VERTEX::Center, CADSTAR_ARCHIVE_PARSER::CLOCKWISE_ARC, CADSTAR_ARCHIVE_PARSER::CLOCKWISE_SEMICIRCLE, CADSTAR_ARCHIVE_PARSER::VERTEX::End, PCB_SHAPE::Flip(), getKiCadPoint(), isFootprint(), KI_FALLTHROUGH, PCB_SHAPE::Move(), EDA_ANGLE::Normalize(), CADSTAR_ARCHIVE_PARSER::POINT, PCB_SHAPE::Rotate(), PCB_SHAPE::Scale(), SEGMENT, EDA_SHAPE::SetArcAngleAndEnd(), EDA_SHAPE::SetCenter(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetStart(), TENTHS_OF_A_DEGREE_T, and CADSTAR_ARCHIVE_PARSER::VERTEX::Type.

Referenced by getShapesFromVertices(), and loadNetTracks().

◆ getShapesFromVertices()

std::vector< PCB_SHAPE * > CADSTAR_PCB_ARCHIVE_LOADER::getShapesFromVertices ( const std::vector< VERTEX > &  aCadstarVertices,
BOARD_ITEM_CONTAINER aContainer = nullptr,
const GROUP_ID aCadstarGroupID = wxEmptyString,
const VECTOR2I aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const VECTOR2I aTransformCentre = { 0, 0 },
const bool &  aMirrorInvert = false 
)
private

Returns a vector of pointers to PCB_SHAPE objects.

Caller owns the objects.

Parameters
aCadstarVertices
aContainerto draw on (e.g. m_board). Can be nullptr.
aCadstarGroupIDto add the shape to
aMoveVectormove shapes by this amount (in KiCad coordinates)
aRotationAnglerotate shapes by this amount (in tenth degrees)
aScalingFactorscale shapes by this amount
aTransformCentrearound which all transforms are applied (KiCad coordinates)
aMirrorInvertif true, mirrors the shapes
Returns

Definition at line 2795 of file cadstar_pcb_archive_loader.cpp.

2804{
2805 std::vector<PCB_SHAPE*> drawSegments;
2806
2807 if( aCadstarVertices.size() < 2 )
2808 //need at least two points to draw a segment! (unlikely but possible to have only one)
2809 return drawSegments;
2810
2811 const VERTEX* prev = &aCadstarVertices.at( 0 ); // first one should always be a point vertex
2812 const VERTEX* cur;
2813
2814 for( size_t i = 1; i < aCadstarVertices.size(); i++ )
2815 {
2816 cur = &aCadstarVertices.at( i );
2817 drawSegments.push_back( getShapeFromVertex( prev->End, *cur, aContainer, aCadstarGroupID,
2818 aMoveVector, aRotationAngle, aScalingFactor,
2819 aTransformCentre, aMirrorInvert ) );
2820 prev = cur;
2821 }
2822
2823 return drawSegments;
2824}
PCB_SHAPE * getShapeFromVertex(const POINT &aCadstarStartPoint, const VERTEX &aCadstarVertex, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a pointer to a PCB_SHAPE object.

References CADSTAR_ARCHIVE_PARSER::VERTEX::End, and getShapeFromVertex().

Referenced by drawCadstarVerticesAsShapes(), getPolySetFromCadstarShape(), and loadCoppers().

◆ getTextCode()

CADSTAR_PCB_ARCHIVE_LOADER::TEXTCODE CADSTAR_PCB_ARCHIVE_LOADER::getTextCode ( const TEXTCODE_ID aCadstarTextCodeID)
private

Definition at line 3397 of file cadstar_pcb_archive_loader.cpp.

3399{
3400 wxCHECK( Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID )
3402 TEXTCODE() );
3403
3404 return Assignments.Codedefs.TextCodes.at( aCadstarTextCodeID );
3405}
std::map< TEXTCODE_ID, TEXTCODE > TextCodes

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_ARCHIVE_PARSER::CODEDEFS::TextCodes.

Referenced by addAttribute(), applyDimensionSettings(), and drawCadstarText().

◆ getViaCode()

CADSTAR_PCB_ARCHIVE_LOADER::VIACODE CADSTAR_PCB_ARCHIVE_LOADER::getViaCode ( const VIACODE_ID aCadstarViaCodeID)
private

Definition at line 3419 of file cadstar_pcb_archive_loader.cpp.

3421{
3422 wxCHECK( Assignments.Codedefs.ViaCodes.find( aCadstarViaCodeID )
3423 != Assignments.Codedefs.ViaCodes.end(),
3424 VIACODE() );
3425
3426 return Assignments.Codedefs.ViaCodes.at( aCadstarViaCodeID );
3427}

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, and CADSTAR_PCB_ARCHIVE_PARSER::CODEDEFS_PCB::ViaCodes.

Referenced by loadNetVia().

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

2549{
2550 long retVal;
2551 bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
2552
2553 if( !success )
2554 {
2555 if( aIsRequired )
2556 THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
2557 else
2558 return UNDEFINED_VALUE;
2559 }
2560
2561 return retVal;
2562}
#define THROW_PARSING_IO_ERROR(param, location)
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_PCB_ARCHIVE_PARSER::NET_PCB::ROUTE_VERTEX::Parse(), CADSTAR_ARCHIVE_PARSER::FORMAT::Parse(), CADSTAR_ARCHIVE_PARSER::HATCH::Parse(), CADSTAR_ARCHIVE_PARSER::FONT::Parse(), CADSTAR_ARCHIVE_PARSER::TEXTCODE::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse(), CADSTAR_ARCHIVE_PARSER::POINT::Parse(), CADSTAR_ARCHIVE_PARSER::LONGPOINT::Parse(), CADSTAR_ARCHIVE_PARSER::GRID::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRNAME::COLUMNORDER::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRNAME::COLUMNWIDTH::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse(), CADSTAR_ARCHIVE_PARSER::REUSEBLOCK::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::GATE::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse(), CADSTAR_ARCHIVE_PARSER::PART::PART_PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::Parse(), CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::PIN_NUM_LABEL_LOC::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMATTR::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::PIN_NUM::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPREASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPERCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::REASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::CADSTAR_PAD_SHAPE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIACODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPCCLASSSPACE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TECHNOLOGY_SECTION::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_PCB_ARCHIVE_PARSER::SYMDEF_PCB::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PIN_ATTRIBUTE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADEXCEPTION::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::PIN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::COPPER_TERMINAL::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::POURING::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPER::NETREF::COPPER_TERM::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::DRILL_TABLE::Parse(), CADSTAR_ARCHIVE_PARSER::TEXT::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 2528 of file cadstar_archive_parser.cpp.

2530{
2531 wxString attrName, retVal;
2532 attrName = "attr";
2533 attrName << aID;
2534
2535 if( !aNode->GetAttribute( attrName, &retVal ) )
2536 {
2537 if( aIsRequired )
2538 THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
2539 else
2540 return wxEmptyString;
2541 }
2542
2543 return retVal;
2544}
#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_ARCHIVE_PARSER::FORMAT::Parse(), CADSTAR_ARCHIVE_PARSER::TIMESTAMP::Parse(), CADSTAR_ARCHIVE_PARSER::HEADER::Parse(), CADSTAR_ARCHIVE_PARSER::VARIANT::Parse(), CADSTAR_ARCHIVE_PARSER::LINECODE::Parse(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Parse(), CADSTAR_ARCHIVE_PARSER::FONT::Parse(), CADSTAR_ARCHIVE_PARSER::TEXTCODE::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse(), CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse(), CADSTAR_ARCHIVE_PARSER::EVALUE::Parse(), CADSTAR_ARCHIVE_PARSER::SHAPE::Parse(), CADSTAR_ARCHIVE_PARSER::GRID::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_ARCHIVE_PARSER::REUSEBLOCK::Parse(), CADSTAR_ARCHIVE_PARSER::REUSEBLOCKREF::Parse(), CADSTAR_ARCHIVE_PARSER::GROUP::Parse(), CADSTAR_ARCHIVE_PARSER::FIGURE::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::GATE::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse(), CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse(), CADSTAR_ARCHIVE_PARSER::PART::PART_PIN::Parse(), CADSTAR_ARCHIVE_PARSER::PART::Parse(), CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse(), CADSTAR_ARCHIVE_PARSER::DFLTSETTINGS::Parse(), CADSTAR_ARCHIVE_PARSER::ATTRCOL::Parse(), CADSTAR_ARCHIVE_PARSER::PARTNAMECOL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINALCODE::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::PIN_NUM_LABEL_LOC::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SHEETS::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::COMP::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::PARTREF::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SIGNALREFERENCELINK::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::SIGLOC::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::BUS::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::JUNCTION_SCH::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse(), CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BUS_TERM::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::MATERIAL::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERDEFS::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPREASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COPPERCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::REASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPACINGCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADREASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADCODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIAREASSIGN::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::VIACODE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::LAYERPAIR::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::SPCCLASSSPACE::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::RULESET::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_COPPER::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::COMPONENT_AREA::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_PCB_ARCHIVE_PARSER::CADSTAR_BOARD::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::PADEXCEPTION::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_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_PCB_ARCHIVE_PARSER::TEMPLATE::POURING::Parse(), CADSTAR_PCB_ARCHIVE_PARSER::TEMPLATE::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::TEXT::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(), CADSTAR_PCB_ARCHIVE_PARSER::ParseTestlandSide(), and CADSTAR_ARCHIVE_PARSER::ParseUnits().

◆ getZoneFromCadstarShape()

ZONE * CADSTAR_PCB_ARCHIVE_LOADER::getZoneFromCadstarShape ( const SHAPE aCadstarShape,
const int &  aLineThickness,
BOARD_ITEM_CONTAINER aParentContainer 
)
private
Parameters
aCadstarShape
aLineThicknessThickness of line to draw with
aParentContainerParent object (e.g. BOARD or FOOTPRINT pointer)
Returns
Pointer to ZONE. Caller owns the object.

Definition at line 2926 of file cadstar_pcb_archive_loader.cpp.

2929{
2930 ZONE* zone = new ZONE( aParentContainer, isFootprint( aParentContainer ) );
2931
2932 if( aCadstarShape.Type == SHAPE_TYPE::HATCHED )
2933 {
2936 }
2937 else
2938 {
2940 }
2941
2942 SHAPE_POLY_SET polygon = getPolySetFromCadstarShape( aCadstarShape, aLineThickness );
2943
2944 zone->AddPolygon( polygon.COutline( 0 ) );
2945
2946 for( int i = 0; i < polygon.HoleCount( 0 ); i++ )
2947 zone->AddPolygon( polygon.CHole( 0, i ) );
2948
2949 return zone;
2950}
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:743
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:581
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:173

References ZONE::AddPolygon(), SHAPE_POLY_SET::CHole(), SHAPE_POLY_SET::COutline(), DIAGONAL_FULL, getPolySetFromCadstarShape(), HATCH_PATTERN, CADSTAR_ARCHIVE_PARSER::HATCHED, SHAPE_POLY_SET::HoleCount(), isFootprint(), NO_HATCH, ZONE::SetFillMode(), ZONE::SetHatchStyle(), and CADSTAR_ARCHIVE_PARSER::SHAPE::Type.

Referenced by loadAreas(), loadCoppers(), loadLibraryAreas(), and loadTemplates().

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

2708{
2709 wxString escapedText = aCadstarString;
2710
2711 escapedText.Replace( wxT( "'" ), wxT( "~" ) );
2712
2713 return ConvertToNewOverbarNotation( escapedText );
2714}
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().

◆ initStackupItem()

void CADSTAR_PCB_ARCHIVE_LOADER::initStackupItem ( const LAYER aCadstarLayer,
BOARD_STACKUP_ITEM aKiCadItem,
int  aDielectricSublayer 
)
private

Definition at line 214 of file cadstar_pcb_archive_loader.cpp.

217{
218 if( !aCadstarLayer.MaterialId.IsEmpty() )
219 {
220 MATERIAL material = Assignments.Layerdefs.Materials.at( aCadstarLayer.MaterialId );
221
222 aKiCadItem->SetMaterial( material.Name, aDielectricSublayer );
223 aKiCadItem->SetEpsilonR( material.Permittivity.GetDouble(), aDielectricSublayer );
224 aKiCadItem->SetLossTangent( material.LossTangent.GetDouble(), aDielectricSublayer );
225 //TODO add Resistivity when KiCad supports it
226 }
227
228 if( !aCadstarLayer.Name.IsEmpty() )
229 aKiCadItem->SetLayerName( aCadstarLayer.Name );
230
231 if( aCadstarLayer.Thickness != 0 )
232 aKiCadItem->SetThickness( getKiCadLength( aCadstarLayer.Thickness ), aDielectricSublayer );
233}
void SetThickness(int aThickness, int aDielectricSubLayer=0)
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
void SetLayerName(const wxString &aName)
Base material class that can be used to derive other material implementations.
Definition: material.h:240
std::map< MATERIAL_ID, MATERIAL > Materials

References CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_ARCHIVE_PARSER::EVALUE::GetDouble(), getKiCadLength(), CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Layerdefs, CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::LossTangent, CADSTAR_PCB_ARCHIVE_PARSER::LAYER::MaterialId, CADSTAR_PCB_ARCHIVE_PARSER::LAYERDEFS::Materials, CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Name, CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Name, CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Permittivity, BOARD_STACKUP_ITEM::SetEpsilonR(), BOARD_STACKUP_ITEM::SetLayerName(), BOARD_STACKUP_ITEM::SetLossTangent(), BOARD_STACKUP_ITEM::SetMaterial(), BOARD_STACKUP_ITEM::SetThickness(), and CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Thickness.

Referenced by loadBoardStackup().

◆ InsertAttributeAtEnd()

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

Definition at line 2397 of file cadstar_archive_parser.cpp.

2398{
2399 wxString result;
2400 int numAttributes = 0;
2401
2402 if( aNode->GetAttribute( wxT( "numAttributes" ), &result ) )
2403 {
2404 numAttributes = wxAtoi( result );
2405 aNode->DeleteAttribute( wxT( "numAttributes" ) );
2406 ++numAttributes;
2407 }
2408
2409 aNode->AddAttribute( wxT( "numAttributes" ), wxString::Format( wxT( "%i" ), numAttributes ) );
2410
2411 wxString paramName = wxT( "attr" );
2412 paramName << numAttributes;
2413
2414 aNode->AddAttribute( paramName, aValue );
2415}

References Format().

Referenced by CADSTAR_ARCHIVE_PARSER::LoadArchiveFile().

◆ isFootprint()

bool CADSTAR_PCB_ARCHIVE_LOADER::isFootprint ( BOARD_ITEM_CONTAINER aContainer)
inlineprivate

Definition at line 532 of file cadstar_pcb_archive_loader.h.

533 {
534 return aContainer && aContainer->Type() == PCB_FOOTPRINT_T;
535 }
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86

References PCB_FOOTPRINT_T, and EDA_ITEM::Type().

Referenced by drawCadstarShape(), getShapeFromVertex(), and getZoneFromCadstarShape().

◆ isLayerSet()

bool CADSTAR_PCB_ARCHIVE_LOADER::isLayerSet ( const LAYER_ID aCadstarLayerID)
private
Parameters
aCadstarLayerID
Returns
true if the layer corresponds to a KiCad LSET or false if the layer maps directly

Definition at line 4069 of file cadstar_pcb_archive_loader.cpp.

4070{
4071 wxCHECK( Assignments.Layerdefs.Layers.find( aCadstarLayerID )
4072 != Assignments.Layerdefs.Layers.end(),
4073 false );
4074
4075 LAYER& layer = Assignments.Layerdefs.Layers.at( aCadstarLayerID );
4076
4077 switch( layer.Type )
4078 {
4079 case LAYER_TYPE::ALLDOC:
4082 return true;
4083
4084 default:
4085 return false;
4086 }
4087
4088 return false;
4089}
Container to hold information pertinent to a layer of a BOARD.
Definition: board.h:156

References CADSTAR_PCB_ARCHIVE_PARSER::ALLDOC, CADSTAR_PCB_ARCHIVE_PARSER::ALLELEC, CADSTAR_PCB_ARCHIVE_PARSER::ALLLAYER, CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Layerdefs, CADSTAR_PCB_ARCHIVE_PARSER::LAYERDEFS::Layers, and CADSTAR_PCB_ARCHIVE_PARSER::LAYER::Type.

Referenced by drawCadstarText(), loadAreas(), and loadLibraryAreas().

◆ IsValidAttribute()

◆ Load()

void CADSTAR_PCB_ARCHIVE_LOADER::Load ( BOARD aBoard,
PROJECT aProject 
)

Loads a CADSTAR PCB Archive file into the KiCad BOARD object given.

Parameters
aBoard

Definition at line 52 of file cadstar_pcb_archive_loader.cpp.

53{
54 m_board = aBoard;
55 m_project = aProject;
56
58 m_progressReporter->SetNumPhases( 3 ); // (0) Read file, (1) Parse file, (2) Load file
59
60 Parse();
61
62 LONGPOINT designLimit = Assignments.Technology.DesignLimit;
63
64 //Note: can't use getKiCadPoint() due wxPoint being int - need long long to make the check
65 long long designSizeXkicad = (long long) designLimit.x * KiCadUnitMultiplier;
66 long long designSizeYkicad = (long long) designLimit.y * KiCadUnitMultiplier;
67
68 // Max size limited by the positive dimension of wxPoint (which is an int)
69 long long maxDesignSizekicad = std::numeric_limits<int>::max();
70
71 if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
72 {
74 _( "The design is too large and cannot be imported into KiCad. \n"
75 "Please reduce the maximum design size in CADSTAR by navigating to: \n"
76 "Design Tab -> Properties -> Design Options -> Maximum Design Size. \n"
77 "Current Design size: %.2f, %.2f millimeters. \n"
78 "Maximum permitted design size: %.2f, %.2f millimeters.\n" ),
79 (double) designSizeXkicad / PCB_IU_PER_MM,
80 (double) designSizeYkicad / PCB_IU_PER_MM,
81 (double) maxDesignSizekicad / PCB_IU_PER_MM,
82 (double) maxDesignSizekicad / PCB_IU_PER_MM ) );
83 }
84
87 / 2;
88
90 {
91 wxLogWarning(
92 _( "The selected file indicates that nets might be out of synchronisation "
93 "with the schematic. It is recommended that you carry out an 'Align Nets' "
94 "procedure in CADSTAR and re-import, to avoid inconsistencies between the "
95 "PCB and the schematic. " ) );
96 }
97
99 {
101
102 // Significantly most amount of time spent loading coppers compared to all the other steps
103 // (39 seconds vs max of 100ms in other steps). This is due to requirement of boolean
104 // operations to join them together into a single polygon.
105 long numSteps = Layout.Coppers.size();
106
107 // A large amount is also spent calculating zone priorities
108 numSteps += ( Layout.Templates.size() * Layout.Templates.size() ) / 2;
109
111 }
112
117 loadGroups();
118 loadBoards();
119 loadFigures();
120 loadTexts();
122 loadAreas();
126 loadCoppers(); // Progress reporting is here as significantly most amount of time spent
127
129 {
130 if( !calculateZonePriorities( id ) )
131 {
132 wxLogError( wxString::Format( _( "Unable to determine zone fill priorities for layer "
133 "'%s'. A best attempt has been made but it is "
134 "possible that DRC errors exist and that manual "
135 "editing of the zone priorities is required." ),
136 m_board->GetLayerName( id ) ) );
137 }
138 }
139
140 loadNets();
142
143 if( Layout.Trunks.size() > 0 )
144 {
145 wxLogWarning(
146 _( "The CADSTAR design contains Trunk routing elements, which have no KiCad "
147 "equivalent. These elements were not loaded." ) );
148 }
149
150 if( Layout.VariantHierarchy.Variants.size() > 0 )
151 {
152 wxLogWarning( wxString::Format(
153 _( "The CADSTAR design contains variants which has no KiCad equivalent. Only "
154 "the variant '%s' was loaded." ),
155 Layout.VariantHierarchy.Variants.begin()->second.Name ) );
156 }
157
158 if( Layout.ReuseBlocks.size() > 0 )
159 {
160 wxLogWarning(
161 _( "The CADSTAR design contains re-use blocks which has no KiCad equivalent. The "
162 "re-use block information has been discarded during the import." ) );
163 }
164
165 wxLogWarning( _( "CADSTAR fonts are different to the ones in KiCad. This will likely result "
166 "in alignment issues that may cause DRC errors. Please review the imported "
167 "text elements carefully and correct manually if required." ) );
168
169 wxLogMessage(
170 _( "The CADSTAR design has been imported successfully.\n"
171 "Please review the import errors and warnings (if any)." ) );
172}
constexpr double PCB_IU_PER_MM
Definition: base_units.h:71
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:452
void remapUnsureLayers()
Callback m_layerMappingHandler for layers we aren't sure of.
bool calculateZonePriorities(PCB_LAYER_ID &aLayer)
Tries to make a best guess as to the zone priorities based on the pour status.
virtual void SetNumPhases(int aNumPhases)=0
Set the number of phases.
virtual void BeginPhase(int aPhase)=0
Initialize the aPhase virtual zone of the dialog progress bar.
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
std::pair< POINT, POINT > DesignArea
std::map< REUSEBLOCK_ID, REUSEBLOCK > ReuseBlocks

References _, LSET::AllCuMask(), CADSTAR_PCB_ARCHIVE_PARSER::Assignments, PROGRESS_REPORTER::BeginPhase(), calculateZonePriorities(), CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Coppers, CADSTAR_ARCHIVE_PARSER::SETTINGS::DesignArea, CADSTAR_ARCHIVE_PARSER::SETTINGS::DesignLimit, Format(), BOARD::GetLayerName(), CADSTAR_PCB_ARCHIVE_PARSER::KiCadUnitMultiplier, CADSTAR_PCB_ARCHIVE_PARSER::Layout, loadAreas(), loadBoards(), loadBoardStackup(), loadComponentLibrary(), loadComponents(), loadCoppers(), loadDesignRules(), loadDimensions(), loadDocumentationSymbols(), loadFigures(), loadGroups(), loadNets(), loadTemplates(), loadTexts(), loadTextVariables(), m_board, m_designCenter, m_numCopperLayers, CADSTAR_ARCHIVE_PARSER::m_progressReporter, m_project, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::NetSynch, CADSTAR_PCB_ARCHIVE_PARSER::Parse(), PCB_IU_PER_MM, remapUnsureLayers(), CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::ReuseBlocks, PROGRESS_REPORTER::SetMaxProgress(), PROGRESS_REPORTER::SetNumPhases(), CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Technology, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Templates, THROW_IO_ERROR, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Trunks, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::VariantHierarchy, CADSTAR_ARCHIVE_PARSER::VARIANT_HIERARCHY::Variants, CADSTAR_PCB_ARCHIVE_PARSER::WARNING, CADSTAR_ARCHIVE_PARSER::LONGPOINT::x, and CADSTAR_ARCHIVE_PARSER::LONGPOINT::y.

Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN::Load().

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

2420{
2421 KEYWORD emptyKeywords[1] = {};
2422 XNODE * iNode = nullptr, *cNode = nullptr;
2423 int tok;
2424 bool cadstarFileCheckDone = false;
2425 wxString str;
2426 wxCSConv win1252( wxT( "windows-1252" ) );
2427 wxMBConv* conv = &win1252; // Initial testing suggests file encoding to be Windows-1252
2428 // More samples required.
2429
2430 // Open the file and get the file size
2431 FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
2432
2433 if( !fp )
2434 THROW_IO_ERROR( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
2435
2436 fseek( fp, 0L, SEEK_END );
2437 long fileSize = ftell( fp );
2438 rewind( fp );
2439
2440 DSNLEXER lexer( emptyKeywords, 0, nullptr, fp, aFileName );
2441
2442 auto currentProgress = [&]() -> double
2443 {
2444 return static_cast<double>( ftell( fp ) ) / fileSize;
2445 };
2446
2447 double previousReportedProgress = -1.0;
2448
2449 while( ( tok = lexer.NextTok() ) != DSN_EOF )
2450 {
2451 if( aProgressReporter && ( currentProgress() - previousReportedProgress ) > 0.01 )
2452 {
2453 if( !aProgressReporter->KeepRefreshing() )
2454 THROW_IO_ERROR( _( "File import cancelled by user." ) );
2455
2456 aProgressReporter->SetCurrentProgress( currentProgress() );
2457 previousReportedProgress = currentProgress();
2458 }
2459
2460 if( tok == DSN_RIGHT )
2461 {
2462 cNode = iNode;
2463 if( cNode )
2464 {
2465 iNode = cNode->GetParent();
2466 }
2467 else
2468 {
2469 //too many closing brackets
2470 THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2471 }
2472 }
2473 else if( tok == DSN_LEFT )
2474 {
2475 tok = lexer.NextTok();
2476 str = wxString( lexer.CurText(), *conv );
2477 cNode = new XNODE( wxXML_ELEMENT_NODE, str );
2478
2479 if( iNode )
2480 {
2481 //we will add it as attribute as well as child node
2482 InsertAttributeAtEnd( iNode, str );
2483 iNode->AddChild( cNode );
2484 }
2485 else if( !cadstarFileCheckDone )
2486 {
2487 if( cNode->GetName() != aFileTypeIdentifier )
2488 THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2489
2490 cadstarFileCheckDone = true;
2491 }
2492
2493 iNode = cNode;
2494 }
2495 else if( iNode )
2496 {
2497 str = wxString( lexer.CurText(), *conv );
2498 //Insert even if string is empty
2499 InsertAttributeAtEnd( iNode, str );
2500 }
2501 else
2502 {
2503 //not enough closing brackets
2504 THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2505 }
2506 }
2507
2508 // Not enough closing brackets
2509 if( iNode != nullptr )
2510 THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2511
2512 // Throw if no data was parsed
2513 if( cNode )
2514 return cNode;
2515 else
2516 THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
2517
2518 return nullptr;
2519}
static void InsertAttributeAtEnd(XNODE *aNode, wxString aValue)
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
@ DSN_LEFT
Definition: dsnlexer.h:67
@ DSN_RIGHT
Definition: dsnlexer.h:66
@ DSN_EOF
Definition: dsnlexer.h:69
Hold a keyword string and its unique integer token.
Definition: dsnlexer.h:40

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 CADSTAR_PCB_ARCHIVE_PARSER::Parse().

◆ loadAreas()

void CADSTAR_PCB_ARCHIVE_LOADER::loadAreas ( )
private

Definition at line 1584 of file cadstar_pcb_archive_loader.cpp.

1585{
1586 for( std::pair<AREA_ID, AREA> areaPair : Layout.Areas )
1587 {
1588 AREA& area = areaPair.second;
1589
1590 if( area.NoVias || area.NoTracks || area.Keepout || area.Routing )
1591 {
1592 int lineThickness = 0; // CADSTAR areas only use the line width for display purpose
1593 ZONE* zone = getZoneFromCadstarShape( area.Shape, lineThickness, m_board );
1594
1595 m_board->Add( zone, ADD_MODE::APPEND );
1596
1597 if( isLayerSet( area.LayerID ) )
1598 zone->SetLayerSet( getKiCadLayerSet( area.LayerID ) );
1599 else
1600 zone->SetLayer( getKiCadLayer( area.LayerID ) );
1601
1602 zone->SetIsRuleArea( true ); //import all CADSTAR areas as Keepout zones
1603 zone->SetDoNotAllowPads( false ); //no CADSTAR equivalent
1604 zone->SetZoneName( area.Name );
1605
1606 zone->SetDoNotAllowFootprints( area.Keepout );
1607
1608 zone->SetDoNotAllowTracks( area.NoTracks );
1609 zone->SetDoNotAllowCopperPour( area.NoTracks );
1610
1611 zone->SetDoNotAllowVias( area.NoVias );
1612
1613 if( area.Placement )
1614 {
1615 wxLogWarning( wxString::Format( _( "The CADSTAR area '%s' is marked as a placement "
1616 "area in CADSTAR. Placement areas are not "
1617 "supported in KiCad. Only the supported elements "
1618 "for the area were imported." ),
1619 area.Name ) );
1620 }
1621 }
1622 else
1623 {
1624 wxLogError( wxString::Format( _( "The CADSTAR area '%s' does not have a KiCad "
1625 "equivalent. Pure Placement areas are not supported." ),
1626 area.Name ) );
1627 }
1628
1629 //todo Process area.AreaHeight when KiCad supports 3D design rules
1630 //TODO process attributes
1631 //TODO process addition to a group
1632 //TODO process "swaprule"
1633 //TODO process re-use block
1634 }
1635}
ZONE * getZoneFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness, BOARD_ITEM_CONTAINER *aParentContainer)
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:708
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:705
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:260
void SetIsRuleArea(bool aEnable)
Definition: zone.h:704
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:707
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:706
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:266
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:709
void SetZoneName(const wxString &aName)
Definition: zone.h:125

References _, BOARD::Add(), APPEND, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Areas, Format(), getKiCadLayer(), getKiCadLayerSet(), getZoneFromCadstarShape(), isLayerSet(), CADSTAR_PCB_ARCHIVE_PARSER::AREA::Keepout, CADSTAR_PCB_ARCHIVE_PARSER::AREA::LayerID, CADSTAR_PCB_ARCHIVE_PARSER::Layout, m_board, CADSTAR_PCB_ARCHIVE_PARSER::AREA::Name, CADSTAR_PCB_ARCHIVE_PARSER::AREA::NoTracks, CADSTAR_PCB_ARCHIVE_PARSER::AREA::NoVias, CADSTAR_PCB_ARCHIVE_PARSER::AREA::Placement, CADSTAR_PCB_ARCHIVE_PARSER::AREA::Routing, ZONE::SetDoNotAllowCopperPour(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetIsRuleArea(), ZONE::SetLayer(), ZONE::SetLayerSet(), ZONE::SetZoneName(), and CADSTAR_PCB_ARCHIVE_PARSER::AREA::Shape.

Referenced by Load().

◆ loadBoards()

void CADSTAR_PCB_ARCHIVE_LOADER::loadBoards ( )
private

Definition at line 1312 of file cadstar_pcb_archive_loader.cpp.

1313{
1314 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair : Layout.Boards )
1315 {
1316 CADSTAR_BOARD& board = boardPair.second;
1317 GROUP_ID boardGroup = createUniqueGroupID( wxT( "Board" ) );
1319 getLineThickness( board.LineCodeID ),
1320 wxString::Format( wxT( "BOARD %s" ), board.ID ),
1321