KiCad PCB EDA Suite
Loading...
Searching...
No Matches
GRAPHICS_IMPORTER_SCH Class Reference

#include <graphics_importer_sch.h>

Inheritance diagram for GRAPHICS_IMPORTER_SCH:
GRAPHICS_IMPORTER

Public Types

enum  POLY_FILL_RULE { PF_NONZERO = 0 , PF_EVEN_ODD }
 

Public Member Functions

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

Static Public Attributes

static constexpr unsigned int DEFAULT_LINE_WIDTH_DFX = 1
 

Protected Member Functions

void addItem (std::unique_ptr< EDA_ITEM > aItem)
 < Add an item to the imported shapes list.
 

Protected Attributes

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

Private Attributes

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

Detailed Description

Definition at line 35 of file graphics_importer_sch.h.

Member Enumeration Documentation

◆ POLY_FILL_RULE

Enumerator
PF_NONZERO 
PF_EVEN_ODD 

Definition at line 78 of file graphics_importer.h.

Constructor & Destructor Documentation

◆ GRAPHICS_IMPORTER_SCH()

GRAPHICS_IMPORTER_SCH::GRAPHICS_IMPORTER_SCH ( )

Member Function Documentation

◆ AddArc()

void GRAPHICS_IMPORTER_SCH::AddArc ( const VECTOR2D aCenter,
const VECTOR2D aStart,
const EDA_ANGLE aAngle,
const IMPORTED_STROKE aStroke 
)
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.
aStrokeis the shape stroke parameters.

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

Implements GRAPHICS_IMPORTER.

Definition at line 110 of file graphics_importer_sch.cpp.

References GRAPHICS_IMPORTER::addItem(), AddLine(), CalcArcCenter(), MapCoordinate(), MapStrokeParams(), and RotatePoint().

◆ AddCircle()

void GRAPHICS_IMPORTER_SCH::AddCircle ( const VECTOR2D aCenter,
double  aRadius,
const IMPORTED_STROKE aStroke,
bool  aFilled,
const COLOR4D aFillColor = COLOR4D::UNSPECIFIED 
)
overridevirtual

Create an object representing a circle.

Parameters
aCenteris the circle center point expressed in mm.
aRadiusis the circle radius expressed in mm.
aStrokeis the shape stroke parameters.

Implements GRAPHICS_IMPORTER.

Definition at line 95 of file graphics_importer_sch.cpp.

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

◆ addItem()

◆ AddLine()

void GRAPHICS_IMPORTER_SCH::AddLine ( const VECTOR2D aOrigin,
const VECTOR2D aEnd,
const IMPORTED_STROKE aStroke 
)
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.
aStrokeis the shape stroke parameters.

Implements GRAPHICS_IMPORTER.

Definition at line 75 of file graphics_importer_sch.cpp.

References GRAPHICS_IMPORTER::addItem(), MapCoordinate(), and MapStrokeParams().

Referenced by AddArc().

◆ AddPolygon()

void GRAPHICS_IMPORTER_SCH::AddPolygon ( const std::vector< VECTOR2D > &  aVertices,
const IMPORTED_STROKE aStroke,
bool  aFilled,
const COLOR4D aFillColor = COLOR4D::UNSPECIFIED 
)
overridevirtual

Create an object representing a polygon.

Parameters
aVerticesis the array of vertices.
aWidthis the stroke width.
aStrokeis the shape stroke parameters.
aFillColoris the fill color.

Implements GRAPHICS_IMPORTER.

Definition at line 148 of file graphics_importer_sch.cpp.

References GRAPHICS_IMPORTER::addItem(), MapCoordinate(), and MapStrokeParams().

◆ AddSpline()

void GRAPHICS_IMPORTER_SCH::AddSpline ( const VECTOR2D aStart,
const VECTOR2D aBezierControl1,
const VECTOR2D aBezierControl2,
const VECTOR2D aEnd,
const IMPORTED_STROKE aStroke 
)
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.
aStrokeis the shape stroke parameters.

Implements GRAPHICS_IMPORTER.

Definition at line 199 of file graphics_importer_sch.cpp.

References GRAPHICS_IMPORTER::addItem(), VECTOR2< T >::EuclideanNorm(), IMPORTED_STROKE::GetWidth(), MapCoordinate(), MapStrokeParams(), and MIN_SEG_LEN_ACCEPTABLE_NM.

◆ AddText()

void GRAPHICS_IMPORTER_SCH::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 
)
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
aColoris the shape color

Implements GRAPHICS_IMPORTER.

Definition at line 179 of file graphics_importer_sch.cpp.

References GRAPHICS_IMPORTER::addItem(), DEGREES_T, 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 230 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_items.

◆ GetImageHeightMM()

double GRAPHICS_IMPORTER::GetImageHeightMM ( ) const
inlineinherited

