--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-02 08:01:48 +03:00
commit ad7928248c
12 changed files with 271 additions and 284 deletions

View file

@ -34,4 +34,20 @@ enum class VarMeasurement : unsigned char { English=0, Metric=1 };
//Default drawing units for AutoCAD DesignCenter blocks: //Default drawing units for AutoCAD DesignCenter blocks:
enum class VarInsunits : unsigned char { Inches=1, Millimeters=4, Centimeters=5 }; enum class VarInsunits : unsigned char { Inches=1, Millimeters=4, Centimeters=5 };
static inline bool DL_FuzzyComparePossibleNulls(double p1, double p2)
{
if(qFuzzyIsNull(p1))
{
return qFuzzyIsNull(p2);
}
else if(qFuzzyIsNull(p2))
{
return false;
}
else
{
return qFuzzyCompare(p1, p2);
}
}
#endif // DXFDEF_H #endif // DXFDEF_H

View file

@ -32,9 +32,11 @@
#include "dl_global.h" #include "dl_global.h"
#if _MSC_VER > 1000 #if defined(Q_CC_MSVC)
#pragma once #if (_MSC_VER > 1000)
#endif // _MSC_VER > 1000 #pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#if defined(__OS2__)||defined(__EMX__) #if defined(__OS2__)||defined(__EMX__)
#define strcasecmp(s,t) stricmp(s,t) #define strcasecmp(s,t) stricmp(s,t)

View file

@ -47,9 +47,8 @@
class DXFLIB_EXPORT DL_CreationInterface class DXFLIB_EXPORT DL_CreationInterface
{ {
public: public:
DL_CreationInterface() DL_CreationInterface() : extrusion(new DL_Extrusion), attributes()
{ {
extrusion = new DL_Extrusion;
} }
virtual ~DL_CreationInterface() virtual ~DL_CreationInterface()
{ {
@ -365,9 +364,12 @@ public:
return extrusion; return extrusion;
} }
private:
Q_DISABLE_COPY(DL_CreationInterface);
protected: protected:
DL_Attributes attributes;
DL_Extrusion *extrusion; DL_Extrusion *extrusion;
DL_Attributes attributes;
}; };
#endif #endif

View file

