57 double scale = ( factor.
x + factor.
y ) * 0.5;
59 if( aLineWidth <= 0.0 )
63 return int( aLineWidth *
scale );
68 double aWidth,
const COLOR4D& aColor )
71 line->SetShape( SHAPE_T::SEGMENT );
78 if( line->GetStart() == line->GetEnd() )
86 bool aFilled,
const COLOR4D& aColor )
89 circle->SetShape( SHAPE_T::CIRCLE );
90 circle->SetFilled( aFilled );
105 arc->SetShape( SHAPE_T::ARC );
125 double radius = ( center - arc->GetStart() ).
EuclideanNorm();
126 double rd_max_value = std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0;
128 if( radius >= rd_max_value )
131 AddLine( aStart, end, aWidth, aColor );
144 std::vector<VECTOR2I> convertedPoints;
145 convertedPoints.reserve( aVertices.size() );
147 for(
const VECTOR2D& precisePoint : aVertices )
148 convertedPoints.emplace_back(
MapCoordinate( precisePoint ) );
151 polygon->SetShape( SHAPE_T::POLY );
154 polygon->SetPolyPoints( convertedPoints );
158 polygon->Rotate( { 0, 0 }, parentFP->GetOrientation() );
159 polygon->Move( parentFP->GetPosition() );
163 addItem( std::move( polygon ) );
168 double aHeight,
double aWidth,
double aThickness,
172 std::unique_ptr<PCB_TEXT> textItem =
createText();
174 textItem->SetTextThickness(
MapLineWidth( aThickness ) );
179 textItem->SetVertJustify( aVJustify );
180 textItem->SetHorizJustify( aHJustify );
181 textItem->SetText( aText );
183 addItem( std::move( textItem ) );
189 double aWidth,
const COLOR4D& aColor )
192 spline->SetShape( SHAPE_T::BEZIER );
199 spline->RebuildBezierToSegmentsPointsList( aWidth );
203 if( spline->GetBezierPoints().size() <= 2 )
205 spline->SetShape( SHAPE_T::SEGMENT );
209 #define MIN_SEG_LEN_ACCEPTABLE_NM 20
214 addItem( std::move( spline ) );
220 return std::make_unique<PCB_SHAPE>(
m_board );
226 return std::make_unique<PCB_TEXT>(
m_board );
constexpr EDA_IU_SCALE pcbIUScale
FOOTPRINT * GetParentFootprint() const
std::unique_ptr< PCB_TEXT > createText() override
Target layer for the imported shapes.
std::unique_ptr< PCB_SHAPE > createDrawing() override
< Create an object representing a graphical shape.
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) override
Create an object representing a text.
void AddLine(const VECTOR2D &aOrigin, const VECTOR2D &aEnd, double aWidth, const COLOR4D &aColor) override
Create an object representing a line segment.
void AddSpline(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, double aWidth, const COLOR4D &aColor) override
Create an object representing an arc.
void AddCircle(const VECTOR2D &aOrigin, double aRadius, double aWidth, bool aFilled, const COLOR4D &aColor) override
Create an object representing a circle.
virtual std::unique_ptr< PCB_SHAPE > createDrawing()=0
< Create an object representing a graphical shape.
virtual std::unique_ptr< PCB_TEXT > createText()=0
Target layer for the imported shapes.
int MapLineWidth(double aLineWidth)
If aLineWidth < 0, the default line thickness value is returned.
PCB_LAYER_ID GetLayer() const
Return the target layer for the imported shapes.
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, const EDA_ANGLE &aAngle, double aWidth, const COLOR4D &aColor) override
Create an object representing an arc.
void AddPolygon(const std::vector< VECTOR2D > &aVertices, double aWidth, const COLOR4D &aColor) override
GRAPHICS_IMPORTER_PCBNEW()
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 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)
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