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

Public Member Functions

 CADSTAR_PCB_ARCHIVE_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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 (wxPoint *aPointToOffset, const wxPoint &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)
 
double getHatchCodeAngleDegrees (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)
 
wxPoint getKiCadPoint (const wxPoint &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)
 
double getAngleDegrees (const long long &aCadstarAngle)
 
double getPolarAngle (const wxPoint &aPoint)
 
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 >, NETCLASSPTR > 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...
 
wxPoint 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...
 
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 110 of file cadstar_pcb_archive_loader.h.

◆ ATTRIBUTE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_ID
inherited

Definition at line 100 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 114 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 113 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 108 of file cadstar_archive_parser.h.

◆ GATE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::GATE_ID
inherited

Definition at line 103 of file cadstar_archive_parser.h.

◆ GROUP_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::GROUP_ID
inherited

Definition at line 109 of file cadstar_archive_parser.h.

◆ HATCHCODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::HATCHCODE_ID
inherited

Definition at line 93 of file cadstar_archive_parser.h.

◆ LAYER_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::LAYER_ID
inherited

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

Definition at line 98 of file cadstar_archive_parser.h.

◆ LAYERPAIR_ID

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

◆ NETCLASS_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NETCLASS_ID
inherited

Definition at line 95 of file cadstar_archive_parser.h.

◆ NETELEMENT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::NETELEMENT_ID
inherited

Definition at line 112 of file cadstar_archive_parser.h.

◆ PAD_ID

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

◆ PART_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::PART_ID
inherited

Definition at line 102 of file cadstar_archive_parser.h.

◆ PART_PIN_ID

typedef long CADSTAR_ARCHIVE_PARSER::PART_PIN_ID
inherited

Pin identifier in the part.

Definition at line 106 of file cadstar_archive_parser.h.

◆ PHYSICAL_LAYER_ID

Definition at line 59 of file cadstar_pcb_archive_parser.h.

◆ REUSEBLOCK_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::REUSEBLOCK_ID
inherited

Definition at line 110 of file cadstar_archive_parser.h.

◆ ROUTECODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::ROUTECODE_ID
inherited

Definition at line 94 of file cadstar_archive_parser.h.

◆ RULESET_ID

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 96 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 101 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 104 of file cadstar_archive_parser.h.

◆ TEXT_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::TEXT_ID
inherited

Definition at line 107 of file cadstar_archive_parser.h.

◆ TEXTCODE_ID

typedef wxString CADSTAR_ARCHIVE_PARSER::TEXTCODE_ID
inherited

Definition at line 97 of file cadstar_archive_parser.h.

◆ TRUNK_ID

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 99 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 CADSTAR_ARCHIVE_PARSER::ALIGNMENT
stronginherited

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

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

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

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

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

See also JUSTIFICATION

Enumerator
NO_ALIGNMENT 

NO_ALIGNMENT has different meaning depending on the object type.

TOPLEFT 
TOPCENTER 
TOPRIGHT 
CENTERLEFT 
CENTERCENTER 
CENTERRIGHT 
BOTTOMLEFT 
BOTTOMCENTER 
BOTTOMRIGHT 

Definition at line 576 of file cadstar_archive_parser.h.

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

◆ ANGUNITS

enum CADSTAR_ARCHIVE_PARSER::ANGUNITS
stronginherited
Enumerator
DEGREES 
RADIANS 

Definition at line 486 of file cadstar_archive_parser.h.

487  {
488  DEGREES,
489  RADIANS
490  };

◆ ATTROWNER

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

Only library Attributes.

PART_DEFINITION 

Only library Attributes.

PIN 
SIGNALREF 
SYMBOL 
SYMDEF 
TEMPLATE 
TESTPOINT 

Definition at line 630 of file cadstar_archive_parser.h.

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

◆ ATTRUSAGE

enum CADSTAR_ARCHIVE_PARSER::ATTRUSAGE
stronginherited
Enumerator
BOTH 

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

COMPONENT 

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

PART_DEFINITION 

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

PART_LIBRARY 

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

SYMBOL 

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

UNDEFINED 

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

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

Definition at line 653 of file cadstar_archive_parser.h.

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

◆ EMBEDDING

Enumerator
NONE 
ABOVE 
BELOW 

Definition at line 142 of file cadstar_pcb_archive_parser.h.

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

◆ GRID_TYPE

enum CADSTAR_ARCHIVE_PARSER::GRID_TYPE
stronginherited
Enumerator
FRACTIONALGRID 

Param1 = Units, Param2 = Divisor.

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

STEPGRID 

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

Definition at line 496 of file cadstar_archive_parser.h.

497  {
498  FRACTIONALGRID,
499  STEPGRID
501  };

◆ JUSTIFICATION

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

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

This only affects multiline text

See also ALIGNMENT

Enumerator
LEFT 
CENTER 
RIGHT 

Definition at line 602 of file cadstar_archive_parser.h.

◆ LAYER_SUBTYPE

Enumerator
LAYERSUBTYPE_NONE 
LAYERSUBTYPE_SILKSCREEN 
LAYERSUBTYPE_PLACEMENT 
LAYERSUBTYPE_ASSEMBLY 
LAYERSUBTYPE_SOLDERRESIST 
LAYERSUBTYPE_PASTE 
LAYERSUBTYPE_CLEARANCE 
LAYERSUBTYPE_ROUT 

Definition at line 119 of file cadstar_pcb_archive_parser.h.

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

◆ LAYER_TYPE

Enumerator
UNDEFINED 

Only used for error detection.

ALLLAYER 

Inbuilt layer type (cannot be assigned to user layers)

ALLELEC 

Inbuilt layer type (cannot be assigned to user layers)

ALLDOC 

Inbuilt layer type (cannot be assigned to user layers)

NOLAYER 

Inbuilt layer type (cannot be assigned to user layers)

ASSCOMPCOPP 

Inbuilt layer type (cannot be assigned to user layers)

JUMPERLAYER 

Inbuilt layer type (cannot be assigned to user layers)

ELEC 
POWER 
NONELEC 

This type has subtypes.

CONSTRUCTION 
DOC 

Definition at line 102 of file cadstar_pcb_archive_parser.h.

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

◆ LINESTYLE

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

Definition at line 280 of file cadstar_archive_parser.h.

◆ MATERIAL_LAYER_TYPE

Type of layer appropriate for the material being set up.

Enumerator
CONSTRUCTION 
ELECTRICAL 

Either.

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

Definition at line 81 of file cadstar_pcb_archive_parser.h.

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

◆ NETSYNCH

Enumerator
UNDEFINED 
WARNING 
FULL 

Definition at line 1153 of file cadstar_pcb_archive_parser.h.

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

◆ PAD_SHAPE_TYPE

Enumerator
ANNULUS 
BULLET 
CIRCLE 

Keyword "ROUND".

DIAMOND 
FINGER 
OCTAGON 
RECTANGLE 
ROUNDED_RECT 

Keyword "ROUNDED".

SQUARE 

Definition at line 259 of file cadstar_pcb_archive_parser.h.

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

◆ PAD_SIDE

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

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

Enumerator
MINIMUM 

