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 1659 of file specctra.h.

Constructor & Destructor Documentation

◆ PLACE()

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

Definition at line 1692 of file specctra.h.

1692  :
1693  ELEM( T_place, aParent )
1694  {
1695  side = T_front;
1696 
1697  rotation = 0.0;
1698 
1699  hasVertex = false;
1700 
1701  mirror = T_NONE;
1702  status = T_NONE;
1703 
1704  place_rules = 0;
1705 
1706  lock_type = T_NONE;
1707  rules = 0;
1708  region = 0;
1709  }
DSN_T lock_type
Definition: specctra.h:1681
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3494
DSN_T status
Definition: specctra.h:1673
double rotation
Definition: specctra.h:1667
bool hasVertex
Definition: specctra.h:1669
DSN_T side
Definition: specctra.h:1665
RULE * place_rules
Definition: specctra.h:1677
RULE * rules
Definition: specctra.h:1684
REGION * region
Definition: specctra.h:1685
DSN_T mirror
Definition: specctra.h:1672

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

◆ ~PLACE()

DSN::PLACE::~PLACE ( )
inline

Definition at line 1711 of file specctra.h.

1712  {
1713  delete place_rules;
1714  delete rules;
1715  delete region;
1716  }
RULE * place_rules
Definition: specctra.h:1677
RULE * rules
Definition: specctra.h:1684
REGION * region
Definition: specctra.h:1685

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 3678 of file specctra.cpp.

3679 {
3680  bool useMultiLine;
3681 
3682  const char* quote = out->GetQuoteChar( component_id.c_str() );
3683 
3684  if( place_rules || properties.size() || rules || region )
3685  {
3686  useMultiLine = true;
3687 
3688  out->Print( nestLevel, "(%s %s%s%s\n", 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", Name(),
3698  quote, component_id.c_str(), quote );
3699  }
3700 
3701  if( hasVertex )
3702  {
3703  out->Print( 0, " %.6g %.6g", vertex.x, vertex.y );
3704 
3705  out->Print( 0, " %s", GetTokenText( side ) );
3706 
3707  out->Print( 0, " %.6g", rotation );
3708  }
3709 
3710  const char* space = " "; // one space, as c string.
3711 
3712  if( mirror != T_NONE )
3713  {
3714  out->Print( 0, "%s(mirror %s)", space, GetTokenText( mirror ) );
3715  space = "";
3716  }
3717 
3718  if( status != T_NONE )
3719  {
3720  out->Print( 0, "%s(status %s)", space, GetTokenText( status ) );
3721  space = "";
3722  }
3723 
3724  if( logical_part.size() )
3725  {
3726  quote = out->GetQuoteChar( logical_part.c_str() );
3727  out->Print( 0, "%s(logical_part %s%s%s)", space,
3728  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();
3745  i != properties.end(); ++i )
3746  {
3747  i->Format( out, nestLevel+2 );
3748  }
3749  out->Print( nestLevel+1, ")\n" );
3750  }
3751  if( lock_type != T_NONE )
3752  out->Print( nestLevel+1, "(lock_type %s)\n", GetTokenText(lock_type) );
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",
3763  quote, part_number.c_str(), quote );
3764  }
3765  }
3766  else
3767  {
3768  if( lock_type != T_NONE )
3769  {
3770  out->Print( 0, "%s(lock_type %s)", space, GetTokenText(lock_type) );
3771  space = "";
3772  }
3773 
3774  if( part_number.size() )
3775  {
3776  quote = out->GetQuoteChar( part_number.c_str() );
3777  out->Print( 0, "%s(PN %s%s%s)", space,
3778  quote, part_number.c_str(), quote );
3779  }
3780  }
3781 
3782  out->Print( 0, ")\n" );
3783 }
DSN_T lock_type
Definition: specctra.h:1681
double y
Definition: specctra.h:97
const char * Name() const
Definition: specctra.cpp:3505
std::string part_number
Definition: specctra.h:1688
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:505
std::string logical_part
Definition: specctra.h:1675
double x
Definition: specctra.h:96
DSN_T status
Definition: specctra.h:1673
POINT vertex
Definition: specctra.h:1670
double rotation
Definition: specctra.h:1667
bool hasVertex
Definition: specctra.h:1669
DSN_T side
Definition: specctra.h:1665
PROPERTIES properties
Definition: specctra.h:1679
RULE * place_rules
Definition: specctra.h:1677
std::string component_id
reference designator
Definition: specctra.h:1663
RULE * rules
Definition: specctra.h:1684
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)
Function GetQuoteChar performs quote character need determination according to the Specctra DSN speci...
Definition: richio.cpp:327
REGION * region
Definition: specctra.h:1685
DSN_T mirror
Definition: specctra.h:1672
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,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

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 264 of file specctra.h.

265  {
266  // overridden in ELEM_HOLDER
267  }

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:200
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:414
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 212 of file specctra.h.

213  {
214  sf.Clear();
215  FormatContents( &sf, 0 );
216  sf.StripUseless();
217 
218  return sf.GetString();
219  }
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:264
const std::string & GetString()
Definition: richio.h:475
void StripUseless()
Function StripUseless removes whitespace, '(', and ')' from the mystring.
Definition: richio.cpp:490
static STRING_FORMATTER sf
Definition: specctra.h:222
void Clear()
Function Clear clears the buffer and empties the internal string.
Definition: richio.h:464

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 1725 of file specctra.h.

1726  {
1727  rotation = aRotation;
1728  }
double rotation
Definition: specctra.h:1667

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 1718 of file specctra.h.

1719  {
1720  vertex = aVertex;
1722  hasVertex = true;
1723  }
void FixNegativeZero()
Function FixNegativeZero will change negative zero to positive zero in the IEEE floating point storag...
Definition: specctra.h:136
POINT vertex
Definition: specctra.h:1670
bool hasVertex
Definition: specctra.h:1669

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 1661 of file specctra.h.

Member Data Documentation

◆ component_id

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

reference designator

Definition at line 1663 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 1669 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 1681 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 1675 of file specctra.h.

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

◆ mirror

DSN_T DSN::PLACE::mirror
private

Definition at line 1672 of file specctra.h.

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

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 200 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 1688 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 1677 of file specctra.h.

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

◆ properties

PROPERTIES DSN::PLACE::properties
private

Definition at line 1679 of file specctra.h.

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

◆ region

REGION* DSN::PLACE::region
private

Definition at line 1685 of file specctra.h.

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

◆ rotation

double DSN::PLACE::rotation
private

Definition at line 1667 of file specctra.h.

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

◆ rules

RULE* DSN::PLACE::rules
private

Definition at line 1684 of file specctra.h.

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

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 222 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 1673 of file specctra.h.

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

◆ type

DSN_T DSN::ELEM::type
protectedinherited

Definition at line 199 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 1670 of file specctra.h.

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


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