25#include <boost/test/unit_test.hpp>
70 BOOST_CHECK( parser.
IsValid() );
76 BOOST_CHECK( header.description.find(
"DESIGN EXPORT FILE" ) != std::string::npos );
87 BOOST_CHECK( parser.
IsValid() );
204 BOOST_CHECK( parser.
IsValid() );
213 BOOST_REQUIRE_EQUAL( symbols.size(), 1 );
224 BOOST_REQUIRE_EQUAL( pinb->
attrs.size(), 4 );
231 BOOST_REQUIRE_EQUAL( pinb->
graphics.size(), 2 );
233 const auto& openLine = pinb->
graphics[0];
236 BOOST_REQUIRE_EQUAL( openLine.points.size(), 2 );
250 BOOST_CHECK( pinb->
font1.empty() );
251 BOOST_CHECK( pinb->
font2.empty() );
287 const auto& pin1 =
res->pins[0];
293 const auto& pin2 =
res->pins[1];
304 const auto& gate = ptIt->second.gates[0];
305 BOOST_REQUIRE_GE( gate.pins.size(), 2u );
347 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
363 auto ptIt = parser.
GetPartTypes().find(
"IC_QUAD_NAND" );
367 const auto& pins = ptIt->second.gates[0].pins;
368 BOOST_REQUIRE_GE( pins.size(), 14u );
397 const auto& rect =
res->graphics[0];
417 BOOST_CHECK( notFound ==
nullptr );
430 BOOST_CHECK( symbols.empty() );
513 bool foundRefDes =
false;
514 bool foundValue =
false;
518 if( attr.name ==
"Ref.Des." )
521 BOOST_CHECK( attr.visible );
524 else if( attr.name ==
"Value" )
527 BOOST_CHECK( attr.visible );
532 BOOST_CHECK( foundRefDes );
533 BOOST_CHECK( foundValue );
551 if( attr.name ==
"Value" )
553 BOOST_CHECK( !attr.visible );
601 BOOST_CHECK( notFound ==
nullptr );
614 BOOST_CHECK( parts.empty() );
684 const auto& wire1 = vcc->
wires[0];
692 const auto& wire2 = vcc->
wires[1];
743 BOOST_CHECK( notFound ==
nullptr );
756 BOOST_CHECK( signals.empty() );
865 if(
pin->GetNumber() ==
"1" )
894 BOOST_CHECK( !builder.
HasSymbol(
"RES_0805" ) );
898 BOOST_CHECK( builder.
HasSymbol(
"RES_0805" ) );
993 BOOST_CHECK( !notPower.has_value() );
996 BOOST_CHECK( !notPower2.has_value() );
1039 BOOST_CHECK( gnd->IsPower() );
1045 BOOST_CHECK( vcc->IsPower() );
1051 BOOST_CHECK( vee->IsPower() );
1056 BOOST_CHECK( gndd->IsPower() );
1061 BOOST_CHECK( earth->IsPower() );
1066 BOOST_CHECK( pwrBar->IsPower() );
1071 BOOST_CHECK( pwrTri->IsPower() );
1089 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"GND",
"G" ),
"GND" );
1090 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"AGND",
"G" ),
"GND" );
1091 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"CHGND",
"G" ),
"Chassis" );
1094 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+RAIL",
"P" ),
"PWR_BAR" );
1095 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-RAIL",
"P" ),
"GNDD" );
1098 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+ARROW",
"P" ),
"PWR_TRIANGLE" );
1099 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-ARROW",
"P" ),
"VEE" );
1102 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"+BUBBLE",
"P" ),
"VCC" );
1103 BOOST_CHECK_EQUAL( PADS_SCH_SYMBOL_BUILDER::GetPowerStyleFromVariant(
"-BUBBLE",
"P" ),
"VEE" );
1127 BOOST_CHECK( sheets.count( 1 ) > 0 );
1138 std::vector<PADS_SCH::PART_PLACEMENT> partsOnSheet1 = parser.
GetPartsOnSheet( 1 );
1152 std::vector<PADS_SCH::SCH_SIGNAL> signalsOnSheet1 = parser.
GetSignalsOnSheet( 1 );
1155 BOOST_CHECK( signalsOnSheet1.size() > 0 );
1163#include <sch_io/pads/pads_sch_schematic_builder.h>
1189 wire.
end.
x = 3000.0;
1190 wire.
end.
y = 2000.0;
1213 int expectedWires = 0;
1215 for(
const auto& signal : parser.
GetSignals() )
1216 expectedWires +=
static_cast<int>( signal.wires.size() );
1218 BOOST_CHECK( expectedWires > 0 );
1232 signal.
name =
"VCC";
1237 wire.
end.
x = 3000.0;
1238 wire.
end.
y = 2000.0;
1239 signal.
wires.push_back( wire );
1261 signal.
name =
"NET 1";
1317 wire.
end.
x = 3000.0;
1318 wire.
end.
y = 2000.0;
1349 LIB_ID libId( wxS(
"test" ), wxS(
"TEST" ) );
1380 footprintAttr.
name =
"PCB DECAL";
1381 footprintAttr.
value =
"CAP_0805";
1382 footprintAttr.
visible =
false;
1383 placement.
attributes.push_back( footprintAttr );
1391 LIB_ID libId( wxS(
"test" ), wxS(
"CAP" ) );
1418 valueAttr.
name =
"VALUE";
1419 valueAttr.
value =
"74HC00";
1425 refAttr.
name =
"REFDES";
1426 refAttr.
value =
"U1";
1436 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1466 BOOST_CHECK(
true );
1483 mfrAttr.
name =
"Manufacturer";
1484 mfrAttr.
value =
"Texas Instruments";
1490 mpnAttr.
name =
"MPN";
1491 mpnAttr.
value =
"SN74HC00N";
1501 LIB_ID libId( wxS(
"test" ), wxS(
"74HC00" ) );
1538 refAttr.
name =
"Ref.Des.";
1539 refAttr.
value =
"R1";
1543 valAttr.
name =
"Part Type";
1544 valAttr.
value =
"10K";
1549 customAttr.
name =
"Tolerance";
1550 customAttr.
value =
"5%";
1552 placement.
attributes.push_back( customAttr );
1560 LIB_ID libId( wxS(
"test" ), wxS(
"RES" ) );
1591 emptyAttr.
name =
"SerialNumber";
1592 emptyAttr.
value =
"";
1597 validAttr.
name =
"Revision";
1598 validAttr.
value =
"A";
1608 LIB_ID libId( wxS(
"test" ), wxS(
"IC" ) );
1624 BOOST_CHECK( snField ==
nullptr );
1635 params.
fields[
"Title"] =
"Test Design";
1636 params.
fields[
"DATE"] =
"2025-01-12";
1637 params.
fields[
"Revision"] =
"A";
1638 params.
fields[
"Company Name"] =
"Test Company";
1690 BOOST_CHECK( tb.
GetTitle().IsEmpty() );
1691 BOOST_CHECK( tb.
GetDate().IsEmpty() );
1700 params.
fields[
"Title"] =
"Test";
1707 BOOST_CHECK(
true );
1715#include <sch_sheet.h>
1734 BOOST_CHECK( size.
x > 0 );
1735 BOOST_CHECK( size.
y > 0 );
1751 BOOST_CHECK( pos.
x > 0 );
1752 BOOST_CHECK( pos.
y > 0 );
1780 BOOST_CHECK( pos1.
x > pos0.
x );
1781 BOOST_CHECK( pos2.
y > pos0.
y );
1803 BOOST_CHECK( sheet->
GetScreen() !=
nullptr );
1807 BOOST_CHECK( pos.
x >= 0 );
1808 BOOST_CHECK( pos.
y >= 0 );
1812 BOOST_CHECK( size.
x > 0 );
1813 BOOST_CHECK( size.
y > 0 );
1838 BOOST_CHECK( filename.Contains( wxT(
"my_design" ) ) );
1839 BOOST_CHECK( filename.Contains( wxT(
"sheet2" ) ) );
1840 BOOST_CHECK( filename.EndsWith( wxT(
".kicad_sch" ) ) );
1865 BOOST_CHECK(
name.Contains( wxT(
"3" ) ) );
1883 BOOST_CHECK( sheet ==
nullptr );
1944 BOOST_CHECK(
pin ==
nullptr );
1967 BOOST_CHECK( screen.
Items().
size() > 0 );
1974 std::set<int> singleSheet = { 1 };
1988 std::set<int> multiSheet = { 1, 2, 3 };
1998 std::set<int> singleSheet = { 1 };
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
size_t size() const
Return the number of items in the tree.
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
Parser for PADS Logic schematic design export files.
bool Parse(const std::string &aFileName)
const std::vector< SCH_SIGNAL > & GetSignals() const
const FILE_HEADER & GetHeader() const
std::vector< SCH_SIGNAL > GetSignalsOnSheet(int aSheetNumber) const
std::set< int > GetSheetNumbers() const
static bool CheckFileHeader(const std::string &aFileName)
const std::vector< SYMBOL_DEF > & GetSymbolDefs() const
const std::vector< PART_PLACEMENT > & GetPartPlacements() const
const std::map< std::string, PARTTYPE_DEF > & GetPartTypes() const
std::vector< PART_PLACEMENT > GetPartsOnSheet(int aSheetNumber) const
const SCH_SIGNAL * GetSignal(const std::string &aName) const
const SYMBOL_DEF * GetSymbolDef(const std::string &aName) const
const PARAMETERS & GetParameters() const
const PART_PLACEMENT * GetPartPlacement(const std::string &aReference) const
std::string GetVersion() const
int GetSheetCount() const
Builder class to create KiCad schematic elements from parsed PADS data.
SCH_LINE * CreateWire(const WIRE_SEGMENT &aWire)
Create a single wire segment.
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet, const std::string &aSignalName, int aPinIndex)
Create hierarchical sheet pin on a sheet symbol.
void ApplyPartAttributes(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Apply part attributes to a symbol instance.
void CreateTitleBlock(SCH_SCREEN *aScreen)
Create title block from parsed PADS parameters.
VECTOR2I CalculateSheetPosition(int aSheetIndex, int aTotalSheets) const
Calculate position for a sheet symbol on the parent sheet.
int CreateCustomFields(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Create custom fields from non-standard PADS attributes.
SCH_LINE * CreateBusWire(const WIRE_SEGMENT &aWire)
Create a single bus wire segment.
SCH_HIERLABEL * CreateHierLabel(const std::string &aSignalName, const VECTOR2I &aPosition, SCH_SCREEN *aScreen)
Create hierarchical label in a sub-schematic.
SCH_GLOBALLABEL * CreateNetLabel(const SCH_SIGNAL &aSignal, const VECTOR2I &aPosition, SPIN_STYLE aOrientation=SPIN_STYLE::RIGHT)
Create a global net label for a signal.
static bool IsGlobalSignal(const std::string &aSignalName, const std::set< int > &aSheetNumbers)
Check if a signal name represents a global signal.
SCH_SHEET * CreateHierarchicalSheet(int aSheetNumber, int aTotalSheets, SCH_SHEET *aParentSheet, const wxString &aBaseFilename)
Create hierarchical sheet for a sub-schematic page.
VECTOR2I GetDefaultSheetSize() const
Get standard sheet size for a given sheet number.
static bool IsBusSignal(const std::string &aName)
Check if a signal name indicates a bus.
Builder class to convert PADS symbol definitions to KiCad LIB_SYMBOL objects.
bool HasSymbol(const std::string &aName) const
Check if a symbol with the given name already exists.
static std::optional< LIB_ID > GetKiCadPowerSymbolId(const std::string &aPadsName)
Get KiCad power library symbol ID for a PADS power symbol.
LIB_SYMBOL * BuildKiCadPowerSymbol(const std::string &aKiCadName)
Build a power symbol using hard-coded KiCad-standard graphics.
static bool IsPowerSymbol(const std::string &aName)
Check if a symbol name indicates a power symbol.
LIB_SYMBOL * GetOrCreateSymbol(const SYMBOL_DEF &aSymbolDef)
Get or create a symbol for the given definition.
LIB_SYMBOL * BuildSymbol(const SYMBOL_DEF &aSymbolDef)
Build a KiCad LIB_SYMBOL from a PADS symbol definition.
Holds all the data relating to one schematic.
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
SCH_SHEET_PATH & CurrentSheet() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Segment description base class to describe items which have 2 end points (track, wire,...
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
const wxString & GetNumber() const
ELECTRICAL_PINTYPE GetType() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const TITLE_BLOCK & GetTitleBlock() const
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetSize(const VECTOR2I &aSize)
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void SetPosition(const VECTOR2I &aPosition) override
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetTitle() const
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
General schematic parameters from SCH and FIELDS sections.
std::map< std::string, std::string > fields
Part instance from PART section.
std::vector< PART_ATTRIBUTE > attributes
Signal (net) definition from CONNECTION and SIGNAL sections.
std::vector< PIN_CONNECTION > connections
std::vector< WIRE_SEGMENT > wires
Symbol definition from CAEDECAL section.
std::vector< SYMBOL_GRAPHIC > graphics
std::vector< SYMBOL_PIN > pins
std::vector< CAEDECAL_ATTR > attrs
Wire segment connecting two endpoints through coordinate vertices.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(CheckFileHeader_ValidLogicFile)
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I