KiCad PCB EDA Suite
DSN::PLACE Class Reference

Class 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

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

Definition at line 1659 of file specctra.h.

Constructor & Destructor Documentation

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

Definition at line 1692 of file specctra.h.

References DSN::T_front, and DSN::T_NONE.

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:3490
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
DSN::PLACE::~PLACE ( )
inline

Definition at line 1711 of file specctra.h.

References place_rules, region, and rules.

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

Member Function Documentation

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

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, DSN::T_NONE, vertex, DSN::POINT::x, and DSN::POINT::y.

3675 {
3676  bool useMultiLine;
3677 
3678  const char* quote = out->GetQuoteChar( component_id.c_str() );
3679 
3680  if( place_rules || properties.size() || rules || region )
3681  {
3682  useMultiLine = true;
3683 
3684  out->Print( nestLevel, "(%s %s%s%s\n", Name(),
3685  quote, component_id.c_str(), quote );
3686 
3687  out->Print( nestLevel+1, "%s", "" );
3688  }
3689  else
3690  {
3691  useMultiLine = false;
3692 
3693  out->Print( nestLevel, "(%s %s%s%s", Name(),
3694  quote, component_id.c_str(), quote );
3695  }
3696 
3697  if( hasVertex )
3698  {
3699  out->Print( 0, " %.6g %.6g", vertex.x, vertex.y );
3700 
3701  out->Print( 0, " %s", GetTokenText( side ) );
3702 
3703  out->Print( 0, " %.6g", rotation );
3704  }
3705 
3706  const char* space = " "; // one space, as c string.
3707 
3708  if( mirror != T_NONE )
3709  {
3710  out->Print( 0, "%s(mirror %s)", space, GetTokenText( mirror ) );
3711  space = "";
3712  }
3713 
3714  if( status != T_NONE )
3715  {
3716  out->Print( 0, "%s(status %s)", space, GetTokenText( status ) );
3717  space = "";
3718  }
3719 
3720  if( logical_part.size() )
3721  {
3722  quote = out->GetQuoteChar( logical_part.c_str() );
3723  out->Print( 0, "%s(logical_part %s%s%s)", space,
3724  quote, logical_part.c_str(), quote );
3725  space = "";
3726  }
3727 
3728  if( useMultiLine )
3729  {
3730  out->Print( 0, "\n" );
3731  if( place_rules )
3732  {
3733  place_rules->Format( out, nestLevel+1 );
3734  }
3735 
3736  if( properties.size() )
3737  {
3738  out->Print( nestLevel+1, "(property \n" );
3739 
3740  for( PROPERTIES::const_iterator i = properties.begin();
3741  i != properties.end(); ++i )
3742  {
3743  i->Format( out, nestLevel+2 );
3744  }
3745  out->Print( nestLevel+1, ")\n" );
3746  }
3747  if( lock_type != T_NONE )
3748  out->Print( nestLevel+1, "(lock_type %s)\n", GetTokenText(lock_type) );
3749  if( rules )
3750  rules->Format( out, nestLevel+1 );
3751 
3752  if( region )
3753  region->Format( out, nestLevel+1 );
3754 
3755  if( part_number.size() )
3756  {
3757  quote = out->GetQuoteChar( part_number.c_str() );
3758  out->Print( nestLevel+1, "(PN %s%s%s)\n",
3759  quote, part_number.c_str(), quote );
3760  }
3761  }
3762  else
3763  {
3764  if( lock_type != T_NONE )
3765  {
3766  out->Print( 0, "%s(lock_type %s)", space, GetTokenText(lock_type) );
3767  space = "";
3768  }
3769 
3770  if( part_number.size() )
3771  {
3772  quote = out->GetQuoteChar( part_number.c_str() );
3773  out->Print( 0, "%s(PN %s%s%s)", space,
3774  quote, part_number.c_str(), quote );
3775  }
3776  }
3777 
3778  out->Print( 0, ")\n" );
3779 }
DSN_T lock_type
Definition: specctra.h:1681
double y
Definition: specctra.h:97
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
const char * Name() const
Definition: specctra.cpp:3501
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:3515
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
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.

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

265  {
266  // overridden in ELEM_HOLDER
267  }
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 3506 of file specctra.cpp.

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().

3507 {
3508  if( parent )
3509  return parent->GetUnits();
3510 
3511  return &UNIT_RES::Default;
3512 }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3506
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
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.

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().

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:500
static STRING_FORMATTER sf
Definition: specctra.h:222
void Clear()
Function Clear clears the buffer and empties the internal string.
Definition: richio.h:464
void DSN::PLACE::SetRotation ( double  aRotation)
inline

Definition at line 1725 of file specctra.h.

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

1726  {
1727  rotation = aRotation;
1728  }
double rotation
Definition: specctra.h:1667
void DSN::PLACE::SetVertex ( const POINT aVertex)
inline

Definition at line 1718 of file specctra.h.

References DSN::POINT::FixNegativeZero().

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

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

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 1661 of file specctra.h.

Member Data Documentation

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().

bool DSN::PLACE::hasVertex
private

Definition at line 1669 of file specctra.h.

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

DSN_T DSN::PLACE::lock_type
private

Definition at line 1681 of file specctra.h.

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

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

Definition at line 1675 of file specctra.h.

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

DSN_T DSN::PLACE::mirror
private

Definition at line 1672 of file specctra.h.

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

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 200 of file specctra.h.

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

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().

RULE* DSN::PLACE::place_rules
private

Definition at line 1677 of file specctra.h.

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

PROPERTIES DSN::PLACE::properties
private

Definition at line 1679 of file specctra.h.

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

REGION* DSN::PLACE::region
private

Definition at line 1685 of file specctra.h.

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

double DSN::PLACE::rotation
private

Definition at line 1667 of file specctra.h.

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

RULE* DSN::PLACE::rules
private

Definition at line 1684 of file specctra.h.

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

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 222 of file specctra.h.

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

DSN_T DSN::PLACE::side
private
DSN_T DSN::PLACE::status
private

Definition at line 1673 of file specctra.h.

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

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().

POINT DSN::PLACE::vertex
private

Definition at line 1670 of file specctra.h.

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


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