135 BOOST_REQUIRE_EQUAL( anchors.size(), 2 );
162 auto segState = diag.shapeStates.find( seg->
m_Uuid );
163 auto dimState = diag.shapeStates.find( dim->m_Uuid );
167 BOOST_CHECK( dimState->second == segState->second );
169 const VECTOR2I dimEnd0 = dim->GetEnd();
171 std::vector<BOARD_ITEM*> staged;
173 [&](
BOARD_ITEM* i ) { staged.push_back( i ); } );
176 BOOST_CHECK_LE( ( dim->GetStart() - seg->
GetEnd() ).EuclideanNorm(), 5000.0 );
177 BOOST_CHECK( ( dim->GetStart() -
VECTOR2I( 10 *
MM, 0 ) ).EuclideanNorm() > 20000.0 );
178 BOOST_CHECK_LE( ( dim->GetEnd() - dimEnd0 ).EuclideanNorm(), 5000.0 );
179 BOOST_CHECK( std::find( staged.begin(), staged.end(), dim ) != staged.end() );
210 std::optional<CONSTRAINT_MEMBER> hit =
214 BOOST_CHECK( hit->m_item == dim->
m_Uuid );
233 std::vector<PCB_SHAPE*> modified;
237 BOOST_CHECK_LE( ( seg->
GetEnd() - dim->GetStart() ).EuclideanNorm(), 5000.0 );
252 seg->
Move( { 0, 3 *
MM } );
256 BOOST_CHECK_LE( ( dim->GetStart() - seg->
GetEnd() ).EuclideanNorm(), 5000.0 );
257 BOOST_CHECK( dim->GetStart().y > 1 *
MM );
269 leader->SetStart( { 10 *
MM, 0 } );
270 leader->SetEnd( { 15 *
MM, 5 *
MM } );
277 std::vector<PCB_CONSTRAINT*> constraints = { c };
306 BOOST_CHECK_LE( (
circle->GetCenter() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
320 dim->SetTextPos( dim->GetKnee() + textOffset );
333 BOOST_CHECK_LE(
std::abs( ( dim->GetEnd() - dim->GetStart() ).EuclideanNorm() - 12 *
MM ), 5000.0 );
336 BOOST_CHECK_LE( ( ( dim->GetTextPos() - dim->GetKnee() ) - textOffset ).EuclideanNorm(), 5000.0 );
379 const double tol = 10000;
383 std::optional<KIID> hit =
386 BOOST_CHECK( *hit ==
circle->m_Uuid );
400 const double tol = 10000;
416 std::vector<ENDPOINT_BINDING> bindings =
419 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
429 BOOST_REQUIRE_EQUAL( anchors.size(), 4 );
443 const double tol = 0.01 *
MM;
446 std::vector<ENDPOINT_BINDING> bindings =
449 BOOST_REQUIRE_EQUAL( bindings.size(), 1 );
457 BOOST_CHECK( bindings.empty() );
466 std::vector<VECTOR2I> pts = { { 0, 0 },
468 { 15 *
MM, 20 *
MM },
470 { -5 *
MM, 10 *
MM } };
474 std::vector<ENDPOINT_BINDING> bindings =
SelectEndpointBindings( &board, fakeDim, pts[1], pts[3], 1000.0 );
476 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
483 std::optional<VECTOR2I> pos =
498 { 10 *
MM, 10 *
MM },
503 std::vector<ENDPOINT_BINDING> bindings =
506 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
512 BOOST_CHECK( binding.target.m_item != b->m_Uuid );
528 chain.SetClosed(
true );
549 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
551 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
558 const VECTOR2I tl = rectTopLeft( rect );
559 const VECTOR2I br = rectBottomRight( rect );
561 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
562 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
567 BOOST_REQUIRE_EQUAL( corners.size(), 4 );
574 BOOST_CHECK_LE( ( dim->GetStart() - corners[0].pos ).EuclideanNorm(), 5000.0 );
575 BOOST_CHECK_LE( ( dim->GetEnd() - corners[1].pos ).EuclideanNorm(), 5000.0 );
584 std::vector<VECTOR2I> pts = { { 0, 0 },
586 { 15 *
MM, 20 *
MM },
588 { -5 *
MM, 10 *
MM } };
595 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
597 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 3 } );
610 for(
int i : { 0, 2, 4 } )
611 BOOST_CHECK_LE( ( outline.
CPoint( i ) - pts[i] ).EuclideanNorm(), 5000.0 );
614 BOOST_CHECK_LE( ( dim->
GetStart() - outline.
CPoint( 1 ) ).EuclideanNorm(), 5000.0 );
615 BOOST_CHECK_LE( ( dim->
GetEnd() - outline.
CPoint( 3 ) ).EuclideanNorm(), 5000.0 );
628 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
630 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
643 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
644 BOOST_CHECK_LE( ( dim->GetStart() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
645 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
665 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
667 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
677 std::vector<PCB_SHAPE*> modified;
681 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
682 BOOST_CHECK_LE( ( rectTopLeft( rect ) -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
683 BOOST_CHECK_LE( ( seg->GetStart() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
684 BOOST_CHECK( std::find( modified.begin(), modified.end(), seg ) != modified.end() );
687 BOOST_CHECK_LE( ( dim->GetStart() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
688 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
700 std::vector<VECTOR2I> pts = { { 0, 0 },
702 { 15 *
MM, 20 *
MM },
704 { -5 *
MM, 10 *
MM } };
710 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
712 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 4 } );
724 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), endBinding->
m_Uuid ) != unmapped.end() );
725 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), startBinding->
m_Uuid ) == unmapped.end() );
728 BOOST_CHECK( adapter.
Solve() );
729 BOOST_CHECK( adapter.
Apply().empty() );
733 for(
int i : { 0, 1, 2 } )
803 BOOST_CHECK_LE( ( seg->GetEnd() -
VECTOR2I( 2 *
MM, 1 *
MM ) ).EuclideanNorm(), 5000.0 );
804 BOOST_CHECK_LE( ( rectTopLeft( rect ) -
VECTOR2I( 2 *
MM, 1 *
MM ) ).EuclideanNorm(), 5000.0 );
805 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 10 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
814 std::vector<VECTOR2I> pts = { { 0, 0 },
816 { 15 *
MM, 20 *
MM },
818 { -5 *
MM, 10 *
MM } };
831 fp->Add( onFootprint );
836 std::vector<BOARD_ITEM*> modified;
837 std::vector<BOARD_ITEM*> removed;
840 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
841 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
857 BOOST_CHECK( removed.empty() );
866 std::vector<VECTOR2I> pts = { { 0, 0 },
868 { 15 *
MM, 20 *
MM },
870 { -5 *
MM, 10 *
MM } };
881 std::vector<BOARD_ITEM*> removed;
885 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
893 BOOST_CHECK( removed.empty() );
902 std::vector<VECTOR2I> pts = { { 0, 0 },
904 { 15 *
MM, 20 *
MM },
906 { -5 *
MM, 10 *
MM } };
916 std::vector<BOARD_ITEM*> modified;
917 std::vector<BOARD_ITEM*> removed;
920 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
921 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
924 BOOST_REQUIRE_EQUAL( removed.size(), 1 );
925 BOOST_CHECK( removed[0] == c );
926 BOOST_CHECK( modified.empty() );
942 std::vector<VECTOR2I> pts = { { 0, 0 },
944 { 15 *
MM, 20 *
MM },
946 { -5 *
MM, 10 *
MM } };
962 VECTOR2I a = pts[k] + ( pts[k - 1] - pts[k] ) / 4;
963 VECTOR2I b = pts[k] + ( pts[k + 1] - pts[k] ) / 4;
969 std::vector<BOARD_ITEM*> modified;
970 std::vector<BOARD_ITEM*> removed;
972 auto modify = [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
973 auto remove = [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); };
988 BOOST_REQUIRE_EQUAL( removed.size(), 2 );
1004 std::vector<VECTOR2I> pts = { { 0, 0 },
1005 { 20 *
MM, 5 *
MM },
1006 { 15 *
MM, 20 *
MM },
1007 { 5 *
MM, 20 *
MM },
1008 { -5 *
MM, 10 *
MM } };
1011 std::vector<VECTOR2I> otherPts = { { 40 *
MM, 0 }, { 60 *
MM, 0 }, { 60 *
MM, 20 *
MM }, { 40 *
MM, 20 *
MM } };
1027 std::vector<BOARD_ITEM*> modified;
1028 std::vector<BOARD_ITEM*> removed;
1031 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
1032 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
1039 BOOST_CHECK( modified.empty() );
1040 BOOST_CHECK( removed.empty() );
1051 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1056 rect->
Rotate( pivot, angle );
1060 std::vector<VECTOR2I> rotated;
1066 rotated.push_back( p );
1074 tl.
x = std::min( tl.
x, p.x );
1075 tl.
y = std::min( tl.
y, p.y );
1076 br.
x = std::max( br.
x, p.x );
1077 br.
y = std::max( br.
y, p.y );
1081 BOOST_REQUIRE_EQUAL( after.size(), 4 );
1088 std::optional<VECTOR2I> v0 =
1093 BOOST_CHECK( *v0 != rotated[0] );
1105 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1107 PCB_DIM_ALIGNED* dim = addAlignedDim( board, before[0].pos, before[1].pos );
1110 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1112 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1116 const VECTOR2I pivot = rect->GetCenter();
1119 rect->Rotate( pivot, angle );
1124 BOOST_REQUIRE_EQUAL( outline.
PointCount(), 4 );
1127 for(
int i = 0; i < 4; ++i )
1132 std::optional<VECTOR2I> pos =
1136 BOOST_CHECK_LE( ( *pos -
expected ).EuclideanNorm(), 2.0 );
1143 checkRect(
addRect( board, { 0, 0 }, { 10 *
MM, 4 *
MM } ) );
1144 checkRect(
addRect( board, { 40 *
MM, 4 *
MM }, { 30 *
MM, 0 } ) );
1156 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1158 PCB_DIM_ALIGNED* dim = addAlignedDim( board, before[0].pos, before[1].pos );
1161 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1163 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1184 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), startBinding->
m_Uuid ) != unmapped.end() );
1185 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), endBinding->
m_Uuid ) != unmapped.end() );
1220 endBinding->
Members()[1].m_index = 7;
1231 std::vector<BOARD_ITEM*> modified;
1232 std::vector<BOARD_ITEM*> added;
1233 std::vector<BOARD_ITEM*> removed;
1235 std::function<void( BOARD_ITEM* )> modify()
1237 return [
this]( BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
1240 std::function<void( BOARD_ITEM* )> add()
1242 return [
this]( BOARD_ITEM* aItem )
1244 added.push_back( aItem );
1249 std::function<void( BOARD_ITEM* )> remove()
1251 return [
this]( BOARD_ITEM* aItem )
1253 removed.push_back( aItem );
1254 board.Remove( aItem );
1292 board.
Add( leader );
1310 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1312 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1317 MODE_STAGING toDriving{ board };
1320 toDriving.modify(), toDriving.add(), toDriving.remove() );
1329 BOOST_CHECK( toDriving.added[0] == driving );
1330 BOOST_CHECK( toDriving.removed.empty() );
1333 MODE_STAGING toArbitrary{ board };
1336 wxString( wxS(
"REF" ) ), toArbitrary.modify(), toArbitrary.add(),
1337 toArbitrary.remove() );
1346 MODE_STAGING toDriven{ board };
1348 toDriven.modify(), toDriven.add(), toDriven.remove() );
1351 BOOST_CHECK( !dim->GetOverrideTextEnabled() );
1352 BOOST_CHECK( toDriven.added.empty() );
1353 BOOST_CHECK( toDriven.removed.empty() );
1364 MODE_STAGING staging{ board };
1367 std::nullopt, staging.modify(), staging.add(),
1368 staging.remove() ) );
1374 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1376 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1379 std::nullopt, staging.modify(), staging.add(),
1380 staging.remove() ) );
1382 staging.modify(), staging.add(), staging.remove() ) );
1384 std::nullopt, staging.modify(), staging.add(),
1385 staging.remove() ) );
1389 board.
Add( leader );
1392 std::nullopt, staging.modify(), staging.add(),
1393 staging.remove() ) );
1395 BOOST_CHECK( staging.modified.empty() );
1396 BOOST_CHECK( staging.added.empty() );
1397 BOOST_CHECK( staging.removed.empty() );
1414 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1416 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1418 MODE_STAGING staging{ board };
1421 staging.modify(), staging.add(), staging.remove() );
1428 const VECTOR2I tl = rectTopLeft( rect );
1429 const VECTOR2I br = rectBottomRight( rect );
1431 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
1432 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
1436 BOOST_CHECK_LE( ( dim->GetStart() - tl ).EuclideanNorm(), 5000.0 );
1437 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( br.
x, tl.
y ) ).EuclideanNorm(), 5000.0 );
1452 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1454 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1457 board.
Add( leader );
1490 dim->ChangeValueFieldText( wxS(
"10 mm MAX" ) );
1497 MODE_STAGING staging{ board };
1499 staging.modify(), staging.add(), staging.remove() );
1501 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"0" ) ) ), dim ) );
1502 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"-3" ) ) ), dim ) );
1503 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"text" ) ) ), dim ) );
1504 BOOST_CHECK( !valueProp->
Validate( wxAny( wxString( wxS(
"15" ) ) ), dim ) );
1507 BOOST_CHECK( !valueProp->
Validate( wxAny( wxString( wxS(
"0" ) ) ), unbound ) );
1527 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1530 arc =
static_cast<PCB_SHAPE*
>( aItem.get() );
1532 board.
Add( aItem.release() );
1543 fillet.ProcessLinePair( *lineA, *lineB );
1554 const std::vector<CONSTRAINT_MEMBER>& members = constraint->GetMembers();
1556 if( members.size() != 2 )
1559 if( ( members[0] == aFirst && members[1] == aSecond ) || ( members[0] == aSecond && members[1] == aFirst ) )
1572 BOOST_CHECK( ( heldTogether( arcStart, cornerA ) && heldTogether( arcEnd, cornerB ) )
1573 || ( heldTogether( arcStart, cornerB ) && heldTogether( arcEnd, cornerA ) ) );
1576 BOOST_CHECK( !heldTogether( cornerA, cornerB ) );
1596 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1601 board.
Add( aItem.release() );
1623 const std::vector<CONSTRAINT_MEMBER>& members = constraint->GetMembers();
1625 if( members.size() != 2 )
1628 if( ( members[0] == aFirst && members[1] == aSecond ) || ( members[0] == aSecond && members[1] == aFirst ) )
1644 BOOST_CHECK( !heldTogether( cornerA, cornerB ) );
1651 const auto runDogbone = [](
const VECTOR2I& aFarB,
bool aAddSlots, std::vector<PCB_SHAPE*>& aInserted,
1652 BOARD& aBoard ) -> std::pair<PCB_SHAPE*, PCB_SHAPE*>
1661 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1664 aInserted.push_back(
static_cast<PCB_SHAPE*
>( aItem.get() ) );
1666 aBoard.
Add( aItem.release() );
1679 return { lineA, lineB };
1689 const std::vector<CONSTRAINT_MEMBER>& members = constraint->GetMembers();
1691 if( members.size() != 2 )
1694 if( members[0] == aMember )
1697 if( members[1] == aMember )
1701 return std::nullopt;
1712 const std::vector<CORNER> corners = { { { 20 *
MM, 20 *
MM },
false, 1 }, { { 10 *
MM, 10 *
MM },
true, 3 } };
1714 for(
const CORNER& corner : corners )
1717 std::vector<PCB_SHAPE*> inserted;
1719 auto [lineA, lineB] = runDogbone( corner.farB, corner.addSlots, inserted, board );
1721 BOOST_REQUIRE_EQUAL( inserted.size(), corner.inserted );
1727 BOOST_CHECK( atA && *atA == lineA->GetEnd() );
1728 BOOST_CHECK( atB && *atB == lineB->GetEnd() );
CONSTRAINT_DIAGNOSIS ApplyConstraintImmediately(BOARD *aBoard, const PCB_CONSTRAINT *aConstraint, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::set< KIID > &aFixedShapes)
Solve a just-created constraint's cluster so the geometry snaps to satisfy it (SolidWorks-style),...
CONSTRAINT_DIAGNOSIS SolveCluster(BOARD *aBoard, const CONSTRAINT_MEMBER &aDragged, const VECTOR2I &aCursor, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify, bool aIncludeDragged, bool aStabilize, const std::set< KIID > &aEdited, const std::optional< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aCoDragged, const std::set< KIID > &aFixedShapes, bool aHoldDraggedRigid)
Gather the cluster of shapes transitively constrained with the dragged shape, solve with the dragged ...
void ReSolveShapeClusters(BOARD *aBoard, const std::vector< PCB_SHAPE * > &aShapes, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Re-solve the clusters of shapes edited outside the solver, e.g.
bool ReSolveShapeClustersHoldingEdited(BOARD *aBoard, const std::vector< PCB_SHAPE * > &aEditedShapes, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Re-solve clusters whose new geometry is authoritative holding every edited shape fully fixed so only ...
BOARD_CONSTRAINT_DIAGNOSTICS DiagnoseBoardConstraints(BOARD *aBoard)
Diagnose every constraint cluster on the board (validate only – geometry is not changed) and return t...
Translates KiCad board geometry to and from the planegcs solver (issue #2329).
bool Solve(const CONSTRAINT_MEMBER &aDragged, const VECTOR2I &aCursor, bool aStabilize=false, const std::set< KIID > &aEdited={}, const std::optional< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aCoDragged=std::nullopt, bool aHoldDraggedRigid=false)
Solve the system, pinning a dragged anchor to a cursor position.
const std::vector< KIID > & UnmappedConstraints() const
Constraints from the last Build() that could not be mapped onto a solver primitive (wrong member coun...
bool Build(const std::vector< PCB_SHAPE * > &aShapes, const std::vector< PCB_CONSTRAINT * > &aConstraints, const std::set< KIID > *aFixedShapes=nullptr, const std::vector< PCB_DIMENSION_BASE * > &aDimensions={})
Translate a cluster into a planegcs system.
std::vector< PCB_SHAPE * > Apply(const std::function< void(BOARD_ITEM *)> &aBeforeWrite={})
Write the solved coordinates back into the shapes, de-normalized to IU.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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.
const CONSTRAINTS & Constraints() const
Geometric constraints (#2329) owned by this board.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Pairwise add dogbone corners to an internal corner.
void ProcessLinePair(PCB_SHAPE &aLineA, PCB_SHAPE &aLineB) override
Perform the action on the pair of lines given.
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
A handler that is based on a set of callbacks provided by the user of the ITEM_MODIFICATION_ROUTINE.
Pairwise line tool that adds a chamfer between the lines.
void ProcessLinePair(PCB_SHAPE &aLineA, PCB_SHAPE &aLineB) override
Perform the action on the pair of lines given.
Pairwise line tool that adds a fillet to the lines.
A geometric constraint between board items (issue #2329).
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
std::optional< double > GetValue() const
bool IsDriving() const
A driving constraint forces its value; a reference (non-driving) one only measures it.
void AddMember(const KIID &aItem, CONSTRAINT_ANCHOR aAnchor=CONSTRAINT_ANCHOR::WHOLE, int aIndex=-1)
void SetDriving(bool aDriving)
std::vector< CONSTRAINT_MEMBER > & Members()
void Update()
Update the dimension's cached text and geometry.
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
void ChangeOverrideText(const wxString &aValue)
void SetOverrideTextEnabled(bool aOverride)
DIM_VALUE_MODE GetValueMode() const
Value mode from board state via DimensionValueMode.
virtual VECTOR2I GetEnd() const
virtual VECTOR2I GetStart() const
The dimension's origin is the first feature point for the dimension.
For better understanding of the points that make a dimension:
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
A radial dimension indicates either the radius or diameter of an arc or circle.
void SetCornerRadius(int aCornerRadius) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void SetEnd(const VECTOR2I &aEnd) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetStart(const VECTOR2I &aStart) override
VALIDATOR_RESULT Validate(const wxAny &&aValue, EDA_ITEM *aItem)
bool IsWriteableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
static PROPERTY_MANAGER & Instance()
void Rebuild()
Rebuild the list of all registered properties.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
bool IsAvailableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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.
void InsertVertex(int aGlobalIndex, const VECTOR2I &aNewVertex)
Adds a vertex in the globally indexed position aGlobalIndex.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
void RemoveVertex(int aGlobalIndex)
Delete the aGlobalIndex-th vertex.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
std::vector< ENDPOINT_BINDING > SelectEndpointBindings(const BOARD *aBoard, const KIID &aItem, const VECTOR2I &aStart, const std::optional< VECTOR2I > &aEnd, double aMaxDist, PCB_LAYER_ID aLayer)
Choose the coincident bindings a freshly drawn item endpoints should take so it tracks the geometry i...
void RemapPolygonVertexMembers(BOARD *aBoard, const KIID &aPoly, int aChangedIndex, int aDelta, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::function< void(BOARD_ITEM *)> &aBeforeRemove)
Repoint persisted VERTEX constraint members after an outline edit of polygon aPoly inserts or removes...
bool DimensionHasValueMode(const PCB_DIMENSION_BASE *aDimension)
True for dimension types with a measured value aligned orthogonal or radial offering the Driven Drivi...
std::optional< CONSTRAINT_MEMBER > NearestConstraintAnchor(const BOARD *aBoard, const VECTOR2I &aPos, double aMaxDist, const std::vector< CONSTRAINT_MEMBER > &aExclude, PCB_LAYER_ID aLayer)
Find the constrainable-item anchor (a shape's segment/arc endpoint or centre, or a dimension's featur...
std::vector< CONSTRAINT_ANCHOR_POINT > ConstraintItemAnchors(const BOARD_ITEM *aItem)
The constraint anchors an item exposes.
bool DimensionCanDrive(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpoint...
std::vector< CONSTRAINT_ANCHOR_POINT > ConstraintShapeAnchors(const PCB_SHAPE *aShape)
Enumerate a shape constraint anchors with positions segment and arc endpoints arc centre circle centr...
std::optional< KIID > SelectRadialDimensionTarget(const BOARD *aBoard, const KIID &aDimension, const VECTOR2I &aCenter, const VECTOR2I &aRim, double aMaxDist)
Single circle or arc a radial dimension binds to or std::nullopt.
DIM_VALUE_MODE DimensionValueMode(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
The value mode aDimension is in, derived from state: a self driving length means Driving,...
PCB_CONSTRAINT * FindDimensionLengthConstraint(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the drivin...
std::optional< VECTOR2I > ConstraintAnchorPosition(const BOARD *aBoard, const CONSTRAINT_MEMBER &aMember)
Current location of a constraint member's anchor (its shape's START/END/CENTER, or a dimension's feat...
bool DimensionEndpointsBound(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
True when both of aDimension measured endpoints are bound to anchors that still resolve a coincident ...
PCB_CONSTRAINT * SetDimensionValueMode(BOARD *aBoard, PCB_DIMENSION_BASE *aDimension, DIM_VALUE_MODE aMode, std::optional< int > aDrivingLengthIU, const std::optional< wxString > &aOverrideText, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::function< void(BOARD_ITEM *)> &aStageAdd, const std::function< void(BOARD_ITEM *)> &aBeforeRemove)
Apply a value mode transition to aDimension Driving creates or updates the driving length with aDrivi...
static bool empty(const wxTextEntryBase *aCtrl)
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Some functions to handle hotkeys in KiCad.
Test utilities for timestamps.
PCB_SHAPE * addSegment(BOARD &aBoard, const VECTOR2I &aStart, const VECTOR2I &aEnd)
PCB_SHAPE * addPoly(BOARD &aBoard, const std::vector< VECTOR2I > &aPoints)
PCB_SHAPE * addCircle(BOARD &aBoard, const VECTOR2I &aCenter, int aRadius)
PCB_CONSTRAINT * addConstraint(BOARD &aBoard, PCB_CONSTRAINT_TYPE aType, const std::vector< CONSTRAINT_MEMBER > &aMembers, std::optional< double > aValue=std::nullopt)
PCB_SHAPE * addRect(BOARD &aBoard, const VECTOR2I &aStart, const VECTOR2I &aEnd)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
CONSTRAINT_ANCHOR
Which feature of a referenced board item participates in a constraint.
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
@ WHOLE
The item as a whole (a segment as a line, a circle).
@ START
First endpoint of a segment or arc.
@ END
Second endpoint of a segment or arc.
@ CENTER
Center of an arc or circle.
@ FIXED_POSITION
A point is locked at its current location.
@ COINCIDENT
Two points are made to coincide.
@ POINT_ON_LINE
A point lies on a segment's supporting line.
@ FIXED_LENGTH
A segment has a driving length value.
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
Board-wide diagnostics for the constraint overlay and info bar.
std::vector< KIID > errored
Invalid constraints (member missing, deleted, or of a kind incompatible with the type).
Parameters that define a simple chamfer operation.
A selectable feature of a shape (a segment endpoint, arc centre, ...) and its location.
The outcome of a constraint solve, in plain data so callers need not know planegcs.
bool solved
Solver reached Success or Converged.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
One of a drawn item feature points bound coincident to an object anchor by draw time auto constrain s...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(DimensionAnchorsPerFamily)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
const SHAPE_LINE_CHAIN chain
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
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_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
VECTOR2< int32_t > VECTOR2I