KiCad PCB EDA Suite
DSN::PLACE Class Reference

Implement a <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
 Write 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
 Return the units for this section. More...
 
virtual void FormatContents (OUTPUTFORMATTER *out, int nestLevel)
 Write 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 ()
 Return a string which uniquely represents this ELEM among 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

Implement a <placement_reference> in the specctra dsn spec.

Definition at line 1687 of file specctra.h.

Constructor & Destructor Documentation

◆ PLACE()

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

Definition at line 1690 of file specctra.h.

1690  :
1691  ELEM( T_place, aParent )
1692  {
1693  side = T_front;
1694 
1695  rotation = 0.0;
1696 
1697  hasVertex = false;
1698 
1699  mirror = T_NONE;
1700  status = T_NONE;
1701 
1702  place_rules = 0;
1703 
1704  lock_type = T_NONE;
1705  rules = 0;
1706  region = 0;
1707  }
DSN_T lock_type
Definition: specctra.h:1751
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3749
DSN_T status
Definition: specctra.h:1743
double rotation
Definition: specctra.h:1737
bool hasVertex
Definition: specctra.h:1739
DSN_T side
Definition: specctra.h:1735
RULE * place_rules
Definition: specctra.h:1747
RULE * rules
Definition: specctra.h:1754
REGION * region
Definition: specctra.h:1755
DSN_T mirror
Definition: specctra.h:1742

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

◆ ~PLACE()

DSN::PLACE::~PLACE ( )
inline

Definition at line 1709 of file specctra.h.

1710  {
1711  delete place_rules;
1712  delete rules;
1713  delete region;
1714  }
RULE * place_rules
Definition: specctra.h:1747
RULE * rules
Definition: specctra.h:1754
REGION * region
Definition: specctra.h:1755

References place_rules, region, and rules.

Member Function Documentation

◆ Format()

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

Write 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 precede the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Reimplemented from DSN::ELEM.

Definition at line 3923 of file specctra.cpp.

3924 {
3925  bool useMultiLine;
3926 
3927  const char* quote = out->GetQuoteChar( component_id.c_str() );
3928 
3929  if( place_rules || properties.size() || rules || region )
3930  {
3931  useMultiLine = true;
3932 
3933  out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, component_id.c_str(), quote );
3934  out->Print( nestLevel+1, "%s", "" );
3935  }
3936  else
3937  {
3938  useMultiLine = false;
3939 
3940  out->Print( nestLevel, "(%s %s%s%s", Name(), quote, component_id.c_str(), quote );
3941  }
3942 
3943  if( hasVertex )
3944  {
3945  out->Print( 0, " %.6f %.6f", vertex.x, vertex.y );
3946  out->Print( 0, " %s", GetTokenText( side ) );
3947  out->Print( 0, " %.6f", rotation );
3948  }
3949 
3950  const char* space = " "; // one space, as c string.
3951 
3952  if( mirror != T_NONE )
3953  {
3954  out->Print( 0, "%s(mirror %s)", space, GetTokenText( mirror ) );
3955  space = "";
3956  }
3957 
3958  if( status != T_NONE )
3959  {
3960  out->Print( 0, "%s(status %s)", space, GetTokenText( status ) );
3961  space = "";
3962  }
3963 
3964  if( logical_part.size() )
3965  {
3966  quote = out->GetQuoteChar( logical_part.c_str() );
3967  out->Print( 0, "%s(logical_part %s%s%s)", space, quote, logical_part.c_str(), quote );
3968  space = "";
3969  }
3970 
3971  if( useMultiLine )
3972  {
3973  out->Print( 0, "\n" );
3974 
3975  if( place_rules )
3976  {
3977  place_rules->Format( out, nestLevel+1 );
3978  }
3979 
3980  if( properties.size() )
3981  {
3982  out->Print( nestLevel + 1, "(property \n" );
3983 
3984  for( PROPERTIES::const_iterator i = properties.begin(); i != properties.end(); ++i )
3985  i->Format( out, nestLevel + 2 );
3986 
3987  out->Print( nestLevel + 1, ")\n" );
3988  }
3989 
3990  if( lock_type != T_NONE )
3991  out->Print( nestLevel + 1, "(lock_type %s)\n", GetTokenText( lock_type ) );
3992 
3993  if( rules )
3994  rules->Format( out, nestLevel+1 );
3995 
3996  if( region )
3997  region->Format( out, nestLevel+1 );
3998 
3999  if( part_number.size() )
4000  {
4001  quote = out->GetQuoteChar( part_number.c_str() );
4002  out->Print( nestLevel + 1, "(PN %s%s%s)\n", quote, part_number.c_str(), quote );
4003  }
4004  }
4005  else
4006  {
4007  if( lock_type != T_NONE )
4008  {
4009  out->Print( 0, "%s(lock_type %s)", space, GetTokenText( lock_type ) );
4010  space = "";
4011  }
4012 
4013  if( part_number.size() )
4014  {
4015  quote = out->GetQuoteChar( part_number.c_str() );
4016  out->Print( 0, "%s(PN %s%s%s)", space, quote, part_number.c_str(), quote );
4017  }
4018  }
4019 
4020  out->Print( 0, ")\n" );
4021 }
DSN_T lock_type
Definition: specctra.h:1751
double y
Definition: specctra.h:105
const char * Name() const
Definition: specctra.cpp:3760
std::string part_number
Definition: specctra.h:1758
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:500
std::string logical_part
Definition: specctra.h:1745
double x
Definition: specctra.h:104
DSN_T status
Definition: specctra.h:1743
POINT vertex
Definition: specctra.h:1740
double rotation
Definition: specctra.h:1737
bool hasVertex
Definition: specctra.h:1739
DSN_T side
Definition: specctra.h:1735
PROPERTIES properties
Definition: specctra.h:1749
RULE * place_rules
Definition: specctra.h:1747
std::string component_id
reference designator
Definition: specctra.h:1733
RULE * rules
Definition: specctra.h:1754
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3774
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:348
REGION * region
Definition: specctra.h:1755
DSN_T mirror
Definition: specctra.h:1742
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
Definition: specctra.cpp:70
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

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

