58 double scale = ( factor.
x + factor.
y ) * 0.5;
60 if( aLineWidth <= 0.0 )
64 return int( aLineWidth *
scale );
80 std::unique_ptr<PCB_SHAPE> line = std::make_unique<PCB_SHAPE>(
m_parent );
81 line->SetShape( SHAPE_T::SEGMENT );
88 if( line->GetStart() == line->GetEnd() )
99 std::unique_ptr<PCB_SHAPE> circle = std::make_unique<PCB_SHAPE>(
m_parent );
100 circle->SetShape( SHAPE_T::CIRCLE );
101 circle->SetFilled( aFilled );
107 addItem( std::move( circle ) );
129 double radius = ( center -
MapCoordinate( aStart ) ).EuclideanNorm();
130 double rd_max_value = std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0;
132 if( radius >= rd_max_value )
135 AddLine( aStart, end, aStroke );
139 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>(
m_parent );
140 arc->SetShape( SHAPE_T::ARC );
154 std::vector<VECTOR2I> convertedPoints;
155 convertedPoints.reserve( aVertices.size() );
157 for(
const VECTOR2D& precisePoint : aVertices )
158 convertedPoints.emplace_back(
MapCoordinate( precisePoint ) );
160 std::unique_ptr<PCB_SHAPE> polygon = std::make_unique<PCB_SHAPE>(
m_parent );
161 polygon->SetShape( SHAPE_T::POLY );
162 polygon->SetFilled( aFilled );
164 polygon->SetPolyPoints( convertedPoints );
168 polygon->Rotate( { 0, 0 }, parentFP->GetOrientation() );
169 polygon->Move( parentFP->GetPosition() );
174 if( polygon->IsPolyShapeValid() )
175 addItem( std::move( polygon ) );
180 double aHeight,
double aWidth,
double aThickness,
184 std::unique_ptr<PCB_TEXT> textItem = std::make_unique<PCB_TEXT>(
m_parent );
186 textItem->SetTextThickness(
MapLineWidth( aThickness ) );
191 textItem->SetVertJustify( aVJustify );
192 textItem->SetHorizJustify( aHJustify );
193 textItem->SetText( aText );
195 addItem( std::move( textItem ) );
203 std::unique_ptr<PCB_SHAPE> spline = std::make_unique<PCB_SHAPE>(
m_parent );
204 spline->SetShape( SHAPE_T::BEZIER );
211 spline->RebuildBezierToSegmentsPointsList(
ARC_HIGH_DEF );
215 if( spline->GetBezierPoints().size() <= 2 )
217 spline->SetShape( SHAPE_T::SEGMENT );
221 #define MIN_SEG_LEN_ACCEPTABLE_NM 20
226 addItem( std::move( spline ) );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
FOOTPRINT * GetParentFootprint() const
GRAPHICS_IMPORTER_PCBNEW(BOARD_ITEM_CONTAINER *aParent)
void AddText(const VECTOR2D &aOrigin, const wxString &aText, double aHeight, double aWidth, double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify, const COLOR4D &aColor=COLOR4D::UNSPECIFIED) override
Create an object representing a text.
BOARD_ITEM_CONTAINER * m_parent
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, const EDA_ANGLE &aAngle, const IMPORTED_STROKE &aStroke) override
Create an object representing an arc.
void AddCircle(const VECTOR2D &aCenter, double aRadius, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor=COLOR4D::UNSPECIFIED) override
Create an object representing a circle.
void AddLine(const VECTOR2D &aStart, const VECTOR2D &aEnd, const IMPORTED_STROKE &aStroke) override
Create an object representing a line segment.
void AddSpline(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, const IMPORTED_STROKE &aStroke) override
Create an object representing an arc.
int MapLineWidth(double aLineWidth)
If aLineWidth < 0, the default line thickness value is returned.
PCB_LAYER_ID GetLayer() const
PCB_LAYER_ID m_layer
< Target layer for the imported shapes.
void AddPolygon(const std::vector< VECTOR2D > &aVertices, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor=COLOR4D::UNSPECIFIED) override
Create an object representing a polygon.
STROKE_PARAMS MapStrokeParams(const IMPORTED_STROKE &aStroke)
VECTOR2I MapCoordinate(const VECTOR2D &aCoordinate)
Convert an imported coordinate to a board coordinate, according to the internal units,...
VECTOR2D GetScale() const
double GetMillimeterToIuFactor()
double GetLineWidthMM() const
Return the line width used for importing the outlines (in mm).
void addItem(std::unique_ptr< EDA_ITEM > aItem)
< Add an item to the imported shapes list.
double m_millimeterToIu
Offset (in mm) for imported coordinates.
const VECTOR2D & GetImportOffsetMM() const
VECTOR2D ImportScalingFactor() const
A clone of IMPORTED_STROKE, but with floating-point width.
LINE_STYLE GetPlotStyle() const
KIGFX::COLOR4D GetColor() const
A color representation with 4 components: red, green, blue, alpha.
Simple container to manage line stroke parameters.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
#define MIN_SEG_LEN_ACCEPTABLE_NM
constexpr int mmToIU(double mm) const
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D