KiCad PCB EDA Suite
eagle_plugin.cpp File Reference
#include <cerrno>
#include <wx/string.h>
#include <wx/xml/xml.h>
#include <wx/filename.h>
#include <convert_basic_shapes_to_polygon.h>
#include <core/arraydim.h>
#include <geometry/geometry_utils.h>
#include <kicad_string.h>
#include <locale_io.h>
#include <properties.h>
#include <trigo.h>
#include <math/util.h>
#include <board.h>
#include <footprint.h>
#include <track.h>
#include <fp_shape.h>
#include <zone.h>
#include <pcb_text.h>
#include <dimension.h>
#include <plugins/eagle/eagle_plugin.h>

Go to the source code of this file.

Macros

#define DIMENSION_PRECISION   1
 

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 *aZone, LAYER_NUM aLayer)
 

Macro Definition Documentation

◆ DIMENSION_PRECISION

#define DIMENSION_PRECISION   1

Definition at line 560 of file eagle_plugin.cpp.

Function Documentation

◆ eagleClamp()

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

Definition at line 97 of file eagle_plugin.cpp.

98 {
99  T ret = std::max( aMin, aValue );
100  return std::min( aMax, ret );
101 }

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 113 of file eagle_plugin.cpp.

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

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 106 of file eagle_plugin.cpp.

107 {
108  wxString key = aFirst + '\x02' + aSecond;
109  return key;
110 }

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 83 of file eagle_plugin.cpp.

84 {
85  ECOORD::EAGLE_UNIT unit = ( aDistance.npos != aDistance.find( "mil" ) )
86  ? ECOORD::EAGLE_UNIT::EU_MIL : ECOORD::EAGLE_UNIT::EU_MM;
87 
88  ECOORD coord( aDistance, unit );
89 
90  return coord.ToPcbUnits();
91 }

References ECOORD::ToPcbUnits().

Referenced by ERULES::parse().

◆ setKeepoutSettingsToZone()

static void setKeepoutSettingsToZone ( ZONE aZone,
LAYER_NUM  aLayer 
)
static

Definition at line 174 of file eagle_plugin.cpp.

175 {
176  if( aLayer == EAGLE_LAYER::TRESTRICT || aLayer == EAGLE_LAYER::BRESTRICT )
177  {
178  aZone->SetIsRuleArea( true );
179  aZone->SetDoNotAllowVias( true );
180  aZone->SetDoNotAllowTracks( true );
181  aZone->SetDoNotAllowCopperPour( true );
182  aZone->SetDoNotAllowPads( true );
183  aZone->SetDoNotAllowFootprints( false );
184 
185  if( aLayer == EAGLE_LAYER::TRESTRICT ) // front layer keepout
186  aZone->SetLayer( F_Cu );
187  else // bottom layer keepout
188  aZone->SetLayer( B_Cu );
189  }
190  else if( aLayer == EAGLE_LAYER::VRESTRICT )
191  {
192  aZone->SetIsRuleArea( true );
193  aZone->SetDoNotAllowVias( true );
194  aZone->SetDoNotAllowTracks( false );
195  aZone->SetDoNotAllowCopperPour( false );
196  aZone->SetDoNotAllowPads( false );
197  aZone->SetDoNotAllowFootprints( false );
198 
199  aZone->SetLayerSet( LSET::AllCuMask() );
200  }
201 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:765
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:243
void SetIsRuleArea(bool aEnable)
Definition: zone.h:762
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:766
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:764
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:763
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:235
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:767

References LSET::AllCuMask(), B_Cu, EAGLE_LAYER::BRESTRICT, F_Cu, ZONE::SetDoNotAllowCopperPour(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetIsRuleArea(), ZONE::SetLayer(), ZONE::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().