KiCad PCB EDA Suite
GRAPHICS_IMPORTER_PCBNEW Class Referenceabstract

#include <graphics_importer_pcbnew.h>

Inheritance diagram for GRAPHICS_IMPORTER_PCBNEW:
GRAPHICS_IMPORTER GRAPHICS_IMPORTER_BOARD GRAPHICS_IMPORTER_MODULE

Public Member Functions

 GRAPHICS_IMPORTER_PCBNEW ()
 
void SetLayer (PCB_LAYER_ID aLayer)
 Sets the target layer for the imported shapes. More...
 
PCB_LAYER_ID GetLayer () const
 Returns 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) 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 &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, double aWidth) override
 Create an object representing an arc. More...
 
wxPoint MapCoordinate (const VECTOR2D &aCoordinate)
 convert a imported coordinate to a board coordinate, according to the internal units, the user scale and offset More...
 
int MapLineWidth (double aLineWidth)
 
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

virtual std::unique_ptr< DRAWSEGMENTcreateDrawing ()=0
 

Create an object representing a graphical shape.

More...
 
virtual std::pair< std::unique_ptr< BOARD_ITEM >, EDA_TEXT * > createText ()=0
 

Create an object representing a text.

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

Adds an item to the imported shapes list.

More...
 

Protected Attributes

PCB_LAYER_ID m_layer
 

Target layer for the 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 39 of file graphics_importer_pcbnew.h.

Constructor & Destructor Documentation

◆ GRAPHICS_IMPORTER_PCBNEW()

GRAPHICS_IMPORTER_PCBNEW::GRAPHICS_IMPORTER_PCBNEW ( )

Definition at line 37 of file graphics_importer_pcbnew.cpp.

38 {
40  m_millimeterToIu = Millimeter2iu( 1.0 );
41 }
double m_millimeterToIu
factor to convert millimeters to Internal Units
PCB_LAYER_ID m_layer
Target layer for the imported shapes.

References Dwgs_User, m_layer, and GRAPHICS_IMPORTER::m_millimeterToIu.

Member Function Documentation

◆ AddArc()

void GRAPHICS_IMPORTER_PCBNEW::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 93 of file graphics_importer_pcbnew.cpp.

95 {
96  unique_ptr<DRAWSEGMENT> arc( createDrawing() );
97  arc->SetShape( S_ARC );
98  arc->SetLayer( GetLayer() );
99  arc->SetWidth( MapLineWidth( aWidth ) );
100  arc->SetCenter( MapCoordinate( aCenter) );
101  arc->SetArcStart( MapCoordinate( aStart ) );
102  arc->SetAngle( aAngle * 10.0 ); // Pcbnew uses the decidegree
103 
104  if( arc->Type() == PCB_MODULE_EDGE_T )
105  static_cast<EDGE_MODULE*>( arc.get() )->SetLocalCoord();
106 
107  addItem( std::move( arc ) );
108 }
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int MapLineWidth(double aLineWidth)
virtual std::unique_ptr< DRAWSEGMENT > createDrawing()=0
Create an object representing a graphical shape.
Arcs (with rounded ends)
void addItem(std::unique_ptr< EDA_ITEM > aItem)
Adds an item to the imported shapes list.

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

◆ AddCircle()

void GRAPHICS_IMPORTER_PCBNEW::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 77 of file graphics_importer_pcbnew.cpp.

78 {
79  unique_ptr<DRAWSEGMENT> circle( createDrawing() );
80  circle->SetShape( S_CIRCLE );
81  circle->SetLayer( GetLayer() );
82  circle->SetWidth( MapLineWidth( aWidth ) );
83  circle->SetCenter( MapCoordinate( aCenter ) );
84  circle->SetArcStart( MapCoordinate( VECTOR2D( aCenter.x + aRadius, aCenter.y ) ) );
85 
86  if( circle->Type() == PCB_MODULE_EDGE_T )
87  static_cast<EDGE_MODULE*>( circle.get() )->SetLocalCoord();
88 
89  addItem( std::move( circle ) );
90 }
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int MapLineWidth(double aLineWidth)
virtual std::unique_ptr< DRAWSEGMENT > createDrawing()=0
Create an object representing a graphical shape.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void addItem(std::unique_ptr< EDA_ITEM > aItem)
Adds an item to the imported shapes list.

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

