KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_shape.h
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 (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <memory>
24#include <optional>
25
26#include <bezier_curves.h>
27#include <core/mirror.h>
28#include <geometry/ellipse.h>
32#include <eda_fill.h>
33#include <properties/property.h>
34#include <stroke_params.h>
35#include <line_ending.h>
36#include <trigo.h>
37#include <frame_type.h>
38#include <api/serializable.h>
39
40class LINE_READER;
41class EDA_DRAW_FRAME;
42class FOOTPRINT;
43class MSG_PANEL_ITEM;
44struct EDA_IU_SCALE;
45
47{
48 class GraphicShape;
49}
50
51using KIGFX::COLOR4D;
52
65
66
75
76
82
83
84class EDA_SHAPE : public SERIALIZABLE
85{
86public:
87 EDA_SHAPE( SHAPE_T aType, int aLineWidth, FILL_T aFill );
88
90 EDA_SHAPE( const SHAPE& aShape );
91
92 EDA_SHAPE( const EDA_SHAPE& aOther );
93 EDA_SHAPE& operator=( const EDA_SHAPE& aOther );
94
95 EDA_SHAPE( EDA_SHAPE&& ) noexcept = default;
96 EDA_SHAPE& operator=( EDA_SHAPE&& ) noexcept = default;
97
98 virtual ~EDA_SHAPE();
99
100 void SwapShape( EDA_SHAPE* aImage );
101
102 void Serialize( google::protobuf::Any &aContainer ) const override;
103 bool Deserialize( const google::protobuf::Any &aContainer ) override;
104
105 void Serialize( google::protobuf::Any &aContainer, const EDA_IU_SCALE& aScale ) const;
106 bool Deserialize( const google::protobuf::Any& aContainer, const EDA_IU_SCALE& aScale );
107
108 void Serialize( kiapi::common::types::GraphicShape& aOutput, const EDA_IU_SCALE& aScale ) const;
109 bool Deserialize( const kiapi::common::types::GraphicShape& aInput, const EDA_IU_SCALE& aScale );
110
111 wxString ShowShape() const;
112
113 wxString SHAPE_T_asString() const;
114
115 virtual bool IsProxyItem() const { return m_proxyItem; }
116 virtual void SetIsProxyItem( bool aIsProxy = true ) { m_proxyItem = aIsProxy; }
117
118 bool IsAnyFill() const
119 {
120 return GetFillMode() != FILL_T::NO_FILL;
121 }
122
129
130 bool IsHatchedFill() const
131 {
132 return GetFillMode() == FILL_T::HATCH
135 }
136
137 virtual bool IsFilledForHitTesting() const
138 {
139 return IsSolidFill();
140 }
141
142 virtual void SetFilled( bool aFlag )
143 {
144 setFilled( aFlag );
145 }
146
147 void SetFillMode( FILL_T aFill );
148 FILL_T GetFillMode() const { return m_fill; }
149
152
154 const SHAPE_POLY_SET& GetHatching() const;
155 const std::vector<SEG>& GetHatchLines() const;
156
157 bool IsClosed() const;
158
159 COLOR4D GetFillColor() const { return m_fillColor; }
160 void SetFillColor( const COLOR4D& aColor ) { m_fillColor = aColor; }
161
162 virtual void SetWidth( int aWidth );
163 virtual int GetWidth() const { return m_stroke.GetWidth(); }
164 virtual int GetEffectiveWidth() const { return GetWidth(); }
165 virtual int GetHatchLineWidth() const { return GetEffectiveWidth(); }
166 virtual int GetHatchLineSpacing() const { return GetHatchLineWidth() * 10; }
167
168 void SetLineStyle( const LINE_STYLE aStyle );
169 LINE_STYLE GetLineStyle() const;
170
171 void SetLineColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); }
172 COLOR4D GetLineColor() const { return m_stroke.GetColor(); }
173
174 virtual void SetShape( SHAPE_T aShape ) { m_shape = aShape; }
175 SHAPE_T GetShape() const { return m_shape; }
176
177 const LINE_ENDING& GetStartEnding() const { return m_startEnding; }
178 void SetStartEnding( const LINE_ENDING& aEnding ) { m_startEnding = aEnding; }
179
180 const LINE_ENDING& GetEndEnding() const { return m_endEnding; }
181 void SetEndEnding( const LINE_ENDING& aEnding ) { m_endEnding = aEnding; }
182
184 void SetStartEndingStyle( LINE_ENDING_STYLE aStyle ) { m_startEnding.SetStyle( aStyle ); }
185
186 LINE_ENDING_STYLE GetEndEndingStyle() const { return m_endEnding.GetStyle(); }
187 void SetEndEndingStyle( LINE_ENDING_STYLE aStyle ) { m_endEnding.SetStyle( aStyle ); }
188
189 int GetStartEndingLength() const { return m_startEnding.GetLength(); }
190 void SetStartEndingLength( int aLength ) { m_startEnding.SetLength( aLength ); }
191 int GetStartEndingWidth() const { return m_startEnding.GetWidth(); }
192 void SetStartEndingWidth( int aWidth ) { m_startEnding.SetWidth( aWidth ); }
193
194 int GetEndEndingLength() const { return m_endEnding.GetLength(); }
195 void SetEndEndingLength( int aLength ) { m_endEnding.SetLength( aLength ); }
196 int GetEndEndingWidth() const { return m_endEnding.GetWidth(); }
197 void SetEndEndingWidth( int aWidth ) { m_endEnding.SetWidth( aWidth ); }
198
199 int GetStartEndingStrokeWidth() const { return m_startEnding.GetStrokeWidth(); }
200 void SetStartEndingStrokeWidth( int aWidth ) { m_startEnding.SetStrokeWidth( aWidth ); }
201 int GetEndEndingStrokeWidth() const { return m_endEnding.GetStrokeWidth(); }
202 void SetEndEndingStrokeWidth( int aWidth ) { m_endEnding.SetStrokeWidth( aWidth ); }
203
210 void GetEndingTangents( EDA_ANGLE& aStartTangent, EDA_ANGLE& aEndTangent, int aLineWidth = 0 ) const;
211
217 bool GetLineEndingEndpoints( VECTOR2I& aStartPoint, VECTOR2I& aEndPoint ) const;
218
226 static bool ShortenSegmentForEndings( VECTOR2I& aStart, VECTOR2I& aEnd, const LINE_ENDING& aStartEnding,
227 const LINE_ENDING& aEndEnding, int aLineWidth );
228
234 bool ShortenArcForEndings( EDA_ANGLE& aStartAngle, EDA_ANGLE& aArcAngle, double aRadius, int aLineWidth ) const;
235
243 std::optional<BEZIER<double>> ShortenedBezierCurve( int aLineWidth ) const;
244
248 std::vector<VECTOR2D> ShortenedBezierPolyline( int aLineWidth ) const;
249
250 bool ShortenPolyForEndings( VECTOR2D& aFirst, VECTOR2D& aLast, const VECTOR2D& aSecond,
251 const VECTOR2D& aPenultimate, int aLineWidth ) const;
252
261 bool ShortenBodyPolyPoints( std::vector<VECTOR2I>& aPoints, bool aClosed, int aOutlineIdx, int aLineWidth ) const;
262
268 bool GetShortenedBodyPolyPoints( const SHAPE_LINE_CHAIN& aOutline, int aOutlineIdx, std::vector<VECTOR2I>& aPoints,
269 int aLineWidth ) const;
270
271
275 const VECTOR2I& GetStart() const { return m_start; }
276 int GetStartY() const { return m_start.y; }
277 int GetStartX() const { return m_start.x; }
278
279 virtual void SetStart( const VECTOR2I& aStart )
280 {
281 m_start = aStart;
282 m_endsSwapped = false;
283 m_hatchingDirty = true;
284 }
285
286 void SetStartY( int y )
287 {
288 VECTOR2I s = m_start;
289 s.y = y;
290 SetStart( s );
291 }
292
293 void SetStartX( int x )
294 {
295 VECTOR2I s = m_start;
296 s.x = x;
297 SetStart( s );
298 }
299
300 void SetCenterY( int y )
301 {
302 VECTOR2I newStart = m_start;
303 VECTOR2I newEnd = m_end;
304 newEnd.y += y - m_start.y;
305 newStart.y = y;
306 SetStart( newStart );
307 SetEnd( newEnd );
308 m_hatchingDirty = true;
309 }
310
311 void SetCenterX( int x )
312 {
313 VECTOR2I newStart = m_start;
314 VECTOR2I newEnd = m_end;
315 newEnd.x += x - m_start.x;
316 newStart.x = x;
317 SetStart( newStart );
318 SetEnd( newEnd );
319 m_hatchingDirty = true;
320 }
321
325 const VECTOR2I& GetEnd() const { return m_end; }
326 int GetEndY() const { return m_end.y; }
327 int GetEndX() const { return m_end.x; }
328
329 virtual void SetEnd( const VECTOR2I& aEnd )
330 {
331 m_end = aEnd;
332 m_endsSwapped = false;
333 m_hatchingDirty = true;
334 }
335
336 void SetEndY( int aY )
337 {
338 VECTOR2I e = m_end;
339 e.y = aY;
340 SetEnd( e );
341 }
342
343 void SetEndX( int aX )
344 {
345 VECTOR2I e = m_end;
346 e.x = aX;
347 SetEnd( e );
348 }
349
350 void SetRadius( int aX )
351 {
352 SetEnd( m_start + VECTOR2I( aX, 0 ) );
353 m_hatchingDirty = true;
354 }
355
356 virtual VECTOR2I GetTopLeft() const { return GetStart(); }
357 virtual VECTOR2I GetBotRight() const { return GetEnd(); }
358
359 virtual void SetTop( int val ) { SetStartY( val ); }
360 virtual void SetLeft( int val ) { SetStartX( val ); }
361 virtual void SetRight( int val ) { SetEndX( val ); }
362 virtual void SetBottom( int val ) { SetEndY( val ); }
363
364 virtual void SetBezierC1( const VECTOR2I& aPt ) { m_bezierC1 = aPt; }
365 const VECTOR2I& GetBezierC1() const { return m_bezierC1; }
366
367 virtual void SetBezierC2( const VECTOR2I& aPt ) { m_bezierC2 = aPt; }
368 const VECTOR2I& GetBezierC2() const { return m_bezierC2; }
369
370 virtual void SetEllipseCenter( const VECTOR2I& aPt )
371 {
372 m_ellipse.Center = aPt;
373 m_hatchingDirty = true;
375 }
376
377 const VECTOR2I& GetEllipseCenter() const { return m_ellipse.Center; }
378
379 virtual void SetEllipseMajorRadius( int aR )
380 {
381 m_ellipse.MajorRadius = aR;
382 m_hatchingDirty = true;
384 }
385
386 int GetEllipseMajorRadius() const { return m_ellipse.MajorRadius; }
387
388 virtual void SetEllipseMinorRadius( int aR )
389 {
390 m_ellipse.MinorRadius = aR;
391 m_hatchingDirty = true;
393 }
394
395 int GetEllipseMinorRadius() const { return m_ellipse.MinorRadius; }
396
397 virtual void SetEllipseRotation( const EDA_ANGLE& aA )
398 {
399 m_ellipse.Rotation = aA;
400 m_hatchingDirty = true;
402 }
403
404 EDA_ANGLE GetEllipseRotation() const { return m_ellipse.Rotation; }
405
406 // Meaningful only when m_shape == SHAPE_T::ELLIPSE_ARC.
407 virtual void SetEllipseStartAngle( const EDA_ANGLE& aA )
408 {
409 m_ellipse.StartAngle = aA;
410 m_hatchingDirty = true;
412 }
413
414 EDA_ANGLE GetEllipseStartAngle() const { return m_ellipse.StartAngle; }
415
416 virtual void SetEllipseEndAngle( const EDA_ANGLE& aA )
417 {
418 m_ellipse.EndAngle = aA;
419 m_hatchingDirty = true;
421 }
422
423 EDA_ANGLE GetEllipseEndAngle() const { return m_ellipse.EndAngle; }
424
427 const ELLIPSE<int>& GetEllipse() const { return m_ellipse; }
428
429 VECTOR2I getCenter() const;
430 void SetCenter( const VECTOR2I& aCenter );
431
439 void SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
440
441 virtual void SetArcAngle( const EDA_ANGLE& aAngle ) { SetArcAngleAndEnd( aAngle, true ); }
442
443 EDA_ANGLE GetArcAngle() const;
444
446
452 bool EndsSwapped() const { return m_endsSwapped; }
453
454 // Some attributes are read only, since they are derived from m_Start, m_End, and m_Angle.
455 // No Set...() function for these attributes.
456
457 VECTOR2I GetArcMid() const;
458 std::vector<VECTOR2I> GetRectCorners() const;
459 virtual std::vector<VECTOR2I> GetCornersInSequence( EDA_ANGLE angle ) const;
460
465 void CalcArcAngles( EDA_ANGLE& aStartAngle, EDA_ANGLE& aEndAngle ) const;
466
467 int GetRadius() const;
468
475 void SetArcGeometry( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
476
488 void SetCachedArcData( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd,
489 const VECTOR2I& aCenter );
490
491 const std::vector<VECTOR2I>& GetBezierPoints() const { return m_bezierPoints; }
492
499 std::vector<VECTOR2I> GetPolyPoints() const;
500
504 int GetPointCount() const;
505
507 const SHAPE_POLY_SET& GetPolyShape() const;
508
512 bool IsPolyShapeValid() const;
513
514 virtual void SetPolyShape( const SHAPE_POLY_SET& aShape )
515 {
516 GetPolyShape() = aShape;
517
518 for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
519 {
520 if( GetPolyShape().HoleCount( ii ) )
521 {
523 break;
524 }
525 }
526 }
527
528 void SetPolyPoints( const std::vector<VECTOR2I>& aPoints );
529
538 void RebuildBezierToSegmentsPointsList( int aMaxError );
540
549 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const
550 {
551 return makeEffectiveShapes( aEdgeOnly );
552 }
553
559 std::vector<SHAPE*> MakeLineEndingEffectiveShapes( int aLineWidth ) const;
560
567 std::vector<SHAPE*> MakeEffectiveShapesWithLineEndings( int aLineWidth ) const;
568
569 virtual std::vector<SHAPE*> MakeEffectiveShapesForHitTesting() const
570 {
571 return makeEffectiveShapes( false, false, true );
572 }
573
590 std::vector<SHAPE*> MakeEffectiveShapesForStroking( int aLineWidth = -1 ) const;
591
592 void ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
593
594 void SetRectangleHeight( const int& aHeight );
595
596 void SetRectangleWidth( const int& aWidth );
597
598 void SetRectangle( const long long int& aHeight, const long long int& aWidth );
599
600 void SetCornerRadius( int aRadius );
601 int GetCornerRadius() const;
602
603 bool IsClockwiseArc() const;
604
608 double GetLength() const;
609
610 int GetRectangleHeight() const;
611 int GetRectangleWidth() const;
612
613 virtual void UpdateHatching() const;
614
626 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc,
627 bool ignoreLineWidth = false, bool includeFill = false ) const;
628
632 void TransformLineEndingsToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc,
633 int aLineWidth ) const;
634
638 void TransformWithLineEndingsToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc,
639 bool ignoreLineWidth = false ) const;
640
641 bool GetLineEndingsBoundingBox( BOX2I& aBBox, int aLineWidth ) const;
642
643 int Compare( const EDA_SHAPE* aOther ) const;
644
645 double Similarity( const EDA_SHAPE& aOther ) const;
646
647 bool operator==( const EDA_SHAPE& aOther ) const;
648
649protected:
650 wxString getFriendlyName( FRAME_T aFrameType ) const;
651
652 void setPosition( const VECTOR2I& aPos );
653 VECTOR2I getPosition() const;
654
655 virtual void setFilled( bool aFlag )
656 {
658 }
659
661 {
662 return SHAPE_POLY_SET();
663 }
664
665 void move( const VECTOR2I& aMoveVector );
666 void rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle );
667 void flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
668 void scale( double aScale );
669
670 virtual EDA_ANGLE getDrawRotation() const { return ANGLE_0; }
671
672 const BOX2I getBoundingBox() const;
673
674 void computeArcBBox( BOX2I& aBBox ) const;
675
676 bool hitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
677 bool hitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const;
678 bool hitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const;
679
680 const std::vector<VECTOR2I> buildBezierToSegmentsPointsList( int aMaxError ) const;
681
682 void beginEdit( const VECTOR2I& aStartPoint );
683 bool continueEdit( const VECTOR2I& aPosition );
684 void calcEdit( const VECTOR2I& aPosition );
685
691 void endEdit( bool aClosed = true );
692 void setEditState( int aState ) { m_editState = aState; }
693
694 virtual bool isMoving() const { return false; }
695
706 // fixme: move to shape_compound
707 std::vector<SHAPE*> makeEffectiveShapes( bool aEdgeOnly, bool aLineChainOnly = false,
708 bool aHittesting = false ) const;
709
717 std::vector<SHAPE*> makeShortenedBodyShapes( int aLineWidth, bool aEdgeOnly = false ) const;
718
720
724
725 virtual int getMaxError() const { return 100; }
726
727 // non-const for PCB_SHAPE
728 SHAPE_POLY_SET& hatching() const;
729 std::vector<SEG>& hatchLines() const;
730
731protected:
732 bool m_endsSwapped; // true if start/end were swapped e.g. SetArcAngleAndEnd
733 SHAPE_T m_shape; // Shape: line, Circle, Arc
734 STROKE_PARAMS m_stroke; // Line style, width, etc.
735 LINE_ENDING m_startEnding; // Line ending at start point
736 LINE_ENDING m_endEnding; // Line ending at end point
739
740 mutable std::unique_ptr<EDA_SHAPE_HATCH_CACHE_DATA> m_hatchingCache;
741 mutable bool m_hatchingDirty;
742
743 long long int m_rectangleHeight;
744 long long int m_rectangleWidth;
746
747 VECTOR2I m_start; // Line start point or Circle center
748 VECTOR2I m_end; // Line end point or Circle 3 o'clock point
749
750 VECTOR2I m_arcCenter; // Used only for Arcs: arc end point
751 ARC_MID m_arcMidData; // Used to store originating data
752
753 VECTOR2I m_bezierC1; // Bezier Control Point 1
754 VECTOR2I m_bezierC2; // Bezier Control Point 2
755
756 std::vector<VECTOR2I> m_bezierPoints;
757 ELLIPSE<int> m_ellipse; // Used only for ELLIPSE / ELLIPSE_ARC
758 mutable std::unique_ptr<SHAPE_POLY_SET> m_poly; // Stores the S_POLYGON shape
759
761 bool m_proxyItem; // A shape storing proxy information (ie: a pad
762 // number box, thermal spoke template, etc.)
763};
764
769
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
Generic cubic Bezier representation.
Represent basic circle geometry with utility geometry functions.
Definition circle.h:33
The base class for create windows for drawing purpose.
UI_FILL_MODE GetFillModeProp() const
static bool ShortenSegmentForEndings(VECTOR2I &aStart, VECTOR2I &aEnd, const LINE_ENDING &aStartEnding, const LINE_ENDING &aEndEnding, int aLineWidth)
Shorten a segment body for line endings.
virtual int GetHatchLineSpacing() const
Definition eda_shape.h:166
EDA_ANGLE GetArcAngle() const
int GetStartEndingLength() const
Definition eda_shape.h:189
SHAPE_T m_shape
Definition eda_shape.h:733
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:329
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false, bool includeFill=false) const
Convert the shape to a closed polygon.
void SetStartX(int x)
Definition eda_shape.h:293
int GetEllipseMinorRadius() const
Definition eda_shape.h:395
bool m_proxyItem
Definition eda_shape.h:761
int m_cornerRadius
Definition eda_shape.h:745
bool m_hatchingDirty
Definition eda_shape.h:741
bool m_endsSwapped
Definition eda_shape.h:732
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:368
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:377
bool GetLineEndingsBoundingBox(BOX2I &aBBox, int aLineWidth) const
void SetCenter(const VECTOR2I &aCenter)
VECTOR2I getCenter() const
int GetStartY() const
Definition eda_shape.h:276
void SetFillModeProp(UI_FILL_MODE)
int m_editState
Definition eda_shape.h:760
virtual int getMaxError() const
Definition eda_shape.h:725
virtual VECTOR2I GetTopLeft() const
Definition eda_shape.h:356
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
void SetEndEnding(const LINE_ENDING &aEnding)
Definition eda_shape.h:181
std::vector< SHAPE * > MakeEffectiveShapesWithLineEndings(int aLineWidth) const
Make effective geometry for the shape body shortened for line endings plus the line-ending geometry i...
const std::vector< VECTOR2I > buildBezierToSegmentsPointsList(int aMaxError) const
void SetEndEndingLength(int aLength)
Definition eda_shape.h:195
void SetStartEndingStyle(LINE_ENDING_STYLE aStyle)
Definition eda_shape.h:184
const SHAPE_POLY_SET & GetHatching() const
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:423
FILL_T GetFillMode() const
Definition eda_shape.h:148
void SetEndEndingWidth(int aWidth)
Definition eda_shape.h:197
void SetCornerRadius(int aRadius)
long long int m_rectangleHeight
Definition eda_shape.h:743
int GetEllipseMajorRadius() const
Definition eda_shape.h:386
std::unique_ptr< EDA_SHAPE_HATCH_CACHE_DATA > m_hatchingCache
Definition eda_shape.h:740
void SetEndY(int aY)
Definition eda_shape.h:336
virtual int GetEffectiveWidth() const
Definition eda_shape.h:164
std::vector< VECTOR2I > GetPolyPoints() const
Duplicate the polygon outlines into a flat list of VECTOR2I points.
ELLIPSE< int > m_ellipse
Definition eda_shape.h:757
void TransformWithLineEndingsToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the shape body shortened for line endings plus line-ending geometry to polygons.
COLOR4D GetLineColor() const
Definition eda_shape.h:172
EDA_SHAPE(EDA_SHAPE &&) noexcept=default
int GetEndX() const
Definition eda_shape.h:327
SHAPE_ELLIPSE buildShapeEllipse() const
void TransformLineEndingsToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, int aLineWidth) const
Append only the line-ending geometry associated with this shape to a polygon set.
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false, bool aHittesting=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
int GetRectangleWidth() const
void SetLineStyle(const LINE_STYLE aStyle)
std::vector< SHAPE * > makeShortenedBodyShapes(int aLineWidth, bool aEdgeOnly=false) const
Make effective geometry for the shape body shortened for line endings, without the line-ending geomet...
void recalcEllipseArcEndpoints()
When m_shape == ELLIPSE_ARC, recompute m_start/m_end from m_ellipse.
void calcEdit(const VECTOR2I &aPosition)
void SetStartY(int y)
Definition eda_shape.h:286
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:549
bool ShortenPolyForEndings(VECTOR2D &aFirst, VECTOR2D &aLast, const VECTOR2D &aSecond, const VECTOR2D &aPenultimate, int aLineWidth) const
SHAPE_POLY_SET & GetPolyShape()
void SetCenterY(int y)
Definition eda_shape.h:300
void GetEndingTangents(EDA_ANGLE &aStartTangent, EDA_ANGLE &aEndTangent, int aLineWidth=0) const
Compute outward-facing tangent angles at the start and end of the shape.
int GetStartEndingStrokeWidth() const
Definition eda_shape.h:199
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
virtual std::vector< VECTOR2I > GetCornersInSequence(EDA_ANGLE angle) const
EDA_ANGLE GetEllipseRotation() const
Definition eda_shape.h:404
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
void SetEndEndingStyle(LINE_ENDING_STYLE aStyle)
Definition eda_shape.h:187
virtual bool isMoving() const
Definition eda_shape.h:694
virtual void SetEllipseEndAngle(const EDA_ANGLE &aA)
Definition eda_shape.h:416
int GetEndEndingStrokeWidth() const
Definition eda_shape.h:201
bool operator==(const EDA_SHAPE &aOther) const
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:175
std::vector< SHAPE * > MakeEffectiveShapesForStroking(int aLineWidth=-1) const
Make a set of SHAPE objects to hand to STROKE_PARAMS::Stroke().
void SetStartEnding(const LINE_ENDING &aEnding)
Definition eda_shape.h:178
virtual void SetBezierC2(const VECTOR2I &aPt)
Definition eda_shape.h:367
virtual VECTOR2I GetBotRight() const
Definition eda_shape.h:357
bool GetShortenedBodyPolyPoints(const SHAPE_LINE_CHAIN &aOutline, int aOutlineIdx, std::vector< VECTOR2I > &aPoints, int aLineWidth) const
Copy an outline and apply line-ending body shortening when applicable.
virtual void SetBottom(int val)
Definition eda_shape.h:362
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
const std::vector< SEG > & GetHatchLines() const
void SetRectangleHeight(const int &aHeight)
SHAPE_POLY_SET & hatching() const
bool IsHatchedFill() const
Definition eda_shape.h:130
virtual SHAPE_POLY_SET getHatchingKnockouts() const
Definition eda_shape.h:660
VECTOR2I m_arcCenter
Definition eda_shape.h:750
void SetCenterX(int x)
Definition eda_shape.h:311
virtual void SetBezierC1(const VECTOR2I &aPt)
Definition eda_shape.h:364
int GetStartEndingWidth() const
Definition eda_shape.h:191
bool GetLineEndingEndpoints(VECTOR2I &aStartPoint, VECTOR2I &aEndPoint) const
Return the source endpoints used to place line endings.
virtual void SetFilled(bool aFlag)
Definition eda_shape.h:142
virtual void SetTop(int val)
Definition eda_shape.h:359
virtual bool IsFilledForHitTesting() const
Definition eda_shape.h:137
virtual void SetEllipseRotation(const EDA_ANGLE &aA)
Definition eda_shape.h:397
bool continueEdit(const VECTOR2I &aPosition)
virtual void SetArcAngle(const EDA_ANGLE &aAngle)
Definition eda_shape.h:441
wxString ShowShape() const
LINE_ENDING_STYLE GetStartEndingStyle() const
Definition eda_shape.h:183
ARC_MID m_arcMidData
Definition eda_shape.h:751
void SetFillColor(const COLOR4D &aColor)
Definition eda_shape.h:160
int GetEndY() const
Definition eda_shape.h:326
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
void SetCachedArcData(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCenter)
Set the data used for mid point caching.
void SetEndX(int aX)
Definition eda_shape.h:343
virtual int GetHatchLineWidth() const
Definition eda_shape.h:165
bool IsSolidFill() const
Definition eda_shape.h:123
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
int GetEndEndingWidth() const
Definition eda_shape.h:196
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
Definition eda_shape.cpp:56
std::vector< SEG > & hatchLines() const
void beginEdit(const VECTOR2I &aStartPoint)
int GetEndEndingLength() const
Definition eda_shape.h:194
VECTOR2I m_start
Definition eda_shape.h:747
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:325
bool IsClosed() const
void SetRadius(int aX)
Definition eda_shape.h:350
LINE_STYLE GetLineStyle() const
void endEdit(bool aClosed=true)
Finish editing the shape.
virtual void SetEllipseCenter(const VECTOR2I &aPt)
Definition eda_shape.h:370
void SetStartEndingLength(int aLength)
Definition eda_shape.h:190
void SetEndEndingStrokeWidth(int aWidth)
Definition eda_shape.h:202
virtual void SetEllipseMinorRadius(int aR)
Definition eda_shape.h:388
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:275
virtual void SetEllipseMajorRadius(int aR)
Definition eda_shape.h:379
void SetLineColor(const COLOR4D &aColor)
Definition eda_shape.h:171
COLOR4D GetFillColor() const
Definition eda_shape.h:159
void SetRectangle(const long long int &aHeight, const long long int &aWidth)
virtual void SetShape(SHAPE_T aShape)
Definition eda_shape.h:174
void SwapShape(EDA_SHAPE *aImage)
std::vector< VECTOR2I > GetRectCorners() const
std::vector< SHAPE * > MakeLineEndingEffectiveShapes(int aLineWidth) const
Make the line-ending geometry associated with this shape.
void SetStartEndingWidth(int aWidth)
Definition eda_shape.h:192
std::vector< VECTOR2I > m_bezierPoints
Definition eda_shape.h:756
bool IsAnyFill() const
Definition eda_shape.h:118
void setPosition(const VECTOR2I &aPos)
virtual std::vector< SHAPE * > MakeEffectiveShapesForHitTesting() const
Definition eda_shape.h:569
virtual void setFilled(bool aFlag)
Definition eda_shape.h:655
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:414
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition eda_shape.h:491
virtual bool IsProxyItem() const
Definition eda_shape.h:115
void computeArcBBox(BOX2I &aBBox) const
const LINE_ENDING & GetStartEnding() const
Definition eda_shape.h:177
virtual void UpdateHatching() const
LINE_ENDING m_startEnding
Definition eda_shape.h:735
bool EndsSwapped() const
Have the start and end points been swapped since they were set?
Definition eda_shape.h:452
void SetRectangleWidth(const int &aWidth)
virtual void SetEllipseStartAngle(const EDA_ANGLE &aA)
Definition eda_shape.h:407
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
virtual void SetLeft(int val)
Definition eda_shape.h:360
double GetLength() const
wxString SHAPE_T_asString() const
int GetStartX() const
Definition eda_shape.h:277
double Similarity(const EDA_SHAPE &aOther) const
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:365
std::optional< BEZIER< double > > ShortenedBezierCurve(int aLineWidth) const
Return the cubic Bezier curve shortened for line endings.
VECTOR2I m_end
Definition eda_shape.h:748
const BOX2I getBoundingBox() const
virtual EDA_ANGLE getDrawRotation() const
Definition eda_shape.h:670
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
int GetRectangleHeight() const
virtual int GetWidth() const
Definition eda_shape.h:163
bool ShortenBodyPolyPoints(std::vector< VECTOR2I > &aPoints, bool aClosed, int aOutlineIdx, int aLineWidth) const
Apply line-ending body shortening to copied/generated polyline points.
bool ShortenArcForEndings(EDA_ANGLE &aStartAngle, EDA_ANGLE &aArcAngle, double aRadius, int aLineWidth) const
Shorten an arc body for line endings.
std::vector< VECTOR2D > ShortenedBezierPolyline(int aLineWidth) const
Return the flattened Bezier polyline after line-ending shortening.
VECTOR2I getPosition() const
bool IsClockwiseArc() const
STROKE_PARAMS m_stroke
Definition eda_shape.h:734
const LINE_ENDING & GetEndEnding() const
Definition eda_shape.h:180
LINE_ENDING m_endEnding
Definition eda_shape.h:736
void SetHatchingDirty()
Definition eda_shape.h:153
void setEditState(int aState)
Definition eda_shape.h:692
LINE_ENDING_STYLE GetEndEndingStyle() const
Definition eda_shape.h:186
void RebuildBezierToSegmentsPointsList()
Definition eda_shape.h:539
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
EDA_SHAPE & operator=(const EDA_SHAPE &aOther)
VECTOR2I m_bezierC1
Definition eda_shape.h:753
FILL_T m_fill
Definition eda_shape.h:737
COLOR4D m_fillColor
Definition eda_shape.h:738
virtual void SetWidth(int aWidth)
EDA_ANGLE GetSegmentAngle() const
void SetStartEndingStrokeWidth(int aWidth)
Definition eda_shape.h:200
virtual void SetRight(int val)
Definition eda_shape.h:361
int GetCornerRadius() const
void SetFillMode(FILL_T aFill)
std::unique_ptr< SHAPE_POLY_SET > m_poly
Definition eda_shape.h:758
virtual void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition eda_shape.h:514
virtual void SetIsProxyItem(bool aIsProxy=true)
Definition eda_shape.h:116
virtual void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:279
wxString getFriendlyName(FRAME_T aFrameType) const
long long int m_rectangleWidth
Definition eda_shape.h:744
VECTOR2I m_bezierC2
Definition eda_shape.h:754
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
const ELLIPSE< int > & GetEllipse() const
Direct read-only access to the underlying ellipse payload.
Definition eda_shape.h:427
bool IsPolyShapeValid() const
int Compare(const EDA_SHAPE *aOther) const
VECTOR2I GetArcMid() const
Plain ellipse / elliptical-arc data.
Definition ellipse.h:32
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
Definition line_ending.h:62
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:65
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
Interface for objects that can be serialized to Protobuf messages.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
int OutlineCount() const
Return the number of outlines in the set.
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
An abstract shape on 2D plane.
Definition shape.h:124
Simple container to manage line stroke parameters.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:422
UI_FILL_MODE
Definition eda_fill.h:41
FILL_T
Definition eda_fill.h:29
@ FILLED_WITH_COLOR
Definition eda_fill.h:33
@ NO_FILL
Definition eda_fill.h:30
@ REVERSE_HATCH
Definition eda_fill.h:35
@ HATCH
Definition eda_fill.h:34
@ FILLED_WITH_BG_BODYCOLOR
Definition eda_fill.h:32
@ FILLED_SHAPE
Fill with object color.
Definition eda_fill.h:31
@ CROSS_HATCH
Definition eda_fill.h:36
SHAPE_T
Definition eda_shape.h:54
@ ELLIPSE
Definition eda_shape.h:62
@ SEGMENT
Definition eda_shape.h:56
@ ELLIPSE_ARC
Definition eda_shape.h:63
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:29
LINE_ENDING_STYLE
Line ending styles for graphic lines, arcs, and beziers.
Definition line_ending.h:44
FLIP_DIRECTION
Definition mirror.h:23
#define DECLARE_ENUM_TO_WXANY(type)
Definition property.h:838
const int scale
LINE_STYLE
Dashed line types.
Holding struct to keep originating midpoint.
Definition eda_shape.h:69
VECTOR2I end
Definition eda_shape.h:72
VECTOR2I center
Definition eda_shape.h:73
VECTOR2I start
Definition eda_shape.h:71
VECTOR2I mid
Definition eda_shape.h:70
SHAPE_POLY_SET hatching
Definition eda_shape.h:79
std::vector< SEG > hatchLines
Definition eda_shape.h:80
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682