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>
29#include <geometry/seg.h>
33#include <eda_fill.h>
34#include <properties/property.h>
35#include <stroke_params.h>
36#include <line_ending.h>
37#include <trigo.h>
38#include <frame_type.h>
39#include <api/serializable.h>
40
41class LINE_READER;
42class EDA_DRAW_FRAME;
43class FOOTPRINT;
44class MSG_PANEL_ITEM;
45struct EDA_IU_SCALE;
46
48{
49 class GraphicShape;
50}
51
52using KIGFX::COLOR4D;
53
66
67
76
77
83
84
85class EDA_SHAPE : public SERIALIZABLE
86{
87public:
88 EDA_SHAPE( SHAPE_T aType, int aLineWidth, FILL_T aFill );
89
91 EDA_SHAPE( const SHAPE& aShape );
92
93 EDA_SHAPE( const EDA_SHAPE& aOther );
94 EDA_SHAPE& operator=( const EDA_SHAPE& aOther );
95
96 EDA_SHAPE( EDA_SHAPE&& ) noexcept = default;
97 EDA_SHAPE& operator=( EDA_SHAPE&& ) noexcept = default;
98
99 virtual ~EDA_SHAPE();
100
101 virtual EDA_ITEM* AsEdaItem() { return nullptr; }
102
103 void SwapShape( EDA_SHAPE* aImage );
104
105 void Serialize( google::protobuf::Any &aContainer ) const override;
106 bool Deserialize( const google::protobuf::Any &aContainer ) override;
107
108 void Serialize( google::protobuf::Any &aContainer, const EDA_IU_SCALE& aScale ) const;
109 bool Deserialize( const google::protobuf::Any& aContainer, const EDA_IU_SCALE& aScale );
110
111 void Serialize( kiapi::common::types::GraphicShape& aOutput, const EDA_IU_SCALE& aScale ) const;
112 bool Deserialize( const kiapi::common::types::GraphicShape& aInput, const EDA_IU_SCALE& aScale );
113
114 wxString ShowShape() const;
115
116 wxString SHAPE_T_asString() const;
117
118 virtual bool IsProxyItem() const { return m_proxyItem; }
119 virtual void SetIsProxyItem( bool aIsProxy = true ) { m_proxyItem = aIsProxy; }
120
121 bool IsAnyFill() const
122 {
123 return GetFillMode() != FILL_T::NO_FILL;
124 }
125
132
133 bool IsHatchedFill() const
134 {
135 return GetFillMode() == FILL_T::HATCH
138 }
139
140 virtual bool IsFilledForHitTesting() const
141 {
142 return IsSolidFill();
143 }
144
145 virtual void SetFilled( bool aFlag )
146 {
147 setFilled( aFlag );
148 }
149
150 void SetFillMode( FILL_T aFill );
151 FILL_T GetFillMode() const { return m_fill; }
152
155
157 const SHAPE_POLY_SET& GetHatching() const;
158 const std::vector<SEG>& GetHatchLines() const;
159
160 bool IsClosed() const;
161
162 COLOR4D GetFillColor() const { return m_fillColor; }
163 void SetFillColor( const COLOR4D& aColor ) { m_fillColor = aColor; }
164
165 virtual void SetWidth( int aWidth );
166 virtual int GetWidth() const { return m_stroke.GetWidth(); }
167 virtual int GetEffectiveWidth() const { return GetWidth(); }
168 virtual int GetHatchLineWidth() const { return GetEffectiveWidth(); }
169 virtual int GetHatchLineSpacing() const { return GetHatchLineWidth() * 10; }
170
171 void SetLineStyle( const LINE_STYLE aStyle );
172 LINE_STYLE GetLineStyle() const;
173
174 void SetLineColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); }
175 COLOR4D GetLineColor() const { return m_stroke.GetColor(); }
176
177 virtual void SetShape( SHAPE_T aShape ) { m_shape = aShape; }
178 SHAPE_T GetShape() const { return m_shape; }
179
181 {
183 }
184 void SetStartEnding( const LINE_ENDING& aEnding ) { m_startEnding = aEnding; }
185
187 {
189 }
190 void SetEndEnding( const LINE_ENDING& aEnding ) { m_endEnding = aEnding; }
191
193 void SetStartEndingStyle( LINE_ENDING_STYLE aStyle ) { m_startEnding.SetStyle( aStyle ); }
194
195 LINE_ENDING_STYLE GetEndEndingStyle() const { return m_endEnding.GetStyle(); }
196 void SetEndEndingStyle( LINE_ENDING_STYLE aStyle ) { m_endEnding.SetStyle( aStyle ); }
197
198 int GetStartEndingLength() const { return m_startEnding.GetLength(); }
199 void SetStartEndingLength( int aLength ) { m_startEnding.SetLength( aLength ); }
200 int GetStartEndingWidth() const { return m_startEnding.GetWidth(); }
201 void SetStartEndingWidth( int aWidth ) { m_startEnding.SetWidth( aWidth ); }
202
203 int GetEndEndingLength() const { return m_endEnding.GetLength(); }
204 void SetEndEndingLength( int aLength ) { m_endEnding.SetLength( aLength ); }
205 int GetEndEndingWidth() const { return m_endEnding.GetWidth(); }
206 void SetEndEndingWidth( int aWidth ) { m_endEnding.SetWidth( aWidth ); }
207
208 int GetStartEndingStrokeWidth() const { return m_startEnding.GetStrokeWidth(); }
209 void SetStartEndingStrokeWidth( int aWidth ) { m_startEnding.SetStrokeWidth( aWidth ); }
210 int GetEndEndingStrokeWidth() const { return m_endEnding.GetStrokeWidth(); }
211 void SetEndEndingStrokeWidth( int aWidth ) { m_endEnding.SetStrokeWidth( aWidth ); }
212
219 void GetEndingTangents( EDA_ANGLE& aStartTangent, EDA_ANGLE& aEndTangent, int aLineWidth = 0 ) const;
220
226 bool GetLineEndingEndpoints( VECTOR2I& aStartPoint, VECTOR2I& aEndPoint ) const;
227
235 static bool ShortenSegmentForEndings( VECTOR2I& aStart, VECTOR2I& aEnd, const LINE_ENDING& aStartEnding,
236 const LINE_ENDING& aEndEnding, int aLineWidth );
237
243 bool ShortenArcForEndings( EDA_ANGLE& aStartAngle, EDA_ANGLE& aArcAngle, double aRadius, int aLineWidth ) const;
244
252 std::optional<BEZIER<double>> ShortenedBezierCurve( int aLineWidth ) const;
253
257 std::vector<VECTOR2D> ShortenedBezierPolyline( int aLineWidth ) const;
258
259 bool ShortenPolyForEndings( VECTOR2D& aFirst, VECTOR2D& aLast, const VECTOR2D& aSecond,
260 const VECTOR2D& aPenultimate, int aLineWidth ) const;
261
270 bool ShortenBodyPolyPoints( std::vector<VECTOR2I>& aPoints, int aOutlineIdx, int aLineWidth ) const;
271
277 bool GetShortenedBodyPolyPoints( const SHAPE_LINE_CHAIN& aOutline, int aOutlineIdx, std::vector<VECTOR2I>& aPoints,
278 int aLineWidth ) const;
279
280
284 const VECTOR2I& GetStart() const { return m_start; }
285 int GetStartY() const { return m_start.y; }
286 int GetStartX() const { return m_start.x; }
287
288 virtual void SetStart( const VECTOR2I& aStart )
289 {
290 m_start = aStart;
291 m_endsSwapped = false;
292 m_hatchingDirty = true;
293 }
294
295 void SetStartY( int y )
296 {
297 VECTOR2I s = m_start;
298 s.y = y;
299 SetStart( s );
300 }
301
302 void SetStartX( int x )
303 {
304 VECTOR2I s = m_start;
305 s.x = x;
306 SetStart( s );
307 }
308
309 void SetCenterY( int y )
310 {
311 VECTOR2I newStart = m_start;
312 VECTOR2I newEnd = m_end;
313 newEnd.y += y - m_start.y;
314 newStart.y = y;
315 SetStart( newStart );
316 SetEnd( newEnd );
317 m_hatchingDirty = true;
318 }
319
320 void SetCenterX( int x )
321 {
322 VECTOR2I newStart = m_start;
323 VECTOR2I newEnd = m_end;
324 newEnd.x += x - m_start.x;
325 newStart.x = x;
326 SetStart( newStart );
327 SetEnd( newEnd );
328 m_hatchingDirty = true;
329 }
330
334 const VECTOR2I& GetEnd() const { return m_end; }
335 int GetEndY() const { return m_end.y; }
336 int GetEndX() const { return m_end.x; }
337
338 virtual void SetEnd( const VECTOR2I& aEnd )
339 {
340 m_end = aEnd;
341 m_endsSwapped = false;
342 m_hatchingDirty = true;
343 }
344
345 void SetEndY( int aY )
346 {
347 VECTOR2I e = m_end;
348 e.y = aY;
349 SetEnd( e );
350 }
351
352 void SetEndX( int aX )
353 {
354 VECTOR2I e = m_end;
355 e.x = aX;
356 SetEnd( e );
357 }
358
359 void SetRadius( int aX )
360 {
361 SetEnd( m_start + VECTOR2I( aX, 0 ) );
362 m_hatchingDirty = true;
363 }
364
365 virtual VECTOR2I GetTopLeft() const { return GetStart(); }
366 virtual VECTOR2I GetBotRight() const { return GetEnd(); }
367
368 virtual void SetTop( int val ) { SetStartY( val ); }
369 virtual void SetLeft( int val ) { SetStartX( val ); }
370 virtual void SetRight( int val ) { SetEndX( val ); }
371 virtual void SetBottom( int val ) { SetEndY( val ); }
372
373 virtual void SetBezierC1( const VECTOR2I& aPt ) { m_bezierC1 = aPt; }
374 const VECTOR2I& GetBezierC1() const { return m_bezierC1; }
375
376 virtual void SetBezierC2( const VECTOR2I& aPt ) { m_bezierC2 = aPt; }
377 const VECTOR2I& GetBezierC2() const { return m_bezierC2; }
378
379 virtual void SetEllipseCenter( const VECTOR2I& aPt )
380 {
381 m_ellipse.Center = aPt;
382 m_hatchingDirty = true;
384 }
385
386 const VECTOR2I& GetEllipseCenter() const { return m_ellipse.Center; }
387
388 virtual void SetEllipseMajorRadius( int aR )
389 {
390 m_ellipse.MajorRadius = aR;
391 m_hatchingDirty = true;
393 }
394
395 int GetEllipseMajorRadius() const { return m_ellipse.MajorRadius; }
396
397 virtual void SetEllipseMinorRadius( int aR )
398 {
399 m_ellipse.MinorRadius = aR;
400 m_hatchingDirty = true;
402 }
403
404 int GetEllipseMinorRadius() const { return m_ellipse.MinorRadius; }
405
406 virtual void SetEllipseRotation( const EDA_ANGLE& aA )
407 {
408 m_ellipse.Rotation = aA;
409 m_hatchingDirty = true;
411 }
412
413 EDA_ANGLE GetEllipseRotation() const { return m_ellipse.Rotation; }
414
415 // Meaningful only when m_shape == SHAPE_T::ELLIPSE_ARC.
416 virtual void SetEllipseStartAngle( const EDA_ANGLE& aA )
417 {
418 m_ellipse.StartAngle = aA;
419 m_hatchingDirty = true;
421 }
422
423 EDA_ANGLE GetEllipseStartAngle() const { return m_ellipse.StartAngle; }
424
425 virtual void SetEllipseEndAngle( const EDA_ANGLE& aA )
426 {
427 m_ellipse.EndAngle = aA;
428 m_hatchingDirty = true;
430 }
431
432 EDA_ANGLE GetEllipseEndAngle() const { return m_ellipse.EndAngle; }
433
436 const ELLIPSE<int>& GetEllipse() const { return m_ellipse; }
437
438 VECTOR2I getCenter() const;
439 virtual void SetCenter( const VECTOR2I& aCenter );
440
448 void SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
449
450 virtual void SetArcAngle( const EDA_ANGLE& aAngle ) { SetArcAngleAndEnd( aAngle, true ); }
451
452 EDA_ANGLE GetArcAngle() const;
453
455
461 bool EndsSwapped() const { return m_endsSwapped; }
462
463 // Some attributes are read only, since they are derived from m_Start, m_End, and m_Angle.
464 // No Set...() function for these attributes.
465
466 VECTOR2I GetArcMid() const;
467 std::vector<VECTOR2I> GetRectCorners() const;
468 virtual std::vector<VECTOR2I> GetCornersInSequence( EDA_ANGLE angle ) const;
469
474 void CalcArcAngles( EDA_ANGLE& aStartAngle, EDA_ANGLE& aEndAngle ) const;
475
476 int GetRadius() const;
477
484 virtual void SetArcGeometry( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
485
490 void SetArcOrSegment( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
491
503 void SetCachedArcData( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd,
504 const VECTOR2I& aCenter );
505
506 const std::vector<VECTOR2I>& GetBezierPoints() const { return m_bezierPoints; }
507
514 std::vector<VECTOR2I> GetPolyPoints() const;
515
519 int GetPointCount() const;
520
522 const SHAPE_POLY_SET& GetPolyShape() const;
523
527 bool IsPolyShapeValid() const;
528
529 virtual void SetPolyShape( const SHAPE_POLY_SET& aShape )
530 {
531 GetPolyShape() = aShape;
532
533 for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
534 {
535 if( GetPolyShape().HoleCount( ii ) )
536 {
538 break;
539 }
540 }
541
542 m_hatchingDirty = true;
543 }
544
545 void SetPolyPoints( const std::vector<VECTOR2I>& aPoints );
546
555 void RebuildBezierToSegmentsPointsList( int aMaxError );
557
566 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const
567 {
568 return makeEffectiveShapes( aEdgeOnly );
569 }
570
576 std::vector<SHAPE*> MakeLineEndingEffectiveShapes( int aLineWidth ) const;
577
584 std::vector<SHAPE*> MakeEffectiveShapesWithLineEndings( int aLineWidth ) const;
585
586 virtual std::vector<SHAPE*> MakeEffectiveShapesForHitTesting() const
587 {
588 return makeEffectiveShapes( false, false, true );
589 }
590
607 std::vector<SHAPE*> MakeEffectiveShapesForStroking( int aLineWidth = -1 ) const;
608
609 void ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
610
611 void SetRectangleHeight( const int& aHeight );
612
613 void SetRectangleWidth( const int& aWidth );
614
615 void SetRectangle( const long long int& aHeight, const long long int& aWidth );
616
617 virtual void SetCornerRadius( int aRadius );
618 int GetCornerRadius() const;
619
620 bool IsClockwiseArc() const;
621
625 double GetLength() const;
626
627 int GetRectangleHeight() const;
628 int GetRectangleWidth() const;
629
630 virtual void UpdateHatching() const;
631
645 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc,
646 bool ignoreLineWidth = false, bool includeFill = false ) const;
647
651 void TransformLineEndingsToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc,
652 int aLineWidth ) const;
653
657 void TransformWithLineEndingsToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc,
658 bool ignoreLineWidth = false ) const;
659
660 bool GetLineEndingsBoundingBox( BOX2I& aBBox, int aLineWidth ) const;
661
662 int Compare( const EDA_SHAPE* aOther ) const;
663
664 double Similarity( const EDA_SHAPE& aOther ) const;
665
666 bool operator==( const EDA_SHAPE& aOther ) const;
667
668protected:
669 wxString getFriendlyName( FRAME_T aFrameType ) const;
670
671 void setPosition( const VECTOR2I& aPos );
672 VECTOR2I getPosition() const;
673
674 virtual void setFilled( bool aFlag )
675 {
677 }
678
680 {
681 return SHAPE_POLY_SET();
682 }
683
684 void move( const VECTOR2I& aMoveVector );
685 void rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle );
686 void flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection );
687 void mirror( const SEG& aAxis );
688 void scale( double aScale );
689
690 virtual EDA_ANGLE getDrawRotation() const { return ANGLE_0; }
691
692 const BOX2I getBoundingBox() const;
693
694 void computeArcBBox( BOX2I& aBBox ) const;
695
696 bool hitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
697 bool hitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const;
698 bool hitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const;
699
700 const std::vector<VECTOR2I> buildBezierToSegmentsPointsList( int aMaxError ) const;
701
702 void beginEdit( const VECTOR2I& aStartPoint );
703 bool continueEdit( const VECTOR2I& aPosition );
704 void calcEdit( const VECTOR2I& aPosition );
705
711 void endEdit( bool aClosed = true );
712 void setEditState( int aState ) { m_editState = aState; }
713
714 virtual bool isMoving() const { return false; }
715
727 // fixme: move to shape_compound
728 std::vector<SHAPE*> makeEffectiveShapes( bool aEdgeOnly, bool aLineChainOnly = false,
729 bool aHittesting = false ) const;
730
738 std::vector<SHAPE*> makeShortenedBodyShapes( int aLineWidth, bool aEdgeOnly = false ) const;
739
741
745
746 virtual int getMaxError() const { return 100; }
747
748 // non-const for PCB_SHAPE
749 SHAPE_POLY_SET& hatching() const;
750 std::vector<SEG>& hatchLines() const;
751
752protected:
753 bool m_endsSwapped; // true if start/end were swapped e.g. SetArcAngleAndEnd
754 SHAPE_T m_shape; // Shape: line, Circle, Arc
755 STROKE_PARAMS m_stroke; // Line style, width, etc.
756 LINE_ENDING m_startEnding; // Line ending at start point
757 LINE_ENDING m_endEnding; // Line ending at end point
758 LINE_ENDING m_blankEnding; // Used to return a blank ending for closed shapes
761
762 mutable std::unique_ptr<EDA_SHAPE_HATCH_CACHE_DATA> m_hatchingCache;
763 mutable bool m_hatchingDirty;
764
765 long long int m_rectangleHeight;
766 long long int m_rectangleWidth;
768
769 VECTOR2I m_start; // Line start point or Circle center
770 VECTOR2I m_end; // Line end point or Circle 3 o'clock point
771
772 VECTOR2I m_arcCenter; // Used only for Arcs: arc end point
773 ARC_MID m_arcMidData; // Used to store originating data
774
775 VECTOR2I m_bezierC1; // Bezier Control Point 1
776 VECTOR2I m_bezierC2; // Bezier Control Point 2
777
778 std::vector<VECTOR2I> m_bezierPoints;
779 ELLIPSE<int> m_ellipse; // Used only for ELLIPSE / ELLIPSE_ARC
780 mutable std::unique_ptr<SHAPE_POLY_SET> m_poly; // Stores the S_POLYGON shape
781
783 bool m_proxyItem; // A shape storing proxy information (ie: a pad
784 // number box, thermal spoke template, etc.)
785};
786
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:917
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.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
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:169
EDA_ANGLE GetArcAngle() const
int GetStartEndingLength() const
Definition eda_shape.h:198
SHAPE_T m_shape
Definition eda_shape.h:754
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:338
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:302
int GetEllipseMinorRadius() const
Definition eda_shape.h:404
bool m_proxyItem
Definition eda_shape.h:783
LINE_ENDING m_blankEnding
Definition eda_shape.h:758
int m_cornerRadius
Definition eda_shape.h:767
void SetArcOrSegment(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the shape from three points, falling back to a SEGMENT from aStart to aEnd when the points are co...
bool m_hatchingDirty
Definition eda_shape.h:763
bool m_endsSwapped
Definition eda_shape.h:753
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:377
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:386
bool GetLineEndingsBoundingBox(BOX2I &aBBox, int aLineWidth) const
virtual void SetCenter(const VECTOR2I &aCenter)
VECTOR2I getCenter() const
int GetStartY() const
Definition eda_shape.h:285
void SetFillModeProp(UI_FILL_MODE)
void mirror(const SEG &aAxis)
int m_editState
Definition eda_shape.h:782
virtual int getMaxError() const
Definition eda_shape.h:746
virtual VECTOR2I GetTopLeft() const
Definition eda_shape.h:365
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
void SetEndEnding(const LINE_ENDING &aEnding)
Definition eda_shape.h:190
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:204
void SetStartEndingStyle(LINE_ENDING_STYLE aStyle)
Definition eda_shape.h:193
const SHAPE_POLY_SET & GetHatching() const
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:432
FILL_T GetFillMode() const
Definition eda_shape.h:151
void SetEndEndingWidth(int aWidth)
Definition eda_shape.h:206
virtual void SetCornerRadius(int aRadius)
long long int m_rectangleHeight
Definition eda_shape.h:765
virtual EDA_ITEM * AsEdaItem()
Definition eda_shape.h:101
int GetEllipseMajorRadius() const
Definition eda_shape.h:395
std::unique_ptr< EDA_SHAPE_HATCH_CACHE_DATA > m_hatchingCache
Definition eda_shape.h:762
void SetEndY(int aY)
Definition eda_shape.h:345
virtual int GetEffectiveWidth() const
Definition eda_shape.h:167
std::vector< VECTOR2I > GetPolyPoints() const
Duplicate the polygon outlines into a flat list of VECTOR2I points.
ELLIPSE< int > m_ellipse
Definition eda_shape.h:779
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:175
EDA_SHAPE(EDA_SHAPE &&) noexcept=default
int GetEndX() const
Definition eda_shape.h:336
bool ShortenBodyPolyPoints(std::vector< VECTOR2I > &aPoints, int aOutlineIdx, int aLineWidth) const
Apply line-ending body shortening to copied/generated polyline points.
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:295
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:566
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:309
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:208
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:413
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
void SetEndEndingStyle(LINE_ENDING_STYLE aStyle)
Definition eda_shape.h:196
virtual bool isMoving() const
Definition eda_shape.h:714
virtual void SetEllipseEndAngle(const EDA_ANGLE &aA)
Definition eda_shape.h:425
int GetEndEndingStrokeWidth() const
Definition eda_shape.h:210
bool operator==(const EDA_SHAPE &aOther) const
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:178
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:184
virtual void SetBezierC2(const VECTOR2I &aPt)
Definition eda_shape.h:376
virtual VECTOR2I GetBotRight() const
Definition eda_shape.h:366
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:371
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:133
virtual SHAPE_POLY_SET getHatchingKnockouts() const
Definition eda_shape.h:679
VECTOR2I m_arcCenter
Definition eda_shape.h:772
void SetCenterX(int x)
Definition eda_shape.h:320
virtual void SetBezierC1(const VECTOR2I &aPt)
Definition eda_shape.h:373
int GetStartEndingWidth() const
Definition eda_shape.h:200
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:145
virtual void SetTop(int val)
Definition eda_shape.h:368
virtual bool IsFilledForHitTesting() const
Definition eda_shape.h:140
virtual void SetEllipseRotation(const EDA_ANGLE &aA)
Definition eda_shape.h:406
bool continueEdit(const VECTOR2I &aPosition)
virtual void SetArcAngle(const EDA_ANGLE &aAngle)
Definition eda_shape.h:450
wxString ShowShape() const
LINE_ENDING_STYLE GetStartEndingStyle() const
Definition eda_shape.h:192
ARC_MID m_arcMidData
Definition eda_shape.h:773
void SetFillColor(const COLOR4D &aColor)
Definition eda_shape.h:163
int GetEndY() const
Definition eda_shape.h:335
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:352
virtual int GetHatchLineWidth() const
Definition eda_shape.h:168
bool IsSolidFill() const
Definition eda_shape.h:126
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
int GetEndEndingWidth() const
Definition eda_shape.h:205
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:203
VECTOR2I m_start
Definition eda_shape.h:769
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:334
bool IsClosed() const
void SetRadius(int aX)
Definition eda_shape.h:359
LINE_STYLE GetLineStyle() const
void endEdit(bool aClosed=true)
Finish editing the shape.
virtual void SetEllipseCenter(const VECTOR2I &aPt)
Definition eda_shape.h:379
void SetStartEndingLength(int aLength)
Definition eda_shape.h:199
void SetEndEndingStrokeWidth(int aWidth)
Definition eda_shape.h:211
virtual void SetEllipseMinorRadius(int aR)
Definition eda_shape.h:397
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:284
virtual void SetEllipseMajorRadius(int aR)
Definition eda_shape.h:388
void SetLineColor(const COLOR4D &aColor)
Definition eda_shape.h:174
COLOR4D GetFillColor() const
Definition eda_shape.h:162
void SetRectangle(const long long int &aHeight, const long long int &aWidth)
virtual void SetShape(SHAPE_T aShape)
Definition eda_shape.h:177
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:201
std::vector< VECTOR2I > m_bezierPoints
Definition eda_shape.h:778
bool IsAnyFill() const
Definition eda_shape.h:121
void setPosition(const VECTOR2I &aPos)
virtual std::vector< SHAPE * > MakeEffectiveShapesForHitTesting() const
Definition eda_shape.h:586
virtual void setFilled(bool aFlag)
Definition eda_shape.h:674
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:423
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition eda_shape.h:506
virtual bool IsProxyItem() const
Definition eda_shape.h:118
void computeArcBBox(BOX2I &aBBox) const
const LINE_ENDING & GetStartEnding() const
Definition eda_shape.h:180
virtual void UpdateHatching() const
LINE_ENDING m_startEnding
Definition eda_shape.h:756
bool EndsSwapped() const
Have the start and end points been swapped since they were set?
Definition eda_shape.h:461
void SetRectangleWidth(const int &aWidth)
virtual void SetEllipseStartAngle(const EDA_ANGLE &aA)
Definition eda_shape.h:416
virtual 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:369
double GetLength() const
wxString SHAPE_T_asString() const
int GetStartX() const
Definition eda_shape.h:286
double Similarity(const EDA_SHAPE &aOther) const
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:374
std::optional< BEZIER< double > > ShortenedBezierCurve(int aLineWidth) const
Return the cubic Bezier curve shortened for line endings.
VECTOR2I m_end
Definition eda_shape.h:770
const BOX2I getBoundingBox() const
virtual EDA_ANGLE getDrawRotation() const
Definition eda_shape.h:690
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:166
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:755
const LINE_ENDING & GetEndEnding() const
Definition eda_shape.h:186
LINE_ENDING m_endEnding
Definition eda_shape.h:757
void SetHatchingDirty()
Definition eda_shape.h:156
void setEditState(int aState)
Definition eda_shape.h:712
LINE_ENDING_STYLE GetEndEndingStyle() const
Definition eda_shape.h:195
void RebuildBezierToSegmentsPointsList()
Definition eda_shape.h:556
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
EDA_SHAPE & operator=(const EDA_SHAPE &aOther)
VECTOR2I m_bezierC1
Definition eda_shape.h:775
FILL_T m_fill
Definition eda_shape.h:759
COLOR4D m_fillColor
Definition eda_shape.h:760
virtual void SetWidth(int aWidth)
EDA_ANGLE GetSegmentAngle() const
void SetStartEndingStrokeWidth(int aWidth)
Definition eda_shape.h:209
virtual void SetRight(int val)
Definition eda_shape.h:370
int GetCornerRadius() const
void SetFillMode(FILL_T aFill)
std::unique_ptr< SHAPE_POLY_SET > m_poly
Definition eda_shape.h:780
virtual void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition eda_shape.h:529
virtual void SetIsProxyItem(bool aIsProxy=true)
Definition eda_shape.h:119
virtual void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:288
wxString getFriendlyName(FRAME_T aFrameType) const
long long int m_rectangleWidth
Definition eda_shape.h:766
VECTOR2I m_bezierC2
Definition eda_shape.h:776
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:436
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
Definition seg.h:38
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:472
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:55
@ ELLIPSE
Definition eda_shape.h:63
@ SEGMENT
Definition eda_shape.h:57
@ ELLIPSE_ARC
Definition eda_shape.h:64
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:26
#define DECLARE_ENUM_TO_WXANY(type)
Definition property.h:879
const int scale
LINE_STYLE
Dashed line types.
Holding struct to keep originating midpoint.
Definition eda_shape.h:70
VECTOR2I end
Definition eda_shape.h:73
VECTOR2I center
Definition eda_shape.h:74
VECTOR2I start
Definition eda_shape.h:72
VECTOR2I mid
Definition eda_shape.h:71
SHAPE_POLY_SET hatching
Definition eda_shape.h:80
std::vector< SEG > hatchLines
Definition eda_shape.h:81
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707