KiCad PCB EDA Suite
eagle_plugin.cpp File Reference
#include <cerrno>
#include <wx/string.h>
#include <wx/xml/xml.h>
#include <common.h>
#include <convert_basic_shapes_to_polygon.h>
#include <fctsys.h>
#include <geometry/geometry_utils.h>
#include <kicad_string.h>
#include <macros.h>
#include <properties.h>
#include <trigo.h>
#include <wx/filename.h>
#include <math/util.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <class_edge_mod.h>
#include <class_zone.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <eagle_plugin.h>

Go to the source code of this file.

Macros

#define DIMENSION_PRECISION   1
 

Typedefs

typedef MODULE_MAP::iterator MODULE_ITER
 
typedef MODULE_MAP::const_iterator MODULE_CITER
 

Functions

static int parseEagle (const wxString &aDistance)
 Parse an eagle distance which is either mm, or mils if there is "mil" suffix. More...
 
template<typename T >
static T eagleClamp (T aMin, T aValue, T aMax)
 
static wxString makeKey (const wxString &aFirst, const wxString &aSecond)
 Assemble a two part key as a simple concatenation of aFirst and aSecond parts, using a separator. More...
 
static wxString interpret_text (const wxString &aText)
 interpret special characters in Eagle text and converts them to KiCAD notation More...
 
static void setKeepoutSettingsToZone (ZONE_CONTAINER *aZone, LAYER_NUM aLayer)
 

Macro Definition Documentation

◆ DIMENSION_PRECISION

#define DIMENSION_PRECISION   1

Definition at line 567 of file eagle_plugin.cpp.

Typedef Documentation

◆ MODULE_CITER

typedef MODULE_MAP::const_iterator MODULE_CITER

Definition at line 83 of file eagle_plugin.cpp.

◆ MODULE_ITER

typedef MODULE_MAP::iterator MODULE_ITER

Definition at line 82 of file eagle_plugin.cpp.

Function Documentation

◆ eagleClamp()

template<typename T >
static T eagleClamp ( aMin,
aValue,
aMax 
)
static

Definition at line 102 of file eagle_plugin.cpp.

103 {
104  T ret = std::max( aMin, aValue );
105  return std::min( aMax, ret );
106 }
T
enum T contains all this lexer's tokens.

Referenced by EAGLE_PLUGIN::loadSignals(), EAGLE_PLUGIN::packagePad(), EAGLE_PLUGIN::packageSMD(), and EAGLE_PLUGIN::transferPad().

◆ interpret_text()

static wxString interpret_text ( const wxString &  aText)
static

interpret special characters in Eagle text and converts them to KiCAD notation

Definition at line 118 of file eagle_plugin.cpp.

119 {
120  wxString text;
121  bool sectionOpen = false;
122 
123  for ( wxString::size_type i = 0; i < aText.size(); i++ )
124  {
125  // Interpret escaped characters
126  if ( aText[ i ] == '\\' )
127  {
128  if ( i + 1 != aText.size() )
129  text.Append( aText[ i + 1 ] );
130 
131  i++;
132  continue;
133  }
134 
135  // Escape ~ for KiCAD
136  if( aText[i] == '~' )
137  {
138  text.Append( '~' );
139  text.Append( '~' );
140  continue;
141  }
142 
143  if ( aText[ i ] == '!' )
144  {
145  if ( sectionOpen )
146  {
147  text.Append( '~' );
148  sectionOpen = false;
149  continue;
150  }
151 
152  static wxString escapeChars( " )]}'\"" );
153 
154  if( i + 1 != aText.size() && escapeChars.Find( aText[i + 1] ) == wxNOT_FOUND )
155  {
156  sectionOpen = true;
157  text.Append( '~' );
158  }
159  else
160  {
161  text.Append( aText[ i ] );
162  }
163  continue;
164  }
165 
166  if( aText[i] == ',' && sectionOpen )
167  {
168  text.Append( '~' );
169  sectionOpen = false;
170  }
171 
172  text.Append( aText[ i ] );
173  }
174 
175  return text;
176 }