Write 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 precede 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 242 of file specctra.h.

243  {
244  // overridden in ELEM_HOLDER
245  }

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

◆ GetUnits()

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

Return the units for this section.

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

Returns
an element 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 3765 of file specctra.cpp.

3766 {
3767  if( parent )
3768  return parent->GetUnits();
3769 
3770  return &UNIT_RES::Default;
3771 }
ELEM * parent
Definition: specctra.h:276
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:410
virtual UNIT_RES * GetUnits() const
Return the units for this section.
Definition: specctra.cpp:3765

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

Return a string which uniquely represents this ELEM among other ELEMs of the same derived class as "this" one.

It is not usable 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 263 of file specctra.h.

264  {
265  sf.Clear();
266  FormatContents( &sf, 0 );
267  sf.StripUseless();
268 
269  return sf.GetString();
270  }
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:242
const std::string & GetString()
Definition: richio.h:438
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:512
static STRING_FORMATTER sf
Definition: specctra.h:273
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:428

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

1724  {
1725  rotation = aRotation;
1726  }
double rotation
Definition: specctra.h:1737

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

1717  {
1718  vertex = aVertex;
1720  hasVertex = true;
1721  }
void FixNegativeZero()
Change negative zero to positive zero in the IEEE floating point storage format.
Definition: specctra.h:144
POINT vertex
Definition: specctra.h:1740
bool hasVertex
Definition: specctra.h:1739

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

Member Data Documentation

◆ component_id

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

reference designator

Definition at line 1733 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 1739 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 1751 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 1745 of file specctra.h.

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

◆ mirror

DSN_T DSN::PLACE::mirror
private

Definition at line 1742 of file specctra.h.

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

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 276 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 1758 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 1747 of file specctra.h.

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

◆ properties

PROPERTIES DSN::PLACE::properties
private

Definition at line 1749 of file specctra.h.

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

◆ region

REGION* DSN::PLACE::region
private

Definition at line 1755 of file specctra.h.

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

◆ rotation

double DSN::PLACE::rotation
private

Definition at line 1737 of file specctra.h.

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

◆ rules

RULE* DSN::PLACE::rules
private

Definition at line 1754 of file specctra.h.

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

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

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

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

◆ type

DSN_T DSN::ELEM::type
protectedinherited

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

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


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