Fix EasyEDA Pro import for POLYGON-shaped pads

EasyEDA Pro uses both "POLY" and "POLYGON" shape types for custom pad
shapes. Previously only "POLY" was handled, causing POLYGON-shaped pads
to be imported incorrectly.

This adds support for the POLYGON shape type by treating it identically
to POLY, converting it to a KiCad custom pad shape with polygon
primitives.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20348
This commit is contained in:
Seth Hillbrand
2026-01-30 09:26:23 -08:00
parent 7c557026e5
commit a0a8993553
4 changed files with 295 additions and 1 deletions
@@ -711,7 +711,7 @@ std::unique_ptr<PAD> PCB_IO_EASYEDAPRO_PARSER::createPAD( FOOTPRINT*
pad->SetSize( PADSTACK::ALL_LAYERS, ScaleSize( size ) );
pad->SetShape( PADSTACK::ALL_LAYERS, PAD_SHAPE::OVAL );
}
else if( padSh == wxS( "POLY" ) )
else if( padSh == wxS( "POLY" ) || padSh == wxS( "POLYGON" ) )
{
pad->SetShape( PADSTACK::ALL_LAYERS, PAD_SHAPE::CUSTOM );
pad->SetAnchorPadShape( PADSTACK::ALL_LAYERS, PAD_SHAPE::CIRCLE );
@@ -0,0 +1,203 @@
["DOCTYPE","FOOTPRINT","1.8"]
["HEAD",{"editorVersion":"2.2.36.7","importFlag":0}]
["CANVAS",0,0,"mm",10,10,0.03937,0.03937,1,1,0,0,5]
["LAYER",1,"TOP","Top Layer",3,"#ff0000",1,"#7f0000",1]
["LAYER",2,"BOTTOM","Bottom Layer",3,"#0000ff",1,"#00007f",1]
["LAYER",3,"TOP_SILK","Top Silkscreen Layer",3,"#ffcc00",1,"#7f6600",1]
["LAYER",4,"BOT_SILK","Bottom Silkscreen Layer",3,"#66cc33",1,"#336619",1]
["LAYER",5,"TOP_SOLDER_MASK","Top Solder Mask Layer",3,"#800080",1,"#400040",1]
["LAYER",6,"BOT_SOLDER_MASK","Bottom Solder Mask Layer",3,"#aa00ff",1,"#55007f",1]
["LAYER",7,"TOP_PASTE_MASK","Top Paste Mask Layer",3,"#808080",1,"#404040",1]
["LAYER",8,"BOT_PASTE_MASK","Bottom Paste Mask Layer",3,"#800000",1,"#400000",1]
["LAYER",9,"TOP_ASSEMBLY","Top Assembly Layer",3,"#33cc99",1,"#19664c",1]
["LAYER",10,"BOT_ASSEMBLY","Bottom Assembly Layer",3,"#5555ff",1,"#2a2a7f",1]
["LAYER",11,"OUTLINE","Board Outline Layer",3,"#ff00ff",1,"#7f007f",1]
["LAYER",12,"MULTI","Multi-Layer",3,"#c0c0c0",1,"#606060",1]
["LAYER",13,"DOCUMENT","Document Layer",3,"#ffffff",1,"#7f7f7f",1]
["LAYER",14,"MECHANICAL","Mechanical Layer",3,"#f022f0",1,"#781178",1]
["LAYER",15,"SIGNAL","Inner1",0,"#999966",1,"#4c4c33",1]
["LAYER",16,"SIGNAL","Inner2",0,"#008000",1,"#004000",1]
["LAYER",17,"SIGNAL","Inner3",0,"#00ff00",1,"#007f00",1]
["LAYER",18,"SIGNAL","Inner4",0,"#bc8e00",1,"#5e4700",1]
["LAYER",19,"SIGNAL","Inner5",0,"#70dbfa",1,"#386d7d",1]
["LAYER",20,"SIGNAL","Inner6",0,"#00cc66",1,"#006633",1]
["LAYER",21,"SIGNAL","Inner7",0,"#9966ff",1,"#4c337f",1]
["LAYER",22,"SIGNAL","Inner8",0,"#800080",1,"#400040",1]
["LAYER",23,"SIGNAL","Inner9",0,"#008080",1,"#004040",1]
["LAYER",24,"SIGNAL","Inner10",0,"#15935f",1,"#a.492f",1]
["LAYER",25,"SIGNAL","Inner11",0,"#000080",1,"#000040",1]
["LAYER",26,"SIGNAL","Inner12",0,"#00b400",1,"#005a00",1]
["LAYER",27,"SIGNAL","Inner13",0,"#2e4756",1,"#17232b",1]
["LAYER",28,"SIGNAL","Inner14",0,"#99842f",1,"#4c4217",1]
["LAYER",29,"SIGNAL","Inner15",0,"#ffffaa",1,"#7f7f55",1]
["LAYER",30,"SIGNAL","Inner16",0,"#99842f",1,"#4c4217",1]
["LAYER",31,"SIGNAL","Inner17",0,"#2e4756",1,"#17232b",1]
["LAYER",32,"SIGNAL","Inner18",0,"#3535ff",1,"#1a1a7f",1]
["LAYER",33,"SIGNAL","Inner19",0,"#8000bc",1,"#40005e",1]
["LAYER",34,"SIGNAL","Inner20",0,"#43ae5f",1,"#21572f",1]
["LAYER",35,"SIGNAL","Inner21",0,"#c3ecce",1,"#617667",1]
["LAYER",36,"SIGNAL","Inner22",0,"#728978",1,"#39443c",1]
["LAYER",37,"SIGNAL","Inner23",0,"#39503f",1,"#1c281f",1]
["LAYER",38,"SIGNAL","Inner24",0,"#0c715d",1,"#06382e",1]
["LAYER",39,"SIGNAL","Inner25",0,"#5a8a80",1,"#2d4540",1]
["LAYER",40,"SIGNAL","Inner26",0,"#2b937e",1,"#15493f",1]
["LAYER",41,"SIGNAL","Inner27",0,"#23999d",1,"#114c4e",1]
["LAYER",42,"SIGNAL","Inner28",0,"#45b4e3",1,"#225a71",1]
["LAYER",43,"SIGNAL","Inner29",0,"#215da1",1,"#102e50",1]
["LAYER",44,"SIGNAL","Inner30",0,"#4564d7",1,"#22326b",1]
["LAYER",45,"SIGNAL","Inner31",0,"#6969e9",1,"#343474",1]
["LAYER",46,"SIGNAL","Inner32",0,"#9069e9",1,"#483474",1]
["LAYER",47,"HOLE","Hole Layer",3,"#222222",1,"#111111",1]
["LAYER",48,"COMPONENT_SHAPE","Component Shape Layer",3,"#00cccc",1,"#006666",1]
["LAYER",49,"COMPONENT_MARKING","Component Marking Layer",3,"#66ffcc",1,"#337f66",1]
["LAYER",50,"PIN_SOLDERING","Pin Soldering Layer",3,"#cc9999",1,"#664c4c",1]
["LAYER",51,"PIN_FLOATING","Pin Floating Layer",3,"#ff99ff",1,"#7f4c7f",1]
["LAYER",52,"COMPONENT_MODEL","Component Model Layer",0,"#ffffff",1,"#7f7f7f",1]
["LAYER",53,"3D_SHELL_OUTLINE","3D Shell Outline Layer",3,"#66ff99",1,"#337f4c",1]
["LAYER",54,"3D_SHELL_TOP","3D Shell Top Layer",3,"#ffccff",1,"#7f667f",1]
["LAYER",55,"3D_SHELL_BOTTOM","3D Shell Bottom Layer",3,"#0066cc",1,"#003366",1]
["LAYER",56,"DRILL_DRAWING","Drill Drawing Layer",3,"#008080",1,"#004040",1]
["LAYER",57,"OTHER","Ratline Layer",7,"#6464ff",1,"#32327f",1]
["LAYER",58,"TOP_STIFFENER","Top Stiffener Layer",0,"#eee666",1,"#777333",1]
["LAYER",59,"BOTTOM_STIFFENER","Bottom Stiffener Layer",0,"#ccff00",1,"#667f00",1]
["LAYER",71,"CUSTOM","Custom1",0,"#9069e9",1,"#483474",1]
["LAYER",72,"CUSTOM","Custom2",0,"#6969e9",1,"#343474",1]
["LAYER",73,"CUSTOM","Custom3",0,"#4564d7",1,"#22326b",1]
["LAYER",74,"CUSTOM","Custom4",0,"#215da1",1,"#102e50",1]
["LAYER",75,"CUSTOM","Custom5",0,"#45b4e3",1,"#225a71",1]
["LAYER",76,"CUSTOM","Custom6",0,"#23999d",1,"#114c4e",1]
["LAYER",77,"CUSTOM","Custom7",0,"#2b937e",1,"#15493f",1]
["LAYER",78,"CUSTOM","Custom8",0,"#5a8a80",1,"#2d4540",1]
["LAYER",79,"CUSTOM","Custom9",0,"#0c715d",1,"#06382e",1]
["LAYER",80,"CUSTOM","Custom10",0,"#39503f",1,"#1c281f",1]
["LAYER",81,"CUSTOM","Custom11",0,"#728978",1,"#39443c",1]
["LAYER",82,"CUSTOM","Custom12",0,"#c3ecce",1,"#617667",1]
["LAYER",83,"CUSTOM","Custom13",0,"#43ae5f",1,"#21572f",1]
["LAYER",84,"CUSTOM","Custom14",0,"#8000bc",1,"#40005e",1]
["LAYER",85,"CUSTOM","Custom15",0,"#3535ff",1,"#1a1a7f",1]
["LAYER",86,"CUSTOM","Custom16",0,"#2e4756",1,"#17232b",1]
["LAYER",87,"CUSTOM","Custom17",0,"#99842f",1,"#4c4217",1]
["LAYER",88,"CUSTOM","Custom18",0,"#ffffaa",1,"#7f7f55",1]
["LAYER",89,"CUSTOM","Custom19",0,"#99842f",1,"#4c4217",1]
["LAYER",90,"CUSTOM","Custom20",0,"#2e4756",1,"#17232b",1]
["LAYER",91,"CUSTOM","Custom21",0,"#00b400",1,"#005a00",1]
["LAYER",92,"CUSTOM","Custom22",0,"#000080",1,"#000040",1]
["LAYER",93,"CUSTOM","Custom23",0,"#15935f",1,"#a.492f",1]
["LAYER",94,"CUSTOM","Custom24",0,"#008080",1,"#004040",1]
["LAYER",95,"CUSTOM","Custom25",0,"#800080",1,"#400040",1]
["LAYER",96,"CUSTOM","Custom26",0,"#9966ff",1,"#4c337f",1]
["LAYER",97,"CUSTOM","Custom27",0,"#00cc66",1,"#006633",1]
["LAYER",98,"CUSTOM","Custom28",0,"#70dbfa",1,"#386d7d",1]
["LAYER",99,"CUSTOM","Custom29",0,"#bc8e00",1,"#5e4700",1]
["LAYER",100,"CUSTOM","Custom30",0,"#00ff00",1,"#007f00",1]
["LAYER",361,"SUBSTRATE","Dielectric1",0,"#000000",1,"#000000",1]
["LAYER_PHYS",3,null,0,null,null,1]
["LAYER_PHYS",7,null,0,null,null,1]
["LAYER_PHYS",5,"",0.394,3.3,0.02,1]
["LAYER_PHYS",1,null,1.379,null,null,1]
["LAYER_PHYS",361,"FR4",59.449,4.5,0,1]
["LAYER_PHYS",2,null,1.378,null,null,1]
["LAYER_PHYS",6,"",0.394,3.3,0.02,1]
["LAYER_PHYS",8,null,0,null,null,1]
["LAYER_PHYS",4,null,0,null,null,1]
["ACTIVE_LAYER",1]
["NET","",null,null,1,null,0,null]
["RULE_TEMPLATE",""]
["RULE","1","safeClearance",1,["mm",[[6],[6,6],[6,6,6],[6,6,6,6],[6,6,6,6,6],[6,6,6,6,6,6],[6,6,6,6,6,6,6],[6,6,6,6,6,6,6,6],[11.8,11.8,11.8,11.8,11.8,11.8,11.8,11.8],[6.9,6.9,6.9,6.9,6.9,6.9,6.9,6.9,6.9]]]]
["RULE","2","otherClearance",1,["mm",0,0,11.811]]
["RULE","3","trackWidth",1,["mm",5,10,100]]
["RULE","11","netLength",1,["mm",0,0]]
["RULE","10","differentialPair",1,["mm",5,10,100,6,6,50,10]]
["RULE","4","blindVia",1,[]]
["RULE","5","viaSize",1,["mm",9.8425,12.0079,196.8504,5.9055,6.0039,118.1102]]
["RULE","6","innerPlane",1,["mm",10,10,0,10,10,90,0,10,10,90]]
["RULE","7","copperRegion",1,["mm",10,10,0,10,10,90,0,0,10,10,90]]
["RULE","8","pasteMaskExpansion",1,["mm",0,0,-1000,-1000]]
["RULE","9","solderMaskExpansion",1,["mm",2,2,-1000,-1000,2,2]]
["RULE","12","Common",1,[0,1,0,1,0,[1,2,12],[]]]
["RULE_SELECTOR",["NET",""],4,{}]
["PRIMITIVE","ALL",1,1]
["PRIMITIVE","COMPONENT",1,1]
["PRIMITIVE","PROPERTY",1,1]
["PRIMITIVE","COMPONENTSILK",1,1]
["PRIMITIVE","TRACK",1,1]
["PRIMITIVE","VIA",1,1]
["PRIMITIVE","TESTPOINT",1,1]
["PRIMITIVE","PAD",1,1]
["PRIMITIVE","PADSPAIR",1,0]
["PRIMITIVE","NETWORK",1,0]
["PRIMITIVE","SUTUREHOLE",1,1]
["PRIMITIVE","TEARDROP",1,1]
["PRIMITIVE","RATLINE",0,0]
["PRIMITIVE","GROUP",1,0]
["PRIMITIVE","TEXT",1,1]
["PRIMITIVE","IMAGE",1,1]
["PRIMITIVE","PICTURE",1,1]
["PRIMITIVE","DIMENSION",1,1]
["PRIMITIVE","BOARDOUTLINE",1,1]
["PRIMITIVE","SLOTREGION",1,1]
["PRIMITIVE","FILLREGIEN",1,1]
["PRIMITIVE","COPPEROUTLINE",1,1]
["PRIMITIVE","COPPERFILLED",1,1]
["PRIMITIVE","PROHIBITEDREGION",1,1]
["PRIMITIVE","CONSTRAINT",1,1]
["PRIMITIVE","PARTITION",0,0]
["PRIMITIVE","LINE",1,1]
["PRIMITIVE","LOCKED",1,1]
["PRIMITIVE","UNLOCKED",1,1]
["PRIMITIVE","SHELL",1,1]
["PRIMITIVE","BOSS",1,1]
["PRIMITIVE","CREASE",1,1]
["PRIMITIVE","TOPSHELLCUT",1,1]
["PRIMITIVE","SIDESHELLCUT",1,1]
["PRIMITIVE","TOPBOTTOMENTITY",1,1]
["PRIMITIVE","SIDEENTITY",1,1]
["PRIMITIVE","FPC_STIFFENER",1,1]
["SILK_OPTS",3,"#000000","#FFFFFF"]
["SILK_OPTS",4,"#000000","#FFFFFF"]
["PREFERENCE",1,10,1,12.0078,24.0158,1,2,"L45",1,0,0,1,null,0,3,"OPTIMIZA_OPEN",0,"OPTIMIZA_WEAK",true,true]
["PANELIZE",0,1,1,0,0,1]
["PANELIZE_STAMP",1,0,1,21.6535,8,33.4646]
["PANELIZE_SIDE",1,1,236.2205,78.7402,39.3701,19.685]
["PANELIZE_STAMP",0,0,1,21.6535,8,33.4646]
["PANELIZE_SIDE",0,0,236.2205,78.7402,39.3701,19.685]
["PAD","e20",0,"",1,"1",-38.39,-62.99,0,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e21",0,"",1,"2",-12.78,-62.99,0,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e22",0,"",1,"3",12.8,-62.99,0,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e23",0,"",1,"4",38.39,-62.99,0,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e24",0,"",1,"8",-38.39,62.99,180,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e25",0,"",1,"7",-12.79,62.99,180,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e26",0,"",1,"6",12.8,62.99,180,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e27",0,"",1,"5",38.39,62.99,180,null,["RECT",15.748,31.496,0],[],0,0,null,1,0,2,2,-3937,-3937,0,null,null,null,null,[]]
["PAD","e28",0,"",1,"9",-36.42,13.78,0,null,["POLYGON",[-64.96,-5.906,"L",-64.96,5.905,-51.181,5.905,-51.181,53.149,-7.874,53.149,-7.874,-25.591,-51.181,-25.591,-51.181,-5.906,-64.96,-5.906]],[],0,0,null,1,0,1.969,1.969,-3937,-3937,0,null,null,null,null,[]]
["PAD","e29",0,"",1,"10",36.42,13.78,0,null,["POLYGON",[64.961,-5.906,"L",51.181,-5.906,51.181,-25.591,7.874,-25.591,7.874,53.148,51.181,53.148,51.181,5.904,64.961,5.904,64.961,-5.906]],[],0,0,null,1,0,1.969,1.969,-3937,-3937,0,null,null,null,null,[]]
["POLY","e2",0,"",13,8.661,["CIRCLE",-53.54,-71.65,4.33],0]
["POLY","e38",0,"",3,7.874,["CIRCLE",-38.58,-90.95,3.94],0]
["FILL","e1",0,"",49,0.2,0,[["CIRCLE",-62.2,-63.98,2.361]],0]
["POLY","e13",0,"",48,2,[-62.205,-59.055,"L",-62.205,59.055,62.204,59.055,62.204,-59.055,-62.205,-59.055],0]
["POLY","e30",0,"",3,5.984,[-62.66,-12.998,"L",-62.66,-61.02],0]
["POLY","e31",0,"",3,5.984,[-62.66,61.02,"L",-62.66,12.997],0]
["POLY","e32",0,"",3,5.984,[61.41,-12.998,"L",61.41,-61.03],0]
["POLY","e33",0,"",3,5.984,[61.41,61.02,"L",61.41,12.996],0]
["POLY","e34",0,"",3,5.984,[53.637,-61.02,"L",61.41,-61.03],0]
["POLY","e35",0,"",3,5.984,[-62.66,61.02,"L",-56.465,61.02],0]
["POLY","e36",0,"",3,5.984,[56.105,61.02,"L",61.41,61.02],0]
["POLY","e37",0,"",3,5.984,[-62.66,-61.02,"L",-54.947,-61.02],0]
["FILL","e3",0,"",50,0.2,0,[[32.485,-48.228,"L",44.296,-48.228,44.296,-63.976,32.485,-63.976,32.485,-48.228]],0]
["FILL","e4",0,"",50,0.2,0,[[6.895,-48.228,"L",18.706,-48.228,18.706,-63.976,6.895,-63.976,6.895,-48.228]],0]
["FILL","e5",0,"",50,0.2,0,[[-18.685,-48.228,"L",-6.874,-48.228,-6.874,-63.976,-18.685,-63.976,-18.685,-48.228]],0]
["FILL","e6",0,"",50,0.2,0,[[-44.295,-48.228,"L",-32.484,-48.228,-32.484,-63.976,-44.295,-63.976,-44.295,-48.228]],0]
["FILL","e7",0,"",50,0.2,0,[[62.107,-4.7244,"L",62.107,4.7244,49.705,4.7244,49.705,49.211,10.729,49.211,10.729,-21.654,49.705,-21.654,49.705,-4.7244,62.107,-4.7244]],0]
["FILL","e8",0,"",50,0.2,0,[[44.289,48.23,"L",32.478,48.23,32.478,63.976,44.289,63.976,44.289,48.23]],0]
["FILL","e9",0,"",50,0.2,0,[[18.679,48.23,"L",6.868,48.23,6.868,63.976,18.679,63.976,18.679,48.23]],0]
["FILL","e10",0,"",50,0.2,0,[[-6.901,48.23,"L",-18.712,48.23,-18.712,63.976,-6.901,63.976,-6.901,48.23]],0]
["FILL","e11",0,"",50,0.2,0,[[-32.491,48.23,"L",-44.302,48.23,-44.302,63.976,-32.491,63.976,-32.491,48.23]],0]
["FILL","e12",0,"",50,0.2,0,[[-62.108,-4.725,"L",-62.108,4.724,-49.707,4.724,-49.707,49.209,-10.73,49.209,-10.73,-21.654,-49.707,-21.654,-49.707,-4.725,-62.108,-4.725]],0]
["FILL","e14",0,"",7,0.2,0,[[46.256,53.148,"L",46.256,78.742,30.516,78.742,30.516,53.148,20.665,53.148,20.665,78.742,4.925,78.742,4.925,47.242,7.874,47.242,7.874,-25.591,51.181,-25.591,51.181,-5.906,64.961,-5.906,64.961,5.904,51.181,5.904,51.181,53.148,46.256,53.148]],0]
["FILL","e15",0,"",7,0.2,0,[[-46.256,78.742,"L",-46.256,53.149,-51.181,53.149,-51.181,5.905,-64.96,5.905,-64.96,-5.906,-51.181,-5.906,-51.181,-25.591,-7.874,-25.591,-7.874,47.242,-4.925,47.242,-4.925,78.742,-20.665,78.742,-20.665,53.149,-30.516,53.149,-30.516,78.742,-46.256,78.742]],0]
["FILL","e16",0,"",7,0.2,0,[[-46.264,-47.241,"L",-46.264,-78.741,-30.524,-78.741,-30.524,-47.241,-46.264,-47.241]],0]
["FILL","e17",0,"",7,0.2,0,[[30.524,-47.243,"L",30.524,-78.743,46.264,-78.743,46.264,-47.243,30.524,-47.243]],0]
["FILL","e18",0,"",7,0.2,0,[[20.675,-78.743,"L",20.675,-47.243,4.935,-47.243,4.935,-78.743,20.675,-78.743]],0]
["FILL","e19",0,"",7,0.2,0,[[-4.915,-78.743,"L",-4.915,-47.243,-20.655,-47.243,-20.655,-78.743,-4.915,-78.743]],0]
["ATTR","e39",0,"",3,null,null,"Footprint","PDFN-8_L3.2-W3.1-P0.65-LS3.4-BL-EP2",0,0,"default",67.5,6,0,0,3,0,0,0,0,0]
["ATTR","e40",0,"",3,null,null,"Designator","U?",0,0,"default",67.5,6,0,0,3,0,0,0,0,0]
+2
View File
@@ -103,6 +103,8 @@ set( QA_PCBNEW_SRCS
pcb_io/kicad_sexpr/test_kicad_sexpr.cpp
pcb_io/easyedapro/test_easyedapro_import.cpp
pcb_io/fabmaster/test_fabmaster_import.cpp
pcb_io/ipc2581/test_ipc2581_export.cpp
@@ -0,0 +1,89 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file test_easyedapro_import.cpp
* Test suite for import of EasyEDA Pro footprints
*/
#include <pcbnew_utils/board_test_utils.h>
#include <pcbnew_utils/board_file_utils.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h>
#include <footprint.h>
#include <pad.h>
struct EASYEDAPRO_IMPORT_FIXTURE
{
EASYEDAPRO_IMPORT_FIXTURE() {}
PCB_IO_EASYEDAPRO plugin;
};
BOOST_FIXTURE_TEST_SUITE( EasyedaproImport, EASYEDAPRO_IMPORT_FIXTURE )
/**
* Test importing a footprint with POLYGON-shaped pads (issue #20348)
* EasyEDA Pro uses POLYGON shape type for complex custom pad shapes,
* which was previously not handled.
*/
BOOST_AUTO_TEST_CASE( PolygonPadImport )
{
std::string dataPath = KI_TEST::GetPcbnewTestDataDir()
+ "plugins/easyedapro/PDFN-8_L3.2-W3.1-P0.65-LS3.4-BL-EP2.efoo";
wxString fpName = wxS( "PDFN-8_L3.2-W3.1-P0.65-LS3.4-BL-EP2" );
FOOTPRINT* fp = plugin.FootprintLoad( dataPath, fpName, false, nullptr );
BOOST_REQUIRE( fp );
// The footprint should have 10 pads: 8 numbered pads plus 2 polygon-shaped pads (9 and 10)
BOOST_CHECK_EQUAL( fp->Pads().size(), 10 );
// Find the polygon pads (pads 9 and 10 in the test file)
PAD* pad9 = fp->FindPadByNumber( "9" );
PAD* pad10 = fp->FindPadByNumber( "10" );
BOOST_REQUIRE( pad9 );
BOOST_REQUIRE( pad10 );
// These pads should be custom shape (POLYGON in EasyEDA Pro becomes CUSTOM in KiCad)
BOOST_CHECK_EQUAL( static_cast<int>( pad9->GetShape( PADSTACK::ALL_LAYERS ) ),
static_cast<int>( PAD_SHAPE::CUSTOM ) );
BOOST_CHECK_EQUAL( static_cast<int>( pad10->GetShape( PADSTACK::ALL_LAYERS ) ),
static_cast<int>( PAD_SHAPE::CUSTOM ) );
// Check that primitives were added to the custom pads
BOOST_CHECK( !pad9->GetPrimitives( PADSTACK::ALL_LAYERS ).empty() );
BOOST_CHECK( !pad10->GetPrimitives( PADSTACK::ALL_LAYERS ).empty() );
delete fp;
}
BOOST_AUTO_TEST_SUITE_END()