Get original image Height.

Returns
Height of the loaded image in mm.

Definition at line 148 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 138 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 180 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_offsetCoordmm.

Referenced by GRAPHICS_IMPORTER_BUFFER::ImportTo(), GRAPHICS_IMPORTER_LIB_SYMBOL::MapCoordinate(), MapCoordinate(), and GRAPHICS_IMPORTER_PCBNEW::MapCoordinate().

◆ GetItems()

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

◆ GetLineWidthMM()

double GRAPHICS_IMPORTER::GetLineWidthMM ( ) const
inlineinherited

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

Definition at line 164 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_lineWidth.

Referenced by GRAPHICS_IMPORTER_LIB_SYMBOL::MapLineWidth(), MapLineWidth(), GRAPHICS_IMPORTER_PCBNEW::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 123 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_plugin.

◆ GetMillimeterToIuFactor()

double GRAPHICS_IMPORTER::GetMillimeterToIuFactor ( )
inlineinherited

◆ GetScale()

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

Definition at line 172 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_scale.

Referenced by GRAPHICS_IMPORTER_BUFFER::ImportTo(), GRAPHICS_IMPORTER_LIB_SYMBOL::MapCoordinate(), MapCoordinate(), and GRAPHICS_IMPORTER_PCBNEW::MapCoordinate().

◆ Import()

bool GRAPHICS_IMPORTER::Import ( const VECTOR2D aScale = VECTOR2D( 1.0, 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 VECTOR2D( 1.0, 1.0 ) to import graphics with their actual size.

Definition at line 66 of file graphics_importer.cpp.

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

◆ ImportScalingFactor()

VECTOR2D GRAPHICS_IMPORTER::ImportScalingFactor ( ) const
inlineinherited

◆ Load()

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

◆ MapCoordinate()

VECTOR2I GRAPHICS_IMPORTER_SCH::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 42 of file graphics_importer_sch.cpp.

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

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

◆ MapLineWidth()

int GRAPHICS_IMPORTER_SCH::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 53 of file graphics_importer_sch.cpp.

References std::abs(), GRAPHICS_IMPORTER::GetLineWidthMM(), GRAPHICS_IMPORTER::ImportScalingFactor(), scale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by AddText(), and MapStrokeParams().

◆ MapStrokeParams()

STROKE_PARAMS GRAPHICS_IMPORTER_SCH::MapStrokeParams ( const IMPORTED_STROKE aStroke)

◆ NewShape()

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

Definition at line 95 of file graphics_importer.cpp.

References GRAPHICS_IMPORTER::m_shapeFillRules.

Referenced by SVG_IMPORT_PLUGIN::Import().

◆ ReportMsg()

void GRAPHICS_IMPORTER::ReportMsg ( const wxString &  aMessage)
inlineinherited

Definition at line 128 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_plugin.

Referenced by GRAPHICS_IMPORTER_BUFFER::ImportTo().

◆ SetImportOffsetMM()

void GRAPHICS_IMPORTER::SetImportOffsetMM ( const VECTOR2D aOffset)
inlineinherited

◆ SetLineWidthMM()

void GRAPHICS_IMPORTER::SetLineWidthMM ( double  aWidth)
inlineinherited

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

Definition at line 156 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 93 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_plugin.

◆ SetScale()

void GRAPHICS_IMPORTER::SetScale ( const VECTOR2D aScale)
inlineinherited

Set the scale factor affecting the imported shapes.

This allows conversion between imported shapes units and millimeters.

Definition at line 198 of file graphics_importer.h.

References GRAPHICS_IMPORTER::m_scale.

Referenced by ConvertSVGToLibShapes(), GRAPHICS_IMPORTER::Import(), SCH_EASYEDAPRO_PARSER::ParseSchematic(), SCH_EASYEDA_PARSER::ParseSchematic(), SCH_EASYEDAPRO_PARSER::ParseSymbol(), and SCH_EASYEDA_PARSER::ParseSymbolShapes().

Member Data Documentation

◆ DEFAULT_LINE_WIDTH_DFX

constexpr unsigned int GRAPHICS_IMPORTER::DEFAULT_LINE_WIDTH_DFX = 1
staticconstexprinherited

Definition at line 236 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 331 of file graphics_importer.h.

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

◆ m_lineWidth

double GRAPHICS_IMPORTER::m_lineWidth
privateinherited

◆ m_millimeterToIu

◆ m_offsetCoordmm

VECTOR2D GRAPHICS_IMPORTER::m_offsetCoordmm
protectedinherited

◆ m_originalHeight

double GRAPHICS_IMPORTER::m_originalHeight
privateinherited

◆ m_originalWidth

double GRAPHICS_IMPORTER::m_originalWidth
privateinherited

◆ m_plugin

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

◆ m_scale

VECTOR2D 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 347 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: