KiCad PCB EDA Suite
DSN::PLACE Class Reference

PLACE implements the <placement_reference> in the specctra dsn spec. More...

#include <specctra.h>

Inheritance diagram for DSN::PLACE:
DSN::ELEM

Public Member Functions

 PLACE (ELEM *aParent)
 
 ~PLACE ()
 
void SetVertex (const POINT &aVertex)
 
void SetRotation (double aRotation)
 
void Format (OUTPUTFORMATTER *out, int nestLevel) override
 Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
DSN_T Type () const
 
const char * Name () const
 
virtual UNIT_RESGetUnits () const
 Function GetUnits returns the units for this section. More...
 
virtual void FormatContents (OUTPUTFORMATTER *out, int nestLevel)
 Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
void SetParent (ELEM *aParent)
 

Protected Member Functions

std::string makeHash ()
 Function makeHash returns a string which uniquely represents this ELEM amoung other ELEMs of the same derived class as "this" one. More...
 

Protected Attributes

DSN_T type
 
ELEMparent
 

Static Protected Attributes

static STRING_FORMATTER sf
 

Private Attributes

std::string component_id
 reference designator More...
 
DSN_T side
 
double rotation
 
bool hasVertex
 
POINT vertex
 
DSN_T mirror
 
DSN_T status
 
std::string logical_part
 
RULEplace_rules
 
PROPERTIES properties
 
DSN_T lock_type
 
RULErules
 
REGIONregion
 
std::string part_number
 

Friends

class SPECCTRA_DB
 

Detailed Description

PLACE implements the <placement_reference> in the specctra dsn spec.

Definition at line 1674 of file specctra.h.

Constructor & Destructor Documentation

◆ PLACE()

DSN::PLACE::PLACE ( ELEM aParent)
inline

Definition at line 1707 of file specctra.h.

1707  :
1708  ELEM( T_place, aParent )
1709  {
1710  side = T_front;
1711 
1712  rotation = 0.0;
1713 
1714  hasVertex = false;
1715 
1716  mirror = T_NONE;
1717  status = T_NONE;
1718 
1719  place_rules = 0;
1720 
1721  lock_type = T_NONE;
1722  rules = 0;
1723  region = 0;
1724  }
DSN_T lock_type
Definition: specctra.h:1696
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3494
DSN_T status
Definition: specctra.h:1688
double rotation
Definition: specctra.h:1682
bool hasVertex
Definition: specctra.h:1684
DSN_T side
Definition: specctra.h:1680
RULE * place_rules
Definition: specctra.h:1692
RULE * rules
Definition: specctra.h:1699
REGION * region
Definition: specctra.h:1700
DSN_T mirror
Definition: specctra.h:1687

References hasVertex, lock_type, mirror, place_rules, region, rotation, rules, side, and status.

◆ ~PLACE()

DSN::PLACE::~PLACE ( )
inline

Definition at line 1726 of file specctra.h.

1727  {
1728  delete place_rules;
1729  delete rules;
1730  delete region;
1731  }
RULE * place_rules
Definition: specctra.h:1692
RULE * rules
Definition: specctra.h:1699
REGION * region
Definition: specctra.h:1700

References place_rules, region, and rules.

Member Function Documentation

◆ Format()

void DSN::PLACE::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
overridevirtual

Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.

Parameters
outThe formatter to write to.
nestLevelA multiple of the number of spaces to preceed the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Reimplemented from DSN::ELEM.

Definition at line 3677 of file specctra.cpp.