◆ 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 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 61 of file graphics_importer_pcbnew.cpp.

62 {
63  unique_ptr<DRAWSEGMENT> line( createDrawing() );
64  line->SetShape( S_SEGMENT );
65  line->SetLayer( GetLayer() );
66  line->SetWidth( MapLineWidth( aWidth ) );
67  line->SetStart( MapCoordinate( aOrigin ) );
68  line->SetEnd( MapCoordinate( aEnd ) );
69 
70  if( line->Type() == PCB_MODULE_EDGE_T )
71  static_cast<EDGE_MODULE*>( line.get() )->SetLocalCoord();
72 
73  addItem( std::move( line ) );
74 }
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
usual segment : line with rounded ends
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int MapLineWidth(double aLineWidth)
virtual std::unique_ptr< DRAWSEGMENT > createDrawing()=0
Create an object representing a graphical shape.
void addItem(std::unique_ptr< EDA_ITEM > aItem)
Adds an item to the imported shapes list.

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

◆ AddPolygon()

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

Implements GRAPHICS_IMPORTER.

Definition at line 111 of file graphics_importer_pcbnew.cpp.

112 {
113  std::vector< wxPoint > convertedPoints;
114  convertedPoints.reserve( convertedPoints.size() );
115 
116  for( const VECTOR2D& precisePoint : aVertices )
117  convertedPoints.emplace_back( MapCoordinate( precisePoint ) );
118 
119  unique_ptr<DRAWSEGMENT> polygon( createDrawing() );
120  polygon->SetShape( S_POLYGON );
121  polygon->SetLayer( GetLayer() );
122  polygon->SetPolyPoints( convertedPoints );
123 
124  if( polygon->Type() == PCB_MODULE_EDGE_T )
125  static_cast<EDGE_MODULE*>( polygon.get() )->SetLocalCoord();
126 
127  polygon->SetWidth( MapLineWidth( aWidth ) );
128  addItem( std::move( polygon ) );
129 }
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
polygon (not yet used for tracks, but could be in microwave apps)
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int MapLineWidth(double aLineWidth)
virtual std::unique_ptr< DRAWSEGMENT > createDrawing()=0
Create an object representing a graphical shape.
void addItem(std::unique_ptr< EDA_ITEM > aItem)
Adds an item to the imported shapes list.

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

◆ 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 156 of file graphics_importer_pcbnew.cpp.

158 {
159  unique_ptr<DRAWSEGMENT> spline( createDrawing() );
160  spline->SetShape( S_CURVE );
161  spline->SetLayer( GetLayer() );
162  spline->SetWidth( MapLineWidth( aWidth ) );
163  spline->SetStart( MapCoordinate( aStart ) );
164  spline->SetBezControl1( MapCoordinate( BezierControl1 ) );
165  spline->SetBezControl2( MapCoordinate( BezierControl2 ) );
166  spline->SetEnd( MapCoordinate( aEnd ) );
167  spline->RebuildBezierToSegmentsPointsList( aWidth );
168 
169  if( spline->Type() == PCB_MODULE_EDGE_T )
170  static_cast<EDGE_MODULE*>( spline.get() )->SetLocalCoord();
171 
172  addItem( std::move( spline ) );
173 }
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int MapLineWidth(double aLineWidth)
virtual std::unique_ptr< DRAWSEGMENT > createDrawing()=0
Create an object representing a graphical shape.
Bezier Curve.
void addItem(std::unique_ptr< EDA_ITEM > aItem)
Adds an item to the imported shapes list.

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

◆ AddText()

void GRAPHICS_IMPORTER_PCBNEW::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 132 of file graphics_importer_pcbnew.cpp.

