44constexpr int MM = 1000000;
55 return { aKind, targetId( aName ) };
63 KI_TEST::DUMMY_TOOL* tool;
66 tool( new KI_TEST::DUMMY_TOOL() )
68 mgr.SetEnvironment( &board,
nullptr,
nullptr,
nullptr,
nullptr );
69 mgr.RegisterTool( tool );
101 rect->SetStart( aStart );
102 rect->SetEnd( aEnd );
107 PCB_SHAPE*
addPoly(
const std::vector<VECTOR2I>& aPoints )
115 PCB_CONSTRAINT* addHorizontal( PCB_SHAPE* aShape )
131 PCB_CONSTRAINT* addCoincident( PCB_SHAPE* aA,
CONSTRAINT_ANCHOR aAnchorA, PCB_SHAPE* aB,
147 std::vector<PCB_SHAPE*>* aModified )
154 aShape->
SetEnd( aCursor );
161 aCommit.
Modify( aNeighbor );
180 const VECTOR2I bStart0 = b->GetStart();
182 std::vector<PCB_SHAPE*> modified;
188 BOOST_CHECK_LE( ( a->
GetEnd() - b->GetStart() ).EuclideanNorm(), 100 );
189 BOOST_CHECK( std::find( modified.begin(), modified.end(), b ) != modified.end() );
207 std::vector<PCB_SHAPE*> modified;
210 const VECTOR2I originalBStart = b->GetStart();
217 { 12 *
MM, 2 *
MM }, &modified,
224 BOOST_CHECK_LE( ( a->
GetEnd() - b->GetStart() ).EuclideanNorm(), 100 );
227 { 14 *
MM, 4 *
MM }, &modified,
234 BOOST_CHECK_LE( ( a->
GetEnd() - b->GetStart() ).EuclideanNorm(), 100 );
249 length->SetValue( 10.0 *
MM );
267 length->SetValue( 10.0 *
MM );
272 board.
Add( horizontal );
317 std::vector<PCB_SHAPE*> modified;
330 ellipse->SetEllipseCenter( { 30 *
MM, 0 } );
331 ellipse->SetEllipseMajorRadius( 6 *
MM );
332 ellipse->SetEllipseMinorRadius( 3 *
MM );
333 board.
Add( ellipse );
335 const int circleRadius =
circle->GetRadius();
336 const int arcRadius = arc->GetRadius();
337 const int ellipseMinorRadius = ellipse->GetEllipseMinorRadius();
342 adapter.
SolveRigidTranslation( { circle->m_Uuid, arc->m_Uuid, ellipse->m_Uuid }, { 3 * MM, 2 * MM } ) );
369 locked->SetLocked(
true );
390 locked->SetLocked(
true );
393 auto session = std::make_shared<BOARD_CONSTRAINT_MOVE_SESSION>();
394 BOOST_REQUIRE( session->Build( &board, { moved }, { 0, 0 } ) );
407 return SNAP_RESOLVER::CLOCK::time_point();
410 [session](
const SNAP_SOURCE_CONTEXT& aContext,
const std::vector<SNAP_CANDIDATE>& aCandidates )
412 return session->ResolveCandidates( aContext, aCandidates );
434 auto session = std::make_shared<BOARD_CONSTRAINT_MOVE_SESSION>();
435 BOOST_REQUIRE( session->Build( &board, { moved }, { 0, 0 } ) );
446 [session](
const SNAP_SOURCE_CONTEXT& aContext,
const std::vector<SNAP_CANDIDATE>& aCandidates )
448 return session->ResolveCandidates( aContext, aCandidates );
479 { 0.0, 40.0 *
MM }, 0.0 );
501 secondGuide->SetLocked(
true );
506 board.
Add( firstOnLine );
511 board.
Add( secondOnLine );
531 board.
Add( horizontal );
540 { 0.0, 40.0 *
MM }, 0.0 );
561 length->SetValue( 10.0 *
MM );
594 board.
Add( horizontal );
600 std::vector<PCB_SHAPE*> modified;
627 std::vector<PCB_SHAPE*> modified;
656 BOOST_CHECK_LE( (
right->GetStart() -
VECTOR2I( 12 *
MM, 3 *
MM ) ).EuclideanNorm(), 1000 );
657 BOOST_CHECK_LE( ( bottom->
GetEnd() -
right->GetStart() ).EuclideanNorm(), 1000 );
702 std::vector<PCB_SHAPE*>
moved;
707 BOOST_CHECK_LE( ( bottom->
GetEnd() -
right->GetStart() ).EuclideanNorm(), 1000 );
723 std::vector<PCB_SHAPE*> modified;
729 BOOST_CHECK_LE( ( a->
GetCenter() - b->GetCenter() ).EuclideanNorm(), 2000 );
730 BOOST_CHECK( std::find( modified.begin(), modified.end(), b ) != modified.end() );
750 const VECTOR2I bStart0 = b->GetStart();
753 std::vector<PCB_SHAPE*> modified;
785 commit.
Push( wxT(
"delete segment" ) );
792 bool referencesDeleted =
false;
796 if( m.m_item == aId )
797 referencesDeleted =
true;
825 seg->Move( { 0, 3 *
MM } );
828 std::vector<PCB_SHAPE*> modified;
832 BOOST_CHECK_LE(
std::abs( seg->GetEnd().y ), 5000 );
833 BOOST_CHECK_LE( ( seg->GetStart() -
VECTOR2I( 2 *
MM, 8 *
MM ) ).EuclideanNorm(), 5000.0 );
836 BOOST_CHECK( std::find( modified.begin(), modified.end(), seg ) != modified.end() );
851 const VECTOR2I bStart0 = b->GetStart();
856 std::vector<PCB_SHAPE*> modified;
865 BOOST_CHECK_LE( ( a->
GetEnd() - b->GetStart() ).EuclideanNorm(), 100 );
886 std::vector<PCB_SHAPE*> modified;
897 const std::array<VECTOR2I, 4> painted = { a->
GetStart(), a->
GetEnd(), b->GetStart(), b->GetEnd() };
899 commit.
Push( wxT(
"Move" ) );
901 const std::array<VECTOR2I, 4> committed = { a->
GetStart(), a->
GetEnd(), b->GetStart(), b->GetEnd() };
917 const VECTOR2I bStart0 = b->GetStart();
920 std::vector<PCB_SHAPE*> modified;
942 len->SetValue( 10.0 *
MM );
947 std::vector<PCB_SHAPE*> modified;
955 BOOST_CHECK_LE( ( seg->
GetStart() - start0 ).EuclideanNorm(), 5000.0 );
959 BOOST_CHECK_LE( ( seg->
GetEnd() -
VECTOR2I( 6 *
MM, 8 *
MM ) ).EuclideanNorm(), 20000.0 );
973 len->SetValue( 10.0 *
MM );
978 std::vector<PCB_SHAPE*> modified;
984 BOOST_CHECK_LE( ( seg->
GetStart() - start0 ).EuclideanNorm(), 5000.0 );
986 BOOST_CHECK_LE( ( seg->
GetEnd() -
VECTOR2I( 10 *
MM, 0 ) ).EuclideanNorm(), 20000.0 );
996 PCB_SHAPE* arc = addArc( { 10 *
MM, 0 }, { 7071068, 7071068 }, { 0, 10 *
MM } );
1006 std::vector<PCB_SHAPE*> modified;
1011 BOOST_CHECK_LE( ( arc->
GetCenter() - center0 ).EuclideanNorm(), 20000.0 );
1013 BOOST_CHECK_LE( ( arc->
GetEnd() - end0 ).EuclideanNorm(), 20000.0 );
1022 PCB_SHAPE* arc = addArc( { 10 *
MM, 0 }, { 7071068, 7071068 }, { 0, 10 *
MM } );
1026 r->SetValue( 12.0 *
MM );
1029 std::vector<PCB_SHAPE*> modified;
1056 std::vector<PCB_SHAPE*> modified;
1062 std::min(
rect->GetStart().y,
rect->GetEnd().y ) );
1064 std::max(
rect->GetStart().y,
rect->GetEnd().y ) );
1067 BOOST_CHECK_LE( (
VECTOR2I( br.
x, tl.y ) -
cursor ).EuclideanNorm(), 5000.0 );
1068 BOOST_CHECK_LE( ( seg->GetStart() -
cursor ).EuclideanNorm(), 5000.0 );
1071 BOOST_CHECK_LE( (
VECTOR2I( tl.x, br.
y ) -
VECTOR2I( 0, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
1079 const std::vector<VECTOR2I> points{ { 0, 0 },
1081 { 13 *
MM, 8 *
MM },
1082 { 5 *
MM, 14 *
MM },
1083 { -3 *
MM, 8 *
MM } };
1096 std::vector<PCB_SHAPE*> modified;
1104 BOOST_CHECK_LE( ( outline.CPoint( 2 ) -
cursor ).EuclideanNorm(), 5000.0 );
1106 for(
int i : { 0, 1, 3, 4 } )
1107 BOOST_CHECK_LE( ( outline.CPoint( i ) - points[i] ).EuclideanNorm(), 5000.0 );
1117 PCB_SHAPE* swapped = addRect( { 10 *
MM, 10 *
MM }, { 0, 0 } );
1121 const std::vector<VECTOR2I> corners{ { 0, 0 },
1123 { 10 *
MM, 10 *
MM },
1126 for(
size_t i = 0; i < corners.size(); ++i )
1150 const std::vector<VECTOR2I> points{ { 0, 0 },
1152 { 13 *
MM, 8 *
MM },
1153 { 5 *
MM, 14 *
MM },
1154 { -3 *
MM, 8 *
MM } };
1158 for(
size_t i = 0; i < points.size(); ++i )
1177 chain.SetClosed(
true );
1180 board.
Add( arcPoly );
1211 std::vector<PCB_SHAPE*> modified;
1213 SolveCluster( &board, {
rect->m_Uuid, vertex->anchor, vertex->index }, vertex->pos, &modified,
1216 BOOST_CHECK_LE( ( seg->GetStart() -
cursor ).EuclideanNorm(), 5000.0 );
1235 const int minWidth = 25400;
1236 const VECTOR2I clamped( minWidth, rawCursor.
y );
1238 rect->SetTop( clamped.
y );
1239 rect->SetRight( clamped.
x );
1247 std::vector<PCB_SHAPE*> modified;
1249 SolveCluster( &board, {
rect->m_Uuid, vertex->anchor, vertex->index }, vertex->pos, &modified,
1252 BOOST_CHECK_LE( ( seg->GetStart() - clamped ).EuclideanNorm(), 5000.0 );
1292 addDrivingVertexLength( board,
rect, 0, 1, 10.0 *
MM );
1295 rect->SetRight( 15 *
MM );
1303 std::vector<PCB_SHAPE*> modified;
1305 SolveCluster( &board, {
rect->m_Uuid, corner->anchor, corner->index }, corner->pos, &modified,
1312 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.x ) - 10 *
MM ), 20000 );
1313 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.y ) - 10 *
MM ), 20000 );
1316 BOOST_CHECK_GT( tl.x, 1 *
MM );
1317 BOOST_CHECK_LT( br.
x, 14 *
MM );
1319 BOOST_TEST_MESSAGE(
"side drag under driving width settled TL at " << tl.x <<
"," << tl.y );
1336 addDrivingVertexLength( board,
rect, 0, 1, 10.0 *
MM );
1339 rect->SetBottom( 15 *
MM );
1346 std::vector<PCB_SHAPE*> modified;
1348 SolveCluster( &board, {
rect->m_Uuid, corner->anchor, corner->index }, corner->pos, &modified,
1354 BOOST_CHECK_LE( tl.EuclideanNorm(), 5000.0 );
1355 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.x ) - 10 *
MM ), 5000 );
1356 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.y ) - 15 *
MM ), 5000 );
1372 rect->SetRight( 15 *
MM );
1378 std::vector<PCB_SHAPE*> modified;
1380 SolveCluster( &board, {
rect->m_Uuid, corner->anchor, corner->index }, corner->pos, &modified,
1383 BOOST_CHECK_LE( dragRectTopLeft(
rect ).EuclideanNorm(), 5000.0 );
1384 BOOST_CHECK_LE( ( dragRectBotRight(
rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
1385 BOOST_CHECK_LE( seg->GetStart().EuclideanNorm(), 5000.0 );
1393 const std::vector<VECTOR2I> points{ { 0, 0 },
1395 { 13 *
MM, 8 *
MM },
1396 { 5 *
MM, 14 *
MM },
1397 { -3 *
MM, 8 *
MM } };
1400 const double edgeLen = std::hypot( 3.0, 8.0 ) *
MM;
1402 addDrivingVertexLength( board, poly, 1, 2, edgeLen );
1405 std::vector<VECTOR2I> dragged = points;
1406 dragged[1] = { 8 *
MM, -2 *
MM };
1407 dragged[2] = { 16 *
MM, 9 *
MM };
1410 std::vector<PCB_SHAPE*> modified;
1419 double solvedLen = ( outline.CPoint( 2 ) - outline.CPoint( 1 ) ).EuclideanNorm();
1421 BOOST_CHECK_LE(
std::abs( solvedLen - edgeLen ), 20000.0 );
1425 const VECTOR2I midBefore = ( points[1] + points[2] ) / 2;
1426 const VECTOR2I midTarget = ( dragged[1] + dragged[2] ) / 2;
1427 const VECTOR2I midSolved = ( outline.CPoint( 1 ) + outline.CPoint( 2 ) ) / 2;
1429 BOOST_CHECK_LT( ( midSolved - midTarget ).EuclideanNorm(), ( midBefore - midTarget ).EuclideanNorm() );
1430 BOOST_CHECK_GT( ( midSolved - midBefore ).EuclideanNorm(), 250000.0 );
1432 for(
int i : { 0, 3, 4 } )
1433 BOOST_CHECK_LE( ( outline.CPoint( i ) - points[i] ).EuclideanNorm(), 5000.0 );
1441 const std::vector<VECTOR2I> points{ { 0, 0 },
1443 { 13 *
MM, 8 *
MM },
1444 { 5 *
MM, 14 *
MM },
1445 { -3 *
MM, 8 *
MM } };
1456 std::vector<VECTOR2I> dragged = points;
1461 std::vector<PCB_SHAPE*> modified;
1470 BOOST_CHECK_LE( ( outline.CPoint( 1 ) - dragged[1] ).EuclideanNorm(), 5000.0 );
1471 BOOST_CHECK_LE( ( outline.CPoint( 2 ) - dragged[2] ).EuclideanNorm(), 5000.0 );
1472 BOOST_CHECK_LE( ( seg->
GetStart() - dragged[1] ).EuclideanNorm(), 5000.0 );
1473 BOOST_CHECK( std::find( modified.begin(), modified.end(), seg ) != modified.end() );
1475 for(
int i : { 0, 3, 4 } )
1476 BOOST_CHECK_LE( ( outline.CPoint( i ) - points[i] ).EuclideanNorm(), 5000.0 );
1483 PCB_SHAPE* arc = addArc( { 10 *
MM, 0 }, { 7071068, 7071068 }, { 0, 10 *
MM } );
1491 std::vector<PCB_SHAPE*> modified;
1499 BOOST_CHECK_LE( ( arc->
GetStart() - start0 ).EuclideanNorm(), 20000.0 );
1500 BOOST_CHECK_LE( ( arc->
GetEnd() - end0 ).EuclideanNorm(), 20000.0 );
1522 std::vector<PCB_SHAPE*>
moved;
1555 std::vector<PCB_SHAPE*>
moved;
1589 free->SetEnd( target );
1591 std::vector<PCB_SHAPE*>
moved;
1625 std::vector<PCB_SHAPE*>
moved;
1647 addHorizontal( holds );
1648 addHorizontal( stale );
1660 std::vector<PCB_SHAPE*>
moved;
1683 addHorizontal( stale );
1694 std::vector<PCB_SHAPE*>
moved;
1727 commit.
Modify( deformed );
1728 commit.
Modify( carried );
1730 carried->Move(
delta );
1732 std::vector<PCB_SHAPE*>
moved;
1750 BOOST_CHECK_LE( ( deformed->
GetEnd() - carried->GetStart() ).EuclideanNorm(), 100 );
1770 const VECTOR2I neighborEnd0 = neighbor->GetEnd();
1773 commit.
Modify( deformed );
1774 deformed->
SetEnd( target );
1776 std::vector<PCB_SHAPE*>
moved;
1777 std::vector<BOARD_ITEM*> staged;
1783 staged.push_back( aItem );
1789 BOOST_CHECK_LE( ( neighbor->GetStart() - target ).EuclideanNorm(), 100 );
1796 BOOST_CHECK( std::find( staged.begin(), staged.end(), neighbor ) != staged.end() );
1817 commit.
Modify( carried );
1819 carried->Move(
delta );
1821 std::vector<PCB_SHAPE*>
moved;
1853 const VECTOR2I anchoredStart0 = anchored->GetStart();
1856 commit.
Modify( carried );
1859 std::vector<PCB_SHAPE*>
moved;
1884 locked->SetLocked(
true );
1896 std::vector<PCB_SHAPE*>
moved;
1905 BOOST_CHECK_LE( ( neighbor->GetStart() -
locked->GetEnd() ).EuclideanNorm(), 100 );
1919 dim->SetStart( { 10 *
MM, 0 } );
1920 dim->SetEnd( { 10 *
MM, 5 *
MM } );
1935 commit.
Modify( deformed );
1942 { dim->m_Uuid },
delta,
nullptr,
1960 const std::vector<VECTOR2I> points{ { 0, 0 }, { 10 *
MM, 0 }, { 10 *
MM, 10 *
MM }, { 0, 10 *
MM } };
1977 commit.
Modify( carried );
1979 std::vector<VECTOR2I> deformed = points;
1980 deformed[2] +=
delta;
1984 std::vector<PCB_SHAPE*>
moved;
1999 BOOST_CHECK_LE( ( outline.
CPoint( 0 ) - carried->
GetStart() ).EuclideanNorm(), 100 );
2000 BOOST_CHECK_LE( ( outline.
CPoint( 0 ) -
VECTOR2I( 2 *
MM, 0 ) ).EuclideanNorm(), 100 );
2002 for(
int i : { 1, 3 } )
2003 BOOST_CHECK_LE( ( outline.
CPoint( i ) - points[i] ).EuclideanNorm(), 100 );
2013 const std::vector<VECTOR2I>
path{ { 0, 2 *
MM }, { 0, 5 *
MM } };
2015 const auto run = [&](
const std::vector<VECTOR2I>& aDeltas ) -> std::pair<VECTOR2I, VECTOR2I>
2020 deformed->
SetEnd( { 10 *
MM, 0 } );
2021 runBoard.
Add( deformed );
2026 runBoard.
Add( neighbor );
2043 {},
delta,
nullptr, {} );
2051 const std::pair<VECTOR2I, VECTOR2I> wandered = run(
path );
2052 const std::pair<VECTOR2I, VECTOR2I> direct = run( {
path.back() } );
2072 const VECTOR2I neighborStart0 = neighbor->GetStart();
2074 std::vector<PCB_SHAPE*>
moved;
2095 const VECTOR2I bStart0 = b->GetStart();
2116 const std::vector<VECTOR2I> polyPoints{ { 0, 0 }, { 10 *
MM, 0 }, { 13 *
MM, 8 *
MM }, { -3 *
MM, 8 *
MM } };
2119 const auto makeProbe = [&](
bool aRectangle, std::unique_ptr<BOARD>& aBoard ) ->
PCB_SHAPE*
2121 aBoard = std::make_unique<BOARD>();
2135 aBoard->
Add( shape );
2139 for(
bool rectangle : {
true,
false } )
2141 std::unique_ptr<BOARD> sizingBoard;
2146 for(
size_t ii = 0; ii < anchorCount; ++ii )
2148 std::unique_ptr<BOARD> probeBoard;
2149 PCB_SHAPE* probe = makeProbe( rectangle, probeBoard );
2154 const VECTOR2I target = before[ii].pos + nudge;
2172 for(
size_t jj = 0; jj < anchorCount; ++jj )
2174 if( jj != ii && rectangle )
static double square(double x)
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.
CONSTRAINT_BLOCK_RESULT
How a block edit solve turned out.
@ REFUSED
No arrangement fits the pinned points, and the geometry is untouched.
@ SOLVED
The constraints hold and every pinned point is exactly where it was put.
@ NOT_MODELED
Nothing the caller pinned belongs to this cluster.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
void Revert() override
Revert the commit by restoring the modified items state.
Translates KiCad board geometry to and from the planegcs solver (issue #2329).
bool SolveRigidTranslation(const std::set< KIID > &aEditedShapes, const VECTOR2I &aTranslation)
std::vector< PCB_SHAPE * > Apply(const std::function< void(BOARD_ITEM *)> &aBeforeWrite={})
Write the solved coordinates back into the shapes, de-normalized to IU.
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={}, const std::vector< PAD * > &aPads={})
Translate a cluster into a planegcs system.
CONSTRAINT_BLOCK_RESULT SolveBlockEdit(const std::vector< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aPinnedAnchors, const std::set< KIID > &aTranslatedShapes, const VECTOR2I &aTranslation)
Solve a block edit whose geometry the caller has already written.
One block edit session, holding several anchors and one travel offset at once.
bool Build(BOARD *aBoard, const std::vector< BOARD_ITEM * > &aBlockItems)
Build one adapter over the clusters holding aBlockItems.
CONSTRAINT_BLOCK_RESULT Solve(const std::vector< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aPinnedAnchors, const std::set< KIID > &aTranslatedShapes, const VECTOR2I &aTranslation, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Solve one frame of the block edit and apply it.
bool IsExactFeasible(const VECTOR2I &aTarget)
bool Build(BOARD *aBoard, const CONSTRAINT_MEMBER &aDragged)
CONSTRAINT_DIAGNOSIS Solve(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=std::nullopt)
SNAP_RESULT ResolveCandidates(const SNAP_SOURCE_CONTEXT &aContext, const std::vector< SNAP_CANDIDATE > &aCandidates)
bool Matches(const CONSTRAINT_MEMBER &aDragged) const
bool Solve(const VECTOR2I &aTarget, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
bool Build(BOARD *aBoard, const std::vector< PCB_SHAPE * > &aEditedShapes, const VECTOR2I &aReference)
SNAP_RESULT ResolveCandidates(const SNAP_SOURCE_CONTEXT &aContext, const std::vector< SNAP_CANDIDATE > &aCandidates)
bool HasBaseConflict() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetLocked(bool aLocked) override
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.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
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)
std::array< uint8_t, 16 > AsBytes() const
static KIID FromName(const std::string &aName)
Return a KIID derived from a name, the same name always gives the same KIID.
A geometric constraint between board items (issue #2329).
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
void AddMember(const KIID &aItem, CONSTRAINT_ANCHOR aAnchor=CONSTRAINT_ANCHOR::WHOLE, int aIndex=-1)
void SetValue(std::optional< double > aValue)
void SetDriving(bool aDriving)
For better understanding of the points that make a dimension:
void SetCenter(const VECTOR2I &aCenter) override
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetEnd(const VECTOR2I &aEnd) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetStart(const VECTOR2I &aStart) override
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) override
Set the three controlling points for an arc.
void SetRadius(int aRadius)
void SetCenter(const VECTOR2I &aCenter)
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.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
SNAP_RESULT Resolve(const SNAP_SOURCE_CONTEXT &aContext) const
void SetFeasibilityCallback(FEASIBILITY_CALLBACK aCallback)
void SetClock(CLOCK_CALLBACK aClock)
void AddCandidate(SNAP_CANDIDATE aCandidate)
std::optional< CONSTRAINT_ANCHOR_POINT > ConstraintShapeVertex(const PCB_SHAPE *aShape, int aIndex)
VERTEX anchor at ordinal aIndex of a rectangle or eligible polygon or std::nullopt if the shape has n...
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...
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
PCB_SHAPE * addPoly(BOARD &aBoard, const std::vector< VECTOR2I > &aPoints)
PCB_SHAPE * addArc(BOARD &aBoard, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
PCB_SHAPE * addCircle(BOARD &aBoard, const VECTOR2I &aCenter, int aRadius)
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.
@ CONCENTRIC
Two arcs/circles share a center.
@ FIXED_POSITION
A point is locked at its current location.
@ COINCIDENT
Two points are made to coincide.
@ PERPENDICULAR
Two segments are perpendicular.
@ FIXED_RADIUS
An arc/circle has a driving radius value.
@ HORIZONTAL
A segment (or two points) is horizontal.
@ POINT_ON_LINE
A point lies on a segment's supporting line.
@ FIXED_LENGTH
A segment has a driving length value.
static bool addSegment(VRML_LAYER &model, IDF_SEGMENT *seg, int icont, int iseg)
std::array< uint8_t, 16 > SNAP_TARGET_ID
The outcome of a constraint solve, in plain data so callers need not know planegcs.
bool solved
Solver reached Success or Converged.
std::vector< KIID > conflicting
Constraints the solver reports as over-constraining.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
static SNAP_CANDIDATE Point(SNAP_STABLE_ID aId, SNAP_PRIORITY_TIER aPriority, SNAP_CANDIDATE_SUBTYPE aSubtype, const VECTOR2I &aPoint, double aResidual)
static SNAP_CANDIDATE Line(SNAP_STABLE_ID aId, SNAP_PRIORITY_TIER aPriority, SNAP_CANDIDATE_SUBTYPE aSubtype, const VECTOR2I &aOrigin, const VECTOR2D &aDirection, double aResidual)
static SNAP_CANDIDATE AxisX(SNAP_STABLE_ID aId, SNAP_PRIORITY_TIER aPriority, SNAP_CANDIDATE_SUBTYPE aSubtype, int aCoordinate, double aResidual)
std::vector< SNAP_GUIDE > guides
SNAP_RESULT_STATUS status
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_FIXTURE_TEST_CASE(DragReDerivesNeighborRevertRestores, DRAG_FIXTURE)
BOOST_AUTO_TEST_CASE(UnbuiltMoveSessionRejectsCandidates)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_CHECK_EQUAL_COLLECTIONS(mixed.begin(), mixed.end(), expMixed.begin(), expMixed.end())
BOOST_AUTO_TEST_SUITE_END()
static const long long MM
const SHAPE_LINE_CHAIN chain
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.
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
VECTOR2< int32_t > VECTOR2I
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)