Referenced by EAGLE_PLUGIN::loadPlain().

◆ makeKey()

static wxString makeKey ( const wxString &  aFirst,
const wxString &  aSecond 
)
static

Assemble a two part key as a simple concatenation of aFirst and aSecond parts, using a separator.

Definition at line 111 of file eagle_plugin.cpp.

112 {
113  wxString key = aFirst + '\x02' + aSecond;
114  return key;
115 }

Referenced by EAGLE_PLUGIN::loadElements(), EAGLE_PLUGIN::loadLibrary(), and EAGLE_PLUGIN::loadSignals().

◆ parseEagle()

static int parseEagle ( const wxString &  aDistance)
static

Parse an eagle distance which is either mm, or mils if there is "mil" suffix.

Return is in BIU.

Definition at line 88 of file eagle_plugin.cpp.

89 {
90  ECOORD::EAGLE_UNIT unit = ( aDistance.npos != aDistance.find( "mil" ) )
91  ? ECOORD::EAGLE_UNIT::EU_MIL : ECOORD::EAGLE_UNIT::EU_MM;
92 
93  ECOORD coord( aDistance, unit );
94 
95  return coord.ToPcbUnits();
96 }

References ECOORD::ToPcbUnits().

Referenced by ERULES::parse().

◆ setKeepoutSettingsToZone()

static void setKeepoutSettingsToZone ( ZONE_CONTAINER aZone,
LAYER_NUM  aLayer 
)
static

Definition at line 179 of file eagle_plugin.cpp.

180 {
181  if( aLayer == EAGLE_LAYER::TRESTRICT || aLayer == EAGLE_LAYER::BRESTRICT )
182  {
183  aZone->SetIsKeepout( true );
184  aZone->SetDoNotAllowVias( true );
185  aZone->SetDoNotAllowTracks( true );
186  aZone->SetDoNotAllowCopperPour( true );
187  aZone->SetDoNotAllowPads( true );
188  aZone->SetDoNotAllowFootprints( false );
189 
190  if( aLayer == EAGLE_LAYER::TRESTRICT ) // front layer keepout
191  aZone->SetLayer( F_Cu );
192  else // bottom layer keepout
193  aZone->SetLayer( B_Cu );
194  }
195  else if( aLayer == EAGLE_LAYER::VRESTRICT )
196  {
197  aZone->SetIsKeepout( true );
198  aZone->SetDoNotAllowVias( true );
199  aZone->SetDoNotAllowTracks( false );
200  aZone->SetDoNotAllowCopperPour( false );
201  aZone->SetDoNotAllowPads( false );
202  aZone->SetDoNotAllowFootprints( false );
203 
204  aZone->SetLayerSet( LSET::AllCuMask() );
205  }
206 }
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:732
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:712
void SetDoNotAllowFootprints(bool aEnable)
Definition: class_zone.h:734
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:731
void SetLayerSet(LSET aLayerSet)
Definition: class_zone.cpp:236
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:228
void SetDoNotAllowPads(bool aEnable)
Definition: class_zone.h:733
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:730
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:729

References LSET::AllCuMask(), B_Cu, EAGLE_LAYER::BRESTRICT, F_Cu, ZONE_CONTAINER::SetDoNotAllowCopperPour(), ZONE_CONTAINER::SetDoNotAllowFootprints(), ZONE_CONTAINER::SetDoNotAllowPads(), ZONE_CONTAINER::SetDoNotAllowTracks(), ZONE_CONTAINER::SetDoNotAllowVias(), ZONE_CONTAINER::SetIsKeepout(), ZONE_CONTAINER::SetLayer(), ZONE_CONTAINER::SetLayerSet(), EAGLE_LAYER::TRESTRICT, and EAGLE_LAYER::VRESTRICT.

Referenced by EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadPolygon(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), and EAGLE_PLUGIN::packageRectangle().