PHYSICAL_LAYER_ID 1 (i.e.

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

MAXIMUM 

The highest PHYSICAL_LAYER_ID currently defined (i.e.

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

THROUGH_HOLE 

All physical layers currently defined.

Definition at line 480 of file cadstar_pcb_archive_parser.h.

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

◆ READABILITY

Sets the readability direction of text.

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

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

Enumerator
BOTTOM_TO_TOP 

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

TOP_TO_BOTTOM 

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

Definition at line 620 of file cadstar_archive_parser.h.

621  {
622  BOTTOM_TO_TOP,
623  TOP_TO_BOTTOM
624  };

◆ RESOLUTION

enum CADSTAR_ARCHIVE_PARSER::RESOLUTION
stronginherited
Enumerator
HUNDREDTH_MICRON 

Definition at line 242 of file cadstar_archive_parser.h.

243  {
244  HUNDREDTH_MICRON
245  };

◆ ROUTING_BIAS

Enumerator
UNBIASED 

Keyword "UNBIASED" (default)

Keyword "X_BIASED".

Keyword "Y_BIASED".

ANTI_ROUTE 

Keyword "ANTITRACK".

OBSTACLE 

Keyword "OBSTACLE".

Definition at line 132 of file cadstar_pcb_archive_parser.h.

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

◆ SHAPE_TYPE

enum CADSTAR_ARCHIVE_PARSER::SHAPE_TYPE
stronginherited
Enumerator
OPENSHAPE 

Unfilled open shape. Cannot have cutouts.

OUTLINE 

Unfilled closed shape.

SOLID 

Filled closed shape (solid fill).

HATCHED 

Filled closed shape (hatch fill).

Definition at line 450 of file cadstar_archive_parser.h.

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

◆ SWAP_RULE

enum CADSTAR_ARCHIVE_PARSER::SWAP_RULE
stronginherited

Corresponds to "Display when" Item property.

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

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

Enumerator
NO_SWAP 

Display when Unmirrored.

USE_SWAP_LAYER 

Display when Mirrored.

BOTH 

Always display (Mirrored and Unmirrored)

Definition at line 810 of file cadstar_archive_parser.h.

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

◆ SYMDEF_TYPE

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

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

Enumerator
COMPONENT 

Standard PCB Component definition.

JUMPER 

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

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

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

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

STARPOINT 

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

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

For a starpoint component to be valid:

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

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

TESTPOINT 

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

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

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

Definition at line 720 of file cadstar_pcb_archive_parser.h.

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

◆ TESTLAND_SIDE

Enumerator
NONE 
MAX 

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

MIN 

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

BOTH 

Definition at line 858 of file cadstar_pcb_archive_parser.h.

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

◆ TEXT_FIELD_NAME

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

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

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

Synthetic for flagging.

Definition at line 135 of file cadstar_archive_parser.h.

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

◆ UNITS

enum CADSTAR_ARCHIVE_PARSER::UNITS
stronginherited
Enumerator
DESIGN 

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

THOU 
INCH 
MICROMETRE 
MM 
CENTIMETER 
METER 

Definition at line 471 of file cadstar_archive_parser.h.

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

◆ VERTEX_TYPE

Enumerator
POINT 
CLOCKWISE_ARC 
CLOCKWISE_SEMICIRCLE 
ANTICLOCKWISE_ARC 
ANTICLOCKWISE_SEMICIRCLE 

Definition at line 416 of file cadstar_archive_parser.h.

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

Constructor & Destructor Documentation

◆ CADSTAR_PCB_ARCHIVE_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;
56  m_doneNetClassWarning = false;
57  m_numNets = 0;
58  m_numCopperLayers = 0 ;
59  m_progressReporter = aProgressReporter;
60  }
CADSTAR_PCB_ARCHIVE_PARSER(const wxString &aFilename)
LAYER_MAPPING_HANDLER m_layerMappingHandler
Callback to get layer mapping.
wxPoint 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.
bool m_doneNetClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
int m_numCopperLayers
Number of layers in the design.
bool m_logLayerWarnings
Used in loadBoardStackup()
bool m_doneCopperWarning
Used by loadCoppers() to avoid multiple duplicate warnings.
PROGRESS_REPORTER * m_progressReporter
int m_numNets
Number of nets loaded so far.

References m_board, m_designCenter, m_doneCopperWarning, m_doneNetClassWarning, m_doneSpacingClassWarning, m_layerMappingHandler, m_logLayerWarnings, m_numCopperLayers, m_numNets, CADSTAR_ARCHIVE_PARSER::m_progressReporter, and m_project.

◆ ~CADSTAR_PCB_ARCHIVE_LOADER()

CADSTAR_PCB_ARCHIVE_LOADER::~CADSTAR_PCB_ARCHIVE_LOADER ( )
inline

Definition at line 63 of file cadstar_pcb_archive_loader.h.

64  {
65  for( std::pair<SYMDEF_ID, FOOTPRINT*> libItem : m_libraryMap )
66  {
67  FOOTPRINT* footprint = libItem.second;
68 
69  if( footprint )
70  delete footprint;
71  }
72  }
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 3198 of file cadstar_pcb_archive_loader.cpp.

3202 {
3203  FP_TEXT* txt;
3204 
3205  if( aCadstarAttributeID == COMPONENT_NAME_ATTRID )
3206  {
3207  txt = &aFootprint->Reference(); //text should be set outside this function
3208  }
3209  else if( aCadstarAttributeID == PART_NAME_ATTRID )
3210  {
3211  if( aFootprint->Value().GetText().IsEmpty() )
3212  {
3213  // Use PART_NAME_ATTRID as the value is value field is blank
3214  aFootprint->SetValue( aAttributeValue );
3215  txt = &aFootprint->Value();
3216  }
3217  else
3218  {
3219  txt = new FP_TEXT( aFootprint );
3220  aFootprint->Add( txt );
3221  txt->SetText( aAttributeValue );
3222  }
3223  txt->SetVisible( false ); //make invisible to avoid clutter.
3224  }
3225  else if( aCadstarAttributeID != COMPONENT_NAME_2_ATTRID
3226  && getAttributeName( aCadstarAttributeID ) == wxT( "Value" ) )
3227  {
3228  if( !aFootprint->Value().GetText().IsEmpty() )
3229  {
3230  //copy the object
3231  aFootprint->Add( aFootprint->Value().Duplicate() );
3232  }
3233 
3234  aFootprint->SetValue( aAttributeValue );
3235  txt = &aFootprint->Value();
3236  txt->SetVisible( false ); //make invisible to avoid clutter.
3237  }
3238  else
3239  {
3240  txt = new FP_TEXT( aFootprint );
3241  aFootprint->Add( txt );
3242  txt->SetText( aAttributeValue );
3243  txt->SetVisible( false ); //make all user attributes invisible to avoid clutter.
3244  //TODO: Future improvement - allow user to decide what to do with attributes
3245  }
3246 
3247  wxPoint rotatedTextPos = getKiCadPoint( aCadstarAttrLoc.Position ) - aFootprint->GetPosition();
3248  RotatePoint( &rotatedTextPos, -aFootprint->GetOrientation() );
3249 
3250  txt->SetTextPos( getKiCadPoint( aCadstarAttrLoc.Position ) );
3251  txt->SetPos0( rotatedTextPos );
3252  txt->SetLayer( getKiCadLayer( aCadstarAttrLoc.LayerID ) );
3253  txt->SetMirrored( aCadstarAttrLoc.Mirror );
3254  txt->SetTextAngle(
3255  getAngleTenthDegree( aCadstarAttrLoc.OrientAngle ) - aFootprint->GetOrientation() );
3256 
3257  if( aCadstarAttrLoc.Mirror ) // If mirroring, invert angle to match CADSTAR
3258  txt->SetTextAngle( -txt->GetTextAngle() );
3259 
3260  TEXTCODE tc = getTextCode( aCadstarAttrLoc.TextCodeID );
3261 
3262  txt->SetTextThickness( getKiCadLength( tc.LineWidth ) );
3263 
3264  wxSize txtSize;
3265  txtSize.x = getKiCadLength( tc.Width );
3266 
3267  // The width is zero for all non-cadstar fonts. Using a width equal to the height seems
3268  // to work well for most fonts.
3269  if( txtSize.x == 0 )
3270  txtSize.x = getKiCadLength( tc.Height );
3271 
3272  txtSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
3273  txt->SetTextSize( txtSize );
3274  txt->SetKeepUpright( false ); //Keeping it upright seems to result in incorrect orientation
3275 
3276  switch( aCadstarAttrLoc.Alignment )
3277  {
3278  case ALIGNMENT::NO_ALIGNMENT: // Default for Single line text is Bottom Left
3281  case ALIGNMENT::BOTTOMLEFT:
3284  break;
3285 
3289  break;
3290 
3294  break;
3295 
3296  case ALIGNMENT::CENTERLEFT:
3299  break;
3300 
3304  break;
3305 
3309  break;
3310 
3311  case ALIGNMENT::TOPLEFT:
3314  break;
3315 
3316  case ALIGNMENT::TOPCENTER:
3319  break;
3320 
3321  case ALIGNMENT::TOPRIGHT:
3324  break;
3325 
3326  default:
3327  wxFAIL_MSG( wxT( "Unknown Alignment - needs review!" ) );
3328  }
3329 
3330  //TODO Handle different font types when KiCad can support it.
3331 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:209
int getKiCadLength(long long aCadstarLength)
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
double getAngleTenthDegree(const long long &aCadstarAngle)
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
void SetTextAngle(double aAngle) override
Definition: fp_text.cpp:73
#define COMPONENT_NAME_2_ATTRID
Component Name 2 Attribute ID - typically used for indicating the placement of designators in placeme...
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:267
double GetOrientation() const
Definition: footprint.h:191
double GetTextAngle() const
Definition: eda_text.h:195
#define COMPONENT_NAME_ATTRID
Component Name Attribute ID - typically used for placement of designators on silk screen.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:499
FP_TEXT & Reference()
Definition: footprint.h:500
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:223
#define PART_NAME_ATTRID
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.
void SetValue(const wxString &aValue)
Definition: footprint.h:493
wxString getAttributeName(const ATTRIBUTE_ID &aCadstarAttributeID)
void SetPos0(const wxPoint &aPos)
Definition: fp_text.h:165
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
void SetKeepUpright(bool aKeepUpright)
Definition: fp_text.h:115
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:222
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)
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:73
wxPoint GetPosition() const override
Definition: footprint.h:187
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
NO_ALIGNMENT has different meaning depending on the object type.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:144

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(), getAngleTenthDegree(), getAttributeName(), getKiCadLayer(), getKiCadLength(), getKiCadPoint(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), getTextCode(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_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(), FP_TEXT::SetKeepUpright(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), FP_TEXT::SetPos0(), EDA_TEXT::SetText(), FP_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 4116 of file cadstar_pcb_archive_loader.cpp.

4118 {
4119  wxCHECK( m_groupMap.find( aCadstarGroupID ) != m_groupMap.end(), );
4120 
4121  PCB_GROUP* parentGroup = m_groupMap.at( aCadstarGroupID );
4122  parentGroup->AddItem( aKiCadItem );
4123 }
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
Map between Cadstar and KiCad groups.

References 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 3593 of file cadstar_pcb_archive_loader.cpp.

3595 {
3596  UNITS dimensionUnits = aCadstarDim.LinearUnits;
3597  TEXTCODE txtCode = getTextCode( aCadstarDim.Text.TextCodeID );
3598  int correctedHeight = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( txtCode.Height ) );
3599  wxSize txtSize( getKiCadLength( txtCode.Width ), correctedHeight );
3600  LINECODE linecode = Assignments.Codedefs.LineCodes.at( aCadstarDim.Line.LineCodeID );
3601 
3602  aKiCadDim->SetLayer( getKiCadLayer( aCadstarDim.LayerID ) );
3603  aKiCadDim->SetPrecision( aCadstarDim.Precision );
3604  aKiCadDim->SetStart( getKiCadPoint( aCadstarDim.ExtensionLineParams.Start ) );
3605  aKiCadDim->SetEnd( getKiCadPoint( aCadstarDim.ExtensionLineParams.End ) );
3606  aKiCadDim->SetExtensionOffset( getKiCadLength( aCadstarDim.ExtensionLineParams.Offset ) );
3607  aKiCadDim->SetLineThickness( getKiCadLength( linecode.Width ) );
3608  aKiCadDim->Text().SetTextThickness( getKiCadLength( txtCode.LineWidth ) );
3609  aKiCadDim->Text().SetTextSize( txtSize );
3610 
3611  // Find prefix and suffix:
3612  wxString prefix = wxEmptyString;
3613  wxString suffix = wxEmptyString;
3614  size_t startpos = aCadstarDim.Text.Text.Find( wxT( "<@DISTANCE" ) );
3615 
3616  if( startpos != wxNOT_FOUND )
3617  {
3618  prefix = ParseTextFields( aCadstarDim.Text.Text.SubString( 0, startpos - 1 ), &m_context );
3619  wxString remainingStr = aCadstarDim.Text.Text.Mid( startpos );
3620  size_t endpos = remainingStr.Find( "@>" );
3621  suffix = ParseTextFields( remainingStr.Mid( endpos + 2 ), &m_context );
3622  }
3623 
3624  if( suffix.StartsWith( wxT( "mm" ) ) )
3625  {
3627  suffix = suffix.Mid( 2 );
3628  }
3629  else
3630  {
3632  }
3633 
3634  aKiCadDim->SetPrefix( prefix );
3635  aKiCadDim->SetSuffix( suffix );
3636 
3637  if( aCadstarDim.LinearUnits == UNITS::DESIGN )
3638  {
3639  // For now we will hardcode the units as per the original CADSTAR design.
3640  // TODO: update this when KiCad supports design units
3642  dimensionUnits = Assignments.Technology.Units;
3643  }
3644 
3645  switch( dimensionUnits )
3646  {
3647  case UNITS::METER:
3648  case UNITS::CENTIMETER:
3649  case UNITS::MICROMETRE:
3650  wxLogWarning( wxString::Format( _( "Dimension ID %s uses a type of unit that "
3651  "is not supported in KiCad. Millimeters were "
3652  "applied instead." ),
3653  aCadstarDim.ID ) );
3655  case UNITS::MM:
3657  break;
3658 
3659  case UNITS::INCH:
3660  aKiCadDim->SetUnitsMode( DIM_UNITS_MODE::INCHES );
3661  break;
3662 
3663  case UNITS::THOU:
3664  aKiCadDim->SetUnitsMode( DIM_UNITS_MODE::MILS );
3665  break;
3666 
3667  case UNITS::DESIGN:
3668  wxFAIL_MSG( wxT( "We should have handled design units before coming here!" ) );
3669  break;
3670  }
3671 }
int getKiCadLength(long long aCadstarLength)
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
void SetUnitsFormat(const DIM_UNITS_FORMAT aFormat)
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
PCB_TEXT & Text()
std::map< LINECODE_ID, LINECODE > LineCodes
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
void SetExtensionOffset(int aOffset)
UNITS Units
Units to display for linear dimensions.
void SetLineThickness(int aWidth)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
long UnitDisplPrecision
Number of decimal points to display for linear dimensions.
Inherits from design units (assumed Assignments->Technology->Units)
virtual void SetEnd(const wxPoint &aPoint)
void SetPrefix(const wxString &aPrefix)
#define _(s)
void SetSuffix(const wxString &aSuffix)
void SetPrecision(int aPrecision)
static wxString ParseTextFields(const wxString &aTextString, PARSER_CONTEXT *aParserContext)
Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)
virtual void SetStart(const wxPoint &aPoint)
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:73
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
void SetUnitsMode(DIM_UNITS_MODE aMode)

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, PCB_DIMENSION_BASE::Text(), CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Text, CADSTAR_ARCHIVE_PARSER::TEXT::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 ( wxPoint *  aPointToOffset,
const wxPoint &  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 3334 of file cadstar_pcb_archive_loader.cpp.

3337 {
3338  VECTOR2I v( *aPointToOffset - aRefPoint );
3339  int newLength = v.EuclideanNorm() - aOffsetAmount;
3340 
3341  if( newLength > 0 )
3342  {
3343  VECTOR2I offsetted = v.Resize( newLength ) + VECTOR2I( aRefPoint );
3344  aPointToOffset->x = offsetted.x;
3345  aPointToOffset->y = offsetted.y;
3346  }
3347  else
3348  {
3349  *aPointToOffset = aRefPoint; // zero length track. Needs to be removed to mimmick
3350  // cadstar behaviour
3351  }
3352 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:404

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 3673 of file cadstar_pcb_archive_loader.cpp.

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

References SHAPE_POLY_SET::Area(), CADSTAR_PCB_ARCHIVE_PARSER::Assignments, 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 3529 of file cadstar_pcb_archive_loader.cpp.

3530 {
3531  if( m_hatchcodesTested.find( aCadstarHatchcodeID ) != m_hatchcodesTested.end() )
3532  {
3533  return; //already checked
3534  }
3535  else
3536  {
3537  HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3538 
3539  if( hcode.Hatches.size() != 2 )
3540  {
3541  wxLogWarning( wxString::Format(
3542  _( "The CADSTAR Hatching code '%s' has %d hatches defined. "
3543  "KiCad only supports 2 hatches (crosshatching) 90 degrees apart. "
3544  "The imported hatching is crosshatched." ),
3545  hcode.Name, (int) hcode.Hatches.size() ) );
3546  }
3547  else
3548  {
3549  if( hcode.Hatches.at( 0 ).LineWidth != hcode.Hatches.at( 1 ).LineWidth )
3550  {
3551  wxLogWarning( wxString::Format(
3552  _( "The CADSTAR Hatching code '%s' has different line widths for each "
3553  "hatch. KiCad only supports one width for the hatching. The imported "
3554  "hatching uses the width defined in the first hatch definition, i.e. "
3555  "%.2f mm." ),
3556  hcode.Name,
3557  (double) ( (double) getKiCadLength( hcode.Hatches.at( 0 ).LineWidth ) )
3558  / 1E6 ) );
3559  }
3560 
3561  if( hcode.Hatches.at( 0 ).Step != hcode.Hatches.at( 1 ).Step )
3562  {
3563  wxLogWarning( wxString::Format(
3564  _( "The CADSTAR Hatching code '%s' has different step sizes for each "
3565  "hatch. KiCad only supports one step size for the hatching. The imported "
3566  "hatching uses the step size defined in the first hatching definition, "
3567  "i.e. %.2f mm." ),
3568  hcode.Name,
3569  (double) ( (double) getKiCadLength( hcode.Hatches.at( 0 ).Step ) )
3570  / 1E6 ) );
3571  }
3572 
3573  if( abs( hcode.Hatches.at( 0 ).OrientAngle - hcode.Hatches.at( 1 ).OrientAngle )
3574  != 90000 )
3575  {
3576  wxLogWarning( wxString::Format(
3577  _( "The hatches in CADSTAR Hatching code '%s' have an angle "
3578  "difference of %.1f degrees. KiCad only supports hatching 90 "
3579  "degrees apart. The imported hatching has two hatches 90 "
3580  "degrees apart, oriented %.1f degrees from horizontal." ),
3581  hcode.Name,
3582  getAngleDegrees( abs( hcode.Hatches.at( 0 ).OrientAngle
3583  - hcode.Hatches.at( 1 ).OrientAngle ) ),
3584  getAngleDegrees( hcode.Hatches.at( 0 ).OrientAngle ) ) );
3585  }
3586  }
3587 
3588  m_hatchcodesTested.insert( aCadstarHatchcodeID );
3589  }
3590 }
int getKiCadLength(long long aCadstarLength)
double getAngleDegrees(const long long &aCadstarAngle)
std::set< HATCHCODE_ID > m_hatchcodesTested
Used by checkAndLogHatchCode() to avoid multiple duplicate warnings.
#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
Definition: eserie.h:61
HATCHCODE getHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)

References _, E6, Format(), getAngleDegrees(), getHatchCode(), getKiCadLength(), CADSTAR_ARCHIVE_PARSER::HATCHCODE::Hatches, m_hatchcodesTested, and CADSTAR_ARCHIVE_PARSER::HATCHCODE::Name.

Referenced by getHatchCodeAngleDegrees(), 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 2645 of file cadstar_archive_parser.cpp.

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

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

Referenced by 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 4126 of file cadstar_pcb_archive_loader.cpp.

4128 {
4129  wxString groupName = aName;
4130  int num = 0;
4131 
4132  while( m_groupMap.find( groupName ) != m_groupMap.end() )
4133  {
4134  groupName = aName + wxT( "_" ) + wxString::Format( wxT( "%i" ), ++num );
4135  }
4136 
4137  PCB_GROUP* docSymGroup = new PCB_GROUP( m_board );
4138  m_board->Add( docSymGroup );
4139  docSymGroup->SetName( groupName );
4140  GROUP_ID groupID( groupName );
4141  m_groupMap.insert( { groupID, docSymGroup } );
4142 
4143  return groupID;
4144 }
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
Map between Cadstar and KiCad groups.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
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
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 wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2727 of file cadstar_pcb_archive_loader.cpp.

2737 {
2738  for( CUTOUT cutout : aCutouts )
2739  {
2740  drawCadstarVerticesAsShapes( cutout.Vertices, aKiCadLayer, aLineThickness, aContainer,
2741  aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2742  aTransformCentre, aMirrorInvert );
2743  }
2744 }
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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPE to draw the vertices on m_board object.
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 wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2665 of file cadstar_pcb_archive_loader.cpp.

2676 {
2677  switch( aCadstarShape.Type )
2678  {
2679  case SHAPE_TYPE::OPENSHAPE:
2680  case SHAPE_TYPE::OUTLINE:
2682  drawCadstarVerticesAsShapes( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
2683  aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2684  aScalingFactor, aTransformCentre, aMirrorInvert );
2685  drawCadstarCutoutsAsShapes( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness,
2686  aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2687  aScalingFactor, aTransformCentre, aMirrorInvert );
2688  break;
2689 
2690  case SHAPE_TYPE::HATCHED:
2692  wxLogWarning( wxString::Format(
2693  _( "The shape for '%s' is Hatch filled in CADSTAR, which has no KiCad equivalent. "
2694  "Using solid fill instead." ),
2695  aShapeName ) );
2696 
2697  case SHAPE_TYPE::SOLID:
2698  {
2699  PCB_SHAPE* shape;
2700 
2701  if( isFootprint( aContainer ) )
2702  shape = new FP_SHAPE( (FOOTPRINT*) aContainer, SHAPE_T::POLY );
2703  else
2704  shape = new PCB_SHAPE( aContainer, SHAPE_T::POLY );
2705 
2706  shape->SetFilled( true );
2707 
2709  aCadstarShape, -1, aContainer, aMoveVector, aRotationAngle, aScalingFactor,
2710  aTransformCentre, aMirrorInvert );
2711 
2712  shapePolys.Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_STRICTLY_SIMPLE );
2713 
2714  shape->SetPolyShape( shapePolys );
2715  shape->SetWidth( aLineThickness );
2716  shape->SetLayer( aKiCadLayer );
2717  aContainer->Add( shape, ADD_MODE::APPEND );
2718 
2719  if( !aCadstarGroupID.IsEmpty() )
2720  addToGroup( aCadstarGroupID, shape );
2721  }
2722  break;
2723  }
2724 }
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT)=0
Adds an item to the container.
void SetFilled(bool aFlag)
Definition: eda_shape.h:92
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:235
Filled closed shape (hatch fill).
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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPE to draw the vertices on m_board object.
Represent a set of closed polygons.
bool isFootprint(BOARD_ITEM_CONTAINER *aContainer)
#define _(s)
void SetWidth(int aWidth)
Definition: eda_shape.h:97
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
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
void addToGroup(const GROUP_ID &aCadstarGroupID, BOARD_ITEM *aKiCadItem)
Unfilled open shape. Cannot have cutouts.
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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPEs to draw the cutouts on m_board object.
SHAPE_TYPE Type() const
Return the type of the shape.
Definition: shape.h:94
Filled closed shape (solid fill).
SHAPE_POLY_SET getPolySetFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness=-1, BOARD_ITEM_CONTAINER *aContainer=nullptr, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a SHAPE_POLY_SET object from a Cadstar SHAPE.

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(), EDA_SHAPE::SetWidth(), CADSTAR_ARCHIVE_PARSER::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 wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2517 of file cadstar_pcb_archive_loader.cpp.

