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

View File

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

View File

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

View File

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

View File

@ -26,6 +26,7 @@
#define DL_ENTITIES_H
#include "dl_global.h"
#include "dxfdef.h"
#include <string>
#include <vector>
@ -39,11 +40,9 @@ struct DXFLIB_EXPORT DL_LayerData
* Constructor.
* Parameters: see member variables.
*/
DL_LayerData(const std::string& lName,
int lFlags)
DL_LayerData(const std::string& lName, int lFlags)
: name(lName), flags(lFlags)
{
name = lName;
flags = lFlags;
}
/** Layer name. */
@ -63,15 +62,10 @@ struct DXFLIB_EXPORT DL_BlockData
* Constructor.
* Parameters: see member variables.
*/
DL_BlockData(const std::string& bName,
int bFlags,
DL_BlockData(const std::string& bName, int bFlags,
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. */
@ -102,7 +96,7 @@ struct DXFLIB_EXPORT DL_LinetypeData
int flags,
int numberOfDashes,
double patternLength,
double* pattern = NULL
double* pattern = nullptr
)
: name(name),
description(description),
@ -110,7 +104,12 @@ struct DXFLIB_EXPORT DL_LinetypeData
numberOfDashes(numberOfDashes),
patternLength(patternLength),
pattern(pattern)
{}
{
}
~DL_LinetypeData()
{
}
/** Linetype name */
std::string name;
@ -124,6 +123,9 @@ struct DXFLIB_EXPORT DL_LinetypeData
double patternLength;
/** Pattern */
double* pattern;
private:
Q_DISABLE_COPY(DL_LinetypeData);
};
@ -167,9 +169,9 @@ struct DXFLIB_EXPORT DL_StyleData
// ignore lastHeightUsed:
return (name==other.name &&
flags==other.flags &&
fixedTextHeight==other.fixedTextHeight &&
widthFactor==other.widthFactor &&
obliqueAngle==other.obliqueAngle &&
DL_FuzzyComparePossibleNulls(fixedTextHeight, other.fixedTextHeight) &&
DL_FuzzyComparePossibleNulls(widthFactor, other.widthFactor) &&
DL_FuzzyComparePossibleNulls(obliqueAngle, other.obliqueAngle) &&
textGenerationFlags==other.textGenerationFlags &&
primaryFontFile==other.primaryFontFile &&
bigFontFile==other.bigFontFile);
@ -208,10 +210,8 @@ struct DXFLIB_EXPORT DL_PointData
* Parameters: see member variables.
*/
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. */
@ -235,14 +235,8 @@ struct DXFLIB_EXPORT DL_LineData
*/
DL_LineData(double lx1, double ly1, double lz1,
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. */
@ -336,14 +330,8 @@ struct DXFLIB_EXPORT DL_ArcData
DL_ArcData(double acx, double acy, double acz,
double aRadius,
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. */
@ -374,12 +362,8 @@ struct DXFLIB_EXPORT DL_CircleData
*/
DL_CircleData(double acx, double acy, double acz,
double aRadius)
: cx(acx), cy(acy), cz(acz), radius(aRadius)
{
cx = acx;
cy = acy;
cz = acz;
radius = aRadius;
}
/*! X Coordinate of center point. */
@ -405,11 +389,8 @@ struct DXFLIB_EXPORT DL_PolylineData
* Parameters: see member variables.
*/
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. */
@ -438,11 +419,8 @@ struct DXFLIB_EXPORT DL_VertexData
*/
DL_VertexData(double px=0.0, double py=0.0, double pz=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. */
@ -463,8 +441,8 @@ struct DXFLIB_EXPORT DL_VertexData
struct DXFLIB_EXPORT DL_TraceData
{
DL_TraceData()
: thickness(0.0)
{
thickness = 0.0;
for (int i=0; i<4; i++)
{
x[i] = 0.0;
@ -482,10 +460,8 @@ struct DXFLIB_EXPORT DL_TraceData
double sx3, double sy3, double sz3,
double sx4, double sy4, double sz4,
double sthickness=0.0)
: thickness(sthickness)
{
thickness = sthickness;
x[0] = sx1;
y[0] = sy1;
z[0] = sz1;
@ -546,7 +522,13 @@ struct DXFLIB_EXPORT DL_SplineData
nKnots(nKnots),
nControl(nControl),
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
{
DL_KnotData() {}
DL_KnotData() : k(0.0) {}
/**
* Constructor.
* Parameters: see member variables.
*/
DL_KnotData(double pk)
: k(pk)
{
k = pk;
}
/*! Knot value. */
@ -606,11 +588,8 @@ struct DXFLIB_EXPORT DL_ControlPointData
* Parameters: see member variables.
*/
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. */
@ -911,7 +890,6 @@ struct DXFLIB_EXPORT DL_AttributeData : public DL_TextData
DL_AttributeData(const DL_TextData& tData, const std::string& tag)
: DL_TextData(tData), tag(tag)
{
}
/**
@ -1063,15 +1041,9 @@ struct DXFLIB_EXPORT DL_DimAlignedData
*/
DL_DimAlignedData(double depx1, double depy1, double depz1,
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. */
@ -1103,18 +1075,10 @@ struct DXFLIB_EXPORT DL_DimLinearData
DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2,
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. */
@ -1149,12 +1113,8 @@ struct DXFLIB_EXPORT DL_DimRadialData
* Parameters: see member variables.
*/
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. */
@ -1180,12 +1140,8 @@ struct DXFLIB_EXPORT DL_DimDiametricData
* Parameters: see member variables.
*/
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). */
@ -1214,24 +1170,12 @@ struct DXFLIB_EXPORT DL_DimAngularData
double ddpx2, double ddpy2, double ddpz2,
double ddpx3, double ddpy3, double ddpz3,
double ddpx4, double ddpy4, double ddpz4)
{
dpx1 = ddpx1;
dpy1 = ddpy1;
dpz1 = ddpz1;
dpx2 = ddpx2;
dpy2 = ddpy2;
dpz2 = ddpz2;
dpx3 = ddpx3;
dpy3 = ddpy3;
dpz3 = ddpz3;
dpx4 = ddpx4;
dpy4 = ddpy4;
dpz4 = ddpz4;
}
: dpx1(ddpx1), dpy1(ddpy1), 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. */
double dpx1;
@ -1275,20 +1219,11 @@ struct DXFLIB_EXPORT DL_DimAngular3PData
DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2,
double ddpx3, double ddpy3, double ddpz3)
{
dpx1 = ddpx1;
dpy1 = ddpy1;
dpz1 = ddpz1;
dpx2 = ddpx2;
dpy2 = ddpy2;
dpz2 = ddpz2;
dpx3 = ddpx3;
dpy3 = ddpy3;
dpz3 = ddpz3;
}
: dpx1(ddpx1), dpy1(ddpy1), dpz1(ddpz1),
dpx2(ddpx2), dpy2(ddpy2), dpz2(ddpz2),
dpx3(ddpx3), dpy3(ddpy3), dpz3(ddpz3)
{
}
/*! X Coordinate of definition point 1. */
double dpx1;
@ -1326,17 +1261,10 @@ struct DXFLIB_EXPORT DL_DimOrdinateData
DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1,
double ddpx2, double ddpy2, double ddpz2,
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. */
@ -1376,16 +1304,15 @@ struct DXFLIB_EXPORT DL_LeaderData
double lTextAnnotationHeight,
double lTextAnnotationWidth,
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). */
@ -1418,10 +1345,8 @@ struct DXFLIB_EXPORT DL_LeaderVertexData
* Parameters: see member variables.
*/
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. */
@ -1442,7 +1367,8 @@ struct DXFLIB_EXPORT DL_HatchData
/**
* Default constructor.
*/
DL_HatchData() {}
DL_HatchData() : numLoops(0), solid(), scale(0.0), angle(0.0), pattern(), originX(0.0), originY(0.0)
{}
/**
* Constructor.
@ -1463,7 +1389,6 @@ struct DXFLIB_EXPORT DL_HatchData
originX(originX),
originY(originY)
{
}
/*! Number of boundary paths (loops). */
@ -1491,14 +1416,15 @@ struct DXFLIB_EXPORT DL_HatchLoopData
/**
* Default constructor.
*/
DL_HatchLoopData() {}
DL_HatchLoopData() : numEdges(0)
{}
/**
* Constructor.
* Parameters: see member variables.
*/
DL_HatchLoopData(int hNumEdges)
: numEdges(hNumEdges)
{
numEdges = hNumEdges;
}
/*! Number of edges in this loop. */
@ -1515,7 +1441,12 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
/**
* 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,
double x2, double y2) :
defined(true),
type(1),
x1(x1),
y1(y1),
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,
bool ccw) :
defined(true),
x1(), y1(), x2(), y2(),
type(2),
cx(cx),
cy(cy),
radius(radius),
angle1(angle1),
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,
bool ccw) :
defined(true),
x1(), y1(), x2(), y2(),
type(3),
cx(cx),
cy(cy),
radius(),
angle1(angle1),
angle2(angle2),
ccw(ccw),
mx(mx),
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 endTangentY) :
defined(true),
type(4),
degree(degree),
x1(), y1(), x2(), y2(),
type(4), cx(), cy(), radius(),
angle1(), angle2(), ccw(),
mx(), my(), ratio(), degree(degree),
rational(rational),
periodic(periodic),
nKnots(nKnots),
@ -1608,7 +1557,8 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
startTangentX(startTangentX),
startTangentY(startTangentY),
endTangentX(endTangentX),
endTangentY(endTangentY)
endTangentY(endTangentY),
vertices()
{
}
@ -1617,11 +1567,6 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
*/
bool defined;
/**
* Edge type. 1=line, 2=arc, 3=elliptic arc, 4=spline.
*/
int type;
// line edges:
/*! Start point (X). */
@ -1633,6 +1578,11 @@ struct DXFLIB_EXPORT DL_HatchEdgeData
/*! End point (Y). */
double y2;
/**
* Edge type. 1=line, 2=arc, 3=elliptic arc, 4=spline.
*/
int type;
/*! Center point of arc or ellipse arc (X). */
double cx;
/*! Center point of arc or ellipse arc (Y). */
@ -1698,22 +1648,13 @@ struct DXFLIB_EXPORT DL_ImageData
double ivx, double ivy, double ivz,
int iwidth, int iheight,
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
@ -1762,9 +1703,8 @@ struct DXFLIB_EXPORT DL_ImageDefData
*/
DL_ImageDefData(const std::string& iref,
const std::string& ifile)
{
ref = iref;
file = ifile;
: ref(iref), file(ifile)
{
}
/*! Reference to the image file

View File

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

View File

@ -44,11 +44,9 @@ public:
/**
* Default constructor.
*/
DL_Extrusion()
DL_Extrusion() : direction(new double[3]), elevation(0.0)
{
direction = new double[3];
setDirection(0.0, 0.0, 1.0);
setElevation(0.0);
}
@ -60,6 +58,10 @@ public:
delete[] direction ;
}
DL_Extrusion(const DL_Extrusion &L)
: direction(L.direction), elevation(L.elevation)
{
}
/**
* Constructor for DXF extrusion.
@ -70,10 +72,9 @@ public:
* world coordinate system
*/
DL_Extrusion(double dx, double dy, double dz, double elevation)
: direction(new double[3]), elevation(elevation)
{
direction = new double[3];
setDirection(dx, dy, dz);
setElevation(elevation);
}
@ -135,8 +136,12 @@ public:
/**
* 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]);
setElevation(extru.elevation);

View File

@ -32,9 +32,11 @@
#include <strings.h>
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if defined(Q_CC_MSVC)
#if (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include <iostream>
#include <algorithm>
@ -60,12 +62,8 @@ public:
/**
* @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() {}
@ -424,7 +422,7 @@ public:
}
else
{
dxfHex(5, h);
dxfHex(5, static_cast<int>(h));
}
dxfString(100, "AcDbSymbolTableRecord");
dxfString(100, "AcDbLayerTableRecord");
@ -450,7 +448,7 @@ public:
}
else
{
dxfHex(5, h);
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, 0x5);
dxfString(100, "AcDbSymbolTableRecord");
@ -477,7 +475,7 @@ public:
}
else
{
dxfHex(5, h);
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, 0x9);
dxfString(100, "AcDbSymbolTableRecord");
@ -504,7 +502,7 @@ public:
}
else
{
dxfHex(5, h);
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity");
@ -536,7 +534,7 @@ public:
}
else
{
dxfHex(5, h);
dxfHex(5, static_cast<int>(h));
}
//dxfHex(330, blockHandle);
dxfString(100, "AcDbEntity");
@ -594,7 +592,7 @@ public:
unsigned long handle(int gc=5) const
{
// handle has to be hex
dxfHex(gc, m_handle);
dxfHex(gc, static_cast<int>(m_handle));
return m_handle++;
}
@ -683,7 +681,7 @@ public:
*/
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
#pragma once
#endif // _MSC_VER > 1000
#if defined(Q_CC_MSVC)
#if (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#endif // Q_CC_MSVC
#include <stdio.h>
#include <string.h>
@ -84,7 +86,7 @@ void DL_WriterA::dxfReal(int gc, double value) const
end = i+1;
}
}
if (end>0 && end<(int)strlen(str))
if (end>0 && end<static_cast<int>(strlen(str)))
{
str[end] = '\0';
}

View File

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

View File

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