3678 {
3679  bool useMultiLine;
3680 
3681  const char* quote = out->GetQuoteChar( component_id.c_str() );
3682 
3683  if( place_rules || properties.size() || rules || region )
3684  {
3685  useMultiLine = true;
3686 
3687  out->Print( nestLevel, "(%s %s%s%s\n",
3688  Name(),
3689  quote, component_id.c_str(), quote );
3690 
3691  out->Print( nestLevel+1, "%s", "" );
3692  }
3693  else
3694  {
3695  useMultiLine = false;
3696 
3697  out->Print( nestLevel, "(%s %s%s%s",
3698  Name(),
3699  quote, component_id.c_str(), quote );
3700  }
3701 
3702  if( hasVertex )
3703  {
3704  out->Print( 0, " %.6f %.6f", vertex.x, vertex.y );
3705 
3706  out->Print( 0, " %s", GetTokenText( side ) );
3707 
3708  out->Print( 0, " %.6f", rotation );
3709  }
3710 
3711  const char* space = " "; // one space, as c string.
3712 
3713  if( mirror != T_NONE )
3714  {
3715  out->Print( 0, "%s(mirror %s)", space, GetTokenText( mirror ) );
3716  space = "";
3717  }
3718 
3719  if( status != T_NONE )
3720  {
3721  out->Print( 0, "%s(status %s)", space, GetTokenText( status ) );
3722  space = "";
3723  }
3724 
3725  if( logical_part.size() )
3726  {
3727  quote = out->GetQuoteChar( logical_part.c_str() );
3728  out->Print( 0, "%s(logical_part %s%s%s)", space, quote, logical_part.c_str(), quote );
3729  space = "";
3730  }
3731 
3732  if( useMultiLine )
3733  {
3734  out->Print( 0, "\n" );
3735  if( place_rules )
3736  {
3737  place_rules->Format( out, nestLevel+1 );
3738  }
3739 
3740  if( properties.size() )
3741  {
3742  out->Print( nestLevel+1, "(property \n" );
3743 
3744  for( PROPERTIES::const_iterator i = properties.begin(); i != properties.end(); ++i )
3745  i->Format( out, nestLevel+2 );
3746 
3747  out->Print( nestLevel+1, ")\n" );
3748  }
3749 
3750  if( lock_type != T_NONE )
3751  out->Print( nestLevel+1, "(lock_type %s)\n", GetTokenText(lock_type) );
3752 
3753  if( rules )
3754  rules->Format( out, nestLevel+1 );
3755 
3756  if( region )
3757  region->Format( out, nestLevel+1 );
3758 
3759  if( part_number.size() )
3760  {
3761  quote = out->GetQuoteChar( part_number.c_str() );
3762  out->Print( nestLevel+1, "(PN %s%s%s)\n", quote, part_number.c_str(), quote );
3763  }
3764  }
3765  else
3766  {
3767  if( lock_type != T_NONE )
3768  {
3769  out->Print( 0, "%s(lock_type %s)", space, GetTokenText(lock_type) );
3770  space = "";
3771  }
3772 
3773  if( part_number.size() )
3774  {
3775  quote = out->GetQuoteChar( part_number.c_str() );
3776  out->Print( 0, "%s(PN %s%s%s)", space, quote, part_number.c_str(), quote );
3777  }
3778  }
3779 
3780  out->Print( 0, ")\n" );
3781 }
DSN_T lock_type
Definition: specctra.h:1696
double y
Definition: specctra.h:96
const char * Name() const
Definition: specctra.cpp:3505
std::string part_number
Definition: specctra.h:1703
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:501
std::string logical_part
Definition: specctra.h:1690
double x
Definition: specctra.h:95
DSN_T status
Definition: specctra.h:1688
POINT vertex
Definition: specctra.h:1685
double rotation
Definition: specctra.h:1682
bool hasVertex
Definition: specctra.h:1684
DSN_T side
Definition: specctra.h:1680
PROPERTIES properties
Definition: specctra.h:1694
RULE * place_rules
Definition: specctra.h:1692
std::string component_id
reference designator
Definition: specctra.h:1678
RULE * rules
Definition: specctra.h:1699
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.cpp:3519
static const char * GetQuoteChar(const char *wrapee, const char *quote_char)
Perform quote character need determination according to the Specctra DSN specification.
Definition: richio.cpp:331
REGION * region
Definition: specctra.h:1700
DSN_T mirror
Definition: specctra.h:1687
const char * GetTokenText(T aTok)
Function GetTokenText is in the DSN namespace and returns the C string representing a SPECCTRA_DB::ke...
Definition: specctra.cpp:69
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408

