KiCad PCB EDA Suite
DSN Namespace Reference

This source file implements export and import capabilities to the specctra dsn file format. More...

Classes

class  ANCESTOR
 
class  BOUNDARY
 
class  CIRCLE
 
class  CLASS
 Class CLASS corresponds to the <class_descriptor> in the specctra spec. More...
 
class  CLASS_CLASS
 
class  CLASSES
 
class  COMP_ORDER
 Class COMP_ORDER corresponds to the <component_order_descriptor>. More...
 
class  COMPONENT
 Class COMPONENT implements the <component_descriptor> in the specctra dsn spec. More...
 
class  CONNECT
 
class  CONTROL
 
class  COPPER_PLANE
 Class COPPER_PLANE corresponds to a <plane_descriptor> in the specctra dsn spec. More...
 
class  ELEM
 Class ELEM is a base class for any DSN element class. More...
 
class  ELEM_HOLDER
 Class ELEM_HOLDER is a holder for any DSN class. More...
 
class  FROMTO
 
class  GRID
 
class  HISTORY
 
class  IMAGE
 
class  KEEPOUT
 Class KEEPOUT is used for <keepout_descriptor> and <plane_descriptor>. More...
 
class  LAYER
 
class  LAYER_NOISE_WEIGHT
 
class  LAYER_RULE
 
class  LIBRARY
 Class LIBRARY corresponds to the <library_descriptor> in the specctra dsn specification. More...
 
class  NET
 Class NET corresponds to a <net_descriptor> in the DSN spec. More...
 
class  NET_OUT
 Class NET_OUT corresponds to the <net_out_descriptor> of the specctra dsn spec. More...
 
class  NETWORK
 
class  PADSTACK
 Class PADSTACK holds either a via or a pad definition. More...
 
class  PARSER
 Class PARSER is simply a configuration record per the SPECCTRA DSN file spec. More...
 
class  PATH
 Class PATH supports both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec. More...
 
class  PCB
 
class  PIN
 
struct  PIN_PAIR
 Struct PIN_PAIR is used within the WAS_IS class below to hold a pair of PIN_REFs and corresponds to the (pins was is) construct within the specctra dsn spec. More...
 
struct  PIN_REF
 Class PIN_REF corresponds to the <pin_reference> definition in the specctra dsn spec. More...
 
class  PLACE
 Class PLACE implements the <placement_reference> in the specctra dsn spec. More...
 
class  PLACEMENT
 
struct  POINT
 Struct POINT is a holder for a point in the SPECCTRA DSN coordinate system. More...
 
struct  PROPERTY
 
class  QARC
 
class  RECTANGLE
 
class  REGION
 
class  ROUTE
 
class  RULE
 Class RULE corresponds to the <rule_descriptor> in the specctra dsn spec. More...
 
class  SESSION
 Class SESSION corresponds to the <session_file_descriptor> in the specctra dsn spec. More...
 
class  SHAPE
 Class SHAPE corresponds to the "(shape ..)" element in the specctra dsn spec. More...
 
class  SPECCTRA_DB
 Class SPECCTRA_DB holds a DSN data tree, usually coming from a DSN file. More...
 
class  SPECCTRA_LAYER_PAIR
 
class  STRINGPROP
 Class STRINGPROP is a container for a single property whose value is a string. More...
 
class  STRUCTURE
 
class  STRUCTURE_OUT
 
class  SUPPLY_PIN
 Class SUPPLY_PIN corresponds to the <supply_pin_descriptor> in the specctra dsn spec. More...
 
class  TOKPROP
 Class TOKPROP is a container for a single property whose value is another DSN_T token. More...
 
class  TOPOLOGY
 
class  UNIT_RES
 Class UNIT_RES is a holder for either a T_unit or T_resolution object which are usually mutually exclusive in the dsn grammar, except within the T_pcb level. More...
 
class  VIA
 Class VIA corresponds to the <via_descriptor> in the specctra dsn spec. More...
 
class  WAS_IS
 Class WAS_IS corresponds to the <was_is_descriptor> in the specctra dsn spec. More...
 
class  WINDOW
 
