From a8504910817afdd3e3b0f45af1acb199ee31b7b5 Mon Sep 17 00:00:00 2001 From: mbs Date: Fri, 19 Jan 2024 22:49:18 +0000 Subject: [PATCH] removed DEBUG macros --- src/Model/MBDebug.h | 313 ------------------------ src/Model/Model_Document.cpp | 16 +- src/Model/Model_Session.cpp | 13 +- src/SHAPERGUI/MBDebug.h | 313 ------------------------ src/SHAPERGUI/SHAPERGUI.cpp | 77 +----- src/SHAPERGUI/SHAPERGUI_CheckBackup.cpp | 46 +--- src/SHAPERGUI/SHAPERGUI_DataModel.cpp | 32 +-- 7 files changed, 13 insertions(+), 797 deletions(-) delete mode 100644 src/Model/MBDebug.h delete mode 100644 src/SHAPERGUI/MBDebug.h diff --git a/src/Model/MBDebug.h b/src/Model/MBDebug.h deleted file mode 100644 index 9b4a83e29..000000000 --- a/src/Model/MBDebug.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef MBDebug_HeaderFile -#define MBDebug_HeaderFile - -//--------------------------------------------------------------- -// Usage of the logging facilities: -// -// (1) At the beginning of each class file to be debugged, there -// should be a static string variable defined with the name -// of the class. Then, include the "MBDebug.h" header file. -// -// //--------------------------------------------------------- -// #define USE_DEBUG -// //#define MB_IGNORE_QT -// //#define MB_FULL_DUMP -// #define MBCLASSNAME "ClassName" -// #include "MBDebug.h" -// // <-- insert includes for addtional debug headers here! -// //--------------------------------------------------------- -// -// (2) At the beginning of each class method, call the DBG_FUN -// macro. -// -// int ClassName::MyMethod(int x) -// { -// DBG_FUN(); -// ... -// } -// -// NOTE: For static methods, call the DBG_FUNC() macro!! -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// This debugging/logging class is a "header-only" solution and -// does NOT require any additional implementation (.cpp) file! -//--------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef MB_IGNORE_QT -# include -# include -#endif - -static std::mutex mtx; - -//--------------------------------------------------------------- -// Set the debug flags dependent on the preprocessor definitions -//--------------------------------------------------------------- -#ifdef USE_DEBUG -# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG -#else -# define MBS_DEBUG_FLAG 0 -#endif /*DEBUG*/ - -#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) - - -//--------------------------------------------------------------- -// Define the global debug macros -//--------------------------------------------------------------- -#define DLOG MBDebug::LogPrint() -#define RETURN(var) { RET(var); return (var); } - -#ifdef USE_DEBUG - -# define DBG_FUN() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) -# define DBG_FUNC() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS) -# define DBG_FUNB(blk) MBDebug _dbg(MBCLASSNAME, blk, MBS_DBG_FLAGS) -# define MSGEL(txt) MBDebug::LogPrint() << ":" << txt << std::endl -# define PRINT(txt) MBDebug::LogPrint() << txt -# define SHOW2(var,typ) do { PRINT(std::this_thread::get_id()); DumpVar(#var,(typ)(var)); } while (0) -# define SHOW(var) do { PRINT(std::this_thread::get_id()); DumpVar(#var,var); } while (0) -# define ARG(var) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,var); } while (0) -# define ARG2(var,typ) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,(typ)(var)); } while (0) -# define RET(var) do { PRINT(std::this_thread::get_id() << ":out:"); DumpVar(#var,var); } while (0) -# define MSG(txt) MBDebug::LogPrint() << std::this_thread::get_id() << ":" << txt - -#else /*!USE_DEBUG*/ - -# define DBG_FUN() -# define DBG_FUNC() -# define DBG_FUNB(blk) -# define MSGEL(txt) -# define PRINT(txt) -# define SHOW2(var,typ) -# define SHOW(var) -# define ARG(var) -# define ARG2(var,typ) -# define RET(var) -# define MSG(txt) - -#endif /*USE_DEBUG*/ - - -//--------------------------------------------------------------- -// Declare the debugging and profiling class -//--------------------------------------------------------------- -class MBDebug -{ -public: - enum { - DF_NONE = 0x00, // no debug - DF_DEBUG = 0x01 // debug a function - }; - - MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) - :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":{ENTER: " << mClassName + "::" + mFuncName; - if (mThis) std::cout << "(this=" << mThis << ")"; - std::cout << std::endl; - } - } - virtual ~MBDebug() - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":}LEAVE: " << mClassName << "::" << mFuncName << std::endl; - } - } - - // Log file output management - static std::ostream& LogPrint() { return std::cout; } - -private: - std::string mClassName; // Name of class to be debugged - std::string mFuncName; // Name of function to be debugged - void* mThis; // The "this" pointer to the class being debugged - unsigned char mFlags; // Debug mode flags -}; - - - -#define YesNo(b) (b ? "Yes" : "No") - - - -inline std::string w2s(std::wstring ws) -{ - using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX; - return(converterX.to_bytes(ws)); -} - -// Primitive types -inline void DumpVar(const char *szName, char value) -{ - std::lock_guard lck(mtx); - DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; -} - -inline void DumpVar(const char *szName, bool value) -{ - std::lock_guard lck(mtx); - DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; -} - -inline void DumpVar(const char *szName, short value) -{ - std::lock_guard lck(mtx); - DLOG << "[shrt]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, int value) -{ - std::lock_guard lck(mtx); - DLOG << "[int]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, long value) -{ - std::lock_guard lck(mtx); - DLOG << "[long]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, double value) -{ - std::lock_guard lck(mtx); - DLOG << "[dbl]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, unsigned char value) -{ - std::lock_guard lck(mtx); - DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned short value) -{ - std::lock_guard lck(mtx); - DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned int value) -{ - std::lock_guard lck(mtx); - DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned long value) -{ - std::lock_guard lck(mtx); - DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, const char* value) -{ - std::lock_guard lck(mtx); - DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::string &value) -{ - std::lock_guard lck(mtx); - DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::wstring &value) -{ - std::lock_guard lck(mtx); - DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; -} - -#ifndef MB_IGNORE_QT -inline void DumpVar(const char *szName, const QString &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const QStringList &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStrLst]: " << szName << "=[len=" << value.length() << "] {"; - bool first = true; - QStringList::const_iterator it = value.constBegin(); - for ( ; it != value.constEnd(); ++it) - { - DLOG << (first ? "" : ",") << "\"" << (*it).toStdString() << "\""; - first = false; - } - DLOG << "}" << std::endl; -} -#endif - -inline void DumpVar(const char *szName, const void* value) -{ - std::lock_guard lck(mtx); - DLOG << "[ptr]: " << szName << "=" << value << std::endl; -} - - -// Collection of primitive types -inline void DumpVar(const char *szName, const std::set &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::vector &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intVect]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list& values) -{ - std::lock_guard lck(mtx); - DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list &values) -{ - std::lock_guard lck(mtx); - DLOG << "[strLst]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "\"" : ", \"") << *it << "\""; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -#endif // MBDebug_HeaderFile - diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index df27cd5d1..badd2ae19 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2023 CEA, EDF +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -87,14 +87,6 @@ # define _separator_ '/' #endif -//--------------------------------------------------------- -#define USE_DEBUG -#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "Model_Document" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- static const int UNDO_LIMIT = 1000; // number of possible undo operations (big for sketcher) @@ -457,7 +449,6 @@ static bool saveDocument(Handle(Model_Application) theApp, Handle(TDocStd_Document) theDoc, const TCollection_ExtendedString& theFilename) { - DBG_FUNC(); PCDM_StoreStatus aStatus; try { // create the directory to save the document @@ -499,11 +490,6 @@ bool Model_Document::save( std::list& theResults, bool doBackup/*=false*/) { - DBG_FUN(); - ARG(theDirName); - ARG(theFileName); - ARG(doBackup); - // if the history line is not in the end, move it to the end before save, otherwise // problems with results restore and (the most important) naming problems will appear // due to change evolution to SELECTION (problems in NamedShape and Name) diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index bc89ab43a..da1fb36ad 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2023 CEA, EDF +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -52,14 +52,6 @@ #include -//--------------------------------------------------------- -#define USE_DEBUG -#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "Model_Session" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- static Model_Session* myImpl = new Model_Session(); @@ -76,9 +68,6 @@ bool Model_Session::load(const char* theFileName) bool Model_Session::save(const char* theFileName, std::list& theResults, bool doBackup=false) { - DBG_FUN(); - ARG(theFileName); - ARG(doBackup); return ROOT_DOC->save(theFileName, "root", theResults, doBackup); } diff --git a/src/SHAPERGUI/MBDebug.h b/src/SHAPERGUI/MBDebug.h deleted file mode 100644 index 9b4a83e29..000000000 --- a/src/SHAPERGUI/MBDebug.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef MBDebug_HeaderFile -#define MBDebug_HeaderFile - -//--------------------------------------------------------------- -// Usage of the logging facilities: -// -// (1) At the beginning of each class file to be debugged, there -// should be a static string variable defined with the name -// of the class. Then, include the "MBDebug.h" header file. -// -// //--------------------------------------------------------- -// #define USE_DEBUG -// //#define MB_IGNORE_QT -// //#define MB_FULL_DUMP -// #define MBCLASSNAME "ClassName" -// #include "MBDebug.h" -// // <-- insert includes for addtional debug headers here! -// //--------------------------------------------------------- -// -// (2) At the beginning of each class method, call the DBG_FUN -// macro. -// -// int ClassName::MyMethod(int x) -// { -// DBG_FUN(); -// ... -// } -// -// NOTE: For static methods, call the DBG_FUNC() macro!! -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// This debugging/logging class is a "header-only" solution and -// does NOT require any additional implementation (.cpp) file! -//--------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef MB_IGNORE_QT -# include -# include -#endif - -static std::mutex mtx; - -//--------------------------------------------------------------- -// Set the debug flags dependent on the preprocessor definitions -//--------------------------------------------------------------- -#ifdef USE_DEBUG -# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG -#else -# define MBS_DEBUG_FLAG 0 -#endif /*DEBUG*/ - -#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) - - -//--------------------------------------------------------------- -// Define the global debug macros -//--------------------------------------------------------------- -#define DLOG MBDebug::LogPrint() -#define RETURN(var) { RET(var); return (var); } - -#ifdef USE_DEBUG - -# define DBG_FUN() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) -# define DBG_FUNC() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS) -# define DBG_FUNB(blk) MBDebug _dbg(MBCLASSNAME, blk, MBS_DBG_FLAGS) -# define MSGEL(txt) MBDebug::LogPrint() << ":" << txt << std::endl -# define PRINT(txt) MBDebug::LogPrint() << txt -# define SHOW2(var,typ) do { PRINT(std::this_thread::get_id()); DumpVar(#var,(typ)(var)); } while (0) -# define SHOW(var) do { PRINT(std::this_thread::get_id()); DumpVar(#var,var); } while (0) -# define ARG(var) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,var); } while (0) -# define ARG2(var,typ) do { PRINT(std::this_thread::get_id() << ":in:"); DumpVar(#var,(typ)(var)); } while (0) -# define RET(var) do { PRINT(std::this_thread::get_id() << ":out:"); DumpVar(#var,var); } while (0) -# define MSG(txt) MBDebug::LogPrint() << std::this_thread::get_id() << ":" << txt - -#else /*!USE_DEBUG*/ - -# define DBG_FUN() -# define DBG_FUNC() -# define DBG_FUNB(blk) -# define MSGEL(txt) -# define PRINT(txt) -# define SHOW2(var,typ) -# define SHOW(var) -# define ARG(var) -# define ARG2(var,typ) -# define RET(var) -# define MSG(txt) - -#endif /*USE_DEBUG*/ - - -//--------------------------------------------------------------- -// Declare the debugging and profiling class -//--------------------------------------------------------------- -class MBDebug -{ -public: - enum { - DF_NONE = 0x00, // no debug - DF_DEBUG = 0x01 // debug a function - }; - - MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) - :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":{ENTER: " << mClassName + "::" + mFuncName; - if (mThis) std::cout << "(this=" << mThis << ")"; - std::cout << std::endl; - } - } - virtual ~MBDebug() - { - if (mFlags & (DF_DEBUG)) - { - std::lock_guard lck(mtx); - std::cout << std::this_thread::get_id() << ":}LEAVE: " << mClassName << "::" << mFuncName << std::endl; - } - } - - // Log file output management - static std::ostream& LogPrint() { return std::cout; } - -private: - std::string mClassName; // Name of class to be debugged - std::string mFuncName; // Name of function to be debugged - void* mThis; // The "this" pointer to the class being debugged - unsigned char mFlags; // Debug mode flags -}; - - - -#define YesNo(b) (b ? "Yes" : "No") - - - -inline std::string w2s(std::wstring ws) -{ - using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX; - return(converterX.to_bytes(ws)); -} - -// Primitive types -inline void DumpVar(const char *szName, char value) -{ - std::lock_guard lck(mtx); - DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; -} - -inline void DumpVar(const char *szName, bool value) -{ - std::lock_guard lck(mtx); - DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; -} - -inline void DumpVar(const char *szName, short value) -{ - std::lock_guard lck(mtx); - DLOG << "[shrt]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, int value) -{ - std::lock_guard lck(mtx); - DLOG << "[int]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, long value) -{ - std::lock_guard lck(mtx); - DLOG << "[long]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, double value) -{ - std::lock_guard lck(mtx); - DLOG << "[dbl]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, unsigned char value) -{ - std::lock_guard lck(mtx); - DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned short value) -{ - std::lock_guard lck(mtx); - DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned int value) -{ - std::lock_guard lck(mtx); - DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned long value) -{ - std::lock_guard lck(mtx); - DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, const char* value) -{ - std::lock_guard lck(mtx); - DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::string &value) -{ - std::lock_guard lck(mtx); - DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::wstring &value) -{ - std::lock_guard lck(mtx); - DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; -} - -#ifndef MB_IGNORE_QT -inline void DumpVar(const char *szName, const QString &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const QStringList &value) -{ - std::lock_guard lck(mtx); - DLOG << "[QStrLst]: " << szName << "=[len=" << value.length() << "] {"; - bool first = true; - QStringList::const_iterator it = value.constBegin(); - for ( ; it != value.constEnd(); ++it) - { - DLOG << (first ? "" : ",") << "\"" << (*it).toStdString() << "\""; - first = false; - } - DLOG << "}" << std::endl; -} -#endif - -inline void DumpVar(const char *szName, const void* value) -{ - std::lock_guard lck(mtx); - DLOG << "[ptr]: " << szName << "=" << value << std::endl; -} - - -// Collection of primitive types -inline void DumpVar(const char *szName, const std::set &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::vector &values) -{ - std::lock_guard lck(mtx); - DLOG << "[intVect]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << *it; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list& values) -{ - std::lock_guard lck(mtx); - DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); - bFirst = false; - } - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list &values) -{ - std::lock_guard lck(mtx); - DLOG << "[strLst]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) { - DLOG << (bFirst ? "\"" : ", \"") << *it << "\""; - bFirst = false; - } - DLOG << "]" << std::endl; -} - -#endif // MBDebug_HeaderFile - diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 056679866..2e6ffda44 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2023 CEA, EDF +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -90,13 +90,9 @@ #include //--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "SHAPERGUI" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//#define DBG_BACKUP_INTERVAL 1 /*Use a short 1 min interval for auto backup for debugging*/ +// Use a short 1 min interval for auto backup for debugging +// Uncomment the following line for debugging. +//#define DBG_BACKUP_INTERVAL 1 //--------------------------------------------------------- #if OCC_VERSION_HEX < 0x070400 @@ -163,7 +159,6 @@ SHAPERGUI::SHAPERGUI() myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false), myAxisArrowRate(-1) { - DBG_FUN(); myWorkshop = new XGUI_Workshop(this); connect(myWorkshop, SIGNAL(commandStatusUpdated()), this, SLOT(onUpdateCommandStatus())); @@ -185,7 +180,6 @@ SHAPERGUI::SHAPERGUI() //****************************************************** SHAPERGUI::~SHAPERGUI() { - DBG_FUN(); delete myWorkshop; delete myProxyViewer; } @@ -193,7 +187,6 @@ SHAPERGUI::~SHAPERGUI() //****************************************************** void SHAPERGUI::initialize(CAM_Application* theApp) { - DBG_FUN(); LightApp_Module::initialize(theApp); myWorkshop->startApplication(); @@ -308,7 +301,6 @@ void SHAPERGUI::viewManagers(QStringList& theList) const //****************************************************** bool SHAPERGUI::activateModule(SUIT_Study* theStudy) { - DBG_FUN(); ModelAPI_Session::get()->moduleDocument(); // initialize a root document if not done yet // this must be done in the initialization and in activation (on the second activation @@ -421,7 +413,6 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) #ifdef DBG_BACKUP_INTERVAL backupInterval = DBG_BACKUP_INTERVAL; // MBS: use shorter interval for debugging #endif - MSGEL("....starting BackupTimer: interval=" << backupInterval); myBackupTimer->start( backupInterval*60000 ); } } @@ -445,7 +436,6 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) //****************************************************** void SHAPERGUI::hideInternalWindows() { - DBG_FUN(); myProxyViewer->activateViewer(false); setMenuShown(false); setToolShown(false); @@ -474,11 +464,9 @@ void SHAPERGUI::hideInternalWindows() //****************************************************** bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) { - DBG_FUN(); saveToolbarsConfig(); myWorkshop->deactivateModule(); - MSGEL("....stopping BackupTimer"); myBackupTimer->stop(); myIsInspectionVisible = myInspectionPanel->isVisible(); @@ -601,9 +589,6 @@ private: //****************************************************** void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation) { - DBG_FUN(); - SHOW(theOperation->id()); - onOperationGeneric(theOperation, moduleName(), "committed"); checkForWaitingBackup(); @@ -612,9 +597,6 @@ void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation) //****************************************************** void SHAPERGUI::onOperationAborted(ModuleBase_Operation* theOperation) { - DBG_FUN(); - SHOW(theOperation->id()); - onOperationGeneric(theOperation, moduleName(), "aborted"); checkForWaitingBackup(); @@ -642,7 +624,6 @@ void SHAPERGUI::checkForWaitingBackup() //****************************************************** void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr) { - DBG_FUN(); if (!mySelector) { mySelector = createSelector(theMgr); myWorkshop->selectionActivate()->updateSelectionFilters(); @@ -663,7 +644,6 @@ void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr) //****************************************************** void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr) { - DBG_FUN(); if (mySelector) { if (theMgr->getType() == OCCViewer_Viewer::Type()) { OCCViewer_Viewer* aViewer = static_cast(theMgr->getViewModel()); @@ -702,7 +682,6 @@ QtxPopupMgr* SHAPERGUI::popupMgr() //****************************************************** void SHAPERGUI::onDefaultPreferences() { - DBG_FUN(); // reset main resources ModuleBase_Preferences::resetResourcePreferences(preferences()); // reset plugin's resources @@ -714,7 +693,6 @@ void SHAPERGUI::onDefaultPreferences() //****************************************************** void SHAPERGUI::onScriptLoaded() { - DBG_FUN(); // this slot is called after processing of the LoadScriptId action of SalomeApp Application // Each dumped script contains updateObjBrowser() that creates a new instance of Object // Browser. When SHAPER module is active, this browser should not be used. It might be removed @@ -730,7 +708,6 @@ void SHAPERGUI::onScriptLoaded() //****************************************************** void SHAPERGUI::onSaveDocByShaper() { - DBG_FUN(); if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage)) return; @@ -740,7 +717,6 @@ void SHAPERGUI::onSaveDocByShaper() //****************************************************** void SHAPERGUI::onSaveAsDocByShaper() { - DBG_FUN(); if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage)) return; @@ -750,9 +726,6 @@ void SHAPERGUI::onSaveAsDocByShaper() //****************************************************** void SHAPERGUI::onBackupDoc() { - DBG_FUN(); - MSGEL(" ...backing up current study"); - // We cannot save the study while we are still in an ongoing operation // => so test for this case first and delay the backup to the time when operation finishes if (myWorkshop && myWorkshop->operationMgr()) @@ -786,8 +759,6 @@ public: //****************************************************** int SHAPERGUI::backupDoc() { - DBG_FUN(); - if (myWorkshop->backupState()) { // This should never happen as I restart the backup timer only when a backup has finished myBackupError = tr("Another backup is still running"); @@ -808,7 +779,6 @@ int SHAPERGUI::backupDoc() try { QString aName = study->studyName(); - SHOW(aName); if ( aName.isEmpty() ) { myBackupError = tr("Study name is empty"); return 34; @@ -848,7 +818,6 @@ int SHAPERGUI::backupDoc() aName = fi.completeBaseName(); } QString aFullName = aFolder + aSep + aName + QString(".hdf"); - SHOW(aFullName); // Save the study into a single HDF file isOk = study->saveDocumentAs( aFullName, true ); @@ -872,7 +841,6 @@ int SHAPERGUI::backupDoc() } // Finally start another salome process and reload the saved document & script for verification - SHOW(aFolder); SHAPERGUI_CheckBackup checkBackup(aFolder, aName); QString testBackup("check_validity.py"); QStringList dirs; @@ -894,10 +862,6 @@ int SHAPERGUI::backupDoc() aResult = 40; } - - MSGEL("...emit backupDone signal"); - SHOW(aFolder); - SHOW(aResult); emit backupDone(aFolder, aResult); return aResult; } @@ -905,12 +869,7 @@ int SHAPERGUI::backupDoc() //****************************************************** void SHAPERGUI::onBackupDone(QString aFolder, int aResult) { - DBG_FUN(); - ARG(aFolder); - ARG(aResult); - int aErrCode = myBackupResult.get(); - SHOW(aErrCode); bool isOk = (aResult == 0); if (isOk) { @@ -928,13 +887,8 @@ void SHAPERGUI::onBackupDone(QString aFolder, int aResult) { aBackupStorage = aResMgr->integerValue( ModuleBase_Preferences::GENERAL_SECTION, "auto_backup_storage", -1); } - else - { - MSGEL("ERR: could not get resource manager"); - } if (aBackupStorage == 0/*StoreLastBackupOnly*/) { - MSGEL("===> only keep the latest successful backup: create " << aFolder.toStdString()); // Only keep the latest successful backup => delete the previous one, if it exists if (isOk && !myLastBackupFolder.isEmpty()) { @@ -955,7 +909,6 @@ void SHAPERGUI::onBackupDone(QString aFolder, int aResult) baseName = baseName.left(baseName.lastIndexOf('.')); if (!baseName.isEmpty() && files.filter(baseName).length() == files.length()) { - MSGEL("........removing old backup folder"); const bool success = dir.removeRecursively(); if (!success) { @@ -972,10 +925,6 @@ void SHAPERGUI::onBackupDone(QString aFolder, int aResult) } myLastBackupFolder = aFolder; } - else - { - MSGEL("===> keep entire backup history: adding " << aFolder.toStdString()); - } // Start the timer again if ( aResMgr && application()->activeStudy() ) @@ -989,7 +938,6 @@ void SHAPERGUI::onBackupDone(QString aFolder, int aResult) #ifdef DBG_BACKUP_INTERVAL backupInterval = DBG_BACKUP_INTERVAL; // MBS: use shorter interval for debugging #endif - MSGEL("....starting BackupTimer: interval=" << backupInterval); myBackupTimer->start( backupInterval*60000 ); } } @@ -1010,7 +958,6 @@ void SHAPERGUI::onUpdateCommandStatus() //****************************************************** SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr) { - DBG_FUN(); if (theMgr->getType() == OCCViewer_Viewer::Type()) { OCCViewer_Viewer* aViewer = static_cast(theMgr->getViewModel()); @@ -1050,7 +997,6 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr) //****************************************************** CAM_DataModel* SHAPERGUI::createDataModel() { - DBG_FUN(); return new SHAPERGUI_DataModel(this); } @@ -1278,7 +1224,6 @@ void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QStri //****************************************************** void SHAPERGUI::createPreferences() { - DBG_FUN(); LightApp_Preferences* aPref = preferences(); if (!aPref) return; @@ -1372,9 +1317,6 @@ void SHAPERGUI::createPreferences() //****************************************************** void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& theParam) { - DBG_FUN(); - ARG(theSection); - ARG(theParam); SUIT_ResourceMgr* aResMgr = application()->resourceMgr(); QString aVal = aResMgr->stringValue(theSection, theParam); Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(), @@ -1455,16 +1397,13 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the #ifdef DBG_BACKUP_INTERVAL backupInterval = DBG_BACKUP_INTERVAL; // MBS: use shorter interval for debugging #endif - MSGEL("....starting BackupTimer: interval=" << backupInterval << " min"); myBackupTimer->start( backupInterval*60000 ); } else { - MSGEL("....stopping backup timer"); myBackupTimer->stop(); } } else { - MSGEL("....stopping backup timer"); myBackupTimer->stop(); } } @@ -1485,13 +1424,11 @@ void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs) bool SHAPERGUI::abortAllOperations() { - DBG_FUN(); return workshop()->operationMgr()->abortAllOperations(); } void SHAPERGUI::createFeatureActions() { - DBG_FUN(); myWorkshop->menuMgr()->createFeatureActions(); } @@ -1621,7 +1558,6 @@ void SHAPERGUI::updateToolbars(const QMap& theNewToolbars) void SHAPERGUI::saveToolbarsConfig() { - DBG_FUN(); if (!myIsToolbarsModified) return; // Save toolbars configuration into map @@ -1670,7 +1606,6 @@ void SHAPERGUI::saveToolbarsConfig() void SHAPERGUI::loadToolbarsConfig() { - DBG_FUN(); SUIT_ResourceMgr* aResMgr = application()->resourceMgr(); QStringList aToolbarNames = aResMgr->parameters(ToolbarsSection); if (aToolbarNames.size() == 0) @@ -1771,7 +1706,6 @@ QIntList SHAPERGUI::getFreeCommands() const void SHAPERGUI::resetToolbars() { - DBG_FUN(); if (!myDefaultToolbars.isEmpty()) updateToolbars(myDefaultToolbars); myIsToolbarsModified = false; @@ -1781,16 +1715,13 @@ void SHAPERGUI::resetToolbars() void SHAPERGUI::publishToStudy() { - DBG_FUN(); if (isActiveModule() && ModelAPI_Session::get()->hasModuleDocument()) { myWorkshop->module()->launchOperation("PublishToStudy", false); // update SHAPERSTUDY objects in OCC and VTK viewers QStringList aVMList; aVMList << "OCCViewer" << "VTKViewer"; - MSGEL("publishToStudy() : updatePresentations(SHAPERSTUDY) start."); getApp()->updatePresentations("SHAPERSTUDY", aVMList); - MSGEL("publishToStudy() : updatePresentations(SHAPERSTUDY) end."); } } diff --git a/src/SHAPERGUI/SHAPERGUI_CheckBackup.cpp b/src/SHAPERGUI/SHAPERGUI_CheckBackup.cpp index 85fb2a6da..fca627954 100644 --- a/src/SHAPERGUI/SHAPERGUI_CheckBackup.cpp +++ b/src/SHAPERGUI/SHAPERGUI_CheckBackup.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 CEA, EDF, OPEN CASCADE SAS +// Copyright (C) 2024 CEA, EDF, OPEN CASCADE SAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -23,15 +23,6 @@ #include #include -//--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "SHAPERGUI_CheckBackup" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- - SHAPERGUI_CheckBackup::SHAPERGUI_CheckBackup(const QString &theFolder, const QString &theBaseName) @@ -39,17 +30,11 @@ SHAPERGUI_CheckBackup::SHAPERGUI_CheckBackup(const QString &theFolder, const QSt , myFolder(theFolder) , myBaseName(theBaseName) { - DBG_FUN(); - ARG(theFolder); - ARG(theBaseName); } int SHAPERGUI_CheckBackup::run(const QString &theTestScript) { - DBG_FUN(); - ARG(theTestScript); - int aResult = 0; if (myProcess) return 64; @@ -84,14 +69,10 @@ int SHAPERGUI_CheckBackup::run(const QString &theTestScript) // Start a python script (test_backup.py), which itself // * launches a SALOME process // * opens the previously backed up HDF study - SHOW(aProgName); - SHOW(args); myProcess->start(aProgName, args); myProcess->waitForFinished(300000); QProcess::ExitStatus exitStat = myProcess->exitStatus(); // 0=NormalExit, 1=CrashExit - SHOW(exitStat); int exitCode = myProcess->exitCode(); - SHOW(exitCode); if (exitStat == QProcess::NormalExit && exitCode != 0) aResult = exitCode; else if (exitStat == QProcess::CrashExit) @@ -114,19 +95,16 @@ int SHAPERGUI_CheckBackup::run(const QString &theTestScript) std::string strResult = line.substr(11); if (strResult.find("PASSED") == 0) { - MSGEL("HDF Test --> PASSED"); if (testFlag == 0x03) break; } else if (strResult.find("FAILED") == 0) { - MSGEL("HDF Test --> FAILED"); aResult = 67; break; } else { - MSGEL("HDF Test --> unknown result"); aResult = 68; break; } @@ -137,19 +115,16 @@ int SHAPERGUI_CheckBackup::run(const QString &theTestScript) std::string strResult = line.substr(10); if (strResult.find("PASSED") == 0) { - MSGEL("PY Test --> PASSED"); if (testFlag == 0x03) break; } else if (strResult.find("FAILED") == 0) { - MSGEL("PY Test --> FAILED"); aResult = 69; break; } else { - MSGEL("PY Test --> unknown result"); aResult = 70; break; } @@ -160,21 +135,14 @@ int SHAPERGUI_CheckBackup::run(const QString &theTestScript) // Not all tests were performed or they were interrupted switch (testFlag) { - case 0x00: MSGEL("None of the tests were performed until the end."); - aResult = 71; - break; - case 0x01: MSGEL("The PY Test was not performed until the end."); - aResult = 72; - break; - case 0x02: MSGEL("The HDF Test was not performed until the end."); - aResult = 73; - break; + case 0x00: aResult = 71; break; + case 0x01: aResult = 72; break; + case 0x02: aResult = 73; break; } } } else { - std::cout << "WARNING: cannot open log file from check_validity.py script" << std::endl; aResult = 74; // log file not found } } @@ -185,20 +153,14 @@ int SHAPERGUI_CheckBackup::run(const QString &theTestScript) void SHAPERGUI_CheckBackup::procStarted() { - DBG_FUN(); } void SHAPERGUI_CheckBackup::procFinished(int code, QProcess::ExitStatus stat) { - DBG_FUN(); - ARG(code); - ARG2(stat, int); } void SHAPERGUI_CheckBackup::procError(QProcess::ProcessError err) { - DBG_FUN(); - ARG2(err, int); } diff --git a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp index 1769826a2..e9ec48d01 100644 --- a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp +++ b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2023 CEA, EDF +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -37,14 +37,6 @@ #include #include -//--------------------------------------------------------- -#define USE_DEBUG -//#define MB_IGNORE_QT -//#define MB_FULL_DUMP -#define MBCLASSNAME "SHAPERGUI_DataModel" -#include "MBDebug.h" -// <-- insert includes for addtional debug headers here! -//--------------------------------------------------------- #define DUMP_NAME "shaper_dump.py" @@ -52,19 +44,14 @@ SHAPERGUI_DataModel::SHAPERGUI_DataModel(SHAPERGUI* theModule) : LightApp_DataModel(theModule), myStudyPath(""), myModule(theModule) { - DBG_FUN(); } SHAPERGUI_DataModel::~SHAPERGUI_DataModel() { - DBG_FUN(); } bool SHAPERGUI_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles) { - DBG_FUN(); - ARG(thePath); - ARG(theFiles); LightApp_DataModel::open( thePath, theStudy, theFiles ); if (theFiles.size() == 0) return false; @@ -99,15 +86,10 @@ bool SHAPERGUI_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStr bool SHAPERGUI_DataModel::save(QStringList& theFiles, bool isBackup/*=false*/) { - DBG_FUN(); - ARG(theFiles); - ARG(isBackup); // Publish to study before saving of the data model - //if (!isBackup) - myModule->publishToStudy(); + myModule->publishToStudy(); - //if (!isBackup) - LightApp_DataModel::save( theFiles ); + LightApp_DataModel::save( theFiles ); XGUI_Workshop* aWorkShop = myModule->workshop(); std::list aFileNames; @@ -141,17 +123,12 @@ bool SHAPERGUI_DataModel::save(QStringList& theFiles, bool isBackup/*=false*/) bool SHAPERGUI_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles, bool isBackup/*=false*/) { - DBG_FUN(); - ARG(thePath); - ARG(theFiles); - ARG(isBackup); myStudyPath = thePath; return save(theFiles, isBackup); } bool SHAPERGUI_DataModel::close() { - DBG_FUN(); myModule->workshop()->closeDocument(); return LightApp_DataModel::close(); } @@ -198,9 +175,6 @@ void SHAPERGUI_DataModel::removeDirectory(const QString& theDirectoryName) bool SHAPERGUI_DataModel::dumpPython(const QString& thePath, CAM_Study* theStudy, bool isMultiFile, QStringList& theListOfFiles) { - DBG_FUN(); - ARG(thePath); - ARG(theListOfFiles); LightApp_Study* aStudy = dynamic_cast(theStudy); if (!aStudy) return false; -- 2.39.2