References component_id, DSN::ELEM::Format(), DSN::RULE::Format(), OUTPUTFORMATTER::GetQuoteChar(), DSN::GetTokenText(), hasVertex, lock_type, logical_part, mirror, DSN::ELEM::Name(), part_number, place_rules, OUTPUTFORMATTER::Print(), properties, region, rotation, rules, side, status, vertex, DSN::POINT::x, and DSN::POINT::y.

◆ FormatContents()

virtual void DSN::ELEM::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
inlinevirtualinherited

Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.

This is the same as Format() except that the outer wrapper is not included.

Parameters
outThe formatter to write to.
nestLevelA multiple of the number of spaces to preceed the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Reimplemented in DSN::WAS_IS, DSN::ROUTE, DSN::HISTORY, DSN::WIRING, DSN::NETWORK, DSN::TOPOLOGY, DSN::LIBRARY, DSN::PADSTACK, DSN::IMAGE, DSN::PLACEMENT, DSN::COMPONENT, DSN::STRUCTURE, DSN::STRUCTURE_OUT, DSN::REGION, DSN::CLASS_CLASS, DSN::CLASSES, DSN::PARSER, and DSN::ELEM_HOLDER.

Definition at line 263 of file specctra.h.

264  {
265  // overridden in ELEM_HOLDER
266  }

Referenced by DSN::ELEM::Format(), and DSN::ELEM::makeHash().

◆ GetUnits()

UNIT_RES * DSN::ELEM::GetUnits ( ) const
virtualinherited

Function GetUnits returns the units for this section.

Derived classes may override this to check for section specific overrides.

Returns
UNIT_RES* - from a local or parent scope

Reimplemented in DSN::ROUTE, DSN::PCB, DSN::WIRING, DSN::LIBRARY, DSN::PADSTACK, DSN::IMAGE, DSN::PLACEMENT, and DSN::STRUCTURE.

Definition at line 3510 of file specctra.cpp.

3511 {
3512  if( parent )
3513  return parent->GetUnits();
3514 
3515  return &UNIT_RES::Default;
3516 }
ELEM * parent
Definition: specctra.h:199
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:413
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3510

References DSN::UNIT_RES::Default, DSN::ELEM::GetUnits(), and DSN::ELEM::parent.

Referenced by DSN::SPECCTRA_DB::FromSESSION(), DSN::ELEM::GetUnits(), DSN::STRUCTURE::GetUnits(), DSN::PLACEMENT::GetUnits(), DSN::IMAGE::GetUnits(), DSN::PADSTACK::GetUnits(), DSN::LIBRARY::GetUnits(), DSN::WIRING::GetUnits(), DSN::PCB::GetUnits(), and DSN::ROUTE::GetUnits().

◆ makeHash()

std::string DSN::ELEM::makeHash ( )
inlineprotectedinherited

Function makeHash returns a string which uniquely represents this ELEM amoung other ELEMs of the same derived class as "this" one.

It is not useable for all derived classes, only those which plan for it by implementing a FormatContents() function that captures all info which will be used in the subsequent string compare. THIS SHOULD NORMALLY EXCLUDE THE TYPENAME, AND INSTANCE NAME OR ID AS WELL.

Definition at line 211 of file specctra.h.

212  {
213  sf.Clear();
214  FormatContents( &sf, 0 );
215  sf.StripUseless();
216 
217  return sf.GetString();
218  }
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:263
const std::string & GetString()
Definition: richio.h:435
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:494
static STRING_FORMATTER sf
Definition: specctra.h:221
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:425

References STRING_FORMATTER::Clear(), DSN::ELEM::FormatContents(), STRING_FORMATTER::GetString(), DSN::ELEM::sf, and STRING_FORMATTER::StripUseless().

