KiCad PCB EDA Suite
GRAPHICS_IMPORTER_BUFFER Class Reference

#include <graphics_importer_buffer.h>

Inheritance diagram for GRAPHICS_IMPORTER_BUFFER:
GRAPHICS_IMPORTER

Public Member Functions

void AddLine (const VECTOR2D &aStart, const VECTOR2D &aEnd, double aWidth) override
 Create an object representing a line segment. More...
 
void AddCircle (const VECTOR2D &aCenter, double aRadius, double aWidth) override
 Create an object representing a circle. More...
 
void AddArc (const VECTOR2D &aCenter, const VECTOR2D &aStart, double 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, EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify) override
 Create an object representing a text. More...
 
void AddSpline (const VECTOR2D &aStart, const VECTOR2D &BezierControl1, const VECTOR2D &BezierControl2, const VECTOR2D &aEnd, double aWidth) override
 Create an object representing an arc. More...
 
void ImportTo (GRAPHICS_IMPORTER &aImporter)
 
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 std::string & 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)
 Sets the line width for the imported outlines (in mm). More...
 
double GetLineWidthMM () const
 Returns 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 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...
 

Static Public Attributes

static constexpr unsigned int DEFAULT_LINE_WIDTH_DFX = 1
 

Default line thickness (in mm)

More...
 

Protected Member Functions

void addItem (std::unique_ptr< EDA_ITEM > aItem)
 

Adds an item to the imported shapes list.

More...
 

Protected Attributes

std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
 

List of imported shapes

More...
 
double m_millimeterToIu
 

factor to convert millimeters to Internal Units

More...
 
VECTOR2D m_offsetCoordmm
 

Offset (in mm) for imported coordinates

More...
 

Detailed Description

Definition at line 176 of file graphics_importer_buffer.h.

Member Function Documentation

◆ AddArc()

