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

A component's outline as stored in an IDF library file. More...

#include <idf_outlines.h>

Inheritance diagram for IDF3_COMP_OUTLINE:
BOARD_OUTLINE

Public Member Functions

 IDF3_COMP_OUTLINE (IDF3_BOARD *aParent)
 
virtual bool Clear (void) override
 Delete internal outline data.
 
bool SetComponentClass (IDF3::COMP_TYPE aCompClass)
 Set the type of component outline (.ELECTRICAL or .MECHANICAL).
 
IDF3::COMP_TYPE GetComponentClass (void)
 
void SetGeomName (const std::string &aGeomName)
 Set the Geometry Name (Package Name, IDFv3 spec) of the component outline.
 
const std::string & GetGeomName (void)
 
void SetPartName (const std::string &aPartName)
 Set the Part Name (Part Number, IDFv3 spec) of the component outline.
 
const std::string & GetPartName (void)
 Return the Part Name (Part Number) of the component outline.
 
const std::string & GetUID (void)
 
bool CreateDefaultOutline (const std::string &aGeom, const std::string &aPart)
 Create a default outline with the given Geometry and Part names.
 
virtual bool SetUnit (IDF3::IDF_UNIT aUnit)
 Function SetUnit sets the native unit of the outline; except for component outlines this must be the same as the native unit of the parent IDF_BOARD object.
 
virtual IDF3::IDF_UNIT GetUnit (void)
 Return the native unit type of the outline.
 
virtual bool SetThickness (double aThickness)
 Set the thickness or height of the outline (mm).
 
virtual double GetThickness (void)
 
IDF3::OUTLINE_TYPE GetOutlineType (void)
 
IDF3_BOARD * GetParent (void)
 
bool AddOutline (IDF_OUTLINE *aOutline)
 Add the specified outline to this object.
 
bool DelOutline (IDF_OUTLINE *aOutline)
 Remove the given outline, subject to IDF ownership rules, if it is owned by this object.
 
bool DelOutline (size_t aIndex)
 Delete the outline specified by the given index, subject to IDF ownership rules.
 
const std::list< IDF_OUTLINE * > * GetOutlines (void)
 Return outlines list.
 
size_t OutlinesSize (void)
 
IDF_OUTLINE * GetOutline (size_t aIndex)
 Return a pointer to the outline as specified by aIndex.
 
IDF3::KEY_OWNER GetOwner (void)
 
bool SetOwner (IDF3::KEY_OWNER aOwner)
 Set the ownership status of the outline subject to IDF ownership rules.
 
bool IsSingle (void)
 
void ClearOutlines (void)
 Clear internal data except for the parent pointer.
 
void AddComment (const std::string &aComment)
 Add a comment to the outline data.
 
size_t CommentsSize (void)
 
std::list< std::string > * GetComments (void)
 
const std::string * GetComment (size_t aIndex)
 
bool DeleteComment (size_t aIndex)
 Deletes a comment based on the given index.
 
void ClearComments (void)
 Deletes all comments.
 
const std::string & GetError (void)
 

Protected Member Functions

void readOutlines (std::istream &aBoardFile, IDF3::IDF_VERSION aIdfVersion)
 
bool writeComments (std::ostream &aBoardFile)
 
bool writeOwner (std::ostream &aBoardFile)
 
void writeOutline (std::ostream &aBoardFile, IDF_OUTLINE *aOutline, size_t aIndex)
 
void writeOutlines (std::ostream &aBoardFile)
 
void clearOutlines (void)
 
void setParent (IDF3_BOARD *aParent)
 Set the parent IDF_BOARD object.
 
bool addOutline (IDF_OUTLINE *aOutline)
 
virtual bool setThickness (double aThickness)
 
virtual void clear (void)
 

Protected Attributes

std::string errormsg
 
std::list< IDF_OUTLINE * > outlines
 
IDF3::KEY_OWNER owner
 
IDF3::OUTLINE_TYPE outlineType
 
bool single
 
std::list< std::string > comments
 
IDF3::IDF_UNIT unit
 
IDF3_BOARD * parent
 
double thickness
 

Private Member Functions

void readProperties (std::istream &aLibFile)
 
bool writeProperties (std::ostream &aLibFile)
 