class  WIRE
 Class WIRE corresponds to <wire_shape_descriptor> in the specctra dsn spec. More...
 
class  WIRE_VIA
 Class WIRE_VIA corresponds to <wire_via_descriptor> in the specctra dsn spec. More...
 
class  WIRING
 Class WIRING corresponds to <wiring_descriptor> in the specctra dsn spec. More...
 

Typedefs

typedef std::vector< std::string > STRINGS
 
typedef std::vector< POINTPOINTS
 
typedef std::vector< PROPERTYPROPERTIES
 
typedef boost::ptr_vector< LAYER_RULELAYER_RULES
 
typedef boost::ptr_vector< PATHPATHS
 
typedef boost::ptr_vector< WINDOWWINDOWS
 
typedef boost::ptr_vector< KEEPOUTKEEPOUTS
 
typedef boost::ptr_vector< LAYERLAYERS
 
typedef boost::ptr_vector< SPECCTRA_LAYER_PAIRSPECCTRA_LAYER_PAIRS
 
typedef boost::ptr_vector< COPPER_PLANECOPPER_PLANES
 
typedef boost::ptr_vector< PLACEPLACES
 
typedef boost::ptr_vector< COMPONENTCOMPONENTS
 
typedef boost::ptr_vector< PINPINS
 
typedef boost::ptr_vector< IMAGEIMAGES
 
typedef boost::ptr_vector< PADSTACKPADSTACKS
 
typedef std::vector< PIN_REFPIN_REFS
 
typedef boost::ptr_vector< FROMTOFROMTOS
 
typedef boost::ptr_vector< COMP_ORDERCOMP_ORDERS
 
typedef boost::ptr_vector< NETNETS
 
typedef boost::ptr_vector< CLASSCLASSLIST
 
typedef boost::ptr_vector< WIREWIRES
 
typedef boost::ptr_vector< WIRE_VIAWIRE_VIAS
 
typedef boost::ptr_vector< ANCESTORANCESTORS
 
typedef boost::ptr_vector< SUPPLY_PINSUPPLY_PINS
 
typedef boost::ptr_vector< NET_OUTNET_OUTS
 
typedef std::vector< PIN_PAIRPIN_PAIRS
 
typedef boost::ptr_set< PADSTACKPADSTACKSET
 
typedef std::map< wxString, int > PINMAP
 data type used to ensure unique-ness of pin names, holding (wxString and int) More...
 
typedef std::set< std::string > STRINGSET
 
typedef std::pair< STRINGSET::iterator, bool > STRINGSET_PAIR
 

Functions

const char * GetTokenText (T aTok)
 Function GetTokenText is in the DSN namespace and returns the C string representing a SPECCTRA_DB::keyword. More...
 
bool operator< (const PADSTACK &lhs, const PADSTACK &rhs)
 Function operator< is used by the PADSTACKSET boost::ptr_set below. More...
 
static double scale (int kicadDist)
 Function scale converts a distance from PCBNEW internal units to the reported specctra dsn units in floating point format. More...
 
static double IU2um (int kicadDist)
 
static double mapX (int x)
 
static double mapY (int y)
 
static POINT mapPt (const wxPoint &pt)
 Function mapPt converts a KiCad point into a DSN file point. More...
 
static bool isRoundKeepout (D_PAD *aPad)
 Function isRoundKeepout decides if the pad is a copper-less through hole which needs to be made into a round keepout. More...
 
static PATHmakePath (const POINT &aStart, const POINT &aEnd, const std::string &aLayerName)
 Function makePath creates a PATH element with a single straight line, a pair of vertices. More...
 
static int scale (double distance, UNIT_RES *aResolution)
 Function scale converts a session file distance to KiCad units of deci-mils. More...
 
static wxPoint mapPt (const POINT &aPoint, UNIT_RES *aResolution)
 Function mapPt translates a point from the Specctra Session format coordinate system to the KiCad coordinate system. More...
 

Detailed Description

This source file implements export and import capabilities to the specctra dsn file format.

The grammar for that file format is documented fairly well. There are classes for each major type of descriptor in the spec.

Since there are so many classes in here, it may be helpful to generate the Doxygen directory:

$ cd &ltkicadSourceRoot&gt $ doxygen

Then you can view the html documentation in the &ltkicadSourceRoot&gt/doxygen directory. The main class in this file is SPECCTRA_DB and its main functions are LoadPCB(), LoadSESSION(), and ExportPCB().

Wide use is made of boost::ptr_vector&lt&gt and std::vector&lt&gt template classes. If the contained object is small, then std::vector tends to be used. If the contained object is large, variable size, or would require writing an assignment operator() or copy constructore, then boost::ptr_vector cannot be beat.

Typedef Documentation

typedef boost::ptr_vector<ANCESTOR> DSN::ANCESTORS

Definition at line 3264 of file specctra.h.

typedef boost::ptr_vector<CLASS> DSN::CLASSLIST

Definition at line 2804 of file specctra.h.

typedef boost::ptr_vector<COMP_ORDER> DSN::COMP_ORDERS

Definition at line 2561 of file specctra.h.

typedef boost::ptr_vector<COMPONENT> DSN::COMPONENTS

Definition at line 1784 of file specctra.h.

typedef boost::ptr_vector<COPPER_PLANE> DSN::COPPER_PLANES

Definition at line 1334 of file specctra.h.

typedef boost::ptr_vector<FROMTO> DSN::FROMTOS

Definition at line 2527 of file specctra.h.

typedef boost::ptr_vector<IMAGE> DSN::IMAGES

Definition at line 2091 of file specctra.h.

typedef boost::ptr_vector<KEEPOUT> DSN::KEEPOUTS

Definition at line 1004 of file specctra.h.

typedef boost::ptr_vector<LAYER_RULE> DSN::LAYER_RULES

Definition at line 568 of file specctra.h.

typedef boost::ptr_vector<LAYER> DSN::LAYERS

Definition at line 1263 of file specctra.h.

typedef boost::ptr_vector<NET_OUT> DSN::NET_OUTS

Definition at line 3411 of file specctra.h.

typedef boost::ptr_vector<NET> DSN::NETS

Definition at line 2689 of file specctra.h.

typedef boost::ptr_vector<PADSTACK> DSN::PADSTACKS

Definition at line 2212 of file specctra.h.

typedef boost::ptr_set<PADSTACK> DSN::PADSTACKSET

Definition at line 3599 of file specctra.h.

typedef boost::ptr_vector<PATH> DSN::PATHS

Definition at line 646 of file specctra.h.

typedef std::vector<PIN_PAIR> DSN::PIN_PAIRS

Definition at line 3496 of file specctra.h.

typedef std::vector<PIN_REF> DSN::PIN_REFS

Definition at line 2459 of file specctra.h.

typedef std::map<wxString, int> DSN::PINMAP

data type used to ensure unique-ness of pin names, holding (wxString and int)

Definition at line 614 of file specctra_export.cpp.

typedef boost::ptr_vector<PIN> DSN::PINS

Definition at line 1972 of file specctra.h.

typedef boost::ptr_vector<PLACE> DSN::PLACES

Definition at line 1732 of file specctra.h.

typedef std::vector<POINT> DSN::POINTS

Definition at line 159 of file specctra.h.

typedef std::vector<PROPERTY> DSN::PROPERTIES

Definition at line 184 of file specctra.h.

typedef boost::ptr_vector<SPECCTRA_LAYER_PAIR> DSN::SPECCTRA_LAYER_PAIRS

Definition at line 1293 of file specctra.h.

typedef std::vector<std::string> DSN::STRINGS

Definition at line 158 of file specctra.h.

typedef std::set<std::string> DSN::STRINGSET

Definition at line 910 of file specctra_export.cpp.

typedef std::pair<STRINGSET::iterator, bool> DSN::STRINGSET_PAIR

Definition at line 911 of file specctra_export.cpp.

typedef boost::ptr_vector<SUPPLY_PIN> DSN::SUPPLY_PINS

Definition at line 3354 of file specctra.h.

typedef boost::ptr_vector<WINDOW> DSN::WINDOWS

Definition at line 877 of file specctra.h.

typedef boost::ptr_vector<WIRE_VIA> DSN::WIRE_VIAS

