57 BOOST_CHECK_EQUAL( aFp.GetTransform().GetRotate().AsDegrees(), aFp.GetOrientation().AsDegrees() );
99 table->SetColCount( 1 );
102 table->AddCell( cell );
120 BOOST_CHECK(
pad->GetLayerSet().test(
B_Cu ) );
121 BOOST_CHECK(
pad->GetLayerSet().test(
B_Paste ) );
122 BOOST_CHECK(
pad->GetLayerSet().test(
B_Mask ) );
177 const BOX2I bboxBefore = shapeBefore->BBox();
187 const BOX2I bboxAfter = shapeAfter->BBox();
206 BOX2I before =
pad->GetBoundingBox();
211 BOX2I after =
pad->GetBoundingBox();
227 BOX2I before =
pad->GetBoundingBox();
233 BOX2I after =
pad->GetBoundingBox();
270 BOOST_CHECK(
copy.IsFlipped() );
285 <<
" actual ( " <<
actual.x <<
", " <<
actual.y <<
" )" );
298 BOOST_CHECK_MESSAGE(
std::abs( derived.
x - stored.
x ) <= 1 &&
std::abs( derived.
y - stored.
y ) <= 1,
299 "pad " <<
pad->GetNumber() <<
" m_libPos ( " << stored.
x <<
", " << stored.
y <<
" )"
300 <<
" != GetFPRelativePosition ( " << derived.
x <<
", " << derived.
y <<
" )" );
316 for(
const FOOTPRINT* fp : m_board->Footprints() )
325 for(
FOOTPRINT* fp : m_board->Footprints() )
343 for(
const FOOTPRINT* fp : m_board->Footprints() )
352 for(
FOOTPRINT* fp : m_board->Footprints() )
370 FOOTPRINT* fp = *m_board->Footprints().begin();
377 std::map<wxString, VECTOR2I> origPadByNumber;
379 origPadByNumber[
pad->GetNumber()] =
pad->GetPosition();
381 std::unique_ptr<FOOTPRINT> snapshot(
static_cast<FOOTPRINT*
>( fp->
Clone() ) );
401 "pad " <<
pad->GetNumber() <<
" after undo at ( " << p.
x <<
", " << p.
y <<
" )"
402 <<
" expected ( " << orig.
x <<
", " << orig.
y <<
" )" );
414 for(
FOOTPRINT* fp : m_board->Footprints() )
416 std::unique_ptr<FOOTPRINT> libCopy(
static_cast<FOOTPRINT*
>( fp->Clone() ) );
419 "footprint " << fp->GetReference() <<
" differs from its own clone" );
424 "footprint " << fp->GetReference()
425 <<
" flipped top-bottom reported as differing from library" );
431 "footprint " << fp->GetReference()
432 <<
" flipped left-right reported as differing from library" );
456 BOOST_CHECK_MESSAGE(
std::abs( libStartFromShape.
x - libStartStored.
x ) <= 1
457 &&
std::abs( libStartFromShape.
y - libStartStored.
y ) <= 1,
458 "shape m_libStart ( " << libStartStored.
x <<
", " << libStartStored.
y <<
" ) "
459 <<
"!= GetFPRelativePosition ( " << libStartFromShape.
x <<
", "
460 << libStartFromShape.
y <<
" )" );
469 for(
const FOOTPRINT* fp : m_board->Footprints() )
478 for(
FOOTPRINT* fp : m_board->Footprints() )
496 FOOTPRINT* fp = *m_board->Footprints().begin();
500 std::map<wxString, VECTOR2I> origOffsets;
504 origOffsets[
pad->GetNumber()] =
pad->GetPosition() -
anchor;
521 BOOST_CHECK_MESSAGE(
std::abs( offset.
x - 2 * orig.
x ) <= 1 &&
std::abs( offset.
y - 2 * orig.
y ) <= 1,
522 "pad " <<
pad->GetNumber() <<
" offset ( " << offset.
x <<
", " << offset.
y <<
" ) "
523 <<
"expected ( " << 2 * orig.
x <<
", " << 2 * orig.
y <<
" )" );
532 FOOTPRINT* fp = *m_board->Footprints().begin();
538 std::vector<VECTOR2I> origStartOffsets;
567 VECTOR2I orig = origStartOffsets[i++];
569 BOOST_CHECK_MESSAGE(
std::abs( offset.
x - 2 * orig.
x ) <= 1 &&
std::abs( offset.
y - 2 * orig.
y ) <= 1,
570 "shape start offset ( " << offset.
x <<
", " << offset.
y <<
" ) "
571 <<
"expected ( " << 2 * orig.
x <<
", " << 2 * orig.
y <<
" )" );
580 FOOTPRINT* fp = *m_board->Footprints().begin();
586 std::map<wxString, VECTOR2I> origPadPositions;
588 origPadPositions[
pad->GetNumber()] =
pad->GetPosition();
590 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"scale_roundtrip.kicad_pcb";
597 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
608 VECTOR2I orig = origPadPositions[
pad->GetNumber()];
611 "pad " <<
pad->GetNumber() <<
" after reload at ( " << p.
x <<
", " << p.
y
612 <<
" ) expected ( " << orig.
x <<
", " << orig.
y <<
" )" );
621 FOOTPRINT* fp = *m_board->Footprints().begin();
624 std::map<wxString, VECTOR2I> origPadPositions;
626 origPadPositions[
pad->GetNumber()] =
pad->GetPosition();
628 std::unique_ptr<FOOTPRINT> snapshot(
static_cast<FOOTPRINT*
>( fp->
Clone() ) );
642 VECTOR2I orig = origPadPositions[
pad->GetNumber()];
645 "pad " <<
pad->GetNumber() <<
" after undo at ( " << p.
x <<
", " << p.
y <<
" ) expected ( "
646 << orig.
x <<
", " << orig.
y <<
" )" );
673 std::vector<VECTOR2I> origOffsets;
680 BOOST_REQUIRE_EQUAL( scaledBoard.
TotalVertices(), (
int) origOffsets.size() );
685 BOOST_CHECK_MESSAGE(
std::abs( offset.
x - 2 * origOffsets[i].x ) <= 1
686 &&
std::abs( offset.
y - 2 * origOffsets[i].y ) <= 1,
687 "vertex " << i <<
" offset ( " << offset.
x <<
", " << offset.
y <<
" ) expected ( "
688 << 2 * origOffsets[i].x <<
", " << 2 * origOffsets[i].y <<
" )" );
697 FOOTPRINT* fp = *m_board->Footprints().begin();
700 std::map<wxString, VECTOR2I> origSizes;
701 std::map<wxString, VECTOR2I> origDrills;
706 origDrills[
pad->GetNumber()] =
pad->GetDrillSize();
730 FOOTPRINT* fp = *m_board->Footprints().begin();
753 FOOTPRINT* fp = *m_board->Footprints().begin();
771 BOOST_CHECK_CLOSE( (
double) scaledBox.
GetWidth(), 2.0 * origBox.
GetWidth(), 10.0 );
780 FOOTPRINT* fp = *m_board->Footprints().begin();
808 FOOTPRINT* fp = *m_board->Footprints().begin();
825 std::vector<int> violations;
828 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
829 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
831 violations.push_back( aItem->GetErrorCode() );
837 for(
int code : violations )
846 BOOST_CHECK_MESSAGE( found,
"expected DRCE_FOOTPRINT_SCALED_WITH_PADS for a 2x scaled "
847 "footprint with pads; got "
848 << violations.size() <<
" violations" );
866 int scaledFlagged = 0;
869 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
870 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
886 FOOTPRINT* fp = *m_board->Footprints().begin();
910 FOOTPRINT* fp = *m_board->Footprints().begin();
933 FOOTPRINT* fp = *m_board->Footprints().begin();
950 <<
" ) expected ( " << origAnchor.
x <<
", " << origAnchor.
y <<
" )" );
960 std::shared_ptr<CONNECTIVITY_DATA> conn = m_board->GetConnectivity();
963 conn->RecalculateRatsnest();
966 PAD* targetPad =
nullptr;
969 for(
FOOTPRINT* fp : m_board->Footprints() )
971 for(
PAD*
pad : fp->Pads() )
973 if( !conn->GetRatsnestForPad(
pad ).empty() )
992 conn->RecalculateRatsnest();
995 std::vector<CN_EDGE> edges = conn->GetRatsnestForPad( targetPad );
1001 for(
const CN_EDGE& e : edges )
1003 if( e.GetSourcePos() == newPadPos || e.GetTargetPos() == newPadPos )
1010 BOOST_CHECK_MESSAGE( found,
"no ratsnest edge originates at the scaled pad position ( " << newPadPos.
x <<
", "
1011 << newPadPos.
y <<
" )" );
1021 FOOTPRINT* fp = *m_board->Footprints().begin();
1036 BOOST_CHECK_CLOSE( (
double) after.
GetWidth(), 2.0 * origWidth, 5.0 );
1037 BOOST_CHECK_CLOSE( (
double) after.
GetHeight(), 2.0 * origHeight, 5.0 );
1052 for(
FOOTPRINT* candidate : m_board->Footprints() )
1054 if( !candidate->GetCourtyard(
F_CrtYd ).IsEmpty() )
1061 BOOST_REQUIRE_MESSAGE( fp,
"no footprint with a front courtyard in issue18" );
1064 double areaBefore = before.
Area();
1070 double areaAfter = after.
Area();
1073 BOOST_CHECK_CLOSE( areaAfter, 4.0 * areaBefore, 1.0 );
1158 auto applyOnSelection =
1159 [&](
double sx,
double sy )
1170 applyOnSelection( 2.0, 2.0 );
1177 BOOST_CHECK_CLOSE( a.
GetScaleX(), 2.0, 1e-9 );
1178 BOOST_CHECK_CLOSE( a.
GetScaleY(), 2.0, 1e-9 );
1179 BOOST_CHECK_CLOSE( b.
GetScaleX(), 2.0, 1e-9 );
1180 BOOST_CHECK_CLOSE( b.
GetScaleY(), 2.0, 1e-9 );
1188 FOOTPRINT* fp = *m_board->Footprints().begin();
1195 BOOST_CHECK_CLOSE( fp->
GetScaleX(), 3.0, 1e-9 );
1196 BOOST_CHECK_CLOSE( fp->
GetScaleY(), 0.75, 1e-9 );
1205 FOOTPRINT* fp = *m_board->Footprints().begin();
1212 BOOST_CHECK_CLOSE( fp->
GetScaleX(), 1.5, 1e-9 );
1213 BOOST_CHECK_CLOSE( fp->
GetScaleY(), 4.0, 1e-9 );
1223 FOOTPRINT* fp = *m_board->Footprints().begin();
1237 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"promoted_arc_roundtrip.kicad_pcb";
1244 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
1247 bool foundArc =
false;
1263 BOOST_CHECK_MESSAGE( foundArc,
"promoted arc did not round-trip as a lib-frame arc" );
1273 FOOTPRINT* fp = *m_board->Footprints().begin();
1285 const std::filesystem::path savePath =
1286 std::filesystem::temp_directory_path() /
"promoted_circle_roundtrip.kicad_pcb";
1293 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
1296 bool foundCircle =
false;
1312 BOOST_CHECK_MESSAGE( foundCircle,
"promoted circle did not round-trip as a lib-frame circle" );
1321 FOOTPRINT* fp = *m_board->Footprints().begin();
1343 BOOST_CHECK_CLOSE( libRotation.
AsDegrees(), 30.0, 0.01 );
1353 const std::filesystem::path savePath =
1354 std::filesystem::temp_directory_path() /
"native_ellipse_rotated_roundtrip.kicad_pcb";
1361 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
1380 BOOST_REQUIRE_MESSAGE( ellipse2,
"native ellipse not found after reload" );
1421 FOOTPRINT* fp = *m_board->Footprints().begin();
1433 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"scale_size_roundtrip_a.kicad_pcb";
1439 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
1441 PAD* pad2 = *fp2->
Pads().begin();
1445 const std::filesystem::path savePath2 = std::filesystem::temp_directory_path() /
"scale_size_roundtrip_b.kicad_pcb";
1451 FOOTPRINT* fp3 = *reloaded2->Footprints().begin();
1453 PAD* pad3 = *fp3->
Pads().begin();
1540 maxX = std::max( maxX, p.x );
1542 BOOST_CHECK_GT( maxX, 3000000 );
1631 const VECTOR2I rotCenter( 150000000, 100000000 );
1655 const VECTOR2I rotCenter( 105000000, 80000000 );
1668 const std::filesystem::path savePath =
1669 std::filesystem::temp_directory_path() /
"normalized_rect_roundtrip.kicad_pcb";
1678 for(
BOARD_ITEM* item : reloaded->Drawings() )
1682 loaded =
static_cast<PCB_SHAPE*
>( item );
1691 BOOST_CHECK_MESSAGE( onDisk == onBoard,
"saved at ( " << onDisk.
GetOrigin().
x <<
", " << onDisk.
GetOrigin().
y
1693 <<
", expected ( " << onBoard.
GetOrigin().
x <<
", "
1703 FOOTPRINT* fp = *m_board->Footprints().begin();
1795 while( rotDeg > 90.0 ) rotDeg -= 180.0;
1796 while( rotDeg <= -90.0 ) rotDeg += 180.0;
1797 BOOST_CHECK_CLOSE( rotDeg, -30.0, 0.1 );
1826 BOOST_CHECK_CLOSE( major_n, major_u, 1.0 );
1827 BOOST_CHECK_CLOSE( minor_n, minor_u, 6.0 );
1829 double diffDeg = rot_n - rot_u;
1830 while( diffDeg > 90.0 ) diffDeg -= 180.0;
1831 while( diffDeg <= -90.0 ) diffDeg += 180.0;
1832 BOOST_CHECK_SMALL( diffDeg, 1.0 );
1861 BOOST_CHECK_CLOSE(
static_cast<double>( bbox.
GetWidth() ), 3162277.0, 1.0 );
1862 BOOST_CHECK_CLOSE(
static_cast<double>( bbox.
GetHeight() ), 1581139.0, 1.0 );
2018 FOOTPRINT* fp = *m_board->Footprints().begin();
2032 pad->SetNumber( wxT(
"88" ) );
2037 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"circle_pad_roundtrip.kicad_pcb";
2044 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
2047 PAD* pad2 =
nullptr;
2051 if( p->GetNumber() == wxT(
"88" ) )
2058 BOOST_REQUIRE_MESSAGE( pad2,
"circle pad not found after reload" );
2077 FOOTPRINT* fp = *m_board->Footprints().begin();
2090 pad->SetNumber( wxT(
"99" ) );
2106 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"pad_prim_roundtrip.kicad_pcb";
2113 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
2116 PAD* pad2 =
nullptr;
2120 if( p->GetNumber() == wxT(
"99" ) )
2127 BOOST_REQUIRE_MESSAGE( pad2,
"custom pad not found after reload" );
2137 const VECTOR2I libDelta = prim2->GetLibraryEnd() - prim2->GetLibraryStart();
2158 std::vector<VECTOR2I> poly = {
2159 { -1000000, -1000000 }, { 1000000, -1000000 }, { 1000000, 1000000 }, { -1000000, 1000000 }
2165 const BOX2I libBefore = prim->GetLibraryPolyShape().BBox();
2172 const BOX2I libAfter = prim->GetLibraryPolyShape().BBox();
2185 FOOTPRINT* fp = *m_board->Footprints().begin();
2198 pad->SetNumber( wxT(
"77" ) );
2201 std::vector<VECTOR2I> poly = {
2202 { -1000000, -1000000 }, { 1000000, -1000000 }, { 1000000, 1000000 }, { -1000000, 1000000 }
2208 const BOX2I before =
pad->GetBoundingBox();
2210 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"pad_poly_prim_roundtrip.kicad_pcb";
2217 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
2220 PAD* pad2 =
nullptr;
2224 if( p->GetNumber() == wxT(
"77" ) )
2231 BOOST_REQUIRE_MESSAGE( pad2,
"custom poly pad not found after reload" );
2277 BOOST_CHECK_CLOSE(
circle->GetEllipseRotation().AsDegrees(), -30.0, 0.001 );
2397 "vertex " << i <<
" expected ( " <<
expected.x <<
", " <<
expected.y <<
" ) actual ( "
2417 std::vector<VECTOR2I> beforeVerts;
2419 beforeVerts.push_back( before.
CVertex( i ) );
2425 BOOST_REQUIRE_EQUAL( after.
TotalVertices(), (
int) beforeVerts.size() );
2433 "vertex " << i <<
" expected ( " <<
expected.x <<
", " <<
expected.y <<
" ) actual ( "
2476 std::vector<VECTOR2I> beforeVerts;
2478 beforeVerts.push_back( before.
CVertex( i ) );
2480 const VECTOR2I offset( 500000, 250000 );
2481 zone->
Move( offset );
2484 BOOST_REQUIRE_EQUAL( after.
TotalVertices(), (
int) beforeVerts.size() );
2492 "vertex " << i <<
" expected ( " <<
expected.x <<
", " <<
expected.y <<
" ) actual ( "
2510 std::vector<VECTOR2I> beforeVerts;
2512 beforeVerts.push_back( before.
CVertex( i ) );
2516 zone->
Rotate( centre, angle );
2519 BOOST_REQUIRE_EQUAL( after.
TotalVertices(), (
int) beforeVerts.size() );
2528 "vertex " << i <<
" expected ( " <<
expected.x <<
", " <<
expected.y <<
" ) actual ( "
2549 <<
" ) expected near board ( 50000000, 30000000 )" );
2573 <<
" ) expected near board ( 50000000, 30000000 )" );
2595 <<
" ) expected near board ( 50000000, 30000000 )" );
2613 BOX2I bbox = shape->BBox();
2617 <<
" ) expected near board ( 50000000, 30000000 )" );
2642 "lib coords did not change after one flip" );
2674 "lib coords did not change after one flip" );
2705 BOOST_CHECK_MESSAGE(
circle->GetLibraryStart() != libStartBefore ||
circle->GetLibraryEnd() != libEndBefore,
2706 "lib coords did not change after one flip" );
2739 "lib coords did not change after one flip" );
2761 text->SetText( wxT(
"X" ) );
2770 BOOST_CHECK_MESSAGE(
text->GetTextPos() != boardPosBefore,
"text position did not change after one flip" );
2783 FOOTPRINT* fp = *m_board->Footprints().begin();
2787 table->SetColCount( 2 );
2791 table->SetColWidth( 0, colW );
2792 table->SetColWidth( 1, colW );
2793 table->SetRowHeight( 0, rowH );
2794 table->SetRowHeight( 1, rowH );
2796 for(
int i = 0; i < 4; ++i )
2800 cell->
SetEnd(
VECTOR2I( ( i % 2 + 1 ) * colW, ( i / 2 + 1 ) * rowH ) );
2801 cell->
SetText( wxString::Format(
"c%d", i ) );
2802 table->AddCell( cell );
2809 const double angles[] = { 90.0, 180.0, 270.0 };
2811 for(
double deg : angles )
2817 std::vector<VECTOR2I> startsBefore, endsBefore;
2820 startsBefore.push_back( cell->GetStart() );
2821 endsBefore.push_back( cell->GetEnd() );
2824 const std::filesystem::path savePath =
2825 std::filesystem::temp_directory_path() /
"table_in_rotated_fp.kicad_pcb";
2831 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
2845 BOOST_REQUIRE_EQUAL( (
int) table2->
GetCells().size(), 4 );
2847 for(
int i = 0; i < 4; ++i )
2853 <<
" ) expected ( " << startsBefore[i].x <<
", " << startsBefore[i].y
2855 BOOST_CHECK_MESSAGE(
std::abs( cell->
GetEnd().
x - endsBefore[i].x ) <= 1
2857 "cell " << i <<
" end ( " << cell->
GetEnd().
x <<
", " << cell->
GetEnd().
y
2858 <<
" ) expected ( " << endsBefore[i].x <<
", " << endsBefore[i].y
2874 const std::vector<Case> cases = {
2875 {
VECTOR2I( 12345678, -7654321 ), 0.0 }, {
VECTOR2I( 12345678, -7654321 ), 90.0 },
2876 {
VECTOR2I( 12345678, -7654321 ), 180.0 }, {
VECTOR2I( 12345678, -7654321 ), 270.0 },
2877 {
VECTOR2I( -12345678, -7654321 ), 90.0 }, {
VECTOR2I( -12345678, 7654321 ), 90.0 },
2878 {
VECTOR2I( 12345678, 7654321 ), 90.0 }, {
VECTOR2I( 12345678, 7654321 ), 270.0 },
2879 {
VECTOR2I( -12345678, -7654321 ), 270.0 },
2882 for(
const Case& tc : cases )
2884 BOOST_TEST_CONTEXT(
"fp pos ( " << tc.pos.x <<
", " << tc.pos.y <<
" ) orient " << tc.angle )
2886 const double fpAngle = tc.angle;
2889 FOOTPRINT* fp = *m_board->Footprints().begin();
2896 table->SetColCount( 2 );
2900 table->SetColWidth( 0, colW );
2901 table->SetColWidth( 1, colW );
2902 table->SetRowHeight( 0, rowH );
2903 table->SetRowHeight( 1, rowH );
2905 for(
int i = 0; i < 4; ++i )
2909 cell->
SetEnd(
VECTOR2I( ( i % 2 + 1 ) * colW, ( i / 2 + 1 ) * rowH ) );
2910 cell->
SetText( wxString::Format(
"c%d", i ) );
2911 table->AddCell( cell );
2921 std::vector<VECTOR2I> startsBefore, endsBefore;
2922 std::vector<double> anglesBefore;
2925 startsBefore.push_back( cell->GetStart() );
2926 endsBefore.push_back( cell->GetEnd() );
2927 anglesBefore.push_back( cell->GetTextAngle().AsDegrees() );
2930 const std::filesystem::path savePath =
2931 std::filesystem::temp_directory_path() /
"table_rotated_in_fp_then_fp_rotated.kicad_pcb";
2937 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
2951 BOOST_REQUIRE_EQUAL( (
int) table2->
GetCells().size(), 4 );
2953 for(
int i = 0; i < 4; ++i )
2959 <<
" ) expected ( " << startsBefore[i].x <<
", " << startsBefore[i].y
2961 BOOST_CHECK_MESSAGE(
std::abs( cell->
GetEnd().
x - endsBefore[i].x ) <= 1
2963 "cell " << i <<
" end ( " << cell->
GetEnd().
x <<
", " << cell->
GetEnd().
y
2964 <<
" ) expected ( " << endsBefore[i].x <<
", " << endsBefore[i].y
2981 table->SetColCount( 2 );
2985 table->SetColWidth( 0, colW );
2986 table->SetColWidth( 1, colW );
2987 table->SetRowHeight( 0, rowH );
2988 table->SetRowHeight( 1, rowH );
2990 for(
int i = 0; i < 4; ++i )
2994 cell->
SetEnd(
VECTOR2I( ( i % 2 + 1 ) * colW, ( i / 2 + 1 ) * rowH ) );
2995 table->AddCell( cell );
3005 std::vector<VECTOR2I> corners = cell->GetCorners();
3006 BOOST_REQUIRE_EQUAL( corners.size(), 4u );
3013 "visual width " << visual.
GetWidth() <<
" expected " << rowH );
3015 "visual height " << visual.
GetHeight() <<
" expected " << colW );
3038 for(
int row = 0; row < 2; ++row )
3043 cell->
SetText( row == 0 ? wxT(
"PCB1234" ) : wxT(
"Rev A00" ) );
3064 box.
Merge( cell->GetStart() );
3065 box.
Merge( cell->GetEnd() );
3075 std::vector<VECTOR2I> starts;
3076 std::vector<VECTOR2I> ends;
3080 starts.push_back( cell->GetStart() );
3081 ends.push_back( cell->GetEnd() );
3086 for(
size_t ii = 0; ii < aTable->
GetCells().size(); ++ii )
3090 BOOST_CHECK_MESSAGE( ( cell->
GetStart() - starts[ii] ).EuclideanNorm() <= 1,
3091 "cell " << ii <<
" start moved to ( " << cell->
GetStart().
x <<
", " << cell->
GetStart().
y
3092 <<
" ) from ( " << starts[ii].x <<
", " << starts[ii].y <<
" )" );
3093 BOOST_CHECK_MESSAGE( ( cell->
GetEnd() - ends[ii] ).EuclideanNorm() <= 1,
3094 "cell " << ii <<
" end moved to ( " << cell->
GetEnd().
x <<
", " << cell->
GetEnd().
y
3095 <<
" ) from ( " << ends[ii].x <<
", " << ends[ii].y <<
" )" );
3124 "table box ( " << after.
GetLeft() <<
", " << after.
GetTop() <<
" ) - ( "
3191 table->SetColCount( 3 );
3193 for(
int col = 0; col < 3; ++col )
3194 table->SetColWidth( col, colWidths[col] );
3196 for(
int row = 0; row < 2; ++row )
3197 table->SetRowHeight( row, rowHeights[row] );
3202 for(
int row = 0; row < 2; ++row )
3206 for(
int col = 0; col < 3; ++col )
3211 cell->
SetText( wxString::Format( wxT(
"%c%d" ),
'A' + col, row + 1 ) );
3212 table->AddCell( cell );
3213 x += colWidths[col];
3216 y += rowHeights[row];
3223 for(
int row = 0; row < 2; ++row )
3225 for(
int col = 0; col < 3; ++col )
3227 wxString
expected = wxString::Format( wxT(
"%c%d" ),
'A' + 2 - col, row + 1 );
3248 table->SetColCount( 2 );
3252 table->SetColWidth( 0, colW );
3253 table->SetColWidth( 1, colW );
3254 table->SetRowHeight( 0, rowH );
3255 table->SetRowHeight( 1, rowH );
3257 for(
int i = 0; i < 4; ++i )
3261 cell->
SetEnd(
VECTOR2I( ( i % 2 + 1 ) * colW, ( i / 2 + 1 ) * rowH ) );
3262 table->AddCell( cell );
3270 std::set<std::pair<int, int>> centers;
3273 int w =
std::abs( cell->GetEnd().x - cell->GetStart().x );
3274 int h =
std::abs( cell->GetEnd().y - cell->GetStart().y );
3276 BOOST_CHECK_MESSAGE( ( w == colW && h == rowH ) || ( w == rowH && h == colW ),
3277 "cell dims " << w <<
" x " << h <<
" expected " << colW <<
"x" << rowH <<
" or rotated" );
3279 std::vector<VECTOR2I> corners = cell->GetCorners();
3280 BOOST_REQUIRE_EQUAL( corners.size(), 4u );
3287 "visual width " << visual.
GetWidth() <<
" expected " << rowH );
3289 "visual height " << visual.
GetHeight() <<
" expected " << colW );
3292 centers.insert( { vc.
x, vc.
y } );
3295 BOOST_CHECK_MESSAGE( centers.size() == 4,
"cells overlapped, got " << centers.size() <<
" unique centers" );
3307 tb->
SetText( wxT(
"Hello" ) );
3318 "lib shape changed to " <<
static_cast<int>( tb->
GetLibraryShape() ) );
3320 "runtime shape changed to " <<
static_cast<int>( tb->
GetShape() ) );
3325 BOOST_CHECK_MESSAGE( newWidth == origWidth,
"width changed from " << origWidth <<
" to " << newWidth );
3326 BOOST_CHECK_MESSAGE( newHeight == origHeight,
"height changed from " << origHeight <<
" to " << newHeight );
3334 FOOTPRINT* fp = *m_board->Footprints().begin();
3341 text->SetText( wxT(
"drift probe" ) );
3353 FOOTPRINT* fp = *aBoard.Footprints().begin();
3358 if( t->GetText() == wxT(
"drift probe" ) )
3365 BOARD* currentBoard = m_board.get();
3366 std::unique_ptr<BOARD> reloadedHolder;
3367 const std::filesystem::path savePathA =
3368 std::filesystem::temp_directory_path() /
"pcb_text_in_rotated_fp_a.kicad_pcb";
3369 const std::filesystem::path savePathB =
3370 std::filesystem::temp_directory_path() /
"pcb_text_in_rotated_fp_b.kicad_pcb";
3372 for(
int cycle = 0; cycle < 3; ++cycle )
3374 const std::filesystem::path&
path = ( cycle % 2 == 0 ) ? savePathA : savePathB;
3379 currentBoard = reloadedHolder.get();
3381 PCB_TEXT* probe = findProbe( *currentBoard );
3386 "cycle " << cycle <<
" text pos ( " << probe->
GetTextPos().
x <<
", "
3387 << probe->
GetTextPos().
y <<
" ) expected ( " << posBefore.
x <<
", " << posBefore.
y
3398 FOOTPRINT* fp = *m_board->Footprints().begin();
3411 const std::filesystem::path savePath = std::filesystem::temp_directory_path() /
"pcb_field_in_rotated_fp.kicad_pcb";
3417 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
3425 <<
" ) expected ( " << refPosBefore.
x <<
", " << refPosBefore.
y
3435 FOOTPRINT* fp = *m_board->Footprints().begin();
3451 text->SetText( wxT(
"scale probe" ) );
3457 tb->
SetText( wxT(
"scale probe box" ) );
3472 const std::filesystem::path savePath =
3473 std::filesystem::temp_directory_path() /
"dim_barcode_in_scaled_fp.kicad_pcb";
3479 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
3496 if( t->GetText() == wxT(
"scale probe" ) )
3509 <<
" ) expected ( " << dimStartBefore.
x <<
", " << dimStartBefore.
y
3513 "dim end after reload ( " << dim2->
GetEnd().
x <<
", " << dim2->
GetEnd().
y <<
" ) expected ( "
3514 << dimEndBefore.
x <<
", " << dimEndBefore.
y <<
" )" );
3518 <<
" ) expected ( " << bcPosBefore.
x <<
", " << bcPosBefore.
y
3523 <<
" ) expected ( " << textPosBefore.
x <<
", " << textPosBefore.
y
3528 <<
" ) expected ( " << tbStartBefore.
x <<
", "
3529 << tbStartBefore.
y <<
" )" );
3532 "textbox end after reload ( " << tb2->
GetEnd().
x <<
", " << tb2->
GetEnd().
y <<
" ) expected ( "
3533 << tbEndBefore.
x <<
", " << tbEndBefore.
y <<
" )" );
3544 text->SetText( wxT(
"X" ) );
3665 bool anyVertexChanged =
false;
3670 anyVertexChanged =
true;
3673 BOOST_CHECK_MESSAGE( anyVertexChanged,
"polygon vertices did not change after one flip" );
3685 BOOST_CHECK_MESSAGE(
std::abs( before.
x - after.
x ) <= 1 &&
std::abs( before.
y - after.
y ) <= 1,
3686 "vertex " << i <<
" before ( " << before.
x <<
", " << before.
y <<
" ) after ( " << after.
x
3687 <<
", " << after.
y <<
" )" );
3719 "lib coords did not change after one flip" );
3752 BOOST_CHECK_MESSAGE( point->
GetPosition() != boardPosBefore,
"board position did not change after one flip" );
3786 "lib coords did not change after one flip" );
3844 BOOST_CHECK_MESSAGE( bezier->
GetBezierC1() != c1Before,
"C1 did not follow rotation" );
3845 BOOST_CHECK_MESSAGE( bezier->
GetBezierC2() != c2Before,
"C2 did not follow rotation" );
3875 "C1 expected ( " << expectedC1.
x <<
", " << expectedC1.
y <<
" ) actual ( "
3879 "C2 expected ( " << expectedC2.
x <<
", " << expectedC2.
y <<
" ) actual ( "
3897 const VECTOR2I libStart( 1000000, 1000000 );
3898 const VECTOR2I libC1( 2000000, 4000000 );
3899 const VECTOR2I libC2( 4000000, 0 );
3900 const VECTOR2I libEnd( 5000000, 3000000 );
3905 bezier->
SetEnd( libEnd );
3922 << board.x <<
", " << board.y <<
" )" );
3925 checkBoard(
"start", libStart, bezier->
GetStart() );
3928 checkBoard(
"end", libEnd, bezier->
GetEnd() );
3943 std::vector<VECTOR2I> libVerts = {
3951 for(
const VECTOR2I& v : libVerts )
3965 BOOST_REQUIRE_EQUAL(
result.TotalVertices(), (
int) libVerts.size() );
3967 for(
int i = 0; i < (int) libVerts.size(); ++i )
3973 "vertex " << i <<
" expected ( " <<
expected.x <<
", " <<
expected.y <<
" ) actual ( "
4003 bool anyMoved =
false;
4010 BOOST_CHECK_MESSAGE( anyMoved,
"polygon vertices did not move after rotation" );
4024 "vertex " << i <<
" before ( " << b.
x <<
", " << b.
y <<
" ) restored ( " << r.
x <<
", "
4061 "vertex " << i <<
" expected ( " <<
expected.x <<
", " <<
expected.y <<
" ) actual ( "
4085 BOOST_CHECK_CLOSE(
pad->GetOrientation().AsDegrees(), 45.0, 1e-6 );
4086 BOOST_CHECK_CLOSE(
pad->GetFPRelativeOrientation().AsDegrees(), 45.0, 1e-6 );
4091 BOOST_CHECK_CLOSE(
pad->GetOrientation().AsDegrees(), 135.0, 1e-6 );
4093 BOOST_CHECK_CLOSE(
pad->GetFPRelativeOrientation().AsDegrees(), 45.0, 1e-6 );
4096 BOOST_CHECK_CLOSE(
pad->GetOrientation().AsDegrees(), 45.0, 1e-6 );
4097 BOOST_CHECK_CLOSE(
pad->GetFPRelativeOrientation().AsDegrees(), 45.0, 1e-6 );
4111 text->SetText( wxT(
"X" ) );
4116 BOOST_CHECK_CLOSE(
text->GetTextAngle().AsDegrees(), 45.0, 1e-6 );
4120 BOOST_CHECK_CLOSE(
text->GetTextAngle().AsDegrees(), 135.0, 1e-6 );
4123 BOOST_CHECK_CLOSE(
text->GetTextAngle().AsDegrees(), 45.0, 1e-6 );
4176 BOOST_CHECK_MESSAGE( tb->
GetTextAngle() != absBefore,
"text angle did not change after one flip" );
4314 [&](
double aFpOrientDeg,
FLIP_DIRECTION aDir,
double aExpectedDelta )
4335 BOOST_CHECK_CLOSE(
actual.AsDegrees(),
expected.AsDegrees(), 1e-6 );
4366 BOOST_CHECK_MESSAGE( bc->
GetPosition() != posBefore,
"barcode pos did not move on first flip" );
4403 BOOST_CHECK_MESSAGE( dim->
GetStart() != startBefore,
"dim start did not move on first flip" );
4441 std::vector<VECTOR2I> savedCorners;
4443 savedCorners.emplace_back( p );
4445 const std::filesystem::path savePath =
4446 std::filesystem::temp_directory_path() /
"rect_noncardinal_roundtrip.kicad_pcb";
4453 for(
BOARD_ITEM* item : reloaded->Drawings() )
4469 BOOST_REQUIRE_EQUAL( (
int) reloadedPoints.size(), (
int) savedCorners.size() );
4471 for(
size_t i = 0; i < savedCorners.size(); ++i )
4517 const VECTOR2I coincident( 53000000, 51000000 );
4524 pad->SetPosition( coincident );
4534 BOOST_REQUIRE_EQUAL(
pad->GetPosition().x, seg->
GetStart().
x );
4535 BOOST_REQUIRE_EQUAL(
pad->GetPosition().y, seg->
GetStart().
y );
4613 aPad =
new PAD( fp );
4645 BOOST_CHECK_MESSAGE( aTxt->
GetTextPos() == aSeg->
GetStart(), aWhen <<
": text vs seg" );
4652 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
4665 std::filesystem::path tmp = std::filesystem::temp_directory_path() /
"kicad_qa_xform_roundtrip.kicad_pcb";
4669 std::filesystem::remove( tmp, ec );
4672 FOOTPRINT* r = reloaded->Footprints().front();
4682 rtxt =
static_cast<PCB_TEXT*
>( it );
4688 BOOST_CHECK( r->
Pads().front()->GetPosition() == padPos );
4689 BOOST_CHECK( rseg->
GetStart() == segStart );
4691 BOOST_CHECK( r->
Points().front()->GetPosition() == ptPos );
4703 VECTOR2I( 53000000, 51000000 ),
pad, seg, txt, pt );
4723 VECTOR2I( 53000000, 51000000 ),
pad, seg, txt, pt );
4739 VECTOR2I( 53000000, 51000000 ),
pad, seg, txt, pt );
4743 std::unique_ptr<FOOTPRINT> clone(
static_cast<FOOTPRINT*
>( fp->
Clone() ) );
4745 BOOST_REQUIRE( !clone->Pads().empty() && !clone->Points().empty() );
4749 for(
BOARD_ITEM* it : clone->GraphicalItems() )
4754 ctxt =
static_cast<PCB_TEXT*
>( it );
4760 BOOST_CHECK( clone->Pads().front()->GetPosition() == ref );
4761 BOOST_CHECK( cseg->
GetStart() == ref );
4763 BOOST_CHECK( clone->Points().front()->GetPosition() == ref );
4777 VECTOR2I( 53000000, 51000000 ),
pad, seg, txt, pt );
4787 BOOST_CHECK(
pad->GetPosition() == padPos );
4788 BOOST_CHECK( seg->
GetStart() == segStart );
4798 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
4804 pad, seg, txt, pt );
4813 std::filesystem::path tmp = std::filesystem::temp_directory_path() /
"kicad_qa_scalar_roundtrip.kicad_pcb";
4817 std::filesystem::remove( tmp, ec );
4820 FOOTPRINT* r = reloaded->Footprints().front();
4829 rtxt =
static_cast<PCB_TEXT*
>( it );
4844 [](
double aScaleX,
double aScaleY )
4870 runCase( 2.0, 2.0 );
4871 runCase( 2.0, 1.0 );
4890 const int maxError =
pcbIUScale.mmToIU( 0.01 );
4902 BOOST_CHECK_GT( height2x, height1x * 3 / 2 );
4909 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
4931 std::filesystem::path tmp = std::filesystem::temp_directory_path() /
"kicad_qa_textbox_roundtrip.kicad_pcb";
4935 std::filesystem::remove( tmp, ec );
4938 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
4961 table->SetColCount( 2 );
4962 table->SetColWidth( 0, 16000000 );
4963 table->SetColWidth( 1, 18000000 );
4964 table->SetRowHeight( 0, 5000000 );
4965 table->SetRowHeight( 1, 5000000 );
4968 { -4000000, 6000000 }, { 12000000, 6000000 }, { -4000000, 11000000 }, { 12000000, 11000000 }
4971 { 12000000, 11000000 }, { 30000000, 11000000 }, { 12000000, 16000000 }, { 30000000, 16000000 }
4974 for(
int ii = 0; ii < 4; ++ii )
4981 cell->
SetEnd( ends[ii] );
4982 table->AddCell( cell );
4996 "table bbox size out of range ( " << bbox.
GetWidth() <<
", " << bbox.
GetHeight() <<
" )" );
5000 "table bbox center ( " <<
center.x <<
", " <<
center.y <<
" ) far from footprint ( "
5001 << aNearPos.
x <<
", " << aNearPos.
y <<
" )" );
5004 BOOST_CHECK( aTable->
GetCells()[0]->GetBoundingBox().GetCenter()
5005 != aTable->
GetCells()[3]->GetBoundingBox().GetCenter() );
5044 for(
double angle : { 0.0, 90.0, 33.0, 217.5 } )
5066 for(
double angle : { 0.0, 90.0, 180.0, 270.0, 33.0, 217.5 } )
5090 FOOTPRINT* fp = *m_board->Footprints().begin();
5104 const std::filesystem::path savePath =
5105 std::filesystem::temp_directory_path() /
"table_in_rotated_scaled_fp.kicad_pcb";
5111 FOOTPRINT* fp2 = *reloaded->Footprints().begin();
5119 table2 =
static_cast<PCB_TABLE*
>( item );
5127 const int tol = 300000;
5133 "table bbox after reload o( "
5145 KI_TEST::LoadBoard( m_settingsManager,
"embedded_table_rotated_legacy_v10", m_board );
5149 for(
FOOTPRINT* fp : m_board->Footprints() )
5151 for(
BOARD_ITEM* item : fp->GraphicalItems() )
5186 BOOST_CHECK_MESSAGE( wRatio > 1.9 && wRatio < 2.1,
"table width ratio " << wRatio <<
" expected ~2.0" );
5187 BOOST_CHECK_MESSAGE( hRatio > 1.4 && hRatio < 1.6,
"table height ratio " << hRatio <<
" expected ~1.5" );
5206 std::vector<VECTOR2I> poly = {
5207 { -1000000, -1000000 }, { 1000000, -1000000 }, { 1000000, 1000000 }, { -1000000, 1000000 }
5212 BOX2I before =
pad->GetBoundingBox();
5216 BOX2I after =
pad->GetBoundingBox();
5221 BOOST_CHECK_MESSAGE( wRatio > 1.9 && wRatio < 2.1,
"custom pad width ratio " << wRatio <<
" expected ~2.0" );
5222 BOOST_CHECK_MESSAGE( hRatio > 1.4 && hRatio < 1.6,
"custom pad height ratio " << hRatio <<
" expected ~1.5" );
5231 for(
FOOTPRINT* fp : m_board->Footprints() )
5235 auto primeAndTransform =
5236 [&](
const std::function<void()>& aTransform )
5238 for(
ZONE* zone : fp->Zones() )
5239 zone->CacheBoundingBox();
5243 for(
ZONE* zone : fp->Zones() )
5245 BOOST_CHECK_MESSAGE( zone->GetBoundingBox() == zone->GetBoardOutline().BBox(),
5246 fp->GetReference() <<
" keepout bbox is stale after transform" );
5250 primeAndTransform( [&]() { fp->SetOrientation( fp->GetOrientation() +
ANGLE_90 ); } );
5251 primeAndTransform( [&]() { fp->SetPosition( fp->GetPosition() +
VECTOR2I( 1234567, 7654321 ) ); } );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
VECTOR2I GetFPRelativePosition() const
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
constexpr const Vec GetEnd() const
constexpr size_type GetWidth() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr const SizeVec & GetSize() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
void RunTests(EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints, BOARD_COMMIT *aCommit=nullptr)
Run the DRC tests.
void SetViolationHandler(DRC_VIOLATION_HANDLER aHandler)
Set an optional DRC violation handler (receives DRC_ITEMs and positions).
int GetEllipseMinorRadius() const
const VECTOR2I & GetBezierC2() const
const VECTOR2I & GetEllipseCenter() const
EDA_ANGLE GetEllipseEndAngle() const
int GetEllipseMajorRadius() const
SHAPE_POLY_SET & GetPolyShape()
EDA_ANGLE GetEllipseRotation() const
virtual void SetFilled(bool aFlag)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
EDA_ANGLE GetEllipseStartAngle() const
const std::vector< VECTOR2I > & GetBezierPoints() const
const VECTOR2I & GetBezierC1() const
bool IsPolyShapeValid() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetTextPos(const VECTOR2I &aPoint)
BOX2I GetTextBox(const RENDER_SETTINGS *aSettings, int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
virtual void SetText(const wxString &aText)
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
void SetAttribute(PAD_ATTRIB aAttribute)
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
void SetPadstackMode(PADSTACK::MODE aMode)
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
static LSET PTHMask()
layer set for a through hole pad
VECTOR2I GetPosition() const override
VECTOR2I GetDrillSize() const
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
void SetPosition(const VECTOR2I &aPos) override
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
static LSET SMDMask()
layer set for a SMD pad on Front layer
void SetLayerSet(const LSET &aLayers) override
const EXTRUDED_3D_BODY * GetExtruded() const
EXTRUDED_3D_BODY * MutableExtruded()
void SetTextSize(int aTextSize)
Change the height of the human-readable text displayed below the barcode.
double GetOrientation() const
const VECTOR2I & GetLibraryPos() const
EDA_ANGLE GetLibraryAngle() const
void SetWidth(int aWidth)
void AssembleBarcode() const
Assemble the barcode polygon and text polygons into a single polygonal representation.
void SetHeight(int aHeight)
VECTOR2I GetPosition() const override
Get the position (center) of the barcode in internal units.
void SetPosition(const VECTOR2I &aPos) override
void SetOrientation(double aDegrees)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the drawing layer for the barcode and its text.
EDA_ANGLE GetAngle() const
void SetText(const wxString &aText)
Set the barcode content text to encode.
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
const VECTOR2I & GetLibraryStart() const
virtual VECTOR2I GetEnd() const
const VECTOR2I & GetLibraryEnd() const
virtual VECTOR2I GetStart() const
The dimension's origin is the first feature point for the dimension.
void SetKeepTextAligned(bool aKeepAligned)
For better understanding of the points that make a dimension:
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
void SetPosition(const VECTOR2I &aPos) override
VECTOR2I GetPosition() const override
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetEllipseCenter(const VECTOR2I &aPt) override
EDA_ANGLE GetLibraryEllipseEndAngle() const
void SetBezierC1(const VECTOR2I &aPt) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
VECTOR2I GetLibraryBezierC1() const
void SetWidth(int aWidth) override
void OverrideLibPoly(const SHAPE_POLY_SET &aPoly)
void OverrideLibBezier(const VECTOR2I &aC1, const VECTOR2I &aC2)
int GetLibraryEllipseMinorRadius() const
void SetEllipseStartAngle(const EDA_ANGLE &aA) override
EDA_ANGLE GetLibraryEllipseStartAngle() const
int GetLibraryEllipseMajorRadius() const
EDA_ANGLE GetLibraryEllipseRotation() const
SHAPE_T GetLibraryShape() const
void SetEllipseEndAngle(const EDA_ANGLE &aA) override
VECTOR2I GetLibraryEllipseCenter() const
void SetEnd(const VECTOR2I &aEnd) override
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetLibraryEnd() const
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
void SetEllipseRotation(const EDA_ANGLE &aA) override
VECTOR2I GetLibraryStart() const
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void OverrideLibCoords(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aArcMid=VECTOR2I(0, 0))
void SetEllipseMinorRadius(int aR) override
STROKE_PARAMS GetStroke() const override
void SetStart(const VECTOR2I &aStart) override
void SetBezierC2(const VECTOR2I &aPt) override
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
VECTOR2I GetLibraryBezierC2() const
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) override
Set the three controlling points for an arc.
VECTOR2I GetLibraryArcMid() const
void SetEllipseMajorRadius(int aR) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
void SetRowSpan(int aSpan)
void SetColSpan(int aSpan)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
PCB_TABLECELL * GetCell(int aRow, int aCol) const
std::vector< PCB_TABLECELL * > GetCells() const
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
VECTOR2I GetPosition() const override
EDA_ANGLE GetTextAngle() const override
int GetTextThickness() const override
void SetBorderEnabled(bool enabled)
Disables the border, this is done by changing the stroke internally.
VECTOR2I GetTextSize() const override
void SetShape(SHAPE_T aShape) override
void SetTextAngle(const EDA_ANGLE &aAngle) override
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
EDA_ANGLE GetTextAngle() const override
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
VECTOR2I GetTextPos() const override
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Convert the text to a polygonSet describing the actual character strokes (one per segment).
int GetTextThickness() const override
void SetTextAngle(const EDA_ANGLE &aAngle) override
VECTOR2I GetTextSize() const override
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
ITERATOR IterateWithHoles(int aOutline)
double Area()
Return the area of this poly set.
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int TotalVertices() const
Return total number of vertices stored in the set.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
int OutlineCount() const
Return the number of outlines in the set.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Handle a list of polygons defining a copper zone.
void SetNeedRefill(bool aNeedRefill)
void TransformSmoothedOutlineToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, SHAPE_POLY_SET *aBoardOutline) const
Convert the outlines shape to a polygon with no holes inflated (optional) by max( aClearanceValue,...
const BOX2I GetBoundingBox() const override
bool HitTestForCorner(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a corner.
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
void Move(const VECTOR2I &offset) override
Move the outlines.
void SetIsRuleArea(bool aEnable)
void CacheBoundingBox()
Used to preload the zone bounding box cache so we don't have to worry about mutex-locking it each tim...
SHAPE_POLY_SET GetBoardOutline() const
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const VECTOR2I &aRefPos, int aAccuracy=0) const
Test if the given VECTOR2I is within the bounds of a filled area of this zone.
void SetIsFilled(bool isFilled)
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
SHAPE_POLY_SET GetLibraryOutline() const
PCB_LAYER_ID GetFirstLayer() const
@ DRCE_FOOTPRINT_SCALED_WITH_PADS
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ ALWAYS_FLASHED
Always flashed for connectivity.
PCB_LAYER_ID
A quick note on layer IDs:
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ SMD
Smd pad, appears on the solder paste layer (default)
BARCODE class definition.
SETTINGS_MANAGER m_settingsManager
std::unique_ptr< BOARD > m_board
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
VECTOR2< int32_t > VECTOR2I