KiCad PCB EDA Suite
Loading...
Searching...
No Matches
GRAPHICS_IMPORTER_PCBNEW Class Referenceabstract

#include <graphics_importer_pcbnew.h>

Inheritance diagram for GRAPHICS_IMPORTER_PCBNEW:
GRAPHICS_IMPORTER GRAPHICS_IMPORTER_BOARD GRAPHICS_IMPORTER_FOOTPRINT

Public Types

enum  POLY_FILL_RULE { PF_NONZERO = 0 , PF_EVEN_ODD }
 

Public Member Functions

 GRAPHICS_IMPORTER_PCBNEW ()
 
void SetLayer (PCB_LAYER_ID aLayer)
 Set the target layer for the imported shapes. More...
 
PCB_LAYER_ID GetLayer () const
 Return the target layer for the imported shapes. More...
 
void AddLine (const VECTOR2D &aOrigin, const VECTOR2D &aEnd, double aWidth) override
 Create an object representing a line segment. More...
 
void AddCircle (const VECTOR2D &aOrigin, double aRadius, double aWidth, bool aFilled) override
 Create an object representing a circle. More...
 
void AddArc (const VECTOR2D &aCenter, const VECTOR2D &aStart, const EDA_ANGLE &aAngle, double aWidth) override
 Create an object representing an arc. More...
 
void AddPolygon (const std::vector< VECTOR2D > &aVertices, double aWidth) override
 
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) override
 Create an object representing a text. More...
 
void AddSpline (const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, double aWidth) override
 Create an object representing an arc. More...
 
VECTOR2I MapCoordinate (const VECTOR2D &aCoordinate)
 Convert an imported coordinate to a board coordinate, according to the internal units, user scale and offset. More...
 
int MapLineWidth (double aLineWidth)
 If aLineWidth < 0, the default line thickness value is returned. More...
 
void SetPlugin (std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > aPlugin)
 Set the import plugin used to obtain shapes from a file. More...
 
bool Load (const wxString &aFileName)
 Load file and get its basic data. More...
 
bool Import (double aScale=1.0)
 Import shapes from loaded file. More...
 
const wxString & GetMessages () const
 Collect warning and error messages after loading/importing. More...
 
double GetImageWidthMM () const
 Get original image Width. More...
 
double GetImageHeightMM () const
 Get original image Height. More...
 
void SetLineWidthMM (double aWidth)
 Set the line width for the imported outlines (in mm). More...
 
double GetLineWidthMM () const
 Return the line width used for importing the outlines (in mm). More...
 
double GetScale () const
 
const VECTOR2DGetImportOffsetMM () const
 
void SetImportOffsetMM (const VECTOR2D &aOffset)
 Set the offset in millimeters to add to coordinates when importing graphic items. More...
 
void SetScale (double aScale)
 Set the scale factor affecting the imported shapes. More...
 
double GetMillimeterToIuFactor ()
 
double ImportScalingFactor () const
 
std::list< std::unique_ptr< EDA_ITEM > > & GetItems ()
 Return the list of objects representing the imported shapes. More...
 
void ClearItems ()
 Empties out the imported shapes list. More...
 
virtual void NewShape (POLY_FILL_RULE aFillRule=PF_NONZERO)
 

Static Public Attributes

static constexpr unsigned int DEFAULT_LINE_WIDTH_DFX = 1
 

Protected Member Functions

virtual std::unique_ptr< PCB_SHAPEcreateDrawing ()=0
 < Create an object representing a graphical shape. More...
 
virtual std::unique_ptr< PCB_TEXTcreateText ()=0
 Target layer for the imported shapes. More...
 
void addItem (std::unique_ptr< EDA_ITEM > aItem)
 < Add an item to the imported shapes list. More...
 

Protected Attributes

PCB_LAYER_ID m_layer
 
double m_millimeterToIu
 Offset (in mm) for imported coordinates. More...
 
