2021-07-14 20:03:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2024-04-15 20:18:54 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-07-14 20:03:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EDA_SHAPE_H
|
|
|
|
#define EDA_SHAPE_H
|
|
|
|
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <geometry/shape_poly_set.h>
|
|
|
|
#include <geometry/geometry_utils.h>
|
2023-06-25 00:08:42 +00:00
|
|
|
#include <properties/property.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <stroke_params.h>
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
class LINE_READER;
|
|
|
|
class EDA_DRAW_FRAME;
|
|
|
|
class FOOTPRINT;
|
|
|
|
class MSG_PANEL_ITEM;
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
using KIGFX::COLOR4D;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
enum class SHAPE_T : int
|
|
|
|
{
|
2024-01-20 23:35:29 +00:00
|
|
|
UNDEFINED = -1,
|
2021-07-14 20:03:32 +00:00
|
|
|
SEGMENT = 0,
|
2023-07-24 16:07:56 +00:00
|
|
|
RECTANGLE, /// use RECTANGLE instead of RECT to avoid collision in a Windows header
|
2021-07-14 20:03:32 +00:00
|
|
|
ARC,
|
|
|
|
CIRCLE,
|
|
|
|
POLY,
|
2023-06-12 18:12:39 +00:00
|
|
|
BEZIER
|
2021-07-14 20:03:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-10-18 00:00:54 +00:00
|
|
|
// WARNING: Do not change these values without updating dialogs that depend on their position values
|
2021-07-18 23:08:54 +00:00
|
|
|
enum class FILL_T : int
|
|
|
|
{
|
|
|
|
NO_FILL = 1,
|
|
|
|
FILLED_SHAPE, // Fill with object color
|
|
|
|
FILLED_WITH_BG_BODYCOLOR, // Fill with background body color
|
|
|
|
FILLED_WITH_COLOR // Fill with a separate color
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-03-04 23:18:34 +00:00
|
|
|
// Holding struct to keep originating midpoint
|
|
|
|
struct ARC_MID
|
|
|
|
{
|
|
|
|
VECTOR2I mid;
|
|
|
|
VECTOR2I start;
|
|
|
|
VECTOR2I end;
|
|
|
|
VECTOR2I center;
|
|
|
|
};
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
class EDA_SHAPE
|
|
|
|
{
|
|
|
|
public:
|
2022-08-27 11:37:43 +00:00
|
|
|
EDA_SHAPE( SHAPE_T aType, int aLineWidth, FILL_T aFill );
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
// Do not create a copy constructor & operator=.
|
|
|
|
// The ones generated by the compiler are adequate.
|
|
|
|
|
2021-12-31 00:05:02 +00:00
|
|
|
virtual ~EDA_SHAPE();
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
void SwapShape( EDA_SHAPE* aImage );
|
|
|
|
|
|
|
|
wxString ShowShape() const;
|
|
|
|
|
|
|
|
wxString SHAPE_T_asString() const;
|
|
|
|
|
2023-09-13 10:27:04 +00:00
|
|
|
virtual bool IsProxyItem() const { return m_proxyItem; }
|
|
|
|
virtual void SetIsProxyItem( bool aIsProxy = true ) { m_proxyItem = aIsProxy; }
|
2022-09-14 10:34:10 +00:00
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
bool IsFilled() const
|
|
|
|
{
|
|
|
|
return GetFillMode() != FILL_T::NO_FILL;
|
|
|
|
}
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2024-06-01 21:47:46 +00:00
|
|
|
virtual bool IsFilledForHitTesting() const
|
|
|
|
{
|
|
|
|
return IsFilled();
|
|
|
|
}
|
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
void SetFilled( bool aFlag )
|
2021-07-14 20:03:32 +00:00
|
|
|
{
|
2023-10-30 17:29:38 +00:00
|
|
|
setFilled( aFlag );
|
2021-07-14 20:03:32 +00:00
|
|
|
}
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
void SetFillMode( FILL_T aFill ) { m_fill = aFill; }
|
|
|
|
FILL_T GetFillMode() const { return m_fill; }
|
|
|
|
|
2022-11-27 18:29:41 +00:00
|
|
|
bool IsClosed() const;
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
COLOR4D GetFillColor() const { return m_fillColor; }
|
|
|
|
void SetFillColor( const COLOR4D& aColor ) { m_fillColor = aColor; }
|
|
|
|
|
|
|
|
void SetWidth( int aWidth ) { m_stroke.SetWidth( aWidth ); }
|
2023-09-14 12:39:35 +00:00
|
|
|
virtual int GetWidth() const { return m_stroke.GetWidth(); }
|
2022-04-08 15:14:42 +00:00
|
|
|
virtual int GetEffectiveWidth() const { return GetWidth(); }
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2023-11-25 13:05:45 +00:00
|
|
|
void SetLineStyle( const LINE_STYLE aStyle );
|
|
|
|
LINE_STYLE GetLineStyle() const;
|
2023-08-25 02:32:12 +00:00
|
|
|
|
2023-10-30 17:29:38 +00:00
|
|
|
void SetLineColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); }
|
|
|
|
COLOR4D GetLineColor() const { return m_stroke.GetColor(); }
|
|
|
|
|
2022-04-08 15:14:42 +00:00
|
|
|
void SetShape( SHAPE_T aShape ) { m_shape = aShape; }
|
|
|
|
SHAPE_T GetShape() const { return m_shape; }
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the starting point of the graphic.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& GetStart() const { return m_start; }
|
2022-06-02 09:42:13 +00:00
|
|
|
int GetStartY() const { return m_start.y; }
|
|
|
|
int GetStartX() const { return m_start.x; }
|
2021-10-17 14:22:07 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetStart( const VECTOR2I& aStart )
|
2021-10-17 14:22:07 +00:00
|
|
|
{
|
|
|
|
m_start = aStart;
|
|
|
|
m_endsSwapped = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStartY( int y )
|
|
|
|
{
|
|
|
|
m_start.y = y;
|
|
|
|
m_endsSwapped = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStartX( int x )
|
|
|
|
{
|
|
|
|
m_start.x = x;
|
|
|
|
m_endsSwapped = false;
|
|
|
|
}
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2024-05-05 18:48:14 +00:00
|
|
|
void SetCenterY( int y )
|
|
|
|
{
|
|
|
|
m_end.y += y - m_start.y;
|
|
|
|
m_start.y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCenterX( int x )
|
|
|
|
{
|
|
|
|
m_end.x += x - m_start.x;
|
|
|
|
m_start.x = x;
|
|
|
|
}
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
/**
|
|
|
|
* Return the ending point of the graphic.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& GetEnd() const { return m_end; }
|
2022-06-02 09:42:13 +00:00
|
|
|
int GetEndY() const { return m_end.y; }
|
|
|
|
int GetEndX() const { return m_end.x; }
|
2021-10-17 14:22:07 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetEnd( const VECTOR2I& aEnd )
|
2021-10-17 14:22:07 +00:00
|
|
|
{
|
|
|
|
m_end = aEnd;
|
|
|
|
m_endsSwapped = false;
|
|
|
|
}
|
|
|
|
|
2024-01-31 02:47:57 +00:00
|
|
|
void SetEndY( int aY )
|
2021-10-17 14:22:07 +00:00
|
|
|
{
|
2024-01-31 02:47:57 +00:00
|
|
|
m_end.y = aY;
|
2021-10-17 14:22:07 +00:00
|
|
|
m_endsSwapped = false;
|
|
|
|
}
|
|
|
|
|
2024-01-31 02:47:57 +00:00
|
|
|
void SetEndX( int aX )
|
2021-10-17 14:22:07 +00:00
|
|
|
{
|
2024-01-31 02:47:57 +00:00
|
|
|
m_end.x = aX;
|
2021-10-17 14:22:07 +00:00
|
|
|
m_endsSwapped = false;
|
|
|
|
}
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2024-01-31 02:47:57 +00:00
|
|
|
void SetRadius( int aX )
|
|
|
|
{
|
|
|
|
m_end = m_start + VECTOR2I( aX, 0 );
|
|
|
|
}
|
|
|
|
|
2022-06-02 09:42:13 +00:00
|
|
|
virtual VECTOR2I GetTopLeft() const { return GetStart(); }
|
|
|
|
virtual VECTOR2I GetBotRight() const { return GetEnd(); }
|
|
|
|
|
|
|
|
virtual void SetTop( int val ) { SetStartY( val ); }
|
|
|
|
virtual void SetLeft( int val ) { SetStartX( val ); }
|
|
|
|
virtual void SetRight( int val ) { SetEndX( val ); }
|
|
|
|
virtual void SetBottom( int val ) { SetEndY( val ); }
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetBezierC1( const VECTOR2I& aPt ) { m_bezierC1 = aPt; }
|
|
|
|
const VECTOR2I& GetBezierC1() const { return m_bezierC1; }
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetBezierC2( const VECTOR2I& aPt ) { m_bezierC2 = aPt; }
|
|
|
|
const VECTOR2I& GetBezierC2() const { return m_bezierC2; }
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I getCenter() const;
|
|
|
|
void SetCenter( const VECTOR2I& aCenter );
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2021-07-18 23:08:54 +00:00
|
|
|
/**
|
2021-10-14 23:39:31 +00:00
|
|
|
* Set the end point from the angle center and start.
|
2023-09-09 16:08:28 +00:00
|
|
|
* aAngle is:
|
|
|
|
* - clockwise in right-down coordinate system
|
|
|
|
* - counter-clockwise in right-up (libedit) coordinate system.
|
2021-07-18 23:08:54 +00:00
|
|
|
*/
|
2022-01-16 16:15:07 +00:00
|
|
|
void SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
|
2021-10-14 23:39:31 +00:00
|
|
|
|
2022-01-14 15:34:41 +00:00
|
|
|
EDA_ANGLE GetArcAngle() const;
|
2021-07-18 23:08:54 +00:00
|
|
|
|
2023-06-24 11:30:17 +00:00
|
|
|
EDA_ANGLE GetSegmentAngle() const;
|
|
|
|
|
2021-10-17 14:22:07 +00:00
|
|
|
/**
|
|
|
|
* Have the start and end points been swapped since they were set?
|
|
|
|
* @return true if they have
|
|
|
|
*/
|
|
|
|
bool EndsSwapped() const { return m_endsSwapped; }
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
// Some attributes are read only, since they are derived from m_Start, m_End, and m_Angle.
|
|
|
|
// No Set...() function for these attributes.
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetArcMid() const;
|
|
|
|
std::vector<VECTOR2I> GetRectCorners() const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
/**
|
2021-10-14 23:39:31 +00:00
|
|
|
* Calc arc start and end angles such that aStartAngle < aEndAngle. Each may be between
|
|
|
|
* -360.0 and 360.0.
|
2021-07-14 20:03:32 +00:00
|
|
|
*/
|
2022-01-16 01:06:25 +00:00
|
|
|
void CalcArcAngles( EDA_ANGLE& aStartAngle, EDA_ANGLE& aEndAngle ) const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
int GetRadius() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the three controlling points for an arc.
|
|
|
|
*
|
|
|
|
* NB: these are NOT what's currently stored, so we have to do some calculations behind
|
|
|
|
* the scenes. However, they are what SHOULD be stored.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetArcGeometry( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-03-04 23:18:34 +00:00
|
|
|
/**
|
|
|
|
* Set the data used for mid point caching. If the controlling points remain constant, then
|
|
|
|
* we keep the midpoint the same as it was when read in. This minimizes VCS churn
|
|
|
|
*
|
|
|
|
* @param aStart Cached start point
|
|
|
|
* @param aMid Cached mid point
|
|
|
|
* @param aEnd Cached end point
|
|
|
|
* @param aCenter Calculated center point using the preceeding three
|
|
|
|
*/
|
|
|
|
void SetCachedArcData( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd, const VECTOR2I& aCenter );
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
const std::vector<VECTOR2I>& GetBezierPoints() const { return m_bezierPoints; }
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
/**
|
2022-01-01 06:04:08 +00:00
|
|
|
* Duplicate the list of corners in a std::vector<VECTOR2I>
|
2021-07-14 20:03:32 +00:00
|
|
|
*
|
|
|
|
* It must be used only to convert the SHAPE_POLY_SET internal corner buffer
|
2022-01-01 06:04:08 +00:00
|
|
|
* to a list of VECTOR2Is, and nothing else, because it duplicates the buffer,
|
2021-07-14 20:03:32 +00:00
|
|
|
* that is inefficient to know for instance the corner count
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void DupPolyPointsList( std::vector<VECTOR2I>& aBuffer ) const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the number of corners of the polygonal shape
|
|
|
|
*/
|
|
|
|
int GetPointCount() const;
|
|
|
|
|
|
|
|
// Accessors to the polygonal shape
|
|
|
|
SHAPE_POLY_SET& GetPolyShape() { return m_poly; }
|
|
|
|
const SHAPE_POLY_SET& GetPolyShape() const { return m_poly; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the polygonal shape is valid (has more than 2 points)
|
|
|
|
*/
|
|
|
|
bool IsPolyShapeValid() const;
|
|
|
|
|
2022-07-29 19:56:55 +00:00
|
|
|
void SetPolyShape( const SHAPE_POLY_SET& aShape )
|
|
|
|
{
|
|
|
|
m_poly = aShape;
|
|
|
|
|
|
|
|
for( int ii = 0; ii < m_poly.OutlineCount(); ++ii )
|
|
|
|
{
|
|
|
|
if( m_poly.HoleCount( ii ) )
|
|
|
|
{
|
|
|
|
m_poly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-03-02 14:18:46 +00:00
|
|
|
void SetPolyPoints( const std::vector<VECTOR2I>& aPoints );
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
/**
|
2022-03-02 14:18:46 +00:00
|
|
|
* Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of
|
|
|
|
* segments.
|
2021-07-14 20:03:32 +00:00
|
|
|
*
|
|
|
|
* Has meaning only for BEZIER shape.
|
|
|
|
*
|
2024-06-18 04:47:06 +00:00
|
|
|
* @param aMinSegLen is the max deviation between the polyline and the curve
|
2021-07-14 20:03:32 +00:00
|
|
|
*/
|
2024-06-18 04:47:06 +00:00
|
|
|
void RebuildBezierToSegmentsPointsList( int aMaxError );
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Make a set of SHAPE objects representing the EDA_SHAPE. Caller owns the objects.
|
2021-07-17 19:56:18 +00:00
|
|
|
*
|
|
|
|
* @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill
|
|
|
|
* shapes.
|
2021-07-14 20:03:32 +00:00
|
|
|
*/
|
2022-07-09 03:34:49 +00:00
|
|
|
virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const
|
|
|
|
{
|
|
|
|
return makeEffectiveShapes( aEdgeOnly );
|
|
|
|
}
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
void ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
|
|
|
|
|
2023-06-24 11:30:17 +00:00
|
|
|
void SetLength( const double& aLength );
|
|
|
|
|
2024-05-26 19:32:06 +00:00
|
|
|
void SetRectangleHeight( const int& aHeight );
|
|
|
|
|
|
|
|
void SetRectangleWidth( const int& aWidth );
|
|
|
|
|
2023-06-26 22:10:40 +00:00
|
|
|
void SetRectangle( const long long int& aHeight, const long long int& aWidth );
|
2023-06-25 09:55:50 +00:00
|
|
|
|
2023-08-14 08:03:27 +00:00
|
|
|
void SetSegmentAngle( const EDA_ANGLE& aAngle );
|
2023-06-24 11:30:17 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
bool IsClockwiseArc() const;
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
/**
|
2023-09-19 10:23:35 +00:00
|
|
|
* @return the length of the segment using the hypotenuse calculation.
|
2021-07-14 20:03:32 +00:00
|
|
|
*/
|
|
|
|
double GetLength() const;
|
|
|
|
|
2023-09-19 10:23:35 +00:00
|
|
|
int GetRectangleHeight() const;
|
|
|
|
int GetRectangleWidth() const;
|
2023-06-25 09:55:50 +00:00
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
/**
|
2022-10-21 12:48:45 +00:00
|
|
|
* Convert the shape to a closed polygon. Circles and arcs are approximated by segments.
|
2021-07-14 20:03:32 +00:00
|
|
|
*
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param aBuffer is a buffer to store the polygon.
|
|
|
|
* @param aClearance is the clearance around the pad.
|
2021-07-14 20:03:32 +00:00
|
|
|
* @param aError is the maximum deviation from a true arc.
|
|
|
|
* @param aErrorLoc whether any approximation error shoule be placed inside or outside
|
2022-10-21 12:48:45 +00:00
|
|
|
* @param ignoreLineWidth is used for edge cut items where the line width is only for
|
|
|
|
* visualization
|
2021-07-14 20:03:32 +00:00
|
|
|
*/
|
2022-10-21 12:48:45 +00:00
|
|
|
void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
|
|
|
|
ERROR_LOC aErrorLoc, bool ignoreLineWidth = false ) const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
|
|
|
int Compare( const EDA_SHAPE* aOther ) const;
|
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
double Similarity( const EDA_SHAPE& aOther ) const;
|
|
|
|
|
|
|
|
bool operator==( const EDA_SHAPE& aOther ) const;
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
protected:
|
2024-04-15 20:18:54 +00:00
|
|
|
wxString getFriendlyName() const;
|
|
|
|
|
|
|
|
void setPosition( const VECTOR2I& aPos );
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I getPosition() const;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2023-10-30 17:29:38 +00:00
|
|
|
virtual void setFilled( bool aFlag )
|
|
|
|
{
|
|
|
|
m_fill = aFlag ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void move( const VECTOR2I& aMoveVector );
|
2022-01-16 21:15:20 +00:00
|
|
|
void rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle );
|
2022-01-01 06:04:08 +00:00
|
|
|
void flip( const VECTOR2I& aCentre, bool aFlipLeftRight );
|
2021-07-14 20:03:32 +00:00
|
|
|
void scale( double aScale );
|
|
|
|
|
2022-08-30 23:28:18 +00:00
|
|
|
const BOX2I getBoundingBox() const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-08-30 23:28:18 +00:00
|
|
|
void computeArcBBox( BOX2I& aBBox ) const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool hitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool hitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2024-06-18 04:47:06 +00:00
|
|
|
const std::vector<VECTOR2I> buildBezierToSegmentsPointsList( int aMaxError ) const;
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void beginEdit( const VECTOR2I& aStartPoint );
|
|
|
|
bool continueEdit( const VECTOR2I& aPosition );
|
|
|
|
void calcEdit( const VECTOR2I& aPosition );
|
2022-01-10 21:36:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finishes editing the shape.
|
|
|
|
* @param aClosed Should polygon shapes be closed (yes for pcbnew/fpeditor, no for libedit)
|
|
|
|
*/
|
|
|
|
void endEdit( bool aClosed = true );
|
2021-10-14 23:39:31 +00:00
|
|
|
void setEditState( int aState ) { m_editState = aState; }
|
|
|
|
|
2022-07-09 03:34:49 +00:00
|
|
|
/**
|
|
|
|
* Make a set of SHAPE objects representing the EDA_SHAPE. Caller owns the objects.
|
|
|
|
*
|
|
|
|
* @param aEdgeOnly indicates only edges should be generated (even if 0 width), and no fill
|
|
|
|
* shapes.
|
|
|
|
* @param aLineChainOnly indicates SHAPE_POLY_SET is being abused slightly to represent a
|
|
|
|
* lineChain rather than a closed polygon
|
|
|
|
*/
|
|
|
|
// fixme: move to shape_compound
|
|
|
|
std::vector<SHAPE*> makeEffectiveShapes( bool aEdgeOnly, bool aLineChainOnly = false ) const;
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
protected:
|
2022-01-01 06:04:08 +00:00
|
|
|
bool m_endsSwapped; // true if start/end were swapped e.g. SetArcAngleAndEnd
|
|
|
|
SHAPE_T m_shape; // Shape: line, Circle, Arc
|
|
|
|
STROKE_PARAMS m_stroke; // Line style, width, etc.
|
|
|
|
FILL_T m_fill;
|
|
|
|
COLOR4D m_fillColor;
|
2021-07-17 19:56:18 +00:00
|
|
|
|
2023-06-26 22:10:40 +00:00
|
|
|
long long int m_rectangleHeight;
|
2023-06-25 09:55:50 +00:00
|
|
|
long long int m_rectangleWidth;
|
|
|
|
|
2023-06-24 11:30:17 +00:00
|
|
|
double m_segmentLength;
|
|
|
|
EDA_ANGLE m_segmentAngle;
|
|
|
|
|
2022-01-16 23:54:59 +00:00
|
|
|
VECTOR2I m_start; // Line start point or Circle center
|
|
|
|
VECTOR2I m_end; // Line end point or Circle 3 o'clock point
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-01-16 23:54:59 +00:00
|
|
|
VECTOR2I m_arcCenter; // Used only for Arcs: arc end point
|
2022-03-04 23:18:34 +00:00
|
|
|
ARC_MID m_arcMidData; // Used to store originating data
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-01-16 23:54:59 +00:00
|
|
|
VECTOR2I m_bezierC1; // Bezier Control Point 1
|
|
|
|
VECTOR2I m_bezierC2; // Bezier Control Point 2
|
2021-07-14 20:03:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> m_bezierPoints;
|
2022-01-16 23:54:59 +00:00
|
|
|
SHAPE_POLY_SET m_poly; // Stores the S_POLYGON shape
|
2021-10-14 23:39:31 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
int m_editState;
|
2023-09-13 10:27:04 +00:00
|
|
|
bool m_proxyItem; // A shape storing proxy information (ie: a pad
|
|
|
|
// number box, thermal spoke template, etc.)
|
2021-07-14 20:03:32 +00:00
|
|
|
};
|
|
|
|
|
2023-06-25 00:08:42 +00:00
|
|
|
#ifndef SWIG
|
|
|
|
DECLARE_ENUM_TO_WXANY( SHAPE_T );
|
2023-11-25 13:05:45 +00:00
|
|
|
DECLARE_ENUM_TO_WXANY( LINE_STYLE );
|
2023-06-25 00:08:42 +00:00
|
|
|
#endif
|
|
|
|
|
2021-07-14 20:03:32 +00:00
|
|
|
#endif // EDA_SHAPE_H
|