KiCad PCB EDA Suite
Loading...
Searching...
No Matches
IDF3 Namespace Reference

Enumerations

enum class  FILE_STATE {
  FILE_START = 0 , FILE_HEADER , FILE_OUTLINE , FILE_PLACEMENT ,
  FILE_INVALID , FILE_ERROR
}
 State values for the IDF parser's input. More...
 
enum class  IDF_VERSION { IDF_V2 = 0 , IDF_V3 }
 The supported IDF versions (3.0 and 2.0 ONLY). More...
 
enum class  KEY_OWNER { UNOWNED = 0 , MCAD , ECAD }
 The type of CAD which has ownership an object. More...
 
enum class  KEY_HOLETYPE {
  PIN = 0 , VIA , MTG , TOOL ,
  OTHER
}
 The purpose of an IDF hole. More...
 
enum class  KEY_PLATING { PTH = 0 , NPTH }
 The plating condition of a hole. More...
 
enum class  KEY_REFDES { BOARD = 0 , NOREFDES , PANEL , REFDES }
 A component's Reference Designator. More...
 
enum class  CAD_TYPE { CAD_ELEC = 0 , CAD_MECH , CAD_INVALID }
 The class of CAD program which is opening or modifying a file. More...
 
enum class  IDF_LAYER {
  LYR_TOP = 0 , LYR_BOTTOM , LYR_BOTH , LYR_INNER ,
  LYR_ALL , LYR_INVALID
}
 The various IDF layer classes and groupings. More...
 
enum class  OUTLINE_TYPE {
  OTLN_BOARD = 0 , OTLN_OTHER , OTLN_PLACE , OTLN_ROUTE ,
  OTLN_PLACE_KEEPOUT , OTLN_ROUTE_KEEPOUT , OTLN_VIA_KEEPOUT , OTLN_GROUP_PLACE ,
  OTLN_COMPONENT , OTLN_INVALID
}
 The class of outline. More...
 
enum class  COMP_TYPE { COMP_ELEC = 0 , COMP_MECH , COMP_INVALID }
 Whether a component is a mechanical or electrical part. More...
 
enum class  IDF_UNIT { UNIT_MM = 0 , UNIT_THOU , UNIT_TNM , UNIT_INVALID }
 The native unit of the board and of component outlines. More...
 
enum class  IDF_PLACEMENT {
  PS_UNPLACED = 0 , PS_PLACED , PS_MCAD , PS_ECAD ,
  PS_INVALID
}
 The placement status of a component. More...
 

Functions

double CalcAngleRad (const IDF_POINT &aStartPoint, const IDF_POINT &aEndPoint)
 Calculate the angle (radians) between the horizon and the segment aStartPoint to aEndPoint.
 
double CalcAngleDeg (const IDF_POINT &aStartPoint, const IDF_POINT &aEndPoint)
 Calculate the angle (degrees) between the horizon and the segment aStartPoint to aEndPoint.
 
void GetOutline (std::list< IDF_SEGMENT * > &aLines, IDF_OUTLINE &aOutline)
 Take contiguous elements from 'aLines' and stuffs them into 'aOutline'; elements put into the outline are deleted from aLines.
 
bool FetchIDFLine (std::istream &aModel, std::string &aLine, bool &isComment, std::streampos &aFilePos)
 Retrieve a single line from an IDF file and performs minimal processing.
 
bool GetIDFString (const std::string &aLine, std::string &aIDFString, bool &hasQuotes, int &aIndex)
 Parse a line retrieved via FetchIDFLine() and returns the first IDF string found from the starting point aIndex.
 
bool CompareToken (const char *aTokenString, const std::string &aInputString)
 Perform a case-insensitive comparison of a token string and an input string.
 
bool ParseOwner (const std::string &aToken, IDF3::KEY_OWNER &aOwner)
 Parse the input string for a valid IDF Owner type.
 
bool ParseIDFLayer (const std::string &aToken, IDF3::IDF_LAYER &aLayer)
 Parse an input string for a valid IDF layer specification.
 
bool WriteLayersText (std::ostream &aBoardFile, IDF3::IDF_LAYER aLayer)
 Write out text corresponding to the given IDF Layer type.
 
std::string GetPlacementString (IDF3::IDF_PLACEMENT aPlacement)
 Return a string representing the given IDF Placement type.
 
