43constexpr int NEAR_MISS =
MM / 10;
44constexpr int FAR_MISS =
MM / 2;
51 s->SetStart( aStart );
59 auto s = std::make_unique<PCB_SHAPE>( &aBoard,
SHAPE_T::ARC );
60 s->SetArcGeometry( aStart, aMid, aEnd );
65std::unique_ptr<PCB_SHAPE> drawnCircle(
BOARD& aBoard,
const VECTOR2I& aCenter,
int aRadius )
68 s->SetCenter( aCenter );
69 s->SetRadius( aRadius );
84 auto drawn = drawnSegment( board, { 10 *
MM, 0 }, { 10 *
MM, 10 *
MM } );
87 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
89 BOOST_CHECK( !picks[0].needsSolve );
91 const std::vector<CONSTRAINT_MEMBER>& members = picks[0].constraint->GetMembers();
92 BOOST_REQUIRE_EQUAL( members.size(), 2 );
104 auto drawn = drawnSegment( board, { 5 *
MM, 0 }, { 5 *
MM, 8 *
MM } );
107 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
110 const std::vector<CONSTRAINT_MEMBER>& members = picks[0].constraint->GetMembers();
122 auto drawn = drawnSegment( board, { 3 *
MM, 0 }, { 3 *
MM, 8 *
MM } );
125 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
127 BOOST_CHECK( picks[0].constraint->GetMembers()[1]
140 auto drawn = drawnArc( board, { 10 *
MM, 0 }, { 10 *
MM + 3536000, 5 *
MM - 3536000 }, { 15 *
MM, 5 *
MM } );
143 BOOST_REQUIRE_EQUAL( picks.size(), 2 );
146 BOOST_CHECK( picks[1].needsSolve );
149 const std::vector<CONSTRAINT_MEMBER>& members = picks[1].constraint->GetMembers();
162 auto drawn = drawnArc( board, { 10 *
MM, 0 }, { 13 *
MM, -1 *
MM }, { 18 *
MM, 4 *
MM } );
165 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
176 auto drawn = drawnSegment( board, { 10 *
MM, 0 }, { 20 *
MM, 0 } );
179 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
190 auto drawn = drawnSegment( board, { 0, 15 *
MM + NEAR_MISS }, { 10 *
MM, 15 *
MM + NEAR_MISS } );
193 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
195 BOOST_CHECK( picks[0].needsSolve );
198 const std::vector<CONSTRAINT_MEMBER>& members = picks[0].constraint->GetMembers();
210 auto drawn = drawnSegment( board, { 0, 15 *
MM + FAR_MISS }, { 10 *
MM, 15 *
MM + FAR_MISS } );
213 BOOST_CHECK( picks.empty() );
224 auto drawn = drawnSegment( board, { 5 *
MM + NEAR_MISS, 15 *
MM }, { 15 *
MM, 15 *
MM } );
227 BOOST_CHECK( picks.empty() );
236 auto horizontal = drawnSegment( board, { 0, 0 }, { 10 *
MM, 0 } );
239 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
242 auto vertical = drawnSegment( board, { 0, 0 }, { 0, 10 *
MM } );
245 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
249 BOOST_CHECK( picks.empty() );
251 auto diagonal = drawnSegment( board, { 0, 0 }, { 10 *
MM, 10 *
MM } );
253 BOOST_CHECK( picks.empty() );
264 auto onCentre = drawnCircle( board, { 0, 0 }, 8 *
MM );
267 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
269 BOOST_CHECK( picks[0].constraint->GetMembers()[0]
272 auto onEndpoint = drawnCircle( board, { 30 *
MM, 0 }, 2 *
MM );
275 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
277 BOOST_CHECK( picks[0].constraint->GetMembers()[0]
280 auto onOutline = drawnCircle( board, { 23 *
MM, 0 }, 2 *
MM );
283 BOOST_REQUIRE_EQUAL( picks.size(), 1 );
285 BOOST_CHECK( picks[0].constraint->GetMembers()[1]
297 const int sagitta = 839200;
299 addArc( board, { 0, 0 }, { 10 *
MM, -sagitta }, { 20 *
MM, 0 } );
301 auto drawn = drawnSegment( board, { 0, 0 }, { 20 *
MM, 0 } );
326 auto drawn = drawnSegment( board, { 10 *
MM, 0 }, { 10 *
MM, 10 *
MM } );
331 board.
Add( existing );
335 BOOST_CHECK( picks.empty() );
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.
A geometric constraint between board items (issue #2329).
std::vector< AUTO_CONSTRAINT > SelectShapeAutoConstraints(BOARD *aBoard, const PCB_SHAPE *aShape, BOARD_ITEM *aParent, bool aAxisConstraint)
Choose the constraints a freshly drawn shape should get from what its features landed on.
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)
@ 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.
@ VERTICAL
A segment (or two points) is vertical.
@ TANGENT
A line and a curve, or two curves, touch tangentially.
@ COINCIDENT
Two points are made to coincide.
@ HORIZONTAL
A segment (or two points) is horizontal.
@ MIDPOINT
A point is the midpoint of a segment.
@ POINT_ON_LINE
A point lies on a segment's supporting line.
One constraint chosen for a freshly drawn shape.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(EndpointBindsCoincident)
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