103 double scale = ( factor.
x + factor.
y ) * 0.5;
105 if( aLineWidth <= 0.0 )
109 return int( aLineWidth *
scale );
127 std::unique_ptr<PCB_SHAPE> line = std::make_unique<PCB_SHAPE>(
m_parent );
135 if( line->GetStart() == line->GetEnd() )
146 std::unique_ptr<PCB_SHAPE>
circle = std::make_unique<PCB_SHAPE>(
m_parent );
148 circle->SetFilled( aFilled );
177 double rd_max_value = std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0;
179 if(
radius >= rd_max_value )
186 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>(
m_parent );
201 std::vector<VECTOR2I> convertedPoints;
202 convertedPoints.reserve( aVertices.size() );
204 for(
const VECTOR2D& precisePoint : aVertices )
205 convertedPoints.emplace_back(
MapCoordinate( precisePoint ) );
207 std::unique_ptr<PCB_SHAPE> polygon = std::make_unique<PCB_SHAPE>(
m_parent );
209 polygon->SetFilled( aFilled );
211 polygon->SetPolyPoints( convertedPoints );
213 if(
FOOTPRINT* parentFP = polygon->GetParentFootprint() )
215 polygon->Rotate( { 0, 0 }, parentFP->GetOrientation() );
216 polygon->Move( parentFP->GetPosition() );
221 if( polygon->IsPolyShapeValid() )
222 addItem( std::move( polygon ) );
227 double aHeight,
double aWidth,
double aThickness,
231 std::unique_ptr<PCB_TEXT> textItem = std::make_unique<PCB_TEXT>(
m_parent );
233 textItem->SetTextThickness(
MapLineWidth( aThickness ) );
238 textItem->SetVertJustify( aVJustify );
239 textItem->SetHorizJustify( aHJustify );
240 textItem->SetText( aText );
242 addItem( std::move( textItem ) );
250 std::unique_ptr<PCB_SHAPE> spline = std::make_unique<PCB_SHAPE>(
m_parent );
261 addItem( std::move( spline ) );
270 std::unique_ptr<PCB_SHAPE> ellipse = std::make_unique<PCB_SHAPE>(
m_parent );
274 ellipse->SetFilled( aFilled );
277 ellipse->SetEllipseCenter(
center );
280 ellipse->SetEllipseRotation( aRotation );
282 addItem( std::move( ellipse ) );
290 std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>(
m_parent );
296 arc->SetEllipseCenter(
center );
299 arc->SetEllipseRotation( aRotation );
300 arc->SetEllipseStartAngle( aStartAngle );
301 arc->SetEllipseEndAngle( aEndAngle );
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.
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
bool CanImportSourceLayer(const wxString &aSourceLayer) const override
Return true if shapes from a given source layer should be imported.
std::map< wxString, PCB_LAYER_ID > m_layerMap
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, const EDA_ANGLE &aAngle, const IMPORTED_STROKE &aStroke) override
Create an object representing an arc.
void SetLayerMap(const std::map< wxString, PCB_LAYER_ID > &aLayerMap)
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.
PCB_LAYER_ID m_defaultLayer
void AddLine(const VECTOR2D &aStart, const VECTOR2D &aEnd, const IMPORTED_STROKE &aStroke) override
Create an object representing a line segment.
void AddEllipse(const VECTOR2D &aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor=COLOR4D::UNSPECIFIED) override
Create an object representing a closed ellipse.
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.
void AddEllipseArc(const VECTOR2D &aCenter, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, const IMPORTED_STROKE &aStroke) override
Create an object representing an elliptical 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)
void SetCurrentSourceLayer(const wxString &aSourceLayer) override
Set the source layer for the next buffered shape to be imported.
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
Factor to convert millimeters to Internal Units.
bool setupSplineOrLine(EDA_SHAPE &aShape, int aAccuracy)
Configure a shape as a spline or a line segment if it's degenerate.
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.
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
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