36 m_symbol( aSymbol ), m_unit( aUnit )
58 if( aLineWidth <= 0.0 )
62 return int( aLineWidth *
scale );
85 std::unique_ptr<LIB_SHAPE> line = std::make_unique<LIB_SHAPE>(
m_symbol, SHAPE_T::POLY );
89 line->AddPoint( pt0 );
90 line->AddPoint( pt1 );
100 std::unique_ptr<LIB_SHAPE> circle = std::make_unique<LIB_SHAPE>(
m_symbol, SHAPE_T::CIRCLE );
101 circle->SetUnit(
m_unit );
102 circle->SetFillColor( aFillColor );
103 circle->SetFilled( aFilled );
108 addItem( std::move( circle ) );
115 std::unique_ptr<LIB_SHAPE> arc = std::make_unique<LIB_SHAPE>(
m_symbol, SHAPE_T::ARC );
135 double radius = ( center - arc->GetStart() ).
EuclideanNorm();
136 constexpr double rd_max_value = std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0;
138 if( radius >= rd_max_value )
141 AddLine( aStart, end, aStroke );
155 std::vector<VECTOR2I> convertedPoints;
156 convertedPoints.reserve( aVertices.size() );
158 for(
const VECTOR2D& precisePoint : aVertices )
159 convertedPoints.emplace_back(
MapCoordinate( precisePoint ) );
161 if( convertedPoints.empty() )
164 std::unique_ptr<LIB_SHAPE> polygon = std::make_unique<LIB_SHAPE>(
m_symbol, SHAPE_T::POLY );
165 polygon->SetUnit(
m_unit );
169 polygon->SetFillMode( aFillColor != COLOR4D::UNSPECIFIED ? FILL_T::FILLED_WITH_COLOR
170 : FILL_T::FILLED_SHAPE );
173 polygon->SetFillColor( aFillColor );
174 polygon->SetPolyPoints( convertedPoints );
175 polygon->AddPoint( convertedPoints[0] );
179 addItem( std::move( polygon ) );
184 double aHeight,
double aWidth,
double aThickness,
188 std::unique_ptr<LIB_TEXT> textItem = std::make_unique<LIB_TEXT>(
m_symbol );
189 textItem->SetUnit(
m_unit );
190 textItem->SetTextColor( aColor );
191 textItem->SetTextThickness(
MapLineWidth( aThickness ) );
196 textItem->SetVertJustify( aVJustify );
197 textItem->SetHorizJustify( aHJustify );
198 textItem->SetText( aText );
200 addItem( std::move( textItem ) );
209 std::unique_ptr<LIB_SHAPE> spline = std::make_unique<LIB_SHAPE>(
m_symbol, SHAPE_T::BEZIER );
210 spline->SetUnit(
m_unit );
216 spline->RebuildBezierToSegmentsPointsList( aStroke.
GetWidth() );
220 if( spline->GetBezierPoints().size() <= 2 )
222 spline->SetShape( SHAPE_T::SEGMENT );
226#define MIN_SEG_LEN_ACCEPTABLE_NM 20
231 addItem( std::move( spline ) );
constexpr EDA_IU_SCALE schIUScale
VECTOR2I MapCoordinate(const VECTOR2D &aCoordinate)
Convert an imported coordinate to a board coordinate, according to the internal units,...
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 AddSpline(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, const IMPORTED_STROKE &aStroke) override
Create an object representing an arc.
STROKE_PARAMS MapStrokeParams(const IMPORTED_STROKE &aStroke)
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 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 AddCircle(const VECTOR2D &aCenter, double aRadius, const IMPORTED_STROKE &aStroke, bool aFilled, const COLOR4D &aFillColor=COLOR4D::UNSPECIFIED) override
Create an object representing a circle.
GRAPHICS_IMPORTER_LIB_SYMBOL(LIB_SYMBOL *aSymbol, int aUnit)
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.
Define a library symbol object.
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
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
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.
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.
double EuclideanNorm(const VECTOR2I &vector)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< double > VECTOR2D