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