+++ /dev/null
-#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 <iostream>
-#include <string>
-#include <locale>
-#include <codecvt>
-#include <list>
-#include <map>
-#include <set>
-#include <vector>
-#include <mutex>
-#include <thread>
-#ifndef MB_IGNORE_QT
-# include <QString>
-# include <QStringList>
-#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<std::mutex> 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<std::mutex> 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<wchar_t>;
- std::wstring_convert<convert_typeX, wchar_t> converterX;
- return(converterX.to_bytes(ws));
-}
-
-// Primitive types
-inline void DumpVar(const char *szName, char value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl;
-}
-
-inline void DumpVar(const char *szName, bool value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl;
-}
-
-inline void DumpVar(const char *szName, short value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[shrt]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, int value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[int]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, long value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[long]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, double value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[dbl]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, unsigned char value)
-{
- std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> lck(mtx);
- DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl;
-}
-
-inline void DumpVar(const char *szName, const std::string &value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl;
-}
-
-inline void DumpVar(const char *szName, const std::wstring &value)
-{
- std::lock_guard<std::mutex> 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<std::mutex> lck(mtx);
- DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl;
-}
-
-inline void DumpVar(const char *szName, const QStringList &value)
-{
- std::lock_guard<std::mutex> 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<std::mutex> lck(mtx);
- DLOG << "[ptr]: " << szName << "=" << value << std::endl;
-}
-
-
-// Collection of primitive types
-inline void DumpVar(const char *szName, const std::set<int> &values)
-{
- std::lock_guard<std::mutex> 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<int> &values)
-{
- std::lock_guard<std::mutex> 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<bool>& values)
-{
- std::lock_guard<std::mutex> 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<std::string> &values)
-{
- std::lock_guard<std::mutex> 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
-
-// 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
# 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)
Handle(TDocStd_Document) theDoc,
const TCollection_ExtendedString& theFilename)
{
- DBG_FUNC();
PCDM_StoreStatus aStatus;
try {
// create the directory to save the document
std::list<std::string>& 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)
-// 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
#include <TopoDS_Shape.hxx>
-//---------------------------------------------------------
-#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();
bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults, bool doBackup=false)
{
- DBG_FUN();
- ARG(theFileName);
- ARG(doBackup);
return ROOT_DOC->save(theFileName, "root", theResults, doBackup);
}
+++ /dev/null
-#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 <iostream>
-#include <string>
-#include <locale>
-#include <codecvt>
-#include <list>
-#include <map>
-#include <set>
-#include <vector>
-#include <mutex>
-#include <thread>
-#ifndef MB_IGNORE_QT
-# include <QString>
-# include <QStringList>
-#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<std::mutex> 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<std::mutex> 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<wchar_t>;
- std::wstring_convert<convert_typeX, wchar_t> converterX;
- return(converterX.to_bytes(ws));
-}
-
-// Primitive types
-inline void DumpVar(const char *szName, char value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl;
-}
-
-inline void DumpVar(const char *szName, bool value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl;
-}
-
-inline void DumpVar(const char *szName, short value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[shrt]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, int value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[int]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, long value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[long]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, double value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[dbl]: " << szName << "=" << value << std::endl;
-}
-
-inline void DumpVar(const char *szName, unsigned char value)
-{
- std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> lck(mtx);
- DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl;
-}
-
-inline void DumpVar(const char *szName, const std::string &value)
-{
- std::lock_guard<std::mutex> lck(mtx);
- DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl;
-}
-
-inline void DumpVar(const char *szName, const std::wstring &value)
-{
- std::lock_guard<std::mutex> 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<std::mutex> lck(mtx);
- DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl;
-}
-
-inline void DumpVar(const char *szName, const QStringList &value)
-{
- std::lock_guard<std::mutex> 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<std::mutex> lck(mtx);
- DLOG << "[ptr]: " << szName << "=" << value << std::endl;
-}
-
-
-// Collection of primitive types
-inline void DumpVar(const char *szName, const std::set<int> &values)
-{
- std::lock_guard<std::mutex> 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<int> &values)
-{
- std::lock_guard<std::mutex> 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<bool>& values)
-{
- std::lock_guard<std::mutex> 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<std::string> &values)
-{
- std::lock_guard<std::mutex> 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
-
-// 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
#include <Events_MessageBool.h>
//---------------------------------------------------------
-#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
myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false),
myAxisArrowRate(-1)
{
- DBG_FUN();
myWorkshop = new XGUI_Workshop(this);
connect(myWorkshop, SIGNAL(commandStatusUpdated()),
this, SLOT(onUpdateCommandStatus()));
//******************************************************
SHAPERGUI::~SHAPERGUI()
{
- DBG_FUN();
delete myWorkshop;
delete myProxyViewer;
}
//******************************************************
void SHAPERGUI::initialize(CAM_Application* theApp)
{
- DBG_FUN();
LightApp_Module::initialize(theApp);
myWorkshop->startApplication();
//******************************************************
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
#ifdef DBG_BACKUP_INTERVAL
backupInterval = DBG_BACKUP_INTERVAL; // MBS: use shorter interval for debugging
#endif
- MSGEL("....starting BackupTimer: interval=" << backupInterval);
myBackupTimer->start( backupInterval*60000 );
}
}
//******************************************************
void SHAPERGUI::hideInternalWindows()
{
- DBG_FUN();
myProxyViewer->activateViewer(false);
setMenuShown(false);
setToolShown(false);
//******************************************************
bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
{
- DBG_FUN();
saveToolbarsConfig();
myWorkshop->deactivateModule();
- MSGEL("....stopping BackupTimer");
myBackupTimer->stop();
myIsInspectionVisible = myInspectionPanel->isVisible();
//******************************************************
void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation)
{
- DBG_FUN();
- SHOW(theOperation->id());
-
onOperationGeneric(theOperation, moduleName(), "committed");
checkForWaitingBackup();
//******************************************************
void SHAPERGUI::onOperationAborted(ModuleBase_Operation* theOperation)
{
- DBG_FUN();
- SHOW(theOperation->id());
-
onOperationGeneric(theOperation, moduleName(), "aborted");
checkForWaitingBackup();
//******************************************************
void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
{
- DBG_FUN();
if (!mySelector) {
mySelector = createSelector(theMgr);
myWorkshop->selectionActivate()->updateSelectionFilters();
//******************************************************
void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr)
{
- DBG_FUN();
if (mySelector) {
if (theMgr->getType() == OCCViewer_Viewer::Type()) {
OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
//******************************************************
void SHAPERGUI::onDefaultPreferences()
{
- DBG_FUN();
// reset main resources
ModuleBase_Preferences::resetResourcePreferences(preferences());
// reset plugin's resources
//******************************************************
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
//******************************************************
void SHAPERGUI::onSaveDocByShaper()
{
- DBG_FUN();
if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
return;
//******************************************************
void SHAPERGUI::onSaveAsDocByShaper()
{
- DBG_FUN();
if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
return;
//******************************************************
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())
//******************************************************
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");
try
{
QString aName = study->studyName();
- SHOW(aName);
if ( aName.isEmpty() ) {
myBackupError = tr("Study name is empty");
return 34;
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 );
}
// 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;
aResult = 40;
}
-
- MSGEL("...emit backupDone signal");
- SHOW(aFolder);
- SHOW(aResult);
emit backupDone(aFolder, aResult);
return aResult;
}
//******************************************************
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)
{
{
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())
{
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)
{
}
myLastBackupFolder = aFolder;
}
- else
- {
- MSGEL("===> keep entire backup history: adding " << aFolder.toStdString());
- }
// Start the timer again
if ( aResMgr && application()->activeStudy() )
#ifdef DBG_BACKUP_INTERVAL
backupInterval = DBG_BACKUP_INTERVAL; // MBS: use shorter interval for debugging
#endif
- MSGEL("....starting BackupTimer: interval=" << backupInterval);
myBackupTimer->start( backupInterval*60000 );
}
}
//******************************************************
SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
{
- DBG_FUN();
if (theMgr->getType() == OCCViewer_Viewer::Type()) {
OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
//******************************************************
CAM_DataModel* SHAPERGUI::createDataModel()
{
- DBG_FUN();
return new SHAPERGUI_DataModel(this);
}
//******************************************************
void SHAPERGUI::createPreferences()
{
- DBG_FUN();
LightApp_Preferences* aPref = preferences();
if (!aPref)
return;
//******************************************************
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(),
#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();
}
}
bool SHAPERGUI::abortAllOperations()
{
- DBG_FUN();
return workshop()->operationMgr()->abortAllOperations();
}
void SHAPERGUI::createFeatureActions()
{
- DBG_FUN();
myWorkshop->menuMgr()->createFeatureActions();
}
void SHAPERGUI::saveToolbarsConfig()
{
- DBG_FUN();
if (!myIsToolbarsModified)
return;
// Save toolbars configuration into map
void SHAPERGUI::loadToolbarsConfig()
{
- DBG_FUN();
SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
QStringList aToolbarNames = aResMgr->parameters(ToolbarsSection);
if (aToolbarNames.size() == 0)
void SHAPERGUI::resetToolbars()
{
- DBG_FUN();
if (!myDefaultToolbars.isEmpty())
updateToolbars(myDefaultToolbars);
myIsToolbarsModified = false;
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.");
}
}
-// 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
#include <QFileInfo>
#include <QStringList>
-//---------------------------------------------------------
-#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)
, 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;
// 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)
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;
}
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;
}
// 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
}
}
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);
}
-// 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
#include <QDir>
#include <QTextStream>
-//---------------------------------------------------------
-#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"
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;
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<std::string> aFileNames;
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();
}
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<LightApp_Study*>(theStudy);
if (!aStudy)
return false;