55 #include <wx/string.h> 56 #include <wx/xml/xml.h> 57 #include <wx/filename.h> 86 ? ECOORD::EAGLE_UNIT::EU_MIL : ECOORD::EAGLE_UNIT::EU_MM;
88 ECOORD coord( aDistance, unit );
99 T ret = std::max( aMin, aValue );
100 return std::min( aMax, ret );
106 static wxString
makeKey(
const wxString& aFirst,
const wxString& aSecond )
108 wxString key = aFirst +
'\x02' + aSecond;
116 bool sectionOpen =
false;
118 for ( wxString::size_type i = 0; i < aText.size(); i++ )
121 if ( aText[ i ] ==
'\\' )
123 if ( i + 1 != aText.size() )
124 text.Append( aText[ i + 1 ] );
131 if( aText[i] ==
'~' )
138 if ( aText[ i ] ==
'!' )
147 static wxString escapeChars(
" )]}'\"" );
149 if( i + 1 != aText.size() && escapeChars.Find( aText[i + 1] ) == wxNOT_FOUND )
156 text.Append( aText[ i ] );
161 if( aText[i] ==
',' && sectionOpen )
167 text.Append( aText[ i ] );
206 wxXmlNode* child = aRules->GetChildren();
210 if( child->GetName() ==
"param" )
212 const wxString&
name = child->GetAttribute(
"name" );
213 const wxString& value = child->GetAttribute(
"value" );
215 if(
name ==
"psElongationLong" )
216 psElongationLong = wxAtoi( value );
217 else if(
name ==
"psElongationOffset" )
218 psElongationOffset = wxAtoi( value );
220 else if(
name ==
"mvStopFrame" )
221 value.ToCDouble( &mvStopFrame );
222 else if(
name ==
"mvCreamFrame" )
223 value.ToCDouble( &mvCreamFrame );
224 else if(
name ==
"mlMinStopFrame" )
226 else if(
name ==
"mlMaxStopFrame" )
228 else if(
name ==
"mlMinCreamFrame" )
230 else if(
name ==
"mlMaxCreamFrame" )
233 else if(
name ==
"srRoundness" )
234 value.ToCDouble( &srRoundness );
235 else if(
name ==
"srMinRoundness" )
237 else if(
name ==
"srMaxRoundness" )
240 else if(
name ==
"psTop" )
241 psTop = wxAtoi( value );
242 else if(
name ==
"psBottom" )
243 psBottom = wxAtoi( value );
244 else if(
name ==
"psFirst" )
245 psFirst = wxAtoi( value );
247 else if(
name ==
"rvPadTop" )
248 value.ToCDouble( &rvPadTop );
249 else if(
name ==
"rlMinPadTop" )
251 else if(
name ==
"rlMaxPadTop" )
254 else if(
name ==
"rvViaOuter" )
255 value.ToCDouble( &rvViaOuter );
256 else if(
name ==
"rlMinViaOuter" )
258 else if(
name ==
"rlMaxViaOuter" )
260 else if(
name ==
"mdWireWire" )
264 child = child->GetNext();
271 m_xpath( new
XPATH() ),
272 m_mod_time( wxDateTime::Now() )
274 using namespace std::placeholders;
293 return wxT(
"Eagle" );
306 return wxSize( kz - aTextThickness, kz - aTextThickness );
325 unique_ptr<BOARD> deleter( aAppendToMe ?
NULL :
m_board );
330 wxXmlDocument xmlDocument;
331 wxFileName fn = aFileName;
333 if( !xmlDocument.Load( fn.GetFullPath() ) )
336 fn.GetFullPath() ) );
339 doc = xmlDocument.GetRoot();
367 if( clearance < defaultNetclass->GetClearance() )
377 wxString errmsg = exc.what();
392 if( (lyrcnt % 2) != 0 )
407 std::vector<FOOTPRINT*> retval;
409 for( std::pair<wxString, FOOTPRINT*> fp :
m_templates )
411 retval.push_back( static_cast<FOOTPRINT*>( fp.second->Clone() ) );
448 wxXmlNode* drawing =
MapChildren( aDoc )[
"drawing"];
451 wxXmlNode* board = drawingChildren[
"board"];
459 wxXmlNode* designrules = boardChildren[
"designrules"];
468 wxXmlNode* layers = drawingChildren[
"layers"];
478 wxXmlNode* plain = boardChildren[
"plain"];
481 wxXmlNode* signals = boardChildren[
"signals"];
484 wxXmlNode* libs = boardChildren[
"libraries"];
487 wxXmlNode* elems = boardChildren[
"elements"];
516 wxXmlNode* layerNode = aLayers->GetChildren();
523 ELAYER elayer( layerNode );
530 cu.push_back( elayer );
533 layerNode = layerNode->GetNext();
537 int ki_layer_count = 0;
539 for(
EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count )
541 if( ki_layer_count == 0 )
543 else if( ki_layer_count ==
int( cu.size()-1 ) )
548 m_cu_map[it->number] = ki_layer_count;
557 for(
EITER it = cu.begin(); it != cu.end(); ++it )
573 #define DIMENSION_PRECISION 1 // 0.001 mm 583 wxXmlNode* gr = aGraphics->GetChildren();
588 wxString grName = gr->GetName();
590 if( grName ==
"wire" )
632 else if( grName ==
"text" )
663 if( degrees == 90 || t.
rot->
spin )
665 else if( degrees == 180 )
667 else if( degrees == 270 )
674 if( ( degrees > 0 ) && ( degrees < 90 ) )
676 else if( ( degrees > 90 ) && ( degrees < 180 ) )
681 else if( ( degrees > 180 ) && ( degrees < 270 ) )
686 else if( ( degrees > 270 ) && ( degrees < 360 ) )
739 else if( grName ==
"circle" )
758 int outlineRadius = radius + ( width / 2 );
761 wxPoint rotatedPoint( outlineRadius, 0 );
769 int innerRadius = radius - ( width / 2 );
772 wxPoint rotatedPoint( innerRadius, 0 );
800 else if( grName ==
"rectangle" )
820 const int outlineIdx = -1;
836 else if( grName ==
"hole" )
852 else if( grName ==
"frame" )
856 else if( grName ==
"polygon" )
862 else if( grName ==
"dimension" )
880 d.
y1 =
ECOORD( newY, ECOORD::EAGLE_UNIT::EU_NM );
881 d.
y2 =
ECOORD( newY, ECOORD::EAGLE_UNIT::EU_NM );
886 d.
x1 =
ECOORD( newX, ECOORD::EAGLE_UNIT::EU_NM );
887 d.
x2 =
ECOORD( newX, ECOORD::EAGLE_UNIT::EU_NM );
905 if( abs( ( d.
x1 - d.
x2 ).ToPcbUnits() ) < 50000 )
925 wxXmlNode* packages =
MapChildren( aLib )[
"packages"];
937 wxXmlNode*
package = packages->GetChildren();
943 wxString pack_ref = package->GetAttribute(
"name" );
948 wxString key = aLibName ?
makeKey( *aLibName, pack_ref ) : pack_ref;
953 std::pair<FOOTPRINT_MAP::iterator, bool> r =
m_templates.insert( {key, m} );
957 wxString lib = aLibName ? *aLibName :
m_lib_path;
958 const wxString& pkg = pack_ref;
961 _(
"<package> name: \"%s\" duplicated in eagle <library>: \"%s\"" ), pkg, lib );
967 package = package->GetNext();
982 wxXmlNode* library = aLibs->GetChildren();
986 const wxString& lib_name = library->GetAttribute(
"name" );
990 library = library->GetNext();
1006 bool refanceNamePresetInPackageLayout;
1007 bool valueNamePresetInPackageLayout;
1010 wxXmlNode* element = aElements->GetChildren();
1014 if( element->GetName() !=
"element" )
1017 element = element->GetNext();
1024 EATTR* nameAttr =
nullptr;
1025 EATTR* valueAttr =
nullptr;
1031 FOOTPRINT_MAP::const_iterator it =
m_templates.find( pkg_key );
1041 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( it->second->Duplicate() );
1046 for(
PAD* pad : footprint->
Pads() )
1048 wxString pn_key =
makeKey( e.
name, pad->GetName() );
1053 const ENET* enet = &ni->second;
1054 pad->SetNetCode( enet->
netcode );
1058 refanceNamePresetInPackageLayout =
true;
1059 valueNamePresetInPackageLayout =
true;
1066 refanceNamePresetInPackageLayout =
false;
1070 if( footprint->
GetValue().size() == 0 )
1073 valueNamePresetInPackageLayout =
false;
1081 if( valueNamePresetInPackageLayout )
1084 if( refanceNamePresetInPackageLayout )
1103 wxXmlNode* attribute = element->GetChildren();
1107 if( attribute->GetName() !=
"attribute" )
1109 attribute = attribute->GetNext();
1113 EATTR a( attribute );
1115 if( a.
name ==
"NAME" )
1128 wxString reference = e.
name;
1133 if( reference.find_first_not_of(
"0123456789" ) == wxString::npos )
1134 reference.Prepend(
"UNK" );
1136 nameAttr->
name = reference;
1139 if( refanceNamePresetInPackageLayout )
1145 if( refanceNamePresetInPackageLayout )
1153 if( refanceNamePresetInPackageLayout )
1167 if( refanceNamePresetInPackageLayout )
1175 else if( a.
name ==
"VALUE" )
1189 if( valueNamePresetInPackageLayout )
1195 if( valueNamePresetInPackageLayout )
1202 if( valueNamePresetInPackageLayout )
1216 if( valueNamePresetInPackageLayout )
1228 attribute = attribute->GetNext();
1241 element = element->GetNext();
1252 ZONE* zone =
nullptr;
1259 _(
"Ignoring a polygon since Eagle layer '%s' (%d) " 1279 wxXmlNode* vertex = aPolyNode->GetChildren();
1280 std::vector<EVERTEX> vertices;
1288 if( vertex->GetName() ==
"vertex" )
1289 vertices.emplace_back( vertex );
1291 vertex = vertex->GetNext();
1294 vertices.push_back( vertices[0] );
1299 for(
size_t i = 0; i < vertices.size() - 1; i++ )
1313 double end_angle = atan2(
kicad_y(
v2.
y ) - center.y,
1315 double radius = sqrt( pow( center.x -
kicad_x( v1.
x ), 2 )
1316 + pow( center.y -
kicad_y( v1.
y ), 2 ) );
1319 double delta_angle =
angle / segCount;
1321 for(
double a = end_angle +
angle;
1322 fabs( a - end_angle ) > fabs( delta_angle );
1326 KiROUND( radius * sin( a ) ) + center.y );
1394 const EATTR* aNameAttr,
const EATTR* aValueAttr )
1416 const EATTR* aAttr )
1421 const EATTR& a = *aAttr;
1438 int textThickness =
KiROUND( fontz.y * ratio / 100 );
1474 if( degrees == 90 || degrees == 0 || spin )
1479 else if( degrees == 180 )
1485 else if( degrees == 270 )
1538 if( ( !aFPText->
IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ) )
1539 || ( aFPText->
IsMirrored() && ( degrees == 360 ) ) )
1551 std::unique_ptr<FOOTPRINT> m = std::make_unique<FOOTPRINT>(
m_board );
1554 fpID.
Parse( aPkgName,
true );
1558 wxXmlNode* packageItem = aPackage->GetChildren();
1560 while( packageItem )
1562 const wxString& itemName = packageItem->GetName();
1564 if( itemName ==
"description" )
1565 m->SetDescription(
FROM_UTF8( packageItem->GetNodeContent().c_str() ) );
1567 else if( itemName ==
"wire" )
1570 else if( itemName ==
"pad" )
1573 else if( itemName ==
"text" )
1576 else if( itemName ==
"rectangle" )
1579 else if( itemName ==
"polygon" )
1582 else if( itemName ==
"circle" )
1585 else if( itemName ==
"hole" )
1588 else if( itemName ==
"smd" )
1591 packageItem = packageItem->GetNext();
1608 wxLogMessage(
wxString::Format(
_(
"Ignoring a wire since Eagle layer '%s' (%d) " 1668 aFootprint->
Add( dwg );
1679 PAD* pad =
new PAD( aFootprint );
1680 aFootprint->
Add( pad );
1690 pad->
SetDrillSize( wxSize( eagleDrillz, eagleDrillz ) );
1741 pad->
SetSize( wxSize( diameter, diameter ) );
1748 int diameter =
KiROUND( drillz + 2 * annulus );
1762 int offset =
KiROUND( ( sz.x - sz.y ) / 2.0 );
1781 wxLogMessage(
wxString::Format(
_(
"Ignoring a text since Eagle layer '%s' (%d) " 1790 if( t.
text ==
">NAME" || t.
text ==
">name" )
1792 else if( t.
text ==
">VALUE" || t.
text ==
">value" )
1793 txt = &aFootprint->
Value();
1797 txt =
new FP_TEXT( aFootprint );
1798 aFootprint->
Add( txt );
1829 if( degrees == 90 || t.
rot->
spin )
1831 else if( degrees == 180 )
1833 else if( degrees == 270 )
1897 const int outlineIdx = -1;
1919 wxLogMessage(
wxString::Format(
_(
"Ignoring a rectange since Eagle layer '%s' (%d) " 1928 aFootprint->
Add( dwg );
1933 std::vector<wxPoint> pts;
1938 pts.push_back( start );
1941 pts.push_back( end );
1958 std::vector<wxPoint> pts;
1961 wxXmlNode* vertex = aTree->GetChildren();
1962 std::vector<EVERTEX> vertices;
1970 if( vertex->GetName() ==
"vertex" )
1971 vertices.emplace_back( vertex );
1973 vertex = vertex->GetNext();
1976 vertices.push_back( vertices[0] );
1978 for(
size_t i = 0; i < vertices.size() - 1; i++ )
1992 double end_angle = atan2(
kicad_y(
v2.
y ) - center.y,
1994 double radius = sqrt( pow( center.x -
kicad_x( v1.
x ), 2 )
1995 + pow( center.y -
kicad_y( v1.
y ), 2 ) );
2002 double delta =
angle / segCount;
2004 for(
double a = end_angle +
angle; fabs( a - end_angle ) > fabs( delta ); a -= delta )
2006 pts.push_back( wxPoint(
KiROUND( radius * cos( a ) ),
2007 KiROUND( radius * sin( a ) ) ) + center );
2034 wxLogMessage(
wxString::Format(
_(
"Ignoring a polygon since Eagle layer '%s' (%d) " 2043 aFootprint->
Add( dwg );
2075 int outlineRadius = radius + ( width / 2 );
2078 wxPoint rotatedPoint( outlineRadius, 0 );
2086 int innerRadius = radius - ( width / 2 );
2089 wxPoint rotatedPoint( innerRadius, 0 );
2104 wxLogMessage(
wxString::Format(
_(
"Ignoring a circle since Eagle layer '%s' (%d) " 2117 radius = radius / 2;
2120 aFootprint->
Add( gr );
2123 switch( (
int) layer )
2145 PAD* pad =
new PAD( aFootprint );
2146 aFootprint->
Add( pad );
2160 pad->
SetPos0( wxPoint( 0, 0 ) );
2187 PAD* pad =
new PAD( aFootprint );
2188 aFootprint->
Add( pad );
2203 else if( layer ==
B_Cu )
2206 int minPadSize = std::min( padSize.x, padSize.y );
2214 double roundRatio = (double) roundRadius / minPadSize / 2.0;
2218 roundRatio = std::fmax( *e.
roundness / 200.0, roundRatio );
2236 else if( layer ==
B_Cu )
2245 else if( layer ==
B_Cu )
2261 const wxSize& padSize( aPad->
GetSize() );
2272 wxCHECK( footprint, );
2296 wxXmlNode* net = aSignals->GetChildren();
2300 bool sawPad =
false;
2304 const wxString& netName =
escapeName( net->GetAttribute(
"name" ) );
2310 wxXmlNode* netItem = net->GetChildren();
2315 const wxString& itemName = netItem->GetName();
2317 if( itemName ==
"wire" )
2328 double end_angle = 0.0;
2329 double radius = 0.0;
2330 double delta_angle = 0.0;
2346 end_angle = atan2(
kicad_y( w.
y2 ) - center.y,
2349 radius = sqrt( pow( center.x -
kicad_x( w.
x1 ), 2 ) +
2353 delta_angle =
angle / segs;
2356 while( fabs(
angle ) > fabs( delta_angle ) )
2358 wxASSERT( radius > 0.0 );
2359 wxPoint end(
KiROUND( radius * cos( end_angle +
angle ) + center.x ),
2360 KiROUND( radius * sin( end_angle +
angle ) + center.y ) );
2373 angle -= delta_angle;
2394 else if( itemName ==
"via" )
2410 via->
SetLayerPair( layer_front_most, layer_back_most );
2422 kidiam =
KiROUND( drillz + 2 * annulus );
2435 via->
SetWidth( drillz + 2 * annulus );
2447 if( layer_front_most ==
F_Cu && layer_back_most ==
B_Cu )
2449 else if( layer_front_most ==
F_Cu || layer_back_most ==
B_Cu )
2465 else if( itemName ==
"contactref" )
2470 const wxString& reference = netItem->GetAttribute(
"element" );
2471 const wxString& pad = netItem->GetAttribute(
"pad" );
2472 wxString key =
makeKey( reference, pad ) ;
2481 else if( itemName ==
"polygon" )
2488 zones.push_back( zone );
2490 if( !zone->GetIsRuleArea() )
2491 zone->SetNetCode( netCode );
2497 netItem = netItem->GetNext();
2500 if( zones.size() && !sawPad )
2504 for(
ZONE* zone : zones )
2513 net = net->GetNext();
2520 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector )
2522 std::map<wxString, PCB_LAYER_ID> layer_map;
2527 layer_map.emplace( layer.Name, layerId );
2535 std::vector<INPUT_LAYER_DESC> inputDescs;
2537 for (
const std::pair<const int, ELAYER>& layerPair :
m_eagleLayers )
2539 const ELAYER& eLayer = layerPair.second;
2550 inputDescs.push_back( layerDesc );
2570 if( copperLayer >= 0 )
2571 copperLayers[copperLayer] =
true;
2578 bool required =
false;
2579 LSET permittedLayers;
2581 permittedLayers.set();
2584 switch( aEagleLayer )
2686 return {
PCB_LAYER_ID( kiLayer ), permittedLayers, required };
2692 static const wxString unknown(
"unknown" );
2694 return it ==
m_eagleLayers.end() ? unknown : it->second.name;
2700 static const int unknown = -1;
2718 int w = atoi( page_width.
c_str() );
2719 int h = atoi( page_height.
c_str() );
2721 int desired_x = ( w - bbbox.
GetWidth() ) / 2;
2722 int desired_y = ( h - bbbox.
GetHeight() ) / 2;
2733 if( aPath.IsEmpty() )
2734 return wxDateTime::Now();
2736 wxFileName fn( aPath );
2738 if( fn.IsFileReadable() )
2739 return fn.GetModificationTime();
2741 return wxDateTime( 0.0 );
2771 string filename = (
const char*) aLibPath.char_str( wxConvFile );
2774 wxXmlDocument xmlDocument;
2775 wxFileName fn( filename );
2777 if( !xmlDocument.Load( fn.GetFullPath() ) )
2779 fn.GetFullPath() ) );
2781 doc = xmlDocument.GetRoot();
2783 wxXmlNode* drawing =
MapChildren( doc )[
"drawing"];
2790 wxXmlNode* layers = drawingChildren[
"layers"];
2795 wxXmlNode* library = drawingChildren[
"library"];
2826 bool aBestEfforts,
const PROPERTIES* aProperties )
2830 init( aProperties );
2838 errorMsg = ioe.
What();
2845 aFootprintNames.Add(
FROM_UTF8( it->first.c_str() ) );
2847 if( !errorMsg.IsEmpty() && !aBestEfforts )
2853 const wxString& aFootprintName,
2856 init( aProperties );
2858 FOOTPRINT_MAP::const_iterator it =
m_templates.find( aFootprintName );
void SetMirrored(bool isMirrored)
std::vector< ZONE * > ZONES
wxString Contents()
return the contents of the XPATH as a single string
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
#define DEFAULT_EDGE_WIDTH
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
void loadAllSections(wxXmlNode *aDocument)
double rlMaxViaOuter
maximum copper annulus on via
void SetOffset(const wxPoint &aOffset)
opt_double curve
range is -359.9..359.9
#define DEFAULT_COURTYARD_WIDTH
int kicad_x(const ECOORD &x) const
void SetHatchThickness(int aThickness)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
void SetEnd0(const wxPoint &aPoint)
void packageHole(FOOTPRINT *aFootprint, wxXmlNode *aTree, bool aCenter) const
Container for project specific data.
static T eagleClamp(T aMin, T aValue, T aMax)
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
void centerBoard()
move the BOARD into the center of the page
BOARD * m_board
which BOARD is being worked on, no ownership here
void SetDoNotAllowTracks(bool aEnable)
int eagle_layer_id(const wxString &aLayerName) const
Get Eagle layer number by its name.
virtual void SetStart(const wxPoint &aPoint)
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
SHAPE_POLY_SET & GetPolyShape()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void FootprintLibOptions(PROPERTIES *aProperties) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
void SetPosition(const wxPoint &aPoint) override
int psTop
Shape of the top pads.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
void SetEnd(const wxPoint &aEnd)
std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetBorderDisplayStyle sets all hatch parameters for the zone.
ERULES * m_rules
Eagle design rules.
const EDA_RECT GetBoardEdgesBoundingBox() const
Returns the board bounding box calculated using exclusively the board edges (graphics on Edge....
void SetTextAngle(double aAngle) override
void SetFilled(bool aFlag)
void SetTextAngle(double aAngle) override
void SetLayerSet(LSET aLayerSet) override
SHAPE_POLY_SET * Outline()
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void push(const char *aPathSegment, const char *aAttribute="")
Keep track of what we are working on within a PTREE.
static const int max_priority
Smd pad, appears on the solder paste layer (default)
double rlMaxPadTop
maximum copper annulus on through hole pads
void SetTextPos(const wxPoint &aPoint)
polygon (not yet used for tracks, but could be in microwave apps)
void SetVisible(bool aVisible)
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
int mlMinStopFrame
solder mask, minimum size (Eagle mils, here nanometers)
double GetTextAngle() const
void SetCopperLayerCount(int aCount)
#define DEFAULT_LINE_WIDTH
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
static int parseEagle(const wxString &aDistance)
Parse an eagle distance which is either mm, or mils if there is "mil" suffix.
int srMinRoundness
corner rounding radius, maximum size (Eagle mils, here nanometers)
usual segment : line with rounded ends
std::map< wxString, int > m_eagleLayersIds
Eagle layer ids stored by layer name.
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void parse(wxXmlNode *aRules)
percent over 100%.
NET_MAP::const_iterator NET_MAP_CITER
PAD_SHAPE_T GetShape() const
void init(const PROPERTIES *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void SetUnits(EDA_UNITS aUnits)
void SetTextSize(const wxSize &aNewSize)
virtual void FootprintLibOptions(PROPERTIES *aListToAppendTo) const
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
void SetSize(const wxSize &aSize)
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
void RotatePoint(int *pX, int *pY, double angle)
void Inflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
like PAD_PTH, but not plated mechanical use only, no connection allowed
A logical library item identifier and consists of various portions much like a URI.
int m_min_via
smallest via we find on Load(), in BIU.
double rvViaOuter
copper annulus is this percent of via hole
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
A name/value tuple with unique names and optional values.
Implement a simple wrapper around runtime_error to isolate the errors thrown by the Eagle XML parser.
void SetPriority(unsigned aPriority)
Function SetPriority.
const wxString & eagle_layer_name(int aLayer) const
Get Eagle layer name by its number.
FOOTPRINT_MAP m_templates
is part of a FOOTPRINT factory that operates using copy construction.
void loadLayerDefs(wxXmlNode *aLayers)
void SetFillMode(ZONE_FILL_MODE aFillMode)
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
virtual void SetParent(EDA_ITEM *aParent)
virtual void RegisterLayerMappingCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
int m_cu_map[17]
map eagle to KiCad, cu layers only.
void SetWidth(int aWidth)
const char * c_str() const
OPTIONAL_XML_ATTRIBUTE< wxString > opt_wxString
int layer_back_most
< extent
void SetIsRuleArea(bool aEnable)
void packageWire(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void Rotate(const wxPoint &aCentre, double aAngle) override
Function Rotate Move the outlines.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
void SetLocalSolderMaskMargin(int aMargin)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
void SetClosed(bool aClosed)
Function SetClosed()
const wxSize & GetDrillSize() const
PCB_LAYER_ID
A quick note on layer IDs:
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.
void SetHeight(int aHeight)
Sets the distance from the feature points to the crossbar line.
LSET is a set of PCB_LAYER_IDs.
#define DEFAULT_SILK_LINE_WIDTH
void NewHole()
Function NewHole creates a new hole on the zone; i.e., a new contour on the zone's outline.
void cacheLib(const wxString &aLibraryPath)
This PLUGIN only caches one footprint library, this determines which one.
wxString escapeName(const wxString &aNetName)
pads are covered by copper
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
virtual void SetText(const wxString &aText)
void SetHatchGap(int aStep)
void SetPos0(const wxPoint &aPos)
void SetShape(PCB_SHAPE_TYPE_T aShape)
virtual const wxString What() const
A composite of Problem() and Where()
std::map< int, ELAYER > m_eagleLayers
Eagle layer data stored by layer number.
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
void SetDoNotAllowPads(bool aEnable)
void SetClearance(int aClearance)
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
Represent a set of closed polygons.
int GetDrill() const
Function GetDrill returns the local drill setting for this VIA.
const wxSize & GetTextSize() const
void packageRectangle(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
void packagePad(FOOTPRINT *aFootprint, wxXmlNode *aTree)
void SetDrillSize(const wxSize &aSize)
void SetAngle(double aAngle, bool aUpdateEnd=true) override
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
const wxSize & GetSize() const
A collection of nets and the parameters used to route or test these nets.
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
virtual BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
FOOTPRINT * makeFootprint(wxXmlNode *aPackage, const wxString &aPkgName)
Create a FOOTPRINT from an Eagle package.
virtual void SetEnd(const wxPoint &aPoint)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
void SetDoNotAllowVias(bool aEnable)
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
a few functions useful in geometry calculations.
subset of eagle.drawing.board.designrules in the XML document
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_layer contains the top layer, the other layer is in m_bottomLayer.
ZONE handles a list of polygons defining a copper zone.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void orientFootprintAndText(FOOTPRINT *aFootprint, const EELEMENT &e, const EATTR *aNameAttr, const EATTR *aValueAttr)
void SetZoneConnection(ZONE_CONNECTION aType)
void SetFileName(const wxString &aFileName)
void SetMinThickness(int aMinThickness)
bool Value(const char *aName, UTF8 *aFetchedValue=nullptr) const
Fetch a property by aName and returns true if that property was found, else false.
static wxDateTime getModificationTime(const wxString &aPath)
get a file's or dir's modification time.
double mdWireWire
wire to wire spacing I presume.
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
int m_min_trace
smallest trace we find on Load(), in BIU.
int NewOutline()
Creates a new hole in a given outline.
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
int m_hole_count
generates unique footprint names from eagle "hole"s.
Eagle XML rectangle in binary.
double srRoundness
corner rounding ratio for SMD pads (percentage)
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
void SetStart0(const wxPoint &aPoint)
void SetPos0(const wxPoint &aPos)
int psFirst
Shape of the first pads.
opt_double curve
range is -359.9..359.9
int LAYER_NUM
This can be replaced with int and removed.
void loadLibraries(wxXmlNode *aLibs)
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
void loadPlain(wxXmlNode *aPlain)
std::tuple< PCB_LAYER_ID, LSET, bool > defaultKicadLayer(int aEagleLayer) const
Get default KiCad layer corresponding to an Eagle layer of the board, a set of sensible layer mapping...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
FOOTPRINT * GetParent() const
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
void transferPad(const EPAD_COMMON &aEaglePad, PAD *aPad) const
Deletes the footprint templates list.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void Move(const wxPoint &aMoveVector) override
Move this object.
Use thermal relief for pads.
Parse an Eagle "attribute" XML element.
static wxString interpret_text(const wxString &aText)
interpret special characters in Eagle text and converts them to KiCAD notation
std::vector< ELAYER > ELAYERS
Handle the data for a net.
wxSize kicad_fontz(const ECOORD &d, int aTextThickness) const
create a font size (fontz) from an eagle font size scalar and KiCad font thickness
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
void SetPadConnection(ZONE_CONNECTION aPadConnection)
opt_wxString dimensionType
int mlMinCreamFrame
solder paste mask, minimum size (Eagle mils, here nanometers)
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
void SetLayerSet(LSET aLayers) override
#define ZONE_THICKNESS_MIN_VALUE_MIL
wxPoint GetPosition() const override
void loadElements(wxXmlNode *aElements)
std::map< wxString, PCB_LAYER_ID > m_layer_map
Map of Eagle layers to KiCad layers.
void packageCircle(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
double DEG2RAD(double deg)
void SetLocalSolderPasteMargin(int aMargin)
void SetStart(const wxPoint &aStart)
Information pertinent to a Pcbnew printed circuit board.
void packagePolygon(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void packageText(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Structure holding common properties for through-hole and SMD pads.
void SetDoNotAllowCopperPour(bool aEnable)
void SetPrecision(int aPrecision)
void SetPosition(const wxPoint &aPos) override
wxPoint ConvertArcCenter(const wxPoint &aStart, const wxPoint &aEnd, double aAngle)
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void SetPosition(const wxPoint &aPos) override
#define DIMENSION_PRECISION
ELAYERS::const_iterator EITER
int GetCopperLayerCount() const
void packageSMD(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
Handles common pad properties.
Handle the component boundary box.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
NETCLASS * GetDefault() const
void loadLibrary(wxXmlNode *aLib, const wxString *aLibName)
Load the Eagle "library" XML element, which can occur either under a "libraries" element (if a *....
void SetWidth(int aWidth)
double mvStopFrame
solderpaste mask, expressed as percentage of the smaller pad/via dimension
void SetHatchOrientation(double aStep)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
int m_min_annulus
smallest via annulus we find on Load(), in BIU.
NET_MAP m_pads_to_nets
net list
static void setKeepoutSettingsToZone(ZONE *aZone, LAYER_NUM aLayer)
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void SetThermalReliefGap(int aThermalReliefGap)
void orientFPText(FOOTPRINT *aFootprint, const EELEMENT &e, FP_TEXT *aFPText, const EATTR *aAttr)
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
int m_min_hole
smallest diameter hole we find on Load(), in BIU.
double rvPadTop
top pad size as percent of drill size
void SetLocalClearance(int aClearance)
void AddPolygon(std::vector< wxPoint > &aPolygon)
add a polygon to the zone outline if the zone outline is empty, this is the main outline else it is a...
Eagle polygon, without vertices which are parsed as needed.
void SetLineThickness(int aWidth)
void loadDesignRules(wxXmlNode *aDesignRules)
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
For better understanding of the points that make a dimension:
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
void SetViaType(VIATYPE aViaType)
int psBottom
Shape of the bottom pads.
static constexpr int Millimeter2iu(double mm)
double rlMinPadTop
minimum copper annulus on through hole pads
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
double rlMinViaOuter
minimum copper annulus on via
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
just inflate the polygon. Acute angles create spikes
#define THROW_IO_ERROR(msg)
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
int mlMaxCreamFrame
solder paste mask, maximum size (Eagle mils, here nanometers)
FP_ZONE is a specialization of ZONE for use in footprints.
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
void mapEagleLayersToKicad()
Generate mapping between Eagle na KiCad layers.
void loadSignals(wxXmlNode *aSignals)
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
void SetOrientation(double aAngle)
Set the rotation angle of the pad.
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
void SetEnd(const wxPoint &aEnd)
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
ZONE * loadPolygon(wxXmlNode *aPolyNode)
Load a copper or keepout polygon and adds it to the board.
void SetDoNotAllowFootprints(bool aEnable)
void Value(const char *aValue)
modify the last path node's value
Container for design settings for a BOARD object.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int mlMaxStopFrame
solder mask, maximum size (Eagle mils, here nanometers)
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
void SetAttribute(PAD_ATTR_T aAttribute)