@ -41,31 +41,36 @@
* Default constructor. * Default constructor.
*/ */
DL_Dxf::DL_Dxf() DL_Dxf::DL_Dxf()
: version(DL_VERSION_2000),
polylineLayer(),
vertices(nullptr),
maxVertices(0),
vertexIndex(0),
knots(nullptr),
maxKnots(0),
knotIndex(0),
weights(nullptr),
weightIndex(0),
controlPoints(nullptr),
maxControlPoints(0),
controlPointIndex(0),
fitPoints(nullptr),
maxFitPoints(0),
fitPointIndex(0),
leaderVertices(nullptr),
maxLeaderVertices(0),
leaderVertexIndex(0),
firstHatchLoop(), hatchEdge(), hatchEdges(),
xRecordHandle(), xRecordValues(), groupCodeTmp(), groupCode(), groupValue(),
currentObjectType(), settingKey(), values(), firstCall(), attrib(),
libVersion(), appDictionaryHandle(), styleHandleStd()
{ {
version = DL_VERSION_2000;
vertices = NULL;
maxVertices = 0;
vertexIndex = 0;
knots = NULL;
maxKnots = 0;
knotIndex = 0;
weights = NULL;
weightIndex = 0;
controlPoints = NULL;
maxControlPoints = 0;
controlPointIndex = 0;
fitPoints = NULL;
maxFitPoints = 0;
fitPointIndex = 0;
leaderVertices = NULL;
maxLeaderVertices = 0;
leaderVertexIndex = 0;
} }
@ -75,27 +80,27 @@ DL_Dxf::DL_Dxf()
*/ */
DL_Dxf::~DL_Dxf() DL_Dxf::~DL_Dxf()
{ {
if (vertices!=NULL) if (vertices!=nullptr)
{ {
delete[] vertices; delete[] vertices;
} }
if (knots!=NULL) if (knots!=nullptr)
{ {
delete[] knots; delete[] knots;
} }
if (controlPoints!=NULL) if (controlPoints!=nullptr)
{ {
delete[] controlPoints; delete[] controlPoints;
} }
if (fitPoints!=NULL) if (fitPoints!=nullptr)
{ {
delete[] fitPoints; delete[] fitPoints;
} }
if (weights!=NULL) if (weights!=nullptr)
{ {
delete[] weights; delete[] weights;
} }
if (leaderVertices!=NULL) if (leaderVertices!=nullptr)
{ {
delete[] leaderVertices; delete[] leaderVertices;
} }
@ -192,7 +197,7 @@ bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface)
DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, fp) ) DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, fp) )
{ {
groupCode = (unsigned int)toInt(groupCodeTmp); groupCode = static_cast<unsigned int>(toInt(groupCodeTmp));
creationInterface->processCodeValuePair(groupCode, groupValue); creationInterface->processCodeValuePair(groupCode, groupValue);
line+=2; line+=2;
@ -218,7 +223,7 @@ bool DL_Dxf::readDxfGroups(std::stringstream& stream,
DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, stream) ) DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, stream) )
{ {
groupCode = (unsigned int)toInt(groupCodeTmp); groupCode = static_cast<unsigned int>(toInt(groupCodeTmp));
line+=2; line+=2;
processDXFGroup(creationInterface, groupCode, groupValue); processDXFGroup(creationInterface, groupCode, groupValue);
@ -322,7 +327,7 @@ bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size,
bool DL_Dxf::stripWhiteSpace(char** s) bool DL_Dxf::stripWhiteSpace(char** s)
{ {
// last non-NULL char: // last non-NULL char:
int lastChar = strlen(*s) - 1; int lastChar = static_cast<int>(strlen(*s) - 1);
// Is last character CR or LF? // Is last character CR or LF?
while ( (lastChar >= 0) && while ( (lastChar >= 0) &&
@ -423,7 +428,7 @@ bool DL_Dxf::processDXFGroup(DL_CreationInterface* creationInterface,
width, // width width, // width
linetype, // linetype linetype, // linetype
handle); // handle handle); // handle
attrib.setInPaperSpace((bool)getIntValue(67, 0)); attrib.setInPaperSpace(static_cast<bool>(getIntValue(67, 0)));
attrib.setLinetypeScale(getRealValue(48, 1.0)); attrib.setLinetypeScale(getRealValue(48, 1.0));
creationInterface->setAttributes(attrib); creationInterface->setAttributes(attrib);
@ -1612,7 +1617,7 @@ bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* /*creationInterface*/)
maxVertices = toInt(groupValue); maxVertices = toInt(groupValue);
if (maxVertices>0) if (maxVertices>0)
{ {
if (vertices!=NULL) if (vertices!=nullptr)
{ {
delete[] vertices; delete[] vertices;
} }
@ -1668,7 +1673,7 @@ bool DL_Dxf::handleSplineData(DL_CreationInterface* /*creationInterface*/)
maxKnots = toInt(groupValue); maxKnots = toInt(groupValue);
if (maxKnots>0) if (maxKnots>0)
{ {
if (knots!=NULL) if (knots!=nullptr)
{ {
delete[] knots; delete[] knots;
} }
@ -1688,11 +1693,11 @@ bool DL_Dxf::handleSplineData(DL_CreationInterface* /*creationInterface*/)
maxControlPoints = toInt(groupValue); maxControlPoints = toInt(groupValue);
if (maxControlPoints>0) if (maxControlPoints>0)
{ {
if (controlPoints!=NULL) if (controlPoints!=nullptr)
{ {
delete[] controlPoints; delete[] controlPoints;
} }
if (weights!=NULL) if (weights!=nullptr)
{ {
delete[] weights; delete[] weights;
} }
@ -1717,7 +1722,7 @@ bool DL_Dxf::handleSplineData(DL_CreationInterface* /*creationInterface*/)
maxFitPoints = toInt(groupValue); maxFitPoints = toInt(groupValue);
if (maxFitPoints>0) if (maxFitPoints>0)
{ {
if (fitPoints!=NULL) if (fitPoints!=nullptr)
{ {
delete[] fitPoints; delete[] fitPoints;
} }
@ -1807,7 +1812,7 @@ bool DL_Dxf::handleLeaderData(DL_CreationInterface* /*creationInterface*/)
maxLeaderVertices = toInt(groupValue); maxLeaderVertices = toInt(groupValue);
if (maxLeaderVertices>0) if (maxLeaderVertices>0)
{ {
if (leaderVertices!=NULL) if (leaderVertices!=nullptr)
{ {
delete[] leaderVertices; delete[] leaderVertices;
} }
@ -2176,7 +2181,7 @@ void DL_Dxf::addHatch(DL_CreationInterface* creationInterface)
for (unsigned int i=0; i<hatchEdges.size(); i++) for (unsigned int i=0; i<hatchEdges.size(); i++)
{ {
creationInterface->addHatchLoop(DL_HatchLoopData(hatchEdges[i].size())); creationInterface->addHatchLoop(DL_HatchLoopData(static_cast<unsigned int>(hatchEdges[i].size())));
for (unsigned int k=0; k<hatchEdges[i].size(); k++) for (unsigned int k=0; k<hatchEdges[i].size(); k++)
{ {
creationInterface->addHatchEdge(DL_HatchEdgeData(hatchEdges[i][k])); creationInterface->addHatchEdge(DL_HatchEdgeData(hatchEdges[i][k]));
@ -2273,6 +2278,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface)
hatchEdge.defined = true; hatchEdge.defined = true;
} }
return true; return true;
default:
return false;
} }
} }
else else
@ -2295,6 +2302,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface)
hatchEdge.y2 = toReal(groupValue); hatchEdge.y2 = toReal(groupValue);
hatchEdge.defined = true; hatchEdge.defined = true;
return true; return true;
default:
return false;
} }
} }
@ -2319,9 +2328,11 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface)
hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI; hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI;
return true; return true;
case 73: case 73:
hatchEdge.ccw = (bool)toInt(groupValue); hatchEdge.ccw = static_cast<bool>(toInt(groupValue));
hatchEdge.defined = true; hatchEdge.defined = true;
return true; return true;
default:
return false;
} }
} }
@ -2352,9 +2363,11 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface)
hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI; hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI;
return true; return true;
case 73: case 73:
hatchEdge.ccw = (bool)toInt(groupValue); hatchEdge.ccw = static_cast<bool>(toInt(groupValue));
hatchEdge.defined = true; hatchEdge.defined = true;
return true; return true;
default:
return false;
} }
} }
@ -2435,6 +2448,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface)
case 23: case 23:
hatchEdge.endTangentY = toReal(groupValue); hatchEdge.endTangentY = toReal(groupValue);
return true; return true;
default:
return false;
} }
} }
} }
@ -2598,6 +2613,8 @@ void DL_Dxf::writeHeader(DL_WriterA& dw)
case DL_Codes::AC1015: case DL_Codes::AC1015:
dw.dxfString(1, "AC1015"); dw.dxfString(1, "AC1015");
break; break;
default:
break;
} }
// Newer version require that (otherwise a*cad crashes..) // Newer version require that (otherwise a*cad crashes..)
@ -2727,7 +2744,7 @@ void DL_Dxf::writePolyline(DL_WriterA& dw,
dw.entityAttributes(attrib); dw.entityAttributes(attrib);
dw.dxfString(100, "AcDbEntity"); dw.dxfString(100, "AcDbEntity");
dw.dxfString(100, "AcDbPolyline"); dw.dxfString(100, "AcDbPolyline");
dw.dxfInt(90, (int)data.number); dw.dxfInt(90, static_cast<int>(data.number));
dw.dxfInt(70, data.flags); dw.dxfInt(70, data.flags);
} }
else else
@ -3072,13 +3089,13 @@ void DL_Dxf::writeInsert(DL_WriterA& dw,
dw.dxfReal(10, data.ipx); dw.dxfReal(10, data.ipx);
dw.dxfReal(20, data.ipy); dw.dxfReal(20, data.ipy);
dw.dxfReal(30, data.ipz); dw.dxfReal(30, data.ipz);
if (data.sx!=1.0 || data.sy!=1.0) if (!DL_FuzzyComparePossibleNulls(data.sx, 1.0) || !DL_FuzzyComparePossibleNulls(data.sy, 1.0))
{ {
dw.dxfReal(41, data.sx); dw.dxfReal(41, data.sx);
dw.dxfReal(42, data.sy); dw.dxfReal(42, data.sy);
dw.dxfReal(43, 1.0); dw.dxfReal(43, 1.0);
} }
if (data.angle!=0.0) if (!DL_FuzzyComparePossibleNulls(data.angle, 0.0))
{ {
dw.dxfReal(50, data.angle); dw.dxfReal(50, data.angle);
} }
@ -3087,7 +3104,7 @@ void DL_Dxf::writeInsert(DL_WriterA& dw,
dw.dxfInt(70, data.cols); dw.dxfInt(70, data.cols);
dw.dxfInt(71, data.rows); dw.dxfInt(71, data.rows);
} }
if (data.colSp!=0.0 || data.rowSp!=0.0) if (!DL_FuzzyComparePossibleNulls(data.colSp, 0.0) || !DL_FuzzyComparePossibleNulls(data.rowSp, 0.0))
{ {
dw.dxfReal(44, data.colSp); dw.dxfReal(44, data.colSp);
dw.dxfReal(45, data.rowSp); dw.dxfReal(45, data.rowSp);
@ -3126,7 +3143,7 @@ void DL_Dxf::writeMText(DL_WriterA& dw,
dw.dxfInt(72, data.drawingDirection); dw.dxfInt(72, data.drawingDirection);
// Creare text chunks of 250 characters each: // Creare text chunks of 250 characters each:
int length = data.text.length(); int length = static_cast<int>(data.text.length());
char chunk[251]; char chunk[251];
int i; int i;
for (i=250; i<length; i+=250) for (i=250; i<length; i+=250)
@ -3240,7 +3257,7 @@ void DL_Dxf::writeDimStyleOverrides(DL_WriterA& dw,
dw.dxfString(1000, "DSTYLE"); dw.dxfString(1000, "DSTYLE");
dw.dxfString(1002, "{"); dw.dxfString(1002, "{");
dw.dxfInt(1070, 144); dw.dxfInt(1070, 144);
dw.dxfInt(1040, data.linearFactor); dw.dxfInt(1040, static_cast<int>(data.linearFactor));
dw.dxfString(1002, "}"); dw.dxfString(1002, "}");
} }
} }
@ -3810,7 +3827,7 @@ void DL_Dxf::writeHatch1(DL_WriterA& dw,
{ {
dw.dxfString(2, "SOLID"); dw.dxfString(2, "SOLID");
} }
dw.dxfInt(70, (int)data.solid); dw.dxfInt(70, static_cast<int>(data.solid));
dw.dxfInt(71, 0); // non-associative dw.dxfInt(71, 0); // non-associative
dw.dxfInt(91, data.numLoops); dw.dxfInt(91, data.numLoops);
} }
@ -3927,7 +3944,7 @@ void DL_Dxf::writeHatchEdge(DL_WriterA& dw,
dw.dxfReal(40, data.radius); dw.dxfReal(40, data.radius);
dw.dxfReal(50, data.angle1/(2*M_PI)*360.0); dw.dxfReal(50, data.angle1/(2*M_PI)*360.0);
dw.dxfReal(51, data.angle2/(2*M_PI)*360.0); dw.dxfReal(51, data.angle2/(2*M_PI)*360.0);
dw.dxfInt(73, (int)(data.ccw)); dw.dxfInt(73, static_cast<int>((data.ccw)));
break; break;
// ellipse arc: // ellipse arc:
@ -3939,7 +3956,7 @@ void DL_Dxf::writeHatchEdge(DL_WriterA& dw,
dw.dxfReal(40, data.ratio); dw.dxfReal(40, data.ratio);
dw.dxfReal(50, data.angle1/(2*M_PI)*360.0); dw.dxfReal(50, data.angle1/(2*M_PI)*360.0);
dw.dxfReal(51, data.angle2/(2*M_PI)*360.0); dw.dxfReal(51, data.angle2/(2*M_PI)*360.0);
dw.dxfInt(73, (int)(data.ccw)); dw.dxfInt(73, static_cast<int>((data.ccw)));
break; break;
// spline: // spline:
@ -4035,7 +4052,7 @@ int DL_Dxf::writeImage(DL_WriterA& dw,
dw.dxfReal(23, data.height); dw.dxfReal(23, data.height);
// handle of IMAGEDEF object // handle of IMAGEDEF object
int handle = dw.incHandle(); int handle = static_cast<int>(dw.incHandle());
dw.dxfHex(340, handle); dw.dxfHex(340, handle);
// flags // flags
@ -4670,7 +4687,7 @@ void DL_Dxf::writeDimStyle(DL_WriterA& dw,
dw.dxfInt(278, 44); dw.dxfInt(278, 44);
dw.dxfInt(283, 0); dw.dxfInt(283, 0);
dw.dxfInt(284, 8); dw.dxfInt(284, 8);
dw.dxfHex(340, styleHandleStd); dw.dxfHex(340, static_cast<int>(styleHandleStd));
//dw.dxfHex(340, 0x11); //dw.dxfHex(340, 0x11);
} }
// * / // * /
@ -4801,7 +4818,7 @@ void DL_Dxf::writeObjects(DL_WriterA& dw, const std::string& appDictionaryName)
dw.dxfString( 3, "ACAD_PLOTSTYLENAME"); dw.dxfString( 3, "ACAD_PLOTSTYLENAME");
dw.dxfHex(350, 0xE); dw.dxfHex(350, 0xE);
dw.dxfString( 3, "AcDbVariableDictionary"); dw.dxfString( 3, "AcDbVariableDictionary");
int acDbVariableDictionaryHandle = dw.handle(350); int acDbVariableDictionaryHandle = static_cast<int>(dw.handle(350));
//int acDbVariableDictionaryHandle = dw.getNextHandle(); //int acDbVariableDictionaryHandle = dw.getNextHandle();
//dw.dxfHex(350, acDbVariableDictionaryHandle); //dw.dxfHex(350, acDbVariableDictionaryHandle);
//dw.incHandle(); //dw.incHandle();
@ -5103,10 +5120,10 @@ void DL_Dxf::writeObjects(DL_WriterA& dw, const std::string& appDictionaryName)
dw.dxfInt(281, 1); dw.dxfInt(281, 1);
dw.dxfString( 3, "DIMASSOC"); dw.dxfString( 3, "DIMASSOC");
//dw.dxfHex(350, 0x2F); //dw.dxfHex(350, 0x2F);
dw.dxfHex(350, dw.getNextHandle()+1); // 2E dw.dxfHex(350, static_cast<int>(dw.getNextHandle()+1)); // 2E
dw.dxfString( 3, "HIDETEXT"); dw.dxfString( 3, "HIDETEXT");
//dw.dxfHex(350, 0x2E); //dw.dxfHex(350, 0x2E);
dw.dxfHex(350, dw.getNextHandle()); // 2D dw.dxfHex(350, static_cast<int>(dw.getNextHandle())); // 2D
dw.dxfString( 0, "DICTIONARYVAR"); dw.dxfString( 0, "DICTIONARYVAR");
@ -5131,7 +5148,7 @@ void DL_Dxf::writeAppDictionary(DL_WriterA& dw)
{ {
dw.dxfString( 0, "DICTIONARY"); dw.dxfString( 0, "DICTIONARY");
//dw.handle(); //dw.handle();
dw.dxfHex(5, appDictionaryHandle); dw.dxfHex(5, static_cast<int>(appDictionaryHandle));
dw.dxfString(100, "AcDbDictionary"); dw.dxfString(100, "AcDbDictionary");
dw.dxfInt(281, 1); dw.dxfInt(281, 1);
} }
@ -5139,7 +5156,7 @@ void DL_Dxf::writeAppDictionary(DL_WriterA& dw)
int DL_Dxf::writeDictionaryEntry(DL_WriterA& dw, const std::string& name) int DL_Dxf::writeDictionaryEntry(DL_WriterA& dw, const std::string& name)
{ {
dw.dxfString( 3, name); dw.dxfString( 3, name);
int handle = dw.getNextHandle(); int handle = static_cast<int>(dw.getNextHandle());
dw.dxfHex(350, handle); dw.dxfHex(350, handle);
dw.incHandle(); dw.incHandle();
return handle; return handle;
@ -5149,7 +5166,7 @@ void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, int value)
{ {
dw.dxfString( 0, "XRECORD"); dw.dxfString( 0, "XRECORD");
dw.dxfHex(5, handle); dw.dxfHex(5, handle);
dw.dxfHex(330, appDictionaryHandle); dw.dxfHex(330, static_cast<int>(appDictionaryHandle));
dw.dxfString(100, "AcDbXrecord"); dw.dxfString(100, "AcDbXrecord");
dw.dxfInt(280, 1); dw.dxfInt(280, 1);
dw.dxfInt(90, value); dw.dxfInt(90, value);
@ -5159,7 +5176,7 @@ void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, double value)
{ {
dw.dxfString( 0, "XRECORD"); dw.dxfString( 0, "XRECORD");
dw.dxfHex(5, handle); dw.dxfHex(5, handle);
dw.dxfHex(330, appDictionaryHandle); dw.dxfHex(330, static_cast<int>(appDictionaryHandle));
dw.dxfString(100, "AcDbXrecord"); dw.dxfString(100, "AcDbXrecord");
dw.dxfInt(280, 1); dw.dxfInt(280, 1);
dw.dxfReal(40, value); dw.dxfReal(40, value);
@ -5169,7 +5186,7 @@ void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, bool value)
{ {
dw.dxfString( 0, "XRECORD"); dw.dxfString( 0, "XRECORD");
dw.dxfHex(5, handle); dw.dxfHex(5, handle);
dw.dxfHex(330, appDictionaryHandle); dw.dxfHex(330, static_cast<int>(appDictionaryHandle));
dw.dxfString(100, "AcDbXrecord"); dw.dxfString(100, "AcDbXrecord");
dw.dxfInt(280, 1); dw.dxfInt(280, 1);
dw.dxfBool(290, value); dw.dxfBool(290, value);
@ -5179,7 +5196,7 @@ void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, const std::string& value)
{ {
dw.dxfString( 0, "XRECORD"); dw.dxfString( 0, "XRECORD");
dw.dxfHex(5, handle); dw.dxfHex(5, handle);
dw.dxfHex(330, appDictionaryHandle); dw.dxfHex(330, static_cast<int>(appDictionaryHandle));
dw.dxfString(100, "AcDbXrecord"); dw.dxfString(100, "AcDbXrecord");
dw.dxfInt(280, 1); dw.dxfInt(280, 1);
dw.dxfString(1000, value); dw.dxfString(1000, value);
@ -5813,7 +5830,7 @@ int DL_Dxf::getLibVersion(const std::string& str)
if (idx>=2) if (idx>=2)
{ {
d[3] = str.length(); d[3] = static_cast<int>(str.length());
v[0] = str.substr(0, d[0]); v[0] = str.substr(0, d[0]);
v[1] = str.substr(d[0]+1, d[1]-d[0]-1); v[1] = str.substr(d[0]+1, d[1]-d[0]-1);

View file

@ -416,13 +416,13 @@ public:
int toInt(const std::string& str) int toInt(const std::string& str)
{ {
char* p; char* p;
return strtol(str.c_str(), &p, 10); return static_cast<int>(strtol(str.c_str(), &p, 10));
} }
bool toBool(const std::string& str) bool toBool(const std::string& str)
{ {
char* p; char* p;
return (bool)strtol(str.c_str(), &p, 10); return static_cast<bool>(strtol(str.c_str(), &p, 10));
} }
std::string getStringValue(int code, const std::string& def) std::string getStringValue(int code, const std::string& def)
@ -457,6 +457,7 @@ public:
} }
private: private:
Q_DISABLE_COPY(DL_Dxf);
DL_Codes::version version; DL_Codes::version version;
std::string polylineLayer; std::string polylineLayer;

View file

@ -26,6 +26,7 @@
#define DL_ENTITIES_H #define DL_ENTITIES_H
#include "dl_global.h" #include "dl_global.h"
#include "dxfdef.h"
#include <string> #include <string>
#include <vector> #include <vector>
@ -39,11 +40,9 @@ struct DXFLIB_EXPORT DL_LayerData
* Constructor. * Constructor.
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_LayerData(const std::string& lName, DL_LayerData(const std::string& lName, int lFlags)
int lFlags) : name(lName), flags(lFlags)
{ {
name = lName;
flags = lFlags;
} }
/** Layer name. */ /** Layer name. */
@ -63,15 +62,10 @@ struct DXFLIB_EXPORT DL_BlockData
* Constructor. * Constructor.
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_BlockData(const std::string& bName, DL_BlockData(const std::string& bName, int bFlags,
int bFlags,
double bbpx, double bbpy, double bbpz) double bbpx, double bbpy, double bbpz)
{ : name(bName), flags(bFlags), bpx(bbpx), bpy(bbpy), bpz(bbpz)
name = bName; {
flags = bFlags;
bpx = bbpx;
bpy = bbpy;
bpz = bbpz;
} }
/** Block name. */ /** Block name. */
@ -102,7 +96,7 @@ struct DXFLIB_EXPORT DL_LinetypeData
int flags, int flags,
int numberOfDashes, int numberOfDashes,
double patternLength, double patternLength,
double* pattern = NULL double* pattern = nullptr
) )
: name(name), : name(name),
description(description), description(description),
@ -110,7 +104,12 @@ struct DXFLIB_EXPORT DL_LinetypeData
numberOfDashes(numberOfDashes), numberOfDashes(numberOfDashes),
patternLength(patternLength), patternLength(patternLength),
pattern(pattern) pattern(pattern)
{} {
}
~DL_LinetypeData()
{
}
/** Linetype name */ /** Linetype name */
std::string name; std::string name;
@ -124,6 +123,9 @@ struct DXFLIB_EXPORT DL_LinetypeData
double patternLength; double patternLength;
/** Pattern */ /** Pattern */
double* pattern; double* pattern;
private:
Q_DISABLE_COPY(DL_LinetypeData);
}; };
@ -167,9 +169,9 @@ struct DXFLIB_EXPORT DL_StyleData
// ignore lastHeightUsed: // ignore lastHeightUsed:
return (name==other.name && return (name==other.name &&
flags==other.flags && flags==other.flags &&
fixedTextHeight==other.fixedTextHeight && DL_FuzzyComparePossibleNulls(fixedTextHeight, other.fixedTextHeight) &&
widthFactor==other.widthFactor && DL_FuzzyComparePossibleNulls(widthFactor, other.widthFactor) &&
obliqueAngle==other.obliqueAngle && DL_FuzzyComparePossibleNulls(obliqueAngle, other.obliqueAngle) &&
textGenerationFlags==other.textGenerationFlags && textGenerationFlags==other.textGenerationFlags &&
primaryFontFile==other.primaryFontFile && primaryFontFile==other.primaryFontFile &&
bigFontFile==other.bigFontFile); bigFontFile==other.bigFontFile);
@ -208,10 +210,8 @@ struct DXFLIB_EXPORT DL_PointData
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_PointData(double px=0.0, double py=0.0, double pz=0.0) DL_PointData(double px=0.0, double py=0.0, double pz=0.0)
: x(px), y(py), z(pz)
{ {
x = px;
y = py;
z = pz;
} }
/*! X Coordinate of the point. */ /*! X Coordinate of the point. */
@ -235,14 +235,8 @@ struct DXFLIB_EXPORT DL_LineData
*/ */
DL_LineData(double lx1, double ly1, double lz1, DL_LineData(double lx1, double ly1, double lz1,
double lx2, double ly2, double lz2) double lx2, double ly2, double lz2)
: x1(lx1), y1(ly1), z1(lz1), x2(lx2), y2(ly2), z2(lz2)
{ {
x1 = lx1;
y1 = ly1;
z1 = lz1;
x2 = lx2;
y2 = ly2;
z2 = lz2;
} }
/*! X Start coordinate of the point. */ /*! X Start coordinate of the point. */
@ -336,14 +330,8 @@ struct DXFLIB_EXPORT DL_ArcData
DL_ArcData(double acx, double acy, double acz, DL_ArcData(double acx, double acy, double acz,
double aRadius, double aRadius,
double aAngle1, double aAngle2) double aAngle1, double aAngle2)
{ : cx(acx), cy(acy), cz(acz), radius(aRadius), angle1(aAngle1), angle2(aAngle2)
{
cx = acx;
cy = acy;
cz = acz;
radius = aRadius;
angle1 = aAngle1;
angle2 = aAngle2;
} }
/*! X Coordinate of center point. */ /*! X Coordinate of center point. */
@ -374,12 +362,8 @@ struct DXFLIB_EXPORT DL_CircleData
*/ */
DL_CircleData(double acx, double acy, double acz, DL_CircleData(double acx, double acy, double acz,
double aRadius) double aRadius)
: cx(acx), cy(acy), cz(acz), radius(aRadius)
{ {
cx = acx;
cy = acy;
cz = acz;
radius = aRadius;
} }
/*! X Coordinate of center point. */ /*! X Coordinate of center point. */
@ -405,11 +389,8 @@ struct DXFLIB_EXPORT DL_PolylineData
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_PolylineData(int pNumber, int pMVerteces, int pNVerteces, int pFlags) DL_PolylineData(int pNumber, int pMVerteces, int pNVerteces, int pFlags)
: number(pNumber), m(pMVerteces), n(pNVerteces), flags(pFlags)
{ {
number = pNumber;
m = pMVerteces;
n = pNVerteces;
flags = pFlags;
} }
/*! Number of vertices in this polyline. */ /*! Number of vertices in this polyline. */
@ -438,11 +419,8 @@ struct DXFLIB_EXPORT DL_VertexData
*/ */
DL_VertexData(double px=0.0, double py=0.0, double pz=0.0, DL_VertexData(double px=0.0, double py=0.0, double pz=0.0,
double pBulge=0.0) double pBulge=0.0)
: x(px), y(py), z(pz), bulge(pBulge)
{ {
x = px;
y = py;
z = pz;
bulge = pBulge;
} }
/*! X Coordinate of the vertex. */ /*! X Coordinate of the vertex. */
@ -463,8 +441,8 @@ struct DXFLIB_EXPORT DL_VertexData
struct DXFLIB_EXPORT DL_TraceData struct DXFLIB_EXPORT DL_TraceData
{ {
DL_TraceData() DL_TraceData()
: thickness(0.0)
{ {
thickness = 0.0;
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
{ {
x[i] = 0.0; x[i] = 0.0;
@ -482,10 +460,8 @@ struct DXFLIB_EXPORT DL_TraceData
double sx3, double sy3, double sz3, double sx3, double sy3, double sz3,
double sx4, double sy4, double sz4, double sx4, double sy4, double sz4,
double sthickness=0.0) double sthickness=0.0)
: thickness(sthickness)
{ {
thickness = sthickness;
x[0] = sx1; x[0] = sx1;
y[0] = sy1; y[0] = sy1;
z[0] = sz1; z[0] = sz1;
@ -546,7 +522,13 @@ struct DXFLIB_EXPORT DL_SplineData
nKnots(nKnots), nKnots(nKnots),
nControl(nControl), nControl(nControl),
nFit(nFit), nFit(nFit),
flags(flags) flags(flags),
tangentStartX(0.0),
tangentStartY(0.0),
tangentStartZ(0.0),
tangentEndX(0.0),
tangentEndY(0.0),
tangentEndZ(0.0)
{ {
} }
@ -580,14 +562,14 @@ struct DXFLIB_EXPORT DL_SplineData
*/ */
struct DXFLIB_EXPORT DL_KnotData struct DXFLIB_EXPORT DL_KnotData
{ {
DL_KnotData() {} DL_KnotData() : k(0.0) {}
/** /**
* Constructor. * Constructor.
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_KnotData(double pk) DL_KnotData(double pk)
: k(pk)
{ {
k = pk;
} }
/*! Knot value. */ /*! Knot value. */
@ -606,11 +588,8 @@ struct DXFLIB_EXPORT DL_ControlPointData
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_ControlPointData(double px, double py, double pz, double weight) DL_ControlPointData(double px, double py, double pz, double weight)
: x(px), y(py), z(pz), w(weight)
{ {
x = px;
y = py;
z = pz;
w = weight;
} }
/*! X coordinate of the control point. */ /*! X coordinate of the control point. */
@ -911,7 +890,6 @@ struct DXFLIB_EXPORT DL_AttributeData : public DL_TextData
DL_AttributeData(const DL_TextData& tData, const std::string& tag) DL_AttributeData(const DL_TextData& tData, const std::string& tag)
: DL_TextData(tData), tag(tag) : DL_TextData(tData), tag(tag)
{ {
} }
/** /**
@ -1063,15 +1041,9 @@ struct DXFLIB_EXPORT DL_DimAlignedData
*/ */
DL_DimAlignedData(double depx1, double depy1, double depz1, DL_DimAlignedData(double depx1, double depy1, double depz1,
double depx2, double depy2, double depz2) double depx2, double depy2, double depz2)
{ : epx1(depx1), epy1(depy1), epz1(depz1),
epx2(depx2), epy2(depy2), epz2(depz2)
epx1 = depx1; {
epy1 = depy1;
epz1 = depz1;
epx2 = depx2;
epy2 = depy2;
epz2 = depz2;
} }
/*! X Coordinate of Extension point 1. */ /*! X Coordinate of Extension point 1. */
@ -1103,18 +1075,10 @@ struct DXFLIB_EXPORT DL_DimLinearData
DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1, DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2, double ddpx2, double ddpy2, double ddpz2,
double dAngle, double dOblique) double dAngle, double dOblique)
: dpx1(ddpx1), dpy1(ddpy1), dpz1(ddpz1),
dpx2(ddpx2), dpy2(ddpy2), dpz2(ddpz2),
angle(dAngle), oblique(dOblique)
{ {
dpx1 = ddpx1;
dpy1 = ddpy1;
dpz1 = ddpz1;
dpx2 = ddpx2;
dpy2 = ddpy2;
dpz2 = ddpz2;
angle = dAngle;
oblique = dOblique;
} }
/*! X Coordinate of Extension point 1. */ /*! X Coordinate of Extension point 1. */
@ -1149,12 +1113,8 @@ struct DXFLIB_EXPORT DL_DimRadialData
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_DimRadialData(double ddpx, double ddpy, double ddpz, double dleader) DL_DimRadialData(double ddpx, double ddpy, double ddpz, double dleader)
: dpx(ddpx), dpy(ddpy), dpz(ddpz), leader(dleader)
{ {
dpx = ddpx;
dpy = ddpy;
dpz = ddpz;
leader = dleader;
} }
/*! X Coordinate of definition point. */ /*! X Coordinate of definition point. */
@ -1180,12 +1140,8 @@ struct DXFLIB_EXPORT DL_DimDiametricData
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_DimDiametricData(double ddpx, double ddpy, double ddpz, double dleader) DL_DimDiametricData(double ddpx, double ddpy, double ddpz, double dleader)
: dpx(ddpx), dpy(ddpy), dpz(ddpz), leader(dleader)
{ {
dpx = ddpx;
dpy = ddpy;
dpz = ddpz;
leader = dleader;
} }
/*! X Coordinate of definition point (DXF 15). */ /*! X Coordinate of definition point (DXF 15). */
@ -1214,24 +1170,12 @@ struct DXFLIB_EXPORT DL_DimAngularData
double ddpx2, double ddpy2, double ddpz2, double ddpx2, double ddpy2, double ddpz2,
double ddpx3, double ddpy3, double ddpz3, double ddpx3, double ddpy3, double ddpz3,
double ddpx4, double ddpy4, double ddpz4) double ddpx4, double ddpy4, double ddpz4)
{ : dpx1(ddpx1), dpy1(ddpy1), dpz1(ddpz1),
dpx2(ddpx2), dpy2(ddpy2), dpz2(ddpz2),
dpx1 = ddpx1; dpx3(ddpx3), dpy3(ddpy3), dpz3(ddpz3),
dpy1 = ddpy1; dpx4(ddpx4), dpy4(ddpy4), dpz4(ddpz4)
dpz1 = ddpz1; {
}
dpx2 = ddpx2;
dpy2 = ddpy2;
dpz2 = ddpz2;
dpx3 = ddpx3;
dpy3 = ddpy3;
dpz3 = ddpz3;
dpx4 = ddpx4;
dpy4 = ddpy4;
dpz4 = ddpz4;
}
/*! X Coordinate of definition point 1. */ /*! X Coordinate of definition point 1. */
double dpx1; double dpx1;
@ -1275,20 +1219,11 @@ struct DXFLIB_EXPORT DL_DimAngular3PData
DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1, DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2, double ddpx2, double ddpy2, double ddpz2,
double ddpx3, double ddpy3, double ddpz3) double ddpx3, double ddpy3, double ddpz3)
{ : dpx1(ddpx1), dpy1(ddpy1), dpz1(ddpz1),
dpx2(ddpx2), dpy2(ddpy2), dpz2(ddpz2),
dpx1 = ddpx1; dpx3(ddpx3), dpy3(ddpy3), dpz3(ddpz3)
dpy1 = ddpy1; {
dpz1 = ddpz1; }
dpx2 = ddpx2;
dpy2 = ddpy2;
dpz2 = ddpz2;
dpx3 = ddpx3;
dpy3 = ddpy3;
dpz3 = ddpz3;
}
/*! X Coordinate of definition point 1. */ /*! X Coordinate of definition point 1. */
double dpx1; double dpx1;
@ -1326,17 +1261,10 @@ struct DXFLIB_EXPORT DL_DimOrdinateData
DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1, DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2, double ddpx2, double ddpy2, double ddpz2,
bool dxtype) bool dxtype)
: dpx1(ddpx1), dpy1(ddpy1), dpz1(ddpz1),
dpx2(ddpx2), dpy2(ddpy2), dpz2(ddpz2),
xtype(dxtype)
{ {
dpx1 = ddpx1;
dpy1 = ddpy1;
dpz1 = ddpz1;
dpx2 = ddpx2;
dpy2 = ddpy2;
dpz2 = ddpz2;
xtype = dxtype;
} }
/*! X Coordinate of definition point 1. */ /*! X Coordinate of definition point 1. */
@ -1376,16 +1304,15 @@ struct DXFLIB_EXPORT DL_LeaderData
double lTextAnnotationHeight, double lTextAnnotationHeight,
double lTextAnnotationWidth, double lTextAnnotationWidth,
int lNumber) int lNumber)
: arrowHeadFlag(lArrowHeadFlag),
leaderPathType(lLeaderPathType),
leaderCreationFlag(lLeaderCreationFlag),
hooklineDirectionFlag(lHooklineDirectionFlag),
hooklineFlag(lHooklineFlag),
textAnnotationHeight(lTextAnnotationHeight),
textAnnotationWidth(lTextAnnotationWidth),
number(lNumber)
{ {
arrowHeadFlag = lArrowHeadFlag;
leaderPathType = lLeaderPathType;
leaderCreationFlag = lLeaderCreationFlag;
hooklineDirectionFlag = lHooklineDirectionFlag;
hooklineFlag = lHooklineFlag;
textAnnotationHeight = lTextAnnotationHeight;
textAnnotationWidth = lTextAnnotationWidth;
number = lNumber;
} }
/*! Arrow head flag (71). */ /*! Arrow head flag (71). */
@ -1418,10 +1345,8 @@ struct DXFLIB_EXPORT DL_LeaderVertexData
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_LeaderVertexData(double px=0.0, double py=0.0, double pz=0.0) DL_LeaderVertexData(double px=0.0, double py=0.0, double pz=0.0)
: x(px), y(py), z(pz)
{ {
x = px;
y = py;
z = pz;
} }
/*! X Coordinate of the vertex. */ /*! X Coordinate of the vertex. */
@ -1442,7 +1367,8 @@ struct DXFLIB_EXPORT DL_HatchData
/** /**
* Default constructor. * Default constructor.
*/ */
DL_HatchData() {} DL_HatchData() : numLoops(0), solid(), scale(0.0), angle(0.0), pattern(), originX(0.0), originY(0.0)
{}
/** /**
* Constructor. * Constructor.
@ -1463,7 +1389,6 @@ struct DXFLIB_EXPORT DL_HatchData
originX(originX), originX(originX),
originY(originY) originY(originY)
{ {
} }
/*! Number of boundary paths (loops). */ /*! Number of boundary paths (loops). */
@ -1491,14 +1416,15 @@ struct DXFLIB_EXPORT DL_HatchLoopData
/** /**
* Default constructor. * Default constructor.
*/ */
DL_HatchLoopData() {} DL_HatchLoopData() : numEdges(0)
{}
/** /**
* Constructor. * Constructor.
* Parameters: see member variables. * Parameters: see member variables.
*/ */
DL_HatchLoopData(int hNumEdges) DL_HatchLoopData(int hNumEdges)
: numEdges(hNumEdges)
{ {
numEdges = hNumEdges;
} }
/*! Number of edges in this loop. */ /*! Number of edges in this loop. */
@ -1515,7 +1441,12 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
/** /**
* Default constructor. * Default constructor.
*/ */
DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0) DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0),
type(0), cx(0.0), cy(0.0), radius(0.0), angle1(0.0), angle2(0.0), ccw(),
mx(0.0), my(0.0), ratio(0.0), degree(0), rational(), periodic(),
nKnots(0), nControl(0), nFit(0), controlPoints(), knots(),
weights(), fitPoints(), startTangentX(0.0), startTangentY(0.0),
endTangentX(0.0), endTangentY(0.0), vertices()
{ {
} }
@ -1526,11 +1457,16 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
DL_HatchEdgeData(double x1, double y1, DL_HatchEdgeData(double x1, double y1,
double x2, double y2) : double x2, double y2) :
defined(true), defined(true),
type(1),
x1(x1), x1(x1),
y1(y1), y1(y1),
x2(x2), x2(x2),
y2(y2) y2(y2),
type(1),
cx(0.0), cy(0.0), radius(0.0), angle1(0.0), angle2(0.0), ccw(),
mx(0.0), my(0.0), ratio(0.0), degree(0), rational(), periodic(),
nKnots(0), nControl(0), nFit(0), controlPoints(), knots(),
weights(), fitPoints(), startTangentX(0.0), startTangentY(0.0),
endTangentX(0.0), endTangentY(0.0), vertices()
{ {
} }
@ -1543,13 +1479,18 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
double angle1, double angle2, double angle1, double angle2,
bool ccw) : bool ccw) :
defined(true), defined(true),
x1(), y1(), x2(), y2(),
type(2), type(2),
cx(cx), cx(cx),
cy(cy), cy(cy),
radius(radius), radius(radius),
angle1(angle1), angle1(angle1),
angle2(angle2), angle2(angle2),
ccw(ccw) ccw(ccw),
mx(0.0), my(0.0), ratio(0.0), degree(0), rational(), periodic(),
nKnots(0), nControl(0), nFit(0), controlPoints(), knots(),
weights(), fitPoints(), startTangentX(0.0), startTangentY(0.0),
endTangentX(0.0), endTangentY(0.0), vertices()
{ {
} }
@ -1563,15 +1504,21 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
double angle1, double angle2, double angle1, double angle2,
bool ccw) : bool ccw) :
defined(true), defined(true),
x1(), y1(), x2(), y2(),
type(3), type(3),
cx(cx), cx(cx),
cy(cy), cy(cy),
radius(),
angle1(angle1), angle1(angle1),
angle2(angle2), angle2(angle2),
ccw(ccw), ccw(ccw),
mx(mx), mx(mx),
my(my), my(my),
ratio(ratio) ratio(ratio),
degree(0), rational(), periodic(),
nKnots(0), nControl(0), nFit(0), controlPoints(), knots(),
weights(), fitPoints(), startTangentX(0.0), startTangentY(0.0),
endTangentX(0.0), endTangentY(0.0), vertices()
{ {
} }
@ -1594,8 +1541,10 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
double endTangentX, double endTangentX,
double endTangentY) : double endTangentY) :
defined(true), defined(true),
type(4), x1(), y1(), x2(), y2(),
degree(degree), type(4), cx(), cy(), radius(),
angle1(), angle2(), ccw(),
mx(), my(), ratio(), degree(degree),
rational(rational), rational(rational),
periodic(periodic), periodic(periodic),
nKnots(nKnots), nKnots(nKnots),
@ -1608,7 +1557,8 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
startTangentX(startTangentX), startTangentX(startTangentX),
startTangentY(startTangentY), startTangentY(startTangentY),
endTangentX(endTangentX), endTangentX(endTangentX),
endTangentY(endTangentY) endTangentY(endTangentY),
vertices()
{ {
} }
@ -1617,11 +1567,6 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
*/ */
bool defined; bool defined;
/**
* Edge type. 1=line, 2=arc, 3=elliptic arc, 4=spline.
*/
int type;
// line edges: // line edges:
/*! Start point (X). */ /*! Start point (X). */
@ -1633,6 +1578,11 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
/*! End point (Y). */ /*! End point (Y). */
double y2; double y2;
/**
* Edge type. 1=line, 2=arc, 3=elliptic arc, 4=spline.
*/
int type;
/*! Center point of arc or ellipse arc (X). */ /*! Center point of arc or ellipse arc (X). */
double cx; double cx;
/*! Center point of arc or ellipse arc (Y). */ /*! Center point of arc or ellipse arc (Y). */
@ -1698,22 +1648,13 @@ struct DXFLIB_EXPORT DL_ImageData
double ivx, double ivy, double ivz, double ivx, double ivy, double ivz,
int iwidth, int iheight, int iwidth, int iheight,
int ibrightness, int icontrast, int ifade) int ibrightness, int icontrast, int ifade)
: ref(iref),
ipx(iipx), ipy(iipy), ipz(iipz),
ux(iux), uy(iuy), uz(iuz),
vx(ivx), vy(ivy), vz(ivz),
width(iwidth), height(iheight),
brightness(ibrightness), contrast(icontrast), fade(ifade)
{ {
ref = iref;
ipx = iipx;
ipy = iipy;
ipz = iipz;
ux = iux;
uy = iuy;
uz = iuz;
vx = ivx;
vy = ivy;
vz = ivz;
width = iwidth;
height = iheight;
brightness = ibrightness;
contrast = icontrast;
fade = ifade;
} }
/*! Reference to the image file /*! Reference to the image file
@ -1762,9 +1703,8 @@ struct DXFLIB_EXPORT DL_ImageDefData
*/ */
DL_ImageDefData(const std::string& iref, DL_ImageDefData(const std::string& iref,
const std::string& ifile) const std::string& ifile)
{ : ref(iref), file(ifile)
ref = iref; {
file = ifile;
} }
/*! Reference to the image file /*! Reference to the image file

View file

@ -28,9 +28,11 @@
#include "dl_global.h" #include "dl_global.h"
#if _MSC_VER > 1000 #if defined(Q_CC_MSVC)
#pragma once #if (_MSC_VER > 1000)
#endif // _MSC_VER > 1000 #pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
/** /**
* Used for exception handling. * Used for exception handling.

View file

@ -44,11 +44,9 @@ public:
/** /**
* Default constructor. * Default constructor.
*/ */
DL_Extrusion() DL_Extrusion() : direction(new double[3]), elevation(0.0)
{ {
direction = new double[3];
setDirection(0.0, 0.0, 1.0); setDirection(0.0, 0.0, 1.0);
setElevation(0.0);
} }
@ -60,6 +58,10 @@ public:
delete[] direction ; delete[] direction ;
} }
DL_Extrusion(const DL_Extrusion &L)
: direction(L.direction), elevation(L.elevation)
{
}
/** /**
* Constructor for DXF extrusion. * Constructor for DXF extrusion.
@ -70,10 +72,9 @@ public:
* world coordinate system * world coordinate system
*/ */
DL_Extrusion(double dx, double dy, double dz, double elevation) DL_Extrusion(double dx, double dy, double dz, double elevation)
: direction(new double[3]), elevation(elevation)
{ {
direction = new double[3];
setDirection(dx, dy, dz); setDirection(dx, dy, dz);
setElevation(elevation);
} }
@ -135,8 +136,12 @@ public:
/** /**
* Copies extrusion (deep copies) from another extrusion object. * Copies extrusion (deep copies) from another extrusion object.
*/ */
DL_Extrusion operator = (const DL_Extrusion& extru) DL_Extrusion & operator = (const DL_Extrusion& extru)
{ {
if ( &extru == this )
{
return *this;
}
setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); setDirection(extru.direction[0], extru.direction[1], extru.direction[2]);
setElevation(extru.elevation); setElevation(extru.elevation);

View file

@ -32,9 +32,11 @@
#include <strings.h> #include <strings.h>
#endif #endif
#if _MSC_VER > 1000 #if defined(Q_CC_MSVC)
#pragma once #if (_MSC_VER > 1000)
#endif // _MSC_VER > 1000 #pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
@ -60,12 +62,8 @@ public:
/** /**
* @param version DXF version. Defaults to DL_VERSION_2002. * @param version DXF version. Defaults to DL_VERSION_2002.
*/ */
DL_Writer(DL_Codes::version version) : m_handle(0x30) DL_Writer(DL_Codes::version version) : m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0), version(version)
{ {
this->version = version;
modelSpaceHandle = 0;
paperSpaceHandle = 0;
paperSpace0Handle = 0;
} }
virtual ~DL_Writer() {} virtual ~DL_Writer() {}
@ -424,7 +422,7 @@ public:
} }
else else
{ {
dxfHex(5, h); dxfHex(5, static_cast<int>(h));
} }
dxfString(100, "AcDbSymbolTableRecord"); dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbLayerTableRecord"); dxfString(100, "AcDbLayerTableRecord");
@ -450,7 +448,7 @@ public:
} }
else else
{ {
dxfHex(5, h); dxfHex(5, static_cast<int>(h));
} }
//dxfHex(330, 0x5); //dxfHex(330, 0x5);
dxfString(100, "AcDbSymbolTableRecord"); dxfString(100, "AcDbSymbolTableRecord");
@ -477,7 +475,7 @@ public:
} }
else else
{ {
dxfHex(5, h); dxfHex(5, static_cast<int>(h));
} }
//dxfHex(330, 0x9); //dxfHex(330, 0x9);
dxfString(100, "AcDbSymbolTableRecord"); dxfString(100, "AcDbSymbolTableRecord");
@ -504,7 +502,7 @@ public:
} }
else else
{ {
dxfHex(5, h); dxfHex(5, static_cast<int>(h));
} }
//dxfHex(330, blockHandle); //dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity"); dxfString(100, "AcDbEntity");
@ -536,7 +534,7 @@ public:
} }
else else
{ {
dxfHex(5, h); dxfHex(5, static_cast<int>(h));
} }
//dxfHex(330, blockHandle); //dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity"); dxfString(100, "AcDbEntity");
@ -594,7 +592,7 @@ public:
unsigned long handle(int gc=5) const unsigned long handle(int gc=5) const
{ {
// handle has to be hex // handle has to be hex
dxfHex(gc, m_handle); dxfHex(gc, static_cast<int>(m_handle));
return m_handle++; return m_handle++;
} }
@ -683,7 +681,7 @@ public:
*/ */
virtual void dxfBool(int gc, bool value) const virtual void dxfBool(int gc, bool value) const
{ {
dxfInt(gc, (int)value); dxfInt(gc, static_cast<int>(value));
} }
/** /**

View file

@ -23,9 +23,11 @@
** **
**********************************************************************/ **********************************************************************/
#if _MSC_VER > 1000 #if defined(Q_CC_MSVC)
#pragma once #if (_MSC_VER > 1000)
#endif // _MSC_VER > 1000 #pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -84,7 +86,7 @@ void DL_WriterA::dxfReal(int gc, double value) const
end = i+1; end = i+1;
} }
} }
if (end>0 && end<(int)strlen(str)) if (end>0 && end<static_cast<int>(strlen(str)))
{ {
str[end] = '\0'; str[end] = '\0';
} }

View file

@ -28,9 +28,11 @@
#include "dl_global.h" #include "dl_global.h"
#if _MSC_VER > 1000 #if defined(Q_CC_MSVC)
#pragma once #if (_MSC_VER > 1000)
#endif // _MSC_VER > 1000 #pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include "dl_writer.h" #include "dl_writer.h"
#include <fstream> #include <fstream>

View file

@ -54,8 +54,8 @@ static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VDxfEngine::VDxfEngine() VDxfEngine::VDxfEngine()
:QPaintEngine(svgEngineFeatures()), :QPaintEngine(svgEngineFeatures()),
size(), resolution(PrintDPI), matrix(), varMeasurement(VarMeasurement::Metric), size(), resolution(PrintDPI), fileName(), matrix(), dxf(nullptr), dw(nullptr),
varInsunits(VarInsunits::Centimeters) varMeasurement(VarMeasurement::Metric), varInsunits(VarInsunits::Centimeters)
{ {
} }