Definition at line 3086 of file specctra.h.

typedef boost::ptr_vector<WIRE> DSN::WIRES

Definition at line 2950 of file specctra.h.

Function Documentation

const char * DSN::GetTokenText ( aTok)

Function GetTokenText is in the DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.

We needed a non-instanance function to get at the SPECCTRA_DB::keyword[] and class SPECCTRA_DB is not defined yet.

Definition at line 69 of file specctra.cpp.

Referenced by DSN::UNIT_RES::Format(), DSN::LAYER::Format(), DSN::TOKPROP::Format(), DSN::GRID::Format(), DSN::PLACE::Format(), DSN::SHAPE::Format(), DSN::FROMTO::Format(), DSN::NET::Format(), DSN::WIRE::Format(), DSN::WIRE_VIA::Format(), DSN::PLACEMENT::FormatContents(), DSN::IMAGE::FormatContents(), DSN::PADSTACK::FormatContents(), PCB_PARSER::parseBoardUnits(), PCB_PARSER::parseDouble(), PCB_PARSER::parseVersion(), and DSNLEXER::SetCommentsAreTokens().

70 {
71  return SPECCTRA_LEXER::TokenName( aTok );
72 }
static bool DSN::isRoundKeepout ( D_PAD aPad)
static

Function isRoundKeepout decides if the pad is a copper-less through hole which needs to be made into a round keepout.

Definition at line 231 of file specctra_export.cpp.

References LSET::AllCuMask(), D_PAD::GetDrillSize(), D_PAD::GetLayerSet(), D_PAD::GetShape(), D_PAD::GetSize(), and PAD_SHAPE_CIRCLE.

Referenced by DSN::SPECCTRA_DB::makeIMAGE(), and DSN::SPECCTRA_DB::makePADSTACK().

