KiCad PCB EDA Suite
Loading...
Searching...
No Matches
point_editor_behavior.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <algorithm>
23
24#include <advanced_config.h>
25#include <commit.h>
27#include <math/util.h>
28#include <reference_image.h>
29
30
32 const SHAPE_POLY_SET& aOutline )
33{
34 const int cornersCount = aOutline.TotalVertices();
35
36 if( cornersCount == 0 )
37 return;
38
39 for( auto iterator = aOutline.CIterateWithHoles(); iterator; iterator++ )
40 {
41 aPoints.AddPoint( *iterator );
42
43 if( iterator.IsEndContour() )
44 aPoints.AddBreak();
45 }
46
47 // Lines have to be added after creating edit points, as they use EDIT_POINT references
48 for( int i = 0; i < cornersCount - 1; ++i )
49 {
50 if( aPoints.IsContourEnd( i ) )
51 aPoints.AddLine( aPoints.Point( i ), aPoints.Point( aPoints.GetContourStartIdx( i ) ) );
52 else
53 aPoints.AddLine( aPoints.Point( i ), aPoints.Point( i + 1 ) );
54
55 aPoints.Line( i ).SetDragPolicy(
56 std::make_unique<POLYGON_EDGE_DRAG_POLICY>( aPoints.Line( i ), aPoints ) );
57 }
58
59 // The last missing line, connecting the last and the first polygon point
60 aPoints.AddLine( aPoints.Point( cornersCount - 1 ),
61 aPoints.Point( aPoints.GetContourStartIdx( cornersCount - 1 ) ) );
62
63 aPoints.Line( aPoints.LinesSize() - 1 )
64 .SetDragPolicy( std::make_unique<POLYGON_EDGE_DRAG_POLICY>(
65 aPoints.Line( aPoints.LinesSize() - 1 ), aPoints ) );
66}
67
68
70 EDIT_POINTS& aPoints )
71{
72 // No size check here, as we can and will rebuild if that fails
73 if( aPoints.PointsSize() != (unsigned) aOutline.TotalVertices() )
74 {
75 // Rebuild the points list
76 aPoints.Clear();
77 BuildForPolyOutline( aPoints, aOutline );
78 }
79 else
80 {
81 for( int i = 0; i < aOutline.TotalVertices(); ++i )
82 aPoints.Point( i ).SetPosition( aOutline.CVertex( i ) );
83 }
84}
85
86
88 const EDIT_POINT& aEditedPoint,
89 EDIT_POINTS& aPoints )
90{
91 CHECK_POINT_COUNT_GE( aPoints, (unsigned) aOutline.TotalVertices() );
92
93 for( int i = 0; i < aOutline.TotalVertices(); ++i )
94 aOutline.SetVertex( i, aPoints.Point( i ).GetPosition() );
95
96 for( unsigned i = 0; i < aPoints.LinesSize(); ++i )
97 {
98 if( !isModified( aEditedPoint, aPoints.Line( i ) ) )
99 aPoints.Line( i ).SetDragPolicy(
100 std::make_unique<POLYGON_EDGE_DRAG_POLICY>( aPoints.Line( i ), aPoints ) );
101 }
102}
103
104
106{
107 SHAPE_POLY_SET cleaned = aOutline;
108
109 cleaned.RemoveNullSegments();
110
111 if( cleaned.TotalVertices() >= 3 )
112 aOutline = cleaned;
113}
114
115
120
121
123{
124 aPoints.AddPoint( m_segment.GetStart() );
125 aPoints.AddPoint( m_segment.GetEnd() );
126}
127
128
130{
131 wxCHECK( aPoints.PointsSize() == SEGMENT_MAX_POINTS, false );
132
133 aPoints.Point( SEGMENT_START ) = m_segment.GetStart();
134 aPoints.Point( SEGMENT_END ) = m_segment.GetEnd();
135 return true;
136}
137
138
140 EDIT_POINTS& aPoints, COMMIT& aCommit,
141 std::vector<EDA_ITEM*>& aUpdatedItems )
142{
144
145 if( isModified( aEditedPoint, aPoints.Point( SEGMENT_START ) ) )
146 m_segment.SetStart( aPoints.Point( SEGMENT_START ).GetPosition() );
147
148 else if( isModified( aEditedPoint, aPoints.Point( SEGMENT_END ) ) )
149 m_segment.SetEnd( aPoints.Point( SEGMENT_END ).GetPosition() );
150}
151
152
154{
155 const ELLIPSE<int>& ellipse = m_ellipse.GetEllipse();
156 return ellipse.GetPointAtAngle( aTheta );
157}
158
159
161{
162 const ELLIPSE<int>& ellipse = m_ellipse.GetEllipse();
163 return ellipse.GetAngleAtPoint( aWorldPt );
164}
165
166
168{
169 const ELLIPSE<int>& ellipse = m_ellipse.GetEllipse();
170
171 aPoints.AddPoint( ellipse.Center );
172 aPoints.AddPoint( ellipse.GetPointAtAngle( ANGLE_0 ) );
173 aPoints.AddPoint( ellipse.GetPointAtAngle( ANGLE_90 ) );
174
175 // The centre is not a point on the ellipse. Dragging it moves the whole shape, and the
176 // radius handles read the centre back, so the two compound if both are placed at once
178
179 if( m_ellipse.GetShape() == SHAPE_T::ELLIPSE_ARC )
180 {
181 aPoints.AddPoint( evaluateAt( m_ellipse.GetEllipseStartAngle() ) );
182 aPoints.AddPoint( evaluateAt( m_ellipse.GetEllipseEndAngle() ) );
183
184 aPoints.AddIndicatorLine( aPoints.Point( ELLIPSE_CENTER ), aPoints.Point( ELLIPSE_ARC_START ) );
185 aPoints.AddIndicatorLine( aPoints.Point( ELLIPSE_CENTER ), aPoints.Point( ELLIPSE_ARC_END ) );
186 }
187}
188
189
191{
192 const bool isArc = ( m_ellipse.GetShape() == SHAPE_T::ELLIPSE_ARC );
193 const size_t expected = isArc ? ELLIPSE_ARC_POINTS : ELLIPSE_CLOSED_POINTS;
194
195 wxCHECK( aPoints.PointsSize() == expected, false );
196
197 const ELLIPSE<int>& ellipse = m_ellipse.GetEllipse();
198
199 aPoints.Point( ELLIPSE_CENTER ).SetPosition( ellipse.Center );
202
203 if( isArc )
204 {
205 aPoints.Point( ELLIPSE_ARC_START ).SetPosition( evaluateAt( m_ellipse.GetEllipseStartAngle() ) );
206 aPoints.Point( ELLIPSE_ARC_END ).SetPosition( evaluateAt( m_ellipse.GetEllipseEndAngle() ) );
207 }
208
209 return true;
210}
211
212
213void EDA_ELLIPSE_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
214 std::vector<EDA_ITEM*>& aUpdatedItems )
215{
216 const bool isArc = ( m_ellipse.GetShape() == SHAPE_T::ELLIPSE_ARC );
217 const size_t expected = isArc ? ELLIPSE_ARC_POINTS : ELLIPSE_CLOSED_POINTS;
218
219 CHECK_POINT_COUNT( aPoints, expected );
220
221 if( isModified( aEditedPoint, aPoints.Point( ELLIPSE_CENTER ) ) )
222 {
223 m_ellipse.SetEllipseCenter( aPoints.Point( ELLIPSE_CENTER ).GetPosition() );
224 }
225 else if( isModified( aEditedPoint, aPoints.Point( ELLIPSE_MAJOR_END ) ) )
226 {
227 const VECTOR2I center = m_ellipse.GetEllipseCenter();
228 const VECTOR2I v = aPoints.Point( ELLIPSE_MAJOR_END ).GetPosition() - center;
229 const double len = std::sqrt( double( v.x ) * v.x + double( v.y ) * v.y );
230
231 m_ellipse.SetEllipseMajorRadius( std::max( 1, KiROUND( len ) ) );
232 m_ellipse.SetEllipseRotation( EDA_ANGLE( std::atan2( (double) v.y, (double) v.x ), RADIANS_T ) );
233 }
234 else if( isModified( aEditedPoint, aPoints.Point( ELLIPSE_MINOR_END ) ) )
235 {
236 const VECTOR2I center = m_ellipse.GetEllipseCenter();
237 const VECTOR2I v = aPoints.Point( ELLIPSE_MINOR_END ).GetPosition() - center;
238 const EDA_ANGLE rotation = m_ellipse.GetEllipseRotation();
239
240 // Absolute value so dragging past the rotation axis keeps radius positive.
241 const double proj = -v.x * rotation.Sin() + v.y * rotation.Cos();
242
243 m_ellipse.SetEllipseMinorRadius( std::max( 1, KiROUND( std::abs( proj ) ) ) );
244 }
245 else if( isArc && isModified( aEditedPoint, aPoints.Point( ELLIPSE_ARC_START ) ) )
246 {
248 EDA_ANGLE prevStart = m_ellipse.GetEllipseStartAngle();
249 EDA_ANGLE sweep = m_ellipse.GetEllipseEndAngle() - prevStart;
250
251 while( ( rawAngle - prevStart ).AsDegrees() > 180.0 )
252 rawAngle = rawAngle - ANGLE_360;
253 while( ( prevStart - rawAngle ).AsDegrees() > 180.0 )
254 rawAngle = rawAngle + ANGLE_360;
255
256 m_ellipse.SetEllipseStartAngle( rawAngle );
257 m_ellipse.SetEllipseEndAngle( rawAngle + sweep );
258 }
259 else if( isArc && isModified( aEditedPoint, aPoints.Point( ELLIPSE_ARC_END ) ) )
260 {
262 EDA_ANGLE prevEnd = m_ellipse.GetEllipseEndAngle();
263
264 while( ( rawAngle - prevEnd ).AsDegrees() > 180.0 )
265 rawAngle = rawAngle - ANGLE_360;
266 while( ( prevEnd - rawAngle ).AsDegrees() > 180.0 )
267 rawAngle = rawAngle + ANGLE_360;
268
269 m_ellipse.SetEllipseEndAngle( rawAngle );
270 }
271}
272
273
275 EDIT_POINTS& aPoints ) const
276{
277 // Select the other end of line
278 return aPoints.Next( aEditedPoint )->GetPosition();
279}
280
281
283{
284 aPoints.AddPoint( m_circle.getCenter() );
285 aPoints.AddPoint( m_circle.GetEnd() );
286}
287
288
290{
291 wxCHECK( aPoints.PointsSize() == CIRC_MAX_POINTS, false );
292
293 aPoints.Point( CIRC_CENTER ).SetPosition( m_circle.getCenter() );
294 aPoints.Point( CIRC_END ).SetPosition( m_circle.GetEnd() );
295 return true;
296}
297
298
300 EDIT_POINTS& aPoints, COMMIT& aCommit,
301 std::vector<EDA_ITEM*>& aUpdatedItems )
302{
304
305 const VECTOR2I& center = aPoints.Point( CIRC_CENTER ).GetPosition();
306 const VECTOR2I& end = aPoints.Point( CIRC_END ).GetPosition();
307
308 if( isModified( aEditedPoint, aPoints.Point( CIRC_CENTER ) ) )
309 m_circle.SetCenter( center );
310 else
311 m_circle.SetEnd( VECTOR2I( end.x, end.y ) );
312}
313
314
316 EDIT_POINTS& aPoints ) const
317{
318 return aPoints.Point( CIRC_CENTER ).GetPosition();
319}
320
321
323{
324 aPoints.AddPoint( m_bezier.GetStart() );
325 aPoints.AddPoint( m_bezier.GetBezierC1() );
326 aPoints.AddPoint( m_bezier.GetBezierC2() );
327 aPoints.AddPoint( m_bezier.GetEnd() );
328
329 aPoints.AddIndicatorLine( aPoints.Point( BEZIER_START ), aPoints.Point( BEZIER_CTRL_PT1 ) );
330 aPoints.AddIndicatorLine( aPoints.Point( BEZIER_CTRL_PT2 ), aPoints.Point( BEZIER_END ) );
331}
332
333
335{
336 wxCHECK( aPoints.PointsSize() == BEZIER_MAX_POINTS, false );
337
338 aPoints.Point( BEZIER_START ).SetPosition( m_bezier.GetStart() );
339 aPoints.Point( BEZIER_CTRL_PT1 ).SetPosition( m_bezier.GetBezierC1() );
340 aPoints.Point( BEZIER_CTRL_PT2 ).SetPosition( m_bezier.GetBezierC2() );
341 aPoints.Point( BEZIER_END ).SetPosition( m_bezier.GetEnd() );
342 return true;
343}
344
345
347 COMMIT& aCommit, std::vector<EDA_ITEM*>& aUpdatedItems )
348{
350
351 if( isModified( aEditedPoint, aPoints.Point( BEZIER_START ) ) )
352 {
353 m_bezier.SetStart( aPoints.Point( BEZIER_START ).GetPosition() );
354 }
355 else if( isModified( aEditedPoint, aPoints.Point( BEZIER_CTRL_PT1 ) ) )
356 {
357 m_bezier.SetBezierC1( aPoints.Point( BEZIER_CTRL_PT1 ).GetPosition() );
358 }
359 else if( isModified( aEditedPoint, aPoints.Point( BEZIER_CTRL_PT2 ) ) )
360 {
361 m_bezier.SetBezierC2( aPoints.Point( BEZIER_CTRL_PT2 ).GetPosition() );
362 }
363 else if( isModified( aEditedPoint, aPoints.Point( BEZIER_END ) ) )
364 {
365 m_bezier.SetEnd( aPoints.Point( BEZIER_END ).GetPosition() );
366 }
367
368 m_bezier.RebuildBezierToSegmentsPointsList( m_maxError );
369}
370
371
372// Note: these static arc functions don't have to be in here - we could ship them out
373// to a utils area for use by other code (e.g. polygon fillet editing).
374
378static void editArcEndpointKeepTangent( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
379 const VECTOR2I& aMid, const VECTOR2I& aEnd, const VECTOR2I& aCursor )
380{
381 VECTOR2I center = aCenter;
382 bool movingStart;
383 bool arcValid = true;
384
385 VECTOR2I p1, p2, p3;
386 // p1 does not move, p2 does.
387
388 if( aStart != aArc.GetStart() )
389 {
390 p1 = aEnd;
391 p2 = aStart;
392 p3 = aMid;
393 movingStart = true;
394 }
395 else if( aEnd != aArc.GetEnd() )
396 {
397 p1 = aStart;
398 p2 = aEnd;
399 p3 = aMid;
400 movingStart = false;
401 }
402 else
403 {
404 return;
405 }
406
407 VECTOR2D v1, v2, v3, v4;
408
409 // Move the coordinate system
410 v1 = p1 - aCenter;
411 v2 = p2 - aCenter;
412 v3 = p3 - aCenter;
413
414 VECTOR2D u1, u2;
415
416 // A point cannot be both the center and on the arc.
417 if( ( v1.EuclideanNorm() == 0 ) || ( v2.EuclideanNorm() == 0 ) )
418 return;
419
420 u1 = v1 / v1.EuclideanNorm();
421 u2 = v3 - ( u1.x * v3.x + u1.y * v3.y ) * u1;
422 u2 = u2 / u2.EuclideanNorm();
423
424 // [ u1, u3 ] is a base centered on the circle with:
425 // u1 : unit vector toward the point that does not move
426 // u2 : unit vector toward the mid point.
427
428 // Get vectors v1, and v2 in that coordinate system.
429
430 double det = u1.x * u2.y - u2.x * u1.y;
431
432 // u1 and u2 are unit vectors, and perpendicular.
433 // det should not be 0. In case it is, do not change the arc.
434 if( det == 0 )
435 return;
436
437 double tmpx = v1.x * u2.y - v1.y * u2.x;
438 double tmpy = -v1.x * u1.y + v1.y * u1.x;
439 v1.x = tmpx;
440 v1.y = tmpy;
441 v1 = v1 / det;
442
443 tmpx = v2.x * u2.y - v2.y * u2.x;
444 tmpy = -v2.x * u1.y + v2.y * u1.x;
445 v2.x = tmpx;
446 v2.y = tmpy;
447 v2 = v2 / det;
448
449 double R = v1.EuclideanNorm();
450 bool transformCircle = false;
451
452 /* p2
453 * X***
454 * ** <---- This is the arc
455 * y ^ **
456 * | R *
457 * | <-----------> *
458 * x------x------>--------x p1
459 * C' <----> C x
460 * delta
461 *
462 * p1 does not move, and the tangent at p1 remains the same.
463 * => The new center, C', will be on the C-p1 axis.
464 * p2 moves
465 *
466 * The radius of the new circle is delta + R
467 *
468 * || C' p2 || = || C' P1 ||
469 * is the same as :
470 * ( delta + p2.x ) ^ 2 + p2.y ^ 2 = ( R + delta ) ^ 2
471 *
472 * delta = ( R^2 - p2.x ^ 2 - p2.y ^2 ) / ( 2 * p2.x - 2 * R )
473 *
474 * We can use this equation for any point p2 with p2.x < R
475 */
476
477 if( v2.x == R )
478 {
479 // Straight line, do nothing
480 }
481 else
482 {
483 if( v2.x > R )
484 {
485 // If we need to invert the curvature.
486 // We modify the input so we can use the same equation
487 transformCircle = true;
488 v2.x = 2 * R - v2.x;
489 }
490
491 // We can keep the tangent constraint.
492 double delta = ( R * R - v2.x * v2.x - v2.y * v2.y ) / ( 2 * v2.x - 2 * R );
493
494 // This is just to limit the radius, so nothing overflows later when drawing.
495 if( abs( v2.y / ( R - v2.x ) ) > ADVANCED_CFG::GetCfg().m_DrawArcCenterMaxAngle )
496 arcValid = false;
497
498 // Never recorded a problem, but still checking.
499 if( !std::isfinite( delta ) )
500 arcValid = false;
501
502 // v4 is the new center
503 v4 = ( !transformCircle ) ? VECTOR2D( -delta, 0 ) : VECTOR2D( 2 * R + delta, 0 );
504
505 tmpx = v4.x * u1.x + v4.y * u2.x;
506 tmpy = v4.x * u1.y + v4.y * u2.y;
507 v4.x = tmpx;
508 v4.y = tmpy;
509
510 center = v4 + aCenter;
511
512 if( arcValid )
513 {
514 aArc.SetCenter( center );
515
516 if( movingStart )
517 aArc.SetStart( aStart );
518 else
519 aArc.SetEnd( aEnd );
520 }
521 }
522}
523
524
528static void editArcCenterKeepEndpoints( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
529 const VECTOR2I& aMid, const VECTOR2I& aEnd )
530{
531 const int c_snapEpsilon_sq = 4;
532
533 VECTOR2I m = ( aStart / 2 + aEnd / 2 );
534 VECTOR2I perp = ( aEnd - aStart ).Perpendicular().Resize( INT_MAX / 2 );
535
536 SEG legal( m - perp, m + perp );
537
538 const SEG testSegments[] = {
539 SEG( aCenter, aCenter + VECTOR2( 1, 0 ) ),
540 SEG( aCenter, aCenter + VECTOR2( 0, 1 ) ),
541 };
542
543 std::vector<VECTOR2I> points = { legal.A, legal.B };
544
545 for( const SEG& seg : testSegments )
546 {
547 OPT_VECTOR2I vec = legal.IntersectLines( seg );
548
549 if( vec && legal.SquaredDistance( *vec ) <= c_snapEpsilon_sq )
550 points.push_back( *vec );
551 }
552
553 OPT_VECTOR2I nearest;
555
556 // Snap by distance between cursor and intersections
557 for( const VECTOR2I& pt : points )
558 {
559 SEG::ecoord d_sq = ( pt - aCenter ).SquaredEuclideanNorm();
560
561 if( d_sq < min_d_sq - c_snapEpsilon_sq )
562 {
563 min_d_sq = d_sq;
564 nearest = pt;
565 }
566 }
567
568 if( nearest )
569 aArc.SetCenter( *nearest );
570}
571
572
577 const VECTOR2I& aStart, const VECTOR2I& aMid,
578 const VECTOR2I& aEnd, const VECTOR2I& aCursor,
579 const EDA_IU_SCALE& aIuScale )
580{
581 // 1 mil floor in the caller's units keeps the arc non-degenerate without
582 // snapping small eeschema arcs that are legitimately under 100 mils.
583 int minRadius = EDA_UNIT_UTILS::Mils2IU( aIuScale, 1 );
584 bool movingStart;
585
586 VECTOR2I p1, p2, prev_p1;
587
588 // user is moving p1, we want to move p2 to the new radius.
589
590 if( aStart != aArc.GetStart() )
591 {
592 prev_p1 = aArc.GetStart();
593 p1 = aStart;
594 p2 = aEnd;
595 movingStart = true;
596 }
597 else
598 {
599 prev_p1 = aArc.GetEnd();
600 p1 = aEnd;
601 p2 = aStart;
602 movingStart = false;
603 }
604
605 p1 = p1 - aCenter;
606 p2 = p2 - aCenter;
607
608 if( p1.x == 0 && p1.y == 0 )
609 p1 = prev_p1 - aCenter;
610
611 if( p2.x == 0 && p2.y == 0 )
612 p2 = { 1, 0 };
613
614 double radius = p1.EuclideanNorm();
615
616 if( radius < minRadius )
617 radius = minRadius;
618
619 p1 = aCenter + p1.Resize( KiROUND( radius ) );
620 p2 = aCenter + p2.Resize( KiROUND( radius ) );
621
622 aArc.SetCenter( aCenter );
623
624 if( movingStart )
625 {
626 aArc.SetStart( p1 );
627 aArc.SetEnd( p2 );
628 }
629 else
630 {
631 aArc.SetStart( p2 );
632 aArc.SetEnd( p1 );
633 }
634}
635
636
637static void editArcEndpointKeepCenterAndRadius( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
638 const VECTOR2I& aMid, const VECTOR2I& aEnd )
639{
640 VECTOR2I p1;
641 bool movingStart = false;
642
643 // User is moving p1, we need to update whichever end that is
644 // The other end won't move.
645
646 if( aStart != aArc.GetStart() )
647 {
648 p1 = aStart;
649 movingStart = true;
650 }
651 else
652 {
653 p1 = aEnd;
654 movingStart = false;
655 }
656
657 // Do not change the radius
658 p1 = p1 - aCenter;
659 p1 = aCenter + p1.Resize( aArc.GetRadius() );
660
661 if( movingStart )
662 {
663 aArc.SetStart( p1 );
664 }
665 else
666 {
667 aArc.SetEnd( p1 );
668 }
669}
670
671
676 const VECTOR2I& aStart, const VECTOR2I& aMid,
677 const VECTOR2I& aEnd, const VECTOR2I& aCursor,
678 const EDA_IU_SCALE& aIuScale )
679{
680 // See EditArcEndpointKeepCenter for why we use the caller's IU scale.
681 int minRadius = EDA_UNIT_UTILS::Mils2IU( aIuScale, 1 );
682
683 // Now, update the edit point position
684 // Express the point in a circle-centered coordinate system.
685 VECTOR2I start = aStart - aCenter;
686 VECTOR2I end = aEnd - aCenter;
687
688 double radius = ( aCursor - aCenter ).EuclideanNorm();
689
690 if( radius < minRadius )
691 radius = minRadius;
692
693 start = start.Resize( KiROUND( radius ) );
694 end = end.Resize( KiROUND( radius ) );
695
696 start = start + aCenter;
697 end = end + aCenter;
698
699 aArc.SetStart( start );
700 aArc.SetEnd( end );
701}
702
703
707static void editArcMidKeepEndpoints( EDA_SHAPE& aArc, const VECTOR2I& aStart, const VECTOR2I& aEnd,
708 const VECTOR2I& aCursor )
709{
710 // Let 'm' be the middle point of the chord between the start and end points
711 VECTOR2I m = ( aStart + aEnd ) / 2;
712
713 // Legal midpoints lie on a vector starting just off the chord midpoint and extending out
714 // past the existing midpoint. We do not allow arc inflection while point editing.
715 const int JUST_OFF = ( aStart - aEnd ).EuclideanNorm() / 100;
716 VECTOR2I v = (VECTOR2I) aArc.GetArcMid() - m;
717 SEG legal( m + v.Resize( JUST_OFF ), m + v.Resize( INT_MAX / 2 ) );
718 VECTOR2I mid = legal.NearestPoint( aCursor );
719
720 if( !IsStraightArc( aStart, mid, aEnd ) )
721 aArc.SetArcGeometry( aStart, mid, aEnd );
722}
723
724
726 KIGFX::VIEW_CONTROLS& aViewContols,
727 const EDA_IU_SCALE& aIuScale ) :
728 m_arc( aArc ),
729 m_arcEditMode( aArcEditMode ),
730 m_viewControls( aViewContols ),
731 m_iuScale( aIuScale )
732{
733 wxASSERT( m_arc.GetShape() == SHAPE_T::ARC );
734}
735
736
738{
739 aPoints.AddPoint( m_arc.GetStart() );
740 aPoints.AddPoint( m_arc.GetArcMid() );
741 aPoints.AddPoint( m_arc.GetEnd() );
742 aPoints.AddPoint( m_arc.getCenter() );
743
744 aPoints.AddIndicatorLine( aPoints.Point( ARC_CENTER ), aPoints.Point( ARC_START ) );
745 aPoints.AddIndicatorLine( aPoints.Point( ARC_CENTER ), aPoints.Point( ARC_END ) );
746}
747
748
750{
751 wxCHECK( aPoints.PointsSize() == 4, false );
752
753 aPoints.Point( ARC_START ).SetPosition( m_arc.GetStart() );
754 aPoints.Point( ARC_MID ).SetPosition( m_arc.GetArcMid() );
755 aPoints.Point( ARC_END ).SetPosition( m_arc.GetEnd() );
756 aPoints.Point( ARC_CENTER ).SetPosition( m_arc.getCenter() );
757 return true;
758}
759
760
761void EDA_ARC_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
762 std::vector<EDA_ITEM*>& aUpdatedItems )
763{
764 CHECK_POINT_COUNT( aPoints, 4 );
765
767 VECTOR2I mid = aPoints.Point( ARC_MID ).GetPosition();
768 VECTOR2I start = aPoints.Point( ARC_START ).GetPosition();
769 VECTOR2I end = aPoints.Point( ARC_END ).GetPosition();
770
771 if( isModified( aEditedPoint, aPoints.Point( ARC_CENTER ) ) )
772 {
773 switch( m_arcEditMode )
774 {
777 break;
778
781 {
782 // Both these modes just move the arc
783 VECTOR2I moveVector = center - m_arc.getCenter();
784
785 m_arc.SetArcGeometry( m_arc.GetStart() + moveVector, m_arc.GetArcMid() + moveVector,
786 m_arc.GetEnd() + moveVector );
787 break;
788 }
789 }
790 }
791 else if( isModified( aEditedPoint, aPoints.Point( ARC_MID ) ) )
792 {
793 const VECTOR2I& cursorPos = m_viewControls.GetCursorPosition( false );
794
795 switch( m_arcEditMode )
796 {
798 editArcMidKeepEndpoints( m_arc, start, end, cursorPos );
799 break;
802 KI_ARC_EDIT::EditArcMidKeepCenter( m_arc, center, start, mid, end, cursorPos, m_iuScale );
803 break;
804 }
805 }
806 else if( isModified( aEditedPoint, aPoints.Point( ARC_START ) )
807 || isModified( aEditedPoint, aPoints.Point( ARC_END ) ) )
808 {
809 const VECTOR2I& cursorPos = m_viewControls.GetCursorPosition();
810
811 switch( m_arcEditMode )
812 {
815 break;
818 break;
820 editArcEndpointKeepTangent( m_arc, center, start, mid, end, cursorPos );
821 break;
822 }
823 }
824}
825
826
828 EDIT_POINTS& aPoints ) const
829{
830 return aPoints.Point( ARC_CENTER ).GetPosition();
831}
832
833
835{
836 aPoints.AddPoint( m_cell.GetEnd() - VECTOR2I( 0, m_cell.GetRectangleHeight() / 2 ) );
837 aPoints.AddPoint( m_cell.GetEnd() - VECTOR2I( m_cell.GetRectangleWidth() / 2, 0 ) );
838}
839
840
842{
843 aPoints.Point( COL_WIDTH ).SetPosition( m_cell.GetEnd() - VECTOR2I( 0, m_cell.GetRectangleHeight() / 2 ) );
844 aPoints.Point( ROW_HEIGHT ).SetPosition( m_cell.GetEnd() - VECTOR2I( m_cell.GetRectangleWidth() / 2, 0 ) );
845 return true;
846}
847
848
850{
851 for( int i = 0; i < REFIMG_MAX_POINTS; ++i )
852 aPoints.AddPoint( {} );
853
854 // Four lines to mark the corners of the bounding box.
855 aPoints.AddIndicatorLine( aPoints.Point( REFIMG_TOP_LEFT ), aPoints.Point( REFIMG_TOP_RIGHT ) );
856 aPoints.AddIndicatorLine( aPoints.Point( REFIMG_TOP_RIGHT ), aPoints.Point( REFIMG_BOT_RIGHT ) );
857 aPoints.AddIndicatorLine( aPoints.Point( REFIMG_BOT_RIGHT ), aPoints.Point( REFIMG_BOT_LEFT ) );
858 aPoints.AddIndicatorLine( aPoints.Point( REFIMG_BOT_LEFT ), aPoints.Point( REFIMG_TOP_LEFT ) );
859
860 aPoints.AddIndicatorLine( aPoints.Point( REFIMG_ORIGIN ), aPoints.Point( REFIMG_ROTATION ) );
861
862 UpdatePoints( aPoints );
863}
864
865
867{
868 wxCHECK( aPoints.PointsSize() == REFIMG_MAX_POINTS, false );
869
870 const VECTOR2I size = m_image.GetBoundingBox().GetSize();
871
872 const VECTOR2I topLeft = m_image.GetPosition() - size / 2;
873 const VECTOR2I botRight = m_image.GetPosition() + size / 2;
874
875 aPoints.Point( REFIMG_TOP_LEFT ).SetPosition( topLeft );
876 aPoints.Point( REFIMG_TOP_RIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) );
877 aPoints.Point( REFIMG_BOT_RIGHT ).SetPosition( botRight );
878 aPoints.Point( REFIMG_BOT_LEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) );
879
880 const VECTOR2I origin = m_image.GetPosition() + m_image.GetTransformOriginOffset();
881 aPoints.Point( REFIMG_ORIGIN ).SetPosition( origin );
882
883 // The rotation handle extends above the image by a short distance (20%), anchored at the
884 // transform origin.
885 const EDA_ANGLE angle = m_image.GetOrientation();
886 const VECTOR2I localOffset = GetRotated( m_image.GetTransformOriginOffset(), -angle );
887 const int handleLength = localOffset.y + KiROUND( m_image.GetSize().y * 0.7 );
888
889 // Now we have the length of the handle, construct the vector
890 const VECTOR2I originToRot = GetRotated( VECTOR2I( 0, -handleLength ), angle );
891
892 aPoints.Point( REFIMG_ROTATION ).SetPosition( origin + originToRot );
893
894 return true;
895}
896
897
899 COMMIT& aCommit, std::vector<EDA_ITEM*>& aUpdatedItems )
900{
902
903 const VECTOR2I topLeft = aPoints.Point( REFIMG_TOP_LEFT ).GetPosition();
904 const VECTOR2I topRight = aPoints.Point( REFIMG_TOP_RIGHT ).GetPosition();
905 const VECTOR2I botRight = aPoints.Point( REFIMG_BOT_RIGHT ).GetPosition();
906 const VECTOR2I botLeft = aPoints.Point( REFIMG_BOT_LEFT ).GetPosition();
907 const VECTOR2I xfrmOrigin = aPoints.Point( REFIMG_ORIGIN ).GetPosition();
908
909 if( isModified( aEditedPoint, aPoints.Point( REFIMG_ORIGIN ) ) )
910 {
911 // Moving the transform origin
912 // As the other points didn't move, we can get the image extent from them
913 m_image.SetTransformOriginOffset( xfrmOrigin - ( topLeft + botRight ) / 2 );
914 return;
915 }
916
917 if( isModified( aEditedPoint, aPoints.Point( REFIMG_ROTATION ) ) )
918 {
919 // Rotating the image around the transform origin
920 const VECTOR2I origin = m_image.GetPosition() + m_image.GetTransformOriginOffset();
921 const VECTOR2I cursorVec = aEditedPoint.GetPosition() - origin;
922 const double angle = std::atan2( -cursorVec.y, cursorVec.x );
923
924 // The angle handle is vertical, offset by 90 degrees from the horizontal.
925 const EDA_ANGLE target = EDA_ANGLE( angle, RADIANS_T ) - ANGLE_90;
926
927 // Rotate the image around the transform origin so that the handle
928 // aligns with the target angle.
929 m_image.Rotate( origin, target - m_image.GetOrientation() );
930 return;
931 }
932
933 const VECTOR2I oldOrigin = m_image.GetPosition() + m_image.GetTransformOriginOffset();
934 const VECTOR2I oldSize = m_image.GetBoundingBox().GetSize();
935
936 OPT_VECTOR2I newCorner;
937 VECTOR2I oldCorner = m_image.GetPosition();
938
939 if( isModified( aEditedPoint, aPoints.Point( REFIMG_TOP_LEFT ) ) )
940 {
941 newCorner = topLeft;
942 oldCorner -= oldSize / 2;
943 }
944 else if( isModified( aEditedPoint, aPoints.Point( REFIMG_TOP_RIGHT ) ) )
945 {
946 newCorner = topRight;
947 oldCorner -= VECTOR2I( -oldSize.x, oldSize.y ) / 2;
948 }
949 else if( isModified( aEditedPoint, aPoints.Point( REFIMG_BOT_LEFT ) ) )
950 {
951 newCorner = botLeft;
952 oldCorner -= VECTOR2I( oldSize.x, -oldSize.y ) / 2;
953 }
954 else if( isModified( aEditedPoint, aPoints.Point( REFIMG_BOT_RIGHT ) ) )
955 {
956 newCorner = botRight;
957 oldCorner += oldSize / 2;
958 }
959
960 if( !newCorner )
961 return;
962
963 // Turn in the respective vectors from the origin
964 *newCorner -= xfrmOrigin;
965 oldCorner -= oldOrigin;
966
967 // If we tried to cross the origin, clamp it to stop it
968 if( sign( newCorner->x ) != sign( oldCorner.x ) || sign( newCorner->y ) != sign( oldCorner.y ) )
969 *newCorner = VECTOR2I( 0, 0 );
970
971 const double newLength = newCorner->EuclideanNorm();
972 const double oldLength = oldCorner.EuclideanNorm();
973
974 double ratio = oldLength > 0 ? ( newLength / oldLength ) : 1.0;
975
976 // Clamp the scaling to the minimum image size the editor allows
977 const VECTOR2I newSize = oldSize * ratio;
978 const double newWidth = std::max( newSize.x, m_minSize );
979 const double newHeight = std::max( newSize.y, m_minSize );
980 ratio = std::min( newWidth / oldSize.x, newHeight / oldSize.y );
981
982 // SetImageScale keeps the transform origin in place, which is what the origin handle pins.
983 m_image.SetImageScale( m_image.GetImageScale() * ratio );
984}
985
986
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_ENDPOINTS_OR_START_DIRECTION
Whe editing endpoints, the other end remains in place.
@ KEEP_CENTER_ENDS_ADJUST_ANGLE
When editing endpoints, only the angle is adjusted.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
double Sin() const
Definition eda_angle.h:177
double Cos() const
Definition eda_angle.h:196
EDA_ARC_POINT_EDIT_BEHAVIOR(EDA_SHAPE &aArc, const ARC_EDIT_MODE &aArcEditMode, KIGFX::VIEW_CONTROLS &aViewContols, const EDA_IU_SCALE &aIuScale)
const ARC_EDIT_MODE & m_arcEditMode
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
KIGFX::VIEW_CONTROLS & m_viewControls
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
EDA_ANGLE parametricAngleOf(const VECTOR2I &aWorldPt) const
Inverse: the parametric angle of a world-space point relative to this ellipse.
VECTOR2I evaluateAt(const EDA_ANGLE &aTheta) const
World-space point on the ellipse at the given parametric angle.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:338
virtual void SetCenter(const VECTOR2I &aCenter)
int GetRadius() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:334
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:284
virtual void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
virtual void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:288
VECTOR2I GetArcMid() const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void SetDragPolicy(std::unique_ptr< POLYGON_EDGE_DRAG_POLICY > aPolicy)
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
unsigned int PointsSize() const
Return number of stored EDIT_POINTs.
void AddPoint(const EDIT_POINT &aPoint)
Add an EDIT_POINT.
void Clear()
Clear all stored EDIT_POINTs and EDIT_LINEs.
EDIT_POINT * Next(const EDIT_POINT &aPoint, bool aTraverseContours=true)
Return the point that is before the given point in the list.
EDIT_LINE & Line(unsigned int aIndex)
bool IsContourEnd(int aPointIdx) const
Check is a point with given index is a contour finish.
void AddIndicatorLine(EDIT_POINT &aOrigin, EDIT_POINT &aEnd)
Adds an EDIT_LINE that is shown as an indicator, rather than an editable line (no center point drag,...
void AddBreak()
Adds a break, indicating the end of a contour.
int GetContourStartIdx(int aPointIdx) const
Return index of the contour origin for a point with given index.
unsigned int LinesSize() const
Return number of stored EDIT_LINEs.
EDIT_POINT & Point(unsigned int aIndex)
void AddLine(const EDIT_LINE &aLine)
Adds an EDIT_LINE.
Represent a single point that can be used for modifying items.
Definition edit_points.h:44
void SetDrivesWholeShape(bool aDrives=true)
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition edit_points.h:72
Plain ellipse / elliptical-arc data.
Definition ellipse.h:32
VECTOR2< NumericType > GetPointAtAngle(EDA_ANGLE angle) const
Get the point on the ellipse at a given angle.
Definition ellipse.cpp:90
EDA_ANGLE GetAngleAtPoint(const VECTOR2< NumericType > &aPt) const
Get the parametric angle of a point on the ellipse.
Definition ellipse.cpp:109
VECTOR2< NumericType > Center
Definition ellipse.h:101
An interface for classes handling user events controlling the view behavior such as zooming,...
static bool isModified(const EDIT_POINT &aEditedPoint, const EDIT_POINT &aPoint)
Checks if two points are the same instance - which means the point is being edited.
static void UpdateOutlineFromPoints(SHAPE_POLY_SET &aOutline, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update the polygon outline with the new positions of the edit points.
static void UpdatePointsFromOutline(const SHAPE_POLY_SET &aOutline, EDIT_POINTS &aPoints)
Update the edit points with the current polygon outline.
void FinalizeItem(EDIT_POINTS &aPoints, COMMIT &aCommit) override
Finalize the edit operation.
static void BuildForPolyOutline(EDIT_POINTS &aPoints, const SHAPE_POLY_SET &aOutline)
Build the edit points for the given polygon outline.
static void RemoveNullSegmentsIfPolygonSurvives(SHAPE_POLY_SET &aOutline)
Remove the zero length segments left by an edit, unless that would strip the outline down to somethin...
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
ecoord SquaredDistance(const SEG &aSeg) const
Definition seg.cpp:35
VECTOR2I::extended_type ecoord
Definition seg.h:40
VECTOR2I B
Definition seg.h:46
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition seg.cpp:599
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
Definition seg.h:217
Represent a set of closed polygons.
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int TotalVertices() const
Return total number of vertices stored in the set.
int RemoveNullSegments()
Look for null segments; ie, segments whose ends are exactly the same and deletes them.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
CONST_ITERATOR CIterateWithHoles(int aOutline) const
Define a general 2D-vector/point.
Definition vector2d.h:67
static constexpr extended_type ECOORD_MAX
Definition vector2d.h:72
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition vector2d.h:281
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition vector2d.h:406
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:472
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:474
@ RADIANS_T
Definition eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:478
@ ELLIPSE_ARC
Definition eda_shape.h:64
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
Definition eda_units.h:169
void EditArcEndpointKeepCenter(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor, const EDA_IU_SCALE &aIuScale)
Move an arc endpoint around the existing center, pulling the opposite endpoint along to keep the radi...
void EditArcMidKeepCenter(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor, const EDA_IU_SCALE &aIuScale)
Move the mid point of an arc while keeping the center, rotating the endpoints onto the new radius.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:461
static void editArcEndpointKeepCenterAndRadius(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
ARC_EDIT_MODE IncrementArcEditMode(ARC_EDIT_MODE aMode)
static void editArcCenterKeepEndpoints(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Move the arc center but keep endpoint locations.
static void editArcMidKeepEndpoints(EDA_SHAPE &aArc, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor)
Move the mid point of the arc, while keeping the angle.
static void editArcEndpointKeepTangent(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor)
Move an end point of the arc, while keeping the tangent at the other endpoint.
#define CHECK_POINT_COUNT(aPoints, aExpected)
#define CHECK_POINT_COUNT_GE(aPoints, aExpected)
std::optional< VECTOR2I > OPT_VECTOR2I
Definition seg.h:35
VECTOR3I expected(15, 30, 45)
VECTOR3I v1(5, 5, 5)
VECTOR2I center
int radius
VECTOR2I end
static double sweep(float aStart, float aEnd)
VECTOR2I v2(1, 0)
VECTOR2I v4(1, 1)
VECTOR2I v3(-2, 1)
int delta
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
Definition trigo.h:73
bool IsStraightArc(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Definition trigo.cpp:549
constexpr int sign(T val)
Definition util.h:167
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707