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 );
347 const double tol = 10000;
351 std::optional<KIID> hit =
354 BOOST_CHECK( *hit ==
circle->m_Uuid );
368 const double tol = 10000;
384 std::vector<DIMENSION_ENDPOINT_BINDING> bindings =
387 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
397 BOOST_REQUIRE_EQUAL( anchors.size(), 4 );
410 std::vector<VECTOR2I> pts = { { 0, 0 },
412 { 15 *
MM, 20 *
MM },
414 { -5 *
MM, 10 *
MM } };
418 std::vector<DIMENSION_ENDPOINT_BINDING> bindings =
421 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
428 std::optional<VECTOR2I> pos =
443 { 10 *
MM, 10 *
MM },
448 std::vector<DIMENSION_ENDPOINT_BINDING> bindings =
451 BOOST_REQUIRE_EQUAL( bindings.size(), 2 );
457 BOOST_CHECK( binding.target.m_item != b->m_Uuid );
473 chain.SetClosed(
true );
494 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
496 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
503 const VECTOR2I tl = rectTopLeft( rect );
504 const VECTOR2I br = rectBottomRight( rect );
506 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
507 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
512 BOOST_REQUIRE_EQUAL( corners.size(), 4 );
519 BOOST_CHECK_LE( ( dim->GetStart() - corners[0].pos ).EuclideanNorm(), 5000.0 );
520 BOOST_CHECK_LE( ( dim->GetEnd() - corners[1].pos ).EuclideanNorm(), 5000.0 );
529 std::vector<VECTOR2I> pts = { { 0, 0 },
531 { 15 *
MM, 20 *
MM },
533 { -5 *
MM, 10 *
MM } };
540 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
542 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 3 } );
555 for(
int i : { 0, 2, 4 } )
556 BOOST_CHECK_LE( ( outline.
CPoint( i ) - pts[i] ).EuclideanNorm(), 5000.0 );
559 BOOST_CHECK_LE( ( dim->
GetStart() - outline.
CPoint( 1 ) ).EuclideanNorm(), 5000.0 );
560 BOOST_CHECK_LE( ( dim->
GetEnd() - outline.
CPoint( 3 ) ).EuclideanNorm(), 5000.0 );
573 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
575 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
588 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
589 BOOST_CHECK_LE( ( dim->GetStart() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
590 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
610 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
612 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
622 std::vector<PCB_SHAPE*> modified;
626 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 15 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
627 BOOST_CHECK_LE( ( rectTopLeft( rect ) -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
628 BOOST_CHECK_LE( ( seg->GetStart() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
629 BOOST_CHECK( std::find( modified.begin(), modified.end(), seg ) != modified.end() );
632 BOOST_CHECK_LE( ( dim->GetStart() -
VECTOR2I( 0, 0 ) ).EuclideanNorm(), 5000.0 );
633 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( 15 *
MM, 0 ) ).EuclideanNorm(), 5000.0 );
645 std::vector<VECTOR2I> pts = { { 0, 0 },
647 { 15 *
MM, 20 *
MM },
649 { -5 *
MM, 10 *
MM } };
655 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
657 { poly->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 4 } );
669 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), endBinding->
m_Uuid ) != unmapped.end() );
670 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), startBinding->
m_Uuid ) == unmapped.end() );
673 BOOST_CHECK( adapter.
Solve() );
674 BOOST_CHECK( adapter.
Apply().empty() );
678 for(
int i : { 0, 1, 2 } )
748 BOOST_CHECK_LE( ( seg->GetEnd() -
VECTOR2I( 2 *
MM, 1 *
MM ) ).EuclideanNorm(), 5000.0 );
749 BOOST_CHECK_LE( ( rectTopLeft( rect ) -
VECTOR2I( 2 *
MM, 1 *
MM ) ).EuclideanNorm(), 5000.0 );
750 BOOST_CHECK_LE( ( rectBottomRight( rect ) -
VECTOR2I( 10 *
MM, 10 *
MM ) ).EuclideanNorm(), 5000.0 );
759 std::vector<VECTOR2I> pts = { { 0, 0 },
761 { 15 *
MM, 20 *
MM },
763 { -5 *
MM, 10 *
MM } };
776 fp->Add( onFootprint );
781 std::vector<BOARD_ITEM*> modified;
782 std::vector<BOARD_ITEM*> removed;
785 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
786 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
802 BOOST_CHECK( removed.empty() );
811 std::vector<VECTOR2I> pts = { { 0, 0 },
813 { 15 *
MM, 20 *
MM },
815 { -5 *
MM, 10 *
MM } };
826 std::vector<BOARD_ITEM*> removed;
830 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
838 BOOST_CHECK( removed.empty() );
847 std::vector<VECTOR2I> pts = { { 0, 0 },
849 { 15 *
MM, 20 *
MM },
851 { -5 *
MM, 10 *
MM } };
861 std::vector<BOARD_ITEM*> modified;
862 std::vector<BOARD_ITEM*> removed;
865 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
866 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
869 BOOST_REQUIRE_EQUAL( removed.size(), 1 );
870 BOOST_CHECK( removed[0] == c );
871 BOOST_CHECK( modified.empty() );
887 std::vector<VECTOR2I> pts = { { 0, 0 },
889 { 15 *
MM, 20 *
MM },
891 { -5 *
MM, 10 *
MM } };
907 VECTOR2I a = pts[k] + ( pts[k - 1] - pts[k] ) / 4;
908 VECTOR2I b = pts[k] + ( pts[k + 1] - pts[k] ) / 4;
914 std::vector<BOARD_ITEM*> modified;
915 std::vector<BOARD_ITEM*> removed;
917 auto modify = [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
918 auto remove = [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); };
933 BOOST_REQUIRE_EQUAL( removed.size(), 2 );
949 std::vector<VECTOR2I> pts = { { 0, 0 },
951 { 15 *
MM, 20 *
MM },
953 { -5 *
MM, 10 *
MM } };
956 std::vector<VECTOR2I> otherPts = { { 40 *
MM, 0 }, { 60 *
MM, 0 }, { 60 *
MM, 20 *
MM }, { 40 *
MM, 20 *
MM } };
972 std::vector<BOARD_ITEM*> modified;
973 std::vector<BOARD_ITEM*> removed;
976 [&](
BOARD_ITEM* aItem ) { modified.push_back( aItem ); },
977 [&](
BOARD_ITEM* aItem ) { removed.push_back( aItem ); } );
984 BOOST_CHECK( modified.empty() );
985 BOOST_CHECK( removed.empty() );
996 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1001 rect->
Rotate( pivot, angle );
1005 std::vector<VECTOR2I> rotated;
1011 rotated.push_back( p );
1019 tl.
x = std::min( tl.
x, p.x );
1020 tl.
y = std::min( tl.
y, p.y );
1021 br.
x = std::max( br.
x, p.x );
1022 br.
y = std::max( br.
y, p.y );
1026 BOOST_REQUIRE_EQUAL( after.size(), 4 );
1033 std::optional<VECTOR2I> v0 =
1038 BOOST_CHECK( *v0 != rotated[0] );
1050 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1052 PCB_DIM_ALIGNED* dim = addAlignedDim( board, before[0].pos, before[1].pos );
1055 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1057 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1061 const VECTOR2I pivot = rect->GetCenter();
1064 rect->Rotate( pivot, angle );
1069 BOOST_REQUIRE_EQUAL( outline.
PointCount(), 4 );
1072 for(
int i = 0; i < 4; ++i )
1077 std::optional<VECTOR2I> pos =
1081 BOOST_CHECK_LE( ( *pos -
expected ).EuclideanNorm(), 2.0 );
1088 checkRect(
addRect( board, { 0, 0 }, { 10 *
MM, 4 *
MM } ) );
1089 checkRect(
addRect( board, { 40 *
MM, 4 *
MM }, { 30 *
MM, 0 } ) );
1101 BOOST_REQUIRE_EQUAL( before.size(), 4 );
1103 PCB_DIM_ALIGNED* dim = addAlignedDim( board, before[0].pos, before[1].pos );
1106 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1108 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1129 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), startBinding->
m_Uuid ) != unmapped.end() );
1130 BOOST_CHECK( std::find( unmapped.begin(), unmapped.end(), endBinding->
m_Uuid ) != unmapped.end() );
1165 endBinding->
Members()[1].m_index = 7;
1176 std::vector<BOARD_ITEM*> modified;
1177 std::vector<BOARD_ITEM*> added;
1178 std::vector<BOARD_ITEM*> removed;
1180 std::function<void( BOARD_ITEM* )> modify()
1182 return [
this]( BOARD_ITEM* aItem ) { modified.push_back( aItem ); };
1185 std::function<void( BOARD_ITEM* )> add()
1187 return [
this]( BOARD_ITEM* aItem )
1189 added.push_back( aItem );
1194 std::function<void( BOARD_ITEM* )> remove()
1196 return [
this]( BOARD_ITEM* aItem )
1198 removed.push_back( aItem );
1199 board.Remove( aItem );
1237 board.
Add( leader );
1255 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1257 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1262 MODE_STAGING toDriving{ board };
1265 toDriving.modify(), toDriving.add(), toDriving.remove() );
1274 BOOST_CHECK( toDriving.added[0] == driving );
1275 BOOST_CHECK( toDriving.removed.empty() );
1278 MODE_STAGING toArbitrary{ board };
1281 wxString( wxS(
"REF" ) ), toArbitrary.modify(), toArbitrary.add(),
1282 toArbitrary.remove() );
1291 MODE_STAGING toDriven{ board };
1293 toDriven.modify(), toDriven.add(), toDriven.remove() );
1296 BOOST_CHECK( !dim->GetOverrideTextEnabled() );
1297 BOOST_CHECK( toDriven.added.empty() );
1298 BOOST_CHECK( toDriven.removed.empty() );
1309 MODE_STAGING staging{ board };
1312 std::nullopt, staging.modify(), staging.add(),
1313 staging.remove() ) );
1319 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1321 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1324 std::nullopt, staging.modify(), staging.add(),
1325 staging.remove() ) );
1327 staging.modify(), staging.add(), staging.remove() ) );
1329 std::nullopt, staging.modify(), staging.add(),
1330 staging.remove() ) );
1334 board.
Add( leader );
1337 std::nullopt, staging.modify(), staging.add(),
1338 staging.remove() ) );
1340 BOOST_CHECK( staging.modified.empty() );
1341 BOOST_CHECK( staging.added.empty() );
1342 BOOST_CHECK( staging.removed.empty() );
1359 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1361 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1363 MODE_STAGING staging{ board };
1366 staging.modify(), staging.add(), staging.remove() );
1373 const VECTOR2I tl = rectTopLeft( rect );
1374 const VECTOR2I br = rectBottomRight( rect );
1376 BOOST_CHECK_LE(
std::abs( ( br.
x - tl.
x ) - 15 *
MM ), 5000 );
1377 BOOST_CHECK_LE(
std::abs( ( br.
y - tl.
y ) - 10 *
MM ), 5000 );
1381 BOOST_CHECK_LE( ( dim->GetStart() - tl ).EuclideanNorm(), 5000.0 );
1382 BOOST_CHECK_LE( ( dim->GetEnd() -
VECTOR2I( br.
x, tl.
y ) ).EuclideanNorm(), 5000.0 );
1397 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 0 } );
1399 { rect->m_Uuid, CONSTRAINT_ANCHOR::VERTEX, 1 } );
1402 board.
Add( leader );
1435 dim->ChangeValueFieldText( wxS(
"10 mm MAX" ) );
1442 MODE_STAGING staging{ board };
1444 staging.modify(), staging.add(), staging.remove() );
1446 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"0" ) ) ), dim ) );
1447 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"-3" ) ) ), dim ) );
1448 BOOST_CHECK( valueProp->
Validate( wxAny( wxString( wxS(
"text" ) ) ), dim ) );
1449 BOOST_CHECK( !valueProp->
Validate( wxAny( wxString( wxS(
"15" ) ) ), dim ) );
1452 BOOST_CHECK( !valueProp->
Validate( wxAny( wxString( wxS(
"0" ) ) ), unbound ) );
void 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 ...
CONSTRAINT_DIAGNOSIS ApplyConstraintImmediately(BOARD *aBoard, const PCB_CONSTRAINT *aConstraint, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Solve a just-created constraint's cluster so the geometry snaps to satisfy it (SolidWorks-style),...
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_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)
Gather the cluster of shapes transitively constrained with the dragged shape, solve with the dragged ...
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)
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...
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...
std::vector< DIMENSION_ENDPOINT_BINDING > SelectDimensionEndpointBindings(BOARD *aBoard, const KIID &aDimension, const VECTOR2I &aStart, const std::optional< VECTOR2I > &aEnd, double aMaxDist)
Choose the coincident bindings a freshly drawn dimension endpoints should take so it tracks the geome...
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 dimension feature points bound coincident to an object anchor by draw time auto constrain di...
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