VECTOR2D m_offsetCoordmm
 
std::vector< POLY_FILL_RULEm_shapeFillRules
 

Private Attributes

std::list< std::unique_ptr< EDA_ITEM > > m_items
 < List of imported items More...
 
std::unique_ptr< GRAPHICS_IMPORT_PLUGINm_plugin
 Total image width. More...
 
double m_originalWidth
 Total image Height;. More...
 
double m_originalHeight
 
double m_scale
 Scale factor applied to the imported graphics. More...
 
double m_lineWidth
 

Detailed Description

Definition at line 39 of file graphics_importer_pcbnew.h.

Member Enumeration Documentation

◆ POLY_FILL_RULE

Enumerator
PF_NONZERO 
PF_EVEN_ODD 

Definition at line 48 of file graphics_importer.h.

Constructor & Destructor Documentation

◆ GRAPHICS_IMPORTER_PCBNEW()

GRAPHICS_IMPORTER_PCBNEW::GRAPHICS_IMPORTER_PCBNEW ( )

Member Function Documentation

◆ AddArc()

void GRAPHICS_IMPORTER_PCBNEW::AddArc ( const VECTOR2D aCenter,
const VECTOR2D aStart,
const EDA_ANGLE aAngle,
double  aWidth 
)
overridevirtual

Create an object representing an arc.

Parameters
aCenteris the arc center point expressed in mm.
aStartis the arc arm end point expressed in mm. Its length is the arc radius.
aAngleis the arc angle.
aWidthis the segment thickness in mm. Use -1 for default line thickness

We need to perform the rotation/conversion here while still using floating point values to avoid rounding errors when operating in integer space in pcbnew

Implements GRAPHICS_IMPORTER.

Definition at line 93 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::addItem(), createDrawing(), GetLayer(), MapCoordinate(), MapLineWidth(), and RotatePoint().

◆ AddCircle()

void GRAPHICS_IMPORTER_PCBNEW::AddCircle ( const VECTOR2D aCenter,
double  aRadius,
double  aWidth,
bool  aFilled 
)
overridevirtual

Create an object representing a circle.

Parameters
aCenteris the circle center point expressed in mm.
aRadiusis the circle radius expressed in mm.
aWidthis the segment thickness in mm. Use -1 for default line thickness

Implements GRAPHICS_IMPORTER.

Definition at line 78 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::addItem(), createDrawing(), GetLayer(), MapCoordinate(), MapLineWidth(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ addItem()

void GRAPHICS_IMPORTER::addItem ( std::unique_ptr< EDA_ITEM aItem)
inlineprotectedinherited

< Add an item to the imported shapes list.

factor to convert millimeters to Internal Units

Definition at line 269 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_items.

Referenced by AddArc(), AddCircle(), AddLine(), AddPolygon(), AddSpline(), and AddText().

◆ AddLine()

void GRAPHICS_IMPORTER_PCBNEW::AddLine ( const VECTOR2D aOrigin,
const VECTOR2D aEnd,
double  aWidth 
)
overridevirtual

Create an object representing a line segment.

Parameters
aOriginis the segment origin point expressed in mm.
aEndis the segment end point expressed in mm.
aWidthis the segment thickness in mm. Use -1 for default line thickness

Implements GRAPHICS_IMPORTER.

Definition at line 60 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::addItem(), createDrawing(), GetLayer(), MapCoordinate(), and MapLineWidth().

◆ AddPolygon()

void GRAPHICS_IMPORTER_PCBNEW::AddPolygon ( const std::vector< VECTOR2D > &  aVertices,
double  aWidth 
)
overridevirtual

◆ AddSpline()

void GRAPHICS_IMPORTER_PCBNEW::AddSpline ( const VECTOR2D aStart,
const VECTOR2D aBezierControl1,
const VECTOR2D aBezierControl2,
const VECTOR2D aEnd,
double  aWidth 
)
overridevirtual

Create an object representing an arc.

Parameters
aStartis the curve start point expressed in mm.
aBezierControl1is the first Bezier control point expressed in mm.
aBezierControl2is the second Bezier control point expressed in mm.
aEndis the curve end point expressed in mm.
aWidthis the segment thickness in mm. Use -1 for default line thickness

Implements GRAPHICS_IMPORTER.

Definition at line 163 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::addItem(), createDrawing(), VECTOR2< T >::EuclideanNorm(), GetLayer(), MapCoordinate(), MapLineWidth(), and MIN_SEG_LEN_ACCEPTABLE_NM.

◆ AddText()

void GRAPHICS_IMPORTER_PCBNEW::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 
)
overridevirtual

