25#ifndef DXF2BRD_ITEMS_H
26#define DXF2BRD_ITEMS_H
30#include "wx/translation.h"
32#include <dl_creationadapter.h>
116#define DXF_IMPORT_LINEWEIGHT_BY_LAYER -1
117#define DXF_IMPORT_LINEWEIGHT_BY_BLOCK -2
118#define DXF_IMPORT_LINEWEIGHT_BY_LW_DEFAULT -3
167 DXF_IMPORT_STYLE(
const wxString& aName,
double aTextHeight,
double aWidthFactor,
bool aBold,
210#define ON_UNSUPPORTED( error_msg ) reportMessage( wxString::Format( _( "%s is not supported." ), \
221 return "AutoCAD DXF";
226 static std::vector<std::string> exts = {
"dxf" };
230 bool Load(
const wxString& aFileName )
override;
324 void ReportMsg(
const wxString& aMessage )
override;
329 double mapX(
double aDxfCoordX );
330 double mapY(
double aDxfCoordY );
331 double mapDim(
double aDxfValue );
376 double aBulge,
double aWidth );
388 virtual void setVariableString(
const std::string& key,
const std::string& value,
394 virtual void setVariableInt(
const std::string& key,
int value,
int code )
override;
401 virtual void addLayer(
const DL_LayerData& aData )
override;
402 virtual void addLine(
const DL_LineData& aData )
override;
403 virtual void addLinetype(
const DL_LinetypeData& data )
override;
412 virtual void addBlock(
const DL_BlockData& )
override;
414 virtual void addTextStyle(
const DL_StyleData& aData )
override;
415 virtual void addPoint(
const DL_PointData& aData )
override;
417 virtual void addCircle(
const DL_CircleData& aData )
override;
418 virtual void addArc(
const DL_ArcData& aData )
override;
419 void addEllipse(
const DL_EllipseData& aData )
override;
421 virtual void addText(
const DL_TextData& aData )
override;
422 virtual void addPolyline(
const DL_PolylineData& aData )
override;
425 virtual void addInsert(
const DL_InsertData& aData )
override;
430 virtual void addVertex(
const DL_VertexData& aData )
override;
433 virtual void addMText(
const DL_MTextData& aData )
override;
440 virtual void addSpline(
const DL_SplineData& aData )
override;
445 virtual void addControlPoint(
const DL_ControlPointData& aData )
override;
450 virtual void addFitPoint(
const DL_FitPointData& aData )
override;
455 virtual void addKnot(
const DL_KnotData& aData )
override;
458 virtual void addXLine(
const DL_XLineData& )
override
460 ReportMsg(
_(
"DXF construction lines not currently supported." ) );
462 virtual void addRay(
const DL_RayData& )
override
464 ReportMsg(
_(
"DXF construction lines not currently supported." ) );
469 ReportMsg(
_(
"DXF arc-aligned text not currently supported." ) );
472 virtual void addDimAlign(
const DL_DimensionData&,
const DL_DimAlignedData& )
override
474 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
476 virtual void addDimLinear(
const DL_DimensionData&,
const DL_DimLinearData& )
override
478 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
480 virtual void addDimRadial(
const DL_DimensionData&,
const DL_DimRadialData& )
override
482 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
484 virtual void addDimDiametric(
const DL_DimensionData&,
const DL_DimDiametricData& )
override
486 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
488 virtual void addDimAngular(
const DL_DimensionData&,
const DL_DimAngular2LData& )
override
490 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
492 virtual void addDimAngular3P(
const DL_DimensionData&,
const DL_DimAngular3PData& )
override
494 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
496 virtual void addDimOrdinate(
const DL_DimensionData&,
const DL_DimOrdinateData& )
override
498 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
502 ReportMsg(
_(
"DXF dimensions not currently supported." ) );
506 virtual void addHatch(
const DL_HatchData& )
override
508 ReportMsg(
_(
"DXF hatches not currently supported." ) );
513 virtual void addTrace(
const DL_TraceData& )
override
515 ReportMsg(
_(
"DXF traces not currently supported." ) );
520 ReportMsg(
_(
"DXF 3dfaces not currently supported." ) );
523 virtual void addSolid(
const DL_SolidData& )
override
525 ReportMsg(
_(
"DXF solids not currently supported." ) );
528 virtual void addImage(
const DL_ImageData& )
override
530 ReportMsg(
_(
"DXF images not currently supported." ) );
532 virtual void linkImage(
const DL_ImageDefData& )
override {}
554 static wxString
toDxfString(
const wxString& aStr );
589 std::vector<std::unique_ptr<DXF_IMPORT_LAYER>>
m_layers;
590 std::vector<std::unique_ptr<DXF_IMPORT_BLOCK>>
m_blocks;
591 std::vector<std::unique_ptr<DXF_IMPORT_STYLE>>
m_styles;
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
A helper class to parse a DXF entity (polyline and spline)
double m_SplineTangentEndY
unsigned int m_SplineDegree
std::vector< VECTOR2D > m_SplineFitPointList
unsigned int m_SplineFitCount
double m_SplineTangentEndX
std::vector< SPLINE_CTRL_POINT > m_SplineControlPointList
double m_SplineTangentStartY
unsigned int m_SplineKnotsCount
VECTOR2D m_LastCoordinate
unsigned int m_SplineControlCount
double m_SplineTangentStartX
std::vector< double > m_SplineKnotsList
A helper class to hold layer settings temporarily during import.
GRAPHICS_IMPORTER_BUFFER m_buffer
DXF_IMPORT_BLOCK(const wxString &aName, double aX, double aY)
A helper class to hold layer settings temporarily during import.
DXF_IMPORT_LAYER(const wxString &aName, int aLineWeight)
DXF_IMPORT_UNITS m_currentUnit
virtual void addXDataApp(const std::string &) override
virtual void addPolyline(const DL_PolylineData &aData) override
double mapY(double aDxfCoordY)
virtual void addImage(const DL_ImageData &) override
std::vector< std::unique_ptr< DXF_IMPORT_LAYER > > m_layers
void addEllipse(const DL_EllipseData &aData) override
static wxString toNativeString(const wxString &aData)
Convert a DXF encoded string into a native Unicode string.
virtual void addDimAngular(const DL_DimensionData &, const DL_DimAngular2LData &) override
virtual void addDimAngular3P(const DL_DimensionData &, const DL_DimAngular3PData &) override
virtual void addAttribute(const DL_AttributeData &) override
virtual void setVariableInt(const std::string &key, int value, int code) override
Called for every int variable in the DXF file (e.g.
bool LoadFromMemory(const wxMemoryBuffer &aMemBuffer) override
Set memory buffer with content for import.
void insertSpline(double aWidth)
virtual void linkImage(const DL_ImageDefData &) override
virtual void addLine(const DL_LineData &aData) override
virtual void addLeader(const DL_LeaderData &) override
VECTOR3D ocsToWcs(const MATRIX3x3D &arbitraryAxis, VECTOR3D point)
Converts a given object coordinate point to world coordinate using the given arbitrary axis vectors.
void insertLine(const VECTOR2D &aSegStart, const VECTOR2D &aSegEnd, double aWidth)
virtual void addXDataReal(int, double) override
DXF_IMPORT_BLOCK * getImportBlock(const std::string &aBlockName)
Return the import layer block.
double getCurrentUnitScale()
virtual void addBlock(const DL_BlockData &) override
Called for each BLOCK in the DXF file.
virtual void addDimAlign(const DL_DimensionData &, const DL_DimAlignedData &) override
virtual void addRay(const DL_RayData &) override
virtual void addLayer(const DL_LayerData &aData) override
virtual void addCircle(const DL_CircleData &aData) override
virtual void addMText(const DL_MTextData &aData) override
DXF_IMPORT_LAYER * getImportLayer(const std::string &aLayerName)
Return the import layer data.
static wxString toDxfString(const wxString &aStr)
Convert a native Unicode string into a DXF encoded string.
virtual void addArcAlignedText(const DL_ArcAlignedTextData &) override
virtual void setVariableDouble(const std::string &key, double value, int code) override
Called for every double variable in the DXF file (e.g.
virtual void addTrace(const DL_TraceData &) override
virtual void addSolid(const DL_SolidData &) override
DXF_IMPORT_STYLE * getImportStyle(const std::string &aStyleName)
Return the import style.
virtual void addInsert(const DL_InsertData &aData) override
std::string m_mtextContent
BOX2D GetImageBBox() const override
Return image bounding box from original imported file.
const wxString GetName() const override
Return the plugin name.
virtual void addLeaderVertex(const DL_LeaderVertexData &) override
virtual void addXRecordString(int, const std::string &) override
MATRIX3x3D getArbitraryAxis(DL_Extrusion *aData)
double GetImageWidth() const override
Return image width from original imported file.
virtual void addDimLinear(const DL_DimensionData &, const DL_DimLinearData &) override
double GetImageHeight() const override
Return image height from original imported file.
virtual void addXDataString(int, const std::string &) override
virtual void add3dFace(const DL_3dFaceData &) override
virtual void addHatch(const DL_HatchData &) override
void updateImageLimits(const VECTOR2D &aPoint)
virtual void addTextStyle(const DL_StyleData &aData) override
virtual void addXDataInt(int, int) override
virtual void addVertex(const DL_VertexData &aData) override
Called for every polyline vertex.
VECTOR3D wcsToOcs(const MATRIX3x3D &arbitraryAxis, VECTOR3D point)
Converts a given world coordinate point to object coordinate using the given arbitrary axis vectors.
virtual void addSpline(const DL_SplineData &aData) override
Called for every spline.
virtual void addText(const DL_TextData &aData) override
virtual void endBlock() override
virtual void setVariableString(const std::string &key, const std::string &value, int code) override
Called for every string variable in the DXF file (e.g.
virtual void addKnot(const DL_KnotData &aData) override
Called for every spline knot value.
virtual void addXRecordInt(int, int) override
bool ImportDxfFile(const wxString &aFile)
Implementation of the method used for communicate with this filter.
virtual void addArc(const DL_ArcData &aData) override
virtual void addXRecordReal(int, double) override
void SetLineWidthMM(double aWidth) override
void SetDefaultLineWidthMM(double aWidth)
Set the default line width when importing dxf items like lines to Pcbnew.
virtual void addFitPoint(const DL_FitPointData &aData) override
Called for every spline fit point.
virtual void addPoint(const DL_PointData &aData) override
void SetBrdLayer(int aBrdLayer)
Set the layer number to import dxf items.
double mapDim(double aDxfValue)
virtual void addDimOrdinate(const DL_DimensionData &, const DL_DimOrdinateData &) override
virtual void addDimDiametric(const DL_DimensionData &, const DL_DimDiametricData &) override
void ReportMsg(const wxString &aMessage) override
virtual void addXRecord(const std::string &) override
virtual void addHatchEdge(const DL_HatchEdgeData &) override
int m_importCoordinatePrecision
double mapX(double aDxfCoordX)
double lineWeightToWidth(int lw, DXF_IMPORT_LAYER *aLayer)
void insertArc(const VECTOR2D &aSegStart, const VECTOR2D &aSegEnd, double aBulge, double aWidth)
std::vector< std::unique_ptr< DXF_IMPORT_BLOCK > > m_blocks
virtual void addHatchLoop(const DL_HatchLoopData &) override
bool Import() override
Actually imports the file.
virtual void addMTextChunk(const std::string &text) override
int m_importAnglePrecision
virtual void endEntity() override
virtual void addControlPoint(const DL_ControlPointData &aData) override
Called for every spline control point.
double m_defaultThickness
GRAPHICS_IMPORTER_BUFFER m_internalImporter
virtual void addXRecordBool(int, bool) override
std::vector< std::unique_ptr< DXF_IMPORT_STYLE > > m_styles
bool Load(const wxString &aFileName) override
Load file for import.
const wxString & GetMessages() const override
virtual void addDimRadial(const DL_DimensionData &, const DL_DimRadialData &) override
void SetUnit(DXF_IMPORT_UNITS aUnit)
Set the default units when importing DXFs.
virtual void addXLine(const DL_XLineData &) override
DXF_IMPORT_BLOCK * m_currentBlock
DXF2BRD_ENTITY_DATA m_curr_entity
void ImportAsFootprintGraphic(bool aImportAsFootprintGraphic)
Allow the import DXF items converted to board graphic items or footprint graphic items.
const std::vector< std::string > GetFileExtensions() const override
Return a vector of the file extensions handled by this plugin.
virtual void SetImporter(GRAPHICS_IMPORTER *aImporter) override
Set the receiver of the imported shapes.
void SetOffset(double aOffsetX, double aOffsetY)
Set the coordinate offset between the imported dxf items and Pcbnew.
virtual void addLinetype(const DL_LinetypeData &data) override
A helper class to hold style settings temporarily during import.
DXF_IMPORT_STYLE(const wxString &aName, double aTextHeight, double aWidthFactor, bool aBold, bool aItalic)
Interface that creates objects representing shapes for a given data model.
Interface for vector graphics import plugins.
DXF_IMPORT_UNITS
DXF Units enum with values as specified in DXF 2012 Specification.
A helper class to store a spline control point (in X,Y plane only)
SPLINE_CTRL_POINT(double a_x, double a_y, double a_weight)
Definition of file extensions used in Kicad.