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 );
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 =
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 );
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 =
400 const double tol = 10000;
416 std::vector<ENDPOINT_BINDING> bindings =
443 const double tol = 0.01 *
MM;
446 std::vector<ENDPOINT_BINDING> bindings =
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 );
483 std::optional<VECTOR2I> pos =
498 { 10 *
MM, 10 *
MM },
503 std::vector<ENDPOINT_BINDING> bindings =
528 chain.SetClosed(
true );
549 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
551 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
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 );
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 } );
639 rect->SetEnd( { 15 *
MM, 10 *
MM } );
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 } );
675 rect->SetEnd( { 15 *
MM, 10 *
MM } );
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() );
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 ); } );
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 ); } );
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 ); } );
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 ); };
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 ); } );
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 );
1088 std::optional<VECTOR2I> v0 =
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 } );
1119 rect->Rotate( pivot, angle );
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 } ) );
1153 rect->SetCornerRadius( 1 *
MM );
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 } );
1170 BOOST_CHECK_GT(
rect->GetPolyShape().COutline( 0 ).ArcCount(), 0 );
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() );
1199 rect->SetStart( { 0, 0 } );
1200 rect->SetEnd( { 10 *
MM, 10 *
MM } );
1222 endBinding->
Members()[1].m_index = 7;
1233 std::vector<BOARD_ITEM*> modified;
1234 std::vector<BOARD_ITEM*> added;
1235 std::vector<BOARD_ITEM*> removed;
1237 std::function<void( BOARD_ITEM* )> modify()
1239 return [
this]( BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
1242 std::function<void( BOARD_ITEM* )> add()
1244 return [
this]( BOARD_ITEM* aItem )
1246 added.push_back( aItem );
1251 std::function<void( BOARD_ITEM* )> remove()
1253 return [
this]( BOARD_ITEM* aItem )
1255 removed.push_back( aItem );
1256 board.Remove( aItem );
1294 board.
Add( leader );
1312 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1314 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1319 MODE_STAGING toDriving{ board };
1322 toDriving.modify(), toDriving.add(), toDriving.remove() );
1335 MODE_STAGING toArbitrary{ board };
1338 wxString( wxS(
"REF" ) ), toArbitrary.modify(), toArbitrary.add(),
1339 toArbitrary.remove() );
1348 MODE_STAGING toDriven{ board };
1350 toDriven.modify(), toDriven.add(), toDriven.remove() );
1366 MODE_STAGING staging{ board };
1369 std::nullopt, staging.modify(), staging.add(),
1370 staging.remove() ) );
1376 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1378 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1381 std::nullopt, staging.modify(), staging.add(),
1382 staging.remove() ) );
1384 staging.modify(), staging.add(), staging.remove() ) );
1386 std::nullopt, staging.modify(), staging.add(),
1387 staging.remove() ) );
1391 board.
Add( leader );
1394 std::nullopt, staging.modify(), staging.add(),
1395 staging.remove() ) );
1416 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1418 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1420 MODE_STAGING staging{ board };
1423 staging.modify(), staging.add(), staging.remove() );
1433 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
1434 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
1438 BOOST_CHECK_LE( ( dim->GetStart() - tl ).EuclideanNorm(), 5000.0 );
1439 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( br.
x, tl.
y ) ).EuclideanNorm(), 5000.0 );
1454 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1456 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1459 board.
Add( leader );
1492 dim->ChangeValueFieldText( wxS(
"10 mm MAX" ) );
1499 MODE_STAGING staging{ board };
1501 staging.modify(), staging.add(), staging.remove() );
1529 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1532 arc =
static_cast<PCB_SHAPE*
>( aItem.get() );
1534 board.
Add( aItem.release() );
1545 fillet.ProcessLinePair( *lineA, *lineB );
1556 const std::vector<CONSTRAINT_MEMBER>& members = constraint->GetMembers();
1558 if( members.size() != 2 )
1561 if( ( members[0] == aFirst && members[1] == aSecond ) || ( members[0] == aSecond && members[1] == aFirst ) )
1574 BOOST_CHECK( ( heldTogether( arcStart, cornerA ) && heldTogether( arcEnd, cornerB ) )
1575 || ( heldTogether( arcStart, cornerB ) && heldTogether( arcEnd, cornerA ) ) );
1598 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1603 board.
Add( aItem.release() );
1625 const std::vector<CONSTRAINT_MEMBER>& members = constraint->GetMembers();
1627 if( members.size() != 2 )
1630 if( ( members[0] == aFirst && members[1] == aSecond ) || ( members[0] == aSecond && members[1] == aFirst ) )
1653 const auto runDogbone = [](
const VECTOR2I& aFarB,
bool aAddSlots, std::vector<PCB_SHAPE*>& aInserted,
1654 BOARD& aBoard ) -> std::pair<PCB_SHAPE*, PCB_SHAPE*>
1663 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1666 aInserted.push_back(
static_cast<PCB_SHAPE*
>( aItem.get() ) );
1668 aBoard.
Add( aItem.release() );
1681 return { lineA, lineB };
1691 const std::vector<CONSTRAINT_MEMBER>& members = constraint->GetMembers();
1693 if( members.size() != 2 )
1696 if( members[0] == aMember )
1699 if( members[1] == aMember )
1703 return std::nullopt;
1714 const std::vector<CORNER> corners = { { { 20 *
MM, 20 *
MM },
false, 1 }, { { 10 *
MM, 10 *
MM },
true, 3 } };
1716 for(
const CORNER& corner : corners )
1719 std::vector<PCB_SHAPE*> inserted;
1721 auto [lineA, lineB] = runDogbone( corner.farB, corner.addSlots, inserted, board );
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...
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.
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.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
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 Move(const VECTOR2I &aMoveVector) override
Move this object.
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_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_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.
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
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)