56#include <wx/xml/xml.h>
57#include <wx/filename.h>
59#include <wx/wfstream.h>
89 ? ECOORD::EAGLE_UNIT::EU_MIL
90 : ECOORD::EAGLE_UNIT::EU_MM;
92 ECOORD coord( aDistance, unit );
103 T ret = std::max( aMin, aValue );
104 return std::min( aMax, ret );
110static wxString
makeKey(
const wxString& aFirst,
const wxString& aSecond )
112 wxString key = aFirst +
'\x02' + aSecond;
160 wxXmlNode* child = aRules->GetChildren();
166 if( child->GetName() == wxT(
"param" ) )
168 const wxString&
name = child->GetAttribute( wxT(
"name" ) );
169 const wxString& value = child->GetAttribute( wxT(
"value" ) );
171 if(
name == wxT(
"psElongationLong" ) )
173 else if(
name == wxT(
"psElongationOffset" ) )
175 else if(
name == wxT(
"mvStopFrame" ) )
177 else if(
name == wxT(
"mvCreamFrame" ) )
179 else if(
name == wxT(
"mlMinStopFrame" ) )
181 else if(
name == wxT(
"mlMaxStopFrame" ) )
183 else if(
name == wxT(
"mlMinCreamFrame" ) )
185 else if(
name == wxT(
"mlMaxCreamFrame" ) )
187 else if(
name == wxT(
"srRoundness" ) )
189 else if(
name == wxT(
"srMinRoundness" ) )
191 else if(
name == wxT(
"srMaxRoundness" ) )
193 else if(
name == wxT(
"psTop" ) )
194 psTop = wxAtoi( value );
195 else if(
name == wxT(
"psBottom" ) )
197 else if(
name == wxT(
"psFirst" ) )
199 else if(
name == wxT(
"rvPadTop" ) )
201 else if(
name == wxT(
"rlMinPadTop" ) )
203 else if(
name == wxT(
"rlMaxPadTop" ) )
205 else if(
name == wxT(
"rvViaOuter" ) )
207 else if(
name == wxT(
"rlMinViaOuter" ) )
209 else if(
name == wxT(
"rlMaxViaOuter" ) )
211 else if(
name == wxT(
"mdWireWire" ) )
215 child = child->GetNext();
222 m_xpath( new
XPATH() ),
223 m_progressReporter( nullptr ),
225 m_lastProgressCount( 0 ),
227 m_mod_time( wxDateTime::Now() )
229 using namespace std::placeholders;
248 return wxT(
"Eagle" );
260 const unsigned PROGRESS_DELTA = 50;
282 return VECTOR2I( kz - aTextThickness, kz - aTextThickness );
303 unique_ptr<BOARD> deleter( aAppendToMe ?
nullptr :
m_board );
315 wxFileName fn = aFileName;
318 wxFFileInputStream stream( fn.GetFullPath() );
319 wxXmlDocument xmlDocument;
321 if( !stream.IsOk() || !xmlDocument.Load( stream ) )
324 fn.GetFullPath() ) );
327 doc = xmlDocument.GetRoot();
353 NETCLASS defaults( wxT(
"dummy" ) );
355 auto finishNetclass =
356 [&]( std::shared_ptr<NETCLASS> netclass )
362 if( netclass->GetTrackWidth() == INT_MAX )
365 if( netclass->GetViaDiameter() == INT_MAX )
368 if( netclass->GetViaDrill() == INT_MAX )
372 std::shared_ptr<NET_SETTINGS>& netSettings = bds.
m_NetSettings;
374 finishNetclass( netSettings->m_DefaultNetClass );
376 for(
const auto& [
name, netclass ] : netSettings->m_NetClasses )
377 finishNetclass( netclass );
382 fn.SetExt( wxT(
"kicad_dru" ) );
383 wxFile rulesFile( fn.GetFullPath(), wxFile::write );
391 wxString errmsg = exc.what();
411 std::vector<FOOTPRINT*> retval;
413 for( std::pair<wxString, FOOTPRINT*> fp :
m_templates )
414 retval.push_back(
static_cast<FOOTPRINT*
>( fp.second->Clone() ) );
450 wxXmlNode* drawing =
MapChildren( aDoc )[
"drawing"];
453 wxXmlNode* board = drawingChildren[
"board"];
456 auto count_children = [
this]( wxXmlNode* aNode )
460 wxXmlNode* child = aNode->GetChildren();
465 child = child->GetNext();
470 wxXmlNode* designrules = boardChildren[
"designrules"];
471 wxXmlNode* layers = drawingChildren[
"layers"];
472 wxXmlNode* plain = boardChildren[
"plain"];
473 wxXmlNode* classes = boardChildren[
"classes"];
474 wxXmlNode* signals = boardChildren[
"signals"];
475 wxXmlNode* libs = boardChildren[
"libraries"];
476 wxXmlNode* elems = boardChildren[
"elements"];
483 count_children( designrules );
484 count_children( layers );
485 count_children( plain );
486 count_children( signals );
487 count_children( elems );
492 libs = libs->GetNext();
496 libs = boardChildren[
"libraries"];
553 wxXmlNode* layerNode = aLayers->GetChildren();
560 ELAYER elayer( layerNode );
566 cu.push_back( elayer );
568 layerNode = layerNode->GetNext();
572 int ki_layer_count = 0;
574 for(
EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count )
576 if( ki_layer_count == 0 )
580 else if( ki_layer_count ==
int( cu.size()-1 ) )
587 m_cu_map[it->number] = ki_layer_count;
596 for(
EITER it = cu.begin(); it != cu.end(); ++it )
613#define DIMENSION_PRECISION DIM_PRECISION::X_XX
624 wxXmlNode* gr = aGraphics->GetChildren();
631 wxString grName = gr->GetName();
633 if( grName == wxT(
"wire" ) )
676 else if( grName == wxT(
"text" ) )
707 if( degrees == 90 || t.
rot->
spin )
711 else if( degrees == 180 )
715 else if( degrees == 270 )
724 if( ( degrees > 0 ) && ( degrees < 90 ) )
728 else if( ( degrees > 90 ) && ( degrees < 180 ) )
733 else if( ( degrees > 180 ) && ( degrees < 270 ) )
738 else if( ( degrees > 270 ) && ( degrees < 360 ) )
797 else if( grName == wxT(
"circle" ) )
816 int outlineRadius = radius + ( width / 2 );
822 VECTOR2I rotatedPoint( outlineRadius, 0 );
830 int innerRadius = radius - ( width / 2 );
836 VECTOR2I rotatedPoint( innerRadius, 0 );
863 else if( grName == wxT(
"rectangle" ) )
883 const int outlineIdx = -1;
899 else if( grName == wxT(
"hole" ) )
915 else if( grName == wxT(
"frame" ) )
919 else if( grName == wxT(
"polygon" ) )
925 else if( grName == wxT(
"dimension" ) )
994 int newY = ( pt1.
y + pt2.
y ) / 2;
1000 int newX = ( pt1.
x + pt2.
x ) / 2;
1011 dimension->
SetEnd( pt2 );
1021 if(
abs( pt1.
x - pt2.
x ) < 50000 )
1023 int offset = pt3.
x - pt1.
x;
1030 else if(
abs( pt1.
y - pt2.
y ) < 50000 )
1032 int offset = pt3.
y - pt1.
y;
1066 wxXmlNode* packages =
MapChildren( aLib )[
"packages"];
1078 wxXmlNode*
package = packages->GetChildren();
1086 wxString pack_ref = package->GetAttribute(
"name" );
1091 wxString key = aLibName ?
makeKey( *aLibName, pack_ref ) : pack_ref;
1096 std::pair<FOOTPRINT_MAP::iterator, bool> r =
m_templates.insert( { key, footprint} );
1100 wxString lib = aLibName ? *aLibName :
m_lib_path;
1101 const wxString& pkg = pack_ref;
1103 wxString emsg =
wxString::Format(
_(
"<package> '%s' duplicated in <library> '%s'" ),
1111 package = package->GetNext();
1126 wxXmlNode*
library = aLibs->GetChildren();
1130 const wxString& lib_name =
library->GetAttribute(
"name" );
1150 bool refanceNamePresetInPackageLayout;
1151 bool valueNamePresetInPackageLayout;
1154 wxXmlNode* element = aElements->GetChildren();
1160 if( element->GetName() != wxT(
"element" ) )
1163 element = element->GetNext();
1170 EATTR* nameAttr =
nullptr;
1171 EATTR* valueAttr =
nullptr;
1177 FOOTPRINT_MAP::const_iterator it =
m_templates.find( pkg_key );
1198 const ENET* enet = &ni->second;
1203 refanceNamePresetInPackageLayout =
true;
1204 valueNamePresetInPackageLayout =
true;
1211 refanceNamePresetInPackageLayout =
false;
1215 if( footprint->
GetValue().size() == 0 )
1218 valueNamePresetInPackageLayout =
false;
1221 wxString reference = e.
name;
1227 if( reference.find_first_not_of(
"0123456789" ) != 0 )
1228 reference.Prepend(
"UNK" );
1232 if( reference.find_first_not_of(
"#" ) != 0 )
1233 reference.Prepend(
"UNK" );
1236 if( reference.find_last_not_of(
"0123456789" ) == (reference.Length()-1) )
1237 reference.Append(
"0" );
1245 if( valueNamePresetInPackageLayout )
1248 if( refanceNamePresetInPackageLayout )
1268 wxXmlNode* attribute = element->GetChildren();
1272 if( attribute->GetName() != wxT(
"attribute" ) )
1274 attribute = attribute->GetNext();
1278 EATTR a( attribute );
1280 if( a.
name == wxT(
"NAME" ) )
1293 nameAttr->
name = reference;
1295 if( refanceNamePresetInPackageLayout )
1302 if( refanceNamePresetInPackageLayout )
1311 if( refanceNamePresetInPackageLayout )
1314 nameAttr->
name = nameAttr->
name + wxT(
" = " ) + e.
name;
1325 if( refanceNamePresetInPackageLayout )
1335 else if( a.
name == wxT(
"VALUE" ) )
1349 if( valueNamePresetInPackageLayout )
1355 if( valueNamePresetInPackageLayout )
1358 footprint->
SetValue( wxT(
"VALUE" ) );
1362 if( valueNamePresetInPackageLayout )
1376 if( valueNamePresetInPackageLayout )
1388 attribute = attribute->GetNext();
1401 element = element->GetNext();
1412 ZONE* zone =
nullptr;
1419 wxLogMessage(
wxString::Format(
_(
"Ignoring a polygon since Eagle layer '%s' (%d) "
1438 wxXmlNode* vertex = aPolyNode->GetChildren();
1439 std::vector<EVERTEX> vertices;
1447 if( vertex->GetName() == wxT(
"vertex" ) )
1448 vertices.emplace_back( vertex );
1450 vertex = vertex->GetNext();
1460 vertices.push_back( vertices[0] );
1465 for(
size_t i = 0; i < vertices.size() - 1; i++ )
1480 double radius = sqrt( pow( center.
x -
kicad_x(
v1.
x ), 2 )
1485 double delta_angle =
angle / segCount;
1487 for(
double a = end_angle +
angle; fabs( a - end_angle ) > fabs( delta_angle );
1491 KiROUND( radius * sin( a ) ) + center.
y );
1559 const EATTR* aNameAttr,
const EATTR* aValueAttr )
1580 const EATTR* aAttr )
1586 const EATTR& a = *aAttr;
1607 int textThickness =
KiROUND( fontz.
y * ratio / 100 );
1639 if( degrees == 90 || degrees == 0 || spin )
1644 else if( degrees == 180 )
1650 else if( degrees == 270 )
1721 if( ( !aFPText->
IsMirrored() && (
abs( degrees ) == 180 ||
abs( degrees ) == 270 ) )
1722 || ( aFPText->
IsMirrored() && ( degrees == 360 ) ) )
1734 std::unique_ptr<FOOTPRINT> m = std::make_unique<FOOTPRINT>(
m_board );
1737 fpID.
Parse( aPkgName,
true );
1741 wxXmlNode* packageItem = aPackage->GetChildren();
1746 m.get()->Value().SetLayer( layer );
1748 while( packageItem )
1750 const wxString& itemName = packageItem->GetName();
1752 if( itemName == wxT(
"description" ) )
1753 m->SetDescription( packageItem->GetNodeContent() );
1754 else if( itemName == wxT(
"wire" ) )
1756 else if( itemName == wxT(
"pad" ) )
1758 else if( itemName == wxT(
"text" ) )
1760 else if( itemName == wxT(
"rectangle" ) )
1762 else if( itemName == wxT(
"polygon" ) )
1764 else if( itemName == wxT(
"circle" ) )
1766 else if( itemName == wxT(
"hole" ) )
1768 else if( itemName == wxT(
"smd" ) )
1771 packageItem = packageItem->GetNext();
1788 wxLogMessage(
wxString::Format(
_(
"Ignoring a wire since Eagle layer '%s' (%d) "
1846 aFootprint->
Add( dwg );
1857 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( aFootprint );
1867 pad->SetDrillSize(
VECTOR2I( eagleDrillz, eagleDrillz ) );
1891 pad->SetChamferRectRatio( 1 - M_SQRT1_2 );
1919 double drillz =
pad->GetDrillSize().x;
1922 int diameter =
KiROUND( drillz + 2 * annulus );
1935 int offset =
KiROUND( ( sz.
x - sz.
y ) / 2.0 );
1943 if(
pad->GetSizeX() > 0 &&
pad->GetSizeY() > 0 )
1945 aFootprint->
Add(
pad.release() );
1961 wxLogMessage(
wxString::Format(
_(
"Ignoring a text since Eagle layer '%s' (%d) "
1969 if( t.
text.Upper() == wxT(
">NAME" ) && aFootprint->
GetReference().IsEmpty() )
1973 textItem->
SetText( wxT(
"REF**" ) );
1975 else if( t.
text.Upper() == wxT(
">VALUE" ) && aFootprint->
GetValue().IsEmpty() )
1977 textItem = &aFootprint->
Value();
1984 textItem =
new FP_TEXT( aFootprint );
1985 aFootprint->
Add( textItem );
2015 if( degrees == 90 || t.
rot->
spin )
2019 else if( degrees == 180 )
2023 else if( degrees == 270 )
2092 const int outlineIdx = -1;
2114 wxLogMessage(
wxString::Format(
_(
"Ignoring a rectangle since Eagle layer '%s' (%d) "
2122 aFootprint->
Add( dwg );
2128 std::vector<VECTOR2I> pts;
2133 pts.push_back( start );
2136 pts.push_back( end );
2150 std::vector<VECTOR2I> pts;
2153 wxXmlNode* vertex = aTree->GetChildren();
2154 std::vector<EVERTEX> vertices;
2162 if( vertex->GetName() == wxT(
"vertex" ) )
2163 vertices.emplace_back( vertex );
2165 vertex = vertex->GetNext();
2168 vertices.push_back( vertices[0] );
2170 for(
size_t i = 0; i < vertices.size() - 1; i++ )
2185 double radius = sqrt( pow( center.
x -
kicad_x(
v1.
x ), 2 )
2196 for(
double a = end_angle +
angle; fabs( a - end_angle ) > fabs(
delta ); a -=
delta )
2228 wxLogMessage(
wxString::Format(
_(
"Ignoring a polygon since Eagle layer '%s' (%d) "
2236 aFootprint->
Add( dwg );
2268 int outlineRadius = radius + ( width / 2 );
2274 VECTOR2I rotatedPoint( outlineRadius, 0 );
2282 int innerRadius = radius - ( width / 2 );
2288 VECTOR2I rotatedPoint( innerRadius, 0 );
2303 wxLogMessage(
wxString::Format(
_(
"Ignoring a circle since Eagle layer '%s' (%d) "
2315 radius = radius / 2;
2319 aFootprint->
Add( gr );
2322 switch( (
int) layer )
2350 pad->SetKeepTopBottom(
false );
2366 pad->SetPosition( padpos );
2370 pad->SetPos0( padpos );
2376 pad->SetDrillSize( sz );
2395 pad->SetKeepTopBottom(
false );
2401 pad->SetSize( padSize );
2402 pad->SetLayer( layer );
2408 pad->SetLayerSet( front );
2409 else if( layer ==
B_Cu )
2410 pad->SetLayerSet( back );
2412 int minPadSize = std::min( padSize.
x, padSize.
y );
2421 double roundRatio = (double) roundRadius / minPadSize / 2.0;
2425 roundRatio = std::fmax( *e.
roundness / 200.0, roundRatio );
2428 pad->SetRoundRectRadiusRatio( roundRatio );
2442 pad->SetLayerSet(
pad->GetLayerSet().set(
F_Mask,
false ) );
2443 else if( layer ==
B_Cu )
2444 pad->SetLayerSet(
pad->GetLayerSet().set(
B_Mask,
false ) );
2451 pad->SetLayerSet(
pad->GetLayerSet().set(
F_Paste,
false ) );
2452 else if( layer ==
B_Cu )
2453 pad->SetLayerSet(
pad->GetLayerSet().set(
B_Paste,
false ) );
2480 wxCHECK( footprint, );
2501 std::vector<ECLASS> eClasses;
2502 wxXmlNode* classNode = aClasses->GetChildren();
2508 ECLASS eClass( classNode );
2509 std::shared_ptr<NETCLASS> netclass;
2511 if( eClass.
name.CmpNoCase( wxT(
"default" ) ) == 0 )
2521 netclass->SetTrackWidth( INT_MAX );
2522 netclass->SetViaDiameter( INT_MAX );
2523 netclass->SetViaDrill( INT_MAX );
2525 eClasses.emplace_back( eClass );
2529 classNode = classNode->GetNext();
2534 for(
ECLASS& eClass : eClasses )
2536 for( std::pair<const wxString&, ECOORD> entry : eClass.clearanceMap )
2541 rule.Printf( wxT(
"(rule \"class %s:%s\"\n"
2542 " (condition \"A.NetClass == '%s' && B.NetClass == '%s'\")\n"
2543 " (constraint clearance (min %smm)))\n" ),
2567 wxXmlNode* net = aSignals->GetChildren();
2573 bool sawPad =
false;
2577 const wxString& netName =
escapeName( net->GetAttribute(
"name" ) );
2579 std::shared_ptr<NETCLASS> netclass;
2581 if( net->HasAttribute(
"class" ) )
2583 netclass =
m_classMap[ net->GetAttribute(
"class" ) ];
2587 std::make_unique<EDA_COMBINED_MATCHER>( netName,
CTX_NETCLASS ),
2599 wxXmlNode* netItem = net->GetChildren();
2604 const wxString& itemName = netItem->GetName();
2606 if( itemName == wxT(
"wire" ) )
2617 double end_angle = 0.0;
2618 double radius = 0.0;
2619 double delta_angle = 0.0;
2627 if( netclass && width < netclass->GetTrackWidth() )
2628 netclass->SetTrackWidth( width );
2638 end_angle = atan2(
kicad_y( w.
y2 ) - center.
y,
2641 radius = sqrt( pow( center.
x -
kicad_x( w.
x1 ), 2 ) +
2646 delta_angle =
angle / segs;
2649 while( fabs(
angle ) > fabs( delta_angle ) )
2651 wxASSERT( radius > 0.0 );
2666 angle -= delta_angle;
2686 else if( itemName == wxT(
"via" ) )
2698 && layer_front_most != layer_back_most )
2708 via->SetWidth( kidiam );
2715 kidiam =
KiROUND( drillz + 2 * annulus );
2716 via->SetWidth( kidiam );
2719 via->SetDrill( drillz );
2723 if( !v.
diam ||
via->GetWidth() <=
via->GetDrill() )
2727 (
double) (
via->GetWidth() / 2 -
via->GetDrill() ),
2729 via->SetWidth( drillz + 2 * annulus );
2735 if( netclass && kidiam < netclass->GetViaDiameter() )
2736 netclass->SetViaDiameter( kidiam );
2741 if( netclass && drillz < netclass->GetViaDrill() )
2742 netclass->SetViaDrill( drillz );
2747 if( layer_front_most ==
F_Cu && layer_back_most ==
B_Cu )
2765 via->SetLayerPair( layer_front_most, layer_back_most );
2766 via->SetPosition( pos );
2769 via->SetNetCode( netCode );
2775 else if( itemName == wxT(
"contactref" ) )
2780 const wxString& reference = netItem->GetAttribute(
"element" );
2781 const wxString&
pad = netItem->GetAttribute(
"pad" );
2791 else if( itemName == wxT(
"polygon" ) )
2798 zones.push_back( zone );
2800 if( !zone->GetIsRuleArea() )
2801 zone->SetNetCode( netCode );
2807 netItem = netItem->GetNext();
2810 if( zones.size() && !sawPad )
2814 for(
ZONE* zone : zones )
2825 net = net->GetNext();
2833 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector )
2835 std::map<wxString, PCB_LAYER_ID> layer_map;
2840 layer_map.emplace( layer.Name, layerId );
2849 std::vector<INPUT_LAYER_DESC> inputDescs;
2851 for (
const std::pair<const int, ELAYER>& layerPair :
m_eagleLayers )
2853 const ELAYER& eLayer = layerPair.second;
2864 inputDescs.push_back( layerDesc );
2885 bool aIsLibraryCache )
const
2894 if( copperLayer >= 0 )
2895 copperLayers[copperLayer] =
true;
2902 bool required =
false;
2903 LSET permittedLayers;
2905 permittedLayers.set();
2908 switch( aEagleLayer )
3006 if( aIsLibraryCache )
3014 return {
PCB_LAYER_ID( kiLayer ), permittedLayers, required };
3020 static const wxString
unknown(
"unknown" );
3028 static const int unknown = -1;
3046 int w = atoi( page_width.
c_str() );
3047 int h = atoi( page_height.
c_str() );
3049 int desired_x = ( w - bbbox.
GetWidth() ) / 2;
3050 int desired_y = ( h - bbbox.
GetHeight() ) / 2;
3061 if( aPath.IsEmpty() )
3062 return wxDateTime::Now();
3064 wxFileName fn( aPath );
3066 if( fn.IsFileReadable() )
3067 return fn.GetModificationTime();
3069 return wxDateTime( 0.0 );
3099 string filename = (
const char*) aLibPath.char_str( wxConvFile );
3102 wxFileName fn( filename );
3103 wxFFileInputStream stream( fn.GetFullPath() );
3104 wxXmlDocument xmlDocument;
3106 if( !stream.IsOk() || !xmlDocument.Load( stream ) )
3109 fn.GetFullPath() ) );
3112 doc = xmlDocument.GetRoot();
3114 wxXmlNode* drawing =
MapChildren( doc )[
"drawing"];
3121 wxXmlNode* layers = drawingChildren[
"layers"];
3127 wxXmlNode*
library = drawingChildren[
"library"];
3162 init( aProperties );
3170 errorMsg = ioe.
What();
3177 aFootprintNames.Add( it->first );
3179 if( !errorMsg.IsEmpty() && !aBestEfforts )
3185 const wxString& aFootprintName,
bool aKeepUUID,
3188 init( aProperties );
3190 FOOTPRINT_MAP::const_iterator it =
m_templates.find( aFootprintName );
3197 copy->SetParent(
nullptr );
3209 int minLayerCount = 2;
3211 std::map<wxString, PCB_LAYER_ID>::const_iterator it;
3218 && ( layerId + 2 ) > minLayerCount )
3219 minLayerCount = layerId + 2;
3225 if( ( minLayerCount % 2 ) != 0 )
3228 return minLayerCount;
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
#define DEFAULT_SILK_LINE_WIDTH
#define DEFAULT_EDGE_WIDTH
#define DEFAULT_LINE_WIDTH
#define DEFAULT_COURTYARD_WIDTH
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
int m_ViasMinAnnularWidth
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
void SetFileName(const wxString &aFileName)
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
void SetCopperLayerCount(int aCount)
const wxString & GetFileName() const
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
coord_type GetHeight() const
coord_type GetWidth() const
void cacheLib(const wxString &aLibraryPath)
This PLUGIN only caches one footprint library, this determines which one.
void FootprintLibOptions(STRING_UTF8_MAP *aProperties) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
int m_hole_count
generates unique footprint names from eagle "hole"s.
FOOTPRINT * makeFootprint(wxXmlNode *aPackage, const wxString &aPkgName)
Create a FOOTPRINT from an Eagle package.
XPATH * m_xpath
keeps track of what we are working on within XML document during a Load().
void loadPlain(wxXmlNode *aPlain)
void packageCircle(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void orientFPText(FOOTPRINT *aFootprint, const EELEMENT &e, FP_TEXT *aFPText, const EATTR *aAttr)
PCB_LAYER_ID kicad_layer(int aLayer) const
Convert an Eagle layer to a KiCad layer.
void packageSMD(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
Handles common pad properties.
static wxDateTime getModificationTime(const wxString &aPath)
get a file's or dir's modification time.
unsigned m_totalCount
for progress reporting
ERULES * m_rules
Eagle design rules.
FOOTPRINT_MAP m_templates
is part of a FOOTPRINT factory that operates using copy construction.
void packagePolygon(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void setKeepoutSettingsToZone(ZONE *aZone, int aLayer) const
int m_min_annulus
smallest via annulus we find on Load(), in BIU.
void loadAllSections(wxXmlNode *aDocument)
void orientFootprintAndText(FOOTPRINT *aFootprint, const EELEMENT &e, const EATTR *aNameAttr, const EATTR *aValueAttr)
std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
std::vector< ELAYER > ELAYERS
std::tuple< PCB_LAYER_ID, LSET, bool > defaultKicadLayer(int aEagleLayer, bool aIsLibraryCache=false) const
Get the default KiCad layer corresponding to an Eagle layer of the board, a set of sensible layer map...
void mapEagleLayersToKicad(bool aIsLibraryCache=false)
Generate mapping between Eagle and KiCad layers.
void loadLibrary(wxXmlNode *aLib, const wxString *aLibName)
Load the Eagle "library" XML element, which can occur either under a "libraries" element (if a *....
int kicad_x(const ECOORD &x) const
NET_MAP m_pads_to_nets
net list
void loadLibraries(wxXmlNode *aLibs)
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
void init(const STRING_UTF8_MAP *aProperties)
initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
const wxString & eagle_layer_name(int aLayer) const
Get Eagle layer name by its number.
void packageText(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
int m_min_trace
smallest trace we find on Load(), in BIU.
int kicad_y(const ECOORD &y) const
Convert an Eagle distance to a KiCad distance.
void packageHole(FOOTPRINT *aFootprint, wxXmlNode *aTree, bool aCenter) const
int m_cu_map[17]
map eagle to KiCad, cu layers only.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
void loadLayerDefs(wxXmlNode *aLayers)
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
int m_min_via
smallest via we find on Load(), in BIU.
unsigned m_lastProgressCount
void centerBoard()
move the BOARD into the center of the page
void packagePad(FOOTPRINT *aFootprint, wxXmlNode *aTree)
ZONE * loadPolygon(wxXmlNode *aPolyNode)
Load a copper or keepout polygon and adds it to the board.
void transferPad(const EPAD_COMMON &aEaglePad, PAD *aPad) const
Deletes the footprint templates list.
void loadDesignRules(wxXmlNode *aDesignRules)
std::map< wxString, PCB_LAYER_ID > m_layer_map
Map of Eagle layers to KiCad layers.
VECTOR2I kicad_fontsize(const ECOORD &d, int aTextThickness) const
create a font size (fontz) from an eagle font size scalar and KiCad font thickness
void loadSignals(wxXmlNode *aSignals)
const STRING_UTF8_MAP * m_props
passed via Save() or Load(), no ownership, may be NULL.
void packageWire(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
int getMinimumCopperLayerCount() const
Determines the minimum copper layer stackup count that includes all mapped layers.
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
std::map< int, ELAYER > m_eagleLayers
Eagle layer data stored by layer number.
ELAYERS::const_iterator EITER
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
std::map< wxString, int > m_eagleLayersIds
Eagle layer ids stored by layer name.
std::map< wxString, std::shared_ptr< NETCLASS > > m_classMap
void packageRectangle(FOOTPRINT *aFootprint, wxXmlNode *aTree) const
void loadClasses(wxXmlNode *aClasses)
int eagle_layer_id(const wxString &aLayerName) const
Get Eagle layer number by its name.
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
BOARD * m_board
which BOARD is being worked on, no ownership here
void loadElements(wxXmlNode *aElements)
int m_min_hole
smallest diameter hole we find on Load(), in BIU.
void SetCenter(const VECTOR2I &aCenter)
SHAPE_POLY_SET & GetPolyShape()
void SetFilled(bool aFlag)
void SetStart(const VECTOR2I &aStart)
void SetShape(SHAPE_T aShape)
void SetEnd(const VECTOR2I &aEnd)
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
const EDA_ANGLE & GetTextAngle() const
void SetTextPos(const VECTOR2I &aPoint)
void SetMirrored(bool isMirrored)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
void SetEnd0(const VECTOR2I &aPoint)
void SetStart0(const VECTOR2I &aPoint)
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetArcAngleAndEnd0(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void SetCenter0(const VECTOR2I &aPt)
void SetPos0(const VECTOR2I &aPos)
A specialization of ZONE for use in footprints.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
virtual void RegisterLayerMappingCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
const UTF8 & GetLibItemName() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
A collection of nets and the parameters used to route or test these nets.
int GetViaDiameter() const
int GetTrackWidth() const
Handle the data for a net.
void SetNetClass(const std::shared_ptr< NETCLASS > &aNetClass)
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
T & Get()
Return a reference to the value of the attribute assuming it is available.
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
void SetZoneConnection(ZONE_CONNECTION aType)
FOOTPRINT * GetParent() const
void SetPosition(const VECTOR2I &aPos) override
void SetPos0(const VECTOR2I &aPos)
void SetLocalSolderMaskMargin(int aMargin)
const VECTOR2I & GetSize() const
void SetUnits(EDA_UNITS aUnits)
void SetLineThickness(int aWidth)
virtual void SetEnd(const VECTOR2I &aPoint)
void SetPrecision(DIM_PRECISION aPrecision)
virtual void SetStart(const VECTOR2I &aPoint)
void SetOverrideText(const wxString &aValue)
For better understanding of the points that make a dimension:
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
A leader is a dimension-like object pointing to a specific point.
A radial dimension indicates either the radius or diameter of an arc or circle.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetStroke(const STROKE_PARAMS &aStroke) override
void SetWidth(int aWidth)
void SetEnd(const VECTOR2I &aEnd)
void SetPosition(const VECTOR2I &aPos) override
virtual void FootprintLibOptions(STRING_UTF8_MAP *aListToAppendTo) const
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
Container for project specific data.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
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 NewOutline()
Creates a new hole in a given outline.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
A name/value tuple with unique names and optional values.
bool Value(const char *aName, UTF8 *aFetchedValue=nullptr) const
Fetch a property by aName and returns true if that property was found, else false.
Simple container to manage line stroke parameters.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
const char * c_str() const
Keep track of what we are working on within a PTREE.
void Value(const char *aValue)
modify the last path node's value
void push(const char *aPathSegment, const char *aAttribute="")
wxString Contents()
return the contents of the XPATH as a single string
Handle a list of polygons defining a copper zone.
void SetHatchThickness(int aThickness)
void SetDoNotAllowPads(bool aEnable)
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
void SetMinThickness(int aMinThickness)
void SetHatchOrientation(const EDA_ANGLE &aStep)
void SetDoNotAllowCopperPour(bool aEnable)
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
void NewHole()
Create a new hole on the zone; i.e., a new contour on the zone's outline.
void SetIsRuleArea(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
void SetFillMode(ZONE_FILL_MODE aFillMode)
void SetDoNotAllowVias(bool aEnable)
VECTOR2I GetPosition() const override
void SetLocalClearance(int aClearance)
void SetThermalReliefGap(int aThermalReliefGap)
void SetLayerSet(LSET aLayerSet) override
void SetDoNotAllowFootprints(bool aEnable)
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
void SetAssignedPriority(unsigned aPriority)
void SetPadConnection(ZONE_CONNECTION aPadConnection)
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void SetHatchGap(int aStep)
static int GetDefaultHatchPitch()
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
wxString escapeName(const wxString &aNetName)
Interprets special characters in Eagle text and converts them to KiCAD notation.
wxString interpretText(const wxString &aText)
Translates Eagle special text reference to a KiCad variable reference.
VECTOR2I ConvertArcCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
OPTIONAL_XML_ATTRIBUTE< wxString > opt_wxString
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
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.
#define DIMENSION_PRECISION
static int parseEagle(const wxString &aDistance)
Parse an eagle distance which is either mm, or mils if there is "mil" suffix.
static T eagleClamp(T aMin, T aValue, T aMax)
std::vector< ZONE * > ZONES
NET_MAP::const_iterator NET_MAP_CITER
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & FULL_CIRCLE
static constexpr EDA_ANGLE & ANGLE_0
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
#define THROW_IO_ERROR(msg)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ NPTH
like PAD_PTH, but not plated
@ SMD
Smd pad, appears on the solder paste layer (default)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
Parse an Eagle "attribute" XML element.
long long int value
Unit used for the value field.
constexpr int mmToIU(double mm) const
opt_wxString dimensionType
Structure holding common properties for through-hole and SMD pads.
Eagle polygon, without vertices which are parsed as needed.
static const int max_priority
Eagle XML rectangle in binary.
subset of eagle.drawing.board.designrules in the XML document
int psBottom
Shape of the bottom pads.
double mvStopFrame
solderpaste mask, expressed as percentage of the smaller pad/via dimension
double srRoundness
corner rounding ratio for SMD pads (percentage)
double rlMinViaOuter
minimum copper annulus on via
int mlMaxCreamFrame
solder paste mask, maximum size (Eagle mils, here nanometers)
int mlMinCreamFrame
solder paste mask, minimum size (Eagle mils, here nanometers)
int psTop
Shape of the top pads.
double rlMaxViaOuter
maximum copper annulus on via
void parse(wxXmlNode *aRules, std::function< void()> aCheckpoint)
percent over 100%.
double mdWireWire
wire to wire spacing I presume.
double rvPadTop
top pad size as percent of drill size
double rvViaOuter
copper annulus is this percent of via hole
double rlMinPadTop
minimum copper annulus on through hole pads
int psElongationOffset
the offset of the hole within the "long" pad.
int mlMinStopFrame
solder mask, minimum size (Eagle mils, here nanometers)
int srMinRoundness
corner rounding radius, maximum size (Eagle mils, here nanometers)
int mlMaxStopFrame
solder mask, maximum size (Eagle mils, here nanometers)
double rlMaxPadTop
maximum copper annulus on through hole pads
int psFirst
Shape of the first pads.
int layer_back_most
< extent
opt_double curve
range is -359.9..359.9
Implement a simple wrapper around runtime_error to isolate the errors thrown by the Eagle XML parser.
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
double DEG2RAD(double deg)
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
@ THERMAL
Use thermal relief for pads.
@ FULL
pads are covered by copper
#define ZONE_THICKNESS_MIN_VALUE_MM