2522 {
2523  PCB_TEXT* txt = new PCB_TEXT( aContainer );
2524  aContainer->Add( txt );
2525  txt->SetText( aCadstarText.Text );
2526 
2527  wxPoint rotatedTextPos = getKiCadPoint( aCadstarText.Position );
2528  RotatePoint( &rotatedTextPos, aTransformCentre, aRotationAngle );
2529  rotatedTextPos.x =
2530  KiROUND( (double) ( rotatedTextPos.x - aTransformCentre.x ) * aScalingFactor );
2531  rotatedTextPos.y =
2532  KiROUND( (double) ( rotatedTextPos.y - aTransformCentre.y ) * aScalingFactor );
2533  rotatedTextPos += aTransformCentre;
2534  txt->SetTextPos( rotatedTextPos );
2535  txt->SetPosition( rotatedTextPos );
2536 
2537  txt->SetTextAngle( getAngleTenthDegree( aCadstarText.OrientAngle ) + aRotationAngle );
2538 
2539  txt->SetMirrored( aCadstarText.Mirror );
2540 
2541  TEXTCODE tc = getTextCode( aCadstarText.TextCodeID );
2542 
2543  txt->SetTextThickness( getKiCadLength( tc.LineWidth ) );
2544 
2545  wxSize unscaledTextSize;
2546  unscaledTextSize.x = getKiCadLength( tc.Width );
2547 
2548  // The width is zero for all non-cadstar fonts. Using a width equal to the height seems
2549  // to work well for most fonts.
2550  if( unscaledTextSize.x == 0 )
2551  unscaledTextSize.x = getKiCadLength( tc.Height );
2552 
2553  unscaledTextSize.y = KiROUND( TXT_HEIGHT_RATIO * (double) getKiCadLength( tc.Height ) );
2554  txt->SetTextSize( unscaledTextSize );
2555 
2556  switch( aCadstarText.Alignment )
2557  {
2558  case ALIGNMENT::NO_ALIGNMENT: // Default for Single line text is Bottom Left
2559  case ALIGNMENT::BOTTOMLEFT:
2562  break;
2563 
2567  break;
2568 
2572  break;
2573 
2574  case ALIGNMENT::CENTERLEFT:
2577  break;
2578 
2582  break;
2583 
2587  break;
2588 
2589  case ALIGNMENT::TOPLEFT:
2592  break;
2593 
2594  case ALIGNMENT::TOPCENTER:
2597  break;
2598 
2599  case ALIGNMENT::TOPRIGHT:
2602  break;
2603 
2604  default:
2605  wxFAIL_MSG( wxT( "Unknown Alignment - needs review!" ) );
2606  }
2607 
2608  if( aMirrorInvert )
2609  {
2610  txt->Flip( aTransformCentre, true );
2611  }
2612 
2613  //scale it after flipping:
2614  if( aScalingFactor != 1.0 )
2615  {
2616  wxSize scaledTextSize;
2617  scaledTextSize.x = KiROUND( (double) unscaledTextSize.x * aScalingFactor );
2618  scaledTextSize.y = KiROUND( (double) unscaledTextSize.y * aScalingFactor );
2619  txt->SetTextSize( scaledTextSize );
2620  txt->SetTextThickness(
2621  KiROUND( (double) getKiCadLength( tc.LineWidth ) * aScalingFactor ) );
2622  }
2623 
2624  txt->Move( aMoveVector );
2625 
2626  if( aCadstarText.Alignment == ALIGNMENT::NO_ALIGNMENT )
2628 
2629  LAYER_ID layersToDrawOn = aCadstarLayerOverride;
2630 
2631  if( layersToDrawOn.IsEmpty() )
2632  layersToDrawOn = aCadstarText.LayerID;
2633 
2634  if( isLayerSet( layersToDrawOn ) )
2635  {
2636  //Make a copy on each layer
2637 
2638  LSEQ layers = getKiCadLayerSet( layersToDrawOn ).Seq();
2639  PCB_TEXT* newtxt;
2640 
2641  for( PCB_LAYER_ID layer : layers )
2642  {
2643  txt->SetLayer( layer );
2644  newtxt = static_cast<PCB_TEXT*>( txt->Duplicate() );
2645  m_board->Add( newtxt, ADD_MODE::APPEND );
2646 
2647  if( !aCadstarGroupID.IsEmpty() )
2648  addToGroup( aCadstarGroupID, newtxt );
2649  }
2650 
2651  m_board->Remove( txt );
2652  delete txt;
2653  }
2654  else
2655  {
2656  txt->SetLayer( getKiCadLayer( layersToDrawOn ) );
2657 
2658  if( !aCadstarGroupID.IsEmpty() )
2659  addToGroup( aCadstarGroupID, txt );
2660  }
2661  //TODO Handle different font types when KiCad can support it.
2662 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:209
int getKiCadLength(long long aCadstarLength)
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT)=0
Adds an item to the container.
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
virtual void SetPosition(const wxPoint &aPos) override
Definition: pcb_text.h:81
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_text.cpp:172
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
double getAngleTenthDegree(const long long &aCadstarAngle)
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
void SetTextAngle(double aAngle) override
Definition: pcb_text.cpp:104
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:267
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
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 Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:223
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:477
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_text.h:86
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:222
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)
void addToGroup(const GROUP_ID &aCadstarGroupID, BOARD_ITEM *aKiCadItem)
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:73
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:710
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:180
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
bool isLayerSet(const LAYER_ID &aCadstarLayerID)
NO_ALIGNMENT has different meaning depending on the object type.
LSET getKiCadLayerSet(const LAYER_ID &aCadstarLayerID)
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:144