virtual void readData (std::istream &aLibFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
 Read a component outline from an open IDFv3 file.
 
virtual void writeData (std::ostream &aLibFile) override
 Write comments and component outline data to an IDFv3 Library file.
 
int incrementRef (void)
 Increment the internal reference counter to keep track of the number of components referring to this outline.
 
int decrementRef (void)
 Decrement the internal reference counter to keep track of the number of components referring to this outline.
 

Private Attributes

std::string uid
 
std::string geometry
 
std::string part
 
IDF3::COMP_TYPE compType
 
int refNum
 
std::map< std::string, std::string > props
 

Friends

class IDF3_BOARD
 
class IDF3_COMP_OUTLINE_DATA
 

Detailed Description

A component's outline as stored in an IDF library file.

Definition at line 615 of file idf_outlines.h.

Constructor & Destructor Documentation

◆ IDF3_COMP_OUTLINE()

IDF3_COMP_OUTLINE::IDF3_COMP_OUTLINE ( IDF3_BOARD * aParent)

Member Function Documentation

◆ AddComment()

void BOARD_OUTLINE::AddComment ( const std::string & aComment)
inherited

Add a comment to the outline data.

This function is not subject to IDF ownership rules.

Definition at line 1520 of file idf_outlines.cpp.

References comments.

Referenced by IDF3_BOARD::GetComponentOutline(), IDF3_BOARD::readBrdSection(), and IDF3_BOARD::readLibSection().

◆ AddOutline()

bool BOARD_OUTLINE::AddOutline ( IDF_OUTLINE * aOutline)
inherited

Add the specified outline to this object.

Parameters
aOutlineis a valid IDF outline.
Returns
true if the outline was added; false if the outline already existed or an ownership violation occurs.

Definition at line 1326 of file idf_outlines.cpp.

References addOutline(), CheckOwnership(), errormsg, outlineType, owner, and parent.

Referenced by IDF_EXPORTER::createOutlineFromExtrudedBody().

◆ addOutline()

bool BOARD_OUTLINE::addOutline ( IDF_OUTLINE * aOutline)
protectedinherited

Definition at line 1296 of file idf_outlines.cpp.

References errormsg, and outlines.

Referenced by AddOutline().

◆ Clear()

bool IDF3_COMP_OUTLINE::Clear ( void )
overridevirtual

◆ clear()

void BOARD_OUTLINE::clear ( void )
protectedvirtualinherited

◆ ClearComments()

void BOARD_OUTLINE::ClearComments ( void )
inherited

Deletes all comments.

Definition at line 1570 of file idf_outlines.cpp.

References comments.

◆ ClearOutlines()

void BOARD_OUTLINE::ClearOutlines ( void )
inherited

Clear internal data except for the parent pointer.

◆ clearOutlines()

void BOARD_OUTLINE::clearOutlines ( void )
protectedinherited

Definition at line 1505 of file idf_outlines.cpp.

References outlines.

Referenced by clear(), and readOutlines().

◆ CommentsSize()

size_t BOARD_OUTLINE::CommentsSize ( void )
inherited
Returns
the number of comments in the internal list.

Definition at line 1529 of file idf_outlines.cpp.

References comments.

◆ CreateDefaultOutline()

bool IDF3_COMP_OUTLINE::CreateDefaultOutline ( const std::string & aGeom,
const std::string & aPart )

Create a default outline with the given Geometry and Part names.

This outline is a star with outer radius 5mm and inner radius 2.5mm.

Definition at line 3560 of file idf_outlines.cpp.

References Clear(), IDF3::COMP_ELEC, compType, geometry, M_PI, BOARD_OUTLINE::outlines, part, IDF_OUTLINE::push(), BOARD_OUTLINE::thickness, uid, BOARD_OUTLINE::unit, IDF3::UNIT_MM, IDF_POINT::x, and IDF_POINT::y.

Referenced by IDF3_BOARD::GetInvalidOutline().

◆ decrementRef()

int IDF3_COMP_OUTLINE::decrementRef ( void )
private

Decrement the internal reference counter to keep track of the number of components referring to this outline.

Returns
the number of remaining references or -1 if there were no references when the function was invoked, in which case the error message is also set.

Definition at line 3543 of file idf_outlines.cpp.

References BOARD_OUTLINE::errormsg, and refNum.

◆ DeleteComment()

bool BOARD_OUTLINE::DeleteComment ( size_t aIndex)
inherited

Deletes a comment based on the given index.

Returns
true if a comment was deleted, false if the index is out of bounds.

Definition at line 1555 of file idf_outlines.cpp.

References comments.

◆ DelOutline() [1/2]

bool BOARD_OUTLINE::DelOutline ( IDF_OUTLINE * aOutline)
inherited

Remove the given outline, subject to IDF ownership rules, if it is owned by this object.

The outline pointer remains valid and it is the user's responsibility to delete the object. The first outline in the list will never be deleted unless it is the sole remaining outline; this is to ensure that a board outline is not removed while the cutouts remain.

Parameters
aOutlineis a pointer to the outline to remove from the list.
Returns
true if the outline was found and removed; false if the outline was not found or an ownership violation occurs.

Definition at line 1337 of file idf_outlines.cpp.

References errormsg, GetOutlineTypeString(), outlines, and outlineType.

◆ DelOutline() [2/2]

bool BOARD_OUTLINE::DelOutline ( size_t aIndex)
inherited

Delete the outline specified by the given index, subject to IDF ownership rules.

The outline data is destroyed. The first outline in the list will never be deleted unless it is the sole remaining outline; this is to ensure that a board outline is not removed while the cutouts remain.

Parameters
aIndexis an index to the outline to delete
Returns
true if the outline was found and deleted; false if the outline was not found or an ownership violation or indexation error occurs.

Definition at line 1395 of file idf_outlines.cpp.

References errormsg, GetOutlineTypeString(), outlines, and outlineType.

◆ GetComment()

const std::string * BOARD_OUTLINE::GetComment ( size_t aIndex)
inherited
Returns
indexed comment or NULL if the index is out of bounds.

Definition at line 1541 of file idf_outlines.cpp.

References comments.

◆ GetComments()

std::list< std::string > * BOARD_OUTLINE::GetComments ( void )
inherited
Returns
the internal list of comments.

Definition at line 1535 of file idf_outlines.cpp.

References comments.

◆ GetComponentClass()

IDF3::COMP_TYPE IDF3_COMP_OUTLINE::GetComponentClass ( void )

@return2 the class of component represented by this outline.

Definition at line 3491 of file idf_outlines.cpp.

References compType.

Referenced by MatchCompOutline().

◆ GetError()

const std::string & BOARD_OUTLINE::GetError ( void )
inlineinherited

Definition at line 253 of file idf_outlines.h.

References errormsg.

◆ GetGeomName()

const std::string & IDF3_COMP_OUTLINE::GetGeomName ( void )
Returns
the Geometry Name (Package Name) of the component outline.

Definition at line 3504 of file idf_outlines.cpp.

References geometry.

◆ GetOutline()

IDF_OUTLINE * BOARD_OUTLINE::GetOutline ( size_t aIndex)
inherited

Return a pointer to the outline as specified by aIndex.

If the index is out of bounds NULL is returned and the error message is set. It is the responsibility of the user to observe IDF ownership rules.

Definition at line 1460 of file idf_outlines.cpp.

References errormsg, and outlines.

Referenced by MatchCompOutline().

◆ GetOutlines()

const std::list< IDF_OUTLINE * > * BOARD_OUTLINE::GetOutlines ( void )
inherited

Return outlines list.

It is up to the user to respect the IDFv3 specification and avoid changes to this list which are in violation of the specification.

Definition at line 1448 of file idf_outlines.cpp.

References outlines.

Referenced by addOutline(), makeBoard(), and makeOtherOutlines().

◆ GetOutlineType()

IDF3::OUTLINE_TYPE BOARD_OUTLINE::GetOutlineType ( void )
inherited
Returns
the type of outline according to the IDFv3 classification.

Definition at line 145 of file idf_outlines.cpp.

References outlineType.

◆ GetOwner()

IDF3::KEY_OWNER BOARD_OUTLINE::GetOwner ( void )
inherited
Returns
the ownership status of the outline (ECAD, MCAD, UNOWNED).

Definition at line 1481 of file idf_outlines.cpp.

References owner.

◆ GetParent()

IDF3_BOARD * BOARD_OUTLINE::GetParent ( void )
inherited
Returns
the parent IDF_BOARD object.

Definition at line 1290 of file idf_outlines.cpp.

References IDF3_BOARD, and parent.

◆ GetPartName()

const std::string & IDF3_COMP_OUTLINE::GetPartName ( void )

Return the Part Name (Part Number) of the component outline.

Definition at line 3517 of file idf_outlines.cpp.

References part.

◆ GetThickness()

double BOARD_OUTLINE::GetThickness ( void )
virtualinherited
Returns
the thickness or height of an outline (mm).

Definition at line 1040 of file idf_outlines.cpp.

References thickness.

Referenced by addOutline(), and makeOtherOutlines().

◆ GetUID()

const std::string & IDF3_COMP_OUTLINE::GetUID ( void )
Returns
the unique identifier for this component outline, this is equal to GEOM_NAME + "_" + PART_NAME.

Definition at line 3523 of file idf_outlines.cpp.

References geometry, part, and uid.

Referenced by IDF3_BOARD::GetComponentOutline(), IDF3_BOARD::GetComponentOutline(), IDF3_BOARD::GetInvalidOutline(), makeComponents(), and IDF3_BOARD::readLibSection().

◆ GetUnit()

IDF3::IDF_UNIT BOARD_OUTLINE::GetUnit ( void )
virtualinherited

Return the native unit type of the outline.

Returns
IDF_UNIT is the native unit (UNIT_MM or UNIT_THOU).

Definition at line 1005 of file idf_outlines.cpp.

References unit.

◆ incrementRef()

int IDF3_COMP_OUTLINE::incrementRef ( void )
private

Increment the internal reference counter to keep track of the number of components referring to this outline.

Returns
the number of current references to this component outline.

Definition at line 3537 of file idf_outlines.cpp.

References refNum.

Referenced by IDF3_COMP_OUTLINE_DATA::IDF3_COMP_OUTLINE_DATA().

◆ IsSingle()

bool BOARD_OUTLINE::IsSingle ( void )
inherited
Returns
true if this type of outline only supports a single outline. All outlines except for BOARD_OUTLINE are single.

Definition at line 1499 of file idf_outlines.cpp.

References single.

◆ OutlinesSize()

size_t BOARD_OUTLINE::OutlinesSize ( void )
inherited
Returns
the number of items in the internal outline list.

Definition at line 1454 of file idf_outlines.cpp.

References outlines.

Referenced by IDF_EXPORTER::createOutlineFromExtrudedBody(), and MatchCompOutline().

◆ readData()

void IDF3_COMP_OUTLINE::readData ( std::istream & aLibFile,
const std::string & aHeader,
IDF3::IDF_VERSION aIdfVersion )
overrideprivatevirtual

Read a component outline from an open IDFv3 file.

If an unrecoverable error occurs, an exception is thrown.

Parameters
aLibFileis an open IDFv3 Library file.
aHeaderis the .ELECTRICAL or .MECHANICAL header as returned by FetchIDFLine.

Reimplemented from BOARD_OUTLINE.

Definition at line 3133 of file idf_outlines.cpp.

References IDF3::COMP_ELEC, IDF3::COMP_MECH, IDF3::CompareToken(), compType, IDF3::FetchIDFLine(), geometry, IDF3::GetIDFString(), GetOutlineTypeString(), IDF_THOU_TO_MM, IDF_TNM_TO_MM, IDF3::IDF_V2, BOARD_OUTLINE::outlineType, part, BOARD_OUTLINE::readOutlines(), readProperties(), BOARD_OUTLINE::thickness, BOARD_OUTLINE::unit, IDF3::UNIT_MM, IDF3::UNIT_THOU, and IDF3::UNIT_TNM.

Referenced by IDF3_BOARD::GetComponentOutline(), and IDF3_BOARD::readLibSection().

◆ readOutlines()

◆ readProperties()

void IDF3_COMP_OUTLINE::readProperties ( std::istream & aLibFile)
private

◆ SetComponentClass()

bool IDF3_COMP_OUTLINE::SetComponentClass ( IDF3::COMP_TYPE aCompClass)

Set the type of component outline (.ELECTRICAL or .MECHANICAL).

Returns
true on success, otherwise false and the error message is set.

Definition at line 3463 of file idf_outlines.cpp.

References IDF3::COMP_ELEC, IDF3::COMP_MECH, compType, and BOARD_OUTLINE::errormsg.

Referenced by IDF_EXPORTER::createOutlineFromExtrudedBody().

◆ SetGeomName()

void IDF3_COMP_OUTLINE::SetGeomName ( const std::string & aGeomName)

Set the Geometry Name (Package Name, IDFv3 spec) of the component outline.

Definition at line 3497 of file idf_outlines.cpp.

References geometry, and uid.

Referenced by IDF3_BOARD::GetComponentOutline().

◆ SetOwner()

bool BOARD_OUTLINE::SetOwner ( IDF3::KEY_OWNER aOwner)
inherited

Set the ownership status of the outline subject to IDF ownership rules.

Returns
true if the ownership was changed and false if a specification violation occurred.

Definition at line 1487 of file idf_outlines.cpp.

References CheckOwnership(), errormsg, outlineType, owner, and parent.

◆ setParent()

void BOARD_OUTLINE::setParent ( IDF3_BOARD * aParent)
protectedinherited

◆ SetPartName()

void IDF3_COMP_OUTLINE::SetPartName ( const std::string & aPartName)

Set the Part Name (Part Number, IDFv3 spec) of the component outline.

Definition at line 3510 of file idf_outlines.cpp.

References part, and uid.

Referenced by IDF3_BOARD::GetComponentOutline().

◆ SetThickness()

bool BOARD_OUTLINE::SetThickness ( double aThickness)
virtualinherited

Set the thickness or height of the outline (mm).

Parameters
aThicknessis the thickness or height of the outline in mm.

Definition at line 1029 of file idf_outlines.cpp.

References CheckOwnership(), errormsg, outlineType, owner, parent, and setThickness().

Referenced by IDF_EXPORTER::createOutlineFromExtrudedBody().

◆ setThickness()

bool BOARD_OUTLINE::setThickness ( double aThickness)
protectedvirtualinherited

Definition at line 1011 of file idf_outlines.cpp.

References errormsg, GetOutlineTypeString(), outlineType, and thickness.

Referenced by SetThickness().

◆ SetUnit()

bool BOARD_OUTLINE::SetUnit ( IDF3::IDF_UNIT aUnit)
virtualinherited

Function SetUnit sets the native unit of the outline; except for component outlines this must be the same as the native unit of the parent IDF_BOARD object.

Parameters
aUnitis the native unit (UNIT_MM or UNIT_THOU)

Definition at line 985 of file idf_outlines.cpp.

References errormsg, GetOutlineTypeString(), outlineType, unit, IDF3::UNIT_MM, IDF3::UNIT_THOU, and IDF3::UNIT_TNM.

Referenced by IDF_EXPORTER::createOutlineFromExtrudedBody(), and IDF3_BOARD::readBrdSection().

◆ writeComments()

bool BOARD_OUTLINE::writeComments ( std::ostream & aBoardFile)
protectedinherited

◆ writeData()

void IDF3_COMP_OUTLINE::writeData ( std::ostream & aLibFile)
overrideprivatevirtual

Write comments and component outline data to an IDFv3 Library file.

Parameters
aLibFileis an IDFv3 library file open for writing.
Returns
true if the data was successfully written, otherwise false.

Reimplemented from BOARD_OUTLINE.

Definition at line 3399 of file idf_outlines.cpp.

References IDF3::COMP_ELEC, IDF3::COMP_MECH, compType, geometry, IDF_THOU_TO_MM, part, refNum, BOARD_OUTLINE::thickness, BOARD_OUTLINE::unit, IDF3::UNIT_THOU, BOARD_OUTLINE::writeComments(), BOARD_OUTLINE::writeOutlines(), and writeProperties().

◆ writeOutline()

◆ writeOutlines()

void BOARD_OUTLINE::writeOutlines ( std::ostream & aBoardFile)
protectedinherited

◆ writeOwner()

bool BOARD_OUTLINE::writeOwner ( std::ostream & aBoardFile)
protectedinherited

◆ writeProperties()

bool IDF3_COMP_OUTLINE::writeProperties ( std::ostream & aLibFile)
private

Definition at line 3114 of file idf_outlines.cpp.

References props.

Referenced by writeData().

Friends And Related Symbol Documentation

◆ IDF3_BOARD

friend class IDF3_BOARD
friend

Definition at line 673 of file idf_outlines.h.

References IDF3_BOARD.

Referenced by IDF3_BOARD, and IDF3_COMP_OUTLINE().

◆ IDF3_COMP_OUTLINE_DATA

friend class IDF3_COMP_OUTLINE_DATA
friend

Definition at line 674 of file idf_outlines.h.

References IDF3_COMP_OUTLINE_DATA.

Referenced by IDF3_COMP_OUTLINE_DATA.

Member Data Documentation

◆ comments

std::list< std::string > BOARD_OUTLINE::comments
protectedinherited

◆ compType

IDF3::COMP_TYPE IDF3_COMP_OUTLINE::compType
private

◆ errormsg

◆ geometry

std::string IDF3_COMP_OUTLINE::geometry
private

◆ outlines

◆ outlineType

◆ owner

◆ parent

◆ part

std::string IDF3_COMP_OUTLINE::part
private

◆ props

std::map< std::string, std::string > IDF3_COMP_OUTLINE::props
private

Definition at line 721 of file idf_outlines.h.

Referenced by Clear(), readProperties(), and writeProperties().

◆ refNum

int IDF3_COMP_OUTLINE::refNum
private

Definition at line 719 of file idf_outlines.h.

Referenced by Clear(), decrementRef(), IDF3_COMP_OUTLINE(), incrementRef(), and writeData().

◆ single

◆ thickness

◆ uid

std::string IDF3_COMP_OUTLINE::uid
private

Definition at line 715 of file idf_outlines.h.

Referenced by Clear(), CreateDefaultOutline(), GetUID(), SetGeomName(), and SetPartName().

◆ unit


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