48 std::unique_ptr<PCB_CONSTRAINT> c =
52 BOOST_REQUIRE_EQUAL( c->GetMembers().size(), 2 );
53 BOOST_CHECK( c->GetMembers()[0].m_item == a->
m_Uuid );
55 BOOST_CHECK( c->GetMembers()[1].m_item == b->m_Uuid );
64 std::unique_ptr<PCB_CONSTRAINT> c =
69 BOOST_CHECK_CLOSE( *c->GetValue(), 7.0 *
MM, 1e-6 );
79 std::unique_ptr<PCB_CONSTRAINT> c =
83 BOOST_REQUIRE_EQUAL( c->GetMembers().size(), 2 );
85 BOOST_CHECK_CLOSE( *c->GetValue(), 90.0, 1e-6 );
95 std::unique_ptr<PCB_CONSTRAINT> c =
102 BOOST_CHECK_CLOSE( *c->GetValue(), 90.0, 1e-3 );
114 for(
bool swapA : {
false,
true } )
116 for(
bool swapB : {
false,
true } )
118 for(
bool swapOrder : {
false,
true } )
126 std::vector<BOARD_ITEM*> items = swapOrder ? std::vector<BOARD_ITEM*>{ b, a }
127 : std::vector<BOARD_ITEM*>{ a, b };
134 BOOST_CHECK_CLOSE( *c->GetValue(), 120.0, 0.05 );
150 BOOST_CHECK_SMALL( *c->GetValue(), 1e-3 );
159 BOOST_CHECK_CLOSE( *c->GetValue(), 180.0, 1e-3 );
172 std::unique_ptr<PCB_CONSTRAINT> c =
178 BOOST_CHECK_CLOSE( *c->GetValue(), 90.0, 1e-3 );
218 BOOST_CHECK( hit->m_item == seg->
m_Uuid );
239 std::optional<CONSTRAINT_MEMBER> second =
242 BOOST_CHECK( *second != *first );
243 BOOST_CHECK( second->m_item != first->m_item );
248 BOOST_CHECK( ( first->m_item == a->
m_Uuid && second->m_item == b->m_Uuid )
249 || ( first->m_item == b->m_Uuid && second->m_item == a->
m_Uuid ) );
268 std::unique_ptr<PCB_CONSTRAINT> c =
273 commit.
Add( c.release() );
274 commit.
Push( wxT(
"add constraint" ) );
281 removeCommit.
Remove( added );
282 removeCommit.
Push( wxT(
"remove constraint" ) );
312 std::map<PCB_CONSTRAINT_TYPE, double> remembered;
324 std::map<PCB_CONSTRAINT_TYPE, double> remembered;
335 std::map<PCB_CONSTRAINT_TYPE, double> remembered;
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
Information pertinent to a Pcbnew printed circuit board.
const CONSTRAINTS & Constraints() const
Geometric constraints (#2329) owned by this board.
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
A geometric constraint between board items (issue #2329).
double InitialConstraintValue(PCB_CONSTRAINT_TYPE aType, double aMeasured, const std::map< PCB_CONSTRAINT_TYPE, double > &aRemembered)
Value a freshly authored constraint dialog should open with.
std::unique_ptr< PCB_CONSTRAINT > BuildConstraintFromItems(BOARD_ITEM *aParent, PCB_CONSTRAINT_TYPE aType, const std::vector< BOARD_ITEM * > &aItems)
Build a constraint of aType from a set of selected board items, or nullptr if the selection does not ...
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...
PCB_SHAPE * addSegment(BOARD &aBoard, const VECTOR2I &aStart, const VECTOR2I &aEnd)
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 * addEllipse(BOARD &aBoard, const VECTOR2I &aCenter, int aMajor, int aMinor, const EDA_ANGLE &aRotation)
@ WHOLE
The item as a whole (a segment as a line, a circle).
@ END
Second endpoint of a segment or arc.
@ CONCENTRIC
Two arcs/circles share a center.
@ COINCIDENT
Two points are made to coincide.
@ FIXED_RADIUS
An arc/circle has a driving radius value.
@ EQUAL_RADIUS
Two arcs/circles have equal radius.
@ FIXED_LENGTH
A segment has a driving length value.
@ ANGULAR_DIMENSION
An angle between members (driving or reference).
@ ARC_ANGLE
An arc has a driving or reference swept-angle value.
@ PARALLEL
Two segments are parallel.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(BuildParallelFromTwoSegments)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I