KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SPRINT_LAYOUT_PARSER Class Reference

#include <sprint_layout_parser.h>

Public Member Functions

 SPRINT_LAYOUT_PARSER ()
 
 ~SPRINT_LAYOUT_PARSER ()
 
bool ParseBoard (const wxString &aFileName)
 
bool ParseMacroFile (const wxString &aFileName)
 
BOARDCreateBoard (std::map< wxString, std::unique_ptr< FOOTPRINT > > &aFootprintMap, size_t aBoardIndex=0)
 
FOOTPRINTCreateFootprint ()
 
const SPRINT_LAYOUT::FILE_DATAGetFileData () const
 

Private Member Functions

uint8_t readUint8 ()
 
uint16_t readUint16 ()
 
int16_t readInt16 ()
 
uint32_t readUint32 ()
 
uint32_t readUnsigned ()
 
int32_t readInt32 ()
 
int32_t readSigned ()
 
float readFloat ()
 
double readDouble ()
 
float readCoord ()
 
std::string readFixedString (size_t aMaxLen)
 
std::string readVarString ()
 
void skip (size_t aBytes)
 
void seek (int aBytes)
 
void parseFileStart (const wxString &aFileName)
 
void parseBoardHeader (SPRINT_LAYOUT::BOARD_DATA &aBoard)
 
void parseObjectsList (SPRINT_LAYOUT::BOARD_DATA &aBoard)
 
void parseGroups (SPRINT_LAYOUT::OBJECT &aObj)
 
void parsePoints (SPRINT_LAYOUT::OBJECT &aObj)
 
void parseObject (SPRINT_LAYOUT::OBJECT &aObject, bool aIsTextChild=false)
 
void parseTrailer ()
 
PCB_LAYER_ID mapLayer (uint8_t aSprintLayer) const
 
int sprintToKicadCoord (float aValue) const
 
VECTOR2I sprintToKicadPos (float aX, float aY) const
 
wxString convertString (const std::string &aStr) const
 
bool layerHasGroundPlane (PCB_LAYER_ID aLayer, const uint8_t aGroundPlane[7]) const
 
NETINFO_ITEMresolveItemNet (BOARD *aBoard, const SPRINT_LAYOUT::OBJECT &aObj, PCB_LAYER_ID aLayer, const uint8_t aGroundPlane[7], NETINFO_ITEM *aGndPlaneNet) const
 
void processPad (BOARD_ITEM_CONTAINER *aContainer, const SPRINT_LAYOUT::OBJECT &aObj, const uint8_t aGroundPlane[7], NETINFO_ITEM *aGndPlaneNet, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void processCircle (BOARD_ITEM_CONTAINER *aContainer, const SPRINT_LAYOUT::OBJECT &aObj, std::vector< std::vector< VECTOR2I > > &aOutlineSegments, const uint8_t aGroundPlane[7], NETINFO_ITEM *aGndPlaneNet, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void processLine (BOARD_ITEM_CONTAINER *aContainer, const SPRINT_LAYOUT::OBJECT &aObj, std::vector< std::vector< VECTOR2I > > &aOutlineSegments, const uint8_t aGroundPlane[7], NETINFO_ITEM *aGndPlaneNet, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void processSegment (BOARD_ITEM_CONTAINER *aContainer, const SPRINT_LAYOUT::OBJECT &aObj, std::vector< std::vector< VECTOR2I > > &aOutlineSegments, const uint8_t aGroundPlane[7], NETINFO_ITEM *aGndPlaneNet, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void processPoly (BOARD_ITEM_CONTAINER *aContainer, const SPRINT_LAYOUT::OBJECT &aObj, std::vector< std::vector< VECTOR2I > > &aOutlineSegments, const uint8_t aGroundPlane[7], NETINFO_ITEM *aGndPlaneNet, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void processText (BOARD_ITEM_CONTAINER *aContainer, const SPRINT_LAYOUT::OBJECT &aObj, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void processItemGroups (BOARD_ITEM *aItem, const SPRINT_LAYOUT::OBJECT &aObj, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 
void buildOutline (BOARD *aBoard, std::vector< std::vector< VECTOR2I > > &aOutlineSegments, const SPRINT_LAYOUT::BOARD_DATA &aBoardData)
 
void resolveGroups (BOARD_ITEM_CONTAINER *aContainer, std::map< uint32_t, std::set< BOARD_ITEM * > > &aGidToItems)
 

Private Attributes

SPRINT_LAYOUT::FILE_DATA m_fileData
 
const uint8_t * m_pos = nullptr
 
const uint8_t * m_start = nullptr
 
const uint8_t * m_end = nullptr
 
std::vector< uint8_t > m_buffer
 
bool m_parsingMacro = false
 

Detailed Description

Definition at line 165 of file sprint_layout_parser.h.

Constructor & Destructor Documentation

◆ SPRINT_LAYOUT_PARSER()

SPRINT_LAYOUT_PARSER::SPRINT_LAYOUT_PARSER ( )
default

◆ ~SPRINT_LAYOUT_PARSER()

SPRINT_LAYOUT_PARSER::~SPRINT_LAYOUT_PARSER ( )
default

Member Function Documentation

◆ buildOutline()

◆ convertString()

wxString SPRINT_LAYOUT_PARSER::convertString ( const std::string & aStr) const
private

Definition at line 730 of file sprint_layout_parser.cpp.

Referenced by CreateBoard(), CreateFootprint(), and processText().

◆ CreateBoard()

BOARD * SPRINT_LAYOUT_PARSER::CreateBoard ( std::map< wxString, std::unique_ptr< FOOTPRINT > > & aFootprintMap,
size_t aBoardIndex = 0 )

Definition at line 844 of file sprint_layout_parser.cpp.

References ZONE::AddPolygon(), anchor, B_Cu, B_SilkS, buildOutline(), SPRINT_LAYOUT::OBJECT::component, SPRINT_LAYOUT::OBJECT::component_id, convertString(), SHAPE_POLY_SET::COutline(), DESCRIPTION, DIAGONAL_EDGE, F_Cu, FOOTPRINT, BOX2< Vec >::GetCenter(), ZONE::GetDefaultHatchPitch(), FOOTPRINT::GetField(), FOOTPRINT::GetFields(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), SPRINT_LAYOUT::BOARD_DATA::ground_plane, In1_Cu, In2_Cu, index, SPRINT_LAYOUT::BOARD_DATA::is_multilayer, SPRINT_LAYOUT::OBJECT::layer, SPRINT_LAYOUT::LAYER_I1, SPRINT_LAYOUT::LAYER_I2, m_fileData, mapLayer(), NEVER, SPRINT_LAYOUT::OBJ_CIRCLE, SPRINT_LAYOUT::OBJ_LINE, SPRINT_LAYOUT::OBJ_OUTLINE_TEXT, SPRINT_LAYOUT::OBJ_POLY, SPRINT_LAYOUT::OBJ_SEGMENT, SPRINT_LAYOUT::OBJ_SMD_PAD, SPRINT_LAYOUT::OBJ_STROKE_TEXT, SPRINT_LAYOUT::OBJ_THT_PAD, SPRINT_LAYOUT::BOARD_DATA::objects, pcbIUScale, processCircle(), processLine(), processPad(), processPoly(), processSegment(), processText(), resolveGroups(), RotatePoint(), BASE_SET::set(), ZONE::SetAssignedPriority(), ZONE::SetBorderDisplayStyle(), ZONE::SetIslandRemovalMode(), ZONE::SetIsRuleArea(), BOARD_ITEM::SetLayer(), ZONE::SetLayerSet(), FOOTPRINT::SetLibDescription(), ZONE::SetLocalClearance(), ZONE::SetNet(), FOOTPRINT::SetOrientationDegrees(), EDA_ITEM::SetParent(), FOOTPRINT::SetReference(), EDA_TEXT::SetText(), ZONE::SetThermalReliefGap(), ZONE::SetThermalReliefSpokeWidth(), FOOTPRINT::SetValue(), ZONE::SetZoneName(), SPRINT_LAYOUT::BOARD_DATA::size_x, SPRINT_LAYOUT::BOARD_DATA::size_y, sprintToKicadCoord(), SPRINT_LAYOUT::OBJECT::type, SPRINT_LAYOUT::COMPONENT_DATA::valid, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_IO_SPRINT_LAYOUT::LoadBoard().

◆ CreateFootprint()

◆ GetFileData()

const SPRINT_LAYOUT::FILE_DATA & SPRINT_LAYOUT_PARSER::GetFileData ( ) const
inline

◆ layerHasGroundPlane()

bool SPRINT_LAYOUT_PARSER::layerHasGroundPlane ( PCB_LAYER_ID aLayer,
const uint8_t aGroundPlane[7] ) const
private

Definition at line 776 of file sprint_layout_parser.cpp.

References B_Cu, F_Cu, In1_Cu, In2_Cu, and m_fileData.

Referenced by processPad(), and resolveItemNet().

◆ mapLayer()

◆ ParseBoard()

◆ parseBoardHeader()

◆ parseFileStart()

void SPRINT_LAYOUT_PARSER::parseFileStart ( const wxString & aFileName)
private

Definition at line 314 of file sprint_layout_parser.cpp.

References _, m_buffer, m_end, m_fileData, m_pos, m_start, readUint8(), and THROW_IO_ERROR.

Referenced by ParseBoard(), and ParseMacroFile().

◆ parseGroups()

void SPRINT_LAYOUT_PARSER::parseGroups ( SPRINT_LAYOUT::OBJECT & aObj)
private

Definition at line 437 of file sprint_layout_parser.cpp.

References _, SPRINT_LAYOUT::OBJECT::groups, MAX_GROUPS, readUnsigned(), and THROW_IO_ERROR.

Referenced by parseObject().

◆ ParseMacroFile()

bool SPRINT_LAYOUT_PARSER::ParseMacroFile ( const wxString & aFileName)

◆ parseObject()

void SPRINT_LAYOUT_PARSER::parseObject ( SPRINT_LAYOUT::OBJECT & aObject,
bool aIsTextChild = false )
private

Definition at line 476 of file sprint_layout_parser.cpp.

References _, SPRINT_LAYOUT::COMPONENT_DATA::center_mode, SPRINT_LAYOUT::OBJECT::clearance, SPRINT_LAYOUT::COMPONENT_DATA::comment, SPRINT_LAYOUT::OBJECT::component, SPRINT_LAYOUT::OBJECT::component_id, SPRINT_LAYOUT::OBJECT::filled, SPRINT_LAYOUT::OBJECT::identifier, SPRINT_LAYOUT::OBJECT::inner, SPRINT_LAYOUT::OBJECT::keepout, SPRINT_LAYOUT::OBJECT::layer, SPRINT_LAYOUT::OBJECT::line_width, m_fileData, MAX_CHILDREN, SPRINT_LAYOUT::OBJECT::mirror_h, SPRINT_LAYOUT::OBJECT::mirror_v, SPRINT_LAYOUT::OBJ_CIRCLE, SPRINT_LAYOUT::OBJ_LINE, SPRINT_LAYOUT::OBJ_OUTLINE_TEXT, SPRINT_LAYOUT::OBJ_POLY, SPRINT_LAYOUT::OBJ_SEGMENT, SPRINT_LAYOUT::OBJ_SMD_PAD, SPRINT_LAYOUT::OBJ_STROKE_TEXT, SPRINT_LAYOUT::OBJ_THT_PAD, SPRINT_LAYOUT::COMPONENT_DATA::off_x, SPRINT_LAYOUT::COMPONENT_DATA::off_y, SPRINT_LAYOUT::OBJECT::outer, SPRINT_LAYOUT::COMPONENT_DATA::package, parseGroups(), parseObject(), parsePoints(), SPRINT_LAYOUT::OBJECT::plated, readCoord(), readDouble(), readFixedString(), readInt16(), readInt32(), readSigned(), readUint16(), readUint32(), readUint8(), readVarString(), SPRINT_LAYOUT::COMPONENT_DATA::rotation, SPRINT_LAYOUT::OBJECT::rotation, skip(), SPRINT_LAYOUT::OBJECT::soldermask, SPRINT_LAYOUT::OBJECT::start_angle, SPRINT_LAYOUT::OBJECT::text, SPRINT_LAYOUT::OBJECT::text_children, THROW_IO_ERROR, SPRINT_LAYOUT::OBJECT::tht_shape, SPRINT_LAYOUT::OBJECT::type, SPRINT_LAYOUT::COMPONENT_DATA::use, SPRINT_LAYOUT::COMPONENT_DATA::valid, SPRINT_LAYOUT::OBJECT::x, and SPRINT_LAYOUT::OBJECT::y.

Referenced by ParseBoard(), parseObject(), and parseObjectsList().

◆ parseObjectsList()

void SPRINT_LAYOUT_PARSER::parseObjectsList ( SPRINT_LAYOUT::BOARD_DATA & aBoard)
private

◆ parsePoints()

void SPRINT_LAYOUT_PARSER::parsePoints ( SPRINT_LAYOUT::OBJECT & aObj)
private

◆ parseTrailer()

void SPRINT_LAYOUT_PARSER::parseTrailer ( )
private

Definition at line 652 of file sprint_layout_parser.cpp.

References m_fileData, readFixedString(), readUint32(), and readVarString().

Referenced by ParseBoard().

◆ processCircle()

◆ processItemGroups()

void SPRINT_LAYOUT_PARSER::processItemGroups ( BOARD_ITEM * aItem,
const SPRINT_LAYOUT::OBJECT & aObj,
std::map< uint32_t, std::set< BOARD_ITEM * > > & aGidToItems )
private

◆ processLine()

◆ processPad()

void SPRINT_LAYOUT_PARSER::processPad ( BOARD_ITEM_CONTAINER * aContainer,
const SPRINT_LAYOUT::OBJECT & aObj,
const uint8_t aGroundPlane[7],
NETINFO_ITEM * aGndPlaneNet,
std::map< uint32_t, std::set< BOARD_ITEM * > > & aGidToItems )
private

Definition at line 1161 of file sprint_layout_parser.cpp.

References BOARD_ITEM_CONTAINER::Add(), FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, ANGLE_45, ANGLE_90, B_Cu, B_Mask, B_Paste, CHAMFERED_RECT, CIRCLE, clearance, SPRINT_LAYOUT::OBJECT::clearance, F_Cu, F_Mask, F_Paste, FOOTPRINT, BOARD::Footprints(), FULL, BOARD_ITEM::GetBoard(), FOOTPRINT::GetFields(), In1_Cu, In2_Cu, SPRINT_LAYOUT::OBJECT::inner, IsBackLayer(), SPRINT_LAYOUT::OBJECT::layer, layerHasGroundPlane(), m_fileData, mapLayer(), SPRINT_LAYOUT::OBJECT::mirror_h, NONE, SPRINT_LAYOUT::OBJ_THT_PAD, SPRINT_LAYOUT::OBJECT::outer, OVAL, PAD, pad, FOOTPRINT::Pads(), SPRINT_LAYOUT::OBJECT::plated, SPRINT_LAYOUT::OBJECT::points, processItemGroups(), PTH, PAD::PTHMask(), RECT_CHAMFER_ALL, RECTANGLE, FOOTPRINT::Reference(), resolveItemNet(), SPRINT_LAYOUT::OBJECT::rotation, EDA_ANGLE::Round(), BOARD_ITEM::SetLayer(), FOOTPRINT::SetReference(), EDA_TEXT::SetVisible(), SMD, SPRINT_LAYOUT::OBJECT::soldermask, sprintToKicadCoord(), sprintToKicadPos(), SPRINT_LAYOUT::OBJECT::start_angle, THERMAL, SPRINT_LAYOUT::OBJECT::tht_shape, SPRINT_LAYOUT::THT_SHAPE_CIRCLE, SPRINT_LAYOUT::THT_SHAPE_H_CHAMFER, SPRINT_LAYOUT::THT_SHAPE_H_RECT, SPRINT_LAYOUT::THT_SHAPE_H_ROUND, SPRINT_LAYOUT::THT_SHAPE_OCT, SPRINT_LAYOUT::THT_SHAPE_SQUARE, SPRINT_LAYOUT::THT_SHAPE_V_CHAMFER, SPRINT_LAYOUT::THT_SHAPE_V_RECT, SPRINT_LAYOUT::THT_SHAPE_V_ROUND, SPRINT_LAYOUT::OBJECT::type, SPRINT_LAYOUT::OBJECT::x, SPRINT_LAYOUT::POINT::x, VECTOR2< T >::x, SPRINT_LAYOUT::OBJECT::y, SPRINT_LAYOUT::POINT::y, and VECTOR2< T >::y.

Referenced by CreateBoard(), and CreateFootprint().

◆ processPoly()

◆ processSegment()

void SPRINT_LAYOUT_PARSER::processSegment ( BOARD_ITEM_CONTAINER * aContainer,
const SPRINT_LAYOUT::OBJECT & aObj,
std::vector< std::vector< VECTOR2I > > & aOutlineSegments,
const uint8_t aGroundPlane[7],
NETINFO_ITEM * aGndPlaneNet,
std::map< uint32_t, std::set< BOARD_ITEM * > > & aGidToItems )
private

◆ processText()

◆ readCoord()

float SPRINT_LAYOUT_PARSER::readCoord ( )
private

Definition at line 170 of file sprint_layout_parser.cpp.

References m_fileData, readFloat(), readInt16(), and readInt32().

Referenced by parseObject(), and parsePoints().

◆ readDouble()

double SPRINT_LAYOUT_PARSER::readDouble ( )
private

Definition at line 149 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, and THROW_IO_ERROR.

Referenced by parseBoardHeader(), and parseObject().

◆ readFixedString()

std::string SPRINT_LAYOUT_PARSER::readFixedString ( size_t aMaxLen)
private

Definition at line 181 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, readUint8(), and THROW_IO_ERROR.

Referenced by parseBoardHeader(), parseObject(), and parseTrailer().

◆ readFloat()

float SPRINT_LAYOUT_PARSER::readFloat ( )
private

Definition at line 140 of file sprint_layout_parser.cpp.

References readUint32().

Referenced by readCoord().

◆ readInt16()

int16_t SPRINT_LAYOUT_PARSER::readInt16 ( )
private

Definition at line 96 of file sprint_layout_parser.cpp.

References readUint16().

Referenced by parseObject(), readCoord(), and readSigned().

◆ readInt32()

int32_t SPRINT_LAYOUT_PARSER::readInt32 ( )
private

Definition at line 134 of file sprint_layout_parser.cpp.

References readUint32().

Referenced by parseBoardHeader(), parseObject(), readCoord(), and readSigned().

◆ readSigned()

int32_t SPRINT_LAYOUT_PARSER::readSigned ( )
private

Definition at line 111 of file sprint_layout_parser.cpp.

References m_fileData, readInt16(), and readInt32().

Referenced by parseObject().

◆ readUint16()

uint16_t SPRINT_LAYOUT_PARSER::readUint16 ( )
private

Definition at line 84 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, and THROW_IO_ERROR.

Referenced by parseObject(), readInt16(), and readUnsigned().

◆ readUint32()

uint32_t SPRINT_LAYOUT_PARSER::readUint32 ( )
private

◆ readUint8()

uint8_t SPRINT_LAYOUT_PARSER::readUint8 ( )
private

Definition at line 75 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, and THROW_IO_ERROR.

Referenced by parseBoardHeader(), parseFileStart(), parseObject(), and readFixedString().

◆ readUnsigned()

uint32_t SPRINT_LAYOUT_PARSER::readUnsigned ( )
private

Definition at line 102 of file sprint_layout_parser.cpp.

References m_fileData, readUint16(), and readUint32().

Referenced by ParseBoard(), parseGroups(), parseObjectsList(), and parsePoints().

◆ readVarString()

std::string SPRINT_LAYOUT_PARSER::readVarString ( )
private

Definition at line 195 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, readUint32(), and THROW_IO_ERROR.

Referenced by parseObject(), and parseTrailer().

◆ resolveGroups()

void SPRINT_LAYOUT_PARSER::resolveGroups ( BOARD_ITEM_CONTAINER * aContainer,
std::map< uint32_t, std::set< BOARD_ITEM * > > & aGidToItems )
private

◆ resolveItemNet()

NETINFO_ITEM * SPRINT_LAYOUT_PARSER::resolveItemNet ( BOARD * aBoard,
const SPRINT_LAYOUT::OBJECT & aObj,
PCB_LAYER_ID aLayer,
const uint8_t aGroundPlane[7],
NETINFO_ITEM * aGndPlaneNet ) const
private

◆ seek()

void SPRINT_LAYOUT_PARSER::seek ( int aBytes)
private

Definition at line 220 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, m_start, and THROW_IO_ERROR.

Referenced by parsePoints().

◆ skip()

void SPRINT_LAYOUT_PARSER::skip ( size_t aBytes)
private

Definition at line 211 of file sprint_layout_parser.cpp.

References _, m_end, m_pos, and THROW_IO_ERROR.

Referenced by parseBoardHeader(), and parseObject().

◆ sprintToKicadCoord()

int SPRINT_LAYOUT_PARSER::sprintToKicadCoord ( float aValue) const
private

◆ sprintToKicadPos()

VECTOR2I SPRINT_LAYOUT_PARSER::sprintToKicadPos ( float aX,
float aY ) const
private

Member Data Documentation

◆ m_buffer

std::vector<uint8_t> SPRINT_LAYOUT_PARSER::m_buffer
private

Definition at line 255 of file sprint_layout_parser.h.

Referenced by parseFileStart().

◆ m_end

const uint8_t* SPRINT_LAYOUT_PARSER::m_end = nullptr
private

◆ m_fileData

◆ m_parsingMacro

bool SPRINT_LAYOUT_PARSER::m_parsingMacro = false
private

Definition at line 256 of file sprint_layout_parser.h.

Referenced by ParseBoard(), and ParseMacroFile().

◆ m_pos

const uint8_t* SPRINT_LAYOUT_PARSER::m_pos = nullptr
private

◆ m_start

const uint8_t* SPRINT_LAYOUT_PARSER::m_start = nullptr
private

Definition at line 253 of file sprint_layout_parser.h.

Referenced by parseFileStart(), and seek().


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