Create an object representing a text.

Parameters
aOriginis the text position.
aTextis the displayed text.
aHeightis the text height expressed in mm.
aWidthis the text width expressed in mm.
aOrientationis the text orientation angle expressed in degrees.
aHJustifyis the text horizontal justification.
aVJustifyis the text vertical justification.
aWidthis the segment thickness in mm. Use -1 for default line thickness

Implements GRAPHICS_IMPORTER.

Definition at line 143 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::addItem(), createText(), DEGREES_T, GetLayer(), GRAPHICS_IMPORTER::ImportScalingFactor(), MapCoordinate(), and MapLineWidth().

◆ ClearItems()

void GRAPHICS_IMPORTER::ClearItems ( )
inlineinherited

Empties out the imported shapes list.

Default line thickness (in mm)

Definition at line 195 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_items.

◆ createDrawing()

virtual std::unique_ptr< PCB_SHAPE > GRAPHICS_IMPORTER_PCBNEW::createDrawing ( )
protectedpure virtual

< Create an object representing a graphical shape.

Create an object representing a text.

Implemented in GRAPHICS_IMPORTER_BOARD, and GRAPHICS_IMPORTER_FOOTPRINT.

Referenced by AddArc(), AddCircle(), AddLine(), AddPolygon(), and AddSpline().

◆ createText()

virtual std::unique_ptr< PCB_TEXT > GRAPHICS_IMPORTER_PCBNEW::createText ( )
protectedpure virtual

Target layer for the imported shapes.

Implemented in GRAPHICS_IMPORTER_BOARD, and GRAPHICS_IMPORTER_FOOTPRINT.

Referenced by AddText().

◆ GetImageHeightMM()

double GRAPHICS_IMPORTER::GetImageHeightMM ( ) const
inlineinherited

Get original image Height.

Returns
Height of the loaded image in mm.

Definition at line 113 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_originalHeight.

◆ GetImageWidthMM()

double GRAPHICS_IMPORTER::GetImageWidthMM ( ) const
inlineinherited

Get original image Width.

Returns
Width of the loaded image in mm.

Definition at line 103 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_originalWidth.

◆ GetImportOffsetMM()

const VECTOR2D & GRAPHICS_IMPORTER::GetImportOffsetMM ( ) const
inlineinherited
Returns
the offset in millimeters to add to coordinates when importing graphic items.

Definition at line 145 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_offsetCoordmm.

Referenced by MapCoordinate().

◆ GetItems()

std::list< std::unique_ptr< EDA_ITEM > > & GRAPHICS_IMPORTER::GetItems ( )
inlineinherited

Return the list of objects representing the imported shapes.

Definition at line 187 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_items.

◆ GetLayer()

PCB_LAYER_ID GRAPHICS_IMPORTER_PCBNEW::GetLayer ( ) const
inline

Return the target layer for the imported shapes.

Definition at line 57 of file graphics_importer_pcbnew.h.

References m_layer.

Referenced by AddArc(), AddCircle(), AddLine(), AddPolygon(), AddSpline(), and AddText().

◆ GetLineWidthMM()

double GRAPHICS_IMPORTER::GetLineWidthMM ( ) const
inlineinherited

