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 <wx/log.h>
#include <wx/wfstream.h>
#include <convert_basic_shapes_to_polygon.h>
#include <core/arraydim.h>
#include <geometry/geometry_utils.h>
#include <string_utils.h>
#include <locale_io.h>
#include <macros.h>
#include <properties.h>
#include <trigo.h>
#include <math/util.h>
#include <progress_reporter.h>
#include <project.h>
#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_track.h>
#include <fp_shape.h>
#include <zone.h>
#include <pad_shapes.h>
#include <pcb_text.h>
#include <pcb_dimension.h>
#include <plugins/eagle/eagle_plugin.h>

Go to the source code of this file.

Macros

#define DIMENSION_PRECISION   2
 

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, int aLayer)
 

Macro Definition Documentation

◆ DIMENSION_PRECISION

#define DIMENSION_PRECISION   2

Definition at line 695 of file eagle_plugin.cpp.

Function Documentation

◆ eagleClamp()

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

Definition at line 105 of file eagle_plugin.cpp.

106{
107 T ret = std::max( aMin, aValue );
108 return std::min( aMax, ret );
109}

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

123{
124 wxString token = aText.Upper();
125
126 if ( token == wxT( ">NAME" ) ) return wxT( "${REFERENCE}" );
127 else if( token == wxT( ">VALUE" ) ) return wxT( "${VALUE}" );
128 else if( token == wxT( ">PART" ) ) return wxT( "${REFERENCE}" );
129 else if( token == wxT( ">GATE" ) ) return wxT( "${UNIT}" );
130 else if( token == wxT( ">MODULE" ) ) return wxT( "${FOOTPRINT_NAME}" );
131 else if( token == wxT( ">SHEETNR" ) ) return wxT( "${#}" );
132 else if( token == wxT( ">SHEETS" ) ) return wxT( "${##}" );
133 else if( token == wxT( ">SHEET" ) ) return wxT( "${#}/${##}" );
134 else if( token == wxT( ">SHEETNR_TOTAL" ) ) return wxT( "${#}" );
135 else if( token == wxT( ">SHEETS_TOTAL" ) ) return wxT( "${##}" );
136 else if( token == wxT( ">SHEET_TOTAL" ) ) return wxT( "${#}/${##}" );
137 else if( token == wxT( ">ASSEMBLY_VARIANT" ) ) return wxT( "${ASSEMBLY_VARIANT}" );
138 else if( token == wxT( ">DRAWING_NAME" ) ) return wxT( "${TITLE}" );
139 else if( token == wxT( ">LAST_DATE_TIME" ) ) return wxT( "${ISSUE_DATE}" );
140 else if( token == wxT( ">PLOT_DATE_TIME" ) ) return wxT( "${CURRENT_DATE}" );
141
142 wxString text;
143 bool sectionOpen = false;
144
145 for( wxString::size_type i = 0; i < aText.size(); i++ )
146 {
147 // Interpret escaped characters
148 if( aText[ i ] == '\\' )
149 {
150 if( i + 1 != aText.size() )
151 text.Append( aText[ i + 1 ] );
152
153 i++;
154 continue;
155 }
156
157 // Escape ~ for KiCAD
158 if( aText[i] == '~' )
159 {
160 text.Append( '~' );
161 text.Append( '~' );
162 continue;
163 }
164
165 if( aText[ i ] == '!' )
166 {
167 if( sectionOpen )
168 {
169 text.Append( '~' );
170 sectionOpen = false;
171 continue;
172 }
173
174 static wxString escapeChars( wxT( " )]}'\"" ) );
175
176 if( i + 1 != aText.size() && escapeChars.Find( aText[i + 1] ) == wxNOT_FOUND )
177 {
178 sectionOpen = true;
179 text.Append( '~' );
180 }
181 else
182 {
183 text.Append( aText[ i ] );
184 }
185
186 continue;
187 }
188
189 if( aText[i] == ',' && sectionOpen )
190 {
191 text.Append( '~' );
192 sectionOpen = false;
193 }
194
195 text.Append( aText[ i ] );
196 }
197
198 return text;
199}

References text.

Referenced by EAGLE_PLUGIN::loadPlain(), and EAGLE_PLUGIN::packageText().

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

115{
116 wxString key = aFirst + '\x02' + aSecond;
117 return key;
118}

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

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

References ECOORD::ToPcbUnits().

Referenced by ERULES::parse().

◆ setKeepoutSettingsToZone()

static void setKeepoutSettingsToZone ( ZONE aZone,
int  aLayer 
)
static

Definition at line 202 of file eagle_plugin.cpp.

203{
204 if( aLayer == EAGLE_LAYER::TRESTRICT || aLayer == EAGLE_LAYER::BRESTRICT )
205 {
206 aZone->SetIsRuleArea( true );
207 aZone->SetDoNotAllowVias( true );
208 aZone->SetDoNotAllowTracks( true );
209 aZone->SetDoNotAllowCopperPour( true );
210 aZone->SetDoNotAllowPads( true );
211 aZone->SetDoNotAllowFootprints( false );
212
213 if( aLayer == EAGLE_LAYER::TRESTRICT ) // front layer keepout
214 aZone->SetLayer( F_Cu );
215 else // bottom layer keepout
216 aZone->SetLayer( B_Cu );
217 }
218 else if( aLayer == EAGLE_LAYER::VRESTRICT )
219 {
220 aZone->SetIsRuleArea( true );
221 aZone->SetDoNotAllowVias( true );
222 aZone->SetDoNotAllowTracks( false );
223 aZone->SetDoNotAllowCopperPour( false );
224 aZone->SetDoNotAllowPads( false );
225 aZone->SetDoNotAllowFootprints( false );
226
227 aZone->SetLayerSet( LSET::AllCuMask() );
228 }
229}
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:725
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:722
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:249
void SetIsRuleArea(bool aEnable)
Definition: zone.h:721
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:724
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:723
void SetLayerSet(LSET aLayerSet) override
Definition: zone.cpp:255
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:726
@ B_Cu
Definition: layer_ids.h:95
@ F_Cu
Definition: layer_ids.h:64

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().