void GRAPHICS_IMPORTER_BUFFER::AddArc ( const VECTOR2D aCenter,
const VECTOR2D aStart,
double  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 expressed in degrees.
aWidthis the segment thickness in mm. Use -1 for default line thickness

Implements GRAPHICS_IMPORTER.

Definition at line 47 of file graphics_importer_buffer.cpp.

49 {
50  m_shapes.push_back( make_shape< IMPORTED_ARC >( aCenter, aStart, aAngle, aWidth ) );
51 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

Referenced by DXF_IMPORT_PLUGIN::addArc(), and DXF_IMPORT_PLUGIN::insertArc().

◆ AddCircle()

void GRAPHICS_IMPORTER_BUFFER::AddCircle ( const VECTOR2D aCenter,
double  aRadius,
double  aWidth 
)
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 41 of file graphics_importer_buffer.cpp.

42 {
43  m_shapes.push_back( make_shape< IMPORTED_CIRCLE >( aCenter, aRadius, aWidth ) );
44 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

Referenced by DXF_IMPORT_PLUGIN::addCircle().

◆ addItem()

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

Adds an item to the imported shapes list.

Definition at line 254 of file graphics_importer.h.

255  {
256  m_items.emplace_back( std::move( aItem ) );
257  }
std::list< std::unique_ptr< EDA_ITEM > > m_items
List of imported items

References GRAPHICS_IMPORTER::m_items.

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

◆ AddLine()

void GRAPHICS_IMPORTER_BUFFER::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 35 of file graphics_importer_buffer.cpp.

36 {
37  m_shapes.push_back( make_shape< IMPORTED_LINE >( aStart, aEnd, aWidth ) );
38 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

Referenced by DXF_IMPORT_PLUGIN::addLine(), DXF_IMPORT_PLUGIN::insertLine(), and DXF_IMPORT_PLUGIN::insertSpline().

◆ AddPolygon()

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

Implements GRAPHICS_IMPORTER.

Definition at line 54 of file graphics_importer_buffer.cpp.

55 {
56  m_shapes.push_back( make_shape< IMPORTED_POLYGON >( aVertices, aWidth ) );
57 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

◆ AddSpline()

void GRAPHICS_IMPORTER_BUFFER::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 69 of file graphics_importer_buffer.cpp.

71 {
72  m_shapes.push_back( make_shape< IMPORTED_SPLINE >( aStart, aBezierControl1, aBezierControl2, aEnd, aWidth ) );
73 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

Referenced by DXF_IMPORT_PLUGIN::insertSpline().

◆ AddText()

void GRAPHICS_IMPORTER_BUFFER::AddText ( const VECTOR2D aOrigin,
const wxString &  aText,
double  aHeight,
double  aWidth,
double  aThickness,
double  aOrientation,
EDA_TEXT_HJUSTIFY_T  aHJustify,
EDA_TEXT_VJUSTIFY_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 60 of file graphics_importer_buffer.cpp.

63 {
64  m_shapes.push_back( make_shape< IMPORTED_TEXT >( aOrigin, aText, aHeight, aWidth,
65  aThickness, aOrientation, aHJustify, aVJustify ) );
66 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

Referenced by DXF_IMPORT_PLUGIN::addMText(), and DXF_IMPORT_PLUGIN::addText().

◆ GetImageHeightMM()

double GRAPHICS_IMPORTER::GetImageHeightMM ( ) const
inlineinherited

Get original image Height.

Returns
Height of the loaded image in mm.

Definition at line 106 of file graphics_importer.h.

107  {
108  return m_originalHeight;
109  }
double m_originalHeight
Total image Height;

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 96 of file graphics_importer.h.

97  {
98  return m_originalWidth;
99  }
double m_originalWidth
Total image width

References GRAPHICS_IMPORTER::m_originalWidth.

◆ GetImportOffsetMM()

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

Definition at line 139 of file graphics_importer.h.

140  {
141  return m_offsetCoordmm;
142  }
VECTOR2D m_offsetCoordmm
Offset (in mm) for imported coordinates

References GRAPHICS_IMPORTER::m_offsetCoordmm.

Referenced by GRAPHICS_IMPORTER_PCBNEW::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 181 of file graphics_importer.h.

182  {
183  return m_items;
184  }
std::list< std::unique_ptr< EDA_ITEM > > m_items
List of imported items

References GRAPHICS_IMPORTER::m_items.

◆ GetLineWidthMM()

double GRAPHICS_IMPORTER::GetLineWidthMM ( ) const
inlineinherited

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

Definition at line 122 of file graphics_importer.h.

123  {
124  return m_lineWidth;
125  }
double m_lineWidth
Default line thickness for the imported graphics

References GRAPHICS_IMPORTER::m_lineWidth.

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

◆ GetMessages()

const std::string& 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 86 of file graphics_importer.h.

87  {
88  return m_plugin->GetMessages();
89  }
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > m_plugin
Plugin used to load a file

References GRAPHICS_IMPORTER::m_plugin.

◆ GetMillimeterToIuFactor()

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

Definition at line 165 of file graphics_importer.h.

166  {
167  return m_millimeterToIu;
168  }
double m_millimeterToIu
factor to convert millimeters to Internal Units

References GRAPHICS_IMPORTER::m_millimeterToIu.

◆ GetScale()

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

Definition at line 130 of file graphics_importer.h.

131  {
132  return m_scale;
133  }
double m_scale
Scale factor applied to the imported graphics.

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 53 of file graphics_importer.cpp.

54 {
55  if( !m_plugin )
56  {
57  wxASSERT_MSG( false, "Plugin has to be set before import." );
58  return false;
59  }
60 
61  SetScale( aScale );
62 
63  m_plugin->SetImporter( this );
64 
65  return m_plugin->Import();
66 }
void SetScale(double aScale)
Set the scale factor affecting the imported shapes.
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > m_plugin
Plugin used to load a file

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 173 of file graphics_importer.h.

174  {
175  return m_scale * m_millimeterToIu;
176  }
double m_millimeterToIu
factor to convert millimeters to Internal Units
double m_scale
Scale factor applied to the imported graphics.

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

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

◆ ImportTo()

void GRAPHICS_IMPORTER_BUFFER::ImportTo ( GRAPHICS_IMPORTER aImporter)

Definition at line 76 of file graphics_importer_buffer.cpp.

77 {
78  for( auto& shape : m_shapes )
79  shape->ImportTo( aImporter );
80 }
std::list< std::unique_ptr< IMPORTED_SHAPE > > m_shapes
List of imported shapes

Referenced by DXF_IMPORT_PLUGIN::Import().

◆ Load()

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

Load file and get its basic data.

Definition at line 38 of file graphics_importer.cpp.

39 {
40  m_items.clear();
41 
42  if( !m_plugin )
43  {
44  wxASSERT_MSG( false, "Plugin has to be set before load." );
45  return false;
46  }
47 
48  m_plugin->SetImporter( this );
49 
50  return m_plugin->Load( aFileName );
51 }
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > m_plugin
Plugin used to load a file
std::list< std::unique_ptr< EDA_ITEM > > m_items
List of imported items

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

◆ SetImportOffsetMM()

void GRAPHICS_IMPORTER::SetImportOffsetMM ( const VECTOR2D aOffset)
inlineinherited

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

The offset is always in mm

Definition at line 148 of file graphics_importer.h.

149  {
150  m_offsetCoordmm = aOffset;
151  }
VECTOR2D m_offsetCoordmm
Offset (in mm) for imported coordinates

References GRAPHICS_IMPORTER::m_offsetCoordmm.

◆ SetLineWidthMM()

void GRAPHICS_IMPORTER::SetLineWidthMM ( double  aWidth)
inlineinherited

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

Definition at line 114 of file graphics_importer.h.

115  {
116  m_lineWidth = aWidth;
117  }
double m_lineWidth
Default line thickness for the imported graphics

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 56 of file graphics_importer.h.

57  {
58  m_plugin = std::move( aPlugin );
59 
60  if( m_plugin )
61  m_plugin->SetImporter( this );
62  }
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > m_plugin
Plugin used to load a file

References GRAPHICS_IMPORTER::m_plugin.

◆ SetScale()

void GRAPHICS_IMPORTER::SetScale ( double  aScale)
inlineinherited

Set the scale factor affecting the imported shapes.

it allows conversion between imported shapes units and mm

Definition at line 157 of file graphics_importer.h.

158  {
159  m_scale = aScale;
160  }
double m_scale
Scale factor applied to the imported graphics.

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
staticinherited

Default line thickness (in mm)

Definition at line 187 of file graphics_importer.h.

Referenced by GRAPHICS_IMPORTER::GRAPHICS_IMPORTER().

◆ m_millimeterToIu

double GRAPHICS_IMPORTER::m_millimeterToIu
protectedinherited

◆ m_offsetCoordmm

VECTOR2D GRAPHICS_IMPORTER::m_offsetCoordmm
protectedinherited

Offset (in mm) for imported coordinates

Definition at line 287 of file graphics_importer.h.

Referenced by GRAPHICS_IMPORTER::GetImportOffsetMM(), and GRAPHICS_IMPORTER::SetImportOffsetMM().

◆ m_shapes

std::list< std::unique_ptr< IMPORTED_SHAPE > > GRAPHICS_IMPORTER_BUFFER::m_shapes
protected

List of imported shapes

Definition at line 198 of file graphics_importer_buffer.h.


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