425 lines
8.8 KiB
C++
425 lines
8.8 KiB
C++
#include "dxfreader.h"
|
|
#include <QDebug>
|
|
|
|
DxfReader::DxfReader(const QString &m_fileName, QObject *parent)
|
|
: QObject(parent)
|
|
,m_fileName(m_fileName)
|
|
{
|
|
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
|
|
|
|
m_blockDataList.clear();
|
|
m_blockData.blockId = 0;
|
|
initBlockDatas();
|
|
// 读取 dxf 文件
|
|
DL_Dxf *dxf = new DL_Dxf;
|
|
if (!dxf->in(std::string(m_fileName.toLocal8Bit()), this))
|
|
{
|
|
// if file open failed
|
|
std::cerr << std::string(m_fileName.toLocal8Bit()) << " could not be opened.\n";
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
m_blockData.blockId++;
|
|
m_blockDataList.append(m_blockData);
|
|
initBlockDatas();
|
|
}
|
|
|
|
if(dxf != NULL)
|
|
{
|
|
delete dxf;
|
|
}
|
|
}
|
|
|
|
DxfReader::~DxfReader()
|
|
{
|
|
}
|
|
|
|
void DxfReader::addText(const DL_TextData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfText << data;
|
|
}
|
|
|
|
void DxfReader::addLine(const DL_LineData &data)
|
|
{
|
|
m_blockData.dxfLines << data;
|
|
}
|
|
|
|
void DxfReader::addArc(const DL_ArcData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfArcs << data;
|
|
}
|
|
|
|
void DxfReader::addCircle(const DL_CircleData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfCircles << data;
|
|
}
|
|
|
|
void DxfReader::addEllipse(const DL_EllipseData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfEllipses << data;
|
|
}
|
|
|
|
void DxfReader::addPolyline(const DL_PolylineData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfPolylines << data;
|
|
}
|
|
|
|
void DxfReader::addPoint(const DL_PointData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfPoints << data;
|
|
}
|
|
|
|
void DxfReader::addSpline(const DL_SplineData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfSplines << data;
|
|
}
|
|
|
|
void DxfReader::addBlock(const DL_BlockData &data)
|
|
{
|
|
dxfBlocks << data;
|
|
m_blockData.blockName = data.name;
|
|
m_blockData.blockId++;
|
|
}
|
|
|
|
void DxfReader::endBlock()
|
|
{
|
|
m_blockDataList.append(m_blockData);
|
|
initBlockDatas();
|
|
}
|
|
|
|
void DxfReader::addLayer(const DL_LayerData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
dxfLayers << data;
|
|
}
|
|
|
|
void DxfReader::addLinetype(const DL_LinetypeData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
dxfLinetypes << data;
|
|
}
|
|
|
|
void DxfReader::addLinetypeDash(double length)
|
|
{
|
|
if(length < 0){}
|
|
}
|
|
|
|
void DxfReader::addXLine(const DL_XLineData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfXLines << data;
|
|
}
|
|
|
|
void DxfReader::addRay(const DL_RayData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfRays << data;
|
|
}
|
|
|
|
void DxfReader::addVertex(const DL_VertexData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfVertexs << data;
|
|
}
|
|
|
|
void DxfReader::addControlPoint(const DL_ControlPointData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfControlPoints << data;
|
|
}
|
|
|
|
void DxfReader::addFitPoint(const DL_FitPointData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfFitPoints << data;
|
|
}
|
|
|
|
void DxfReader::addKnot(const DL_KnotData &data)
|
|
{
|
|
if(data.k == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addInsert(const DL_InsertData &data)
|
|
{
|
|
if(data.angle == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addSolid(const DL_SolidData &data)
|
|
{
|
|
if(data.x == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addTrace(const DL_TraceData &data)
|
|
{
|
|
if(data.x == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addTextStyle(const DL_StyleData &data)
|
|
{
|
|
if(data.flags == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addMTextChunk(const std::string &text)
|
|
{
|
|
if(text.data() == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addMText(const DL_MTextData &data)
|
|
{
|
|
if(data.angle == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addArcAlignedText(const DL_ArcAlignedTextData &data)
|
|
{
|
|
if(data.alignment == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addAttribute(const DL_AttributeData &data)
|
|
{
|
|
if(data.angle == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addDimAlign(const DL_DimensionData &data, const DL_DimAlignedData &edata)
|
|
{
|
|
if(data.angle == 0){}
|
|
if(edata.epx1 == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addDimLinear(const DL_DimensionData &data, const DL_DimLinearData &edata)
|
|
{
|
|
if(data.angle == 0){}
|
|
if(edata.angle == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addDimRadial(const DL_DimensionData &data, const DL_DimRadialData &edata)
|
|
{
|
|
if(data.angle == 0){}
|
|
if(edata.dpx == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addDimDiametric(const DL_DimensionData &data, const DL_DimDiametricData &edata)
|
|
{
|
|
if(data.angle == 0){}
|
|
if(edata.dpx == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
//void DxfReader::addDimAngular(const DL_DimensionData &data, const DL_DimAngularData &edata)
|
|
//{
|
|
// if(data.angle == 0){}
|
|
// if(edata.dpx1 == 0){}
|
|
// //qDebug() << Q_FUNC_INFO;
|
|
//}
|
|
|
|
void DxfReader::addDimAngular3P(const DL_DimensionData &data, const DL_DimAngular3PData &edata)
|
|
{
|
|
if(data.angle == 0){}
|
|
if(edata.dpx1 == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addDimOrdinate(const DL_DimensionData &data, const DL_DimOrdinateData &edata)
|
|
{
|
|
if(data.angle == 0){}
|
|
if(edata.dpx1 == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addLeader(const DL_LeaderData &data)
|
|
{
|
|
if(data.arrowHeadFlag == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addLeaderVertex(const DL_LeaderVertexData &data)
|
|
{
|
|
if(data.x == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addHatch(const DL_HatchData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfHatchs << data;
|
|
}
|
|
|
|
void DxfReader::addHatchLoop(const DL_HatchLoopData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfHatchLoops << data;
|
|
}
|
|
|
|
void DxfReader::addHatchEdge(const DL_HatchEdgeData &data)
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
m_blockData.dxfHatchEdges << data;
|
|
}
|
|
|
|
void DxfReader::addImage(const DL_ImageData &data)
|
|
{
|
|
if(data.brightness == 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::linkImage(const DL_ImageDefData &data)
|
|
{
|
|
if(data.file == ""){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addXRecord(const std::string &handle)
|
|
{
|
|
if(handle.length() <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXRecordString(int code, const std::string &value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value.length() <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXRecordReal(int code, double value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXRecordInt(int code, int value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXRecordBool(int code, bool value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXDataApp(const std::string &appId)
|
|
{
|
|
if(appId.length() <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXDataString(int code, const std::string &value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value.length() <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXDataReal(int code, double value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value <= 0){}
|
|
}
|
|
|
|
void DxfReader::addXDataInt(int code, int value)
|
|
{
|
|
if(code <= 0){}
|
|
if(value <= 0){}
|
|
}
|
|
|
|
void DxfReader::addDictionary(const DL_DictionaryData &data)
|
|
{
|
|
if(data.handle.length() <= 0){}
|
|
// qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addDictionaryEntry(const DL_DictionaryEntryData &data)
|
|
{
|
|
if(data.handle.length() <= 0){}
|
|
// qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::setVariableVector(const std::string &key, double v1, double v2, double v3, int code)
|
|
{
|
|
if(key.length() <= 0){}
|
|
if(v1 <= 0){}
|
|
if(v2 <= 0){}
|
|
if(v3 <= 0){}
|
|
if(code <= 0){}
|
|
}
|
|
|
|
void DxfReader::setVariableString(const std::string &key, const std::string &value, int code)
|
|
{
|
|
if(key.length() <= 0){}
|
|
if(value.length() <= 0){}
|
|
if(code <= 0){}
|
|
}
|
|
|
|
void DxfReader::setVariableInt(const std::string &key, int value, int code)
|
|
{
|
|
if(key.length() <= 0){}
|
|
if(value <= 0){}
|
|
if(code <= 0){}
|
|
}
|
|
|
|
void DxfReader::setVariableDouble(const std::string &key, double value, int code)
|
|
{
|
|
if(key.length() <= 0){}
|
|
if(value <= 0){}
|
|
if(code <= 0){}
|
|
}
|
|
|
|
void DxfReader::add3dFace(const DL_3dFaceData &data)
|
|
{
|
|
if(data.thickness <= 0){}
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
void DxfReader::addComment(const std::string &comment)
|
|
{
|
|
if(comment.length() <= 0){}
|
|
}
|
|
|
|
void DxfReader::endSequence()
|
|
{
|
|
//qDebug() << Q_FUNC_INFO;
|
|
}
|
|
|
|
QList<BlockDatas> DxfReader::getBlockDatas()
|
|
{
|
|
return m_blockDataList;
|
|
}
|
|
|
|
void DxfReader::initBlockDatas()
|
|
{
|
|
m_blockData.dxfArcs.clear();
|
|
m_blockData.dxfLines.clear();
|
|
m_blockData.dxfText.clear();
|
|
m_blockData.dxfArcs.clear();
|
|
m_blockData.dxfCircles.clear();
|
|
m_blockData.dxfEllipses.clear();
|
|
m_blockData.dxfPolylines.clear();
|
|
m_blockData.dxfPoints.clear();
|
|
m_blockData.dxfSplines.clear();
|
|
m_blockData.dxfVertexs.clear();
|
|
m_blockData.dxfXLines.clear();
|
|
m_blockData.dxfRays.clear();
|
|
m_blockData.dxfControlPoints.clear();
|
|
m_blockData.dxfFitPoints.clear();
|
|
m_blockData.dxfHatchs.clear();
|
|
m_blockData.dxfHatchLoops.clear();
|
|
m_blockData.dxfHatchEdges.clear();
|
|
}
|