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

Constructor & Destructor Documentation

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

Definition at line 1689 of file specctra.h.

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

1689  :
1690  ELEM( T_place, aParent )
1691  {
1692  side = T_front;
1693 
1694  rotation = 0.0;
1695 
1696  hasVertex = false;
1697 
1698  mirror = T_NONE;
1699  status = T_NONE;
1700 
1701  place_rules = 0;
1702 
1703  lock_type = T_NONE;
1704  rules = 0;
1705  region = 0;
1706  }
DSN_T lock_type
Definition: specctra.h:1678
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3486
DSN_T status
Definition: specctra.h:1670
double rotation
Definition: specctra.h:1664
bool hasVertex
Definition: specctra.h:1666
DSN_T side
Definition: specctra.h:1662
RULE * place_rules
Definition: specctra.h:1674
RULE * rules
Definition: specctra.h:1681
REGION * region
Definition: specctra.h:1682
DSN_T mirror
Definition: specctra.h:1669
DSN::PLACE::~PLACE ( )
inline

Definition at line 1708 of file specctra.h.

References place_rules, region, and rules.

1709  {
1710  delete place_rules;
1711  delete rules;
1712  delete region;
1713  }
RULE * place_rules
Definition: specctra.h:1674
RULE * rules
Definition: specctra.h:1681
REGION * region
Definition: specctra.h:1682

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 3670 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.

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

3503 {
3504  if( parent )
3505  return parent->GetUnits();
3506 
3507  return &UNIT_RES::Default;
3508 }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3502
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:504
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 1722 of file specctra.h.

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

1723  {
1724  rotation = aRotation;
1725  }
double rotation
Definition: specctra.h:1664
void DSN::PLACE::SetVertex ( const POINT aVertex)
inline

Definition at line 1715 of file specctra.h.

References DSN::POINT::FixNegativeZero().

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

1716  {
1717  vertex = aVertex;
1719  hasVertex = true;
1720  }
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:1667
bool hasVertex
Definition: specctra.h:1666

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 1658 of file specctra.h.

Member Data Documentation

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

reference designator

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

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

DSN_T DSN::PLACE::lock_type
private

Definition at line 1678 of file specctra.h.

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

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

Definition at line 1672 of file specctra.h.

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

DSN_T DSN::PLACE::mirror
private

Definition at line 1669 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 1685 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 1674 of file specctra.h.

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

PROPERTIES DSN::PLACE::properties
private

Definition at line 1676 of file specctra.h.

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

REGION* DSN::PLACE::region
private

Definition at line 1682 of file specctra.h.

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

double DSN::PLACE::rotation
private

Definition at line 1664 of file specctra.h.

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

RULE* DSN::PLACE::rules
private

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

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


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