From 1726b55339d5198e8c0747edbb237d6d7a30c61b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 5 Jul 2017 19:35:34 +0300 Subject: [PATCH] GCC warnings. --HG-- branch : develop --- common.pri | 4 +- src/app/tape/dialogs/dialogmdatabase.h | 4 +- src/app/tape/dialogs/dialognewmeasurements.h | 2 +- src/app/valentina/core/vapplication.cpp | 2 +- .../valentina/dialogs/dialoglayoutprogress.h | 2 +- src/libs/qmuparser/qmuparserbase.cpp | 8 +- src/libs/qmuparser/qmuparsercallback.cpp | 4 +- src/libs/qmuparser/qmuparsertest.cpp | 8 +- src/libs/qmuparser/qmuparsertoken.h | 22 +- src/libs/qmuparser/qmuparsertokenreader.cpp | 2 +- src/libs/qmuparser/qmutranslation.h | 5 +- src/libs/vdxf/dxiface.h | 46 +- src/libs/vdxf/libdxfrw/drw_base.h | 166 +++-- src/libs/vdxf/libdxfrw/drw_classes.h | 17 +- src/libs/vdxf/libdxfrw/drw_entities.cpp | 57 +- src/libs/vdxf/libdxfrw/drw_entities.h | 627 ++++++++++++------ src/libs/vdxf/libdxfrw/drw_header.cpp | 22 +- src/libs/vdxf/libdxfrw/drw_header.h | 37 +- src/libs/vdxf/libdxfrw/drw_objects.cpp | 13 +- src/libs/vdxf/libdxfrw/drw_objects.h | 197 +++++- src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp | 18 +- .../vdxf/libdxfrw/intern/drw_textcodec.cpp | 9 +- src/libs/vdxf/libdxfrw/intern/drw_textcodec.h | 2 + src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp | 112 ++-- src/libs/vdxf/libdxfrw/intern/dwgbuffer.h | 29 +- src/libs/vdxf/libdxfrw/intern/dwgreader.cpp | 16 +- src/libs/vdxf/libdxfrw/intern/dwgreader.h | 104 ++- src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp | 15 +- src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp | 46 +- src/libs/vdxf/libdxfrw/intern/dwgreader18.h | 19 +- src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp | 55 +- src/libs/vdxf/libdxfrw/intern/dwgreader21.h | 20 +- src/libs/vdxf/libdxfrw/intern/dwgreader24.h | 6 +- src/libs/vdxf/libdxfrw/intern/dwgreader27.h | 6 +- src/libs/vdxf/libdxfrw/intern/dwgutil.cpp | 6 +- src/libs/vdxf/libdxfrw/intern/dwgutil.h | 12 +- src/libs/vdxf/libdxfrw/intern/dxfreader.cpp | 14 +- src/libs/vdxf/libdxfrw/intern/dxfreader.h | 18 +- src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp | 54 +- src/libs/vdxf/libdxfrw/intern/dxfwriter.h | 9 +- src/libs/vdxf/libdxfrw/intern/rscodec.cpp | 31 +- src/libs/vdxf/libdxfrw/intern/rscodec.h | 4 + src/libs/vdxf/libdxfrw/libdwgr.cpp | 25 +- src/libs/vdxf/libdxfrw/libdwgr.h | 3 +- src/libs/vdxf/libdxfrw/libdxfrw.cpp | 126 ++-- src/libs/vdxf/libdxfrw/libdxfrw.h | 1 + src/libs/vlayout/vtextmanager.cpp | 8 +- src/libs/vmisc/def.cpp | 4 +- src/libs/vmisc/vsettings.h | 2 +- src/libs/vmisc/vtapesettings.h | 2 +- src/libs/vobj/delaunay.cpp | 56 +- .../plugins/vfilepropertyeditor.cpp | 4 +- .../vpropertyexplorer/vpropertydelegate.h | 2 +- .../vpropertyfactorymanager.cpp | 6 +- .../vpropertyexplorer/vpropertyformview.cpp | 2 +- .../vpropertyexplorer/vpropertyformview.h | 6 +- .../vpropertyexplorer/vpropertyformview_p.h | 6 +- .../vpropertyexplorer/vpropertyformwidget.cpp | 2 +- src/libs/vpropertyexplorer/vpropertymodel.h | 2 +- src/libs/vpropertyexplorer/vpropertyset.cpp | 14 +- .../vpropertyexplorer/vpropertytreeview.h | 6 +- .../tools/dialogpointfromarcandtangent.h | 2 +- .../tools/dialogpointfromcircleandtangent.h | 2 +- .../tools/dialogpointofintersectionarcs.h | 2 +- .../tools/dialogpointofintersectioncircles.h | 2 +- .../tools/dialogpointofintersectioncurves.h | 2 +- .../tools/piece/dialogseamallowance.cpp | 8 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 12 +- src/libs/vtools/undocommands/adddetnode.h | 2 +- .../vtools/undocommands/addpatternpiece.h | 3 +- src/libs/vtools/undocommands/addtocalc.h | 2 +- .../vtools/undocommands/deletepatternpiece.h | 2 +- src/libs/vtools/undocommands/deltool.h | 2 +- .../undocommands/label/movedoublelabel.h | 2 +- .../vtools/undocommands/label/movelabel.h | 3 +- src/libs/vtools/undocommands/movespoint.h | 2 +- src/libs/vtools/undocommands/renamepp.h | 2 +- .../vtools/undocommands/savetooloptions.h | 2 +- src/libs/vtools/undocommands/vundocommand.h | 2 +- src/libs/vwidgets/vnobrushscalepathitem.h | 2 +- src/libs/vwidgets/vwidgetpopup.cpp | 4 +- src/libs/vwidgets/vwidgetpopup.h | 2 +- 82 files changed, 1417 insertions(+), 772 deletions(-) diff --git a/common.pri b/common.pri index e923764b2..55fd53a16 100644 --- a/common.pri +++ b/common.pri @@ -293,8 +293,8 @@ GCC_DEBUG_CXXFLAGS += \ -Wno-unused \ -ftrapv -# Good support Q_NULLPTR come later -greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4) { +# Good support Q_NULLPTR came later +greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 5) { GCC_DEBUG_CXXFLAGS += -Wzero-as-null-pointer-constant } diff --git a/src/app/tape/dialogs/dialogmdatabase.h b/src/app/tape/dialogs/dialogmdatabase.h index 858883fa6..6e388a07b 100644 --- a/src/app/tape/dialogs/dialogmdatabase.h +++ b/src/app/tape/dialogs/dialogmdatabase.h @@ -43,8 +43,8 @@ class DialogMDataBase : public QDialog Q_OBJECT public: - explicit DialogMDataBase(const QStringList &list, QWidget *parent = 0); - explicit DialogMDataBase(QWidget *parent = 0); + explicit DialogMDataBase(const QStringList &list, QWidget *parent = nullptr); + explicit DialogMDataBase(QWidget *parent = nullptr); virtual ~DialogMDataBase() Q_DECL_OVERRIDE; QStringList GetNewNames() const; diff --git a/src/app/tape/dialogs/dialognewmeasurements.h b/src/app/tape/dialogs/dialognewmeasurements.h index ffc7d4449..27e8d5f89 100644 --- a/src/app/tape/dialogs/dialognewmeasurements.h +++ b/src/app/tape/dialogs/dialognewmeasurements.h @@ -43,7 +43,7 @@ class DialogNewMeasurements : public QDialog Q_OBJECT public: - explicit DialogNewMeasurements(QWidget *parent = 0); + explicit DialogNewMeasurements(QWidget *parent = nullptr); ~DialogNewMeasurements(); MeasurementsType Type() const; diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index fa9619427..536ffad42 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -283,7 +283,7 @@ VApplication::VApplication(int &argc, char **argv) VApplication::~VApplication() { qCDebug(vApp, "Application closing."); - qInstallMessageHandler(0); // Resore the message handler + qInstallMessageHandler(nullptr); // Resore the message handler delete trVars; VCommandLine::Reset(); } diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.h b/src/app/valentina/dialogs/dialoglayoutprogress.h index 7f339e44f..0a187b307 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.h +++ b/src/app/valentina/dialogs/dialoglayoutprogress.h @@ -43,7 +43,7 @@ class DialogLayoutProgress : public QDialog Q_OBJECT public: - explicit DialogLayoutProgress(int count, QWidget *parent = 0); + explicit DialogLayoutProgress(int count, QWidget *parent = nullptr); ~DialogLayoutProgress(); signals: diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index a91b17744..5d1d1dc1d 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -338,7 +338,7 @@ QString QmuParserBase::GetVersion(EParserVersionInfo eInfo) void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback, funmap_type &a_Storage, const QString &a_szCharSet ) { - if (a_Callback.GetAddr()==0) + if (a_Callback.GetAddr() == nullptr) { Error(ecINVALID_FUN_PTR); } @@ -582,7 +582,7 @@ void QmuParserBase::DefineStrConst(const QString &a_strName, const QString &a_st */ void QmuParserBase::DefineVar(const QString &a_sName, qreal *a_pVar) { - if (a_pVar==0) + if (a_pVar == nullptr) { Error(ecINVALID_VAR_PTR); } @@ -787,7 +787,7 @@ void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack & assert(m_pTokenReader.get()); // Operator stack empty or does not contain tokens with callback functions - if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr()==0 ) + if (a_stOpt.empty() || a_stOpt.top().GetFuncAddr() == nullptr) { return; } @@ -1451,7 +1451,7 @@ void QmuParserBase::CreateRPN() const // The opening bracket was popped from the stack now check if there // was a function before this bracket if (stOpt.size() && stOpt.top().GetCode()!=cmOPRT_INFIX && stOpt.top().GetCode()!=cmOPRT_BIN && - stOpt.top().GetFuncAddr()!=0) + stOpt.top().GetFuncAddr()!=nullptr) { ApplyFunc(stOpt, stVal, iArgCount); } diff --git a/src/libs/qmuparser/qmuparsercallback.cpp b/src/libs/qmuparser/qmuparsercallback.cpp index bea76bdd7..be15787bf 100644 --- a/src/libs/qmuparser/qmuparsercallback.cpp +++ b/src/libs/qmuparser/qmuparsercallback.cpp @@ -296,8 +296,8 @@ QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti ) * @throw nothrow */ QmuParserCallback::QmuParserCallback() - : m_pFun ( 0 ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), - m_bAllowOpti ( 0 ) + : m_pFun ( nullptr ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ), + m_iType ( tpVOID ), m_bAllowOpti ( 0 ) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index 6f00ed403..ff63ccfdd 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -339,12 +339,12 @@ int QmuParserTester::TestNames() PARSER_THROWCHECK ( Var, true, "a_min", &a ) PARSER_THROWCHECK ( Var, true, "a_min0", &a ) PARSER_THROWCHECK ( Var, true, "a_min9", &a ) - PARSER_THROWCHECK ( Var, false, "a_min9", 0 ) + PARSER_THROWCHECK ( Var, false, "a_min9", nullptr ) // Postfix operators // fail PARSER_THROWCHECK ( PostfixOprt, false, "(k", f1of1 ) PARSER_THROWCHECK ( PostfixOprt, false, "9+", f1of1 ) - PARSER_THROWCHECK ( PostfixOprt, false, "+", 0 ) + PARSER_THROWCHECK ( PostfixOprt, false, "+", nullptr ) // pass PARSER_THROWCHECK ( PostfixOprt, true, "-a", f1of1 ) PARSER_THROWCHECK ( PostfixOprt, true, "?a", f1of1 ) @@ -543,7 +543,7 @@ int QmuParserTester::TestVarConst() for ( item = UsedVar.begin(); item != UsedVar.end(); ++item ) { - if ( item->second != 0 ) + if ( item->second != nullptr ) { throw false; // all pointers to undefined variables must be null } @@ -1378,7 +1378,7 @@ int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass // destroy the originals from p2 vParser.clear(); // delete the vector - p1.reset ( 0 ); + p1.reset ( nullptr ); fVal[2] = p2.Eval(); diff --git a/src/libs/qmuparser/qmuparsertoken.h b/src/libs/qmuparser/qmuparsertoken.h index cbd0d12f9..04bbc769a 100644 --- a/src/libs/qmuparser/qmuparsertoken.h +++ b/src/libs/qmuparser/qmuparsertoken.h @@ -67,8 +67,8 @@ public: * @sa ECmdCode */ QmuParserToken() - : m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), m_pTok ( 0 ), m_iIdx ( -1 ), m_strTok(), m_strVal(), m_fVal(), - m_pCallback() + : m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), m_pTok ( nullptr ), m_iIdx ( -1 ), m_strTok(), m_strVal(), + m_fVal(), m_pCallback() {} //------------------------------------------------------------------------------ @@ -121,7 +121,7 @@ public: m_iType = a_Tok.m_iType; m_fVal = a_Tok.m_fVal; // create new callback object if a_Tok has one - m_pCallback.reset ( a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0 ); + m_pCallback.reset ( a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : nullptr ); } //------------------------------------------------------------------------------ @@ -145,7 +145,7 @@ public: m_iCode = a_iType; m_iType = tpVOID; - m_pTok = 0; + m_pTok = nullptr; m_strTok = a_strTok; m_iIdx = -1; @@ -165,7 +165,7 @@ public: m_strTok = a_sTok; m_pCallback.reset ( new QmuParserCallback ( a_pCallback ) ); - m_pTok = 0; + m_pTok = nullptr; m_iIdx = -1; return *this; @@ -186,8 +186,8 @@ public: m_strTok = a_strTok; m_iIdx = -1; - m_pTok = 0; - m_pCallback.reset ( 0 ); + m_pTok = nullptr; + m_pCallback.reset ( nullptr ); return *this; } @@ -206,7 +206,7 @@ public: m_strTok = a_strTok; m_iIdx = -1; m_pTok = reinterpret_cast ( a_pVar ); - m_pCallback.reset ( 0 ); + m_pCallback.reset ( nullptr ); return *this; } @@ -224,8 +224,8 @@ public: m_strTok = a_strTok; m_iIdx = a_iSize; - m_pTok = 0; - m_pCallback.reset ( 0 ); + m_pTok = nullptr; + m_pCallback.reset ( nullptr ); return *this; } @@ -361,7 +361,7 @@ public: generic_fun_type GetFuncAddr() const { return ( union_cast( m_pCallback.get() ) ) ? - union_cast( m_pCallback->GetAddr() ) : union_cast(0); + union_cast( m_pCallback->GetAddr() ) : union_cast(nullptr); } //------------------------------------------------------------------------------ diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp index 911e9af53..3c52d57ae 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.cpp +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -947,7 +947,7 @@ bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) else { a_Tok.SetVar ( &m_fZero, strTok ); - m_UsedVar[strTok] = 0; // Add variable to used-var-list + m_UsedVar[strTok] = nullptr; // Add variable to used-var-list } m_iPos = iEnd; diff --git a/src/libs/qmuparser/qmutranslation.h b/src/libs/qmuparser/qmutranslation.h index e7f155579..9cb727bba 100644 --- a/src/libs/qmuparser/qmutranslation.h +++ b/src/libs/qmuparser/qmutranslation.h @@ -54,12 +54,13 @@ class QMUPARSERSHARED_EXPORT QmuTranslation public: QmuTranslation(); ~QmuTranslation(){} - QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation = 0, int n = -1); + QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation = nullptr, + int n = -1); QmuTranslation &operator=(const QmuTranslation &tr); QmuTranslation(const QmuTranslation &tr); QString translate() const; static QmuTranslation translate(const QString &context, const QString &sourceText, - const QString &disambiguation = 0, int n = -1); + const QString &disambiguation = nullptr, int n = -1); QString getMcontext() const; QString getMsourceText() const; QString getMdisambiguation() const; diff --git a/src/libs/vdxf/dxiface.h b/src/libs/vdxf/dxiface.h index 2d835e40a..b35f64bb6 100644 --- a/src/libs/vdxf/dxiface.h +++ b/src/libs/vdxf/dxiface.h @@ -22,18 +22,32 @@ class QFont; //class to store image data and path from DRW_ImageDef class dx_ifaceImg : public DRW_Image { public: - dx_ifaceImg(){} - dx_ifaceImg(const DRW_Image& p):DRW_Image(p){} - ~dx_ifaceImg(){} + dx_ifaceImg() + : path() + {} + + dx_ifaceImg(const DRW_Image& p) + : DRW_Image(p), + path() + {} + + virtual ~dx_ifaceImg() = default; std::string path; //stores the image path }; //container class to store entites. class dx_ifaceBlock : public DRW_Block { public: - dx_ifaceBlock(){} - dx_ifaceBlock(const DRW_Block& p):DRW_Block(p){} - ~dx_ifaceBlock(){ + dx_ifaceBlock() + : ent() + {} + + dx_ifaceBlock(const DRW_Block& p) + : DRW_Block(p), + ent() + {} + + virtual ~dx_ifaceBlock(){ for (std::list::const_iterator it=ent.begin(); it!=ent.end(); ++it) delete *it; } @@ -44,9 +58,19 @@ public: //container class to store full dwg/dxf data. class dx_data { public: - dx_data(){ - mBlock = new dx_ifaceBlock(); - } + dx_data() + : headerC(), + lineTypes(), + layers(), + dimStyles(), + VPorts(), + textStyles(), + appIds(), + blocks(), + images(), + mBlock(new dx_ifaceBlock()) + {} + ~dx_data(){ //cleanup, for (std::list::const_iterator it=blocks.begin(); it!=blocks.end(); ++it) @@ -65,7 +89,8 @@ public: std::listimages; //temporary list to find images for link with DRW_ImageDef. Do not delete it!! dx_ifaceBlock* mBlock; //container to store model entities - +private: + Q_DISABLE_COPY(dx_data) }; @@ -96,6 +121,7 @@ public: UTF8STRING AddFont(const QFont &f); private: + Q_DISABLE_COPY(dx_iface) dxfRW* dxfW; //pointer to writer, needed to send data dx_data cData; // class to store or read data DRW::Version version; diff --git a/src/libs/vdxf/libdxfrw/drw_base.h b/src/libs/vdxf/libdxfrw/drw_base.h index 23378663c..16d2d5d50 100644 --- a/src/libs/vdxf/libdxfrw/drw_base.h +++ b/src/libs/vdxf/libdxfrw/drw_base.h @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef DRW_ASSERTS # define drw_assert(a) assert(a) @@ -158,6 +159,23 @@ enum TransparencyCodes { } // namespace DRW +Q_REQUIRED_RESULT static inline bool DRW_FuzzyComparePossibleNulls(double p1, double p2); +static inline bool DRW_FuzzyComparePossibleNulls(double p1, double p2) +{ + if(qFuzzyIsNull(p1)) + { + return qFuzzyIsNull(p2); + } + else if(qFuzzyIsNull(p2)) + { + return false; + } + else + { + return qFuzzyCompare(p1, p2); + } +} + //! Class to handle 3D coordinate point /*! * Class to handle 3D coordinate point @@ -165,13 +183,27 @@ enum TransparencyCodes { */ class DRW_Coord { public: - DRW_Coord() { x = 0; y = 0; z = 0; } - DRW_Coord(double ix, double iy, double iz) { - x = ix; y = iy; z = iz; - } + DRW_Coord() + : x(0), + y(0), + z(0) + {} + DRW_Coord(double ix, double iy, double iz) + : x(ix), + y(iy), + z(iz) + {} - DRW_Coord operator = (const DRW_Coord& data) { - x = data.x; y = data.y; z = data.z; + DRW_Coord &operator = (const DRW_Coord& data) + { + if ( &data == this ) + { + return *this; + } + + x = data.x; + y = data.y; + z = data.z; return *this; } /*!< convert to unitary vector */ @@ -199,16 +231,22 @@ public: */ class DRW_Vertex2D { public: - DRW_Vertex2D() { + DRW_Vertex2D() + : x(), + y(), + stawidth(0), + endwidth(0), + bulge(0) + { // eType = DRW::LWPOLYLINE; - stawidth = endwidth = bulge = 0; - } - DRW_Vertex2D(double sx, double sy, double b) { - stawidth = endwidth = 0; - x = sx; - y =sy; - bulge = b; } + DRW_Vertex2D(double sx, double sy, double b) + : x(sx), + y(sy), + stawidth(0), + endwidth(0), + bulge(b) + {} public: double x; /*!< x coordinate, code 10 */ @@ -234,41 +272,85 @@ public: INVALID }; //TODO: add INT64 support - DRW_Variant() { - type = INVALID; + DRW_Variant() + : content(), + type(INVALID), + code(), + sdata(), + vdata() + {} + + DRW_Variant(int c, dint32 i) + : content(), + type(), + code(c), + sdata(), + vdata() + { + addInt(i); } - DRW_Variant(int c, dint32 i) { - code = c; addInt(i); + DRW_Variant(int c, duint32 i) + : content(), + type(), + code(c), + sdata(), + vdata() + { + addInt(static_cast(i));//RLZ: verify if work with big numbers } - DRW_Variant(int c, duint32 i) { - code = c; addInt(static_cast(i));//RLZ: verify if worrk with big numbers + + DRW_Variant(int c, double d) + : content(), + type(), + code(c), + sdata(), + vdata() + { + addDouble(d); } - DRW_Variant(int c, double d) { - code = c; addDouble(d); + + DRW_Variant(int c, UTF8STRING s) + : content(), + type(), + code(c), + sdata(), + vdata() + { + addString(s); } - DRW_Variant(int c, UTF8STRING s) { - code = c; addString(s); + + DRW_Variant(int c, DRW_Coord crd) + : content(), + type(), + code(c), + sdata(), + vdata() + { + addCoord(crd); } - DRW_Variant(int c, DRW_Coord crd) { - code = c; addCoord(crd); - } - DRW_Variant(const DRW_Variant& d) { - code = d.code; - type = d.type; - content = d.content; - if (d.type == COORD) { + + DRW_Variant(const DRW_Variant& d) + : content(d.content), + type(d.type), + code(d.code), + sdata(), + vdata() + { + if (d.type == COORD) + { vdata = d.vdata; content.v = &vdata; } - if (d.type == STRING) { + + if (d.type == STRING) + { sdata = d.sdata; content.s = &sdata; } } - ~DRW_Variant() { - } + ~DRW_Variant() = default; void addString(UTF8STRING s) {setType(STRING); sdata = s; content.s = &sdata;} void addInt(int i) {setType(INTEGER); content.i = i;} @@ -305,12 +387,14 @@ private: */ class dwgHandle{ public: - dwgHandle(){ - code=0; - size=0; - ref=0; - } - ~dwgHandle(){} + dwgHandle() + : code(0), + size(0), + ref(0) + {} + + ~dwgHandle() = default; + duint8 code; duint8 size; duint32 ref; diff --git a/src/libs/vdxf/libdxfrw/drw_classes.h b/src/libs/vdxf/libdxfrw/drw_classes.h index 84ea32de0..cb3ff761e 100644 --- a/src/libs/vdxf/libdxfrw/drw_classes.h +++ b/src/libs/vdxf/libdxfrw/drw_classes.h @@ -29,10 +29,19 @@ class dwgBuffer; */ class DRW_Class { public: - DRW_Class() { - } - ~DRW_Class() { - } + DRW_Class() + : recName(), + className(), + appName(), + proxyFlag(), + instanceCount(), + wasaProxyFlag(), + entityFlag(), + classNum(), + dwgType() + {} + + ~DRW_Class() = default; void parseCode(int code, dxfReader *reader); void write(dxfWriter *writer, DRW::Version ver); diff --git a/src/libs/vdxf/libdxfrw/drw_entities.cpp b/src/libs/vdxf/libdxfrw/drw_entities.cpp index 0265f56c2..99107a2b8 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.cpp +++ b/src/libs/vdxf/libdxfrw/drw_entities.cpp @@ -135,7 +135,7 @@ bool DRW_Entity::parseCode(int code, dxfReader *reader){ case 1033: if (curr) curr->setCoordZ(reader->getDouble()); - curr=NULL; + curr=nullptr; break; case 1040: case 1041: @@ -159,7 +159,7 @@ bool DRW_Entity::parseDxfGroups(int code, dxfReader *reader){ int nc; std::string appName= reader->getString(); if (!appName.empty() && appName.at(0)== '{'){ - curr.addString(appName.substr(1, (int) appName.size()-1)); + curr.addString(appName.substr(1, static_cast(appName.size()-1))); curr.code = code; ls.push_back(curr); while (code !=102 && appName.at(0)== '}'){ @@ -205,7 +205,7 @@ bool DRW_Entity::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBu DRW_DBG(" Object size: "); DRW_DBG(objSize); DRW_DBG("\n"); } if (version > DRW::AC1021) {//2010+ - duint32 ms = buf->size(); + duint32 ms = static_cast(buf->size()); objSize = ms*8 - bs; DRW_DBG(" Object size: "); DRW_DBG(objSize); DRW_DBG("\n"); } @@ -222,7 +222,7 @@ bool DRW_Entity::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBu DRW_DBG("\nDRW_TableEntry::parseDwg string 0x8000 bit is set"); strBuf->moveBitPos(-33);//RLZ pending to verify duint16 hiSize = strBuf->getRawShort16(); - strDataSize = ((strDataSize&0x7fff) | (hiSize<<15)); + strDataSize = static_cast((strDataSize&0x7fff) | (hiSize<<15)); } strBuf->moveBitPos( -strDataSize -16); //-14 DRW_DBG("strBuf start strDataSize pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n"); @@ -290,7 +290,7 @@ bool DRW_Entity::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBu // entmode = 2; else if(entmode ==2) entmode = 0; - space = (DRW::Space)entmode; //RLZ verify cast values + space = static_cast(entmode); //RLZ verify cast values DRW_DBG("entmode: "); DRW_DBG(entmode); numReactors = buf->getBitShort(); //BS DRW_DBG(", numReactors: "); DRW_DBG(numReactors); @@ -493,7 +493,7 @@ void DRW_Point::parseCode(int code, dxfReader *reader){ } bool DRW_Point::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing point *********************************************\n"); @@ -535,7 +535,7 @@ void DRW_Line::parseCode(int code, dxfReader *reader){ } bool DRW_Line::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing line *********************************************\n"); @@ -573,7 +573,7 @@ bool DRW_Line::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ } bool DRW_Ray::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing ray/xline *********************************************\n"); @@ -613,7 +613,7 @@ void DRW_Circle::parseCode(int code, dxfReader *reader){ } bool DRW_Circle::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing circle *********************************************\n"); @@ -672,7 +672,7 @@ void DRW_Arc::parseCode(int code, dxfReader *reader){ } bool DRW_Arc::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing circle arc *********************************************\n"); @@ -730,7 +730,7 @@ void DRW_Ellipse::applyExtrusion(){ //if ratio > 1 minor axis are greather than major axis, correct it void DRW_Ellipse::correctAxis(){ bool complete = false; - if (staparam == endparam) { + if (DRW_FuzzyComparePossibleNulls(staparam, endparam)) { staparam = 0.0; endparam = M_PIx2; //2*M_PI; complete = true; @@ -754,7 +754,7 @@ void DRW_Ellipse::correctAxis(){ } bool DRW_Ellipse::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing ellipse *********************************************\n"); @@ -851,7 +851,7 @@ void DRW_Trace::parseCode(int code, dxfReader *reader){ } bool DRW_Trace::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing Trace *********************************************\n"); @@ -909,7 +909,7 @@ void DRW_3Dface::parseCode(int code, dxfReader *reader){ } bool DRW_3Dface::parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(v, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(v, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing 3Dface *********************************************\n"); @@ -943,7 +943,7 @@ bool DRW_3Dface::parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs){ fourPoint.x = buf->getDefaultDouble(thirdPoint.x); fourPoint.y = buf->getDefaultDouble(thirdPoint.y); fourPoint.z = buf->getDefaultDouble(thirdPoint.z); - invisibleflag = has_no_flag ? (int)NoEdge : buf->getBitShort(); + invisibleflag = has_no_flag ? static_cast(NoEdge) : buf->getBitShort(); } drw_assert(invisibleflag>=NoEdge); drw_assert(invisibleflag<=AllEdges); @@ -1041,7 +1041,7 @@ void DRW_Insert::parseCode(int code, dxfReader *reader){ bool DRW_Insert::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ dint32 objCount = 0; - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n************************** parsing insert/minsert *****************************************\n"); @@ -1187,7 +1187,7 @@ void DRW_LWPolyline::parseCode(int code, dxfReader *reader){ } bool DRW_LWPolyline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing LWPolyline *******************************************\n"); @@ -1307,10 +1307,10 @@ void DRW_Text::parseCode(int code, dxfReader *reader){ textgen = reader->getInt32(); break; case 72: - alignH = (HAlign)reader->getInt32(); + alignH = static_cast(reader->getInt32()); break; case 73: - alignV = (VAlign)reader->getInt32(); + alignV = static_cast(reader->getInt32()); break; case 1: text = reader->getUtf8String(); @@ -1393,11 +1393,11 @@ bool DRW_Text::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ DRW_DBG("textgen: "); DRW_DBG(textgen); } if ( !(data_flags & 0x40) ) { /* Horiz align. BS 72 present if !(DataFlags & 0x40) */ - alignH = (HAlign)buf->getBitShort(); + alignH = static_cast(buf->getBitShort()); DRW_DBG(", alignH: "); DRW_DBG(alignH); } if ( !(data_flags & 0x80) ) { /* Vert align. BS 73 present if !(DataFlags & 0x80) */ - alignV = (VAlign)buf->getBitShort(); + alignV = static_cast(buf->getBitShort()); DRW_DBG(", alignV: "); DRW_DBG(alignV); } DRW_DBG("\n"); @@ -1432,7 +1432,10 @@ void DRW_MText::parseCode(int code, dxfReader *reader){ break; case 71: { // Attachment point - Attach a = (Attach)reader->getInt32(); + Attach a = static_cast(reader->getInt32()); + + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wswitch-default") switch(a) { case TopLeft: @@ -1472,6 +1475,8 @@ void DRW_MText::parseCode(int code, dxfReader *reader){ alignH = HRight; break; } + + QT_WARNING_POP } break; case 72: // To prevent redirection to DRW_Text::parseCode. @@ -1606,7 +1611,7 @@ void DRW_Polyline::parseCode(int code, dxfReader *reader){ //0x10 polyline 3D bit 4(8) set //0x1D PFACE bit 5(16) set bool DRW_Polyline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing polyline *********************************************\n"); @@ -1721,7 +1726,7 @@ void DRW_Vertex::parseCode(int code, dxfReader *reader){ //0x0D PFACE //0x0E PFACE FACE bool DRW_Vertex::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs, double el){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing pline Vertex *********************************************\n"); @@ -2145,7 +2150,7 @@ void DRW_Spline::parseCode(int code, dxfReader *reader){ } bool DRW_Spline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ - bool ret = DRW_Entity::parseDwg(version, buf, NULL, bs); + bool ret = DRW_Entity::parseDwg(version, buf, nullptr, bs); if (!ret) return ret; DRW_DBG("\n***************************** parsing spline *********************************************\n"); @@ -2416,7 +2421,7 @@ void DRW_Dimension::parseCode(int code, dxfReader *reader){ break; case 42: actual = reader->getDouble(); - hasActual = (actual != 0.0); + hasActual = not qFuzzyIsNull(actual); break; case 53: rot = reader->getDouble(); diff --git a/src/libs/vdxf/libdxfrw/drw_entities.h b/src/libs/vdxf/libdxfrw/drw_entities.h index 912967e5b..2c2ec9c83 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.h +++ b/src/libs/vdxf/libdxfrw/drw_entities.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "drw_base.h" class dxfReader; @@ -99,54 +100,87 @@ class DRW_Entity { SETENTFRIENDS public: //initializes default values - DRW_Entity() { - eType = DRW::UNKNOWN; - handle = parentHandle = DRW::NoHandle; //no handle (0) - lineType = "BYLAYER"; - color = DRW::ColorByLayer; // default BYLAYER (256) - ltypeScale = 1.0; - visible = true; - layer = "0"; - lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29) - space = DRW::ModelSpace; // default ModelSpace (0) - haveExtrusion = false; - color24 = -1; //default -1 not set - numProxyGraph = 0; - shadow = DRW::CastAndReceieveShadows; - material = DRW::MaterialByLayer; - plotStyle = DRW::DefaultPlotStyle; - transparency = DRW::Opaque; - nextEntLink = prevEntLink = 0; - numReactors = xDictFlag = 0; - curr = NULL; - ownerHandle= false; - } + DRW_Entity() + : eType(DRW::UNKNOWN), + handle(DRW::NoHandle), + appData(), + parentHandle(DRW::NoHandle), + space(DRW::ModelSpace), + layer("0"), + lineType("BYLAYER"), + material(DRW::MaterialByLayer), + color(DRW::ColorByLayer), + lWeight(DRW_LW_Conv::widthByLayer), + ltypeScale(1.0), + visible(true), + numProxyGraph(0), + proxyGraphics(), + color24(-1), + colorName(), + transparency(DRW::Opaque), + plotStyle(DRW::DefaultPlotStyle), + shadow(DRW::CastAndReceieveShadows), + haveExtrusion(false), + extData(), + haveNextLinks(), + plotFlags(), + ltFlags(), + materialFlag(), + shadowFlag(), + lTypeH(), + layerH(), + nextEntLink(0), + prevEntLink(0), + ownerHandle(false), + xDictFlag(0), + numReactors(0), + objSize(), + oType(), + extAxisX(), + extAxisY(), + curr(nullptr) + {} - DRW_Entity(const DRW_Entity& e) { - eType = e.eType; - handle = e.handle; - parentHandle = e.parentHandle; //no handle (0) - lineType = e.lineType; - color = e.color; // default BYLAYER (256) - ltypeScale = e.ltypeScale; - visible = e.visible; - layer = e.layer; - lWeight = e.lWeight; - space = e.space; - haveExtrusion = e.haveExtrusion; - color24 = e.color24; //default -1 not set - numProxyGraph = e.numProxyGraph; - shadow = e.shadow; - material = e.material; - plotStyle = e.plotStyle; - transparency = e.transparency; - nextEntLink = e.nextEntLink; - prevEntLink = e.prevEntLink; - numReactors = e.numReactors; - xDictFlag = e.xDictFlag; - curr = NULL; - ownerHandle= false; -// curr = e.curr; + DRW_Entity(const DRW_Entity& e) + : eType(e.eType), + handle(e.handle), + appData(), + parentHandle(e.parentHandle), + space(e.space), + layer(e.layer), + lineType(e.lineType), + material(e.material), + color(e.color), + lWeight(e.lWeight), + ltypeScale(e.ltypeScale), + visible(e.visible), + numProxyGraph(e.numProxyGraph), + proxyGraphics(), + color24(e.color24), + colorName(), + transparency(e.transparency), + plotStyle(e.plotStyle), + shadow(e.shadow), + haveExtrusion(e.haveExtrusion), + extData(), + haveNextLinks(), + plotFlags(), + ltFlags(), + materialFlag(), + shadowFlag(), + lTypeH(), + layerH(), + nextEntLink(e.nextEntLink), + prevEntLink(e.prevEntLink), + ownerHandle(false), + xDictFlag(e.xDictFlag), + numReactors(e.numReactors), + objSize(), + oType(), + extAxisX(), + extAxisY(), + curr(nullptr/*e.curr*/) + { for (std::vector::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){ extData.push_back(new DRW_Variant(*(*it))); } @@ -233,6 +267,7 @@ protected: //only for read dwg dint16 oType; private: + DRW_Entity &operator=(const DRW_Entity &) Q_DECL_EQ_DELETE; DRW_Coord extAxisX; DRW_Coord extAxisY; DRW_Variant* curr; @@ -247,11 +282,12 @@ private: class DRW_Point : public DRW_Entity { SETENTFRIENDS public: - DRW_Point() { + DRW_Point() + : basePoint(), + thickness(0), + extPoint(DRW_Coord(0, 0, 1)) + { eType = DRW::POINT; - basePoint.z = extPoint.x = extPoint.y = 0; - extPoint.z = 1; - thickness = 0; } virtual void applyExtrusion(){} @@ -276,9 +312,10 @@ public: class DRW_Line : public DRW_Point { SETENTFRIENDS public: - DRW_Line() { + DRW_Line() + : secPoint() + { eType = DRW::LINE; - secPoint.z = 0; } virtual void applyExtrusion(){} @@ -326,7 +363,9 @@ public: class DRW_Circle : public DRW_Point { SETENTFRIENDS public: - DRW_Circle() { + DRW_Circle() + : radious() + { eType = DRW::CIRCLE; } @@ -348,9 +387,12 @@ public: class DRW_Arc : public DRW_Circle { SETENTFRIENDS public: - DRW_Arc() { + DRW_Arc() + : staangle(), + endangle(), + isccw(1) + { eType = DRW::ARC; - isccw = 1; } virtual void applyExtrusion(); @@ -390,9 +432,13 @@ public: class DRW_Ellipse : public DRW_Line { SETENTFRIENDS public: - DRW_Ellipse() { + DRW_Ellipse() + : ratio(), + staparam(), + endparam(), + isccw(1) + { eType = DRW::ELLIPSE; - isccw = 1; } void toPolyline(DRW_Polyline *pol, int parts = 128); @@ -422,10 +468,11 @@ public: class DRW_Trace : public DRW_Line { SETENTFRIENDS public: - DRW_Trace() { + DRW_Trace() + : thirdPoint(), + fourPoint() + { eType = DRW::TRACE; - thirdPoint.z = 0; - fourPoint.z = 0; } virtual void applyExtrusion(); @@ -492,9 +539,10 @@ public: AllEdges = 0x0F }; - DRW_3Dface() { + DRW_3Dface() + : invisibleflag(0) + { eType = DRW::E3DFACE; - invisibleflag = 0; } virtual void applyExtrusion(){} @@ -508,7 +556,7 @@ public: //! fourth corner in WCS const DRW_Coord & fourthCorner() { return fourPoint; } //! edge visibility flags - InvisibleEdgeFlags edgeFlags() { return (InvisibleEdgeFlags)invisibleflag; } + InvisibleEdgeFlags edgeFlags() { return static_cast(invisibleflag); } protected: //! interpret code in dxf reading process or dispatch to inherited class @@ -529,12 +577,13 @@ public: class DRW_Block : public DRW_Point { SETENTFRIENDS public: - DRW_Block() { + DRW_Block() + : name("*U0"), + flags(0), + isEnd(false) + { eType = DRW::BLOCK; layer = "0"; - flags = 0; - name = "*U0"; - isEnd = false; } virtual void applyExtrusion(){} @@ -559,16 +608,20 @@ private: class DRW_Insert : public DRW_Point { SETENTFRIENDS public: - DRW_Insert() { + DRW_Insert() + : name(), + xscale(1), + yscale(1), + zscale(1), + angle(0), + colcount(1), + rowcount(1), + colspace(0), + rowspace(0), + blockRecH(), + seqendH() + { eType = DRW::INSERT; - xscale = 1; - yscale = 1; - zscale = 1; - angle = 0; - colcount = 1; - rowcount = 1; - colspace = 0; - rowspace = 0; } virtual void applyExtrusion(){DRW_Point::applyExtrusion();} @@ -600,27 +653,33 @@ public: //only for read dwg class DRW_LWPolyline : public DRW_Entity { SETENTFRIENDS public: - DRW_LWPolyline() { + DRW_LWPolyline() + : vertexnum(), + flags(0), + width(0.0), + elevation(0.0), + thickness(0.0), + extPoint(DRW_Coord(0, 0, 1)), + vertex(nullptr), + vertlist() + { eType = DRW::LWPOLYLINE; - elevation = thickness = width = 0.0; - flags = 0; - extPoint.x = extPoint.y = 0; - extPoint.z = 1; - vertex = NULL; } - DRW_LWPolyline(const DRW_LWPolyline& p):DRW_Entity(p){ + DRW_LWPolyline(const DRW_LWPolyline& p) + : DRW_Entity(p), + vertexnum(), + flags(p.flags), + width(p.width), + elevation(p.elevation), + thickness(p.thickness), + extPoint(p.extPoint), + vertex(nullptr), + vertlist() + { this->eType = DRW::LWPOLYLINE; - this->elevation = p.elevation; - this->thickness = p.thickness; - this->width = p.width; - this->flags = p.flags; - this->extPoint = p.extPoint; - this->vertex = NULL; for (unsigned i=0; ivertlist.push_back( new DRW_Vertex2D( *(p.vertlist.at(i)) ) ); - - this->vertex = NULL; } ~DRW_LWPolyline() { @@ -658,6 +717,8 @@ public: DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ DRW_Vertex2D *vertex; /*!< current vertex to add data */ std::vector vertlist; /*!< vertex list */ +private: + DRW_LWPolyline &operator=(const DRW_LWPolyline &) Q_DECL_EQ_DELETE; }; //! Class to handle insert entries @@ -686,15 +747,19 @@ public: HFit /*!< fit into point = 5 (if VAlign==0) */ }; - DRW_Text() { + DRW_Text() + : height(), + text(), + angle(0), + widthscale(1), + oblique(0), + style("STANDARD"), + textgen(0), + alignH(HLeft), + alignV(VBaseLine), + styleH() + { eType = DRW::TEXT; - angle = 0; - widthscale = 1; - oblique = 0; - style = "STANDARD"; - textgen = 0; - alignH = HLeft; - alignV = VBaseLine; } virtual void applyExtrusion(){} //RLZ TODO @@ -737,12 +802,13 @@ public: BottomRight }; - DRW_MText() { + DRW_MText() + : interlin(1), + haveXAxis(false)//if true needed to recalculate angle + { eType = DRW::MTEXT; - interlin = 1; - alignV = (VAlign)TopLeft; - textgen = 1; - haveXAxis = false; //if true needed to recalculate angle + alignV = static_cast(TopLeft); + textgen = 1; } protected: @@ -764,20 +830,36 @@ private: class DRW_Vertex : public DRW_Point { SETENTFRIENDS public: - DRW_Vertex() { + DRW_Vertex() + : stawidth(0), + endwidth(0), + bulge(0), + flags(0), + tgdir(), + vindex1(0), + vindex2(0), + vindex3(0), + vindex4(0), + identifier(0) + { eType = DRW::VERTEX; - stawidth = endwidth = bulge = 0; - vindex1 = vindex2 = vindex3 = vindex4 = 0; - flags = identifier = 0; } - DRW_Vertex(double sx, double sy, double sz, double b) { - stawidth = endwidth = 0; - vindex1 = vindex2 = vindex3 = vindex4 = 0; - flags = identifier = 0; + + DRW_Vertex(double sx, double sy, double sz, double b) + : stawidth(0), + endwidth(0), + bulge(b), + flags(0), + tgdir(), + vindex1(0), + vindex2(0), + vindex3(0), + vindex4(0), + identifier(0) + { basePoint.x = sx; - basePoint.y =sy; - basePoint.z =sz; - bulge = b; + basePoint.y = sy; + basePoint.z = sz; } protected: @@ -808,23 +890,41 @@ public: class DRW_Polyline : public DRW_Point { SETENTFRIENDS public: - DRW_Polyline() { + DRW_Polyline() + : flags(0), + defstawidth(0.0), + defendwidth(0.0), + vertexcount(0), + facecount(0), + smoothM(0), + smoothN(0), + curvetype(0), + vertlist(), + hadlesList(), + firstEH(), + lastEH(), + seqEndH() + { eType = DRW::POLYLINE; - defstawidth = defendwidth = 0.0; basePoint.x = basePoint.y = 0.0; - flags = vertexcount = facecount = 0; - smoothM = smoothN = curvetype = 0; } - DRW_Polyline(const DRW_Polyline& p) : DRW_Point(p) { - flags = p.flags ; - defstawidth = p.defstawidth; - defendwidth = p.defendwidth; - vertexcount = p.vertexcount; - facecount = p.facecount ; - smoothM = p.smoothM ; - smoothN = p.smoothN ; - curvetype = p.curvetype ; + DRW_Polyline(const DRW_Polyline& p) + : DRW_Point(p), + flags(p.flags), + defstawidth(p.defstawidth), + defendwidth(p.defendwidth), + vertexcount(p.vertexcount), + facecount(p.facecount), + smoothM(p.smoothM), + smoothN(p.smoothN), + curvetype(p.curvetype), + vertlist(), + hadlesList(), + firstEH(), + lastEH(), + seqEndH() + { for (unsigned i=0; ivertlist.push_back( new DRW_Vertex( *(p.vertlist.at(i)) ) ); } @@ -878,26 +978,49 @@ private: class DRW_Spline : public DRW_Entity { SETENTFRIENDS public: - DRW_Spline() { + DRW_Spline() + : normalVec(), + tgStart(), + tgEnd(), + flags(0), + degree(), + nknots(0), + ncontrol(0), + nfit(0), + tolknot(0.0000001), + tolcontrol(0.0000001), + tolfit(0.0000001), + knotslist(), + weightlist(), + controllist(), + fitlist(), + controlpoint(), + fitpoint() + { eType = DRW::SPLINE; - flags = nknots = ncontrol = nfit = 0; - tolknot = tolcontrol = tolfit = 0.0000001; - } - DRW_Spline(const DRW_Spline& p):DRW_Entity(p){ + DRW_Spline(const DRW_Spline& p) + : DRW_Entity(p), + normalVec(p.normalVec), + tgStart(p.tgStart), + tgEnd(p.tgEnd), + flags(p.flags), + degree(p.degree), + nknots(p.nknots), + ncontrol(p.ncontrol), + nfit(p.nfit), + tolknot(p.tolknot), + tolcontrol(p.tolcontrol), + tolfit(p.tolfit), + knotslist(), + weightlist(), + controllist(), + fitlist(), + controlpoint(), + fitpoint() + { eType = DRW::SPLINE; - normalVec = p.normalVec ; - tgStart = p.tgStart ; - tgEnd = p.tgEnd ; - flags = p.flags ; - degree = p.degree ; - nknots = p.nknots ; - ncontrol = p.ncontrol ; - nfit = p.nfit ; - tolknot = p.tolknot ; - tolcontrol = p.tolcontrol; - tolfit = p.tolfit ; for(double v : p.knotslist) knotslist.push_back(v); for(double v : p.weightlist) weightlist.push_back(v); @@ -943,6 +1066,7 @@ public: std::vector fitlist; /*!< fit points list, code 11, 21 & 31 */ private: + DRW_Spline &operator=(const DRW_Spline &) Q_DECL_EQ_DELETE; DRW_Coord *controlpoint; /*!< current control point to add data */ DRW_Coord *fitpoint; /*!< current fit point to add data */ }; @@ -954,10 +1078,11 @@ private: */ class DRW_HatchLoop { public: - DRW_HatchLoop(int t) { - type = t; - numedges = 0; - } + DRW_HatchLoop(int t) + : type(t), + numedges(0), + objlist() + {} ~DRW_HatchLoop() { // for(DRW_LWPolyline *item : pollist) delete item; @@ -965,7 +1090,7 @@ public: } void update() { - numedges = (int)objlist.size(); + numedges = static_cast(objlist.size()); } public: @@ -985,14 +1110,30 @@ public: class DRW_Hatch : public DRW_Point { SETENTFRIENDS public: - DRW_Hatch() { + DRW_Hatch() + : name(), + solid(1), + associative(0), + hstyle(0), + hpattern(1), + doubleflag(0), + loopsnum(0), + angle(0.0), + scale(0.0), + deflines(0), + looplist(), + loop(nullptr), + line(), + arc(), + ellipse(), + spline(), + pline(), + pt(), + plvert(), + ispol() + { eType = DRW::HATCH; - angle = scale = 0.0; basePoint.x = basePoint.y = basePoint.z = 0.0; - loopsnum = hstyle = associative = 0; - solid = hpattern = 1; - deflines = doubleflag = 0; - loop = NULL; clearEntities(); } @@ -1025,13 +1166,14 @@ public: std::vector looplist; /*!< polyline list */ private: + Q_DISABLE_COPY(DRW_Hatch) void clearEntities(){ - pt = line = NULL; - pline = NULL; - arc = NULL; - ellipse = NULL; - spline = NULL; - plvert = NULL; + pt = line = nullptr; + pline = nullptr; + arc = nullptr; + ellipse = nullptr; + spline = nullptr; + plvert = nullptr; } void addLine() { @@ -1061,7 +1203,7 @@ private: void addSpline() { clearEntities(); if (loop) { - pt = NULL; + pt = nullptr; spline = new DRW_Spline; loop->objlist.push_back(spline); } @@ -1086,10 +1228,18 @@ private: class DRW_Image : public DRW_Line { SETENTFRIENDS public: - DRW_Image() { + DRW_Image() + : ref(), + vVector(), + sizeu(), + sizev(), + dz(), + clip(0), + brightness(50), + contrast(50), + fade(0) + { eType = DRW::IMAGE; - fade = clip = 0; - brightness = contrast = 50; } protected: @@ -1121,48 +1271,66 @@ public: class DRW_Dimension : public DRW_Entity { SETENTFRIENDS public: - DRW_Dimension() { + DRW_Dimension() + : type(0), + name(), + defPoint(), + textPoint(), + text(), + style("STANDARD"), + align(5), + linesty(1), + linefactor(1.0), + rot(0.0), + extPoint(DRW_Coord(0, 0, 1.0)), + hdir(), + clonePoint(), + def1(), + def2(), + angle(0.0), + oblique(0.0), + circlePoint(), + arcPoint(), + length(0.0), + hasActual(false), + actual(0.0), + dimStyleH(), + blockH() + { eType = DRW::DIMENSION; - type = 0; - linesty = 1; - linefactor = extPoint.z = 1.0; - angle = oblique = rot = 0.0; - align = 5; - style = "STANDARD"; - defPoint.z = extPoint.x = extPoint.y = 0; - textPoint.z = rot = 0; - clonePoint.x = clonePoint.y = clonePoint.z = 0; - length = 0.0; - hasActual = false; - actual = 0.0; } - DRW_Dimension(const DRW_Dimension& d): DRW_Entity(d) { + DRW_Dimension(const DRW_Dimension& d) + : DRW_Entity(d), + type(d.type), + name(d.name), + defPoint(d.defPoint), + textPoint(d.textPoint), + text(d.text), + style(d.style), + align(d.align), + linesty(d.linesty), + linefactor(d.linefactor), + rot(d.rot), + extPoint(d.extPoint), + hdir(), + clonePoint(d.clonePoint), + def1(d.def1), + def2(d.def2), + angle(d.angle), + oblique(d.oblique), + circlePoint(d.circlePoint), + arcPoint(d.arcPoint), + length(d.length), + hasActual(d.hasActual), + actual(d.actual), + dimStyleH(), + blockH() + { eType = DRW::DIMENSION; - type =d.type; - name = d.name; - defPoint = d.defPoint; - textPoint = d.textPoint; - text = d.text; - style = d.style; - align = d.align; - linesty = d.linesty; - linefactor = d.linefactor; - rot = d.rot; - extPoint = d.extPoint; - clonePoint = d.clonePoint; - def1 = d.def1; - def2 = d.def2; - angle = d.angle; - oblique = d.oblique; - arcPoint = d.arcPoint; - circlePoint = d.circlePoint; - length = d.length; - hasActual = d.hasActual; - actual = d.actual; //RLZ needed a def value for this: hdir = ??? } - virtual ~DRW_Dimension() {} + virtual ~DRW_Dimension() = default; virtual void applyExtrusion(){} @@ -1451,13 +1619,28 @@ protected: class DRW_Leader : public DRW_Entity { SETENTFRIENDS public: - DRW_Leader() { + DRW_Leader() + : style(), + arrow(1), + leadertype(0), + flag(3), + hookline(), + hookflag(0), + textheight(), + textwidth(), + vertnum(0), + coloruse(), + annotHandle(), + extrusionPoint(DRW_Coord(0, 0, 1.0)), + horizdir(), + offsetblock(), + offsettext(), + vertexlist(), + vertexpoint(), + dimStyleH(), + AnnotH() + { eType = DRW::LEADER; - flag = 3; - hookflag = vertnum = leadertype = 0; - extrusionPoint.x = extrusionPoint.y = 0.0; - arrow = 1; - extrusionPoint.z = 1.0; } ~DRW_Leader() { for(DRW_Coord *item : vertexlist) delete item; @@ -1489,6 +1672,7 @@ public: std::vector vertexlist; /*!< vertex points list, code 10, 20 & 30 */ private: + Q_DISABLE_COPY(DRW_Leader) DRW_Coord *vertexpoint; /*!< current control point to add data */ dwgHandle dimStyleH; dwgHandle AnnotH; @@ -1502,13 +1686,28 @@ private: class DRW_Viewport : public DRW_Point { SETENTFRIENDS public: - DRW_Viewport() { + DRW_Viewport() + : pswidth(205), + psheight(156), + vpstatus(0), + vpID(), + centerPX(128.5), + centerPY(97.5), + snapPX(), + snapPY(), + snapSpPX(), + snapSpPY(), + viewDir(), + viewTarget(), + viewLength(), + frontClip(), + backClip(), + viewHeight(), + snapAngle(), + twistAngle(), + frozenLyCount() + { eType = DRW::VIEWPORT; - vpstatus = 0; - pswidth = 205; - psheight = 156; - centerPX = 128.5; - centerPY = 97.5; } virtual void applyExtrusion(){} diff --git a/src/libs/vdxf/libdxfrw/drw_header.cpp b/src/libs/vdxf/libdxfrw/drw_header.cpp index 60be5ccb3..a0e263998 100644 --- a/src/libs/vdxf/libdxfrw/drw_header.cpp +++ b/src/libs/vdxf/libdxfrw/drw_header.cpp @@ -16,11 +16,23 @@ #include "intern/drw_dbg.h" #include "intern/dwgbuffer.h" -DRW_Header::DRW_Header() { - linetypeCtrl = layerCtrl = styleCtrl = dimstyleCtrl = appidCtrl = 0; - blockCtrl = viewCtrl = ucsCtrl = vportCtrl = vpEntHeaderCtrl = 0; - version = DRW::AC1021; -} +DRW_Header::DRW_Header() + : vars(), + comments(), + name(), + curr(), + version(DRW::AC1021), + linetypeCtrl(0), + layerCtrl(0), + styleCtrl(0), + dimstyleCtrl(0), + appidCtrl(0), + blockCtrl(0), + viewCtrl(0), + ucsCtrl(0), + vportCtrl(0), + vpEntHeaderCtrl(0) +{} void DRW_Header::addComment(std::string c){ if (!comments.empty()) diff --git a/src/libs/vdxf/libdxfrw/drw_header.h b/src/libs/vdxf/libdxfrw/drw_header.h index a8fdc8e3f..016348f78 100644 --- a/src/libs/vdxf/libdxfrw/drw_header.h +++ b/src/libs/vdxf/libdxfrw/drw_header.h @@ -35,24 +35,42 @@ class DRW_Header { SETHDRFRIENDS public: DRW_Header(); + ~DRW_Header() { clearVars(); } - DRW_Header(const DRW_Header& h){ - this->version = h.version; - this->comments = h.comments; - for (std::map::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it){ + DRW_Header(const DRW_Header& h) + : vars(), + comments(h.comments), + name(), + curr(nullptr), + version(h.version), + linetypeCtrl(), + layerCtrl(), + styleCtrl(), + dimstyleCtrl(), + appidCtrl(), + blockCtrl(), + viewCtrl(), + ucsCtrl(), + vportCtrl(), + vpEntHeaderCtrl() + { + for (std::map::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it) + { this->vars[it->first] = new DRW_Variant( *(it->second) ); } - this->curr = NULL; } - DRW_Header& operator=(const DRW_Header &h) { - if(this != &h) { + DRW_Header& operator=(const DRW_Header &h) + { + if(this != &h) + { clearVars(); this->version = h.version; this->comments = h.comments; - for (std::map::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it){ + for (std::map::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it) + { this->vars[it->first] = new DRW_Variant( *(it->second) ); } } @@ -75,7 +93,8 @@ private: bool getInt(std::string key, int *varInt); bool getStr(std::string key, std::string *varStr); bool getCoord(std::string key, DRW_Coord *varStr); - void clearVars(){ + void clearVars() + { for (std::map::iterator it=vars.begin(); it!=vars.end(); ++it) delete it->second; diff --git a/src/libs/vdxf/libdxfrw/drw_objects.cpp b/src/libs/vdxf/libdxfrw/drw_objects.cpp index 88818b313..a529684b6 100644 --- a/src/libs/vdxf/libdxfrw/drw_objects.cpp +++ b/src/libs/vdxf/libdxfrw/drw_objects.cpp @@ -69,7 +69,7 @@ void DRW_TableEntry::parseCode(int code, dxfReader *reader){ case 1033: if (curr) curr->setCoordZ(reader->getDouble()); - curr=NULL; + curr=nullptr; break; case 1040: case 1041: @@ -95,13 +95,14 @@ DRW_DBG("\n***************************** parsing table entry ******************* DRW_DBG(" Object size: "); DRW_DBG(objSize); DRW_DBG("\n"); } if (version > DRW::AC1021) {//2010+ - duint32 ms = buf->size(); + duint32 ms =static_cast(buf->size()); objSize = ms*8 - bs; DRW_DBG(" Object size: "); DRW_DBG(objSize); DRW_DBG("\n"); } if (strBuf != NULL && version > DRW::AC1018) {//2007+ strBuf->moveBitPos(objSize-1); - DRW_DBG(" strBuf strbit pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n"); + DRW_DBG(" strBuf strbit pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); + DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n"); if (strBuf->getBit() == 1){ DRW_DBG("DRW_TableEntry::parseDwg string bit is 1\n"); strBuf->moveBitPos(-17); @@ -111,7 +112,7 @@ DRW_DBG("\n***************************** parsing table entry ******************* DRW_DBG("\nDRW_TableEntry::parseDwg string 0x8000 bit is set"); strBuf->moveBitPos(-33);//RLZ pending to verify duint16 hiSize = strBuf->getRawShort16(); - strDataSize = ((strDataSize&0x7fff) | (hiSize<<15)); + strDataSize = static_cast((strDataSize&0x7fff) | (hiSize<<15)); } strBuf->moveBitPos( -strDataSize -16); //-14 DRW_DBG("strBuf start strDataSize pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n"); @@ -132,7 +133,7 @@ DRW_DBG("\n***************************** parsing table entry ******************* duint8 *tmpExtData = new duint8[extDataSize]; buf->getBytes(tmpExtData, extDataSize); dwgBuffer tmpExtDataBuf(tmpExtData, extDataSize, buf->decoder); - int pos = tmpExtDataBuf.getPosition(); + int pos = static_cast(tmpExtDataBuf.getPosition()); int bpos = tmpExtDataBuf.getBitPos(); DRW_DBG("ext data pos: "); DRW_DBG(pos); DRW_DBG("."); DRW_DBG(bpos); DRW_DBG("\n"); duint8 dxfCode = tmpExtDataBuf.getRawChar8(); @@ -458,7 +459,7 @@ void DRW_LType::parseCode(int code, dxfReader *reader){ /*TODO: control max length permited */ void DRW_LType::update(){ double d =0; - size = (int)path.size(); + size = static_cast(path.size()); for (int i = 0; i< size; i++){ d += fabs(path.at(i)); } diff --git a/src/libs/vdxf/libdxfrw/drw_objects.h b/src/libs/vdxf/libdxfrw/drw_objects.h index 07cba081a..0630c249c 100644 --- a/src/libs/vdxf/libdxfrw/drw_objects.h +++ b/src/libs/vdxf/libdxfrw/drw_objects.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "drw_base.h" class dxfReader; @@ -56,13 +57,19 @@ namespace DRW { class DRW_TableEntry { public: //initializes default values - DRW_TableEntry() { - tType = DRW::UNKNOWNT; - flags = 0; - numReactors = xDictFlag = 0; - parentHandle = 0; - curr = NULL; - } + DRW_TableEntry() + : tType(DRW::UNKNOWNT), + handle(), + parentHandle(0), + name(), + flags(0), + extData(), + curr(nullptr), + oType(), + xDictFlag(0), + numReactors(0), + objSize() + {} virtual~DRW_TableEntry() { for (std::vector::iterator it=extData.begin(); it!=extData.end(); ++it) @@ -71,15 +78,19 @@ public: extData.clear(); } - DRW_TableEntry(const DRW_TableEntry& e) { - tType = e.tType; - handle = e.handle; - parentHandle = e.parentHandle; - name = e.name; - flags = e.flags; - numReactors = e.numReactors; - xDictFlag = e.xDictFlag; - curr = e.curr; + DRW_TableEntry(const DRW_TableEntry& e) + : tType(e.tType), + handle(e.handle), + parentHandle(e.parentHandle), + name(e.name), + flags(e.flags), + extData(), + curr(e.curr), + oType(), + xDictFlag(e.xDictFlag), + numReactors(e.numReactors), + objSize() + { for (std::vector::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){ extData.push_back(new DRW_Variant(*(*it))); } @@ -90,7 +101,7 @@ protected: virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0) = 0; bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0); void reset(){ - flags =0; + flags = 0; for (std::vector::iterator it=extData.begin(); it!=extData.end(); ++it) delete *it; extData.clear(); @@ -105,6 +116,7 @@ public: std::vector extData; /*!< FIFO list of extended data, codes 1000 to 1071*/ private: + DRW_TableEntry &operator=(const DRW_TableEntry &) Q_DECL_EQ_DELETE; DRW_Variant* curr; //***** dwg parse ********/ @@ -124,7 +136,76 @@ protected: class DRW_Dimstyle : public DRW_TableEntry { SETOBJFRIENDS public: - DRW_Dimstyle() { reset();} + DRW_Dimstyle() + : dimpost(), + dimapost(), + dimblk(), + dimblk1(), + dimblk2(), + dimscale(), + dimasz(), + dimexo(), + dimdli(), + dimexe(), + dimrnd(), + dimdle(), + dimtp(), + dimtm(), + dimfxl(), + dimtxt(), + dimcen(), + dimtsz(), + dimaltf(), + dimlfac(), + dimtvp(), + dimtfac(), + dimgap(), + dimaltrnd(), + dimtol(), + dimlim(), + dimtih(), + dimtoh(), + dimse1(), + dimse2(), + dimtad(), + dimzin(), + dimazin(), + dimalt(), + dimaltd(), + dimtofl(), + dimsah(), + dimtix(), + dimsoxd(), + dimclrd(), + dimclre(), + dimclrt(), + dimadec(), + dimunit(), + dimdec(), + dimtdec(), + dimaltu(), + dimalttd(), + dimaunit(), + dimfrac(), + dimlunit(), + dimdsep(), + dimtmove(), + dimjust(), + dimsd1(), + dimsd2(), + dimtolj(), + dimtzin(), + dimaltz(), + dimaltttz(), + dimfit(), + dimupt(), + dimatfit(), + dimfxlon(), + dimtxsty(), + dimldrblk(), + dimlwd(), + dimlwe() + { reset();} void reset(){ tType = DRW::DIMSTYLE; @@ -243,7 +324,13 @@ public: class DRW_LType : public DRW_TableEntry { SETOBJFRIENDS public: - DRW_LType() { reset();} + DRW_LType() + : desc(), + size(), + length(), + path(), + pathIdx() + { reset();} void reset(){ tType = DRW::LTYPE; @@ -279,7 +366,16 @@ private: class DRW_Layer : public DRW_TableEntry { SETOBJFRIENDS public: - DRW_Layer() { reset();} + DRW_Layer() + : lineType(), + color(), + color24(), + plotF(), + lWeight(), + handlePlotS(), + handleMaterialS(), + lTypeH() + { reset();} void reset() { tType = DRW::LAYER; @@ -315,7 +411,16 @@ public: class DRW_Block_Record : public DRW_TableEntry { SETOBJFRIENDS public: - DRW_Block_Record() { reset();} + DRW_Block_Record() + : insUnits(), + basePoint(), + block(), + endBlock(), + firstEH(), + lastEH(), + entMap() + { reset();} + void reset() { tType = DRW::BLOCK_RECORD; flags = 0; @@ -349,7 +454,16 @@ private: class DRW_Textstyle : public DRW_TableEntry { SETOBJFRIENDS public: - DRW_Textstyle() { reset();} + DRW_Textstyle() + : height(), + width(), + oblique(), + genFlag(), + lastHeight(), + font(), + bigFont(), + fontFamily() + {reset();} void reset(){ tType = DRW::STYLE; @@ -384,7 +498,32 @@ public: class DRW_Vport : public DRW_TableEntry { SETOBJFRIENDS public: - DRW_Vport() { reset();} + DRW_Vport() + : lowerLeft(), + UpperRight(), + center(), + snapBase(), + snapSpacing(), + gridSpacing(), + viewDir(), + viewTarget(), + height(), + ratio(), + lensHeight(), + frontClip(), + backClip(), + snapAngle(), + twistAngle(), + viewMode(), + circleZoom(), + fastZoom(), + ucsIcon(), + snap(), + grid(), + snapStyle(), + snapIsopair(), + gridBehavior() + { reset();} void reset(){ tType = DRW::VPORT; @@ -452,7 +591,17 @@ public: class DRW_ImageDef : public DRW_TableEntry {// SETOBJFRIENDS public: - DRW_ImageDef() { + DRW_ImageDef() + : name(), + imgVersion(), + u(), + v(), + up(), + vp(), + loaded(), + resolution(), + reactors() + { reset(); } diff --git a/src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp b/src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp index d999edf38..9c4f7f2e3 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp +++ b/src/libs/vdxf/libdxfrw/intern/drw_dbg.cpp @@ -42,7 +42,7 @@ public: virtual void printHL(int c, int s, int h); virtual void printPT(double x, double y, double z); print_debug(); - virtual ~print_debug(){} + virtual ~print_debug() = default; private: std::ios_base::fmtflags flags; }; @@ -55,11 +55,11 @@ DRW_dbg *DRW_dbg::getInstance(){ return instance; } -DRW_dbg::DRW_dbg(){ - level = NONE; - prClass = new print_none; - flags = std::cerr.flags(); -} +DRW_dbg::DRW_dbg() + : level(NONE), + flags(std::cerr.flags()), + prClass(new print_none) +{} void DRW_dbg::setLevel(LEVEL lvl){ level = lvl; @@ -120,9 +120,9 @@ void DRW_dbg::printPT(double x, double y, double z){ prClass->printPT(x, y, z); } -print_debug::print_debug(){ - flags = std::cerr.flags(); -} +print_debug::print_debug() + : flags(std::cerr.flags()) +{} void print_debug::printS(std::string s){ std::cerr << s; diff --git a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp index 0c04122d4..9051acd26 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp +++ b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp @@ -6,10 +6,11 @@ #include #include "../drw_base.h" -DRW_TextCodec::DRW_TextCodec() { - version = DRW::AC1021; - conv = nullptr; -} +DRW_TextCodec::DRW_TextCodec() + : version(DRW::AC1021), + cp(), + conv(nullptr) +{} void DRW_TextCodec::setVersion(int v, bool dxfFormat){ if (v == DRW::AC1009 || v == DRW::AC1006) { diff --git a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h index d081f4120..961ce1ba3 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h +++ b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h @@ -2,6 +2,7 @@ #define DRW_TEXTCODEC_H #include +#include class QTextCodec; @@ -22,6 +23,7 @@ private: std::string correctCodePage(const std::string& s); private: + Q_DISABLE_COPY(DRW_TextCodec) int version; std::string cp; QTextCodec *conv; diff --git a/src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp b/src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp index 8bf914f21..bf05aa5b6 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dwgbuffer.cpp @@ -144,32 +144,40 @@ bool dwgCharStream::read(duint8* s, duint64 n){ return true; } -dwgBuffer::dwgBuffer(duint8 *buf, int size, DRW_TextCodec *dc){ - filestr = new dwgCharStream(buf, size); - decoder = dc; - maxSize = size; - bitPos = 0; -} +dwgBuffer::dwgBuffer(duint8 *buf, int size, DRW_TextCodec *dc) + : decoder(dc), + filestr(new dwgCharStream(buf, size)), + maxSize(size), + currByte(), + bitPos(0) +{} -dwgBuffer::dwgBuffer(std::istream *stream, DRW_TextCodec *dc){ - filestr = new dwgFileStream(stream); - decoder = dc; - maxSize = filestr->size(); - bitPos = 0; -} +dwgBuffer::dwgBuffer(std::istream *stream, DRW_TextCodec *dc) + : decoder(dc), + filestr(new dwgFileStream(stream)), + maxSize(static_cast(filestr->size())), + currByte(), + bitPos(0) +{} + +dwgBuffer::dwgBuffer( const dwgBuffer& org ) + : decoder(org.decoder), + filestr(org.filestr->clone()), + maxSize(static_cast(filestr->size())), + currByte(org.currByte), + bitPos(org.bitPos) +{} + +dwgBuffer& dwgBuffer::operator=( const dwgBuffer& org ) +{ + if (&org == this) + { + return *this; + } -dwgBuffer::dwgBuffer( const dwgBuffer& org ){ filestr = org.filestr->clone(); decoder = org.decoder; - maxSize = filestr->size(); - currByte = org.currByte; - bitPos = org.bitPos; -} - -dwgBuffer& dwgBuffer::operator=( const dwgBuffer& org ){ - filestr = org.filestr->clone(); - decoder = org.decoder; - maxSize = filestr->size(); + maxSize = static_cast(filestr->size()); currByte = org.currByte; bitPos = org.bitPos; return *this; @@ -233,7 +241,7 @@ duint8 dwgBuffer::getBit(){ } ret = (currByte >> (7 - bitPos) & 1); - bitPos +=1; + ++bitPos; if (bitPos == 8) bitPos = 0; @@ -254,15 +262,15 @@ duint8 dwgBuffer::get2Bits(){ currByte = buffer; } - bitPos +=2; + bitPos = static_cast(bitPos+2); if (bitPos < 9) - ret = currByte >>(8 - bitPos); + ret = static_cast(currByte >>(8 - bitPos)); else {//read one bit per byte - ret = currByte << 1; + ret = static_cast(currByte << 1); filestr->read (&buffer,1); currByte = buffer; bitPos = 1; - ret = ret | currByte >> 7; + ret = static_cast(ret | currByte >> 7); } if (bitPos == 8) bitPos = 0; @@ -280,15 +288,15 @@ duint8 dwgBuffer::get3Bits(){ currByte = buffer; } - bitPos +=3; + bitPos = static_cast(bitPos + 3); if (bitPos < 9) - ret = currByte >>(8 - bitPos); + ret = static_cast(currByte >>(8 - bitPos)); else {//read one bit per byte - ret = currByte << 1; + ret = static_cast(currByte << 1); filestr->read (&buffer,1); currByte = buffer; bitPos = 1; - ret = ret | currByte >> 7; + ret = static_cast(ret | currByte >> 7); } if (bitPos == 8) bitPos = 0; @@ -315,9 +323,9 @@ duint16 dwgBuffer::getBitShort(){ dint16 dwgBuffer::getSBitShort(){ duint8 b = get2Bits(); if (b == 0) - return (dint16)getRawShort16(); + return static_cast(getRawShort16()); else if (b== 1) - return (dint16)getRawChar8(); + return static_cast(getRawChar8()); else if (b == 2) return 0; else @@ -384,9 +392,9 @@ duint8 dwgBuffer::getRawChar8(){ if (bitPos == 0) return buffer; else { - ret = currByte << bitPos; + ret = static_cast(currByte << bitPos); currByte = buffer; - ret = ret | (currByte >>(8 - bitPos)); + ret = static_cast(ret | (currByte >>(8 - bitPos))); } return ret; } @@ -399,15 +407,15 @@ duint16 dwgBuffer::getRawShort16(){ filestr->read (buffer,2); if (bitPos == 0) { /* no offset directly swap bytes for little-endian */ - ret = (buffer[1] << 8) | (buffer[0] & 0x00FF); + ret = static_cast((buffer[1] << 8) | (buffer[0] & 0x00FF)); } else { - ret = (buffer[0] << 8) | (buffer[1] & 0x00FF); + ret = static_cast((buffer[0] << 8) | (buffer[1] & 0x00FF)); /* apply offset */ - ret = ret >> (8 - bitPos); - ret = ret | (currByte << (8 + bitPos)); + ret = static_cast(ret >> (8 - bitPos)); + ret = static_cast(ret | (currByte << (8 + bitPos))); currByte = buffer[1]; /* swap bytes for little-endian */ - ret = (ret << 8) | (ret >> 8); + ret = static_cast((ret << 8) | (ret >> 8)); } return ret; } @@ -593,10 +601,10 @@ std::string dwgBuffer::get8bitStr(){ std::string dwgBuffer::get16bitStr(duint16 textSize, bool nullTerm){ if (textSize == 0) return std::string(); - textSize *=2; + textSize = static_cast(textSize*2); duint16 ts = textSize; if (nullTerm) - ts += 2; + ts = static_cast(ts+2); duint8 *tmpBuffer = new duint8[textSize + 2]; bool good = getBytes(tmpBuffer, ts); if (!good) @@ -664,7 +672,7 @@ duint16 dwgBuffer::getObjType(DRW::Version v){//OT if (b == 0) return getRawChar8(); else if (b== 1){ - return (getRawChar8() + 0x01F0); + return static_cast((getRawChar8() + 0x01F0)); } else //b == 2 return getRawShort16(); } @@ -757,7 +765,7 @@ duint32 dwgBuffer::getCmColor(DRW::Version v) { duint16 idx = getBitShort(); duint32 rgb = getBitLong(); duint8 cb = getRawChar8(); - duint8 type = rgb >> 24; + duint8 type = static_cast(rgb >> 24); DRW_DBG("\ntype COLOR: "); DRW_DBGH(type); DRW_DBG("\nindex COLOR: "); DRW_DBGH(idx); DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb); @@ -802,7 +810,7 @@ duint32 dwgBuffer::getEnColor(DRW::Version v) { duint32 cb = 0; duint16 idx = getBitShort(); DRW_DBG("idx reads COLOR: "); DRW_DBGH(idx); - duint16 flags = idx>>8; + duint16 flags = static_cast(idx>>8); idx = idx & 0x1FF; //RLZ: warning this is correct? DRW_DBG("\nflag COLOR: "); DRW_DBGH(flags); DRW_DBG(", index COLOR: "); DRW_DBGH(idx); @@ -835,7 +843,7 @@ duint16 dwgBuffer::getBERawShort16(){ char buffer[2]; buffer[0] = getRawChar8(); buffer[1] = getRawChar8(); - duint16 size = (buffer[0] << 8) | (buffer[1] & 0xFF); + duint16 size = static_cast((buffer[0] << 8) | (buffer[1] & 0xFF)); return size; } @@ -849,15 +857,15 @@ bool dwgBuffer::getBytes(unsigned char *buf, int size){ if (bitPos != 0){ for (int i=0; i> (8 - bitPos)); + buf[i] = static_cast((currByte << bitPos) | (tmp >> (8 - bitPos))); currByte = tmp; } } return true; } -duint16 dwgBuffer::crc8(duint16 dx,dint32 start,dint32 end){ - int pos = filestr->getPos(); +duint16 dwgBuffer::crc8(duint16 dx, dint32 start, dint32 end){ + int pos = static_cast(filestr->getPos()); filestr->setPos(start); int n = end-start; duint8 *tmpBuf = new duint8[n]; @@ -870,9 +878,9 @@ duint16 dwgBuffer::crc8(duint16 dx,dint32 start,dint32 end){ duint8 al; while (n-- > 0) { - al = (duint8)((*p) ^ ((dint8)(dx & 0xFF))); + al = static_cast((*p) ^ (static_cast(dx & 0xFF))); dx = (dx>>8) & 0xFF; - dx = dx ^ crctable[al & 0xFF]; + dx = static_cast(dx ^ crctable[al & 0xFF]); p++; } delete[]tmpBuf; @@ -880,7 +888,7 @@ duint16 dwgBuffer::crc8(duint16 dx,dint32 start,dint32 end){ } duint32 dwgBuffer::crc32(duint32 seed,dint32 start,dint32 end){ - int pos = filestr->getPos(); + int pos = static_cast(filestr->getPos()); filestr->setPos(start); int n = end-start; duint8 *tmpBuf = new duint8[n]; diff --git a/src/libs/vdxf/libdxfrw/intern/dwgbuffer.h b/src/libs/vdxf/libdxfrw/intern/dwgbuffer.h index 2dffc23d5..80e753bf1 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgbuffer.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgbuffer.h @@ -15,6 +15,7 @@ #include #include +#include #include "../drw_base.h" class DRW_Coord; @@ -35,13 +36,16 @@ public: class dwgFileStream: public dwgBasicStream{ public: - dwgFileStream(std::istream *s){ - stream =s; + dwgFileStream(std::istream *s) + : stream(nullptr), + sz(0) + { + stream = s; stream->seekg (0, std::ios::end); sz = stream->tellg(); stream->seekg(0, std::ios_base::beg); } - virtual ~dwgFileStream(){} + virtual ~dwgFileStream() = default; virtual bool read(duint8* s, duint64 n); virtual duint64 size(){return sz;} virtual duint64 getPos(){return stream->tellg();} @@ -49,19 +53,21 @@ public: virtual bool good(){return stream->good();} virtual dwgBasicStream* clone(){return new dwgFileStream(stream);} private: + Q_DISABLE_COPY(dwgFileStream) std::istream *stream; duint64 sz; }; class dwgCharStream: public dwgBasicStream{ public: - dwgCharStream(duint8 *buf, int s){ - stream =buf; - sz = s; - pos = 0; - isOk = true; - } - virtual ~dwgCharStream(){} + dwgCharStream(duint8 *buf, duint64 s) + : stream(buf), + sz(s), + pos(0), + isOk(true) + {} + virtual ~dwgCharStream() = default; + virtual bool read(duint8* s, duint64 n); virtual duint64 size(){return sz;} virtual duint64 getPos(){return pos;} @@ -69,6 +75,7 @@ public: virtual bool good(){return isOk;} virtual dwgBasicStream* clone(){return new dwgCharStream(stream, sz);} private: + Q_DISABLE_COPY(dwgCharStream) duint8 *stream; duint64 sz; duint64 pos; @@ -134,7 +141,7 @@ public: bool isGood(){return filestr->good();} bool getBytes(duint8 *buf, int size); - int numRemainingBytes(){return (maxSize- filestr->getPos());} + int numRemainingBytes(){return (maxSize- static_cast(filestr->getPos()));} duint16 crc8(duint16 dx,dint32 start,dint32 end); duint32 crc32(duint32 seed,dint32 start,dint32 end); diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader.cpp b/src/libs/vdxf/libdxfrw/intern/dwgreader.cpp index da6ac3555..a41d4d42b 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader.cpp @@ -160,7 +160,7 @@ bool dwgReader::readDwgHandles(dwgBuffer *dbuf, duint32 offset, duint32 size) { DRW_DBG("object map section crc8 read= "); DRW_DBG(crcRead); DRW_DBG("\nobject map section crc8 calculated= "); DRW_DBG(crcCalc); DRW_DBG("\nobject section buf->curPosition()= "); DRW_DBG(dbuf->getPosition()); DRW_DBG("\n"); - startPos = dbuf->getPosition(); + startPos = static_cast(dbuf->getPosition()); } bool ret = dbuf->isGood(); @@ -994,7 +994,7 @@ bool dwgReader::readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& in } else { DRW_Class *cl = it->second; if (cl->dwgType != 0) - oType = cl->dwgType; + oType = static_cast(cl->dwgType); } } @@ -1221,7 +1221,7 @@ bool dwgReader::readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& in } dwgBuffer buff(tmpByteStr, size, &decoder); //oType are set parsing entities - dint16 oType = obj.type; + dint16 oType = static_cast(obj.type); switch (oType){ case 102: { @@ -1235,7 +1235,11 @@ bool dwgReader::readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& in break; } if (!ret){ - DRW_DBG("Warning: Object type "); DRW_DBG(oType);DRW_DBG("has failed, handle: "); DRW_DBG(obj.handle); DRW_DBG("\n"); + DRW_DBG("Warning: Object type "); + DRW_DBG(oType); + DRW_DBG("has failed, handle: "); + DRW_DBG(obj.handle); + DRW_DBG("\n"); } delete[]tmpByteStr; return ret; @@ -1245,8 +1249,8 @@ bool dwgReader::readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& in bool DRW_ObjControl::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){ int unkData=0; - bool ret = DRW_TableEntry::parseDwg(version, buf, NULL, bs); - DRW_DBG("\n***************************** parsing object control entry *********************************************\n"); + bool ret = DRW_TableEntry::parseDwg(version, buf, nullptr, bs); + DRW_DBG("\n***************************** parsing object control entry *****************************************\n"); if (!ret) return ret; //last parsed is: XDic Missing Flag 2004+ diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader.h b/src/libs/vdxf/libdxfrw/intern/dwgreader.h index 4e8893286..258e421ee 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader.h @@ -22,12 +22,18 @@ class objHandle{ public: - objHandle(){ handle = type = loc = 0; } - objHandle(duint32 t, duint32 h, duint32 l){ - type = t; - handle = h; - loc = l; - } + objHandle() + : type(0), + handle(0), + loc(0) + {} + + objHandle(duint32 t, duint32 h, duint32 l) + : type(t), + handle(h), + loc(l) + {} + duint32 type; duint32 handle; duint32 loc; @@ -55,11 +61,27 @@ public: * */ class dwgPageInfo { public: - dwgPageInfo(){} - dwgPageInfo(duint64 i, duint64 ad, duint32 sz){ - Id=i; address=ad; size=sz; - } - ~dwgPageInfo(){} + dwgPageInfo() + : Id(), + address(), + size(), + dataSize(), + startOffset(), + cSize(), + uSize() + {} + + dwgPageInfo(duint64 i, duint64 ad, duint32 sz) + : Id(i), + address(ad), + size(sz), + dataSize(), + startOffset(), + cSize(), + uSize() + {} + + ~dwgPageInfo() = default; duint64 Id; duint64 address; //in file stream, for rd18, rd21 duint64 size; //in file stream, for rd18, rd21 @@ -82,13 +104,19 @@ public: * */ class dwgSectionInfo { public: - dwgSectionInfo(){ - compresed = 1;//1=no, 2=yes - encrypted = 0;//??? - pageCount = 0; - Id=-1; - } - ~dwgSectionInfo(){} + dwgSectionInfo() + : Id(-1), + name(), + compresed(1),//1=no, 2=yes + encrypted(0),//??? + pages(), + size(), + pageCount(0), + maxSize(), + address() + {} + + ~dwgSectionInfo() = default; dint32 Id; //section Id, 2000- rd15 rd18 std::string name; //section name rd18 duint32 compresed;//is compresed? 1=no, 2=yes rd18, rd21(encoding) @@ -108,10 +136,11 @@ public: */ class DRW_ObjControl : public DRW_TableEntry { public: - DRW_ObjControl() { reset();} + DRW_ObjControl() + : hadlesList() + { reset();} - void reset(){ - } + void reset(){} bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0); std::listhadlesList; }; @@ -120,16 +149,31 @@ public: class dwgReader { friend class dwgR; public: - dwgReader(std::istream *stream, dwgR *p){ - fileBuf = new dwgBuffer(stream); - parent = p; + dwgReader(std::istream *stream, dwgR *p) + : ObjectMap(), + objObjectMap(), + remainingMap(), + ltypemap(), + layermap(), + blockmap(), + stylemap(), + dimstylemap(), + vportmap(), + blockRecordmap(), + appIdmap(), + maintenanceVersion(0), + fileBuf(new dwgBuffer(stream)), + parent(p), + version(), + previewImagePos(), + sections(), + classesmap(), + decoder(), + nextEntLink(0), + prevEntLink(0) + { decoder.setVersion(DRW::AC1021, false);//default 2007 in utf8(no convert) decoder.setCodePage("UTF-16", false); -// blockCtrl=0; //RLZ: temporary -// blockCtrl=layerCtrl=styleCtrl=linetypeCtrl=viewCtrl=0; -// ucsCtrl=vportCtrl=appidCtrl=dimstyleCtrl=vpEntHeaderCtrl=0; - nextEntLink = prevEntLink = 0; - maintenanceVersion=0; } virtual ~dwgReader(); @@ -196,6 +240,8 @@ protected: // duint32 blockCtrl; duint32 nextEntLink; duint32 prevEntLink; +private: + Q_DISABLE_COPY(dwgReader) }; diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp b/src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp index 41bbe9b1d..21757c24f 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader15.cpp @@ -88,8 +88,12 @@ bool dwgReader15::readFileHeader() { return false; DRW_DBG("\nposition after read section locator records= "); DRW_DBG(fileBuf->getPosition()); DRW_DBG(", bit are= "); DRW_DBG(fileBuf->getBitPos()); - duint32 ckcrc = fileBuf->crc8(0,0,fileBuf->getPosition()); + duint32 ckcrc = static_cast(fileBuf->crc8(0, 0, static_cast(fileBuf->getPosition()))); DRW_DBG("\nfile header crc8 0 result= "); DRW_DBG(ckcrc); + + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wswitch-default") + switch (count){ case 3: ckcrc = ckcrc ^ 0xA598; @@ -103,6 +107,9 @@ bool dwgReader15::readFileHeader() { case 6: ckcrc = ckcrc ^ 0x8461; } + + QT_WARNING_POP + DRW_DBG("\nfile header crc8 xor result= "); DRW_DBG(ckcrc); DRW_DBG("\nfile header CRC= "); DRW_DBG(fileBuf->getRawShort16()); DRW_DBG("\nfile header sentinel= "); @@ -123,8 +130,8 @@ bool dwgReader15::readDwgHeader(DRW_Header& hdr){ if (!fileBuf->setPosition(si.address)) return false; duint8 *tmpByteStr = new duint8[si.size]; - fileBuf->getBytes(tmpByteStr, si.size); - dwgBuffer buff(tmpByteStr, si.size, &decoder); + fileBuf->getBytes(tmpByteStr, static_cast(si.size)); + dwgBuffer buff(tmpByteStr, static_cast(si.size), &decoder); DRW_DBG("Header section sentinel= "); checkSentinel(&buff, secEnum::HEADER, true); bool ret = dwgReader::readDwgHeader(hdr, &buff, &buff); @@ -172,7 +179,7 @@ bool dwgReader15::readDwgHandles() { if (si.Id<0)//not found, ends return false; - bool ret = dwgReader::readDwgHandles(fileBuf, si.address, si.size); + bool ret = dwgReader::readDwgHandles(fileBuf, static_cast(si.address), static_cast(si.size)); return ret; } diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp b/src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp index d91b92e50..c1ca52631 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader18.cpp @@ -116,10 +116,10 @@ bool dwgReader18::parseDataPage(dwgSectionInfo si/*, duint8 *dData*/){ //decript section header duint8 hdrData[32]; fileBuf->getBytes(hdrData, 32); - dwgCompressor::decrypt18Hdr(hdrData, 32, pi.address); + dwgCompressor::decrypt18Hdr(hdrData, 32, static_cast(pi.address)); DRW_DBG("Section "); DRW_DBG(si.name); DRW_DBG(" page header=\n"); for (unsigned int i=0, j=0; i< 32;i++) { - DRW_DBGH( (unsigned char)hdrData[i]); + DRW_DBGH( static_cast(hdrData[i])); if (j == 7) { DRW_DBG("\n"); j = 0; @@ -150,10 +150,10 @@ bool dwgReader18::parseDataPage(dwgSectionInfo si/*, duint8 *dData*/){ duint8 *cData = new duint8[pi.cSize]; if (!fileBuf->setPosition(pi.address+32)) return false; - fileBuf->getBytes(cData, pi.cSize); + fileBuf->getBytes(cData, static_cast(pi.cSize)); //calculate checksum - duint32 calcsD = checksum(0, cData, pi.cSize); + duint32 calcsD = checksum(0, cData, static_cast(pi.cSize)); for (duint8 i= 24; i<28; ++i) hdrData[i]=0; duint32 calcsH = checksum(calcsD, hdrData, 32); @@ -164,7 +164,7 @@ bool dwgReader18::parseDataPage(dwgSectionInfo si/*, duint8 *dData*/){ pi.uSize = si.maxSize; DRW_DBG("decompresing "); DRW_DBG(pi.cSize); DRW_DBG(" bytes in "); DRW_DBG(pi.uSize); DRW_DBG(" bytes\n"); dwgCompressor comp; - comp.decompress18(cData, oData, pi.cSize, pi.uSize); + comp.decompress18(cData, oData, static_cast(pi.cSize), static_cast(pi.uSize)); delete[]cData; } return true; @@ -222,14 +222,14 @@ bool dwgReader18::readFileHeader() { DRW_DBG(", "); j++; } - byteStr[i] = DRW_magicNum18[i] ^ ch; + byteStr[i] = static_cast(DRW_magicNum18[i] ^ ch); } DRW_DBG("\n"); // size =0x6C; DRW_DBG("Decripted Header Data=\n"); for (int i=0, j = 0; i< size;i++) { - DRW_DBGH( (unsigned char)byteStr[i]); + DRW_DBGH( static_cast(byteStr[i])); if (j == 15) { DRW_DBG("\n"); j = 0; @@ -277,8 +277,8 @@ bool dwgReader18::readFileHeader() { DRW_DBG("\nEnd Encrypted Data. Reads 0x14 bytes, equal to magic number:\n"); for (int i=0, j=0; i< 0x14;i++) { - DRW_DBG("magic num: "); DRW_DBGH( (unsigned char)DRW_magicNumEnd18[i]); - DRW_DBG(",read "); DRW_DBGH( (unsigned char)fileBuf->getRawChar8()); + DRW_DBG("magic num: "); DRW_DBGH( static_cast(DRW_magicNumEnd18[i])); + DRW_DBG(",read "); DRW_DBGH( static_cast(fileBuf->getRawChar8())); if (j == 3) { DRW_DBG("\n"); j = 0; @@ -382,7 +382,7 @@ bool dwgReader18::readFileHeader() { dwgPageInfo pi = sectionPageMapTmp[pn]; //get a copy DRW_DBG(" reading pag num = "); DRW_DBGH(pn); pi.dataSize = buff3.getRawLong32(); - pi.startOffset = buff3.getRawLong64(); + pi.startOffset = static_cast(buff3.getRawLong64()); secInfo.pages[pn]= pi;//complete copy in secInfo DRW_DBG("\n Page number= "); DRW_DBGH(secInfo.pages[pn].Id); DRW_DBG("\n size in file= "); DRW_DBGH(secInfo.pages[pn].size); @@ -413,20 +413,20 @@ bool dwgReader18::readDwgHeader(DRW_Header& hdr){ //global store for uncompressed data of all pages uncompSize=si.size; if (ret) { - dwgBuffer dataBuf(objData, si.size, &decoder); + dwgBuffer dataBuf(objData, static_cast(si.size), &decoder); DRW_DBG("Header section sentinel= "); checkSentinel(&dataBuf, secEnum::HEADER, true); if (version == DRW::AC1018){ ret = dwgReader::readDwgHeader(hdr, &dataBuf, &dataBuf); } else { - dwgBuffer handleBuf(objData, si.size, &decoder); + dwgBuffer handleBuf(objData, static_cast(si.size), &decoder); ret = dwgReader::readDwgHeader(hdr, &dataBuf, &handleBuf); } } //Cleanup: global store for uncompressed data of all pages - if (objData != NULL){ + if (objData != nullptr){ delete[] objData; - objData = NULL; + objData = nullptr; } return ret; } @@ -442,7 +442,7 @@ bool dwgReader18::readDwgClasses(){ uncompSize=si.size; if (ret) { - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); DRW_DBG("classes section sentinel= "); checkSentinel(&dataBuf, secEnum::CLASSES, true); @@ -466,7 +466,7 @@ bool dwgReader18::readDwgClasses(){ /*******************************/ dwgBuffer *strBuf = &dataBuf; - dwgBuffer strBuff(objData, uncompSize, &decoder); + dwgBuffer strBuff(objData, static_cast(uncompSize), &decoder); //prepare string stream for 2007+ if (version > DRW::AC1021) {//2007+ strBuf = &strBuff; @@ -529,9 +529,9 @@ bool dwgReader18::readDwgClasses(){ ret = strBuf->isGood(); } //Cleanup: global store for uncompressed data of all pages - if (objData != NULL){ + if (objData != nullptr){ delete[] objData; - objData = NULL; + objData = nullptr; } return ret; } @@ -554,14 +554,14 @@ bool dwgReader18::readDwgHandles() { uncompSize=si.size; if (ret) { - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); - ret = dwgReader::readDwgHandles(&dataBuf, 0, si.size); + ret = dwgReader::readDwgHandles(&dataBuf, 0, static_cast(si.size)); } //Cleanup: global store for uncompressed data of all pages - if (objData != NULL){ + if (objData != nullptr){ delete[] objData; - objData = NULL; + objData = nullptr; uncompSize = 0; } return ret; @@ -584,7 +584,7 @@ bool dwgReader18::readDwgTables(DRW_Header& hdr) { uncompSize=si.size; if (ret) { - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgTables(hdr, &dataBuf); diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader18.h b/src/libs/vdxf/libdxfrw/intern/dwgreader18.h index f81409669..6ed69fae0 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader18.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader18.h @@ -43,11 +43,15 @@ static const int DRW_magicNumEnd18[] = { class dwgReader18 : public dwgReader { public: - dwgReader18(std::istream *stream, dwgR *p):dwgReader(stream, p){ - objData = NULL; - } + dwgReader18(std::istream *stream, dwgR *p) + : dwgReader(stream, p), + objData(nullptr), + uncompSize(), + securityFlags() + {} + virtual ~dwgReader18(){ - if (objData != NULL) + if (objData != nullptr) delete[] objData; } bool readMetaData(); @@ -58,20 +62,20 @@ public: bool readDwgTables(DRW_Header& hdr); bool readDwgBlocks(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgBlocks(intfa, &dataBuf); return ret; } virtual bool readDwgEntities(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgEntities(intfa, &dataBuf); return ret; } virtual bool readDwgObjects(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgObjects(intfa, &dataBuf); return ret; } @@ -86,6 +90,7 @@ protected: duint64 uncompSize; private: + Q_DISABLE_COPY(dwgReader18) void genMagicNumber(); // dwgBuffer* bufObj; void parseSysPage(duint8 *decompSec, duint32 decompSize); //called: Section page map: 0x41630e3b diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp b/src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp index 9d4f23c25..83077a7e8 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader21.cpp @@ -59,16 +59,17 @@ bool dwgReader21::parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, //round to 8 duint64 alsize = (sizeCompressed + 7) &(-8); //minimum RS chunk: - duint32 chunks = (((alsize * correctionFactor)+238)/239); + duint32 chunks = static_cast(((alsize * correctionFactor)+238)/239); duint64 fpsize = chunks * 255; if (! fileBuf->setPosition(offset)) return false; duint8 *tmpDataRaw = new duint8[fpsize]; - fileBuf->getBytes(tmpDataRaw, fpsize); + fileBuf->getBytes(tmpDataRaw, static_cast(fpsize)); duint8 *tmpDataRS = new duint8[fpsize]; - dwgRSCodec::decode239I(tmpDataRaw, tmpDataRS, fpsize/255); - dwgCompressor::decompress21(tmpDataRS, decompData, sizeCompressed, sizeUncompressed); + dwgRSCodec::decode239I(tmpDataRaw, tmpDataRS, static_cast(fpsize/255)); + dwgCompressor::decompress21(tmpDataRS, decompData, static_cast(sizeCompressed), + static_cast(sizeUncompressed)); delete[]tmpDataRaw; delete[]tmpDataRS; return true; @@ -82,7 +83,7 @@ bool dwgReader21::parseDataPage(dwgSectionInfo si, duint8 *dData){ return false; duint8 *tmpPageRaw = new duint8[pi.size]; - fileBuf->getBytes(tmpPageRaw, pi.size); + fileBuf->getBytes(tmpPageRaw, static_cast(pi.size)); #ifdef DRW_DBG_DUMP DRW_DBG("\nSection OBJECTS raw data=\n"); for (unsigned int i=0, j=0; i< pi.size;i++) { @@ -93,7 +94,7 @@ bool dwgReader21::parseDataPage(dwgSectionInfo si, duint8 *dData){ #endif duint8 *tmpPageRS = new duint8[pi.size]; - duint8 chunks =pi.size / 255; + duint8 chunks = static_cast(pi.size / 255); dwgRSCodec::decode251I(tmpPageRaw, tmpPageRS, chunks); #ifdef DRW_DBG_DUMP DRW_DBG("\nSection OBJECTS RS data=\n"); @@ -107,7 +108,8 @@ bool dwgReader21::parseDataPage(dwgSectionInfo si, duint8 *dData){ DRW_DBG("\npage uncomp size: "); DRW_DBG(pi.uSize); DRW_DBG(" comp size: "); DRW_DBG(pi.cSize); DRW_DBG("\noffset: "); DRW_DBG(pi.startOffset); duint8 *pageData = dData + pi.startOffset; - dwgCompressor::decompress21(tmpPageRS, pageData, pi.cSize, pi.uSize); + dwgCompressor::decompress21(tmpPageRS, pageData, static_cast(pi.cSize), + static_cast(pi.uSize)); #ifdef DRW_DBG_DUMP DRW_DBG("\n\nSection OBJECTS decompresed data=\n"); @@ -236,7 +238,7 @@ bool dwgReader21::readFileHeader() { duint64 address = 0x480; duint64 i = 0; - dwgBuffer PagesMapBuf(PagesMapData, PagesMapSizeUncompressed, &decoder); + dwgBuffer PagesMapBuf(PagesMapData, static_cast(PagesMapSizeUncompressed), &decoder); //stores temporaly info of all pages: std::mapsectionPageMapTmp; @@ -249,7 +251,7 @@ bool dwgReader21::readFileHeader() { DRW_DBG("Page gap= "); DRW_DBG(id); DRW_DBG(" Page num= "); DRW_DBG(ind); DRW_DBG(" size= "); DRW_DBGH(size); DRW_DBG(" address= "); DRW_DBGH(address); DRW_DBG("\n"); - sectionPageMapTmp[ind] = dwgPageInfo(ind, address,size); + sectionPageMapTmp[static_cast(ind)] = dwgPageInfo(ind, address, static_cast(size)); address += size; //TODO num can be negative indicating gap // seek += offset; @@ -258,15 +260,16 @@ bool dwgReader21::readFileHeader() { DRW_DBG("\n*** dwgReader21: Processing Section Map ***\n"); duint8 *SectionsMapData = new duint8[SectionsMapSizeUncompressed]; - dwgPageInfo sectionMap = sectionPageMapTmp[SectionsMapId]; - ret = parseSysPage(SectionsMapSizeCompressed, SectionsMapSizeUncompressed, SectionsMapCorrectionFactor, sectionMap.address, SectionsMapData); + dwgPageInfo sectionMap = sectionPageMapTmp[static_cast(SectionsMapId)]; + ret = parseSysPage(SectionsMapSizeCompressed, SectionsMapSizeUncompressed, SectionsMapCorrectionFactor, + sectionMap.address, SectionsMapData); if (!ret) return false; //reads sections: //Note: compressed value are not stored in file then, commpresed field are use to store // encoding value - dwgBuffer SectionsMapBuf(SectionsMapData, SectionsMapSizeUncompressed, &decoder); + dwgBuffer SectionsMapBuf(SectionsMapData, static_cast(SectionsMapSizeUncompressed), &decoder); duint8 nextId =1; while(SectionsMapBuf.getPosition() < SectionsMapBuf.size()){ dwgSectionInfo secInfo; @@ -274,28 +277,28 @@ bool dwgReader21::readFileHeader() { DRW_DBG("\nSize of section (data size)= "); DRW_DBGH(secInfo.size); secInfo.maxSize = SectionsMapBuf.getRawLong64(); DRW_DBG("\nMax Decompressed Size= "); DRW_DBGH(secInfo.maxSize); - secInfo.encrypted = SectionsMapBuf.getRawLong64(); + secInfo.encrypted = static_cast(SectionsMapBuf.getRawLong64()); //encrypted (doc: 0 no, 1 yes, 2 unkn) on read: objects 0 and encrypted yes DRW_DBG("\nencription= "); DRW_DBGH(secInfo.encrypted); DRW_DBG("\nHashCode = "); DRW_DBGH(SectionsMapBuf.getRawLong64()); duint64 SectionNameLength = SectionsMapBuf.getRawLong64(); DRW_DBG("\nSectionNameLength = "); DRW_DBG(SectionNameLength); DRW_DBG("\nUnknown = "); DRW_DBGH(SectionsMapBuf.getRawLong64()); - secInfo.compresed = SectionsMapBuf.getRawLong64(); + secInfo.compresed = static_cast(SectionsMapBuf.getRawLong64()); DRW_DBG("\nEncoding (compresed) = "); DRW_DBGH(secInfo.compresed); secInfo.pageCount = SectionsMapBuf.getRawLong64(); DRW_DBG("\nPage count= "); DRW_DBGH(secInfo.pageCount); - secInfo.name = SectionsMapBuf.getUCSStr(SectionNameLength); + secInfo.name = SectionsMapBuf.getUCSStr(static_cast(SectionNameLength)); DRW_DBG("\nSection name = "); DRW_DBG(secInfo.name); DRW_DBG("\n"); for (unsigned int i=0; i< secInfo.pageCount; i++){ duint64 po = SectionsMapBuf.getRawLong64(); - duint32 ds = SectionsMapBuf.getRawLong64(); - duint32 pn = SectionsMapBuf.getRawLong64(); + duint32 ds = static_cast(SectionsMapBuf.getRawLong64()); + duint32 pn = static_cast(SectionsMapBuf.getRawLong64()); DRW_DBG(" pag Id = "); DRW_DBGH(pn); DRW_DBG(" data size = "); DRW_DBGH(ds); dwgPageInfo pi = sectionPageMapTmp[pn]; //get a copy pi.dataSize = ds; - pi.startOffset = po; + pi.startOffset = static_cast(po); pi.uSize = SectionsMapBuf.getRawLong64(); pi.cSize = SectionsMapBuf.getRawLong64(); secInfo.pages[pn]= pi;//complete copy in secInfo @@ -339,8 +342,8 @@ bool dwgReader21::readDwgHeader(DRW_Header& hdr){ return ret; } - dwgBuffer dataBuf(tmpHeaderData, si.size, &decoder); - dwgBuffer handleBuf(tmpHeaderData, si.size, &decoder); + dwgBuffer dataBuf(tmpHeaderData, static_cast(si.size), &decoder); + dwgBuffer handleBuf(tmpHeaderData, static_cast(si.size), &decoder); DRW_DBG("Header section sentinel= "); checkSentinel(&dataBuf, secEnum::HEADER, true); ret = dwgReader::readDwgHeader(hdr, &dataBuf, &handleBuf); @@ -360,7 +363,7 @@ bool dwgReader21::readDwgClasses(){ if (!ret) return ret; - dwgBuffer buff(tmpClassesData, si.size, &decoder); + dwgBuffer buff(tmpClassesData, static_cast(si.size), &decoder); DRW_DBG("classes section sentinel= "); checkSentinel(&buff, secEnum::CLASSES, true); @@ -378,7 +381,7 @@ bool dwgReader21::readDwgClasses(){ /*******************************/ //prepare string stream - dwgBuffer strBuff(tmpClassesData, si.size, &decoder); + dwgBuffer strBuff(tmpClassesData, static_cast(si.size), &decoder); duint32 strStartPos = bitSize + 159;//size in bits + 20 bytes (sn+size) - 1 bit (endbit) DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos); strBuff.setPosition(strStartPos >> 3); @@ -444,9 +447,9 @@ bool dwgReader21::readDwgHandles(){ if (!ret) return ret; - dwgBuffer dataBuf(tmpHandlesData, si.size, &decoder); + dwgBuffer dataBuf(tmpHandlesData, static_cast(si.size), &decoder); - ret = dwgReader::readDwgHandles(&dataBuf, 0, si.size); + ret = dwgReader::readDwgHandles(&dataBuf, 0, static_cast(si.size)); delete[]tmpHandlesData; return ret; } @@ -470,7 +473,7 @@ bool dwgReader21::readDwgTables(DRW_Header& hdr) { return ret; DRW_DBG("readDwgTables total data size= "); DRW_DBG(dataSize); DRW_DBG("\n"); - dwgBuffer dataBuf(objData, dataSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(dataSize), &decoder); ret = dwgReader::readDwgTables(hdr, &dataBuf); return ret; @@ -479,7 +482,7 @@ bool dwgReader21::readDwgTables(DRW_Header& hdr) { bool dwgReader21::readDwgBlocks(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, dataSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(dataSize), &decoder); ret = dwgReader::readDwgBlocks(intfa, &dataBuf); return ret; diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader21.h b/src/libs/vdxf/libdxfrw/intern/dwgreader21.h index f95c77a25..87125e3e1 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader21.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader21.h @@ -22,12 +22,14 @@ //reader for AC1021 aka v2007, chapter 5 class dwgReader21 : public dwgReader { public: - dwgReader21(std::istream *stream, dwgR *p):dwgReader(stream, p){ - objData = NULL; - dataSize = 0; - } + dwgReader21(std::istream *stream, dwgR *p) + : dwgReader(stream, p), + objData(nullptr), + dataSize(0) + {} + virtual ~dwgReader21(){ - if (objData != NULL) + if (objData != nullptr) delete[] objData; } bool readMetaData(); @@ -39,13 +41,13 @@ public: bool readDwgBlocks(DRW_Interface& intfa); virtual bool readDwgEntities(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, dataSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(dataSize), &decoder); ret = dwgReader::readDwgEntities(intfa, &dataBuf); return ret; } virtual bool readDwgObjects(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, dataSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(dataSize), &decoder); ret = dwgReader::readDwgObjects(intfa, &dataBuf); return ret; } @@ -54,7 +56,9 @@ public: //} private: - bool parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset, duint8 *decompData); + Q_DISABLE_COPY(dwgReader21) + bool parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset, + duint8 *decompData); bool parseDataPage(dwgSectionInfo si, duint8 *dData); duint8 *objData; diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader24.h b/src/libs/vdxf/libdxfrw/intern/dwgreader24.h index e5fc43a72..4031b4bec 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader24.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader24.h @@ -30,19 +30,19 @@ public: // bool readDwgTables(){return false;} bool readDwgBlocks(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgBlocks(intfa, &dataBuf); return ret; } virtual bool readDwgEntities(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgEntities(intfa, &dataBuf); return ret; } virtual bool readDwgObjects(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgObjects(intfa, &dataBuf); return ret; } diff --git a/src/libs/vdxf/libdxfrw/intern/dwgreader27.h b/src/libs/vdxf/libdxfrw/intern/dwgreader27.h index 32c67f65b..883f2665b 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgreader27.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgreader27.h @@ -30,19 +30,19 @@ public: // bool readDwgTables(){return false;} bool readDwgBlocks(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgBlocks(intfa, &dataBuf); return ret; } virtual bool readDwgEntities(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgEntities(intfa, &dataBuf); return ret; } virtual bool readDwgObjects(DRW_Interface& intfa){ bool ret = true; - dwgBuffer dataBuf(objData, uncompSize, &decoder); + dwgBuffer dataBuf(objData, static_cast(uncompSize), &decoder); ret = dwgReader::readDwgObjects(intfa, &dataBuf); return ret; } diff --git a/src/libs/vdxf/libdxfrw/intern/dwgutil.cpp b/src/libs/vdxf/libdxfrw/intern/dwgutil.cpp index 10121cf3d..04e1d90fb 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgutil.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dwgutil.cpp @@ -219,9 +219,9 @@ void dwgCompressor::decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duin void dwgCompressor::decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset){ - duint8 max = size / 4; + duint8 max = static_cast(size / 4); duint32 secMask = 0x4164536b ^ offset; - duint32* pHdr = (duint32*)buf; + duint32* pHdr = reinterpret_cast(buf); for (duint8 j = 0; j < max; j++) *pHdr++ ^= secMask; } @@ -245,7 +245,7 @@ duint32 dwgCompressor::litLength21(duint8 *cbuf, duint8 oc, duint32 *si){ if (n == 0xff) { do { n = cbuf[srcIndex++]; - n |= (duint32)(cbuf[srcIndex++] << 8); + n |= static_cast(cbuf[srcIndex++] << 8); length += n; } while (n == 0xffff); } diff --git a/src/libs/vdxf/libdxfrw/intern/dwgutil.h b/src/libs/vdxf/libdxfrw/intern/dwgutil.h index a0505402a..f04b74206 100644 --- a/src/libs/vdxf/libdxfrw/intern/dwgutil.h +++ b/src/libs/vdxf/libdxfrw/intern/dwgutil.h @@ -29,8 +29,16 @@ public: class dwgCompressor { public: - dwgCompressor(){} - ~dwgCompressor(){} + dwgCompressor() + : bufC(), + bufD(), + sizeC(), + sizeD(), + pos(), + rpos() + {} + + ~dwgCompressor() = default; void decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize); static void decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset); diff --git a/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp b/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp index 84f864101..24423fbda 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp @@ -105,13 +105,13 @@ bool dxfReaderBinary::readCode(int *code) { unsigned short *int16p; char buffer[2]; filestr->read(buffer,2); - int16p = (unsigned short *) buffer; + int16p = reinterpret_cast(buffer); //exist a 32bits int (code 90) with 2 bytes??? if ((*code == 90) && (*int16p>2000)){ DRW_DBG(*code); DRW_DBG(" de 16bits\n"); filestr->seekg(-4, std::ios_base::cur); filestr->read(buffer,2); - int16p = (unsigned short *) buffer; + int16p = reinterpret_cast(buffer); } *code = *int16p; DRW_DBG(*code); DRW_DBG("\n"); @@ -137,7 +137,7 @@ bool dxfReaderBinary::readInt16() { type = INT32; char buffer[2]; filestr->read(buffer,2); - intData = (int)((buffer[1] << 8) | buffer[0]); + intData = static_cast((buffer[1] << 8) | buffer[0]); DRW_DBG(intData); DRW_DBG("\n"); return (filestr->good()); } @@ -147,7 +147,7 @@ bool dxfReaderBinary::readInt32() { unsigned int *int32p; char buffer[4]; filestr->read(buffer,4); - int32p = (unsigned int *) buffer; + int32p = reinterpret_cast(buffer); intData = *int32p; DRW_DBG(intData); DRW_DBG("\n"); return (filestr->good()); @@ -158,7 +158,7 @@ bool dxfReaderBinary::readInt64() { unsigned long long int *int64p; //64 bits integer pointer char buffer[8]; filestr->read(buffer,8); - int64p = (unsigned long long int *) buffer; + int64p = reinterpret_cast(buffer); int64 = *int64p; DRW_DBG(int64); DRW_DBG(" int64\n"); return (filestr->good()); @@ -169,7 +169,7 @@ bool dxfReaderBinary::readDouble() { double *result; char buffer[8]; filestr->read(buffer,8); - result = (double *) buffer; + result = reinterpret_cast(buffer); doubleData = *result; DRW_DBG(doubleData); DRW_DBG("\n"); return (filestr->good()); @@ -179,7 +179,7 @@ bool dxfReaderBinary::readDouble() { bool dxfReaderBinary::readBool() { char buffer[1]; filestr->read(buffer,1); - intData = (int)(buffer[0]); + intData = static_cast(buffer[0]); DRW_DBG(intData); DRW_DBG("\n"); return (filestr->good()); } diff --git a/src/libs/vdxf/libdxfrw/intern/dxfreader.h b/src/libs/vdxf/libdxfrw/intern/dxfreader.h index a0fa327c9..5529e79e4 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfreader.h +++ b/src/libs/vdxf/libdxfrw/intern/dxfreader.h @@ -27,11 +27,18 @@ public: }; enum TYPE type; public: - dxfReader(std::istream *stream){ - filestr = stream; - type = INVALID; - } - virtual ~dxfReader(){} + dxfReader(std::istream *stream) + : type(INVALID), + filestr(stream), + strData(), + doubleData(), + intData(), + int64(), + skip(), + decoder() + {} + + virtual ~dxfReader() = default; bool readRec(int *code); std::string getString() {return strData;} @@ -65,6 +72,7 @@ protected: unsigned long long int int64; //64 bits integer bool skip; //set to true for ascii dxf, false for binary private: + Q_DISABLE_COPY(dxfReader) DRW_TextCodec decoder; }; diff --git a/src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp b/src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp index 40ca3fc15..63a691ee3 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dxfwriter.cpp @@ -105,8 +105,8 @@ bool dxfWriter::writeUtf8Caps(int code, std::string text) { bool dxfWriterBinary::writeString(int code, std::string text) { char bufcode[2]; - bufcode[0] =code & 0xFF; - bufcode[1] =code >> 8; + bufcode[0] = static_cast(code & 0xFF); + bufcode[1] = static_cast(code >> 8); filestr->write(bufcode, 2); *filestr << text << '\0'; return (filestr->good()); @@ -145,10 +145,10 @@ bool dxfWriterBinary::writeString(int code, std::string text) { bool dxfWriterBinary::writeInt16(int code, int data) { char bufcode[2]; char buffer[2]; - bufcode[0] =code & 0xFF; - bufcode[1] =code >> 8; - buffer[0] =data & 0xFF; - buffer[1] =data >> 8; + bufcode[0] = static_cast(code & 0xFF); + bufcode[1] = static_cast(code >> 8); + buffer[0] = static_cast(data & 0xFF); + buffer[1] = static_cast(data >> 8); filestr->write(bufcode, 2); filestr->write(buffer, 2); return (filestr->good()); @@ -156,32 +156,32 @@ bool dxfWriterBinary::writeInt16(int code, int data) { bool dxfWriterBinary::writeInt32(int code, int data) { char buffer[4]; - buffer[0] =code & 0xFF; - buffer[1] =code >> 8; + buffer[0] = static_cast(code & 0xFF); + buffer[1] = static_cast(code >> 8); filestr->write(buffer, 2); - buffer[0] =data & 0xFF; - buffer[1] =data >> 8; - buffer[2] =data >> 16; - buffer[3] =data >> 24; + buffer[0] = static_cast(data & 0xFF); + buffer[1] = static_cast(data >> 8); + buffer[2] = static_cast(data >> 16); + buffer[3] = static_cast(data >> 24); filestr->write(buffer, 4); return (filestr->good()); } bool dxfWriterBinary::writeInt64(int code, unsigned long long int data) { char buffer[8]; - buffer[0] =code & 0xFF; - buffer[1] =code >> 8; + buffer[0] = static_cast(code & 0xFF); + buffer[1] = static_cast(code >> 8); filestr->write(buffer, 2); - buffer[0] =data & 0xFF; - buffer[1] =data >> 8; - buffer[2] =data >> 16; - buffer[3] =data >> 24; - buffer[4] =data >> 32; - buffer[5] =data >> 40; - buffer[6] =data >> 48; - buffer[7] =data >> 56; + buffer[0] = static_cast(data & 0xFF); + buffer[1] = static_cast(data >> 8); + buffer[2] = static_cast(data >> 16); + buffer[3] = static_cast(data >> 24); + buffer[4] = static_cast(data >> 32); + buffer[5] = static_cast(data >> 40); + buffer[6] = static_cast(data >> 48); + buffer[7] = static_cast(data >> 56); filestr->write(buffer, 8); return (filestr->good()); } @@ -189,12 +189,12 @@ bool dxfWriterBinary::writeInt64(int code, unsigned long long int data) { bool dxfWriterBinary::writeDouble(int code, double data) { char bufcode[2]; char buffer[8]; - bufcode[0] =code & 0xFF; - bufcode[1] =code >> 8; + bufcode[0] = static_cast(code & 0xFF); + bufcode[1] = static_cast(code >> 8); filestr->write(bufcode, 2); unsigned char *val; - val = (unsigned char *) &data; + val = reinterpret_cast(&data); for (int i=0; i<8; i++) { buffer[i] =val[i]; } @@ -206,8 +206,8 @@ bool dxfWriterBinary::writeDouble(int code, double data) { bool dxfWriterBinary::writeBool(int code, bool data) { char buffer[1]; char bufcode[2]; - bufcode[0] =code & 0xFF; - bufcode[1] =code >> 8; + bufcode[0] = static_cast(code & 0xFF); + bufcode[1] = static_cast(code >> 8); filestr->write(bufcode, 2); buffer[0] = data; filestr->write(buffer, 1); diff --git a/src/libs/vdxf/libdxfrw/intern/dxfwriter.h b/src/libs/vdxf/libdxfrw/intern/dxfwriter.h index 2af464bea..09b26c349 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfwriter.h +++ b/src/libs/vdxf/libdxfrw/intern/dxfwriter.h @@ -17,8 +17,12 @@ class dxfWriter { public: - dxfWriter(std::ofstream *stream){filestr = stream; /*count =0;*/} - virtual ~dxfWriter(){} + dxfWriter(std::ofstream *stream) + : filestr(stream), + encoder() + {} + + virtual ~dxfWriter() = default; virtual bool writeString(int code, std::string text) = 0; bool writeUtf8String(int code, std::string text); bool writeUtf8Caps(int code, std::string text); @@ -34,6 +38,7 @@ public: protected: std::ofstream *filestr; private: + Q_DISABLE_COPY(dxfWriter) DRW_TextCodec encoder; }; diff --git a/src/libs/vdxf/libdxfrw/intern/rscodec.cpp b/src/libs/vdxf/libdxfrw/intern/rscodec.cpp index 78926f3fa..e518abfbb 100644 --- a/src/libs/vdxf/libdxfrw/intern/rscodec.cpp +++ b/src/libs/vdxf/libdxfrw/intern/rscodec.cpp @@ -29,20 +29,19 @@ #include // std::nothrow #include -RScodec::RScodec(unsigned int pp, int mm, int tt) { - this->mm = mm; - this->tt = tt; - nn = (1<(err[loc[i]]);/*change errors by correct data, in polynomial form */ } } return count; @@ -330,10 +329,10 @@ bool RScodec::encode(unsigned char *data, unsigned char *parity) { if (feedback != -1) { for (j=bb-1; j>0; j--) if (gg[j] != -1) - bd[j] = bd[j-1]^alpha_to[(gg[j]+feedback)%nn] ; + bd[j] = static_cast(bd[j-1]^alpha_to[(gg[j]+feedback)%nn]); else bd[j] = bd[j-1] ; - bd[0] = alpha_to[(gg[0]+feedback)%nn] ; + bd[0] = static_cast(alpha_to[(gg[0]+feedback)%nn]); } else { for (j=bb-1; j>0; j--) bd[j] = bd[j-1] ; diff --git a/src/libs/vdxf/libdxfrw/intern/rscodec.h b/src/libs/vdxf/libdxfrw/intern/rscodec.h index 10cb2a833..7fa3fc289 100644 --- a/src/libs/vdxf/libdxfrw/intern/rscodec.h +++ b/src/libs/vdxf/libdxfrw/intern/rscodec.h @@ -28,6 +28,9 @@ #ifndef RSCODEC_H #define RSCODEC_H + +#include + /** mm: RS code over GF(2^4) nn: nn= (2^mm) - 1 length of codeword @@ -55,6 +58,7 @@ private: private: + Q_DISABLE_COPY(RScodec) int mm; //RS code over GF(2^4) int tt; //number of errors that can be corrected int nn; //(2^mm) - 1 length of codeword diff --git a/src/libs/vdxf/libdxfrw/libdwgr.cpp b/src/libs/vdxf/libdxfrw/libdwgr.cpp index adca43c25..7200f5c9b 100644 --- a/src/libs/vdxf/libdxfrw/libdwgr.cpp +++ b/src/libs/vdxf/libdxfrw/libdwgr.cpp @@ -35,17 +35,20 @@ secObjects };*/ -dwgR::dwgR(){ +dwgR::dwgR() + : version(DRW::UNKNOWNV), + error(DRW::BAD_NONE), + fileName(), + applyExt(false), + codePage(), + iface(), + reader(nullptr) +{ DRW_DBGSL(DRW_dbg::NONE); - reader = NULL; -// writer = NULL; - applyExt = false; - version = DRW::UNKNOWNV; - error = DRW::BAD_NONE; } dwgR::~dwgR(){ - if (reader != NULL) + if (reader != nullptr) delete reader; } @@ -74,9 +77,9 @@ bool dwgR::getPreview(std::istream &stream){ } else error = DRW::BAD_READ_METADATA; - if (reader != NULL) { + if (reader != nullptr) { delete reader; - reader = NULL; + reader = nullptr; } return isOk; } @@ -101,9 +104,9 @@ bool dwgR::read(std::istream &stream, DRW_Interface *interface_, bool ext){ } else error = DRW::BAD_READ_METADATA; - if (reader != NULL) { + if (reader != nullptr) { delete reader; - reader = NULL; + reader = nullptr; } return isOk; diff --git a/src/libs/vdxf/libdxfrw/libdwgr.h b/src/libs/vdxf/libdxfrw/libdwgr.h index 060100495..dff7a0930 100644 --- a/src/libs/vdxf/libdxfrw/libdwgr.h +++ b/src/libs/vdxf/libdxfrw/libdwgr.h @@ -14,7 +14,7 @@ #define LIBDWGR_H #include -//#include +#include #include "drw_entities.h" #include "drw_objects.h" #include "drw_classes.h" @@ -37,6 +37,7 @@ private: bool open(std::istream *stream); bool processDwg(); private: + Q_DISABLE_COPY(dwgR) DRW::Version version; DRW::error error; std::string fileName; diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index 097e23bed..849156669 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -32,18 +32,33 @@ secObjects };*/ -dxfRW::dxfRW(const char* name){ +dxfRW::dxfRW(const char* name) + : version(), + fileName(name), + codePage(), + binFile(), + reader(nullptr), + writer(nullptr), + iface(), + header(), + nextentity(), + entCount(), + wlayer0(), + dimstyleStd(), + applyExt(false), + writingBlock(), + elParts(128), //parts munber when convert ellipse to polyline + blockMap(), + imageDef(), + currHandle() +{ DRW_DBGSL(DRW_dbg::NONE); - fileName = name; - reader = NULL; - writer = NULL; - applyExt = false; - elParts = 128; //parts munber when convert ellipse to polyline } + dxfRW::~dxfRW(){ - if (reader != NULL) + if (reader != nullptr) delete reader; - if (writer != NULL) + if (writer != nullptr) delete writer; for (std::vector::iterator it=imageDef.begin(); it!=imageDef.end(); ++it) delete *it; @@ -66,7 +81,7 @@ bool dxfRW::read(DRW_Interface *interface_, bool ext){ bool isOk = false; applyExt = ext; std::ifstream filestr; - if ( interface_ == NULL ) + if ( interface_ == nullptr ) return isOk; DRW_DBG("dxfRW::read 1def\n"); filestr.open (fileName.c_str(), std::ios_base::in | std::ios::binary); @@ -77,7 +92,7 @@ bool dxfRW::read(DRW_Interface *interface_, bool ext){ char line[22]; char line2[22] = "AutoCAD Binary DXF\r\n"; - line2[20] = (char)26; + line2[20] = static_cast(26); line2[21] = '\0'; filestr.read (line, 22); filestr.close(); @@ -99,7 +114,7 @@ bool dxfRW::read(DRW_Interface *interface_, bool ext){ isOk = processDxf(); filestr.close(); delete reader; - reader = NULL; + reader = nullptr; return isOk; } @@ -112,7 +127,7 @@ bool dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin){ if (binFile) { filestr.open (fileName.c_str(), std::ios_base::out | std::ios::binary | std::ios::trunc); //write sentinel - filestr << "AutoCAD Binary DXF\r\n" << (char)26 << '\0'; + filestr << "AutoCAD Binary DXF\r\n" << static_cast(26) << '\0'; writer = new dxfWriterBinary(&filestr); DRW_DBG("dxfRW::read binary file\n"); } else { @@ -157,7 +172,7 @@ bool dxfRW::write(DRW_Interface *interface_, DRW::Version ver, bool bin){ filestr.close(); isOk = true; delete writer; - writer = NULL; + writer = nullptr; return isOk; } @@ -530,7 +545,7 @@ bool dxfRW::writePoint(DRW_Point *ent) { } writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0) { + if (not qFuzzyIsNull(ent->basePoint.z)) { writer->writeDouble(30, ent->basePoint.z); } return true; @@ -544,7 +559,7 @@ bool dxfRW::writeLine(DRW_Line *ent) { } writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0 || ent->secPoint.z != 0.0) { + if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z)) { writer->writeDouble(30, ent->basePoint.z); writer->writeDouble(11, ent->secPoint.x); writer->writeDouble(21, ent->secPoint.y); @@ -566,7 +581,7 @@ bool dxfRW::writeRay(DRW_Ray *ent) { crd.unitize(); writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0 || ent->secPoint.z != 0.0) { + if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z)) { writer->writeDouble(30, ent->basePoint.z); writer->writeDouble(11, crd.x); writer->writeDouble(21, crd.y); @@ -588,7 +603,7 @@ bool dxfRW::writeXline(DRW_Xline *ent) { crd.unitize(); writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0 || ent->secPoint.z != 0.0) { + if (not qFuzzyIsNull(ent->basePoint.z) || not qFuzzyIsNull(ent->secPoint.z)) { writer->writeDouble(30, ent->basePoint.z); writer->writeDouble(11, crd.x); writer->writeDouble(21, crd.y); @@ -608,7 +623,7 @@ bool dxfRW::writeCircle(DRW_Circle *ent) { } writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0) { + if (not qFuzzyIsNull(ent->basePoint.z)) { writer->writeDouble(30, ent->basePoint.z); } writer->writeDouble(40, ent->radious); @@ -623,7 +638,7 @@ bool dxfRW::writeArc(DRW_Arc *ent) { } writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0) { + if (not qFuzzyIsNull(ent->basePoint.z)) { writer->writeDouble(30, ent->basePoint.z); } writer->writeDouble(40, ent->radious); @@ -733,23 +748,23 @@ bool dxfRW::writeLWPolyline(DRW_LWPolyline *ent){ if (version > DRW::AC1009) { writer->writeString(100, "AcDbPolyline"); } - ent->vertexnum = (int)ent->vertlist.size(); + ent->vertexnum = static_cast(ent->vertlist.size()); writer->writeInt32(90, ent->vertexnum); writer->writeInt16(70, ent->flags); writer->writeDouble(43, ent->width); - if (ent->elevation != 0) + if (not qFuzzyIsNull(ent->elevation)) writer->writeDouble(38, ent->elevation); - if (ent->thickness != 0) + if (not qFuzzyIsNull(ent->thickness)) writer->writeDouble(39, ent->thickness); for (int i = 0; i< ent->vertexnum; i++){ DRW_Vertex2D *v = ent->vertlist.at(i); writer->writeDouble(10, v->x); writer->writeDouble(20, v->y); - if (v->stawidth != 0) + if (not qFuzzyIsNull(v->stawidth)) writer->writeDouble(40, v->stawidth); - if (v->endwidth != 0) + if (not qFuzzyIsNull(v->endwidth)) writer->writeDouble(41, v->endwidth); - if (v->bulge != 0) + if (not qFuzzyIsNull(v->bulge)) writer->writeDouble(42, v->bulge); } } else { @@ -774,14 +789,14 @@ bool dxfRW::writePolyline(DRW_Polyline *ent) { writer->writeDouble(10, 0.0); writer->writeDouble(20, 0.0); writer->writeDouble(30, ent->basePoint.z); - if (ent->thickness != 0) { + if (not qFuzzyIsNull(ent->thickness)) { writer->writeDouble(39, ent->thickness); } writer->writeInt16(70, ent->flags); - if (ent->defstawidth != 0) { + if (not qFuzzyIsNull(ent->defstawidth)) { writer->writeDouble(40, ent->defstawidth); } - if (ent->defendwidth != 0) { + if (not qFuzzyIsNull(ent->defendwidth)) { writer->writeDouble(41, ent->defendwidth); } if (ent->flags & 16 || ent->flags & 32) { @@ -798,7 +813,7 @@ bool dxfRW::writePolyline(DRW_Polyline *ent) { writer->writeInt16(75, ent->curvetype); } DRW_Coord crd = ent->extPoint; - if (crd.x != 0 || crd.y != 0 || crd.z != 1) { + if (not qFuzzyIsNull(crd.x) || not qFuzzyIsNull(crd.y) || not DRW_FuzzyComparePossibleNulls(crd.z, 1)) { writer->writeDouble(210, crd.x); writer->writeDouble(220, crd.y); writer->writeDouble(230, crd.z); @@ -827,11 +842,11 @@ bool dxfRW::writePolyline(DRW_Polyline *ent) { writer->writeDouble(20, v->basePoint.y); writer->writeDouble(30, v->basePoint.z); } - if (v->stawidth != 0) + if (not qFuzzyIsNull(v->stawidth)) writer->writeDouble(40, v->stawidth); - if (v->endwidth != 0) + if (not qFuzzyIsNull(v->endwidth)) writer->writeDouble(41, v->endwidth); - if (v->bulge != 0) + if (not qFuzzyIsNull(v->bulge)) writer->writeDouble(42, v->bulge); if (v->flags != 0) { writer->writeInt16(70, ent->flags); @@ -883,7 +898,7 @@ bool dxfRW::writeSpline(DRW_Spline *ent){ for (int i = 0; i< ent->nknots; i++){ writer->writeDouble(40, ent->knotslist.at(i)); } - for (int i = 0; i< (int)ent->weightlist.size(); i++) { + for (int i = 0; i< static_cast(ent->weightlist.size()); i++) { writer->writeDouble(41, ent->weightlist.at(i)); } for (int i = 0; i< ent->ncontrol; i++){ @@ -912,7 +927,7 @@ bool dxfRW::writeHatch(DRW_Hatch *ent){ writer->writeString(2, ent->name); writer->writeInt16(70, ent->solid); writer->writeInt16(71, ent->associative); - ent->loopsnum = (int)ent->looplist.size(); + ent->loopsnum = static_cast(ent->looplist.size()); writer->writeInt16(91, ent->loopsnum); //write paths data for (int i = 0; i< ent->loopsnum; i++){ @@ -928,7 +943,7 @@ bool dxfRW::writeHatch(DRW_Hatch *ent){ switch ( (loop->objlist.at(j))->eType) { case DRW::LINE: { writer->writeInt16(72, 1); - DRW_Line* l = (DRW_Line*)loop->objlist.at(j); + DRW_Line* l = static_cast(loop->objlist.at(j)); writer->writeDouble(10, l->basePoint.x); writer->writeDouble(20, l->basePoint.y); writer->writeDouble(11, l->secPoint.x); @@ -936,7 +951,7 @@ bool dxfRW::writeHatch(DRW_Hatch *ent){ break; } case DRW::ARC: { writer->writeInt16(72, 2); - DRW_Arc* a = (DRW_Arc*)loop->objlist.at(j); + DRW_Arc* a = static_cast(loop->objlist.at(j)); writer->writeDouble(10, a->basePoint.x); writer->writeDouble(20, a->basePoint.y); writer->writeDouble(40, a->radious); @@ -946,7 +961,7 @@ bool dxfRW::writeHatch(DRW_Hatch *ent){ break; } case DRW::ELLIPSE: { writer->writeInt16(72, 3); - DRW_Ellipse* a = (DRW_Ellipse*)loop->objlist.at(j); + DRW_Ellipse* a = static_cast(loop->objlist.at(j)); a->correctAxis(); writer->writeDouble(10, a->basePoint.x); writer->writeDouble(20, a->basePoint.y); @@ -1000,7 +1015,7 @@ bool dxfRW::writeLeader(DRW_Leader *ent){ writer->writeDouble(40, ent->textheight); writer->writeDouble(41, ent->textwidth); writer->writeDouble(76, ent->vertnum); - writer->writeDouble(76, ent->vertexlist.size()); + writer->writeDouble(76, static_cast(ent->vertexlist.size())); for (unsigned int i=0; ivertexlist.size(); i++) { DRW_Coord *vert = ent->vertexlist.at(i); writer->writeDouble(10, vert->x); @@ -1034,10 +1049,10 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { writer->writeInt16(71, ent->getAlign()); if ( ent->getTextLineStyle() != 1) writer->writeInt16(72, ent->getTextLineStyle()); - if ( ent->getTextLineFactor() != 1) + if ( not DRW_FuzzyComparePossibleNulls(ent->getTextLineFactor(), 1)) writer->writeDouble(41, ent->getTextLineFactor()); writer->writeUtf8String(3, ent->getStyle()); - if ( ent->getTextLineFactor() != 0) + if ( not qFuzzyIsNull(ent->getTextLineFactor())) writer->writeDouble(53, ent->getDir()); writer->writeDouble(210, ent->getExtrusion().x); writer->writeDouble(220, ent->getExtrusion().y); @@ -1048,10 +1063,10 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { switch (ent->eType) { case DRW::DIMALIGNED: case DRW::DIMLINEAR: { - DRW_DimAligned * dd = (DRW_DimAligned*)ent; + DRW_DimAligned * dd = static_cast(ent); writer->writeString(100, "AcDbAlignedDimension"); DRW_Coord crd = dd->getClonepoint(); - if (crd.x != 0 || crd.y != 0 || crd.z != 0) { + if (not qFuzzyIsNull(crd.x) || not qFuzzyIsNull(crd.y) || not qFuzzyIsNull(crd.z)) { writer->writeDouble(12, crd.x); writer->writeDouble(22, crd.y); writer->writeDouble(32, crd.z); @@ -1063,16 +1078,16 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { writer->writeDouble(24, dd->getDef2Point().y); writer->writeDouble(34, dd->getDef2Point().z); if (ent->eType == DRW::DIMLINEAR) { - DRW_DimLinear * dl = (DRW_DimLinear*)ent; - if (dl->getAngle() != 0) + DRW_DimLinear * dl = static_cast(ent); + if (not qFuzzyIsNull(dl->getAngle())) writer->writeDouble(50, dl->getAngle()); - if (dl->getOblique() != 0) + if (not qFuzzyIsNull(dl->getOblique())) writer->writeDouble(52, dl->getOblique()); writer->writeString(100, "AcDbRotatedDimension"); } break; } case DRW::DIMRADIAL: { - DRW_DimRadial * dd = (DRW_DimRadial*)ent; + DRW_DimRadial * dd = static_cast(ent); writer->writeString(100, "AcDbRadialDimension"); writer->writeDouble(15, dd->getDiameterPoint().x); writer->writeDouble(25, dd->getDiameterPoint().y); @@ -1080,7 +1095,7 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { writer->writeDouble(40, dd->getLeaderLength()); break; } case DRW::DIMDIAMETRIC: { - DRW_DimDiametric * dd = (DRW_DimDiametric*)ent; + DRW_DimDiametric * dd = static_cast(ent); writer->writeString(100, "AcDbDiametricDimension"); writer->writeDouble(15, dd->getDiameter1Point().x); writer->writeDouble(25, dd->getDiameter1Point().y); @@ -1088,7 +1103,7 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { writer->writeDouble(40, dd->getLeaderLength()); break; } case DRW::DIMANGULAR: { - DRW_DimAngular * dd = (DRW_DimAngular*)ent; + DRW_DimAngular * dd = static_cast(ent); writer->writeString(100, "AcDb2LineAngularDimension"); writer->writeDouble(13, dd->getFirstLine1().x); writer->writeDouble(23, dd->getFirstLine1().y); @@ -1104,7 +1119,7 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { writer->writeDouble(36, dd->getDimPoint().z); break; } case DRW::DIMANGULAR3P: { - DRW_DimAngular3p * dd = (DRW_DimAngular3p*)ent; + DRW_DimAngular3p * dd = static_cast(ent); writer->writeDouble(13, dd->getFirstLine().x); writer->writeDouble(23, dd->getFirstLine().y); writer->writeDouble(33, dd->getFirstLine().z); @@ -1116,7 +1131,7 @@ bool dxfRW::writeDimension(DRW_Dimension *ent) { writer->writeDouble(35, dd->getVertexPoint().z); break; } case DRW::DIMORDINATE: { - DRW_DimOrdinate * dd = (DRW_DimOrdinate*)ent; + DRW_DimOrdinate * dd = static_cast(ent); writer->writeString(100, "AcDbOrdinateDimension"); writer->writeDouble(13, dd->getFirstLine().x); writer->writeDouble(23, dd->getFirstLine().y); @@ -1238,7 +1253,7 @@ bool dxfRW::writeViewport(DRW_Viewport *ent) { } writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); - if (ent->basePoint.z != 0.0) + if (not qFuzzyIsNull(ent->basePoint.z)) writer->writeDouble(30, ent->basePoint.z); writer->writeDouble(40, ent->pswidth); writer->writeDouble(41, ent->psheight); @@ -1352,7 +1367,7 @@ bool dxfRW::writeBlock(DRW_Block *bk){ writer->writeInt16(70, bk->flags); writer->writeDouble(10, bk->basePoint.x); writer->writeDouble(20, bk->basePoint.y); - if (bk->basePoint.z != 0.0) { + if (not qFuzzyIsNull(bk->basePoint.z)) { writer->writeDouble(30, bk->basePoint.z); } if (version > DRW::AC1009) @@ -2667,6 +2682,10 @@ bool dxfRW::processDimension() { nextentity = reader->getString(); DRW_DBG(nextentity); DRW_DBG("\n"); int type = dim.type & 0x0F; + + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wswitch-default") + switch (type) { case 0: { DRW_DimLinear d(dim); @@ -2697,6 +2716,9 @@ bool dxfRW::processDimension() { iface->addDimOrdinate(&d); break; } } + + QT_WARNING_POP + return true; //found new entity or ENDSEC, terminate } default: diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.h b/src/libs/vdxf/libdxfrw/libdxfrw.h index 18c264952..86ccaaeae 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.h +++ b/src/libs/vdxf/libdxfrw/libdxfrw.h @@ -72,6 +72,7 @@ public: void setEllipseParts(int parts){elParts = parts;} /*!< set parts munber when convert ellipse to polyline */ private: + Q_DISABLE_COPY(dxfRW) /// used by read() to parse the content of the file bool processDxf(); bool processHeader(); diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 8a935bee8..a6e219e8b 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -264,10 +264,10 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data) } // MCP QStringList qslMaterials; - qslMaterials << QApplication::translate("Detail", "Fabric", 0) - << QApplication::translate("Detail", "Lining", 0) - << QApplication::translate("Detail", "Interfacing", 0) - << QApplication::translate("Detail", "Interlining", 0); + qslMaterials << QApplication::translate("Detail", "Fabric", nullptr) + << QApplication::translate("Detail", "Lining", nullptr) + << QApplication::translate("Detail", "Interfacing", nullptr) + << QApplication::translate("Detail", "Interlining", nullptr); QString qsText = QLatin1String("%1, ") + tr("cut") + QLatin1String(" %2%3"); QStringList qslPlace; qslPlace << "" << QLatin1String(" ") + tr("on fold"); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 33f820bf0..c6966e159 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -155,7 +155,7 @@ void SetOverrideCursor(Qt::CursorShape shape) #ifndef QT_NO_CURSOR QPixmap oldPixmap; QCursor* pOldCursor = QGuiApplication::overrideCursor(); - if (pOldCursor != 0) + if (pOldCursor != nullptr) { oldPixmap = pOldCursor->pixmap(); } @@ -200,7 +200,7 @@ void RestoreOverrideCursor(Qt::CursorShape shape) #ifndef QT_NO_CURSOR QPixmap oldPixmap; QCursor* pOldCursor = QGuiApplication::overrideCursor(); - if (pOldCursor != 0) + if (pOldCursor != nullptr) { oldPixmap = pOldCursor->pixmap(); } diff --git a/src/libs/vmisc/vsettings.h b/src/libs/vmisc/vsettings.h index bd3d37f7e..39454c69c 100644 --- a/src/libs/vmisc/vsettings.h +++ b/src/libs/vmisc/vsettings.h @@ -51,7 +51,7 @@ class VSettings : public VCommonSettings Q_OBJECT public: VSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), - QObject *parent = 0); + QObject *parent = nullptr); QString GetLabelLanguage() const; void SetLabelLanguage(const QString &value); diff --git a/src/libs/vmisc/vtapesettings.h b/src/libs/vmisc/vtapesettings.h index bc7d743e2..436b07a79 100644 --- a/src/libs/vmisc/vtapesettings.h +++ b/src/libs/vmisc/vtapesettings.h @@ -44,7 +44,7 @@ class VTapeSettings : public VCommonSettings Q_OBJECT public: VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), - QObject *parent = 0); + QObject *parent = nullptr); QByteArray GetDataBaseGeometry() const; void SetDataBaseGeometry(const QByteArray &value); diff --git a/src/libs/vobj/delaunay.cpp b/src/libs/vobj/delaunay.cpp index 029b208d9..c36138246 100644 --- a/src/libs/vobj/delaunay.cpp +++ b/src/libs/vobj/delaunay.cpp @@ -132,7 +132,7 @@ static point2d_t* point_alloc() point2d_t* p; p = (point2d_t*)malloc(sizeof(point2d_t)); - assert( p != NULL ); + assert( p != nullptr ); // cppcheck-suppress memsetClassFloat memset(p, 0, sizeof(point2d_t)); @@ -144,7 +144,7 @@ static point2d_t* point_alloc() */ static void point_free( point2d_t* p ) { - assert( p != NULL ); + assert( p != nullptr ); free(p); } @@ -156,7 +156,7 @@ static halfedge_t* halfedge_alloc() halfedge_t* d; d = (halfedge_t*)malloc(sizeof(halfedge_t)); - assert( d != NULL ); + assert( d != nullptr ); memset(d, 0, sizeof(halfedge_t)); return d; @@ -167,7 +167,7 @@ static halfedge_t* halfedge_alloc() */ static void halfedge_free( halfedge_t* d ) { - assert( d != NULL ); + assert( d != nullptr ); memset(d, 0, sizeof(halfedge_t)); free(d); } @@ -182,21 +182,21 @@ void del_free_halfedges( delaunay_t *del ) halfedge_t *d, *sig; /* if there is nothing to do */ - if( del->points == NULL ) + if( del->points == nullptr ) return; for( i = 0; i <= (del->end_point - del->start_point); i++ ) { /* free all the halfedges around the point */ d = del->points[i]->he; - if( d != NULL ) + if( d != nullptr ) { do { sig = d->next; halfedge_free( d ); d = sig; } while( d != del->points[i]->he ); - del->points[i]->he = NULL; + del->points[i]->he = nullptr; } } } @@ -207,7 +207,7 @@ void del_free_halfedges( delaunay_t *del ) //static face_t* face_alloc() //{ // face_t *f = (face_t*)malloc(sizeof(face_t)); -// assert( f != NULL ); +// assert( f != nullptr ); // memset(f, 0, sizeof(face_t)); // return f; //} @@ -217,7 +217,7 @@ void del_free_halfedges( delaunay_t *del ) */ //static void face_free(face_t *f) //{ -// assert( f != NULL ); +// assert( f != nullptr ); // free(f); //} @@ -622,8 +622,8 @@ static void del_remove_edge( halfedge_t *d ) prev = d->prev; pair = d->pair; - assert(next != NULL); - assert(prev != NULL); + assert(next != nullptr); + assert(prev != nullptr); next->prev = prev; prev->next = next; @@ -631,23 +631,23 @@ static void del_remove_edge( halfedge_t *d ) /* check to see if we have already removed pair */ if( pair ) - pair->pair = NULL; + pair->pair = nullptr; /* check to see if the vertex points to this halfedge */ if( d->vertex->he == d ) d->vertex->he = next; - d->vertex = NULL; - d->next = NULL; - d->prev = NULL; - d->pair = NULL; + d->vertex = nullptr; + d->next = nullptr; + d->prev = nullptr; + d->pair = nullptr; next = orig_pair->next; prev = orig_pair->prev; pair = orig_pair->pair; - assert(next != NULL); - assert(prev != NULL); + assert(next != nullptr); + assert(prev != nullptr); next->prev = prev; prev->next = next; @@ -655,16 +655,16 @@ static void del_remove_edge( halfedge_t *d ) /* check to see if we have already removed pair */ if( pair ) - pair->pair = NULL; + pair->pair = nullptr; /* check to see if the vertex points to this halfedge */ if( orig_pair->vertex->he == orig_pair ) orig_pair->vertex->he = next; - orig_pair->vertex = NULL; - orig_pair->next = NULL; - orig_pair->prev = NULL; - orig_pair->pair = NULL; + orig_pair->vertex = nullptr; + orig_pair->next = nullptr; + orig_pair->prev = nullptr; + orig_pair->pair = nullptr; /* finally free the halfedges */ @@ -946,7 +946,7 @@ static void build_halfedge_face( delaunay_t *del, halfedge_t *d ) halfedge_t *curr; /* test if the halfedge has already a pointing face */ - if( d->face != NULL ) + if( d->face != nullptr ) return; del->faces = (face_t*)realloc(del->faces, (del->num_faces + 1) * sizeof(face_t)); @@ -987,7 +987,7 @@ void del_build_faces( delaunay_t *del ) halfedge_t *curr; del->num_faces = 0; - del->faces = NULL; + del->faces = nullptr; /* build external face first */ build_halfedge_face(del, del->rightmost_he->pair); @@ -1006,10 +1006,10 @@ void del_build_faces( delaunay_t *del ) /* */ delaunay2d_t* delaunay2d_from(del_point2d_t *points, quint32 num_points) { - delaunay2d_t* res = NULL; + delaunay2d_t* res = nullptr; delaunay_t del; quint32 i; - quint32* faces = NULL; + quint32* faces = nullptr; del.num_faces = 0; //Warning using uninitialized value @@ -1019,7 +1019,7 @@ delaunay2d_t* delaunay2d_from(del_point2d_t *points, quint32 num_points) { /* allocate the points */ del.points = (point2d_t**)malloc(num_points * sizeof(point2d_t*)); - assert( del.points != NULL ); + assert( del.points != nullptr ); memset(del.points, 0, num_points * sizeof(point2d_t*)); /* copy the points */ diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp index c89c171fc..75a28482d 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -111,10 +111,10 @@ QString VPE::VFileEditWidget::getFile() const void VPE::VFileEditWidget::onToolButtonClicked() { - QString filepath = (Directory ? QFileDialog::getExistingDirectory(0, tr("Directory"), CurrentFilePath, + QString filepath = (Directory ? QFileDialog::getExistingDirectory(nullptr, tr("Directory"), CurrentFilePath, QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog) - : QFileDialog::getOpenFileName(0, tr("Open File"), CurrentFilePath, + : QFileDialog::getOpenFileName(nullptr, tr("Open File"), CurrentFilePath, FileDialogFilter, nullptr, QFileDialog::DontUseNativeDialog)); if (filepath.isNull() == false) diff --git a/src/libs/vpropertyexplorer/vpropertydelegate.h b/src/libs/vpropertyexplorer/vpropertydelegate.h index 435a6ad17..17363fa33 100644 --- a/src/libs/vpropertyexplorer/vpropertydelegate.h +++ b/src/libs/vpropertyexplorer/vpropertydelegate.h @@ -38,7 +38,7 @@ class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDeleg { Q_OBJECT public: - explicit VPropertyDelegate(QObject *parent = 0); + explicit VPropertyDelegate(QObject *parent = nullptr); virtual ~VPropertyDelegate() Q_DECL_OVERRIDE; //! Creates the editor widget diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp b/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp index 55877c8e1..d9c00cd65 100644 --- a/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp @@ -53,7 +53,7 @@ VPE::VPropertyFactoryManager::~VPropertyFactoryManager() delete d_ptr; if (this == DefaultManager) { - DefaultManager = NULL; + DefaultManager = nullptr; } } @@ -94,7 +94,7 @@ void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* f else { // Only remove one type - if (d_ptr->Factories.value(type, NULL) == factory) + if (d_ptr->Factories.value(type, nullptr) == factory) { d_ptr->Factories.remove(type); } @@ -113,7 +113,7 @@ bool VPE::VPropertyFactoryManager::isRegistered(VAbstractPropertyFactory* factor VPE::VAbstractPropertyFactory* VPE::VPropertyFactoryManager::getFactory(const QString& type) { - return d_ptr->Factories.value(type, NULL); + return d_ptr->Factories.value(type, nullptr); } diff --git a/src/libs/vpropertyexplorer/vpropertyformview.cpp b/src/libs/vpropertyexplorer/vpropertyformview.cpp index 3238a6010..27b929039 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformview.cpp @@ -192,7 +192,7 @@ void VPE::VPropertyFormView::removeModelAndSet() { if (static_cast(d_ptr)->Model) { - disconnect(static_cast(d_ptr)->Model, 0, this, 0); + disconnect(static_cast(d_ptr)->Model, nullptr, this, nullptr); static_cast(d_ptr)->Model = nullptr; } diff --git a/src/libs/vpropertyexplorer/vpropertyformview.h b/src/libs/vpropertyexplorer/vpropertyformview.h index a2cda844d..a55784be2 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview.h +++ b/src/libs/vpropertyexplorer/vpropertyformview.h @@ -42,13 +42,13 @@ class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormView : public VPropertyFormWid Q_OBJECT public: //! Constructor - explicit VPropertyFormView(QWidget *parent = 0); + explicit VPropertyFormView(QWidget *parent = nullptr); //! Constructor - explicit VPropertyFormView(VPropertyModel* model, QWidget *parent = 0); + explicit VPropertyFormView(VPropertyModel* model, QWidget *parent = nullptr); //! Constructor - explicit VPropertyFormView(VPropertySet* property_set, QWidget *parent = 0); + explicit VPropertyFormView(VPropertySet* property_set, QWidget *parent = nullptr); //! Destructor virtual ~VPropertyFormView() Q_DECL_OVERRIDE; diff --git a/src/libs/vpropertyexplorer/vpropertyformview_p.h b/src/libs/vpropertyexplorer/vpropertyformview_p.h index 677eff952..1c287275f 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview_p.h +++ b/src/libs/vpropertyexplorer/vpropertyformview_p.h @@ -48,17 +48,17 @@ public: bool IgnoreDataChangedSignal; VPropertyFormViewPrivate() - : VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(NULL), NeedsRebuild(false), + : VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(nullptr), NeedsRebuild(false), IgnoreDataChangedSignal(false) {} explicit VPropertyFormViewPrivate(VPropertyModel* prop_model) - : VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(NULL), NeedsRebuild(false), + : VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(nullptr), NeedsRebuild(false), IgnoreDataChangedSignal(false) {} explicit VPropertyFormViewPrivate(VPropertySet* prop_set) - : VPropertyFormWidgetPrivate(), Model(NULL), PropertySet(prop_set), NeedsRebuild(false), + : VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(prop_set), NeedsRebuild(false), IgnoreDataChangedSignal(false) {} diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp index 571a4bff7..2d0744953 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -79,7 +79,7 @@ void VPE::VPropertyFormWidget::build() if (layout()) { QLayoutItem *child; - while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0) + while (layout()->count() > 0 && (child = layout()->takeAt(0)) != nullptr) { if (child->widget()) { diff --git a/src/libs/vpropertyexplorer/vpropertymodel.h b/src/libs/vpropertyexplorer/vpropertymodel.h index 542e25e81..23a6c9324 100644 --- a/src/libs/vpropertyexplorer/vpropertymodel.h +++ b/src/libs/vpropertyexplorer/vpropertymodel.h @@ -160,7 +160,7 @@ protected: virtual QModelIndex getIndexFromProperty(VProperty* property, int column = 0) const; //! Protected constructor passing the private object - explicit VPropertyModel(VPropertyModelPrivate* d, QObject* parent = 0); + explicit VPropertyModel(VPropertyModelPrivate* d, QObject* parent = nullptr); //! The model data VPropertyModelPrivate* d_ptr; diff --git a/src/libs/vpropertyexplorer/vpropertyset.cpp b/src/libs/vpropertyexplorer/vpropertyset.cpp index 9dda684d3..1e1e08fb3 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.cpp +++ b/src/libs/vpropertyexplorer/vpropertyset.cpp @@ -50,7 +50,7 @@ bool VPE::VPropertySet::addProperty(VProperty *property, const QString &id, cons return false; } - VProperty* tmpParent = parentid.isEmpty() ? NULL : getProperty(parentid); + VProperty* tmpParent = parentid.isEmpty() ? nullptr : getProperty(parentid); return addProperty(property, id, tmpParent); } @@ -96,12 +96,12 @@ bool VPE::VPropertySet::hasProperty(VProperty *property) const return false; } - return hasProperty(property, NULL); + return hasProperty(property, nullptr); } VPE::VProperty *VPE::VPropertySet::getProperty(const QString &id) const { - return d_ptr->Properties.value(id, NULL); + return d_ptr->Properties.value(id, nullptr); } VPE::VProperty *VPE::VPropertySet::takeProperty(const QString &id) @@ -125,7 +125,7 @@ void VPE::VPropertySet::removeProperty(VProperty* prop, bool delete_property) removePropertyFromSet(prop); // Remove from parent and optionally delete - prop->setParent(NULL); + prop->setParent(nullptr); if (delete_property) { @@ -191,7 +191,7 @@ const QList &VPE::VPropertySet::getRootProperties() const VPE::VProperty *VPE::VPropertySet::getRootProperty(int row) const { - return d_ptr->RootProperties.value(row, NULL); + return d_ptr->RootProperties.value(row, nullptr); } int VPE::VPropertySet::getRootPropertyCount() const @@ -204,7 +204,7 @@ VPE::VPropertySet* VPE::VPropertySet::clone() const VPropertySet* tmpResult = new VPropertySet(); foreach(VProperty* tmpProperty, d_ptr->RootProperties) - cloneProperty(tmpProperty, NULL, tmpResult); + cloneProperty(tmpProperty, nullptr, tmpResult); return tmpResult; @@ -217,7 +217,7 @@ bool VPE::VPropertySet::hasProperty(VProperty *property, VProperty *parent) cons return false; } - const QList& tmpChildrenList = (parent != NULL ? parent->getChildren() : d_ptr->RootProperties); + const QList& tmpChildrenList = (parent != nullptr ? parent->getChildren() : d_ptr->RootProperties); foreach(VProperty* tmpProp, tmpChildrenList) { if (!tmpProp) diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.h b/src/libs/vpropertyexplorer/vpropertytreeview.h index f4dd1ee1f..04d1442f2 100644 --- a/src/libs/vpropertyexplorer/vpropertytreeview.h +++ b/src/libs/vpropertyexplorer/vpropertytreeview.h @@ -42,11 +42,11 @@ class VPROPERTYEXPLORERSHARED_EXPORT VPropertyTreeView : public QTreeView Q_OBJECT public: //! Default constructor - explicit VPropertyTreeView(QWidget *parent = 0); + explicit VPropertyTreeView(QWidget *parent = nullptr); //! The destructor, taking a model and setting it to the tree view //! \param model The model to set as model for this tree view - explicit VPropertyTreeView(VPropertyModel* model, QWidget *parent = 0); + explicit VPropertyTreeView(VPropertyModel* model, QWidget *parent = nullptr); //! Destructor virtual ~VPropertyTreeView() Q_DECL_OVERRIDE; @@ -60,7 +60,7 @@ protected: virtual void init(); //! protected constructor - VPropertyTreeView(VPropertyTreeViewPrivate* d, bool init_, QWidget *parent = 0); + VPropertyTreeView(VPropertyTreeViewPrivate* d, bool init_, QWidget *parent = nullptr); //! The protected data VPropertyTreeViewPrivate* d_ptr; diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h index 5659ef9d4..8fb0d1c16 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h +++ b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h @@ -49,7 +49,7 @@ class DialogPointFromArcAndTangent : public DialogTool Q_OBJECT public: - DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogPointFromArcAndTangent(); diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h index 6c1a2bfc3..974c3f325 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h @@ -49,7 +49,7 @@ class DialogPointFromCircleAndTangent : public DialogTool Q_OBJECT public: - DialogPointFromCircleAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + DialogPointFromCircleAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogPointFromCircleAndTangent(); void SetPointName(const QString &value); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h index 59d46e0e4..15e905e65 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h @@ -49,7 +49,7 @@ class DialogPointOfIntersectionArcs : public DialogTool Q_OBJECT public: - DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); virtual ~DialogPointOfIntersectionArcs() Q_DECL_OVERRIDE; void SetPointName(const QString &value); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h index 1239f4fba..5ca099fad 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h @@ -49,7 +49,7 @@ class DialogPointOfIntersectionCircles : public DialogTool Q_OBJECT public: - DialogPointOfIntersectionCircles(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + DialogPointOfIntersectionCircles(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); virtual ~DialogPointOfIntersectionCircles() Q_DECL_OVERRIDE; void SetPointName(const QString &value); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h index cfc369235..b0dfd1a36 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h @@ -48,7 +48,7 @@ class DialogPointOfIntersectionCurves : public DialogTool Q_OBJECT public: - explicit DialogPointOfIntersectionCurves(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + explicit DialogPointOfIntersectionCurves(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); virtual ~DialogPointOfIntersectionCurves() Q_DECL_OVERRIDE; void SetPointName(const QString &value); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 6585d4ff4..97431f1af 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -2649,10 +2649,10 @@ void DialogSeamAllowance::InitPatternPieceDataTab() connect(uiTabLabels->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged); - m_qslMaterials << QApplication::translate("Detail", "Fabric", 0) - << QApplication::translate("Detail", "Lining", 0) - << QApplication::translate("Detail", "Interfacing", 0) - << QApplication::translate("Detail", "Interlining", 0); + m_qslMaterials << QApplication::translate("Detail", "Fabric", nullptr) + << QApplication::translate("Detail", "Lining", nullptr) + << QApplication::translate("Detail", "Interfacing", nullptr) + << QApplication::translate("Detail", "Interlining", nullptr); for (int i = 0; i < m_qslMaterials.count(); ++i) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 0a80c7071..cc477abf8 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1505,15 +1505,15 @@ void VToolSeamAllowance::DeleteTool(bool ask) // Deleting inside UnionDetails cause crash. // Because this object should be inactive from no one we disconnect all signals that may cause a crash // KEEP THIS LIST ACTUALL!!! - disconnect(doc, 0, this, 0); + disconnect(doc, nullptr, this, nullptr); if (QGraphicsScene *toolScene = scene()) { - disconnect(toolScene, 0, this, 0); + disconnect(toolScene, nullptr, this, nullptr); } - disconnect(m_dataLabel, 0, this, 0); - disconnect(m_patternInfo, 0, this, 0); - disconnect(m_grainLine, 0, this, 0); - disconnect(m_sceneDetails, 0, this, 0); + disconnect(m_dataLabel, nullptr, this, nullptr); + disconnect(m_patternInfo, nullptr, this, nullptr); + disconnect(m_grainLine, nullptr, this, nullptr); + disconnect(m_sceneDetails, nullptr, this, nullptr); hide();// User shouldn't see this object diff --git a/src/libs/vtools/undocommands/adddetnode.h b/src/libs/vtools/undocommands/adddetnode.h index 3a9ded5e7..5bafb476e 100644 --- a/src/libs/vtools/undocommands/adddetnode.h +++ b/src/libs/vtools/undocommands/adddetnode.h @@ -42,7 +42,7 @@ class AddDetNode : public VUndoCommand { Q_OBJECT public: - AddDetNode(const QDomElement &xml, VAbstractPattern *doc, const QString &drawName, QUndoCommand *parent = 0); + AddDetNode(const QDomElement &xml, VAbstractPattern *doc, const QString &drawName, QUndoCommand *parent = nullptr); virtual ~AddDetNode() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/addpatternpiece.h b/src/libs/vtools/undocommands/addpatternpiece.h index 0cdc25c19..047944c43 100644 --- a/src/libs/vtools/undocommands/addpatternpiece.h +++ b/src/libs/vtools/undocommands/addpatternpiece.h @@ -42,7 +42,8 @@ class AddPatternPiece : public VUndoCommand { Q_OBJECT public: - AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = 0); + AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, + QUndoCommand *parent = nullptr); virtual ~AddPatternPiece() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/addtocalc.h b/src/libs/vtools/undocommands/addtocalc.h index 212439a90..148503147 100644 --- a/src/libs/vtools/undocommands/addtocalc.h +++ b/src/libs/vtools/undocommands/addtocalc.h @@ -42,7 +42,7 @@ class AddToCalc : public VUndoCommand { Q_OBJECT public: - AddToCalc(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0); + AddToCalc(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); virtual ~AddToCalc() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/deletepatternpiece.h b/src/libs/vtools/undocommands/deletepatternpiece.h index 5f981f1a3..b23950c40 100644 --- a/src/libs/vtools/undocommands/deletepatternpiece.h +++ b/src/libs/vtools/undocommands/deletepatternpiece.h @@ -42,7 +42,7 @@ class DeletePatternPiece : public VUndoCommand { Q_OBJECT public: - DeletePatternPiece(VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = 0); + DeletePatternPiece(VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = nullptr); virtual ~DeletePatternPiece() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/deltool.h b/src/libs/vtools/undocommands/deltool.h index 83377ca80..96d466d8b 100644 --- a/src/libs/vtools/undocommands/deltool.h +++ b/src/libs/vtools/undocommands/deltool.h @@ -42,7 +42,7 @@ class DelTool : public VUndoCommand { Q_OBJECT public: - DelTool(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = 0); + DelTool(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr); virtual ~DelTool() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.h b/src/libs/vtools/undocommands/label/movedoublelabel.h index 4a0147cbf..4864c1d2f 100644 --- a/src/libs/vtools/undocommands/label/movedoublelabel.h +++ b/src/libs/vtools/undocommands/label/movedoublelabel.h @@ -44,7 +44,7 @@ class MoveDoubleLabel : public MoveAbstractLabel Q_OBJECT public: MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, DoublePoint type, - quint32 toolId, quint32 pointId, QUndoCommand *parent = 0); + quint32 toolId, quint32 pointId, QUndoCommand *parent = nullptr); virtual ~MoveDoubleLabel() Q_DECL_OVERRIDE; virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/label/movelabel.h b/src/libs/vtools/undocommands/label/movelabel.h index d3014e85d..e9e18447c 100644 --- a/src/libs/vtools/undocommands/label/movelabel.h +++ b/src/libs/vtools/undocommands/label/movelabel.h @@ -41,7 +41,8 @@ class MoveLabel : public MoveAbstractLabel { Q_OBJECT public: - MoveLabel(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QUndoCommand *parent = 0); + MoveLabel(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, + QUndoCommand *parent = nullptr); virtual ~MoveLabel(); virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/movespoint.h b/src/libs/vtools/undocommands/movespoint.h index 8d67dce4e..08d4720ab 100644 --- a/src/libs/vtools/undocommands/movespoint.h +++ b/src/libs/vtools/undocommands/movespoint.h @@ -44,7 +44,7 @@ class MoveSPoint : public VUndoCommand Q_OBJECT public: MoveSPoint(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, - QUndoCommand *parent = 0); + QUndoCommand *parent = nullptr); virtual ~MoveSPoint() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/renamepp.h b/src/libs/vtools/undocommands/renamepp.h index 2990e0c0d..b56e4c360 100644 --- a/src/libs/vtools/undocommands/renamepp.h +++ b/src/libs/vtools/undocommands/renamepp.h @@ -41,7 +41,7 @@ class RenamePP :public VUndoCommand { Q_OBJECT public: - RenamePP(VAbstractPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent = 0); + RenamePP(VAbstractPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent = nullptr); virtual ~RenamePP() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/savetooloptions.h b/src/libs/vtools/undocommands/savetooloptions.h index 89258dd02..f6d0059ab 100644 --- a/src/libs/vtools/undocommands/savetooloptions.h +++ b/src/libs/vtools/undocommands/savetooloptions.h @@ -43,7 +43,7 @@ class SaveToolOptions : public VUndoCommand Q_OBJECT public: SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VAbstractPattern *doc, const quint32 &id, - QUndoCommand *parent = 0); + QUndoCommand *parent = nullptr); virtual ~SaveToolOptions() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/vundocommand.h b/src/libs/vtools/undocommands/vundocommand.h index c5f22c4de..bf17d96e5 100644 --- a/src/libs/vtools/undocommands/vundocommand.h +++ b/src/libs/vtools/undocommands/vundocommand.h @@ -68,7 +68,7 @@ class VUndoCommand : public QObject, public QUndoCommand { Q_OBJECT public: - VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0); + VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); virtual ~VUndoCommand() Q_DECL_OVERRIDE; signals: void ClearScene(); diff --git a/src/libs/vwidgets/vnobrushscalepathitem.h b/src/libs/vwidgets/vnobrushscalepathitem.h index f9b736dc3..bd968bca1 100644 --- a/src/libs/vwidgets/vnobrushscalepathitem.h +++ b/src/libs/vwidgets/vnobrushscalepathitem.h @@ -38,7 +38,7 @@ class VNoBrushScalePathItem : public QGraphicsPathItem { public: - explicit VNoBrushScalePathItem(QGraphicsItem *parent = 0); + explicit VNoBrushScalePathItem(QGraphicsItem *parent = nullptr); protected: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, diff --git a/src/libs/vwidgets/vwidgetpopup.cpp b/src/libs/vwidgets/vwidgetpopup.cpp index a7357ad70..8e6470bb5 100644 --- a/src/libs/vwidgets/vwidgetpopup.cpp +++ b/src/libs/vwidgets/vwidgetpopup.cpp @@ -66,7 +66,7 @@ void VWidgetPopup::SetWidget(QWidget *widget, bool own) if (mOwn) { - mWidget->setParent(0); + mWidget->setParent(nullptr); delete mWidget; } else @@ -77,7 +77,7 @@ void VWidgetPopup::SetWidget(QWidget *widget, bool own) mWidget = widget; mOwn = own; - mOldParent = 0; + mOldParent = nullptr; if (mWidget) { diff --git a/src/libs/vwidgets/vwidgetpopup.h b/src/libs/vwidgets/vwidgetpopup.h index f6505c912..8acd265b7 100644 --- a/src/libs/vwidgets/vwidgetpopup.h +++ b/src/libs/vwidgets/vwidgetpopup.h @@ -55,7 +55,7 @@ public: If \a parent not specified (default), then popup widget gets attribute Qt::WA_DeleteOnClose and will be deleted after close. */ - explicit VWidgetPopup(QWidget *parent = 0); + explicit VWidgetPopup(QWidget *parent = nullptr); /** Sets widget to be popped up to \a widget. If \a own is true then the widget will be reparented to the popup widget.