133 BOOST_REQUIRE_EQUAL( anchors.size(), 2 );
160 auto segState = diag.shapeStates.find( seg->
m_Uuid );
161 auto dimState = diag.shapeStates.find( dim->m_Uuid );
165 BOOST_CHECK( dimState->second == segState->second );
167 const VECTOR2I dimEnd0 = dim->GetEnd();
169 std::vector<BOARD_ITEM*> staged;
171 [&](
BOARD_ITEM* i ) { staged.push_back( i ); } );
174 BOOST_CHECK_LE( ( dim->GetStart() - seg->
GetEnd() ).EuclideanNorm(), 5000.0 );
175 BOOST_CHECK( ( dim->GetStart() -
VECTOR2I( 10 *
MM, 0 ) ).EuclideanNorm() > 20000.0 );
176 BOOST_CHECK_LE( ( dim->GetEnd() - dimEnd0 ).EuclideanNorm(), 5000.0 );
177 BOOST_CHECK( std::find( staged.begin(), staged.end(), dim ) != staged.end() );
208 std::optional<CONSTRAINT_MEMBER> hit =
212 BOOST_CHECK( hit->m_item == dim->
m_Uuid );
231 std::vector<PCB_SHAPE*> modified;
235 BOOST_CHECK_LE( ( seg->
GetEnd() - dim->GetStart() ).EuclideanNorm(), 5000.0 );
250 seg->
Move( { 0, 3 *
MM } );
254 BOOST_CHECK_LE( ( dim->GetStart() - seg->
GetEnd() ).EuclideanNorm(), 5000.0 );
255 BOOST_CHECK( dim->GetStart().y > 1 *
MM );
267 leader->SetStart( { 10 *
MM, 0 } );
268 leader->SetEnd( { 15 *
MM, 5 *
MM } );
275 std::vector<PCB_CONSTRAINT*> constraints = { c };
304 BOOST_CHECK_LE( (
circle->GetCenter() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
318 dim->SetTextPos( dim->GetKnee() + textOffset );
331 BOOST_CHECK_LE(
std::abs( ( dim->GetEnd() - dim->GetStart() ).EuclideanNorm() - 12 *
MM ), 5000.0 );
334 BOOST_CHECK_LE( ( ( dim->GetTextPos() - dim->GetKnee() ) - textOffset ).EuclideanNorm(), 5000.0 );
377 const double tol = 10000;
381 std::optional<KIID> hit =
384 BOOST_CHECK( *hit ==
circle->m_Uuid );
398 const double tol = 10000;
414 std::vector<ENDPOINT_BINDING> bindings =
417 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
427 BOOST_REQUIRE_EQUAL( anchors.size(), 4 );
441 const double tol = 0.01 *
MM;
444 std::vector<ENDPOINT_BINDING> bindings =
447 BOOST_REQUIRE_EQUAL( bindings.size(), 1 );
455 BOOST_CHECK( bindings.empty() );
464 std::vector<VECTOR2I> pts = { { 0, 0 },
466 { 15 *
MM, 20 *
MM },
468 { -5 *
MM, 10 *
MM } };
472 std::vector<ENDPOINT_BINDING> bindings =
SelectEndpointBindings( &board, fakeDim, pts[1], pts[3], 1000.0 );
474 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
481 std::optional<VECTOR2I> pos =
496 { 10 *
MM, 10 *
MM },
501 std::vector<ENDPOINT_BINDING> bindings =
504 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
510 BOOST_CHECK( binding.target.m_item != b->m_Uuid );
526 chain.SetClosed(
true );
547 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
549 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
556 const VECTOR2I tl = rectTopLeft( rect );
557 const VECTOR2I br = rectBottomRight( rect );
559 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
560 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
565 BOOST_REQUIRE_EQUAL( corners.size(), 4 );
572 BOOST_CHECK_LE( ( dim->GetStart() - corners[0].pos ).EuclideanNorm(), 5000.0 );
573 BOOST_CHECK_LE( ( dim->GetEnd() - corners[1].pos ).EuclideanNorm(), 5000.0 );
582 std::vector<VECTOR2I> pts = { { 0, 0 },
584 { 15 *
MM, 20 *
MM },
586 { -5 *
MM, 10 *
MM } };
593 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
595 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 3 } );
608 for(
int i : { 0, 2, 4 } )
609 BOOST_CHECK_LE( ( outline.
CPoint( i ) - pts[i] ).EuclideanNorm(), 5000.0 );
612 BOOST_CHECK_LE( ( dim->
GetStart() - outline.
CPoint( 1 ) ).EuclideanNorm(), 5000.0 );
613 BOOST_CHECK_LE( ( dim->
GetEnd() - outline.
CPoint( 3 ) ).EuclideanNorm(), 5000.0 );
626 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
628 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
641 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
642 BOOST_CHECK_LE( ( dim->GetStart() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
643 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
663 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
665 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
675 std::vector<PCB_SHAPE*> modified;
679 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
680 BOOST_CHECK_LE( ( rectTopLeft( rect ) -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
681 BOOST_CHECK_LE( ( seg->GetStart() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
682 BOOST_CHECK( std::find( modified.begin(), modified.end(), seg ) != modified.end() );
685 BOOST_CHECK_LE( ( dim->GetStart() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
686 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
698 std::vector<VECTOR2I> pts = { { 0, 0 },
700 { 15 *
MM, 20 *
MM },
702 { -5 *
MM, 10 *
MM } };
708 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
710 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 4 } );
722 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), endBinding->
m_Uuid ) != unmapped.end() );
723 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), startBinding->
m_Uuid ) == unmapped.end() );
726 BOOST_CHECK( adapter.
Solve() );
727 BOOST_CHECK( adapter.
Apply().empty() );
731 for(
int i : { 0, 1, 2 } )
801 BOOST_CHECK_LE( ( seg->GetEnd() -
VECTOR2I( 2 *
MM, 1 *
MM ) ).EuclideanNorm(), 5000.0 );
802 BOOST_CHECK_LE( ( rectTopLeft( rect ) -
VECTOR2I( 2 *
MM, 1 *
MM ) ).EuclideanNorm(), 5000.0 );
803 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 10 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
812 std::vector<VECTOR2I> pts = { { 0, 0 },
814 { 15 *
MM, 20 *
MM },
816 { -5 *
MM, 10 *
MM } };
829 fp->Add( onFootprint );
834 std::vector<BOARD_ITEM*> modified;
835 std::vector<BOARD_ITEM*> removed;
838 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
839 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
855 BOOST_CHECK( removed.empty() );
864 std::vector<VECTOR2I> pts = { { 0, 0 },
866 { 15 *
MM, 20 *
MM },
868 { -5 *
MM, 10 *
MM } };
879 std::vector<BOARD_ITEM*> removed;
883 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
891 BOOST_CHECK( removed.empty() );
900 std::vector<VECTOR2I> pts = { { 0, 0 },
902 { 15 *
MM, 20 *
MM },
904 { -5 *
MM, 10 *
MM } };
914 std::vector<BOARD_ITEM*> modified;
915 std::vector<BOARD_ITEM*> removed;
918 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
919 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
922 BOOST_REQUIRE_EQUAL( removed.size(), 1 );
923 BOOST_CHECK( removed[0] == c );
924 BOOST_CHECK( modified.empty() );
940 std::vector<VECTOR2I> pts = { { 0, 0 },
942 { 15 *
MM, 20 *
MM },
944 { -5 *
MM, 10 *
MM } };
960 VECTOR2I a = pts[k] + ( pts[k - 1] - pts[k] ) / 4;
961 VECTOR2I b = pts[k] + ( pts[k + 1] - pts[k] ) / 4;
967 std::vector<BOARD_ITEM*> modified;
968 std::vector<BOARD_ITEM*> removed;
970 auto modify = [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
971 auto remove = [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); };
986 BOOST_REQUIRE_EQUAL( removed.size(), 2 );
1002 std::vector<VECTOR2I> pts = { { 0, 0 },
1003 { 20 *
MM, 5 *
MM },
1004 { 15 *
MM, 20 *
MM },
1005 { 5 *
MM, 20 *
MM },
1006 { -5 *
MM, 10 *
MM } };
1009 std::vector<VECTOR2I> otherPts = { { 40 *
MM, 0 }, { 60 *
MM, 0 }, { 60 *
MM, 20 *
MM }, { 40 *
MM, 20 *
MM } };
1025 std::vector<BOARD_ITEM*> modified;
1026 std::vector<BOARD_ITEM*> removed;
1029 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
1030 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
1037 BOOST_CHECK( modified.empty() );
1038 BOOST_CHECK( removed.empty() );
1049 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1054 rect->
Rotate( pivot, angle );
1058 std::vector<VECTOR2I> rotated;
1064 rotated.push_back( p );
1072 tl.
x = std::min( tl.
x, p.x );
1073 tl.
y = std::min( tl.
y, p.y );
1074 br.
x = std::max( br.
x, p.x );
1075 br.
y = std::max( br.
y, p.y );
1079 BOOST_REQUIRE_EQUAL( after.size(), 4 );
1086 std::optional<VECTOR2I> v0 =
1091 BOOST_CHECK( *v0 != rotated[0] );
1103 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1105 PCB_DIM_ALIGNED* dim = addAlignedDim( board, before[0].pos, before[1].pos );
1108 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1110 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1114 const VECTOR2I pivot = rect->GetCenter();
1117 rect->Rotate( pivot, angle );
1122 BOOST_REQUIRE_EQUAL( outline.
PointCount(), 4 );
1125 for(
int i = 0; i < 4; ++i )
1130 std::optional<VECTOR2I> pos =
1134 BOOST_CHECK_LE( ( *pos -
expected ).EuclideanNorm(), 2.0 );
1141 checkRect(
addRect( board, { 0, 0 }, { 10 *
MM, 4 *
MM } ) );
1142 checkRect(
addRect( board, { 40 *
MM, 4 *
MM }, { 30 *
MM, 0 } ) );
1154 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1156 PCB_DIM_ALIGNED* dim = addAlignedDim( board, before[0].pos, before[1].pos );
1159 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1161 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1182 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), startBinding->
m_Uuid ) != unmapped.end() );
1183 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), endBinding->
m_Uuid ) != unmapped.end() );
1218 endBinding->
Members()[1].m_index = 7;
1229 std::vector<BOARD_ITEM*> modified;
1230 std::vector<BOARD_ITEM*> added;
1231 std::vector<BOARD_ITEM*> removed;
1233 std::function<void( BOARD_ITEM* )> modify()
1235 return [
this]( BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
1238 std::function<void( BOARD_ITEM* )> add()
1240 return [
this]( BOARD_ITEM* aItem )
1242 added.push_back( aItem );
1247 std::function<void( BOARD_ITEM* )> remove()
1249 return [
this]( BOARD_ITEM* aItem )
1251 removed.push_back( aItem );
1252 board.Remove( aItem );
1290 board.
Add( leader );
1308 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1310 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1315 MODE_STAGING toDriving{ board };
1318 toDriving.modify(), toDriving.add(), toDriving.remove() );
1327 BOOST_CHECK( toDriving.added[0] == driving );
1328 BOOST_CHECK( toDriving.removed.empty() );
1331 MODE_STAGING toArbitrary{ board };
1334 wxString( wxS(
"REF" ) ), toArbitrary.modify(), toArbitrary.add(),
1335 toArbitrary.remove() );
1344 MODE_STAGING toDriven{ board };
1346 toDriven.modify(), toDriven.add(), toDriven.remove() );
1349 BOOST_CHECK( !dim->GetOverrideTextEnabled() );
1350 BOOST_CHECK( toDriven.added.empty() );
1351 BOOST_CHECK( toDriven.removed.empty() );
1362 MODE_STAGING staging{ board };
1365 std::nullopt, staging.modify(), staging.add(),
1366 staging.remove() ) );
1372 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1374 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1377 std::nullopt, staging.modify(), staging.add(),
1378 staging.remove() ) );
1380 staging.modify(), staging.add(), staging.remove() ) );
1382 std::nullopt, staging.modify(), staging.add(),
1383 staging.remove() ) );
1387 board.
Add( leader );
1390 std::nullopt, staging.modify(), staging.add(),
1391 staging.remove() ) );
1393 BOOST_CHECK( staging.modified.empty() );
1394 BOOST_CHECK( staging.added.empty() );
1395 BOOST_CHECK( staging.removed.empty() );
1412 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1414 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1416 MODE_STAGING staging{ board };
1419 staging.modify(), staging.add(), staging.remove() );
1426 const VECTOR2I tl = rectTopLeft( rect );
1427 const VECTOR2I br = rectBottomRight( rect );
1429 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
1430 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
1434 BOOST_CHECK_LE( ( dim->GetStart() - tl ).EuclideanNorm(), 5000.0 );
1435 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( br.
x, tl.
y ) ).EuclideanNorm(), 5000.0 );
1450 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1452 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1455 board.
Add( leader );
1488 dim->ChangeValueFieldText( wxS(
"10 mm MAX" ) );
1495 MODE_STAGING staging{ board };
1497 staging.modify(), staging.add(), staging.remove() );
1499 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"0" ) ) ), dim ) );
1500 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"-3" ) ) ), dim ) );
1501 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"text" ) ) ), dim ) );
1502 BOOST_CHECK( !valueProp->
Validate( wxAny( wxString( wxS(
"15" ) ) ), dim ) );
1505 BOOST_CHECK( !valueProp->
Validate( wxAny( wxString( wxS(
"0" ) ) ), unbound ) );
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.
void SetCornerRadius(int aRadius)
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 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 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)
Provide class metadata.Helper macro to map type hashes to names.
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).
DIM_VALUE_MODE DimensionValueMode(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
The value mode aDimension is in, derived from state: a self driving length means Driving,...
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...
std::vector< ENDPOINT_BINDING > SelectEndpointBindings(BOARD *aBoard, const KIID &aItem, const VECTOR2I &aStart, const std::optional< VECTOR2I > &aEnd, double aMaxDist)
Choose the coincident bindings a freshly drawn item endpoints should take so it tracks the geometry i...
bool DimensionHasValueMode(const PCB_DIMENSION_BASE *aDimension)
True for dimension types with a measured value aligned orthogonal or radial offering the Driven Drivi...
PCB_CONSTRAINT * FindDimensionLengthConstraint(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the drivin...
std::vector< CONSTRAINT_ANCHOR_POINT > ConstraintItemAnchors(const BOARD_ITEM *aItem)
The constraint anchors an item exposes.
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(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.
std::optional< VECTOR2I > ConstraintAnchorPosition(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...
std::optional< CONSTRAINT_MEMBER > NearestConstraintAnchor(BOARD *aBoard, const VECTOR2I &aPos, double aMaxDist, const std::vector< CONSTRAINT_MEMBER > &aExclude)
Find the constrainable-item anchor (a shape's segment/arc endpoint or centre, or a dimension's featur...
bool DimensionCanDrive(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpoint...
bool DimensionEndpointsBound(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.
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.
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).
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_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
VECTOR2< int32_t > VECTOR2I