std::string GetLayerString (IDF3::IDF_LAYER aLayer)
 Return a string representing the given IDF Layer type.
 
std::string GetOwnerString (IDF3::KEY_OWNER aOwner)
 

Enumeration Type Documentation

◆ CAD_TYPE

enum class IDF3::CAD_TYPE
strong

The class of CAD program which is opening or modifying a file.

Enumerator
CAD_ELEC 
CAD_MECH 
CAD_INVALID 

Definition at line 126 of file idf_common.h.

◆ COMP_TYPE

enum class IDF3::COMP_TYPE
strong

Whether a component is a mechanical or electrical part.

Enumerator
COMP_ELEC 
COMP_MECH 
COMP_INVALID 

Definition at line 166 of file idf_common.h.

◆ FILE_STATE

enum class IDF3::FILE_STATE
strong

State values for the IDF parser's input.

Enumerator
FILE_START 
FILE_HEADER 
FILE_OUTLINE 
FILE_PLACEMENT 
FILE_INVALID 
FILE_ERROR 

Definition at line 62 of file idf_common.h.

◆ IDF_LAYER

enum class IDF3::IDF_LAYER
strong

The various IDF layer classes and groupings.

Enumerator
LYR_TOP 
LYR_BOTTOM 
LYR_BOTH 
LYR_INNER 
LYR_ALL 
LYR_INVALID 

Definition at line 136 of file idf_common.h.

◆ IDF_PLACEMENT

enum class IDF3::IDF_PLACEMENT
strong

The placement status of a component.

Enumerator
PS_UNPLACED 
PS_PLACED 
PS_MCAD 
PS_ECAD 
PS_INVALID 

Definition at line 187 of file idf_common.h.

◆ IDF_UNIT

enum class IDF3::IDF_UNIT
strong

The native unit of the board and of component outlines.

Enumerator
UNIT_MM 
UNIT_THOU 
UNIT_TNM 
UNIT_INVALID 

Definition at line 176 of file idf_common.h.

◆ IDF_VERSION

enum class IDF3::IDF_VERSION
strong

The supported IDF versions (3.0 and 2.0 ONLY).

Enumerator
IDF_V2 
IDF_V3 

Definition at line 75 of file idf_common.h.

◆ KEY_HOLETYPE

enum class IDF3::KEY_HOLETYPE
strong

The purpose of an IDF hole.

Enumerator
PIN 
VIA 
MTG 
TOOL 
OTHER 

Definition at line 94 of file idf_common.h.

◆ KEY_OWNER

enum class IDF3::KEY_OWNER
strong

The type of CAD which has ownership an object.

Enumerator
UNOWNED 
MCAD 
ECAD 

Definition at line 84 of file idf_common.h.

◆ KEY_PLATING

enum class IDF3::KEY_PLATING
strong

The plating condition of a hole.

Enumerator
PTH 
NPTH 

Definition at line 106 of file idf_common.h.

◆ KEY_REFDES

enum class IDF3::KEY_REFDES
strong

A component's Reference Designator.

Enumerator
BOARD 
NOREFDES 
PANEL 
REFDES 

Definition at line 115 of file idf_common.h.

◆ OUTLINE_TYPE

enum class IDF3::OUTLINE_TYPE
strong

The class of outline.

Enumerator
OTLN_BOARD 
OTLN_OTHER 
OTLN_PLACE 
OTLN_ROUTE 
OTLN_PLACE_KEEPOUT 
OTLN_ROUTE_KEEPOUT 
OTLN_VIA_KEEPOUT 
OTLN_GROUP_PLACE 
OTLN_COMPONENT 
OTLN_INVALID 

Definition at line 149 of file idf_common.h.

Function Documentation

◆ CalcAngleDeg()

double IDF3::CalcAngleDeg ( const IDF_POINT & aStartPoint,
const IDF_POINT & aEndPoint )

Calculate the angle (degrees) between the horizon and the segment aStartPoint to aEndPoint.

Parameters
aStartPointis the start point of a line segment.
aEndPointis the end point of a line segment.
Returns
the angle in degrees.

Definition at line 826 of file idf_common.cpp.

References CalcAngleRad(), and M_PI.

Referenced by IDF_SEGMENT::CalcCenterAndRadius(), IDF_SEGMENT::IDF_SEGMENT(), and IDF_SEGMENT::SwapEnds().