135 {
136  unique_ptr<BOARD_ITEM> boardItem;
137  EDA_TEXT* textItem;
138  tie( boardItem, textItem ) = createText();
139  boardItem->SetLayer( GetLayer() );
140  textItem->SetThickness( MapLineWidth( aThickness ) );
141  textItem->SetTextPos( MapCoordinate( aOrigin ) );
142  textItem->SetTextAngle( aOrientation * 10.0 ); // Pcbnew uses the decidegree
143  textItem->SetTextWidth( aWidth * ImportScalingFactor() );
144  textItem->SetTextHeight( aHeight * ImportScalingFactor() );
145  textItem->SetVertJustify( aVJustify );
146  textItem->SetHorizJustify( aHJustify );
147  textItem->SetText( aText );
148 
149  if( boardItem->Type() == PCB_MODULE_TEXT_T )
150  static_cast<TEXTE_MODULE*>( boardItem.get() )->SetLocalCoord();
151 
152  addItem( std::move( boardItem ) );
153 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:173
double ImportScalingFactor() const
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:240
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels,...
Definition: eda_text.h:128
int MapLineWidth(double aLineWidth)
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:64
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:211
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
void SetTextWidth(int aWidth)
Definition: eda_text.h:234
void addItem(std::unique_ptr< EDA_ITEM > aItem)
Adds an item to the imported shapes list.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:210
void SetTextHeight(int aHeight)
Definition: eda_text.h:237
virtual std::pair< std::unique_ptr< BOARD_ITEM >, EDA_TEXT * > createText()=0
Create an object representing a text.
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:165

References GRAPHICS_IMPORTER::addItem(), createText(), GetLayer(), GRAPHICS_IMPORTER::ImportScalingFactor(), MapCoordinate(), MapLineWidth(), PCB_MODULE_TEXT_T, EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextHeight(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextWidth(), EDA_TEXT::SetThickness(), and EDA_TEXT::SetVertJustify().

◆ createDrawing()

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

Create an object representing a graphical shape.

Implemented in GRAPHICS_IMPORTER_MODULE, and GRAPHICS_IMPORTER_BOARD.

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

◆ createText()

virtual std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> GRAPHICS_IMPORTER_PCBNEW::createText ( )
protectedpure virtual

Create an object representing a text.

Both pointers point to different parts of the same object, the EDA_TEXT pointer is simply for convenience.

Implemented in GRAPHICS_IMPORTER_MODULE, and GRAPHICS_IMPORTER_BOARD.

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 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 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.

◆ GetLayer()

PCB_LAYER_ID GRAPHICS_IMPORTER_PCBNEW::GetLayer ( ) const
inline

Returns the target layer for the imported shapes.

Definition at line 56 of file graphics_importer_pcbnew.h.

57  {
58  return m_layer;
59  }
PCB_LAYER_ID m_layer
Target layer for the imported shapes.

References m_layer.

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

◆ 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 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 AddText(), MapCoordinate(), and MapLineWidth().

◆ 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.

◆ MapCoordinate()

wxPoint GRAPHICS_IMPORTER_PCBNEW::MapCoordinate ( const VECTOR2D aCoordinate)

convert a imported coordinate to a board coordinate, according to the internal units, the user scale and offset

Parameters
aCoordinateis the imported coordinate in mm

Definition at line 44 of file graphics_importer_pcbnew.cpp.

45 {
46  VECTOR2D coord = ( aCoordinate + GetImportOffsetMM() ) * ImportScalingFactor();
47  return wxPoint( (int) coord.x, (int) coord.y );
48 }
double ImportScalingFactor() const
const VECTOR2D & GetImportOffsetMM() const

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

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

◆ MapLineWidth()

int GRAPHICS_IMPORTER_PCBNEW::MapLineWidth ( double  aLineWidth)
Returns
a line thickness in a board Iu value, according to the internal units. if aLineWidth < 0, the default ine thickness value is returned
Parameters
aLineWidthis the line thickness in mm to convert

Definition at line 51 of file graphics_importer_pcbnew.cpp.

52 {
53  if( aLineWidth <= 0.0 )
54  return int( GetLineWidthMM() * ImportScalingFactor() );
55 
56  // aLineWidth is in mm:
57  return int( aLineWidth * ImportScalingFactor() );
58 }
double ImportScalingFactor() const
double GetLineWidthMM() const
Returns the line width used for importing the outlines (in mm).

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

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

◆ 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.

◆ SetLayer()

void GRAPHICS_IMPORTER_PCBNEW::SetLayer ( PCB_LAYER_ID  aLayer)
inline

Sets the target layer for the imported shapes.

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

Definition at line 48 of file graphics_importer_pcbnew.h.

49  {
50  m_layer = aLayer;
51  }
PCB_LAYER_ID m_layer
Target layer for the imported shapes.

References m_layer.

◆ 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_layer

PCB_LAYER_ID GRAPHICS_IMPORTER_PCBNEW::m_layer
protected

Target layer for the imported shapes.

Definition at line 99 of file graphics_importer_pcbnew.h.

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

◆ 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().


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