QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RDxfImporter Class Reference

Importer for the DXF format, based on the dxflib library. More...

#include <RDxfImporter.h>

Inheritance diagram for RDxfImporter:
RFileImporter DL_CreationAdapter RImporter DL_CreationInterface

List of all members.

Public Member Functions

virtual bool importFile (const QString &fileName, const QString &nameFilter)
 Must be implemented by file importers to import the given file into the document.
virtual void processCodeValuePair (unsigned int groupCode, char *groupValue)
 RDxfImporter (RDocument &document, RMessageHandler *messageHandler=NULL, RProgressHandler *progressHandler=NULL)
 Copyright (c) 2011-2013 by Andrew Mustun.
virtual ~RDxfImporter ()
- Public Member Functions inherited from RFileImporter
 RFileImporter ()
 Copyright (c) 2011-2013 by Andrew Mustun.
 RFileImporter (RDocument &document, RMessageHandler *messageHandler=NULL, RProgressHandler *progressHandler=NULL)
virtual ~RFileImporter ()
- Public Member Functions inherited from RImporter
virtual void endImport ()
 Ends the import.
virtual RBlock::Id getCurrentBlockId ()
RDocumentgetDocument ()
virtual void importObject (RObject *object)
 Provided for script importers as importObjectP will loose the object ID.
virtual void importObjectP (QSharedPointer< RObject > object)
 Imports an entity into the document.
 RImporter ()
 Copyright (c) 2011-2013 by Andrew Mustun.
 RImporter (RDocument &document, RMessageHandler *messageHandler=NULL, RProgressHandler *progressHandler=NULL)
virtual void setCurrentBlockId (RBlock::Id id)
void setDocument (RDocument *d)
virtual void startImport ()
 Starts the import.
virtual ~RImporter ()
- Public Member Functions inherited from DL_CreationAdapter
virtual void add3dFace (const DL_3dFaceData &)
 Called for every 3dface start.
virtual void addComment (const std::string &)
 Called for every comment in the DXF file (code 999).
 DL_CreationAdapter ()
virtual void endSequence ()
 Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done)
virtual void processCodeValuePair (unsigned int, const std::string &)
 Called for every code / value tuple of the DXF file.
virtual ~DL_CreationAdapter ()
- Public Member Functions inherited from DL_CreationInterface
 DL_CreationInterface ()
DL_Attributes getAttributes ()
DL_ExtrusiongetExtrusion ()
void setAttributes (const DL_Attributes &attrib)
 Sets the current attributes for entities.
void setExtrusion (double dx, double dy, double dz, double elevation)
 Sets the current attributes for entities.
virtual ~DL_CreationInterface ()

Private Member Functions

virtual void addArc (const DL_ArcData &data)
 Called for every arc.
virtual void addAttribute (const DL_AttributeData &data)
 Implementation of the method which handles block attributes (ATTRIB).
virtual void addBlock (const DL_BlockData &data)
 Called for every block.
virtual void addCircle (const DL_CircleData &data)
 Called for every circle.
virtual void addControlPoint (const DL_ControlPointData &data)
 Called for every spline control point.
virtual void addDictionary (const DL_DictionaryData &data)
 Called for dictionary objects.
virtual void addDictionaryEntry (const DL_DictionaryEntryData &data)
 Called for dictionary entries.
virtual void addDimAlign (const DL_DimensionData &data, const DL_DimAlignedData &edata)
 Called for every aligned dimension entity.
virtual void addDimAngular (const DL_DimensionData &data, const DL_DimAngularData &edata)
 Called for every angular dimension (2 lines version) entity.
virtual void addDimAngular3P (const DL_DimensionData &data, const DL_DimAngular3PData &edata)
 Called for every angular dimension (3 points version) entity.
virtual void addDimDiametric (const DL_DimensionData &data, const DL_DimDiametricData &edata)
 Called for every diametric dimension entity.
virtual void addDimLinear (const DL_DimensionData &data, const DL_DimLinearData &edata)
 Called for every linear or rotated dimension entity.
virtual void addDimOrdinate (const DL_DimensionData &data, const DL_DimOrdinateData &edata)
 Called for every ordinate dimension entity.
virtual void addDimRadial (const DL_DimensionData &data, const DL_DimRadialData &edata)
 Called for every radial dimension entity.
virtual void addEllipse (const DL_EllipseData &data)
 Called for every ellipse.
virtual void addFitPoint (const DL_FitPointData &data)
 Called for every spline fit point.