Return the line width used for importing the outlines (in mm).

Definition at line 129 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_lineWidth.

Referenced by MapLineWidth(), and DXF_IMPORT_PLUGIN::SetImporter().

◆ GetMessages()

const wxString & GRAPHICS_IMPORTER::GetMessages ( ) const
inlineinherited

Collect warning and error messages after loading/importing.

Returns
the list of messages in one string. Each message ends by '
'

Definition at line 93 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_plugin.

◆ GetMillimeterToIuFactor()

double GRAPHICS_IMPORTER::GetMillimeterToIuFactor ( )
inlineinherited
Returns
the conversion factor from mm to internal unit

Definition at line 171 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_millimeterToIu.

◆ GetScale()

double GRAPHICS_IMPORTER::GetScale ( ) const
inlineinherited
Returns
the scale factor affecting the imported shapes.

Definition at line 137 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_scale.

◆ Import()

bool GRAPHICS_IMPORTER::Import ( double  aScale = 1.0)
inherited

Import shapes from loaded file.

It is important to have the file loaded before importing.

Parameters
aScaleallow import graphic items with a non 1:1 import ratio aScale = 1.0 to import graphics with their actual size.

Definition at line 54 of file graphics_importer.cpp.

References GRAPHICS_IMPORTER::m_plugin, and GRAPHICS_IMPORTER::SetScale().

◆ ImportScalingFactor()

double GRAPHICS_IMPORTER::ImportScalingFactor ( ) const
inlineinherited
Returns
the overall scale factor to convert the imported shapes dimension to mm.

Definition at line 179 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_millimeterToIu, and GRAPHICS_IMPORTER::m_scale.

Referenced by AddText(), MapCoordinate(), and MapLineWidth().

◆ Load()

bool GRAPHICS_IMPORTER::Load ( const wxString &  aFileName)
inherited

Load file and get its basic data.

Definition at line 39 of file graphics_importer.cpp.

References GRAPHICS_IMPORTER::m_items, and GRAPHICS_IMPORTER::m_plugin.

◆ MapCoordinate()

VECTOR2I GRAPHICS_IMPORTER_PCBNEW::MapCoordinate ( const VECTOR2D aCoordinate)

Convert an imported coordinate to a board coordinate, according to the internal units, user scale and offset.

Parameters
aCoordinateis the imported coordinate in mm.