◆ CalcAngleRad()

double IDF3::CalcAngleRad ( const IDF_POINT & aStartPoint,
const IDF_POINT & aEndPoint )

Calculate the angle (radians) between the horizon and the segment aStartPoint to aEndPoint.

Parameters
aStartPointis the start point of a line segment.
aEndPointis the end point of a line segment.
Returns
the angle in radians.

Definition at line 820 of file idf_common.cpp.

References IDF_POINT::x, and IDF_POINT::y.

Referenced by CalcAngleDeg(), and IDF_SEGMENT::CalcCenterAndRadius().

◆ CompareToken()

◆ FetchIDFLine()

bool IDF3::FetchIDFLine ( std::istream & aModel,
std::string & aLine,
bool & isComment,
std::streampos & aFilePos )

Retrieve a single line from an IDF file and performs minimal processing.

If a comment symbol is encountered then it is removed and a single leading space is removed if present; all trailing spaces are removed. If the line is not a comment then all leading and trailing spaces are stripped.

Parameters
[in]aModelis an open IDFv3 file.
[out]aLineis the line retrieved from the file.
[out]isCommentis set to true if the line is a comment.
[out]aFilePosisset to the beginning of the line in case the file needs to be rewound.
Returns
true if a line was read and was not empty; otherwise false.

Definition at line 32 of file idf_helpers.cpp.

Referenced by IDF3_BOARD::GetComponentOutline(), IDF_DRILL_DATA::read(), IDF3_BOARD::readBoardFile(), IDF3_BOARD::readBrdHeader(), IDF3_BOARD::readBrdSection(), BOARD_OUTLINE::readData(), GROUP_OUTLINE::readData(), IDF3_COMP_OUTLINE::readData(), OTHER_OUTLINE::readData(), PLACE_OUTLINE::readData(), ROUTE_OUTLINE::readData(), IDF3_BOARD::readLibHeader(), IDF3_BOARD::readLibSection(), IDF_NOTE::readNote(), BOARD_OUTLINE::readOutlines(), IDF3_COMP_OUTLINE_DATA::readPlaceData(), and IDF3_COMP_OUTLINE::readProperties().

◆ GetIDFString()

bool IDF3::GetIDFString ( const std::string & aLine,
std::string & aIDFString,
bool & hasQuotes,
int & aIndex )

Parse a line retrieved via FetchIDFLine() and returns the first IDF string found from the starting point aIndex.

Parameters
[in]aLineis the line to parse.
[out]aIDFStringis the IDF string retrieved.
[out]hasQuotesis true if the string was in quotation marks.
[in,out]aIndexis the index into the input line.
Returns
true if a string was retrieved, otherwise false.

Definition at line 68 of file idf_helpers.cpp.

References ERROR_IDF.

Referenced by IDF_DRILL_DATA::read(), IDF3_BOARD::readBrdHeader(), IDF3_BOARD::readBrdSection(), BOARD_OUTLINE::readData(), GROUP_OUTLINE::readData(), IDF3_COMP_OUTLINE::readData(), OTHER_OUTLINE::readData(), PLACE_OUTLINE::readData(), ROUTE_OUTLINE::readData(), IDF3_BOARD::readLibHeader(), IDF3_BOARD::readLibSection(), IDF_NOTE::readNote(), BOARD_OUTLINE::readOutlines(), IDF3_COMP_OUTLINE_DATA::readPlaceData(), and IDF3_COMP_OUTLINE::readProperties().

◆ GetLayerString()

std::string IDF3::GetLayerString ( IDF3::IDF_LAYER aLayer)

Return a string representing the given IDF Layer type.

Parameters
aLayeris the IDF layer type to encode as a string.
Returns
the string representation of aLayer.

Definition at line 271 of file idf_helpers.cpp.

References LYR_ALL, LYR_BOTH, LYR_BOTTOM, LYR_INNER, and LYR_TOP.

Referenced by IDF3_COMP_OUTLINE_DATA::readPlaceData(), IDF3_COMPONENT::SetPosition(), and IDF3_COMP_OUTLINE_DATA::writePlaceData().

◆ GetOutline()

void IDF3::GetOutline ( std::list< IDF_SEGMENT * > & aLines,
IDF_OUTLINE & aOutline )

Take contiguous elements from 'aLines' and stuffs them into 'aOutline'; elements put into the outline are deleted from aLines.

This function is useful for sorting the jumbled mess of line segments and arcs which represent a board outline and cutouts in KiCad. The function will determine which segment element within aLines contains the leftmost point and retrieve the outline of which that segment is part.

Parameters
aLines(input/output) is a list of IDF segments which comprise an outline and cutouts.
aOutline(output) is the ordered set of segments/

Definition at line 839 of file idf_common.cpp.

References IDF_SEGMENT::angle, IDF_OUTLINE::back(), IDF_OUTLINE::Clear(), IDF_SEGMENT::endPoint, IDF_OUTLINE::front(), IDF_SEGMENT::IsCircle(), IDF_SEGMENT::MatchesStart(), MIN_ANG, IDF_OUTLINE::push(), IDF_OUTLINE::size(), and IDF_SEGMENT::startPoint.

Referenced by IDF_EXPORTER::createOutlineFromExtrudedBody(), IDF_EXPORTER::exportFootprint(), and idf_export_outline().

◆ GetOwnerString()

std::string IDF3::GetOwnerString ( IDF3::KEY_OWNER aOwner)

Definition at line 301 of file idf_helpers.cpp.

References ECAD, MCAD, and UNOWNED.

Referenced by CheckOwnership().

◆ GetPlacementString()

std::string IDF3::GetPlacementString ( IDF3::IDF_PLACEMENT aPlacement)

Return a string representing the given IDF Placement type.

Parameters
aPlacementis the IDF placement type to encode as a string.
Returns
the string representation of aPlacement.

Definition at line 244 of file idf_helpers.cpp.

References PS_ECAD, PS_MCAD, PS_PLACED, and PS_UNPLACED.

Referenced by IDF3_BOARD::checkComponentOwnership(), IDF3_COMP_OUTLINE_DATA::checkOwnership(), IDF3_COMPONENT::checkOwnership(), and IDF3_COMP_OUTLINE_DATA::readPlaceData().

◆ ParseIDFLayer()

bool IDF3::ParseIDFLayer ( const std::string & aToken,
IDF3::IDF_LAYER & aLayer )

Parse an input string for a valid IDF layer specification.

Parameters
[in]aTokenis the string to be parsed.
[out]aLayeris the IDF Layer type or group.
Returns
true if a valid IDF Layer type was found, otherwise false.

Definition at line 169 of file idf_helpers.cpp.

References CompareToken(), ERROR_IDF, LYR_ALL, LYR_BOTH, LYR_BOTTOM, LYR_INNER, LYR_INVALID, and LYR_TOP.

Referenced by GROUP_OUTLINE::readData(), OTHER_OUTLINE::readData(), PLACE_OUTLINE::readData(), and ROUTE_OUTLINE::readData().

◆ ParseOwner()

bool IDF3::ParseOwner ( const std::string & aToken,
IDF3::KEY_OWNER & aOwner )

Parse the input string for a valid IDF Owner type.

Parameters
[in]aTokenis the string to be parsed.
[out]aOwneris the IDF Owner class.
Returns
true if a valid OWNER was found, otherwise false.

Definition at line 145 of file idf_helpers.cpp.

References CompareToken(), ECAD, ERROR_IDF, MCAD, and UNOWNED.

Referenced by IDF_DRILL_DATA::read(), BOARD_OUTLINE::readData(), GROUP_OUTLINE::readData(), OTHER_OUTLINE::readData(), PLACE_OUTLINE::readData(), and ROUTE_OUTLINE::readData().

◆ WriteLayersText()

bool IDF3::WriteLayersText ( std::ostream & aBoardFile,
IDF3::IDF_LAYER aLayer )

Write out text corresponding to the given IDF Layer type.

Parameters
[in]aBoardFileis an IDFv3 file open for output.
aLayeris the IDF Layer type.
Returns
true if the data was successfully written, otherwise false

Definition at line 204 of file idf_helpers.cpp.

References LYR_ALL, LYR_BOTH, LYR_BOTTOM, LYR_INNER, and LYR_TOP.

Referenced by GROUP_OUTLINE::writeData(), OTHER_OUTLINE::writeData(), PLACE_OUTLINE::writeData(), ROUTE_OUTLINE::writeData(), and IDF3_COMP_OUTLINE_DATA::writePlaceData().