54 if( aLineWidth <= 0.0 )
58 return int( aLineWidth *
scale );
81 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>();
84 line->SetStartPoint( pt0 );
85 line->SetEndPoint( pt1 );
96 circle->SetFillColor( aFillColor );
97 circle->SetFilled( aFilled );
109 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>(
SHAPE_T::ARC );
128 double radius = (
center - arc->GetStart() ).EuclideanNorm();
129 constexpr double rd_max_value = std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0;
131 if(
radius >= rd_max_value )
148 std::vector<VECTOR2I> convertedPoints;
149 convertedPoints.reserve( aVertices.size() );
151 for(
const VECTOR2D& precisePoint : aVertices )
152 convertedPoints.emplace_back(
MapCoordinate( precisePoint ) );
154 if( convertedPoints.empty() )
157 std::unique_ptr<SCH_SHAPE> polygon = std::make_unique<SCH_SHAPE>(
SHAPE_T::POLY );
165 polygon->SetFillColor( aFillColor );
166 polygon->SetPolyPoints( convertedPoints );
167 polygon->AddPoint( convertedPoints[0] );
171 addItem( std::move( polygon ) );
176 double aHeight,
double aWidth,
double aThickness,
180 std::unique_ptr<SCH_TEXT> textItem = std::make_unique<SCH_TEXT>();
181 textItem->SetTextColor( aColor );
182 textItem->SetTextThickness(
MapLineWidth( aThickness ) );
187 textItem->SetVertJustify( aVJustify );
188 textItem->SetHorizJustify( aHJustify );
189 textItem->SetText( aText );
191 addItem( std::move( textItem ) );
199 std::unique_ptr<SCH_SHAPE> spline = std::make_unique<SCH_SHAPE>(
SHAPE_T::BEZIER );
210 AddLine( aStart, aEnd, aStroke );
212 addItem( std::move( spline ) );
221 std::unique_ptr<SCH_SHAPE> ellipse = std::make_unique<SCH_SHAPE>(
SHAPE_T::ELLIPSE );
223 ellipse->SetFilled( aFilled );
224 ellipse->SetFillColor( aFillColor );
229 ellipse->SetEllipseRotation( aRotation );
231 addItem( std::move( ellipse ) );
245 arc->SetEllipseRotation( aRotation );
246 arc->SetEllipseStartAngle( aStartAngle );
247 arc->SetEllipseEndAngle( aEndAngle );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
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.
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, const EDA_ANGLE &aAngle, 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.
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.
VECTOR2I MapCoordinate(const VECTOR2D &aCoordinate)
Convert an imported coordinate to a board coordinate, according to the internal units,...
STROKE_PARAMS MapStrokeParams(const IMPORTED_STROKE &aStroke)
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.
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 AddPolygon(const std::vector< VECTOR2D > &aVertices, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor=COLOR4D::UNSPECIFIED) override
Create an object representing a polygon.
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.
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.
@ FILLED_SHAPE
Fill with object color.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
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.
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D