Definition at line 43 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::GetImportOffsetMM(), GRAPHICS_IMPORTER::ImportScalingFactor(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by AddArc(), AddCircle(), AddLine(), AddPolygon(), AddSpline(), and AddText().

◆ MapLineWidth()

int GRAPHICS_IMPORTER_PCBNEW::MapLineWidth ( double  aLineWidth)

If aLineWidth < 0, the default line thickness value is returned.

Parameters
aLineWidthis the line thickness in mm to convert.
Returns
a line thickness in a board Iu value, according to the internal units.

Definition at line 50 of file graphics_importer_pcbnew.cpp.

References GRAPHICS_IMPORTER::GetLineWidthMM(), and GRAPHICS_IMPORTER::ImportScalingFactor().

Referenced by AddArc(), AddCircle(), AddLine(), AddPolygon(), AddSpline(), and AddText().

◆ NewShape()

void GRAPHICS_IMPORTER::NewShape ( POLY_FILL_RULE  aFillRule = PF_NONZERO)
virtualinherited

Definition at line 83 of file graphics_importer.cpp.

References GRAPHICS_IMPORTER::m_shapeFillRules.

Referenced by SVG_IMPORT_PLUGIN::Import().

◆ SetImportOffsetMM()

void GRAPHICS_IMPORTER::SetImportOffsetMM ( const VECTOR2D aOffset)
inlineinherited

Set the offset in millimeters to add to coordinates when importing graphic items.

Definition at line 153 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_offsetCoordmm.

◆ SetLayer()

void GRAPHICS_IMPORTER_PCBNEW::SetLayer ( PCB_LAYER_ID  aLayer)
inline

Set the target layer for the imported shapes.

Parameters
aLayeris the layer to be used by the imported shapes.

Definition at line 49 of file graphics_importer_pcbnew.h.

References m_layer.

◆ SetLineWidthMM()

void GRAPHICS_IMPORTER::SetLineWidthMM ( double  aWidth)
inlineinherited

Set the line width for the imported outlines (in mm).

Definition at line 121 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_lineWidth.

◆ SetPlugin()

void GRAPHICS_IMPORTER::SetPlugin ( std::unique_ptr< GRAPHICS_IMPORT_PLUGIN aPlugin)
inlineinherited

Set the import plugin used to obtain shapes from a file.

Definition at line 63 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_plugin.

◆ SetScale()

void GRAPHICS_IMPORTER::SetScale ( double  aScale)
inlineinherited

Set the scale factor affecting the imported shapes.

This allows conversion between imported shapes units and millimeters.

Definition at line 163 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_scale.

Referenced by GRAPHICS_IMPORTER::Import().

Member Data Documentation

◆ DEFAULT_LINE_WIDTH_DFX

constexpr unsigned int GRAPHICS_IMPORTER::DEFAULT_LINE_WIDTH_DFX = 1
staticconstexprinherited

Definition at line 201 of file graphics_importer.h.

Referenced by GRAPHICS_IMPORTER::GRAPHICS_IMPORTER().

◆ m_items

std::list<std::unique_ptr<EDA_ITEM> > GRAPHICS_IMPORTER::m_items
privateinherited

< List of imported items

Plugin used to load a file

Definition at line 284 of file graphics_importer.h.

Referenced by GRAPHICS_IMPORTER::addItem(), GRAPHICS_IMPORTER::ClearItems(), GRAPHICS_IMPORTER::GetItems(), and GRAPHICS_IMPORTER::Load().

◆ m_layer

PCB_LAYER_ID GRAPHICS_IMPORTER_PCBNEW::m_layer
protected

Definition at line 103 of file graphics_importer_pcbnew.h.

Referenced by GetLayer(), GRAPHICS_IMPORTER_PCBNEW(), and SetLayer().

◆ m_lineWidth

double GRAPHICS_IMPORTER::m_lineWidth
privateinherited

◆ m_millimeterToIu

double GRAPHICS_IMPORTER::m_millimeterToIu
protectedinherited

◆ m_offsetCoordmm

VECTOR2D GRAPHICS_IMPORTER::m_offsetCoordmm
protectedinherited

◆ m_originalHeight

double GRAPHICS_IMPORTER::m_originalHeight
privateinherited

◆ m_originalWidth

double GRAPHICS_IMPORTER::m_originalWidth
privateinherited

Total image Height;.

Definition at line 290 of file graphics_importer.h.

Referenced by GRAPHICS_IMPORTER::GetImageWidthMM(), and GRAPHICS_IMPORTER::GRAPHICS_IMPORTER().

◆ m_plugin

std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> GRAPHICS_IMPORTER::m_plugin
privateinherited

◆ m_scale

double GRAPHICS_IMPORTER::m_scale
privateinherited

Scale factor applied to the imported graphics.

1.0 does not change the size of imported items scale < 1.0 reduce the size of imported items Default line thickness for the imported graphics

Definition at line 300 of file graphics_importer.h.

Referenced by GRAPHICS_IMPORTER::GetScale(), GRAPHICS_IMPORTER::GRAPHICS_IMPORTER(), GRAPHICS_IMPORTER::ImportScalingFactor(), and GRAPHICS_IMPORTER::SetScale().

◆ m_shapeFillRules

std::vector<POLY_FILL_RULE> GRAPHICS_IMPORTER::m_shapeFillRules
protectedinherited

The documentation for this class was generated from the following files: