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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <advanced_config.h>
28
29
31 const SHAPE_POLY_SET& aOutline )
32{
33 const int cornersCount = aOutline.TotalVertices();
34
35 for( auto iterator = aOutline.CIterateWithHoles(); iterator; iterator++ )
36 {
37 aPoints.AddPoint( *iterator );
38
39 if( iterator.IsEndContour() )
40 aPoints.AddBreak();
41 }
42
43 // Lines have to be added after creating edit points, as they use EDIT_POINT references
44 for( int i = 0; i < cornersCount - 1; ++i )
45 {
46 if( aPoints.IsContourEnd( i ) )
47 aPoints.AddLine( aPoints.Point( i ), aPoints.Point( aPoints.GetContourStartIdx( i ) ) );
48 else
49 aPoints.AddLine( aPoints.Point( i ), aPoints.Point( i + 1 ) );
50
51 aPoints.Line( i ).SetConstraint( new EC_PERPLINE( aPoints.Line( i ) ) );
52 }
53
54 // The last missing line, connecting the last and the first polygon point
55 aPoints.AddLine( aPoints.Point( cornersCount - 1 ),
56 aPoints.Point( aPoints.GetContourStartIdx( cornersCount - 1 ) ) );
57
58 aPoints.Line( aPoints.LinesSize() - 1 )
59 .SetConstraint( new EC_PERPLINE( aPoints.Line( aPoints.LinesSize() - 1 ) ) );
60}
61
62
64 EDIT_POINTS& aPoints )
65{
66 // No size check here, as we can and will rebuild if that fails
67 if( aPoints.PointsSize() != (unsigned) aOutline.TotalVertices() )
68 {
69 // Rebuild the points list
70 aPoints.Clear();
71 BuildForPolyOutline( aPoints, aOutline );
72 }
73 else
74 {
75 for( int i = 0; i < aOutline.TotalVertices(); ++i )
76 {
77 aPoints.Point( i ).SetPosition( aOutline.CVertex( i ) );
78 }
79 }
80}
81
82
84 const EDIT_POINT& aEditedPoint,
85 EDIT_POINTS& aPoints )
86{
87 CHECK_POINT_COUNT_GE( aPoints, (unsigned) aOutline.TotalVertices() );
88
89 for( int i = 0; i < aOutline.TotalVertices(); ++i )
90 {
91 aOutline.SetVertex( i, aPoints.Point( i ).GetPosition() );
92 }
93
94 for( unsigned i = 0; i < aPoints.LinesSize(); ++i )
95 {
96 if( !isModified( aEditedPoint, aPoints.Line( i ) ) )
97 {
98 aPoints.Line( i ).SetConstraint( new EC_PERPLINE( aPoints.Line( i ) ) );
99 }
100 }
101}
102
103
105{
106 aPoints.AddPoint( m_segment.GetStart() );
107 aPoints.AddPoint( m_segment.GetEnd() );
108}
109
110
112{
114
115 aPoints.Point( SEGMENT_START ) = m_segment.GetStart();
116 aPoints.Point( SEGMENT_END ) = m_segment.GetEnd();
117}
118
119
121 EDIT_POINTS& aPoints, COMMIT& aCommit,
122 std::vector<EDA_ITEM*>& aUpdatedItems )
123{
125
126 if( isModified( aEditedPoint, aPoints.Point( SEGMENT_START ) ) )
128
129 else if( isModified( aEditedPoint, aPoints.Point( SEGMENT_END ) ) )
131}
132
135 EDIT_POINTS& aPoints ) const
136{
137 // Select the other end of line
138 return aPoints.Next( aEditedPoint )->GetPosition();
139}
140
141
143{
144 aPoints.AddPoint( m_circle.getCenter() );
145 aPoints.AddPoint( m_circle.GetEnd() );
146}
147
148
150{
152
154 aPoints.Point( CIRC_END ).SetPosition( m_circle.GetEnd() );
155}
156
157
159 EDIT_POINTS& aPoints, COMMIT& aCommit,
160 std::vector<EDA_ITEM*>& aUpdatedItems )
161{
163
164 const VECTOR2I& center = aPoints.Point( CIRC_CENTER ).GetPosition();
165 const VECTOR2I& end = aPoints.Point( CIRC_END ).GetPosition();
166
167 if( isModified( aEditedPoint, aPoints.Point( CIRC_CENTER ) ) )
168 {
170 }
171 else
172 {
174 }
175}
176
177
180 EDIT_POINTS& aPoints ) const
181{
182 return aPoints.Point( CIRC_CENTER ).GetPosition();
183}
184
185
187{
188 aPoints.AddPoint( m_bezier.GetStart() );
189 aPoints.AddPoint( m_bezier.GetBezierC1() );
190 aPoints.AddPoint( m_bezier.GetBezierC2() );
191 aPoints.AddPoint( m_bezier.GetEnd() );
192
193 aPoints.AddIndicatorLine( aPoints.Point( BEZIER_START ), aPoints.Point( BEZIER_CTRL_PT1 ) );
194 aPoints.AddIndicatorLine( aPoints.Point( BEZIER_CTRL_PT2 ), aPoints.Point( BEZIER_END ) );
195}
196
197
199{
201
206}
207
208
210 EDIT_POINTS& aPoints, COMMIT& aCommit,
211 std::vector<EDA_ITEM*>& aUpdatedItems )
212{
214
215 if( isModified( aEditedPoint, aPoints.Point( BEZIER_START ) ) )
216 {
218 }
219 else if( isModified( aEditedPoint, aPoints.Point( BEZIER_CTRL_PT1 ) ) )
220 {
222 }
223 else if( isModified( aEditedPoint, aPoints.Point( BEZIER_CTRL_PT2 ) ) )
224 {
226 }
227 else if( isModified( aEditedPoint, aPoints.Point( BEZIER_END ) ) )
228 {
230 }
231
233}
234
235
236// Note: these static arc functions don't have to be in here - we could ship them out
237// to a utils area for use by other code (e.g. polygon fillet editing).
238
242static void editArcEndpointKeepTangent( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
243 const VECTOR2I& aMid, const VECTOR2I& aEnd, const VECTOR2I& aCursor )
244{
245 VECTOR2I center = aCenter;
246 bool movingStart;
247 bool arcValid = true;
248
249 VECTOR2I p1, p2, p3;
250 // p1 does not move, p2 does.
251
252 if( aStart != aArc.GetStart() )
253 {
254 p1 = aEnd;
255 p2 = aStart;
256 p3 = aMid;
257 movingStart = true;
258 }
259 else if( aEnd != aArc.GetEnd() )
260 {
261 p1 = aStart;
262 p2 = aEnd;
263 p3 = aMid;
264 movingStart = false;
265 }
266 else
267 {
268 return;
269 }
270
271 VECTOR2D v1, v2, v3, v4;
272
273 // Move the coordinate system
274 v1 = p1 - aCenter;
275 v2 = p2 - aCenter;
276 v3 = p3 - aCenter;
277
278 VECTOR2D u1, u2;
279
280 // A point cannot be both the center and on the arc.
281 if( ( v1.EuclideanNorm() == 0 ) || ( v2.EuclideanNorm() == 0 ) )
282 return;
283
284 u1 = v1 / v1.EuclideanNorm();
285 u2 = v3 - ( u1.x * v3.x + u1.y * v3.y ) * u1;
286 u2 = u2 / u2.EuclideanNorm();
287
288 // [ u1, u3 ] is a base centered on the circle with:
289 // u1 : unit vector toward the point that does not move
290 // u2 : unit vector toward the mid point.
291
292 // Get vectors v1, and v2 in that coordinate system.
293
294 double det = u1.x * u2.y - u2.x * u1.y;
295
296 // u1 and u2 are unit vectors, and perpendicular.
297 // det should not be 0. In case it is, do not change the arc.
298 if( det == 0 )
299 return;
300
301 double tmpx = v1.x * u2.y - v1.y * u2.x;
302 double tmpy = -v1.x * u1.y + v1.y * u1.x;
303 v1.x = tmpx;
304 v1.y = tmpy;
305 v1 = v1 / det;
306
307 tmpx = v2.x * u2.y - v2.y * u2.x;
308 tmpy = -v2.x * u1.y + v2.y * u1.x;
309 v2.x = tmpx;
310 v2.y = tmpy;
311 v2 = v2 / det;
312
313 double R = v1.EuclideanNorm();
314 bool transformCircle = false;
315
316 /* p2
317 * X***
318 * ** <---- This is the arc
319 * y ^ **
320 * | R *
321 * | <-----------> *
322 * x------x------>--------x p1
323 * C' <----> C x
324 * delta
325 *
326 * p1 does not move, and the tangent at p1 remains the same.
327 * => The new center, C', will be on the C-p1 axis.
328 * p2 moves
329 *
330 * The radius of the new circle is delta + R
331 *
332 * || C' p2 || = || C' P1 ||
333 * is the same as :
334 * ( delta + p2.x ) ^ 2 + p2.y ^ 2 = ( R + delta ) ^ 2
335 *
336 * delta = ( R^2 - p2.x ^ 2 - p2.y ^2 ) / ( 2 * p2.x - 2 * R )
337 *
338 * We can use this equation for any point p2 with p2.x < R
339 */
340
341 if( v2.x == R )
342 {
343 // Straight line, do nothing
344 }
345 else
346 {
347 if( v2.x > R )
348 {
349 // If we need to invert the curvature.
350 // We modify the input so we can use the same equation
351 transformCircle = true;
352 v2.x = 2 * R - v2.x;
353 }
354
355 // We can keep the tangent constraint.
356 double delta = ( R * R - v2.x * v2.x - v2.y * v2.y ) / ( 2 * v2.x - 2 * R );
357
358 // This is just to limit the radius, so nothing overflows later when drawing.
359 if( abs( v2.y / ( R - v2.x ) ) > ADVANCED_CFG::GetCfg().m_DrawArcCenterMaxAngle )
360 arcValid = false;
361
362 // Never recorded a problem, but still checking.
363 if( !std::isfinite( delta ) )
364 arcValid = false;
365
366 // v4 is the new center
367 v4 = ( !transformCircle ) ? VECTOR2D( -delta, 0 ) : VECTOR2D( 2 * R + delta, 0 );
368
369 tmpx = v4.x * u1.x + v4.y * u2.x;
370 tmpy = v4.x * u1.y + v4.y * u2.y;
371 v4.x = tmpx;
372 v4.y = tmpy;
373
374 center = v4 + aCenter;
375
376 if( arcValid )
377 {
378 aArc.SetCenter( center );
379
380 if( movingStart )
381 aArc.SetStart( aStart );
382 else
383 aArc.SetEnd( aEnd );
384 }
385 }
386}
387
388
392static void editArcCenterKeepEndpoints( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
393 const VECTOR2I& aMid, const VECTOR2I& aEnd )
394{
395 const int c_snapEpsilon_sq = 4;
396
397 VECTOR2I m = ( aStart / 2 + aEnd / 2 );
398 VECTOR2I perp = ( aEnd - aStart ).Perpendicular().Resize( INT_MAX / 2 );
399
400 SEG legal( m - perp, m + perp );
401
402 const SEG testSegments[] = {
403 SEG( aCenter, aCenter + VECTOR2( 1, 0 ) ),
404 SEG( aCenter, aCenter + VECTOR2( 0, 1 ) ),
405 };
406
407 std::vector<VECTOR2I> points = { legal.A, legal.B };
408
409 for( const SEG& seg : testSegments )
410 {
411 OPT_VECTOR2I vec = legal.IntersectLines( seg );
412
413 if( vec && legal.SquaredDistance( *vec ) <= c_snapEpsilon_sq )
414 points.push_back( *vec );
415 }
416
417 OPT_VECTOR2I nearest;
419
420 // Snap by distance between cursor and intersections
421 for( const VECTOR2I& pt : points )
422 {
423 SEG::ecoord d_sq = ( pt - aCenter ).SquaredEuclideanNorm();
424
425 if( d_sq < min_d_sq - c_snapEpsilon_sq )
426 {
427 min_d_sq = d_sq;
428 nearest = pt;
429 }
430 }
431
432 if( nearest )
433 aArc.SetCenter( *nearest );
434}
435
436
440static void editArcEndpointKeepCenter( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
441 const VECTOR2I& aMid, const VECTOR2I& aEnd, const VECTOR2I& aCursor )
442{
443 int minRadius = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 1 );
444 bool movingStart;
445
446 VECTOR2I p1, p2, prev_p1;
447
448 // user is moving p1, we want to move p2 to the new radius.
449
450 if( aStart != aArc.GetStart() )
451 {
452 prev_p1 = aArc.GetStart();
453 p1 = aStart;
454 p2 = aEnd;
455 movingStart = true;
456 }
457 else
458 {
459 prev_p1 = aArc.GetEnd();
460 p1 = aEnd;
461 p2 = aStart;
462 movingStart = false;
463 }
464
465 p1 = p1 - aCenter;
466 p2 = p2 - aCenter;
467
468 if( p1.x == 0 && p1.y == 0 )
469 p1 = prev_p1 - aCenter;
470
471 if( p2.x == 0 && p2.y == 0 )
472 p2 = { 1, 0 };
473
474 double radius = p1.EuclideanNorm();
475
476 if( radius < minRadius )
477 radius = minRadius;
478
479 p1 = aCenter + p1.Resize( radius );
480 p2 = aCenter + p2.Resize( radius );
481
482 aArc.SetCenter( aCenter );
483
484 if( movingStart )
485 {
486 aArc.SetStart( p1 );
487 aArc.SetEnd( p2 );
488 }
489 else
490 {
491 aArc.SetStart( p2 );
492 aArc.SetEnd( p1 );
493 }
494}
495
496
497static void editArcEndpointKeepCenterAndRadius( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
498 const VECTOR2I& aMid, const VECTOR2I& aEnd )
499{
500 VECTOR2I p1;
501 bool movingStart = false;
502
503 // User is moving p1, we need to update whichever end that is
504 // The other end won't move.
505
506 if( aStart != aArc.GetStart() )
507 {
508 p1 = aStart;
509 movingStart = true;
510 }
511 else
512 {
513 p1 = aEnd;
514 movingStart = false;
515 }
516
517 // Do not change the radius
518 p1 = p1 - aCenter;
519 p1 = aCenter + p1.Resize( aArc.GetRadius() );
520
521 if( movingStart )
522 {
523 aArc.SetStart( p1 );
524 }
525 else
526 {
527 aArc.SetEnd( p1 );
528 }
529}
530
531
535static void editArcMidKeepCenter( EDA_SHAPE& aArc, const VECTOR2I& aCenter, const VECTOR2I& aStart,
536 const VECTOR2I& aMid, const VECTOR2I& aEnd, const VECTOR2I& aCursor )
537{
538 int minRadius = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 1 );
539
540 SEG chord( aStart, aEnd );
541
542 // Now, update the edit point position
543 // Express the point in a circle-centered coordinate system.
544 VECTOR2I start = aStart - aCenter;
545 VECTOR2I end = aEnd - aCenter;
546
547 double radius = ( aCursor - aCenter ).EuclideanNorm();
548
549 if( radius < minRadius )
550 radius = minRadius;
551
552 start = start.Resize( radius );
553 end = end.Resize( radius );
554
555 start = start + aCenter;
556 end = end + aCenter;
557
558 aArc.SetStart( start );
559 aArc.SetEnd( end );
560}
561
562
566static void editArcMidKeepEndpoints( EDA_SHAPE& aArc, const VECTOR2I& aStart, const VECTOR2I& aEnd,
567 const VECTOR2I& aCursor )
568{
569 // Let 'm' be the middle point of the chord between the start and end points
570 VECTOR2I m = ( aStart + aEnd ) / 2;
571
572 // Legal midpoints lie on a vector starting just off the chord midpoint and extending out
573 // past the existing midpoint. We do not allow arc inflection while point editing.
574 const int JUST_OFF = ( aStart - aEnd ).EuclideanNorm() / 100;
575 VECTOR2I v = (VECTOR2I) aArc.GetArcMid() - m;
576 SEG legal( m + v.Resize( JUST_OFF ), m + v.Resize( INT_MAX / 2 ) );
577 VECTOR2I mid = legal.NearestPoint( aCursor );
578
579 aArc.SetArcGeometry( aStart, mid, aEnd );
580}
581
582
584 KIGFX::VIEW_CONTROLS& aViewContols ) :
585 m_arc( aArc ), m_arcEditMode( aArcEditMode ), m_viewControls( aViewContols )
586{
587 wxASSERT( m_arc.GetShape() == SHAPE_T::ARC );
588}
589
590
592{
593 aPoints.AddPoint( m_arc.GetStart() );
594 aPoints.AddPoint( m_arc.GetArcMid() );
595 aPoints.AddPoint( m_arc.GetEnd() );
596 aPoints.AddPoint( m_arc.getCenter() );
597
598 aPoints.AddIndicatorLine( aPoints.Point( ARC_CENTER ), aPoints.Point( ARC_START ) );
599 aPoints.AddIndicatorLine( aPoints.Point( ARC_CENTER ), aPoints.Point( ARC_END ) );
600}
601
602
604{
605 CHECK_POINT_COUNT( aPoints, 4 );
606
607 aPoints.Point( ARC_START ).SetPosition( m_arc.GetStart() );
608 aPoints.Point( ARC_MID ).SetPosition( m_arc.GetArcMid() );
609 aPoints.Point( ARC_END ).SetPosition( m_arc.GetEnd() );
611}
612
613
614void EDA_ARC_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
615 std::vector<EDA_ITEM*>& aUpdatedItems )
616{
617 CHECK_POINT_COUNT( aPoints, 4 );
618
620 VECTOR2I mid = aPoints.Point( ARC_MID ).GetPosition();
621 VECTOR2I start = aPoints.Point( ARC_START ).GetPosition();
622 VECTOR2I end = aPoints.Point( ARC_END ).GetPosition();
623
624 if( isModified( aEditedPoint, aPoints.Point( ARC_CENTER ) ) )
625 {
626 switch( m_arcEditMode )
627 {
628 case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION:
630 break;
631 case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS:
632 case ARC_EDIT_MODE::KEEP_CENTER_ENDS_ADJUST_ANGLE:
633 {
634 // Both these modes just move the arc
635 VECTOR2I moveVector = VECTOR2I( center.x, center.y ) - m_arc.getCenter();
636
637 m_arc.SetArcGeometry( m_arc.GetStart() + moveVector, m_arc.GetArcMid() + moveVector,
638 m_arc.GetEnd() + moveVector );
639 break;
640 }
641 }
642 }
643 else if( isModified( aEditedPoint, aPoints.Point( ARC_MID ) ) )
644 {
645 const VECTOR2I& cursorPos = m_viewControls.GetCursorPosition( false );
646
647 switch( m_arcEditMode )
648 {
649 case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION:
650 editArcMidKeepEndpoints( m_arc, start, end, cursorPos );
651 break;
652 case ARC_EDIT_MODE::KEEP_CENTER_ENDS_ADJUST_ANGLE:
653 case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS:
654 editArcMidKeepCenter( m_arc, center, start, mid, end, cursorPos );
655 break;
656 }
657 }
658 else if( isModified( aEditedPoint, aPoints.Point( ARC_START ) )
659 || isModified( aEditedPoint, aPoints.Point( ARC_END ) ) )
660 {
661 const VECTOR2I& cursorPos = m_viewControls.GetCursorPosition();
662
663 switch( m_arcEditMode )
664 {
665 case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS:
666 editArcEndpointKeepCenter( m_arc, center, start, mid, end, cursorPos );
667 break;
668 case ARC_EDIT_MODE::KEEP_CENTER_ENDS_ADJUST_ANGLE:
670 break;
671 case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION:
672 editArcEndpointKeepTangent( m_arc, center, start, mid, end, cursorPos );
673 break;
674 }
675 }
676}
677
678
680 EDIT_POINTS& aPoints ) const
681{
682 return aPoints.Point( ARC_CENTER ).GetPosition();
683}
684
685
687{
688 aPoints.AddPoint( m_cell.GetEnd() - VECTOR2I( 0, m_cell.GetRectangleHeight() / 2 ) );
689 aPoints.AddPoint( m_cell.GetEnd() - VECTOR2I( m_cell.GetRectangleWidth() / 2, 0 ) );
690}
691
692
694{
695 aPoints.Point( COL_WIDTH )
697 aPoints.Point( ROW_HEIGHT )
699}
700
701
703{
704 switch( aMode )
705 {
712 default:
713 wxFAIL_MSG( "Invalid arc edit mode" );
714 return aMode;
715 }
716}
ARC_EDIT_MODE
Settings for arc editing.
Definition: app_settings.h:52
@ 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 int ARC_HIGH_DEF
Definition: base_units.h:122
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:110
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:74
EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.
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
EDA_ARC_POINT_EDIT_BEHAVIOR(EDA_SHAPE &aArc, const ARC_EDIT_MODE &aArcEditMode, KIGFX::VIEW_CONTROLS &aViewContols)
void 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.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
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.
void 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 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.
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:258
void SetBezierC2(const VECTOR2I &aPt)
Definition: eda_shape.h:257
void SetCenter(const VECTOR2I &aCenter)
Definition: eda_shape.cpp:954
VECTOR2I getCenter() const
Definition: eda_shape.cpp:928
int GetRectangleWidth() const
Definition: eda_shape.cpp:420
int GetRadius() const
Definition: eda_shape.cpp:1003
SHAPE_T GetShape() const
Definition: eda_shape.h:168
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
Definition: eda_shape.cpp:901
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:215
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:177
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:173
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:219
void SetBezierC1(const VECTOR2I &aPt)
Definition: eda_shape.h:254
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
Definition: eda_shape.cpp:1036
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:255
int GetRectangleHeight() const
Definition: eda_shape.cpp:406
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:973
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void SetConstraint(EDIT_CONSTRAINT< EDIT_LINE > *aConstraint)
Set a constraint for and EDIT_POINT.
Definition: edit_points.h:267
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
Definition: edit_points.h:353
unsigned int PointsSize() const
Return number of stored EDIT_POINTs.
Definition: edit_points.h:534
void AddPoint(const EDIT_POINT &aPoint)
Add an EDIT_POINT.
Definition: edit_points.h:390
void Clear()
Clear all stored EDIT_POINTs and EDIT_LINEs.
Definition: edit_points.h:378
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)
Definition: edit_points.h:521
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,...
Definition: edit_points.h:434
void AddBreak()
Adds a break, indicating the end of a contour.
Definition: edit_points.h:445
int GetContourStartIdx(int aPointIdx) const
Return index of the contour origin for a point with given index.
Definition: edit_points.cpp:77
unsigned int LinesSize() const
Return number of stored EDIT_LINEs.
Definition: edit_points.h:542
EDIT_POINT & Point(unsigned int aIndex)
Definition: edit_points.h:511
void AddLine(const EDIT_LINE &aLine)
Adds an EDIT_LINE.
Definition: edit_points.h:410
Represent a single point that can be used for modifying items.
Definition: edit_points.h:48
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
Definition: edit_points.h:107
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:71
An interface for classes handling user events controlling the view behavior such as zooming,...
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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.
static void BuildForPolyOutline(EDIT_POINTS &aPoints, const SHAPE_POLY_SET &aOutline)
Build the edit points for the given polygon outline.
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
ecoord SquaredDistance(const SEG &aSeg) const
Definition: seg.cpp:75
VECTOR2I::extended_type ecoord
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:50
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition: seg.cpp:365
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
Definition: seg.h:220
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.
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
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:76
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:283
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:385
T y
Definition: vector3.h:64
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector3.h:153
T x
Definition: vector3.h:63
double m_DrawArcCenterMaxAngle
When drawing an arc, the angle ( center - start ) - ( start - end ) can be limited to avoid extremely...
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
Definition: eda_units.h:166
static void editArcEndpointKeepCenterAndRadius(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
static void editArcEndpointKeepCenter(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 around the circumference.
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 editArcMidKeepCenter(EDA_SHAPE &aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor)
Move the mid point of the arc, while keeping the two endpoints.
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:39
Holding struct to keep originating midpoint.
Definition: eda_shape.h:79
VECTOR3I v1(5, 5, 5)
VECTOR2I center
int radius
VECTOR2I end
VECTOR2I v2(1, 0)
VECTOR2I v4(1, 1)
VECTOR2I v3(-2, 1)
constexpr int delta
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
VECTOR2< double > VECTOR2D
Definition: vector2d.h:694