References BOARD_ITEM_CONTAINER::Add(), BOARD::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(), getAngleTenthDegree(), getKiCadLayer(), getKiCadLayerSet(), getKiCadLength(), getKiCadPoint(), getTextCode(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_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(), PCB_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), 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, and CADSTAR_ARCHIVE_PARSER::TEXTCODE::Width.

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 wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2747 of file cadstar_pcb_archive_loader.cpp.

2757 {
2758  std::vector<PCB_SHAPE*> shapes = getShapesFromVertices( aCadstarVertices, aContainer,
2759  aCadstarGroupID, aMoveVector,
2760  aRotationAngle, aScalingFactor,
2761  aTransformCentre, aMirrorInvert );
2762 
2763  for( PCB_SHAPE* shape : shapes )
2764  {
2765  shape->SetWidth( aLineThickness );
2766  shape->SetLayer( aKiCadLayer );
2767  shape->SetParent( aContainer );
2768  aContainer->Add( shape, ADD_MODE::APPEND );
2769  }
2770 }
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT)=0
Adds an item to the container.
std::vector< PCB_SHAPE * > getShapesFromVertices(const std::vector< VERTEX > &aCadstarVertices, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a vector of pointers to PCB_SHAPE objects.

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

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

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

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

Referenced by 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 1402 of file cadstar_archive_parser.h.

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

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary().

◆ getAngleDegrees()

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

Definition at line 467 of file cadstar_pcb_archive_loader.h.

468  {
469  return getAngleTenthDegree( aCadstarAngle ) / 10.0;
470  }
double getAngleTenthDegree(const long long &aCadstarAngle)

References getAngleTenthDegree().

Referenced by checkAndLogHatchCode(), getHatchCodeAngleDegrees(), and loadDimensions().

◆ getAngleTenthDegree()

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

Definition at line 447 of file cadstar_pcb_archive_loader.h.

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

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

Referenced by addAttribute(), drawCadstarText(), getAngleDegrees(), getKiCadPad(), loadComponents(), and loadDocumentationSymbols().

◆ getAttributeName()

wxString CADSTAR_PCB_ARCHIVE_LOADER::getAttributeName ( const ATTRIBUTE_ID aCadstarAttributeID)
private

Definition at line 3420 of file cadstar_pcb_archive_loader.cpp.

3421 {
3422  wxCHECK( Assignments.Codedefs.AttributeNames.find( aCadstarAttributeID )
3424  wxEmptyString );
3425 
3426  return Assignments.Codedefs.AttributeNames.at( aCadstarAttributeID ).Name;
3427 }
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 3430 of file cadstar_pcb_archive_loader.cpp.

3432 {
3433  wxCHECK( aCadstarAttributeMap.find( aCadstarAttributeID ) != aCadstarAttributeMap.end(),
3434  wxEmptyString );
3435 
3436  return aCadstarAttributeMap.at( aCadstarAttributeID ).Value;
3437 }

Referenced by loadComponentAttributes().

◆ getCopperCode()

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

◆ getFootprintFromCadstarID()

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

Definition at line 3872 of file cadstar_pcb_archive_loader.cpp.

3874 {
3875  if( m_componentMap.find( aCadstarComponentID ) == m_componentMap.end() )
3876  return nullptr;
3877  else
3878  return m_componentMap.at( aCadstarComponentID );
3879 }
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

◆ getHatchCodeAngleDegrees()

double CADSTAR_PCB_ARCHIVE_LOADER::getHatchCodeAngleDegrees ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3483 of file cadstar_pcb_archive_loader.cpp.

3485 {
3486  checkAndLogHatchCode( aCadstarHatchcodeID );
3487  HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3488 
3489  if( hcode.Hatches.size() < 1 )
3491  else
3492  return getAngleDegrees( hcode.Hatches.at( 0 ).OrientAngle );
3493 }
double getAngleDegrees(const long long &aCadstarAngle)
void checkAndLogHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
ZONE_SETTINGS & GetDefaultZoneSettings()
HATCHCODE getHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
double m_HatchOrientation
Definition: zone_settings.h:86

References checkAndLogHatchCode(), getAngleDegrees(), 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 4007 of file cadstar_pcb_archive_loader.cpp.

4009 {
4010  if( aDetectMaxLayer && aLayerNum == m_numCopperLayers )
4011  return PCB_LAYER_ID::B_Cu;
4012 
4013  switch( aLayerNum )
4014  {
4015  case 1: return PCB_LAYER_ID::F_Cu;
4016  case 2: return PCB_LAYER_ID::In1_Cu;
4017  case 3: return PCB_LAYER_ID::In2_Cu;
4018  case 4: return PCB_LAYER_ID::In3_Cu;
4019  case 5: return PCB_LAYER_ID::In4_Cu;
4020  case 6: return PCB_LAYER_ID::In5_Cu;
4021  case 7: return PCB_LAYER_ID::In6_Cu;
4022  case 8: return PCB_LAYER_ID::In7_Cu;
4023  case 9: return PCB_LAYER_ID::In8_Cu;
4024  case 10: return PCB_LAYER_ID::In9_Cu;
4025  case 11: return PCB_LAYER_ID::In10_Cu;
4026  case 12: return PCB_LAYER_ID::In11_Cu;
4027  case 13: return PCB_LAYER_ID::In12_Cu;
4028  case 14: return PCB_LAYER_ID::In13_Cu;
4029  case 15: return PCB_LAYER_ID::In14_Cu;
4030  case 16: return PCB_LAYER_ID::In15_Cu;
4031  case 17: return PCB_LAYER_ID::In16_Cu;
4032  case 18: return PCB_LAYER_ID::In17_Cu;
4033  case 19: return PCB_LAYER_ID::In18_Cu;
4034  case 20: return PCB_LAYER_ID::In19_Cu;
4035  case 21: return PCB_LAYER_ID::In20_Cu;
4036  case 22: return PCB_LAYER_ID::In21_Cu;
4037  case 23: return PCB_LAYER_ID::In22_Cu;
4038  case 24: return PCB_LAYER_ID::In23_Cu;
4039  case 25: return PCB_LAYER_ID::In24_Cu;
4040  case 26: return PCB_LAYER_ID::In25_Cu;
4041  case 27: return PCB_LAYER_ID::In26_Cu;
4042  case 28: return PCB_LAYER_ID::In27_Cu;
4043  case 29: return PCB_LAYER_ID::In28_Cu;
4044  case 30: return PCB_LAYER_ID::In29_Cu;
4045  case 31: return PCB_LAYER_ID::In30_Cu;
4046  case 32: return PCB_LAYER_ID::B_Cu;
4047  }
4048 
4050 }
int m_numCopperLayers
Number of layers in the design.
Definition: layer_ids.h:71

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 3521 of file cadstar_pcb_archive_loader.cpp.

3522 {
3523  wxCHECK( m_groupMap.find( aCadstarGroupID ) != m_groupMap.end(), nullptr );
3524 
3525  return m_groupMap.at( aCadstarGroupID );
3526 }
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
Map between Cadstar and KiCad groups.

References m_groupMap.

Referenced by loadBoards().

◆ getKiCadHatchCodeGap()

int CADSTAR_PCB_ARCHIVE_LOADER::getKiCadHatchCodeGap ( const HATCHCODE_ID aCadstarHatchcodeID)
private

Definition at line 3509 of file cadstar_pcb_archive_loader.cpp.

3510 {
3511  checkAndLogHatchCode( aCadstarHatchcodeID );
3512  HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3513 
3514  if( hcode.Hatches.size() < 1 )
3516  else
3517  return getKiCadLength( hcode.Hatches.at( 0 ).Step );
3518 }
int getKiCadLength(long long aCadstarLength)
void checkAndLogHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
ZONE_SETTINGS & GetDefaultZoneSettings()
HATCHCODE getHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)

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 3496 of file cadstar_pcb_archive_loader.cpp.

