KiCad PCB EDA Suite
gpcb_plugin.cpp File Reference

Geda PCB file plugin implementation file. More...

#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <trigo.h>
#include <wildcards_and_files_ext.h>
#include <filter_reader.h>
#include <class_board.h>
#include <class_module.h>
#include <class_pcb_text.h>
#include <class_drawsegment.h>
#include <class_edge_mod.h>
#include <gpcb_plugin.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/wfstream.h>
#include <boost/ptr_container/ptr_map.hpp>
#include <memory.h>

Go to the source code of this file.

Classes

class  GPCB_FPL_CACHE_ITEM
 Class GPCB_FPL_CACHE_ITEM is helper class for creating a footprint library cache. More...
 
class  GPCB_FPL_CACHE
 

Macros

#define TRACE_PARAMS(arr)
 
#define TEXT_DEFAULT_SIZE   ( 40*IU_PER_MILS )
 
#define OLD_GPCB_UNIT_CONV   IU_PER_MILS
 
#define NEW_GPCB_UNIT_CONV   ( 0.01*IU_PER_MILS )
 

Typedefs

typedef boost::ptr_map< std::string, GPCB_FPL_CACHE_ITEMMODULE_MAP
 
typedef MODULE_MAP::iterator MODULE_ITER
 
typedef MODULE_MAP::const_iterator MODULE_CITER
 

Functions

static long parseInt (const wxString &aValue, double aScalar)
 

Variables

static const wxString traceFootprintLibrary = wxT( "KICAD_TRACE_GEDA_PLUGIN" )
 Flag to enable GEDA PCB plugin debug output. More...
 

Detailed Description

Geda PCB file plugin implementation file.

Geda PCB file plugin definition file.

Definition in file gpcb_plugin.cpp.

Macro Definition Documentation

#define NEW_GPCB_UNIT_CONV   ( 0.01*IU_PER_MILS )
#define OLD_GPCB_UNIT_CONV   IU_PER_MILS
#define TEXT_DEFAULT_SIZE   ( 40*IU_PER_MILS )
#define TRACE_PARAMS (   arr)

Definition at line 126 of file gpcb_plugin.cpp.

Referenced by GPCB_FPL_CACHE::parseParameters().

Typedef Documentation

typedef MODULE_MAP::const_iterator MODULE_CITER

Definition at line 181 of file gpcb_plugin.cpp.

typedef MODULE_MAP::iterator MODULE_ITER

Definition at line 180 of file gpcb_plugin.cpp.

typedef boost::ptr_map< std::string, GPCB_FPL_CACHE_ITEM > MODULE_MAP

Definition at line 179 of file gpcb_plugin.cpp.

Function Documentation

static long parseInt ( const wxString &  aValue,
double  aScalar 
)
inlinestatic

Definition at line 74 of file gpcb_plugin.cpp.

References Format(), KiROUND(), and THROW_IO_ERROR.

Referenced by PCB_PARSER::parseD_PAD(), PCB_PARSER::parseGeneralSection(), PCB_PARSER::parseHeader(), PCB_PARSER::parseLayer(), GPCB_FPL_CACHE::parseMODULE(), PCB_PARSER::parseMODULE_unchecked(), PCB_PARSER::parseNETINFO_ITEM(), PCB_PARSER::parseTITLE_BLOCK(), PCB_PARSER::parseTRACK(), PCB_PARSER::parseVersion(), PCB_PARSER::parseVIA(), and PCB_PARSER::parseZONE_CONTAINER().

75 {
76  double value = LONG_MAX;
77 
78  /*
79  * In 2011 gEDA/pcb introduced values with units, like "10mm" or "200mil".
80  * Unit-less values are still centimils (100000 units per inch), like with
81  * the previous format.
82  *
83  * Distinction between the even older format (mils, 1000 units per inch)
84  * and the pre-2011 format is done in ::parseMODULE already; the
85  * distinction is by wether an object definition opens with '(' or '['.
86  * All values with explicite unit open with a '[' so there's no need to
87  * consider this distinction when parsing them.
88  *
89  * The solution here is to watch for a unit and, if present, convert the
90  * value to centimils. All unit-less values are read unaltered. This way
91  * the code below can contine to consider all read values to be in mils or
92  * centimils. It also matches the strategy gEDA/pcb uses for backwards
93  * compatibility with its own layouts.
94  *
95  * Fortunately gEDA/pcb allows only units 'mil' and 'mm' in files, see
96  * definition of ALLOW_READABLE in gEDA/pcb's pcb_printf.h. So we don't
97  * have to test for all 11 units gEDA/pcb allows in user dialogs.
98  */
99  if( aValue.EndsWith( wxT( "mm" ) ) )
100  {
101  aScalar *= 100000.0 / 25.4;
102  }
103  else if( aValue.EndsWith( wxT( "mil" ) ) )
104  {
105  aScalar *= 100.;
106  }
107 
108  // This conversion reports failure on strings as simple as "1000", still
109  // it returns the right result in &value. Thus, ignore the return value.
110  aValue.ToCDouble(&value);
111  if( value == LONG_MAX ) // conversion really failed
112  {
113  THROW_IO_ERROR( wxString::Format( _( "Cannot convert \"%s\" to an integer" ),
114  aValue.GetData() ) );
115  return 0;
116  }
117 
118  return KiROUND( value * aScalar );
119 }
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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38