From e07693e0bf7cded75dfa2894295007dbd050044c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 20 Jul 2009 20:52:26 +0200 Subject: [PATCH] Small fixes in the debugging stuff, especially in docs. --- debug.cpp | 13 ++++++++++--- debug.h | 20 +++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/debug.cpp b/debug.cpp index 8b42741..1389f69 100644 --- a/debug.cpp +++ b/debug.cpp @@ -1,4 +1,5 @@ #include "headers.h" + #ifndef NDEBUG #include "modules/root.h" @@ -16,7 +17,10 @@ using namespace std; -int pos; +int pos; ///< modified by STREAM_POS macro - stores the current position (to ease debugging) + + + QWidget* MRoot::debugModule(QPixmap &pixmap,const QPoint &click) { // create a new modeless dialog window @@ -264,14 +268,17 @@ QWidget* MQuadTree::debugModule(QPixmap &pixmap,const QPoint &click) { planeBlock->summers_makeValid(); /// \todo only approximation planeBlock->getSums(range).unpack(rSum,r2Sum); float estSE= estimateSE(rSum,r2Sum,range.size(),range.level); + float realSE= range.encoderData->bestSE; + if (realSE==-1) + realSE= numeric_limits::infinity(); QString msg= QString("Level: %1\nRegular: %2\n" "Top-left corner: %3 %4\nWidth: %5\nHeight: %6\n" - "Estimated SE: %7 - %8% of the encoded value") + "Estimated SE: %7 (%8% of the encoded value)") .arg(range.level) .arg(range.isRegular()) .arg(range.x0) .arg(range.y0) .arg(range.width()) .arg(range.height()) - .arg(estSE) .arg(100*estSE/range.encoderData->bestSE); + .arg(estSE) .arg(100*estSE/realSE); return new QLabel(msg); } else { // provide general info diff --git a/debug.h b/debug.h index 7dfd6fe..80f9a3a 100644 --- a/debug.h +++ b/debug.h @@ -1,19 +1,29 @@ #ifndef DEBUG_HEADER_ #define DEBUG_HEADER_ -/** Defining my own ASSERT macro */ +/** A shortcut for things only to be compiled in debugging mode */ +#ifdef NDEBUG + #define DEBUG_ONLY(expr) +#else + #define DEBUG_ONLY(expr) expr +#endif + + +/** Defining my own ASSERT macro to pause execution in the debugger */ #ifdef NDEBUG #define DEBUG_ONLY(expr) #define ASSERT(expr) void(0) #else inline void assert_fail_() { - int *i=0, j=*i; - *i=j; + int *i= 0, j= *i; + *i= j; } #define DEBUG_ONLY(expr) expr #define ASSERT(expr) ( (expr) ? void(0) : assert_fail_() ) #endif + +/** The name for anonymous namespaces (to unconfuse some IDEs) */ #define NOSPACE /* empty */ @@ -30,6 +40,8 @@ template inline T debugCast(U toCast) { #endif } + +/** A shortcut declaration and empty implementation for modules */ #ifdef NDEBUG #define DECLARE_debugModule #define DECLARE_debugModule_empty @@ -40,6 +52,8 @@ template inline T debugCast(U toCast) { virtual QWidget* debugModule(QPixmap &,const QPoint &) { return 0; } #endif + +/** A debugging utility - stores the position in a stream into ::pos (a global variable) */ #ifndef NDEBUG extern int pos; inline void STREAM_POS(std::istream &file) { pos= file.tellg(); } -- 2.11.4.GIT