3498 {
3499  checkAndLogHatchCode( aCadstarHatchcodeID );
3500  HATCHCODE hcode = getHatchCode( aCadstarHatchcodeID );
3501 
3502  if( hcode.Hatches.size() < 1 )
3504  else
3505  return getKiCadLength( hcode.Hatches.at( 0 ).LineWidth );
3506 }
int getKiCadLength(long long aCadstarLength)
void checkAndLogHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
ZONE_SETTINGS & GetDefaultZoneSettings()
HATCHCODE getHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)

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 4076 of file cadstar_pcb_archive_loader.cpp.

4077 {
4078  if( getLayerType( aCadstarLayerID ) == LAYER_TYPE::NOLAYER )
4079  {
4080  //The "no layer" is common for CADSTAR documentation symbols
4081  //map it to undefined layer for later processing
4083  }
4084 
4085  wxCHECK( m_layermap.find( aCadstarLayerID ) != m_layermap.end(),
4087 
4088  return m_layermap.at( aCadstarLayerID );
4089 }
Inbuilt layer type (cannot be assigned to user layers)
LAYER_TYPE getLayerType(const LAYER_ID aCadstarLayerID)
std::map< LAYER_ID, PCB_LAYER_ID > m_layermap
Map between Cadstar and KiCad 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 4092 of file cadstar_pcb_archive_loader.cpp.

4093 {
4094  LAYER_TYPE layerType = getLayerType( aCadstarLayerID );
4095 
4096  switch( layerType )
4097  {
4098  case LAYER_TYPE::ALLDOC:
4101 
4102  case LAYER_TYPE::ALLELEC:
4104 
4105  case LAYER_TYPE::ALLLAYER:
4106  return LSET::AllLayersMask()
4108  ^ ( LSET( PCB_LAYER_ID::Rescue ) );
4109 
4110  default:
4111  return LSET( getKiCadLayer( aCadstarLayerID ) );
4112  }
4113 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
Inbuilt layer type (cannot be assigned to user layers)
Inbuilt layer type (cannot be assigned to user layers)
LAYER_TYPE getLayerType(const LAYER_ID aCadstarLayerID)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
int m_numCopperLayers
Number of layers in the design.
#define MAX_CU_LAYERS
Definition: layer_ids.h:147
static LSET AllLayersMask()
Definition: lset.cpp:796
Inbuilt layer type (cannot be assigned to user layers)
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)

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 3899 of file cadstar_pcb_archive_loader.cpp.

3900 {
3901  if( aCadstarNetID.IsEmpty() )
3902  {
3903  return nullptr;
3904  }
3905  else if( m_netMap.find( aCadstarNetID ) != m_netMap.end() )
3906  {
3907  return m_netMap.at( aCadstarNetID );
3908  }
3909  else
3910  {
3911  wxCHECK( Layout.Nets.find( aCadstarNetID ) != Layout.Nets.end(), nullptr );
3912 
3913  NET_PCB csNet = Layout.Nets.at( aCadstarNetID );
3914  wxString newName = csNet.Name;
3915 
3916  if( csNet.Name.IsEmpty() )
3917  {
3918  if( csNet.Pins.size() > 0 )
3919  {
3920  // Create default KiCad net naming:
3921 
3922  NET_PCB::PIN firstPin = ( *csNet.Pins.begin() ).second;
3923  //we should have already loaded the component with loadComponents() :
3924  FOOTPRINT* m = getFootprintFromCadstarID( firstPin.ComponentID );
3925  newName = wxT( "Net-(" );
3926  newName << m->Reference().GetText();
3927  newName << wxT( "-Pad" ) << wxString::Format( wxT( "%ld" ), firstPin.PadID );
3928  newName << wxT( ")" );
3929  }
3930  else
3931  {
3932  wxFAIL_MSG( wxT( "A net with no pins associated?" ) );
3933  newName = wxT( "csNet-" );
3934  newName << wxString::Format( wxT( "%i" ), csNet.SignalNum );
3935  }
3936  }
3937 
3938  if( !m_doneNetClassWarning && !csNet.NetClassID.IsEmpty()
3939  && csNet.NetClassID != wxT( "NONE" ) )
3940  {
3941  wxLogMessage( _( "The CADSTAR design contains nets with a 'Net Class' assigned. KiCad "
3942  "does not have an equivalent to CADSTAR's Net Class so these elements "
3943  "were not imported. Note: KiCad's version of 'Net Class' is closer to "
3944  "CADSTAR's 'Net Route Code' (which has been imported for all nets)." ) );
3945  m_doneNetClassWarning = true;
3946  }
3947 
3948  if( !m_doneSpacingClassWarning && !csNet.SpacingClassID.IsEmpty()
3949  && csNet.SpacingClassID != wxT( "NONE" ) )
3950  {
3951  wxLogWarning( _( "The CADSTAR design contains nets with a 'Spacing Class' assigned. "
3952  "KiCad does not have an equivalent to CADSTAR's Spacing Class so "
3953  "these elements were not imported. Please review the design rules as "
3954  "copper pours will affected by this." ) );
3956  }
3957 
3958  NETINFO_ITEM* netInfo = new NETINFO_ITEM( m_board, newName, ++m_numNets );
3959  NETCLASSPTR netclass;
3960 
3961  std::tuple<ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID> key = { csNet.RouteCodeID,
3962  csNet.NetClassID,
3963  csNet.SpacingClassID };
3964 
3965  if( m_netClassMap.find( key ) != m_netClassMap.end() )
3966  {
3967  netclass = m_netClassMap.at( key );
3968  }
3969  else
3970  {
3971  wxString netClassName;
3972 
3973 
3974  ROUTECODE rc = getRouteCode( csNet.RouteCodeID );
3975  netClassName += wxT( "Route code: " ) + rc.Name;
3976 
3977  if( !csNet.NetClassID.IsEmpty() )
3978  {
3979  CADSTAR_NETCLASS nc = Assignments.Codedefs.NetClasses.at( csNet.NetClassID );
3980  netClassName += wxT( " | Net class: " ) + nc.Name;
3981  }
3982 
3983  if( !csNet.SpacingClassID.IsEmpty() )
3984  {
3985  SPCCLASSNAME sp = Assignments.Codedefs.SpacingClassNames.at( csNet.SpacingClassID );
3986  netClassName += wxT( " | Spacing class: " ) + sp.Name;
3987  }
3988 
3989  netclass.reset( new NETCLASS( *m_board->GetDesignSettings().GetDefault() ) );
3990  netclass->SetName( netClassName );
3991  m_board->GetDesignSettings().GetNetClasses().Add( netclass );
3992  netclass->SetTrackWidth( getKiCadLength( rc.OptimalWidth ) );
3993  m_netClassMap.insert( { key, netclass } );
3994  }
3995 
3996  netclass->Add( newName );
3997  netInfo->SetNetClass( netclass );
3998  m_board->Add( netInfo, ADD_MODE::APPEND );
3999  m_netMap.insert( { aCadstarNetID, netInfo } );
4000  return netInfo;
4001  }
4002 
4003  return nullptr;
4004 }
int getKiCadLength(long long aCadstarLength)
bool m_doneSpacingClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
FP_TEXT & Reference()
Definition: footprint.h:500
std::map< NET_ID, NET_PCB > Nets
Contains tracks and vias.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
bool m_doneNetClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
std::map< NETCLASS_ID, CADSTAR_NETCLASS > NetClasses
#define _(s)
NETCLASSES & GetNetClasses() const
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
bool Add(const NETCLASSPTR &aNetclass)
Add aNetclass and puts it into this NETCLASSES container.
Definition: netclass.cpp:90
Handle the data for a net.
Definition: netinfo.h:66
std::map< std::tuple< ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID >, NETCLASSPTR > m_netClassMap
Map between Cadstar and KiCad classes.
std::map< SPACING_CLASS_ID, SPCCLASSNAME > SpacingClassNames
std::map< NET_ID, NETINFO_ITEM * > m_netMap
Map between Cadstar and KiCad Nets.
NETCLASS * GetDefault() const
FOOTPRINT * getFootprintFromCadstarID(const COMPONENT_ID &aCadstarComponentID)
void SetNetClass(const NETCLASSPTR &aNetClass)
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
int m_numNets
Number of nets loaded so far.

References _, NETCLASSES::Add(), BOARD::Add(), APPEND, CADSTAR_PCB_ARCHIVE_PARSER::Assignments, CADSTAR_PCB_ARCHIVE_PARSER::ASSIGNMENTS::Codedefs, Format(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), getFootprintFromCadstarID(), getKiCadLength(), BOARD_DESIGN_SETTINGS::GetNetClasses(), getRouteCode(), EDA_TEXT::GetText(), CADSTAR_PCB_ARCHIVE_PARSER::Layout, m_board, m_doneNetClassWarning, m_doneSpacingClassWarning, m_netClassMap, m_netMap, m_numNets, CADSTAR_ARCHIVE_PARSER::ROUTECODE::Name, CADSTAR_ARCHIVE_PARSER::CADSTAR_NETCLASS::Name, CADSTAR_ARCHIVE_PARSER::SPCCLASSNAME::Name, CADSTAR_ARCHIVE_PARSER::CODEDEFS::NetClasses, CADSTAR_PCB_ARCHIVE_PARSER::LAYOUT::Nets, CADSTAR_ARCHIVE_PARSER::ROUTECODE::OptimalWidth, FOOTPRINT::Reference(), NETINFO_ITEM::SetNetClass(), 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 921 of file cadstar_pcb_archive_loader.cpp.

922 {
923  PADCODE csPadcode = getPadCode( aCadstarPad.PadCodeID );
924  wxString errorMSG;
925 
926  PAD* pad = new PAD( aParent );
927  LSET padLayerSet;
928 
929  switch( aCadstarPad.Side )
930  {
931  case PAD_SIDE::MAXIMUM: //Bottom side
932  padLayerSet |= LSET( 3, B_Cu, B_Paste, B_Mask );
933  break;
934 
935  case PAD_SIDE::MINIMUM: //TOP side
936  padLayerSet |= LSET( 3, F_Cu, F_Paste, F_Mask );
937  break;
938 
940  padLayerSet = LSET::AllCuMask() | LSET( 4, F_Mask, B_Mask, F_Paste, B_Paste );
941  break;
942 
943  default:
944  wxFAIL_MSG( wxT( "Unknown Pad type" ) );
945  }
946 
947  pad->SetAttribute( PAD_ATTRIB::SMD ); // assume SMD pad for now
948  pad->SetLocalSolderMaskMargin( 0 );
949  pad->SetLocalSolderPasteMargin( 0 );
950  pad->SetLocalSolderPasteMarginRatio( 0.0 );
951  bool complexPadErrorLogged = false;
952 
953  for( auto& reassign : csPadcode.Reassigns )
954  {
955  PCB_LAYER_ID kiLayer = getKiCadLayer( reassign.first );
956  CADSTAR_PAD_SHAPE shape = reassign.second;
957 
958  if( shape.Size == 0 )
959  {
960  padLayerSet.reset( kiLayer );
961  }
962  else
963  {
964  int newMargin = getKiCadLength( shape.Size - csPadcode.Shape.Size ) / 2;
965 
966  if( kiLayer == F_Mask || kiLayer == B_Mask )
967  {
968  if( std::abs( pad->GetLocalSolderMaskMargin() ) < std::abs( newMargin ) )
969  pad->SetLocalSolderMaskMargin( newMargin );
970  }
971  else if( kiLayer == F_Paste || kiLayer == B_Paste )
972  {
973  if( std::abs( pad->GetLocalSolderPasteMargin() ) < std::abs( newMargin ) )
974  pad->SetLocalSolderPasteMargin( newMargin );
975  }
976  else
977  {
978  //TODO fix properly when KiCad supports full padstacks
979 
980  if( !complexPadErrorLogged )
981  {
982  complexPadErrorLogged = true;
983  errorMSG +=
984  wxT( "\n - " )
986  _( "The CADSTAR pad definition '%s' is a complex pad stack, "
987  "which is not supported in KiCad. Please review the "
988  "imported pads as they may require manual correction." ),
989  csPadcode.Name );
990  }
991  }
992  }
993  }
994 
995  pad->SetLayerSet( padLayerSet );
996 
997  if( aCadstarPad.PCBonlyPad )
998  {
999  // PCB Only pads in CADSTAR do not have a representation in the schematic - they are
1000  // purely mechanical pads that have no net associated with them. Make the pad name
1001  // empty to avoid warnings when importing from the schematic
1002  pad->SetNumber( wxEmptyString );
1003  }
1004  else
1005  {
1006  pad->SetNumber( aCadstarPad.Identifier.IsEmpty()
1007  ? wxString::Format( wxT( "%ld" ), aCadstarPad.ID )
1008  : aCadstarPad.Identifier );
1009  }
1010 
1011  if( csPadcode.Shape.Size == 0 )
1012  {
1013  if( csPadcode.DrillDiameter == UNDEFINED_VALUE
1014  && aCadstarPad.Side == PAD_SIDE::THROUGH_HOLE )
1015  {
1016  // Through-hole, zero sized pad?. Lets load this just on the F_Mask for now to
1017  // prevent DRC errors.
1018  // TODO: This could be a custom padstack, update when KiCad supports padstacks
1019  pad->SetAttribute( PAD_ATTRIB::SMD );
1020  pad->SetLayerSet( LSET( 1, F_Mask ) );
1021  }
1022 
1023  // zero sized pads seems to break KiCad so lets make it very small instead
1024  csPadcode.Shape.Size = 1;
1025  }
1026 
1027  wxPoint padOffset = { 0, 0 }; // offset of the pad origin (before rotating)
1028  wxPoint drillOffset = { 0, 0 }; // offset of the drill origin w.r.t. the pad (before rotating)
1029 
1030  switch( csPadcode.Shape.ShapeType )
1031  {
1033  //todo fix: use custom shape instead (Donught shape, i.e. a circle with a hole)
1034  pad->SetShape( PAD_SHAPE::CIRCLE );
1035  pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1036  getKiCadLength( csPadcode.Shape.Size ) } );
1037  break;
1038 
1040  pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1041  pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1042  + (long long) csPadcode.Shape.LeftLength
1043  + (long long) csPadcode.Shape.RightLength ),
1044  getKiCadLength( csPadcode.Shape.Size ) } );
1047  pad->SetRoundRectRadiusRatio( 0.5 );
1048  pad->SetChamferRectRatio( 0.0 );
1049 
1050  padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1051  ( (long long) csPadcode.Shape.RightLength / 2 ) );
1052  break;
1053 
1055  pad->SetShape( PAD_SHAPE::CIRCLE );
1056  pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1057  getKiCadLength( csPadcode.Shape.Size ) } );
1058  break;
1059 
1061  {
1062  // Cadstar diamond shape is a square rotated 45 degrees
1063  // We convert it in KiCad to a square with chamfered edges
1064  int sizeOfSquare = (double) getKiCadLength( csPadcode.Shape.Size ) * sqrt(2.0);
1065  pad->SetShape( PAD_SHAPE::RECT );
1066  pad->SetChamferRectRatio( 0.5 );
1067  pad->SetSize( { sizeOfSquare, sizeOfSquare } );
1068 
1069  padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1070  ( (long long) csPadcode.Shape.RightLength / 2 ) );
1071  }
1072  break;
1073 
1075  pad->SetShape( PAD_SHAPE::OVAL );
1076  pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1077  + (long long) csPadcode.Shape.LeftLength
1078  + (long long) csPadcode.Shape.RightLength ),
1079  getKiCadLength( csPadcode.Shape.Size ) } );
1080 
1081  padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1082  ( (long long) csPadcode.Shape.RightLength / 2 ) );
1083  break;
1084 
1086  pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1087  pad->SetChamferPositions( RECT_CHAMFER_POSITIONS::RECT_CHAMFER_ALL );
1088  pad->SetChamferRectRatio( 0.25 );
1089  pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1090  getKiCadLength( csPadcode.Shape.Size ) } );
1091  break;
1092 
1094  pad->SetShape( PAD_SHAPE::RECT );
1095  pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1096  + (long long) csPadcode.Shape.LeftLength
1097  + (long long) csPadcode.Shape.RightLength ),
1098  getKiCadLength( csPadcode.Shape.Size ) } );
1099 
1100  padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1101  ( (long long) csPadcode.Shape.RightLength / 2 ) );
1102  break;
1103 
1105  pad->SetShape( PAD_SHAPE::RECT );
1106  pad->SetRoundRectCornerRadius( getKiCadLength( csPadcode.Shape.InternalFeature ) );
1107  pad->SetSize( { getKiCadLength( (long long) csPadcode.Shape.Size
1108  + (long long) csPadcode.Shape.LeftLength
1109  + (long long) csPadcode.Shape.RightLength ),
1110  getKiCadLength( csPadcode.Shape.Size ) } );
1111 
1112  padOffset.x = getKiCadLength( ( (long long) csPadcode.Shape.LeftLength / 2 ) -
1113  ( (long long) csPadcode.Shape.RightLength / 2 ) );
1114  break;
1115 
1116 
1118  pad->SetShape( PAD_SHAPE::RECT );
1119  pad->SetSize( { getKiCadLength( csPadcode.Shape.Size ),
1120  getKiCadLength( csPadcode.Shape.Size ) } );
1121  break;
1122 
1123  default:
1124  wxFAIL_MSG( wxT( "Unknown Pad Shape" ) );
1125  }
1126 
1127  if( csPadcode.ReliefClearance != UNDEFINED_VALUE )
1128  pad->SetThermalGap( getKiCadLength( csPadcode.ReliefClearance ) );
1129 
1130  if( csPadcode.ReliefWidth != UNDEFINED_VALUE )
1131  pad->SetThermalSpokeWidth( getKiCadLength( csPadcode.ReliefWidth ) );
1132 
1133  if( csPadcode.DrillDiameter != UNDEFINED_VALUE )
1134  {
1135  if( csPadcode.SlotLength != UNDEFINED_VALUE )
1136  {
1138  pad->SetDrillSize( { getKiCadLength( (long long) csPadcode.SlotLength +
1139  (long long) csPadcode.DrillDiameter ),
1140  getKiCadLength( csPadcode.DrillDiameter ) } );
1141  }
1142  else
1143  {
1145  pad->SetDrillSize( { getKiCadLength( csPadcode.DrillDiameter ),
1146  getKiCadLength( csPadcode.DrillDiameter ) } );
1147  }
1148 
1149  drillOffset.x = -getKiCadLength( csPadcode.DrillXoffset );
1150  drillOffset.y = getKiCadLength( csPadcode.DrillYoffset );
1151 
1152  if( csPadcode.Plated )
1153  pad->SetAttribute( PAD_ATTRIB::PTH );
1154  else
1155  pad->SetAttribute( PAD_ATTRIB::NPTH );
1156  }
1157  else
1158  {
1159  pad->SetDrillSize( { 0, 0 } );
1160  }
1161 
1162  if( csPadcode.SlotOrientation != 0 )
1163  {
1164  LSET lset = pad->GetLayerSet();
1165  lset &= LSET::AllCuMask();
1166 
1167  if( lset.size() > 0 )
1168  {
1169  SHAPE_POLY_SET padOutline;
1170  PCB_LAYER_ID layer = lset.Seq().at( 0 );
1171  int maxError = m_board->GetDesignSettings().m_MaxError;
1172 
1173  pad->SetPosition( { 0, 0 } );
1174  pad->SetPos0( { 0, 0 } );
1175  pad->TransformShapeWithClearanceToPolygon( padOutline, layer, 0, maxError,
1177 
1178  PCB_SHAPE* padShape = new PCB_SHAPE;
1179  padShape->SetShape( SHAPE_T::POLY );
1180  padShape->SetFilled( true );
1181  padShape->SetPolyShape( padOutline );
1182  padShape->SetWidth( 0 );
1183  padShape->Move( padOffset - drillOffset );
1184  padShape->Rotate( wxPoint( 0, 0 ),
1185  1800.0 - getAngleTenthDegree( 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 - " )
1206  + wxString::Format(
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  double padOrientation = getAngleTenthDegree( aCadstarPad.OrientAngle )
1225  + getAngleTenthDegree( 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 + getAngleTenthDegree( csPadcode.SlotOrientation ) );
1232 
1233  //TODO handle csPadcode.Reassigns when KiCad supports full padstacks
1234 
1235  pad->SetLocked( true ); // Cadstar pads are always locked with respect to the footprint
1236 
1237  //log warnings:
1238  if( m_padcodesTested.find( csPadcode.ID ) == m_padcodesTested.end() && !errorMSG.IsEmpty() )
1239  {
1240  wxLogError( _( "The CADSTAR pad definition '%s' has import errors: %s" ),
1241  csPadcode.Name,
1242  errorMSG );
1243 
1244  m_padcodesTested.insert( csPadcode.ID );
1245  }
1246 
1247  return pad;
1248 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
int getKiCadLength(long long aCadstarLength)
void SetFilled(bool aFlag)
Definition: eda_shape.h:92
double getAngleTenthDegree(const long long &aCadstarAngle)
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:235
Smd pad, appears on the solder paste layer (default)
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.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:109
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
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
Plated through hole pad.
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:97
like PAD_PTH, but not plated
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
Represent a set of closed polygons.
std::set< PADCODE_ID > m_padcodesTested
Used by getKiCadPad() to avoid multiple duplicate warnings.
The highest PHYSICAL_LAYER_ID currently defined (i.e.
#define _(s)
void SetWidth(int aWidth)
Definition: eda_shape.h:97
All physical layers currently defined.
static const long UNDEFINED_VALUE
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:227
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
PADCODE getPadCode(const PADCODE_ID &aCadstarPadCodeID)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:100
wxPoint GetPosition() const override
Definition: footprint.h:187
Definition: pad.h:57

References _, LSET::AllCuMask(), 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(), getAngleTenthDegree(), 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, 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(), EDA_SHAPE::SetWidth(), 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, and CADSTAR_ARCHIVE_PARSER::UNDEFINED_VALUE.

Referenced by loadComponents(), and loadLibraryPads().

◆ getKiCadPoint()

wxPoint CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPoint ( const wxPoint &  aCadstarPoint)
private

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

Parameters
aCadstarPoint
Returns

Definition at line 3882 of file cadstar_pcb_archive_loader.cpp.

3883 {
3884  wxPoint retval;
3885 
3886  retval.x = ( aCadstarPoint.x - m_designCenter.x ) * KiCadUnitMultiplier;
3887  retval.y = -( aCadstarPoint.y - m_designCenter.y ) * KiCadUnitMultiplier;
3888 
3889  return retval;
3890 }
wxPoint m_designCenter
Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canv...
int KiCadUnitMultiplier
Use this value to convert units in this CPA file to KiCad units.

References CADSTAR_PCB_ARCHIVE_PARSER::KiCadUnitMultiplier, and m_designCenter.

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 3409 of file cadstar_pcb_archive_loader.cpp.

3411 {
3412  wxCHECK( Assignments.Codedefs.LayerPairs.find( aCadstarLayerPairID )
3413  != Assignments.Codedefs.LayerPairs.end(),
3414  LAYERPAIR() );
3415 
3416  return Assignments.Codedefs.LayerPairs.at( aCadstarLayerPairID );
3417 }
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()

◆ 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 2991 of file cadstar_pcb_archive_loader.cpp.

2992 {
2993  SHAPE_LINE_CHAIN lineChain;
2994 
2995  for( PCB_SHAPE* shape : aShapes )
2996  {
2997  switch( shape->GetShape() )
2998  {
2999  case SHAPE_T::ARC:
3000  {
3001  if( shape->GetClass() == wxT( "MGRAPHIC" ) )
3002  {
3003  FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
3004  SHAPE_ARC arc( fp_shape->GetCenter0(), fp_shape->GetStart0(), fp_shape->GetArcAngle() / 10.0 );
3005 
3006  if( shape->EndsSwapped() )
3007  arc.Reverse();
3008 
3009  lineChain.Append( arc );
3010  }
3011  else
3012  {
3013  SHAPE_ARC arc( shape->GetCenter(), shape->GetStart(), shape->GetArcAngle() / 10.0 );
3014 
3015  if( shape->EndsSwapped() )
3016  arc.Reverse();
3017 
3018  lineChain.Append( arc );
3019  }
3020  }
3021  break;
3022  case SHAPE_T::SEGMENT:
3023  if( shape->GetClass() == wxT( "MGRAPHIC" ) )
3024  {
3025  FP_SHAPE* fp_shape = (FP_SHAPE*) shape;
3026  lineChain.Append( fp_shape->GetStart0().x, fp_shape->GetStart0().y );
3027  lineChain.Append( fp_shape->GetEnd0().x, fp_shape->GetEnd0().y );
3028  }
3029  else
3030  {
3031  lineChain.Append( shape->GetStartX(), shape->GetStartY() );
3032  lineChain.Append( shape->GetEndX(), shape->GetEndY() );
3033  }
3034  break;
3035 
3036  default:
3037  wxFAIL_MSG( wxT( "Drawsegment type is unexpected. Ignored." ) );
3038  }
3039  }
3040 
3041  // Shouldn't have less than 3 points to make a closed shape!
3042  wxASSERT( lineChain.PointCount() > 2 );
3043 
3044  // Check if it is closed
3045  if( lineChain.GetPoint( 0 ) != lineChain.GetPoint( lineChain.PointCount() - 1 ) )
3046  {
3047  lineChain.Append( lineChain.GetPoint( 0 ) );
3048  }
3049 
3050  lineChain.SetClosed( true );
3051 
3052  return lineChain;
3053 }
double GetArcAngle() const
Definition: eda_shape.cpp:536
const wxPoint & GetStart0() const
Definition: fp_shape.h:112
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.
wxPoint GetCenter0() const
Definition: fp_shape.cpp:145
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
virtual const VECTOR2I GetPoint(int aIndex) const override
void Reverse()
Definition: shape_arc.cpp:578
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const wxPoint & GetEnd0() const
Definition: fp_shape.h:115

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, and SHAPE_LINE_CHAIN::SetClosed().

Referenced by getPolySetFromCadstarShape().

◆ getLineThickness()

int CADSTAR_PCB_ARCHIVE_LOADER::getLineThickness ( const LINECODE_ID aCadstarLineCodeID)
private

Definition at line 3355 of file cadstar_pcb_archive_loader.cpp.

3356 {
3357  wxCHECK( Assignments.Codedefs.LineCodes.find( aCadstarLineCodeID )
3358  != Assignments.Codedefs.LineCodes.end(),
3360 
3361  return getKiCadLength( Assignments.Codedefs.LineCodes.at( aCadstarLineCodeID ).Width );
3362 }
int getKiCadLength(long long aCadstarLength)
std::map< LINECODE_ID, LINECODE > LineCodes
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.

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 169 of file cadstar_pcb_archive_loader.cpp.

170 {
171  std::vector<FOOTPRINT*> retval;
172 
173  for( std::pair<SYMDEF_ID, FOOTPRINT*> fpPair : m_libraryMap )
174  {
175  retval.push_back( static_cast<FOOTPRINT*>( fpPair.second->Clone() ) );
176  }
177 
178  return retval;
179 }
std::map< SYMDEF_ID, FOOTPRINT * > m_libraryMap
Map between Cadstar and KiCad components in the library.

References m_libraryMap.

Referenced by CADSTAR_PCB_ARCHIVE_PLUGIN::Load().

◆ GetNumberOfChildNodes()

long CADSTAR_ARCHIVE_PARSER::GetNumberOfChildNodes ( XNODE aNode)
staticinherited

Definition at line 2575 of file cadstar_archive_parser.cpp.

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

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

Referenced by CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting().

◆ GetNumberOfStepsForReporting()

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

Definition at line 2587 of file cadstar_archive_parser.cpp.

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

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

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

◆ getPadCode()

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

◆ getPadReference()

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

Definition at line 1251 of file cadstar_pcb_archive_loader.cpp.

1253 {
1254  size_t index = aCadstarPadID - (long) 1;
1255 
1256  if( !( index < aFootprint->Pads().size() ) )
1257  {
1258  THROW_IO_ERROR( wxString::Format( _( "Unable to find pad index '%d' in footprint '%s'." ),
1259  (long) aCadstarPadID,
1260  aFootprint->GetReference() ) );
1261  }
1262 
1263  return aFootprint->Pads().at( index );
1264 }
PADS & Pads()
Definition: footprint.h:169
const wxString & GetReference() const
Definition: footprint.h:463
#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
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

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" ) )
1008  return PAD_SIDE::THROUGH_HOLE;
1009  else if( aPadSideString == wxT( "BOTTOM" ) )
1010  return PAD_SIDE::MAXIMUM;
1011  else if( aPadSideString == wxT( "TOP" ) )
1012  return PAD_SIDE::MINIMUM;
1013  else
1014  return PAD_SIDE::THROUGH_HOLE; // Assume through hole as default
1015 }
The highest PHYSICAL_LAYER_ID currently defined (i.e.
All physical layers currently defined.

References 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 3452 of file cadstar_pcb_archive_loader.cpp.

3454 {
3455  wxCHECK( Parts.PartDefinitions.find( aCadstarPartID ) != Parts.PartDefinitions.end(), PART() );
3456 
3457  return Parts.PartDefinitions.at( aCadstarPartID );
3458 }
std::map< PART_ID, PART > PartDefinitions

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

Referenced by loadComponentAttributes(), and loadComponents().

◆ getPolarAngle()

double CADSTAR_PCB_ARCHIVE_LOADER::getPolarAngle ( const wxPoint &  aPoint)
private
Parameters
aPoint
Returns
Angle in decidegrees of the polar representation of the point, scaled 0..360

Definition at line 3893 of file cadstar_pcb_archive_loader.cpp.

3894 {
3895  return NormalizeAnglePos( ArcTangente( aPoint.y, aPoint.x ) );
3896 }
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
Definition: trigo.h:281
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References ArcTangente(), and NormalizeAnglePos().

Referenced by getShapeFromVertex().

◆ getPolySetFromCadstarShape()

SHAPE_POLY_SET CADSTAR_PCB_ARCHIVE_LOADER::getPolySetFromCadstarShape ( const SHAPE aCadstarShape,
const int &  aLineThickness = -1,
BOARD_ITEM_CONTAINER aContainer = nullptr,
const wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2931 of file cadstar_pcb_archive_loader.cpp.

2939 {
2940  GROUP_ID noGroup = wxEmptyString;
2941 
2942  std::vector<PCB_SHAPE*> outlineShapes = getShapesFromVertices( aCadstarShape.Vertices,
2943  aContainer, noGroup, aMoveVector,
2944  aRotationAngle, aScalingFactor,
2945  aTransformCentre, aMirrorInvert );
2946 
2947  SHAPE_POLY_SET polySet( getLineChainFromShapes( outlineShapes ) );
2948 
2949  //cleanup
2950  for( PCB_SHAPE* shape : outlineShapes )
2951  delete shape;
2952 
2953  for( CUTOUT cutout : aCadstarShape.Cutouts )
2954  {
2955  std::vector<PCB_SHAPE*> cutoutShapes = getShapesFromVertices( cutout.Vertices, aContainer,
2956  noGroup, aMoveVector,
2957  aRotationAngle, aScalingFactor,
2958  aTransformCentre, aMirrorInvert );
2959 
2960  polySet.AddHole( getLineChainFromShapes( cutoutShapes ) );
2961 
2962  //cleanup
2963  for( PCB_SHAPE* shape : cutoutShapes )
2964  delete shape;
2965  }
2966 
2967  polySet.ClearArcs();
2968 
2969  if( aLineThickness > 0 )
2970  {
2971  polySet.Inflate( aLineThickness / 2, 32,
2972  SHAPE_POLY_SET::CORNER_STRATEGY::ROUND_ALL_CORNERS );
2973  }
2974 
2975 #ifdef DEBUG
2976  for( int i = 0; i < polySet.OutlineCount(); ++i )
2977  {
2978  wxASSERT( polySet.Outline( i ).PointCount() > 2 );
2979 
2980  for( int j = 0; j < polySet.HoleCount( i ); ++j )
2981  {
2982  wxASSERT( polySet.Hole( i, j ).PointCount() > 2 );
2983  }
2984  }
2985 #endif
2986 
2987  return polySet;
2988 }
Represent a set of closed polygons.
Make a cutout to an existing zone.
SHAPE_LINE_CHAIN getLineChainFromShapes(const std::vector< PCB_SHAPE * > aShapes)
Returns a SHAPE_LINE_CHAIN object from a series of PCB_SHAPE objects.
std::vector< PCB_SHAPE * > getShapesFromVertices(const std::vector< VERTEX > &aCadstarVertices, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a vector of pointers to 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 3461 of file cadstar_pcb_archive_loader.cpp.

3463 {
3464  wxCHECK( Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID )
3465  != Assignments.Codedefs.RouteCodes.end(),
3466  ROUTECODE() );
3467 
3468  return Assignments.Codedefs.RouteCodes.at( aCadstarRouteCodeID );
3469 }
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 wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2805 of file cadstar_pcb_archive_loader.cpp.

2814 {
2815  PCB_SHAPE* shape = nullptr;
2816  bool cw = false;
2817  double arcStartAngle, arcEndAngle, arcAngle;
2818 
2819  wxPoint startPoint = getKiCadPoint( aCadstarStartPoint );
2820  wxPoint endPoint = getKiCadPoint( aCadstarVertex.End );
2821  wxPoint centerPoint;
2822 
2823  if( aCadstarVertex.Type == VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE
2824  || aCadstarVertex.Type == VERTEX_TYPE::CLOCKWISE_SEMICIRCLE )
2825  {
2826  centerPoint = ( startPoint + endPoint ) / 2;
2827  }
2828  else
2829  {
2830  centerPoint = getKiCadPoint( aCadstarVertex.Center );
2831  }
2832 
2833  switch( aCadstarVertex.Type )
2834  {
2835 
2836  case VERTEX_TYPE::POINT:
2837 
2838  if( isFootprint( aContainer ) )
2839  shape = new FP_SHAPE( static_cast<FOOTPRINT*>( aContainer ), SHAPE_T::SEGMENT );
2840  else
2841  shape = new PCB_SHAPE( aContainer, SHAPE_T::SEGMENT );
2842 
2843  shape->SetStart( startPoint );
2844  shape->SetEnd( endPoint );
2845  break;
2846 
2849  cw = true;
2851 
2854 
2855  if( isFootprint( aContainer ) )
2856  shape = new FP_SHAPE((FOOTPRINT*) aContainer, SHAPE_T::ARC );
2857  else
2858  shape = new PCB_SHAPE( aContainer, SHAPE_T::ARC );
2859 
2860  shape->SetCenter( centerPoint );
2861  shape->SetStart( startPoint );
2862 
2863  arcStartAngle = getPolarAngle( startPoint - centerPoint );
2864  arcEndAngle = getPolarAngle( endPoint - centerPoint );
2865  arcAngle = arcEndAngle - arcStartAngle;
2866  //TODO: detect if we are supposed to draw a circle instead (i.e. two SEMICIRCLEs
2867  // with opposite start/end points and same centre point)
2868 
2869  if( cw )
2870  shape->SetArcAngleAndEnd( NormalizeAnglePos( arcAngle ) );
2871  else
2872  shape->SetArcAngleAndEnd( NormalizeAngleNeg( arcAngle ), true );
2873 
2874  break;
2875  }
2876 
2877  //Apply transforms
2878  if( aMirrorInvert )
2879  shape->Flip( aTransformCentre, true );
2880 
2881  if( aScalingFactor != 1.0 )
2882  {
2883  shape->Move( -aTransformCentre );
2884  shape->Scale( aScalingFactor );
2885  shape->Move( aTransformCentre );
2886  }
2887 
2888  if( aRotationAngle != 0.0 )
2889  shape->Rotate( aTransformCentre, aRotationAngle );
2890 
2891  if( aMoveVector != wxPoint{ 0, 0 } )
2892  shape->Move( aMoveVector );
2893 
2894  if( isFootprint( aContainer ) && shape != nullptr )
2895  static_cast<FP_SHAPE*>( shape )->SetLocalCoord();
2896 
2897  if( !aCadstarGroupID.IsEmpty() )
2898  addToGroup( aCadstarGroupID, shape );
2899 
2900  return shape;
2901 }
T NormalizeAngleNeg(T Angle)
Normalize angle to be in the 0.0 .. -360.0 range: angle is in 1/10 degrees.
Definition: trigo.h:268
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:135
void Scale(double aScale)
Definition: pcb_shape.cpp:103
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
void SetArcAngleAndEnd(double aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
Definition: eda_shape.cpp:547
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:109
void SetStart(const wxPoint &aStart)
Definition: eda_shape.h:110
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:97
double getPolarAngle(const wxPoint &aPoint)
bool isFootprint(BOARD_ITEM_CONTAINER *aContainer)
void SetCenter(const wxPoint &aCenter)
Definition: eda_shape.cpp:419
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
Definition: trigo.h:281
void addToGroup(const GROUP_ID &aCadstarGroupID, BOARD_ITEM *aKiCadItem)
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_shape.cpp:115

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(), getPolarAngle(), isFootprint(), KI_FALLTHROUGH, PCB_SHAPE::Move(), NormalizeAngleNeg(), NormalizeAnglePos(), CADSTAR_ARCHIVE_PARSER::POINT, PCB_SHAPE::Rotate(), PCB_SHAPE::Scale(), SEGMENT, EDA_SHAPE::SetArcAngleAndEnd(), EDA_SHAPE::SetCenter(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetStart(), 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 wxPoint &  aMoveVector = { 0, 0 },
const double &  aRotationAngle = 0.0,
const double &  aScalingFactor = 1.0,
const wxPoint &  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 2773 of file cadstar_pcb_archive_loader.cpp.

2782 {
2783  std::vector<PCB_SHAPE*> drawSegments;
2784 
2785  if( aCadstarVertices.size() < 2 )
2786  //need at least two points to draw a segment! (unlikely but possible to have only one)
2787  return drawSegments;
2788 
2789  const VERTEX* prev = &aCadstarVertices.at( 0 ); // first one should always be a point vertex
2790  const VERTEX* cur;
2791 
2792  for( size_t i = 1; i < aCadstarVertices.size(); i++ )
2793  {
2794  cur = &aCadstarVertices.at( i );
2795  drawSegments.push_back( getShapeFromVertex( prev->End, *cur, aContainer, aCadstarGroupID,
2796  aMoveVector, aRotationAngle, aScalingFactor,
2797  aTransformCentre, aMirrorInvert ) );
2798  prev = cur;
2799  }
2800 
2801  return drawSegments;
2802 }
PCB_SHAPE * getShapeFromVertex(const POINT &aCadstarStartPoint, const VERTEX &aCadstarVertex, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &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 3376 of file cadstar_pcb_archive_loader.cpp.

3378 {
3379  wxCHECK( Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID )
3380  != Assignments.Codedefs.TextCodes.end(),
3381  TEXTCODE() );
3382 
3383  return Assignments.Codedefs.TextCodes.at( aCadstarTextCodeID );
3384 }
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 3398 of file cadstar_pcb_archive_loader.cpp.

3400 {
3401  wxCHECK( Assignments.Codedefs.ViaCodes.find( aCadstarViaCodeID )
3402  != Assignments.Codedefs.ViaCodes.end(),
3403  VIACODE() );
3404 
3405  return Assignments.Codedefs.ViaCodes.at( aCadstarViaCodeID );
3406 }

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

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

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

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

◆ GetXmlAttributeIDString()

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

Definition at line 2428 of file cadstar_archive_parser.cpp.

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

References THROW_MISSING_PARAMETER_IO_ERROR.

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

2907 {
2908  ZONE* zone = new ZONE( aParentContainer, isFootprint( aParentContainer ) );
2909 
2910  if( aCadstarShape.Type == SHAPE_TYPE::HATCHED )
2911  {
2914  }
2915  else
2916  {
2918  }
2919 
2920  SHAPE_POLY_SET polygon = getPolySetFromCadstarShape( aCadstarShape, aLineThickness );
2921 
2922  zone->AddPolygon( polygon.COutline( 0 ) );
2923 
2924  for( int i = 0; i < polygon.HoleCount( 0 ); i++ )
2925  zone->AddPolygon( polygon.CHole( 0, i ) );
2926 
2927  return zone;
2928 }
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
Definition: zone.h:616
Filled closed shape (hatch fill).
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: zone.h:180
Represent a set of closed polygons.
bool isFootprint(BOARD_ITEM_CONTAINER *aContainer)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void AddPolygon(std::vector< wxPoint > &aPolygon)
Add a polygon to the zone outline.
Definition: zone.cpp:798
SHAPE_TYPE Type() const
Return the type of the shape.
Definition: shape.h:94
SHAPE_POLY_SET getPolySetFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness=-1, BOARD_ITEM_CONTAINER *aContainer=nullptr, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a SHAPE_POLY_SET object from a Cadstar SHAPE.

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

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

References ConvertToNewOverbarNotation().

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

◆ initStackupItem()

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

Definition at line 209 of file cadstar_pcb_archive_loader.cpp.

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

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

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

References Format().

Referenced by CADSTAR_ARCHIVE_PARSER::LoadArchiveFile().

◆ isFootprint()

bool CADSTAR_PCB_ARCHIVE_LOADER::isFootprint ( BOARD_ITEM_CONTAINER aContainer)
inlineprivate

Definition at line 517 of file cadstar_pcb_archive_loader.h.

518  {
519  return aContainer && aContainer->Type() == PCB_FOOTPRINT_T;
520  }
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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