From 637baaeabb5338f9cee996b62ba6230c9dd8856f Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 18:10:42 +0300 Subject: [PATCH 01/11] Fixed warnings in Linux (_MSC_VER) --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_codes.h | 8 +++++--- src/libs/vdxf/dxflib/dl_exception.h | 8 +++++--- src/libs/vdxf/dxflib/dl_writer.h | 8 +++++--- src/libs/vdxf/dxflib/dl_writer_ascii.cpp | 8 +++++--- src/libs/vdxf/dxflib/dl_writer_ascii.h | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_codes.h b/src/libs/vdxf/dxflib/dl_codes.h index 4cd116fad..2336b3685 100644 --- a/src/libs/vdxf/dxflib/dl_codes.h +++ b/src/libs/vdxf/dxflib/dl_codes.h @@ -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) diff --git a/src/libs/vdxf/dxflib/dl_exception.h b/src/libs/vdxf/dxflib/dl_exception.h index fdca72963..506e194c8 100644 --- a/src/libs/vdxf/dxflib/dl_exception.h +++ b/src/libs/vdxf/dxflib/dl_exception.h @@ -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. diff --git a/src/libs/vdxf/dxflib/dl_writer.h b/src/libs/vdxf/dxflib/dl_writer.h index ff744ba50..882033ede 100644 --- a/src/libs/vdxf/dxflib/dl_writer.h +++ b/src/libs/vdxf/dxflib/dl_writer.h @@ -32,9 +32,11 @@ #include #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 #include diff --git a/src/libs/vdxf/dxflib/dl_writer_ascii.cpp b/src/libs/vdxf/dxflib/dl_writer_ascii.cpp index 319c34f23..f54a6fd1b 100644 --- a/src/libs/vdxf/dxflib/dl_writer_ascii.cpp +++ b/src/libs/vdxf/dxflib/dl_writer_ascii.cpp @@ -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 #include diff --git a/src/libs/vdxf/dxflib/dl_writer_ascii.h b/src/libs/vdxf/dxflib/dl_writer_ascii.h index 6f8b4f965..51686de8c 100644 --- a/src/libs/vdxf/dxflib/dl_writer_ascii.h +++ b/src/libs/vdxf/dxflib/dl_writer_ascii.h @@ -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 From 139027926e8700af8aecf0b6fe87f1da1f2fd89a Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 19:59:12 +0300 Subject: [PATCH 02/11] Fixed warnings in Linux (correct structure members initialization) --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_entities.h | 213 ++++++++--------------------- src/libs/vdxf/dxflib/dl_writer.h | 5 +- 2 files changed, 57 insertions(+), 161 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index 67c8597ff..59d9f7084 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -39,11 +39,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 +61,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. */ @@ -208,10 +201,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 +226,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 +321,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 +353,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 +380,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 +410,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 +432,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 +451,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; @@ -586,8 +553,8 @@ struct DXFLIB_EXPORT DL_KnotData * Parameters: see member variables. */ DL_KnotData(double pk) + : k(pk) { - k = pk; } /*! Knot value. */ @@ -606,11 +573,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 +875,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 +1026,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 +1060,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 +1098,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 +1125,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 +1155,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 +1204,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 +1246,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 +1289,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 +1330,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. */ @@ -1463,7 +1373,6 @@ struct DXFLIB_EXPORT DL_HatchData originX(originX), originY(originY) { - } /*! Number of boundary paths (loops). */ @@ -1497,8 +1406,8 @@ struct DXFLIB_EXPORT DL_HatchLoopData * Parameters: see member variables. */ DL_HatchLoopData(int hNumEdges) + : numEdges(hNumEdges) { - numEdges = hNumEdges; } /*! Number of edges in this loop. */ @@ -1698,22 +1607,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 +1662,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 diff --git a/src/libs/vdxf/dxflib/dl_writer.h b/src/libs/vdxf/dxflib/dl_writer.h index 882033ede..86a7f668e 100644 --- a/src/libs/vdxf/dxflib/dl_writer.h +++ b/src/libs/vdxf/dxflib/dl_writer.h @@ -62,12 +62,9 @@ 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) { this->version = version; - modelSpaceHandle = 0; - paperSpaceHandle = 0; - paperSpace0Handle = 0; } virtual ~DL_Writer() {} From 80d35507cafef3a72332cee9468403169eae90fa Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 20:49:02 +0300 Subject: [PATCH 03/11] Fixed warnings in Linux 1. correct structure members initialization 2. struct has pointer data members but has no copy constructor --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_creationinterface.h | 14 ++- src/libs/vdxf/dxflib/dl_dxf.cpp | 52 ++++++------ src/libs/vdxf/dxflib/dl_dxf.h | 94 +++++++++++++++++++++ src/libs/vdxf/dxflib/dl_entities.h | 77 ++++++++++++++--- src/libs/vdxf/dxflib/dl_extrusion.h | 10 ++- src/libs/vdxf/dxflib/dl_writer.h | 2 +- src/libs/vdxf/vdxfengine.cpp | 2 +- 7 files changed, 211 insertions(+), 40 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_creationinterface.h b/src/libs/vdxf/dxflib/dl_creationinterface.h index a824d4aa6..2c80b4f86 100644 --- a/src/libs/vdxf/dxflib/dl_creationinterface.h +++ b/src/libs/vdxf/dxflib/dl_creationinterface.h @@ -47,7 +47,7 @@ class DXFLIB_EXPORT DL_CreationInterface { public: - DL_CreationInterface() + DL_CreationInterface() : extrusion(), attributes() { extrusion = new DL_Extrusion; } @@ -56,6 +56,18 @@ public: delete extrusion; } + DL_CreationInterface(const DL_CreationInterface &L) : extrusion(L.extrusion), attributes(L.attributes) + { + } + + DL_CreationInterface & operator=(const DL_CreationInterface &L) + { + extrusion = L.extrusion; + attributes = L.attributes; + + return *this; + } + /** * Called for every code / value tuple of the DXF file. The complete DXF file * contents can be handled by the implemetation of this function. diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 3eea2dd09..0f3979320 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -41,31 +41,35 @@ * Default constructor. */ DL_Dxf::DL_Dxf() + : 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), + + polylineLayer(), 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; } diff --git a/src/libs/vdxf/dxflib/dl_dxf.h b/src/libs/vdxf/dxflib/dl_dxf.h index 32eb0c2a8..04d37cfea 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.h +++ b/src/libs/vdxf/dxflib/dl_dxf.h @@ -119,6 +119,100 @@ public: DL_Dxf(); ~DL_Dxf(); + DL_Dxf(const DL_Dxf &L) + : version(L.version), + polylineLayer(L.polylineLayer), + vertices(L.vertices), + maxVertices(L.maxVertices), + vertexIndex(L.vertexIndex), + knots(L.knots), + maxKnots(L.maxKnots), + knotIndex(L.knotIndex), + + weights(L.weights), + weightIndex(L.weightIndex), + + controlPoints(L.controlPoints), + maxControlPoints(L.maxControlPoints), + controlPointIndex(L.controlPointIndex), + + fitPoints(L.fitPoints), + maxFitPoints(L.maxFitPoints), + fitPointIndex(L.fitPointIndex), + + leaderVertices(L.leaderVertices), + maxLeaderVertices(L.maxLeaderVertices), + leaderVertexIndex(L.leaderVertexIndex), + + firstHatchLoop(L.firstHatchLoop), + hatchEdge(L.hatchEdge), + hatchEdges(L.hatchEdges), + + xRecordHandle(L.xRecordHandle), + xRecordValues(L.xRecordValues), + + groupCodeTmp(L.groupCodeTmp), + groupCode(L.groupCode), + groupValue(L.groupValue), + currentObjectType(L.currentObjectType), + settingKey(L.settingKey), + values(L.values), + firstCall(L.firstCall), + attrib(L.attrib), + libVersion(L.libVersion), + appDictionaryHandle(L.appDictionaryHandle), + styleHandleStd(L.styleHandleStd) + { + } + + DL_Dxf & operator=(const DL_Dxf &L) + { + version = L.version; + polylineLayer = L.polylineLayer; + vertices = L.vertices; + maxVertices = L.maxVertices; + vertexIndex = L.vertexIndex; + knots = L.knots; + maxKnots = L.maxKnots; + knotIndex = L.knotIndex; + + weights = L.weights; + weightIndex = L.weightIndex; + + controlPoints = L.controlPoints; + maxControlPoints = L.maxControlPoints; + controlPointIndex = L.controlPointIndex; + + fitPoints = L.fitPoints; + maxFitPoints = L.maxFitPoints; + fitPointIndex = L.fitPointIndex; + + leaderVertices = L.leaderVertices; + maxLeaderVertices = L.maxLeaderVertices; + leaderVertexIndex = L.leaderVertexIndex; + + firstHatchLoop = L.firstHatchLoop; + hatchEdge = L.hatchEdge; + hatchEdges = L.hatchEdges; + + xRecordHandle = L.xRecordHandle; + xRecordValues = L.xRecordValues; + + groupCodeTmp = L.groupCodeTmp; + groupCode = L.groupCode; + groupValue = L.groupValue; + currentObjectType = L.currentObjectType; + settingKey = L.settingKey; + values = L.values; + firstCall = L.firstCall; + attrib = L.attrib; + libVersion = L.libVersion; + appDictionaryHandle = L.appDictionaryHandle; + styleHandleStd = L.styleHandleStd; + + return *this; + } + bool in(const std::string& file, DL_CreationInterface* creationInterface); bool readDxfGroups(FILE* fp, diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index 59d9f7084..2ff99bd39 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -103,7 +103,34 @@ struct DXFLIB_EXPORT DL_LinetypeData numberOfDashes(numberOfDashes), patternLength(patternLength), pattern(pattern) - {} + { + } + + ~DL_LinetypeData() + { + } + + DL_LinetypeData(const DL_LinetypeData &L) + : name(L.name), + description(L.description), + flags(L.flags), + numberOfDashes(L.numberOfDashes), + patternLength(L.patternLength), + pattern(L.pattern) + { + } + + DL_LinetypeData & operator=(const DL_LinetypeData &L) + { + name = L.name; + description = L.description; + flags = L.flags; + numberOfDashes = L.numberOfDashes; + patternLength = L.patternLength; + pattern = L.pattern; + + return *this; + } /** Linetype name */ std::string name; @@ -513,7 +540,13 @@ struct DXFLIB_EXPORT DL_SplineData nKnots(nKnots), nControl(nControl), nFit(nFit), - flags(flags) + flags(flags), + tangentStartX(), + tangentStartY(), + tangentStartZ(), + tangentEndX(), + tangentEndY(), + tangentEndZ() { } @@ -547,7 +580,7 @@ struct DXFLIB_EXPORT DL_SplineData */ struct DXFLIB_EXPORT DL_KnotData { - DL_KnotData() {} + DL_KnotData() : k() {} /** * Constructor. * Parameters: see member variables. @@ -1352,7 +1385,8 @@ struct DXFLIB_EXPORT DL_HatchData /** * Default constructor. */ - DL_HatchData() {} + DL_HatchData() : numLoops(), solid(), scale(), angle(), pattern(), originX(), originY() + {} /** * Constructor. @@ -1400,7 +1434,7 @@ struct DXFLIB_EXPORT DL_HatchLoopData /** * Default constructor. */ - DL_HatchLoopData() {} + DL_HatchLoopData() : numEdges() {} /** * Constructor. * Parameters: see member variables. @@ -1424,7 +1458,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(), cx(), cy(), radius(), angle1(), angle2(), ccw(), + mx(), my(), ratio(), degree(), rational(), periodic(), + nKnots(), nControl(), nFit(), controlPoints(), knots(), + weights(), fitPoints(), startTangentX(), startTangentY(), + endTangentX(), endTangentY(), vertices() { } @@ -1439,7 +1478,12 @@ struct DXFLIB_EXPORT DL_HatchEdgeData x1(x1), y1(y1), x2(x2), - y2(y2) + y2(y2), + cx(), cy(), radius(), angle1(), angle2(), ccw(), + mx(), my(), ratio(), degree(), rational(), periodic(), + nKnots(), nControl(), nFit(), controlPoints(), knots(), + weights(), fitPoints(), startTangentX(), startTangentY(), + endTangentX(), endTangentY(), vertices() { } @@ -1458,7 +1502,12 @@ struct DXFLIB_EXPORT DL_HatchEdgeData radius(radius), angle1(angle1), angle2(angle2), - ccw(ccw) + ccw(ccw), + x1(), y1(), x2(), y2(), + mx(), my(), ratio(), degree(), rational(), periodic(), + nKnots(), nControl(), nFit(), controlPoints(), knots(), + weights(), fitPoints(), startTangentX(), startTangentY(), + endTangentX(), endTangentY(), vertices() { } @@ -1480,7 +1529,12 @@ struct DXFLIB_EXPORT DL_HatchEdgeData ccw(ccw), mx(mx), my(my), - ratio(ratio) + ratio(ratio), + x1(), y1(), x2(), y2(), + degree(), rational(), periodic(), radius(), + nKnots(), nControl(), nFit(), controlPoints(), knots(), + weights(), fitPoints(), startTangentX(), startTangentY(), + endTangentX(), endTangentY(), vertices() { } @@ -1517,7 +1571,10 @@ struct DXFLIB_EXPORT DL_HatchEdgeData startTangentX(startTangentX), startTangentY(startTangentY), endTangentX(endTangentX), - endTangentY(endTangentY) + endTangentY(endTangentY), + x1(), y1(), x2(), y2(), + mx(), my(), ratio(), vertices(), + cx(), cy(), radius(), angle1(), angle2(), ccw() { } diff --git a/src/libs/vdxf/dxflib/dl_extrusion.h b/src/libs/vdxf/dxflib/dl_extrusion.h index 75f6ff197..2a100c3ea 100644 --- a/src/libs/vdxf/dxflib/dl_extrusion.h +++ b/src/libs/vdxf/dxflib/dl_extrusion.h @@ -44,7 +44,7 @@ public: /** * Default constructor. */ - DL_Extrusion() + DL_Extrusion() : direction(), elevation() { direction = new double[3]; setDirection(0.0, 0.0, 1.0); @@ -60,6 +60,10 @@ public: delete[] direction ; } + DL_Extrusion(const DL_Extrusion &L) + : direction(L.direction), elevation(L.elevation) + { + } /** * Constructor for DXF extrusion. @@ -70,10 +74,10 @@ public: * world coordinate system */ DL_Extrusion(double dx, double dy, double dz, double elevation) + : direction(), elevation(elevation) { direction = new double[3]; setDirection(dx, dy, dz); - setElevation(elevation); } @@ -135,7 +139,7 @@ public: /** * Copies extrusion (deep copies) from another extrusion object. */ - DL_Extrusion operator = (const DL_Extrusion& extru) + DL_Extrusion & operator = (const DL_Extrusion& extru) { setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); setElevation(extru.elevation); diff --git a/src/libs/vdxf/dxflib/dl_writer.h b/src/libs/vdxf/dxflib/dl_writer.h index 86a7f668e..659c525c3 100644 --- a/src/libs/vdxf/dxflib/dl_writer.h +++ b/src/libs/vdxf/dxflib/dl_writer.h @@ -62,7 +62,7 @@ public: /** * @param version DXF version. Defaults to DL_VERSION_2002. */ - DL_Writer(DL_Codes::version version) : m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0) + DL_Writer(DL_Codes::version version) : m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0), version() { this->version = version; } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 23624c555..2908e31cf 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -55,7 +55,7 @@ static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() VDxfEngine::VDxfEngine() :QPaintEngine(svgEngineFeatures()), size(), resolution(PrintDPI), matrix(), varMeasurement(VarMeasurement::Metric), - varInsunits(VarInsunits::Centimeters) + varInsunits(VarInsunits::Centimeters), dw(), dxf(), fileName() { } From c3fef2abd7edaf523e03fe49714341d6b2462a59 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 20:57:50 +0300 Subject: [PATCH 04/11] Fixed warnings in Linux (old-style cast) --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_dxf.cpp | 18 +++++++++--------- src/libs/vdxf/dxflib/dl_dxf.h | 2 +- src/libs/vdxf/dxflib/dl_writer.h | 14 +++++++------- src/libs/vdxf/dxflib/dl_writer_ascii.cpp | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 0f3979320..8a21cad61 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -196,7 +196,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(toInt(groupCodeTmp)); creationInterface->processCodeValuePair(groupCode, groupValue); line+=2; @@ -222,7 +222,7 @@ bool DL_Dxf::readDxfGroups(std::stringstream& stream, DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, stream) ) { - groupCode = (unsigned int)toInt(groupCodeTmp); + groupCode = static_cast(toInt(groupCodeTmp)); line+=2; processDXFGroup(creationInterface, groupCode, groupValue); @@ -427,7 +427,7 @@ bool DL_Dxf::processDXFGroup(DL_CreationInterface* creationInterface, width, // width linetype, // linetype handle); // handle - attrib.setInPaperSpace((bool)getIntValue(67, 0)); + attrib.setInPaperSpace(static_cast(getIntValue(67, 0))); attrib.setLinetypeScale(getRealValue(48, 1.0)); creationInterface->setAttributes(attrib); @@ -2323,7 +2323,7 @@ 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(toInt(groupValue)); hatchEdge.defined = true; return true; } @@ -2356,7 +2356,7 @@ 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(toInt(groupValue)); hatchEdge.defined = true; return true; } @@ -2731,7 +2731,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(data.number)); dw.dxfInt(70, data.flags); } else @@ -3814,7 +3814,7 @@ void DL_Dxf::writeHatch1(DL_WriterA& dw, { dw.dxfString(2, "SOLID"); } - dw.dxfInt(70, (int)data.solid); + dw.dxfInt(70, static_cast(data.solid)); dw.dxfInt(71, 0); // non-associative dw.dxfInt(91, data.numLoops); } @@ -3931,7 +3931,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((data.ccw))); break; // ellipse arc: @@ -3943,7 +3943,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((data.ccw))); break; // spline: diff --git a/src/libs/vdxf/dxflib/dl_dxf.h b/src/libs/vdxf/dxflib/dl_dxf.h index 04d37cfea..f2b5383e2 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.h +++ b/src/libs/vdxf/dxflib/dl_dxf.h @@ -516,7 +516,7 @@ public: bool toBool(const std::string& str) { char* p; - return (bool)strtol(str.c_str(), &p, 10); + return static_cast(strtol(str.c_str(), &p, 10)); } std::string getStringValue(int code, const std::string& def) diff --git a/src/libs/vdxf/dxflib/dl_writer.h b/src/libs/vdxf/dxflib/dl_writer.h index 659c525c3..85c3ac562 100644 --- a/src/libs/vdxf/dxflib/dl_writer.h +++ b/src/libs/vdxf/dxflib/dl_writer.h @@ -423,7 +423,7 @@ public: } else { - dxfHex(5, h); + dxfHex(5, static_cast(h)); } dxfString(100, "AcDbSymbolTableRecord"); dxfString(100, "AcDbLayerTableRecord"); @@ -449,7 +449,7 @@ public: } else { - dxfHex(5, h); + dxfHex(5, static_cast(h)); } //dxfHex(330, 0x5); dxfString(100, "AcDbSymbolTableRecord"); @@ -476,7 +476,7 @@ public: } else { - dxfHex(5, h); + dxfHex(5, static_cast(h)); } //dxfHex(330, 0x9); dxfString(100, "AcDbSymbolTableRecord"); @@ -503,7 +503,7 @@ public: } else { - dxfHex(5, h); + dxfHex(5, static_cast(h)); } //dxfHex(330, blockHandle); dxfString(100, "AcDbEntity"); @@ -535,7 +535,7 @@ public: } else { - dxfHex(5, h); + dxfHex(5, static_cast(h)); } //dxfHex(330, blockHandle); dxfString(100, "AcDbEntity"); @@ -593,7 +593,7 @@ public: unsigned long handle(int gc=5) const { // handle has to be hex - dxfHex(gc, m_handle); + dxfHex(gc, static_cast(m_handle)); return m_handle++; } @@ -682,7 +682,7 @@ public: */ virtual void dxfBool(int gc, bool value) const { - dxfInt(gc, (int)value); + dxfInt(gc, static_cast(value)); } /** diff --git a/src/libs/vdxf/dxflib/dl_writer_ascii.cpp b/src/libs/vdxf/dxflib/dl_writer_ascii.cpp index f54a6fd1b..f52596e80 100644 --- a/src/libs/vdxf/dxflib/dl_writer_ascii.cpp +++ b/src/libs/vdxf/dxflib/dl_writer_ascii.cpp @@ -86,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(strlen(str))) { str[end] = '\0'; } From 418a7ab57fcf7438180f25bb1f50cedd9780b392 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 21:00:58 +0300 Subject: [PATCH 05/11] Fixed warnings in Linux (default statement in switch case) --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_dxf.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 8a21cad61..f8ec8a9ae 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -2277,6 +2277,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.defined = true; } return true; + default: + return true; } } else @@ -2299,6 +2301,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.y2 = toReal(groupValue); hatchEdge.defined = true; return true; + default: + return true; } } @@ -2326,6 +2330,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.ccw = static_cast(toInt(groupValue)); hatchEdge.defined = true; return true; + default: + return true; } } @@ -2359,6 +2365,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.ccw = static_cast(toInt(groupValue)); hatchEdge.defined = true; return true; + default: + return true; } } @@ -2439,6 +2447,8 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) case 23: hatchEdge.endTangentY = toReal(groupValue); return true; + default: + return true; } } } @@ -2602,6 +2612,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..) From 1eaf5055a712372261f9cb26c46e7a2422720809 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 21:06:31 +0300 Subject: [PATCH 06/11] Fixed warnings in Linux (correct order of variables) --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_creationinterface.h | 2 +- src/libs/vdxf/dxflib/dl_dxf.cpp | 3 ++- src/libs/vdxf/dxflib/dl_entities.h | 29 +++++++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_creationinterface.h b/src/libs/vdxf/dxflib/dl_creationinterface.h index 2c80b4f86..f2ad0c1b0 100644 --- a/src/libs/vdxf/dxflib/dl_creationinterface.h +++ b/src/libs/vdxf/dxflib/dl_creationinterface.h @@ -378,8 +378,8 @@ public: } protected: - DL_Attributes attributes; DL_Extrusion *extrusion; + DL_Attributes attributes; }; #endif diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index f8ec8a9ae..5b5ba7ffd 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -42,6 +42,7 @@ */ DL_Dxf::DL_Dxf() : version(DL_VERSION_2000), + polylineLayer(), vertices(NULL), maxVertices(0), vertexIndex(0), @@ -65,7 +66,7 @@ DL_Dxf::DL_Dxf() maxLeaderVertices(0), leaderVertexIndex(0), - polylineLayer(), firstHatchLoop(), hatchEdge(), hatchEdges(), + firstHatchLoop(), hatchEdge(), hatchEdges(), xRecordHandle(), xRecordValues(), groupCodeTmp(), groupCode(), groupValue(), currentObjectType(), settingKey(), values(), firstCall(), attrib(), libVersion(), appDictionaryHandle(), styleHandleStd() diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index 2ff99bd39..fb546cbb9 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -1474,11 +1474,11 @@ 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), + type(1), cx(), cy(), radius(), angle1(), angle2(), ccw(), mx(), my(), ratio(), degree(), rational(), periodic(), nKnots(), nControl(), nFit(), controlPoints(), knots(), @@ -1496,6 +1496,7 @@ struct DXFLIB_EXPORT DL_HatchEdgeData double angle1, double angle2, bool ccw) : defined(true), + x1(), y1(), x2(), y2(), type(2), cx(cx), cy(cy), @@ -1503,7 +1504,6 @@ struct DXFLIB_EXPORT DL_HatchEdgeData angle1(angle1), angle2(angle2), ccw(ccw), - x1(), y1(), x2(), y2(), mx(), my(), ratio(), degree(), rational(), periodic(), nKnots(), nControl(), nFit(), controlPoints(), knots(), weights(), fitPoints(), startTangentX(), startTangentY(), @@ -1521,17 +1521,18 @@ 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), - x1(), y1(), x2(), y2(), - degree(), rational(), periodic(), radius(), + degree(), rational(), periodic(), nKnots(), nControl(), nFit(), controlPoints(), knots(), weights(), fitPoints(), startTangentX(), startTangentY(), endTangentX(), endTangentY(), vertices() @@ -1557,8 +1558,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), @@ -1572,9 +1575,7 @@ struct DXFLIB_EXPORT DL_HatchEdgeData startTangentY(startTangentY), endTangentX(endTangentX), endTangentY(endTangentY), - x1(), y1(), x2(), y2(), - mx(), my(), ratio(), vertices(), - cx(), cy(), radius(), angle1(), angle2(), ccw() + vertices() { } @@ -1583,11 +1584,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). */ @@ -1599,6 +1595,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). */ From 92a7f21621e27d026cf7a7fc52ea9f69c32a24f6 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 30 Sep 2015 21:10:13 +0300 Subject: [PATCH 07/11] Fixed warnings in Linux 1. fixed old-style cast 2. correct order of variables --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_dxf.cpp | 32 ++++++++++++++++---------------- src/libs/vdxf/dxflib/dl_dxf.h | 2 +- src/libs/vdxf/vdxfengine.cpp | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index 5b5ba7ffd..f6f2ff402 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -327,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(strlen(*s) - 1); // Is last character CR or LF? while ( (lastChar >= 0) && @@ -2181,7 +2181,7 @@ void DL_Dxf::addHatch(DL_CreationInterface* creationInterface) for (unsigned int i=0; iaddHatchLoop(DL_HatchLoopData(hatchEdges[i].size())); + creationInterface->addHatchLoop(DL_HatchLoopData(static_cast(hatchEdges[i].size()))); for (unsigned int k=0; kaddHatchEdge(DL_HatchEdgeData(hatchEdges[i][k])); @@ -3143,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(data.text.length()); char chunk[251]; int i; for (i=250; i(data.linearFactor)); dw.dxfString(1002, "}"); } } @@ -4052,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(dw.incHandle()); dw.dxfHex(340, handle); // flags @@ -4687,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(styleHandleStd)); //dw.dxfHex(340, 0x11); } // * / @@ -4818,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(dw.handle(350)); //int acDbVariableDictionaryHandle = dw.getNextHandle(); //dw.dxfHex(350, acDbVariableDictionaryHandle); //dw.incHandle(); @@ -5120,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(dw.getNextHandle()+1)); // 2E dw.dxfString( 3, "HIDETEXT"); //dw.dxfHex(350, 0x2E); - dw.dxfHex(350, dw.getNextHandle()); // 2D + dw.dxfHex(350, static_cast(dw.getNextHandle())); // 2D dw.dxfString( 0, "DICTIONARYVAR"); @@ -5148,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(appDictionaryHandle)); dw.dxfString(100, "AcDbDictionary"); dw.dxfInt(281, 1); } @@ -5156,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(dw.getNextHandle()); dw.dxfHex(350, handle); dw.incHandle(); return handle; @@ -5166,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(appDictionaryHandle)); dw.dxfString(100, "AcDbXrecord"); dw.dxfInt(280, 1); dw.dxfInt(90, value); @@ -5176,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(appDictionaryHandle)); dw.dxfString(100, "AcDbXrecord"); dw.dxfInt(280, 1); dw.dxfReal(40, value); @@ -5186,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(appDictionaryHandle)); dw.dxfString(100, "AcDbXrecord"); dw.dxfInt(280, 1); dw.dxfBool(290, value); @@ -5196,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(appDictionaryHandle)); dw.dxfString(100, "AcDbXrecord"); dw.dxfInt(280, 1); dw.dxfString(1000, value); @@ -5830,7 +5830,7 @@ int DL_Dxf::getLibVersion(const std::string& str) if (idx>=2) { - d[3] = str.length(); + d[3] = static_cast(str.length()); v[0] = str.substr(0, d[0]); v[1] = str.substr(d[0]+1, d[1]-d[0]-1); diff --git a/src/libs/vdxf/dxflib/dl_dxf.h b/src/libs/vdxf/dxflib/dl_dxf.h index f2b5383e2..f9a2d3456 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.h +++ b/src/libs/vdxf/dxflib/dl_dxf.h @@ -510,7 +510,7 @@ public: int toInt(const std::string& str) { char* p; - return strtol(str.c_str(), &p, 10); + return static_cast(strtol(str.c_str(), &p, 10)); } bool toBool(const std::string& str) diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 2908e31cf..1256fe05e 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -54,8 +54,8 @@ static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() //--------------------------------------------------------------------------------------------------------------------- VDxfEngine::VDxfEngine() :QPaintEngine(svgEngineFeatures()), - size(), resolution(PrintDPI), matrix(), varMeasurement(VarMeasurement::Metric), - varInsunits(VarInsunits::Centimeters), dw(), dxf(), fileName() + size(), resolution(PrintDPI), fileName(), matrix(), dxf(), dw(), + varMeasurement(VarMeasurement::Metric), varInsunits(VarInsunits::Centimeters) { } From 15834562af0effc612f364f541daf8cdc489794e Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Thu, 1 Oct 2015 05:05:21 +0300 Subject: [PATCH 08/11] Fixed warnings in Linux --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_creationinterface.h | 5 ++- src/libs/vdxf/dxflib/dl_dxf.cpp | 46 ++++++++++----------- src/libs/vdxf/dxflib/dl_dxf.h | 5 ++- src/libs/vdxf/dxflib/dl_entities.h | 9 ++-- src/libs/vdxf/dxflib/dl_extrusion.h | 5 ++- 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_creationinterface.h b/src/libs/vdxf/dxflib/dl_creationinterface.h index f2ad0c1b0..e5c980eea 100644 --- a/src/libs/vdxf/dxflib/dl_creationinterface.h +++ b/src/libs/vdxf/dxflib/dl_creationinterface.h @@ -65,7 +65,10 @@ public: extrusion = L.extrusion; attributes = L.attributes; - return *this; + if ( &L == this ) + { + return *this; + } } /** diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index f6f2ff402..c25dc359f 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -43,26 +43,26 @@ DL_Dxf::DL_Dxf() : version(DL_VERSION_2000), polylineLayer(), - vertices(NULL), + vertices(nullptr), maxVertices(0), vertexIndex(0), - knots(NULL), + knots(nullptr), maxKnots(0), knotIndex(0), - weights(NULL), + weights(nullptr), weightIndex(0), - controlPoints(NULL), + controlPoints(nullptr), maxControlPoints(0), controlPointIndex(0), - fitPoints(NULL), + fitPoints(nullptr), maxFitPoints(0), fitPointIndex(0), - leaderVertices(NULL), + leaderVertices(nullptr), maxLeaderVertices(0), leaderVertexIndex(0), @@ -80,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; } @@ -1617,7 +1617,7 @@ bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* /*creationInterface*/) maxVertices = toInt(groupValue); if (maxVertices>0) { - if (vertices!=NULL) + if (vertices!=nullptr) { delete[] vertices; } @@ -1673,7 +1673,7 @@ bool DL_Dxf::handleSplineData(DL_CreationInterface* /*creationInterface*/) maxKnots = toInt(groupValue); if (maxKnots>0) { - if (knots!=NULL) + if (knots!=nullptr) { delete[] knots; } @@ -1693,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; } @@ -1722,7 +1722,7 @@ bool DL_Dxf::handleSplineData(DL_CreationInterface* /*creationInterface*/) maxFitPoints = toInt(groupValue); if (maxFitPoints>0) { - if (fitPoints!=NULL) + if (fitPoints!=nullptr) { delete[] fitPoints; } @@ -1812,7 +1812,7 @@ bool DL_Dxf::handleLeaderData(DL_CreationInterface* /*creationInterface*/) maxLeaderVertices = toInt(groupValue); if (maxLeaderVertices>0) { - if (leaderVertices!=NULL) + if (leaderVertices!=nullptr) { delete[] leaderVertices; } @@ -2279,7 +2279,7 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) } return true; default: - return true; + return false; } } else @@ -2303,7 +2303,7 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.defined = true; return true; default: - return true; + return false; } } @@ -2332,7 +2332,7 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.defined = true; return true; default: - return true; + return false; } } @@ -2367,7 +2367,7 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.defined = true; return true; default: - return true; + return false; } } @@ -2449,7 +2449,7 @@ bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) hatchEdge.endTangentY = toReal(groupValue); return true; default: - return true; + return false; } } } diff --git a/src/libs/vdxf/dxflib/dl_dxf.h b/src/libs/vdxf/dxflib/dl_dxf.h index f9a2d3456..460b5e61b 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.h +++ b/src/libs/vdxf/dxflib/dl_dxf.h @@ -210,7 +210,10 @@ public: appDictionaryHandle = L.appDictionaryHandle; styleHandleStd = L.styleHandleStd; - return *this; + if ( &L == this ) + { + return *this; + } } bool in(const std::string& file, diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index fb546cbb9..83a188e31 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -95,7 +95,7 @@ struct DXFLIB_EXPORT DL_LinetypeData int flags, int numberOfDashes, double patternLength, - double* pattern = NULL + double* pattern = nullptr ) : name(name), description(description), @@ -129,7 +129,10 @@ struct DXFLIB_EXPORT DL_LinetypeData patternLength = L.patternLength; pattern = L.pattern; - return *this; + if ( &L == this ) + { + return *this; + } } /** Linetype name */ @@ -1279,7 +1282,7 @@ 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), + : dpx1(ddpx1), dpy1(ddpy1), dpz1(ddpz1), dpx2(ddpx2), dpy2(ddpy2), dpz2(ddpz2), xtype(dxtype) { diff --git a/src/libs/vdxf/dxflib/dl_extrusion.h b/src/libs/vdxf/dxflib/dl_extrusion.h index 2a100c3ea..3e6c78b78 100644 --- a/src/libs/vdxf/dxflib/dl_extrusion.h +++ b/src/libs/vdxf/dxflib/dl_extrusion.h @@ -144,7 +144,10 @@ public: setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); setElevation(extru.elevation); - return *this; + if ( &extru == this ) + { + return *this; + } } From c298be342db0171bff8f86761560ee20ea7e6347 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Thu, 1 Oct 2015 18:48:25 +0300 Subject: [PATCH 09/11] Q_DISABLE_COPY instead copy constructor --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_creationinterface.h | 18 +--- src/libs/vdxf/dxflib/dl_dxf.h | 98 +-------------------- src/libs/vdxf/dxflib/dl_entities.h | 76 ++++++---------- 3 files changed, 31 insertions(+), 161 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_creationinterface.h b/src/libs/vdxf/dxflib/dl_creationinterface.h index e5c980eea..fa7d0688c 100644 --- a/src/libs/vdxf/dxflib/dl_creationinterface.h +++ b/src/libs/vdxf/dxflib/dl_creationinterface.h @@ -56,21 +56,6 @@ public: delete extrusion; } - DL_CreationInterface(const DL_CreationInterface &L) : extrusion(L.extrusion), attributes(L.attributes) - { - } - - DL_CreationInterface & operator=(const DL_CreationInterface &L) - { - extrusion = L.extrusion; - attributes = L.attributes; - - if ( &L == this ) - { - return *this; - } - } - /** * Called for every code / value tuple of the DXF file. The complete DXF file * contents can be handled by the implemetation of this function. @@ -380,6 +365,9 @@ public: return extrusion; } +private: + Q_DISABLE_COPY(DL_CreationInterface); + protected: DL_Extrusion *extrusion; DL_Attributes attributes; diff --git a/src/libs/vdxf/dxflib/dl_dxf.h b/src/libs/vdxf/dxflib/dl_dxf.h index 460b5e61b..80dba39ef 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.h +++ b/src/libs/vdxf/dxflib/dl_dxf.h @@ -119,103 +119,6 @@ public: DL_Dxf(); ~DL_Dxf(); - DL_Dxf(const DL_Dxf &L) - : version(L.version), - polylineLayer(L.polylineLayer), - vertices(L.vertices), - maxVertices(L.maxVertices), - vertexIndex(L.vertexIndex), - knots(L.knots), - maxKnots(L.maxKnots), - knotIndex(L.knotIndex), - - weights(L.weights), - weightIndex(L.weightIndex), - - controlPoints(L.controlPoints), - maxControlPoints(L.maxControlPoints), - controlPointIndex(L.controlPointIndex), - - fitPoints(L.fitPoints), - maxFitPoints(L.maxFitPoints), - fitPointIndex(L.fitPointIndex), - - leaderVertices(L.leaderVertices), - maxLeaderVertices(L.maxLeaderVertices), - leaderVertexIndex(L.leaderVertexIndex), - - firstHatchLoop(L.firstHatchLoop), - hatchEdge(L.hatchEdge), - hatchEdges(L.hatchEdges), - - xRecordHandle(L.xRecordHandle), - xRecordValues(L.xRecordValues), - - groupCodeTmp(L.groupCodeTmp), - groupCode(L.groupCode), - groupValue(L.groupValue), - currentObjectType(L.currentObjectType), - settingKey(L.settingKey), - values(L.values), - firstCall(L.firstCall), - attrib(L.attrib), - libVersion(L.libVersion), - appDictionaryHandle(L.appDictionaryHandle), - styleHandleStd(L.styleHandleStd) - { - } - - DL_Dxf & operator=(const DL_Dxf &L) - { - version = L.version; - polylineLayer = L.polylineLayer; - vertices = L.vertices; - maxVertices = L.maxVertices; - vertexIndex = L.vertexIndex; - knots = L.knots; - maxKnots = L.maxKnots; - knotIndex = L.knotIndex; - - weights = L.weights; - weightIndex = L.weightIndex; - - controlPoints = L.controlPoints; - maxControlPoints = L.maxControlPoints; - controlPointIndex = L.controlPointIndex; - - fitPoints = L.fitPoints; - maxFitPoints = L.maxFitPoints; - fitPointIndex = L.fitPointIndex; - - leaderVertices = L.leaderVertices; - maxLeaderVertices = L.maxLeaderVertices; - leaderVertexIndex = L.leaderVertexIndex; - - firstHatchLoop = L.firstHatchLoop; - hatchEdge = L.hatchEdge; - hatchEdges = L.hatchEdges; - - xRecordHandle = L.xRecordHandle; - xRecordValues = L.xRecordValues; - - groupCodeTmp = L.groupCodeTmp; - groupCode = L.groupCode; - groupValue = L.groupValue; - currentObjectType = L.currentObjectType; - settingKey = L.settingKey; - values = L.values; - firstCall = L.firstCall; - attrib = L.attrib; - libVersion = L.libVersion; - appDictionaryHandle = L.appDictionaryHandle; - styleHandleStd = L.styleHandleStd; - - if ( &L == this ) - { - return *this; - } - } - bool in(const std::string& file, DL_CreationInterface* creationInterface); bool readDxfGroups(FILE* fp, @@ -554,6 +457,7 @@ public: } private: + Q_DISABLE_COPY(DL_Dxf); DL_Codes::version version; std::string polylineLayer; diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index 83a188e31..2e2f01325 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -110,31 +110,6 @@ struct DXFLIB_EXPORT DL_LinetypeData { } - DL_LinetypeData(const DL_LinetypeData &L) - : name(L.name), - description(L.description), - flags(L.flags), - numberOfDashes(L.numberOfDashes), - patternLength(L.patternLength), - pattern(L.pattern) - { - } - - DL_LinetypeData & operator=(const DL_LinetypeData &L) - { - name = L.name; - description = L.description; - flags = L.flags; - numberOfDashes = L.numberOfDashes; - patternLength = L.patternLength; - pattern = L.pattern; - - if ( &L == this ) - { - return *this; - } - } - /** Linetype name */ std::string name; /** Linetype description */ @@ -147,6 +122,9 @@ struct DXFLIB_EXPORT DL_LinetypeData double patternLength; /** Pattern */ double* pattern; + +private: + Q_DISABLE_COPY(DL_LinetypeData); }; @@ -544,12 +522,12 @@ struct DXFLIB_EXPORT DL_SplineData nControl(nControl), nFit(nFit), flags(flags), - tangentStartX(), - tangentStartY(), - tangentStartZ(), - tangentEndX(), - tangentEndY(), - tangentEndZ() + tangentStartX(0.0), + tangentStartY(0.0), + tangentStartZ(0.0), + tangentEndX(0.0), + tangentEndY(0.0), + tangentEndZ(0.0) { } @@ -1462,11 +1440,11 @@ struct DXFLIB_EXPORT DL_HatchEdgeData * Default constructor. */ DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0), - type(), cx(), cy(), radius(), angle1(), angle2(), ccw(), - mx(), my(), ratio(), degree(), rational(), periodic(), - nKnots(), nControl(), nFit(), controlPoints(), knots(), - weights(), fitPoints(), startTangentX(), startTangentY(), - endTangentX(), endTangentY(), vertices() + 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() { } @@ -1482,11 +1460,11 @@ struct DXFLIB_EXPORT DL_HatchEdgeData x2(x2), y2(y2), type(1), - cx(), cy(), radius(), angle1(), angle2(), ccw(), - mx(), my(), ratio(), degree(), rational(), periodic(), - nKnots(), nControl(), nFit(), controlPoints(), knots(), - weights(), fitPoints(), startTangentX(), startTangentY(), - endTangentX(), endTangentY(), vertices() + 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() { } @@ -1507,10 +1485,10 @@ struct DXFLIB_EXPORT DL_HatchEdgeData angle1(angle1), angle2(angle2), ccw(ccw), - mx(), my(), ratio(), degree(), rational(), periodic(), - nKnots(), nControl(), nFit(), controlPoints(), knots(), - weights(), fitPoints(), startTangentX(), startTangentY(), - endTangentX(), endTangentY(), vertices() + 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() { } @@ -1535,10 +1513,10 @@ struct DXFLIB_EXPORT DL_HatchEdgeData mx(mx), my(my), ratio(ratio), - degree(), rational(), periodic(), - nKnots(), nControl(), nFit(), controlPoints(), knots(), - weights(), fitPoints(), startTangentX(), startTangentY(), - endTangentX(), endTangentY(), vertices() + 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() { } From 55ab727d783291dc7603145e7fde2ab4861d437e Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 2 Oct 2015 04:07:07 +0300 Subject: [PATCH 10/11] Correct structure members initialization --HG-- branch : feature --- src/libs/vdxf/dxflib/dl_creationinterface.h | 3 +-- src/libs/vdxf/dxflib/dl_entities.h | 7 ++++--- src/libs/vdxf/dxflib/dl_extrusion.h | 14 ++++++-------- src/libs/vdxf/dxflib/dl_writer.h | 3 +-- src/libs/vdxf/vdxfengine.cpp | 2 +- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/libs/vdxf/dxflib/dl_creationinterface.h b/src/libs/vdxf/dxflib/dl_creationinterface.h index fa7d0688c..7683d76c6 100644 --- a/src/libs/vdxf/dxflib/dl_creationinterface.h +++ b/src/libs/vdxf/dxflib/dl_creationinterface.h @@ -47,9 +47,8 @@ class DXFLIB_EXPORT DL_CreationInterface { public: - DL_CreationInterface() : extrusion(), attributes() + DL_CreationInterface() : extrusion(new DL_Extrusion), attributes() { - extrusion = new DL_Extrusion; } virtual ~DL_CreationInterface() { diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index 2e2f01325..84c09b2ed 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -561,7 +561,7 @@ struct DXFLIB_EXPORT DL_SplineData */ struct DXFLIB_EXPORT DL_KnotData { - DL_KnotData() : k() {} + DL_KnotData() : k(0.0) {} /** * Constructor. * Parameters: see member variables. @@ -1366,7 +1366,7 @@ struct DXFLIB_EXPORT DL_HatchData /** * Default constructor. */ - DL_HatchData() : numLoops(), solid(), scale(), angle(), pattern(), originX(), originY() + DL_HatchData() : numLoops(0), solid(), scale(0.0), angle(0.0), pattern(), originX(0.0), originY(0.0) {} /** @@ -1415,7 +1415,8 @@ struct DXFLIB_EXPORT DL_HatchLoopData /** * Default constructor. */ - DL_HatchLoopData() : numEdges() {} + DL_HatchLoopData() : numEdges(0) + {} /** * Constructor. * Parameters: see member variables. diff --git a/src/libs/vdxf/dxflib/dl_extrusion.h b/src/libs/vdxf/dxflib/dl_extrusion.h index 3e6c78b78..0f1ab9790 100644 --- a/src/libs/vdxf/dxflib/dl_extrusion.h +++ b/src/libs/vdxf/dxflib/dl_extrusion.h @@ -44,11 +44,9 @@ public: /** * Default constructor. */ - DL_Extrusion() : direction(), elevation() + DL_Extrusion() : direction(new double[3]), elevation(0.0) { - direction = new double[3]; setDirection(0.0, 0.0, 1.0); - setElevation(0.0); } @@ -74,9 +72,8 @@ public: * world coordinate system */ DL_Extrusion(double dx, double dy, double dz, double elevation) - : direction(), elevation(elevation) + : direction(new double[3]), elevation(elevation) { - direction = new double[3]; setDirection(dx, dy, dz); } @@ -141,13 +138,14 @@ public: */ DL_Extrusion & operator = (const DL_Extrusion& extru) { - setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); - setElevation(extru.elevation); - if ( &extru == this ) { return *this; } + setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); + setElevation(extru.elevation); + + return *this; } diff --git a/src/libs/vdxf/dxflib/dl_writer.h b/src/libs/vdxf/dxflib/dl_writer.h index 85c3ac562..00515fded 100644 --- a/src/libs/vdxf/dxflib/dl_writer.h +++ b/src/libs/vdxf/dxflib/dl_writer.h @@ -62,9 +62,8 @@ public: /** * @param version DXF version. Defaults to DL_VERSION_2002. */ - DL_Writer(DL_Codes::version version) : m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0), version() + DL_Writer(DL_Codes::version version) : m_handle(0x30), modelSpaceHandle(0), paperSpaceHandle(0), paperSpace0Handle(0), version(version) { - this->version = version; } virtual ~DL_Writer() {} diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 1256fe05e..e4701a115 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -54,7 +54,7 @@ static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() //--------------------------------------------------------------------------------------------------------------------- VDxfEngine::VDxfEngine() :QPaintEngine(svgEngineFeatures()), - size(), resolution(PrintDPI), fileName(), matrix(), dxf(), dw(), + size(), resolution(PrintDPI), fileName(), matrix(), dxf(nullptr), dw(nullptr), varMeasurement(VarMeasurement::Metric), varInsunits(VarInsunits::Centimeters) { } From 0b16f5acf0af5e0eebfdf926994a12afcb80fceb Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 2 Oct 2015 05:46:10 +0300 Subject: [PATCH 11/11] Fixed "comparing floating point with == is unsafe" --HG-- branch : feature --- src/libs/vdxf/dxfdef.h | 16 ++++++++++++++++ src/libs/vdxf/dxflib/dl_dxf.cpp | 6 +++--- src/libs/vdxf/dxflib/dl_entities.h | 7 ++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/libs/vdxf/dxfdef.h b/src/libs/vdxf/dxfdef.h index b92073651..d9cc7a44b 100644 --- a/src/libs/vdxf/dxfdef.h +++ b/src/libs/vdxf/dxfdef.h @@ -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 diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index c25dc359f..7ce27f418 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -3089,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); } @@ -3104,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); diff --git a/src/libs/vdxf/dxflib/dl_entities.h b/src/libs/vdxf/dxflib/dl_entities.h index 84c09b2ed..e9e871be0 100644 --- a/src/libs/vdxf/dxflib/dl_entities.h +++ b/src/libs/vdxf/dxflib/dl_entities.h @@ -26,6 +26,7 @@ #define DL_ENTITIES_H #include "dl_global.h" +#include "dxfdef.h" #include #include @@ -168,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);