Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dwg import: less noisy debugging
  • Loading branch information
jef-n committed Feb 19, 2019
1 parent 1a96982 commit 6090a93
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 52 deletions.
22 changes: 12 additions & 10 deletions external/libdxfrw/drw_entities.cpp
Expand Up @@ -13,15 +13,6 @@
// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#ifndef DWGDEBUG
#ifdef QGSLOGGER_H
#error qgislogger.h already included
#endif
#undef QGISDEBUG
#endif // !DWGDEBUG

#include "qgslogger.h"

#include <cstdlib>

#include "drw_entities.h"
Expand All @@ -31,6 +22,17 @@

#include <QStringList>

#include "qgslogger.h"

#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

#define RESERVE( vector, size ) try { \
vector.reserve(size); \
} catch(const std::exception &e) { \
Expand Down Expand Up @@ -1305,7 +1307,7 @@ bool DRW_Insert::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs )
angle = buf->getBitDouble();
extPoint = buf->getExtrusion( false ); //3BD R14 style

QgsDebugMsgLevel( QStringLiteral( "scale:%1, angle:%2 extrusion:%3" )
QgsDebugMsgLevel( QStringLiteral( "scale:%1 angle:%2 extrusion:%3" )
.arg( QStringLiteral( "%1,%2,%3" ).arg( xscale ).arg( yscale ).arg( zscale ) )
.arg( angle )
.arg( QStringLiteral( "%1,%2,%3" ).arg( extPoint.x ).arg( extPoint.y ).arg( extPoint.z ) ), 4
Expand Down
15 changes: 14 additions & 1 deletion external/libdxfrw/drw_header.cpp
Expand Up @@ -10,17 +10,30 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/

// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#include "drw_header.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
#include "intern/drw_dbg.h"
#include "intern/dwgbuffer.h"

#include "qgslogger.h"
#include <QStringList>

#include <cassert>

#include "qgslogger.h"

#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

DRW_Header::DRW_Header()
: curr( nullptr )
, version( DRW::AC1021 )
Expand Down
16 changes: 14 additions & 2 deletions external/libdxfrw/drw_objects.cpp
Expand Up @@ -10,6 +10,9 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/

// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#include <iostream>
#include <cmath>

Expand All @@ -20,10 +23,19 @@
#include "intern/drw_dbg.h"
#include "intern/dwgutil.h"

#undef QGISDEBUG
#include "qgslogger.h"
#include <QStringList>

#include "qgslogger.h"

#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

#define RESERVE( vector, size ) try { \
vector.reserve(size); \
} catch(const std::exception &e) { \
Expand Down
3 changes: 2 additions & 1 deletion external/libdxfrw/intern/drw_textcodec.cpp
Expand Up @@ -296,7 +296,8 @@ std::string DRW_Converter::encodeNum( int c )
return std::string( ( char * )ret );
}

/** 's' is a string with at least 4 bytes length
/**
* 's' is a string with at least 4 bytes length
** returned 'b' is byte length of encoded char: 2,3 or 4
**/
int DRW_Converter::decodeNum( std::string s, int *b )
Expand Down
29 changes: 9 additions & 20 deletions external/libdxfrw/intern/dwgbuffer.cpp
Expand Up @@ -10,34 +10,23 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/

// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#include "dwgbuffer.h"
#include "../libdwgr.h"
#include "drw_textcodec.h"
#include "drw_dbg.h"

#undef QGISDEBUG
#include "qgslogger.h"

#if 0
//#include <bitset>
#include <fstream>
#include <algorithm>
#include <sstream>
#include "dwgreader.h"
#include "dxfwriter.h"

#define FIRSTHANDLE 48

enum sections
{
secUnknown,
secHeader,
secTables,
secBlocks,
secEntities,
secObjects
};
#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

static unsigned int crctable[256] =
Expand Down
15 changes: 13 additions & 2 deletions external/libdxfrw/intern/dwgreader.cpp
Expand Up @@ -10,6 +10,9 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/

// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#include <cstdlib>
#include <iostream>
#include <fstream>
Expand All @@ -19,12 +22,20 @@
#include "dwgreader.h"
#include "drw_textcodec.h"

#undef QGISDEBUG
#include "qgslogger.h"
#include "qgsmessagelog.h"

#include <QStringList>

#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif


dwgReader::~dwgReader()
{
Expand Down Expand Up @@ -221,7 +232,7 @@ bool dwgReader::readDwgHandles( dwgBuffer *dbuf, duint32 offset, duint32 size )
*/
bool dwgReader::readDwgTables( DRW_Header &hdr, dwgBuffer *dbuf )
{
QgsDebugMsg( "Entering." );
QgsDebugMsgLevel( "Entering.", 4 );

bool ret = true;
bool ret2 = true;
Expand Down
11 changes: 11 additions & 0 deletions external/libdxfrw/intern/dxfreader.cpp
Expand Up @@ -10,6 +10,9 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/

// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#include <cstdlib>
#include <fstream>
#include <string>
Expand All @@ -20,6 +23,14 @@

#include "qgslogger.h"

#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

bool dxfReader::readRec( int *codeData )
{
Expand Down
13 changes: 12 additions & 1 deletion external/libdxfrw/libdxfrw.cpp
Expand Up @@ -10,8 +10,11 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/

// uncomment to get detailed debug output on DWG read. Caution: this option makes DWG import super-slow!
// #define DWGDEBUG 1

#include "libdxfrw.h"

#include <fstream>
#include <algorithm>
#include <sstream>
Expand All @@ -24,6 +27,15 @@

#include "qgslogger.h"

#ifndef DWGDEBUG
#undef QgsDebugCall
#undef QgsDebugMsg
#undef QgsDebugMsgLevel
#define QgsDebugCall
#define QgsDebugMsg(str)
#define QgsDebugMsgLevel(str, level)
#endif

#if __cplusplus >= 201500
#define FALLTHROUGH [[fallthrough]];
#elif defined(__clang__)
Expand Down Expand Up @@ -2314,7 +2326,6 @@ bool dxfRW::processTables()
bool dxfRW::processLType()
{
QgsDebugMsg( "Entering." );

int code;
std::string sectionstr;
bool reading = false;
Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgspointxy.sip.in
Expand Up @@ -262,7 +262,7 @@ Multiply x and y by the given value
sipRes = qHash( *sipCpp );
%End

}; // class QgsPoint
}; // class QgsPointXY



Expand Down

0 comments on commit 6090a93

Please sign in to comment.