232 {
233  if( aPad->GetShape()==PAD_SHAPE_CIRCLE )
234  {
235  if( aPad->GetDrillSize().x >= aPad->GetSize().x )
236  return true;
237 
238  if( !( aPad->GetLayerSet() & LSET::AllCuMask() ).any() )
239  return true;
240  }
241 
242  return false;
243 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:402
const wxSize & GetSize() const
Definition: class_pad.h:269
static double DSN::IU2um ( int  kicadDist)
inlinestatic

Definition at line 191 of file specctra_export.cpp.

Referenced by DSN::SPECCTRA_DB::makePADSTACK(), and DSN::SPECCTRA_DB::makeVia().

192 {
193  return kicadDist * (1000.0 / IU_PER_MM);
194 }
static PATH* DSN::makePath ( const POINT aStart,
const POINT aEnd,
const std::string &  aLayerName 
)
static

Function makePath creates a PATH element with a single straight line, a pair of vertices.

Definition at line 250 of file specctra_export.cpp.

References DSN::PATH::AppendPoint(), and DSN::PATH::SetLayerId().

Referenced by DSN::SPECCTRA_DB::makePADSTACK().

251 {
252  PATH* path = new PATH( 0, T_path );
253 
254  path->AppendPoint( aStart );
255  path->AppendPoint( aEnd );
256  path->SetLayerId( aLayerName.c_str() );
257  return path;
258 }
void SetLayerId(const char *aLayerId)
Definition: specctra.h:602
void AppendPoint(const POINT &aPoint)
Definition: specctra.h:595
Class PATH supports both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec...
Definition: specctra.h:576
static wxPoint DSN::mapPt ( const POINT aPoint,
UNIT_RES aResolution 
)
static

Function mapPt translates a point from the Specctra Session format coordinate system to the KiCad coordinate system.

Parameters
aPointThe session point to translate
aResolution- The amount to scale the point.
Returns
wxPoint - The KiCad coordinate system point.

Definition at line 196 of file specctra_import.cpp.

References scale(), DSN::POINT::x, and DSN::POINT::y.

197 {
198  wxPoint ret( scale( aPoint.x, aResolution ),
199  -scale( aPoint.y, aResolution ) ); // negate y
200 
201  return ret;
202 }
double y
Definition: specctra.h:97
double x
Definition: specctra.h:96
const int scale
static POINT DSN::mapPt ( const wxPoint pt)
static

Function mapPt converts a KiCad point into a DSN file point.

Kicad's BOARD coordinates are in nanometers (called Internal Units or IU)and we are exporting in units of mils, so we have to scale them.

Definition at line 215 of file specctra_export.cpp.

References DSN::POINT::FixNegativeZero(), mapX(), mapY(), wxPoint::x, DSN::POINT::x, wxPoint::y, and DSN::POINT::y.

Referenced by DSN::SPECCTRA_DB::fillBOUNDARY(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::FromSESSION(), DSN::SPECCTRA_DB::makeIMAGE(), DSN::SPECCTRA_DB::makePADSTACK(), DSN::SPECCTRA_DB::makeTRACK(), and DSN::SPECCTRA_DB::makeVIA().

216 {
217  POINT ret;
218 
219  ret.x = mapX( pt.x );
220  ret.y = mapY( pt.y );
221  ret.FixNegativeZero();
222  return ret;
223 }
void FixNegativeZero()
Function FixNegativeZero will change negative zero to positive zero in the IEEE floating point storag...
Definition: specctra.h:136
double y
Definition: specctra.h:97
double x
Definition: specctra.h:96
Struct POINT is a holder for a point in the SPECCTRA DSN coordinate system.
Definition: specctra.h:94
static double mapY(int y)
static double mapX(int x)
static double DSN::mapX ( int  x)
inlinestatic

Definition at line 197 of file specctra_export.cpp.

References scale().

Referenced by mapPt().

198 {
199  return scale( x );
200 }
const int scale
static double DSN::mapY ( int  y)
inlinestatic

Definition at line 203 of file specctra_export.cpp.

References scale().

Referenced by mapPt().

204 {
205  return -scale( y ); // make y negative, since it is increasing going down.
206 }
const int scale
bool DSN::operator< ( const PADSTACK lhs,
const PADSTACK rhs 
)
inline

Function operator< is used by the PADSTACKSET boost::ptr_set below.

Definition at line 2219 of file specctra.h.

References DSN::PADSTACK::Compare().

2220 {
2221  return PADSTACK::Compare( (PADSTACK*) &lhs, (PADSTACK*) &rhs ) < 0;
2222 }
YYCODETYPE lhs
static int DSN::scale ( double  distance,
UNIT_RES aResolution 
)
static

Function scale converts a session file distance to KiCad units of deci-mils.

Parameters
distanceThe session file length to convert.
aResolutionThe session UNIT_RES which holds the engineering unit specifier
Returns
int - The KiCad length in internal unit

Definition at line 157 of file specctra_import.cpp.

References DSN::UNIT_RES::GetEngUnits(), DSN::UNIT_RES::GetValue(), and KiROUND().

158 {
159  double resValue = aResolution->GetValue();
160  double factor;
161 
162  switch( aResolution->GetEngUnits() )
163  {
164  default:
165  case T_inch:
166  factor = 25.4e6; // nanometers per inch
167  break;
168  case T_mil:
169  factor = 25.4e3; // nanometers per mil
170  break;
171  case T_cm:
172  factor = 1e7; // nanometers per cm
173  break;
174  case T_mm:
175  factor = 1e6; // nanometers per mm
176  break;
177  case T_um:
178  factor = 1e3; // nanometers per um
179  break;
180  }
181 
182  int ret = KiROUND( factor * distance / resValue );
183 
184  return ret;
185 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
DSN_T GetEngUnits() const
Definition: specctra.h:423
int GetValue() const
Definition: specctra.h:424
static double DSN::scale ( int  kicadDist)
inlinestatic

Function scale converts a distance from PCBNEW internal units to the reported specctra dsn units in floating point format.

Definition at line 183 of file specctra_export.cpp.

Referenced by DSN::SPECCTRA_DB::exportNETCLASS(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::makeIMAGE(), DSN::SPECCTRA_DB::makePADSTACK(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVia(), DSN::SPECCTRA_DB::makeVIA(), mapPt(), mapX(), and mapY().

184 {
185  // nanometers to um
186  return kicadDist / ( IU_PER_MM / 1000.0 );
187 }