Referenced by DSN::IMAGE::Compare(), and DSN::PADSTACK::Compare().

◆ Name()

◆ SetParent()

◆ SetRotation()

void DSN::PLACE::SetRotation ( double  aRotation)
inline

Definition at line 1740 of file specctra.h.

1741  {
1742  rotation = aRotation;
1743  }
double rotation
Definition: specctra.h:1682

References rotation.

Referenced by DSN::SPECCTRA_DB::doPLACE(), and DSN::SPECCTRA_DB::FromBOARD().

◆ SetVertex()

void DSN::PLACE::SetVertex ( const POINT aVertex)
inline

Definition at line 1733 of file specctra.h.

1734  {
1735  vertex = aVertex;
1737  hasVertex = true;
1738  }
void FixNegativeZero()
Function FixNegativeZero will change negative zero to positive zero in the IEEE floating point storag...
Definition: specctra.h:135
POINT vertex
Definition: specctra.h:1685
bool hasVertex
Definition: specctra.h:1684

References DSN::POINT::FixNegativeZero(), hasVertex, and vertex.

Referenced by DSN::SPECCTRA_DB::doPLACE(), and DSN::SPECCTRA_DB::FromBOARD().

◆ Type()

Friends And Related Function Documentation

◆ SPECCTRA_DB

friend class SPECCTRA_DB
friend

Definition at line 1676 of file specctra.h.

Member Data Documentation

◆ component_id

std::string DSN::PLACE::component_id
private

reference designator

Definition at line 1678 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), DSN::SPECCTRA_DB::FromBOARD(), and DSN::SPECCTRA_DB::FromSESSION().

◆ hasVertex

bool DSN::PLACE::hasVertex
private

Definition at line 1684 of file specctra.h.

Referenced by Format(), DSN::SPECCTRA_DB::FromSESSION(), PLACE(), and SetVertex().

◆ lock_type

DSN_T DSN::PLACE::lock_type
private

Definition at line 1696 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), and PLACE().

◆ logical_part

std::string DSN::PLACE::logical_part
private

Definition at line 1690 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), and Format().

◆ mirror

DSN_T DSN::PLACE::mirror
private

Definition at line 1687 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), and PLACE().

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 199 of file specctra.h.

Referenced by DSN::ELEM::GetUnits(), and DSN::ELEM::SetParent().

◆ part_number

std::string DSN::PLACE::part_number
private

Definition at line 1703 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), and DSN::SPECCTRA_DB::FromBOARD().

◆ place_rules

RULE* DSN::PLACE::place_rules
private

Definition at line 1692 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), PLACE(), and ~PLACE().

◆ properties

PROPERTIES DSN::PLACE::properties
private

Definition at line 1694 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), and Format().

◆ region

REGION* DSN::PLACE::region
private

Definition at line 1700 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), PLACE(), and ~PLACE().

◆ rotation

double DSN::PLACE::rotation
private

Definition at line 1682 of file specctra.h.

Referenced by Format(), DSN::SPECCTRA_DB::FromSESSION(), PLACE(), and SetRotation().

◆ rules

RULE* DSN::PLACE::rules
private

Definition at line 1699 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), PLACE(), and ~PLACE().

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 221 of file specctra.h.

Referenced by DSN::ELEM::makeHash().

◆ side

DSN_T DSN::PLACE::side
private

◆ status

DSN_T DSN::PLACE::status
private

Definition at line 1688 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPLACE(), Format(), and PLACE().

◆ type

DSN_T DSN::ELEM::type
protectedinherited

Definition at line 198 of file specctra.h.

Referenced by DSN::UNIT_RES::Format(), DSN::ELEM::Name(), and DSN::ELEM::Type().

◆ vertex

POINT DSN::PLACE::vertex
private

Definition at line 1685 of file specctra.h.

Referenced by Format(), DSN::SPECCTRA_DB::FromSESSION(), and SetVertex().


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