virtual void addHatch (const DL_HatchData &data)
 Called for every hatch entity.
virtual void addHatchEdge (const DL_HatchEdgeData &data)
 Called for every hatch edge entity.
virtual void addHatchLoop (const DL_HatchLoopData &data)
 Called for every hatch loop.
virtual void addImage (const DL_ImageData &data)
 Called for every image entity.
virtual void addInsert (const DL_InsertData &data)
 Called for every insert.
virtual void addKnot (const DL_KnotData &data)
 Called for every spline knot value.
virtual void addLayer (const DL_LayerData &data)
 Called for every layer.
virtual void addLeader (const DL_LeaderData &data)
 Called for every leader start.
virtual void addLeaderVertex (const DL_LeaderVertexData &data)
 Called for every leader vertex.
virtual void addLine (const DL_LineData &data)
 Called for every line.
virtual void addLinetype (const DL_LinetypeData &data)
 Called for every linetype.
virtual void addLinetypeDash (double length)
 Called for every dash in linetype pattern.
virtual void addMText (const DL_MTextData &data)
 Called for every Multi Text entity.
virtual void addMTextChunk (const std::string &text)
 Called for additional text chunks for MTEXT entities.
virtual void addPoint (const DL_PointData &data)
 Called for every point.
virtual void addPolyline (const DL_PolylineData &data)
 Called for every polyline start.
virtual void addRay (const DL_RayData &data)
 Called for every ray.
virtual void addSolid (const DL_SolidData &data)
 Called for every solid start.
virtual void addSpline (const DL_SplineData &data)
 Called for every spline.
virtual void addText (const DL_TextData &data)
 Implementation of the method which handles texts (TEXT).
virtual void addTextStyle (const DL_StyleData &data)
 Called for every text style.
virtual void addTrace (const DL_TraceData &data)
 Called for every trace start.
virtual void addVertex (const DL_VertexData &data)
 Called for every polyline vertex.
virtual void addXDataApp (const std::string &appId)
 Called for every beginning of an XData section of the given application.
virtual void addXDataInt (int code, int value)
 Called for XData tuples.
virtual void addXDataReal (int code, double value)
 Called for XData tuples.
virtual void addXDataString (int code, const std::string &value)
 Called for XData tuples.
virtual void addXLine (const DL_XLineData &data)
 Called for every xline.
virtual void addXRecord (const std::string &handle)
 Called for every XRecord with the given handle.
virtual void addXRecordBool (int code, bool value)
 Called for XRecords of type bool.
virtual void addXRecordInt (int code, int value)
 Called for XRecords of type int.
virtual void addXRecordReal (int code, double value)
 Called for XRecords of type double.
virtual void addXRecordString (int code, const std::string &value)
 Called for XRecords of type string.
virtual RDimensionData convDimensionData (const DL_DimensionData &data)
virtual void endBlock ()
 Called to end the current block.
virtual void endEntity ()
 Called after an entity has been completed.
virtual void endSection ()
 Called when a section (entity, table entry, etc.) is finished.
RTextBasedData getTextBasedData (const DL_TextData &data)
int getXDataInt (const QString &appId, int code, int pos=0)
QString getXDataString (const QString &appId, int code, int pos=0)
void importEntity (QSharedPointer< REntity > entity)
virtual void linkImage (const DL_ImageDefData &data)
 Called for every image definition.
virtual void setVariableDouble (const std::string &key, double value, int code)
 Called for every double variable in the DXF file (e.g.
virtual void setVariableInt (const std::string &key, int value, int code)
 Called for every int variable in the DXF file (e.g.
virtual void setVariableString (const std::string &key, const std::string &value, int code)
 Called for every string variable in the DXF file (e.g.
virtual void setVariableVector (const std::string &key, double v1, double v2, double v3, int code)
 Called for every vector variable in the DXF file (e.g.

Static Private Member Functions

static QString decode (const QString &str)
static QString getEncoding (const QString &str)
 Tries to convert the given DXF encoding string to an encoding recognized by Qt.

Private Attributes

RDxfServices dxfServices
QString fileName
RHatchData hatch
QMultiMap< int, RObject::Idimages
bool inDict
RLeaderData leader
QStringList lockedLayers
QByteArray mtext
QList< double > pattern
RPolyline polyline
QMap< QString, QString > qcadDict
QString qcadDictHandle
RSpline spline
QMap< QString, RDxfTextStyletextStyles
QString variableKey
QMap< QString, QList< QPair
< int, QVariant > > > 
xData
QString xDataAppId

Detailed Description

Importer for the DXF format, based on the dxflib library.


Constructor & Destructor Documentation

RDxfImporter::RDxfImporter ( RDocument document,
RMessageHandler messageHandler = NULL,
RProgressHandler progressHandler = NULL 
)

Copyright (c) 2011-2013 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

RDxfImporter::~RDxfImporter ( )
virtual

Member Function Documentation

void RDxfImporter::addArc ( const DL_ArcData data)
privatevirtual

Called for every arc.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addAttribute ( const DL_AttributeData data)
privatevirtual

Implementation of the method which handles block attributes (ATTRIB).

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addBlock ( const DL_BlockData data)
privatevirtual

Called for every block.

Note: all entities added after this command go into this block until endBlock() is called.

See also:
endBlock()

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addCircle ( const DL_CircleData data)
privatevirtual

Called for every circle.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addControlPoint ( const DL_ControlPointData data)
privatevirtual

Called for every spline control point.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDictionary ( const DL_DictionaryData data)
privatevirtual

Called for dictionary objects.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDictionaryEntry ( const DL_DictionaryEntryData data)
privatevirtual

Called for dictionary entries.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimAlign ( const DL_DimensionData data,
const DL_DimAlignedData edata 
)
privatevirtual

Called for every aligned dimension entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimAngular ( const DL_DimensionData data,
const DL_DimAngularData edata 
)
privatevirtual

Called for every angular dimension (2 lines version) entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimAngular3P ( const DL_DimensionData data,
const DL_DimAngular3PData edata 
)
privatevirtual

Called for every angular dimension (3 points version) entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimDiametric ( const DL_DimensionData data,
const DL_DimDiametricData edata 
)
privatevirtual

Called for every diametric dimension entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimLinear ( const DL_DimensionData data,
const DL_DimLinearData edata 
)
privatevirtual

Called for every linear or rotated dimension entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimOrdinate ( const DL_DimensionData data,
const DL_DimOrdinateData edata 
)
privatevirtual

Called for every ordinate dimension entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addDimRadial ( const DL_DimensionData data,
const DL_DimRadialData edata 
)
privatevirtual

Called for every radial dimension entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addEllipse ( const DL_EllipseData data)
privatevirtual

Called for every ellipse.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addFitPoint ( const DL_FitPointData data)
privatevirtual

Called for every spline fit point.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addHatch ( const DL_HatchData data)
privatevirtual

Called for every hatch entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addHatchEdge ( const DL_HatchEdgeData data)
privatevirtual

Called for every hatch edge entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addHatchLoop ( const DL_HatchLoopData data)
privatevirtual

Called for every hatch loop.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addImage ( const DL_ImageData data)
privatevirtual

Called for every image entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addInsert ( const DL_InsertData data)
privatevirtual

Called for every insert.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addKnot ( const DL_KnotData data)
privatevirtual

Called for every spline knot value.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addLayer ( const DL_LayerData data)
privatevirtual

Called for every layer.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addLeader ( const DL_LeaderData data)
privatevirtual

Called for every leader start.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addLeaderVertex ( const DL_LeaderVertexData data)
privatevirtual

Called for every leader vertex.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addLine ( const DL_LineData data)
privatevirtual

Called for every line.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addLinetype ( const DL_LinetypeData data)
privatevirtual

Called for every linetype.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addLinetypeDash ( double  length)
privatevirtual

Called for every dash in linetype pattern.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addMText ( const DL_MTextData data)
privatevirtual

Called for every Multi Text entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addMTextChunk ( const std::string &  text)
privatevirtual

Called for additional text chunks for MTEXT entities.

The chunks come at 250 character in size each. Note that those chunks come before the actual MTEXT entity.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addPoint ( const DL_PointData data)
privatevirtual

Called for every point.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addPolyline ( const DL_PolylineData data)
privatevirtual

Called for every polyline start.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addRay ( const DL_RayData data)
privatevirtual

Called for every ray.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addSolid ( const DL_SolidData data)
privatevirtual

Called for every solid start.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addSpline ( const DL_SplineData data)
privatevirtual

Called for every spline.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addText ( const DL_TextData data)
privatevirtual

Implementation of the method which handles texts (TEXT).

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addTextStyle ( const DL_StyleData data)
privatevirtual

Called for every text style.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addTrace ( const DL_TraceData data)
privatevirtual

Called for every trace start.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addVertex ( const DL_VertexData data)
privatevirtual

Called for every polyline vertex.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXDataApp ( const std::string &  appId)
privatevirtual

Called for every beginning of an XData section of the given application.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXDataInt ( int  code,
int  value 
)
privatevirtual

Called for XData tuples.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXDataReal ( int  code,
double  value 
)
privatevirtual

Called for XData tuples.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXDataString ( int  code,
const std::string &  value 
)
privatevirtual

Called for XData tuples.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXLine ( const DL_XLineData data)
privatevirtual

Called for every xline.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXRecord ( const std::string &  handle)
privatevirtual

Called for every XRecord with the given handle.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXRecordBool ( int  code,
bool  value 
)
privatevirtual

Called for XRecords of type bool.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXRecordInt ( int  code,
int  value 
)
privatevirtual

Called for XRecords of type int.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXRecordReal ( int  code,
double  value 
)
privatevirtual

Called for XRecords of type double.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::addXRecordString ( int  code,
const std::string &  value 
)
privatevirtual

Called for XRecords of type string.

Reimplemented from DL_CreationAdapter.

RDimensionData RDxfImporter::convDimensionData ( const DL_DimensionData data)
privatevirtual
QString RDxfImporter::decode ( const QString &  str)
staticprivate
void RDxfImporter::endBlock ( )
privatevirtual

Called to end the current block.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::endEntity ( )
privatevirtual

Called after an entity has been completed.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::endSection ( )
privatevirtual

Called when a section (entity, table entry, etc.) is finished.

Reimplemented from DL_CreationAdapter.

QString RDxfImporter::getEncoding ( const QString &  str)
staticprivate

Tries to convert the given DXF encoding string to an encoding recognized by Qt.

RTextBasedData RDxfImporter::getTextBasedData ( const DL_TextData data)
private
int RDxfImporter::getXDataInt ( const QString &  appId,
int  code,
int  pos = 0 
)
private
QString RDxfImporter::getXDataString ( const QString &  appId,
int  code,
int  pos = 0 
)
private
void RDxfImporter::importEntity ( QSharedPointer< REntity entity)
private
bool RDxfImporter::importFile ( const QString &  fileName,
const QString &  nameFilter 
)
virtual

Must be implemented by file importers to import the given file into the document.

Implements RFileImporter.

void RDxfImporter::linkImage ( const DL_ImageDefData data)
privatevirtual

Called for every image definition.

Reimplemented from DL_CreationAdapter.

void RDxfImporter::processCodeValuePair ( unsigned int  groupCode,
char *  groupValue 
)
virtual
void RDxfImporter::setVariableDouble ( const std::string &  key,
double  value,
int  code 
)
privatevirtual

Called for every double variable in the DXF file (e.g.

"$DIMEXO").

Reimplemented from DL_CreationAdapter.

void RDxfImporter::setVariableInt ( const std::string &  key,
int  value,
int  code 
)
privatevirtual

Called for every int variable in the DXF file (e.g.

"$ACADMAINTVER").

Reimplemented from DL_CreationAdapter.

void RDxfImporter::setVariableString ( const std::string &  key,
const std::string &  value,
int  code 
)
privatevirtual

Called for every string variable in the DXF file (e.g.

"$ACADVER").

Reimplemented from DL_CreationAdapter.

void RDxfImporter::setVariableVector ( const std::string &  key,
double  v1,
double  v2,
double  v3,
int  code 
)
privatevirtual

Called for every vector variable in the DXF file (e.g.

"$EXTMIN").

Reimplemented from DL_CreationAdapter.


Member Data Documentation

RDxfServices RDxfImporter::dxfServices
private
QString RDxfImporter::fileName
private
RHatchData RDxfImporter::hatch
private
QMultiMap<int, RObject::Id> RDxfImporter::images
private
bool RDxfImporter::inDict
private
RLeaderData RDxfImporter::leader
private
QStringList RDxfImporter::lockedLayers
private
QByteArray RDxfImporter::mtext
private
QList<double> RDxfImporter::pattern
private
RPolyline RDxfImporter::polyline
private
QMap<QString, QString> RDxfImporter::qcadDict
private
QString RDxfImporter::qcadDictHandle
private
RSpline RDxfImporter::spline
private
QMap<QString, RDxfTextStyle> RDxfImporter::textStyles
private
QString RDxfImporter::variableKey
private
QMap<QString, QList<QPair<int, QVariant> > > RDxfImporter::xData
private
QString RDxfImporter::xDataAppId
private

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