From: mbs Date: Mon, 6 Mar 2023 17:45:44 +0000 (+0000) Subject: added debug messages only X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=874521cff78bb836cf3b95b923df944e1d32bf73;p=modules%2Fgui.git added debug messages only --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 2e6f51e43..29903de7b 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -46,6 +46,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "CAM_Application"; +#include "MBDebug.h" +//--------------------------------------------------------- + namespace { class BusyLocker @@ -101,6 +107,8 @@ CAM_Application::CAM_Application( const bool autoLoad ) myAutoLoad( autoLoad ), myBlocked( false ) { + DBG_FUN(); + ARG(autoLoad); readModuleList(); } @@ -111,6 +119,7 @@ CAM_Application::CAM_Application( const bool autoLoad ) */ CAM_Application::~CAM_Application() { + DBG_FUN(); for ( QList::const_iterator it = myModules.begin(); it != myModules.end(); ++it ) delete *it; myModules.clear(); @@ -125,6 +134,7 @@ CAM_Application::~CAM_Application() */ void CAM_Application::start() { + DBG_FUN(); // check modules for ( ModuleInfoList::iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) @@ -155,6 +165,8 @@ CAM_Module* CAM_Application::activeModule() const */ CAM_Module* CAM_Application::module( const QString& modName ) const { + DBG_FUN(); + ARG(modName); CAM_Module* mod = 0; for ( QList::const_iterator it = myModules.begin(); it != myModules.end() && !mod; ++it ) @@ -178,6 +190,7 @@ CAM_Application::ModuleList CAM_Application::modules() const */ void CAM_Application::modules( CAM_Application::ModuleList& out ) const { + DBG_FUN(); out.clear(); for ( QList::const_iterator it = myModules.begin(); @@ -196,6 +209,8 @@ void CAM_Application::modules( CAM_Application::ModuleList& out ) const */ void CAM_Application::modules( QStringList& lst, const bool loaded ) const { + DBG_FUN(); + ARG(loaded); lst.clear(); if ( loaded ) @@ -224,6 +239,7 @@ void CAM_Application::modules( QStringList& lst, const bool loaded ) const */ void CAM_Application::addModule( CAM_Module* mod ) { + DBG_FUN(); if ( !mod || myModules.contains( mod ) ) return; @@ -267,6 +283,7 @@ void CAM_Application::addModule( CAM_Module* mod ) */ void CAM_Application::loadModules() { + DBG_FUN(); for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) { CAM_Module* mod = loadModule( (*it).title ); @@ -295,6 +312,9 @@ void CAM_Application::loadModules() */ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool showMsg ) { + DBG_FUN(); + ARG(modName); + ARG(showMsg); if ( myInfoList.isEmpty() ) { qWarning( qPrintable( tr( "Modules configuration is not defined." ) ) ); @@ -408,6 +428,8 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show */ bool CAM_Application::activateModule( const QString& modName ) { + DBG_FUN(); + ARG(modName); if ( (!modName.isEmpty() && !activeStudy()) || myBlocked ) return false; @@ -448,6 +470,7 @@ bool CAM_Application::activateModule( const QString& modName ) */ bool CAM_Application::activateModule( CAM_Module* mod ) { + DBG_FUN(); if ( mod && !activeStudy() ) return false; @@ -496,6 +519,9 @@ bool CAM_Application::activateModule( CAM_Module* mod ) */ bool CAM_Application::activateOperation( const QString& modName, int actionId ) { + DBG_FUN(); + ARG(modName); + ARG(actionId); CAM_Module* mod = loadModule(modName, false); if (mod) { addModule(mod); @@ -513,6 +539,9 @@ bool CAM_Application::activateOperation( const QString& modName, int actionId ) */ bool CAM_Application::activateOperation( const QString& modName, const QString& actionId ) { + DBG_FUN(); + ARG(modName); + ARG(actionId); CAM_Module* mod = loadModule(modName, false); if (mod) { addModule(mod); @@ -534,6 +563,10 @@ bool CAM_Application::activateOperation( const QString& modName, const QString& actionId, const QString& pluginName ) { + DBG_FUN(); + ARG(modName); + ARG(actionId); + ARG(pluginName); CAM_Module* mod = loadModule(modName, false); if (mod) { addModule(mod); @@ -548,6 +581,7 @@ bool CAM_Application::activateOperation( const QString& modName, */ SUIT_Study* CAM_Application::createNewStudy() { + DBG_FUN(); return new CAM_Study( this ); } @@ -556,6 +590,7 @@ SUIT_Study* CAM_Application::createNewStudy() */ void CAM_Application::updateCommandsStatus() { + DBG_FUN(); STD_Application::updateCommandsStatus(); if ( activeModule() ) @@ -571,12 +606,14 @@ void CAM_Application::updateCommandsStatus() */ void CAM_Application::beforeCloseDoc( SUIT_Study* theDoc ) { + DBG_FUN(); for ( QList::iterator it = myModules.begin(); it != myModules.end(); ++it ) (*it)->studyClosed( theDoc ); } void CAM_Application::afterCloseDoc() { + DBG_FUN(); } /*! @@ -585,6 +622,7 @@ void CAM_Application::afterCloseDoc() */ void CAM_Application::setActiveStudy( SUIT_Study* study ) { + DBG_FUN(); STD_Application::setActiveStudy( study ); } @@ -598,6 +636,7 @@ void CAM_Application::setActiveStudy( SUIT_Study* study ) */ bool CAM_Application::checkModule( const QString& ) { + DBG_FUN(); return true; } @@ -611,6 +650,7 @@ bool CAM_Application::checkModule( const QString& ) */ void CAM_Application::moduleAdded( CAM_Module* /*mod*/ ) { + DBG_FUN(); } /*! @@ -623,6 +663,7 @@ void CAM_Application::moduleAdded( CAM_Module* /*mod*/ ) */ void CAM_Application::moduleDeactivated( CAM_Module* /*mod*/ ) { + DBG_FUN(); } /*! @@ -632,12 +673,15 @@ void CAM_Application::moduleDeactivated( CAM_Module* /*mod*/ ) */ QString CAM_Application::moduleName( const QString& title ) { + DBG_FUNC(); + ARG(title); QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) { if ( (*it).title == title ) res = (*it).name; } + RET(res); return res; } @@ -648,12 +692,15 @@ QString CAM_Application::moduleName( const QString& title ) */ QString CAM_Application::moduleTitle( const QString& name ) { + DBG_FUNC(); + ARG(name); QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) { if ( (*it).name == name ) res = (*it).title; } + RET(res); return res; } @@ -680,12 +727,15 @@ QString CAM_Application::moduleIcon( const QString& name ) */ QString CAM_Application::moduleDescription( const QString& name ) { + DBG_FUNC(); + ARG(name); QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it ) { if ( (*it).name == name || (*it).title == name ) res = tr((*it).description.toUtf8()); } + RET(res); return res; } @@ -697,6 +747,8 @@ QString CAM_Application::moduleDescription( const QString& name ) */ QString CAM_Application::moduleLibrary( const QString& name, const bool full ) { + DBG_FUNC(); + ARG(name); QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) { @@ -705,6 +757,7 @@ QString CAM_Application::moduleLibrary( const QString& name, const bool full ) } if ( !res.isEmpty() && full ) res = SUIT_Tools::library( res ); + RET(res); return res; } @@ -715,6 +768,8 @@ QString CAM_Application::moduleLibrary( const QString& name, const bool full ) */ QString CAM_Application::moduleDisplayer( const QString& name ) { + DBG_FUNC(); + ARG(name); QString res; if ( !name.isEmpty() ) @@ -729,6 +784,7 @@ QString CAM_Application::moduleDisplayer( const QString& name ) } } + RET(res); return res; } @@ -754,6 +810,7 @@ QString CAM_Application::moduleDisplayer( const QString& name ) */ void CAM_Application::readModuleList() { + DBG_FUN(); if ( !myInfoList.isEmpty() ) return; @@ -763,6 +820,7 @@ void CAM_Application::readModuleList() QStringList modList; QString args = QApplication::arguments().join( " " ); + SHOW(args); QRegExp rx1("--modules=([\\w,]*)"); rx1.setMinimal( false ); @@ -799,6 +857,7 @@ void CAM_Application::readModuleList() if ( modList.isEmpty() ) { QString mods = resMgr->stringValue( "launch", "modules", QString() ); + SHOW(mods); modList = mods.split( ",", QString::SkipEmptyParts ); } @@ -822,6 +881,8 @@ void CAM_Application::readModuleList() bool CAM_Application::appendModuleInfo( const QString& modName ) { + DBG_FUN(); + ARG(modName); if ( modName.isEmpty() ) return false; // empty module name @@ -872,6 +933,8 @@ bool CAM_Application::appendModuleInfo( const QString& modName ) void CAM_Application::removeModuleInfo( const QString& modName ) { + DBG_FUN(); + ARG(modName); QMutableListIterator it( myInfoList ); while ( it.hasNext() ) { @@ -895,6 +958,8 @@ void CAM_Application::removeModuleInfo( const QString& modName ) */ void CAM_Application::contextMenuPopup( const QString& type, QMenu* menu, QString& title ) { + DBG_FUN(); + ARG(type); // to do : add common items for popup menu ( if they are exist ) if ( activeModule() ) activeModule()->contextMenuPopup( type, menu, title ); @@ -905,6 +970,7 @@ void CAM_Application::contextMenuPopup( const QString& type, QMenu* menu, QStrin */ void CAM_Application::createEmptyStudy() { + DBG_FUN(); /*SUIT_Study* study = */activeStudy(); STD_Application::createEmptyStudy(); } @@ -914,6 +980,7 @@ void CAM_Application::createEmptyStudy() */ CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() { + DBG_FUNC(); ModuleShortInfoList info; ModuleShortInfo kernel; @@ -944,6 +1011,7 @@ CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() */ bool CAM_Application::abortAllOperations() { + DBG_FUN(); bool aborted = true; for ( QList::const_iterator it = myModules.begin(); it != myModules.end() && aborted; ++it ) { diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 161d69a84..c6ea6d044 100644 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -37,6 +37,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "CAM_Module"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! \class CAM_Module \brief Base implementation of the module in the CAM application architecture. @@ -77,6 +83,7 @@ CAM_Module::CAM_Module() myApp( 0 ), myDataModel( 0 ) { + DBG_FUN(); } /*! @@ -94,6 +101,8 @@ CAM_Module::CAM_Module( const QString& name ) myMenuShown( false ), myToolShown( false ) { + DBG_FUN(); + ARG(name); } /*! @@ -103,6 +112,7 @@ CAM_Module::CAM_Module( const QString& name ) */ CAM_Module::~CAM_Module() { + DBG_FUN(); delete myDataModel; myDataModel = 0; } @@ -120,6 +130,7 @@ CAM_Module::~CAM_Module() */ void CAM_Module::initialize( CAM_Application* app ) { + DBG_FUN(); myApp = app; if ( myApp ) { @@ -232,6 +243,7 @@ bool CAM_Module::isSelectionCompatible() */ bool CAM_Module::activateModule( SUIT_Study* /*study*/ ) { + DBG_FUN(); // IMN 05/03/2015: we copied myActionMap for reset/unset actions accelerator keys // after activate/deactivate modules for ( QMap::Iterator it = myActionShortcutMap.begin(); it != myActionShortcutMap.end(); ++it ) @@ -257,6 +269,7 @@ bool CAM_Module::activateModule( SUIT_Study* /*study*/ ) */ bool CAM_Module::deactivateModule( SUIT_Study* ) { + DBG_FUN(); // IMN 05/03/2015: we copied myActionMap for reset/unset actions accelerator keys // after activate/deactivate modules myActionShortcutMap.clear(); @@ -277,6 +290,7 @@ bool CAM_Module::deactivateModule( SUIT_Study* ) */ void CAM_Module::studyClosed( SUIT_Study* study ) { + DBG_FUN(); CAM_Study* camDoc = dynamic_cast( study ); if ( !camDoc ) return; @@ -298,6 +312,7 @@ void CAM_Module::studyClosed( SUIT_Study* study ) */ void CAM_Module::studyChanged( SUIT_Study* /*oldStudy*/, SUIT_Study* /*newStudy*/ ) { + DBG_FUN(); } /*! @@ -320,6 +335,8 @@ bool CAM_Module::isActiveModule() const */ void CAM_Module::putInfo( const QString& msg, const int msec ) { + DBG_FUN(); + ARG(msg); if ( application() ) application()->putInfo( msg, msec ); @@ -338,6 +355,9 @@ void CAM_Module::putInfo( const QString& msg, const int msec ) */ int CAM_Module::showNotification( const QString& message, const QString& title, int timeout ) { + DBG_FUN(); + ARG(message); + ARG(title); int res = -1; if ( application() ) res = application()->showNotification( message, title, timeout ); @@ -350,6 +370,8 @@ int CAM_Module::showNotification( const QString& message, const QString& title, */ void CAM_Module::hideNotification( const QString& message ) { + DBG_FUN(); + ARG(message); if ( application() ) application()->hideNotification( message ); } @@ -360,6 +382,8 @@ void CAM_Module::hideNotification( const QString& message ) */ void CAM_Module::hideNotification( int id ) { + DBG_FUN(); + ARG(id); if ( application() ) application()->hideNotification( id ); } @@ -374,6 +398,8 @@ void CAM_Module::hideNotification( int id ) */ void CAM_Module::onInfoChanged( QString txt ) { + DBG_FUN(); + ARG(txt); if ( txt.isEmpty() && isActiveModule() && !myInfo.isEmpty() && application() ) application()->putInfo( myInfo ); } @@ -387,6 +413,7 @@ void CAM_Module::onInfoChanged( QString txt ) */ void CAM_Module::onApplicationClosed( SUIT_Application* theApp ) { + DBG_FUN(); if (myApp == theApp) myApp = NULL; } @@ -397,6 +424,7 @@ void CAM_Module::onApplicationClosed( SUIT_Application* theApp ) */ CAM_DataModel* CAM_Module::createDataModel() { + DBG_FUN(); return new CAM_DataModel( this ); } @@ -407,6 +435,8 @@ CAM_DataModel* CAM_Module::createDataModel() */ void CAM_Module::setName( const QString& name ) { + DBG_FUN(); + ARG(name); setObjectName( name ); } @@ -417,6 +447,8 @@ void CAM_Module::setName( const QString& name ) */ void CAM_Module::setModuleName( const QString& name ) { + DBG_FUN(); + ARG(name); myName = name; } @@ -455,6 +487,7 @@ QtxActionToolMgr* CAM_Module::toolMgr() const */ int CAM_Module::createTool( const QString& title, const QString& name ) { + MSGEL("CAM_Module::createTool(title=\"" << title.toStdString() << "\", name=\"" << name.toStdString() << "\")"); if ( !toolMgr() ) return -1; @@ -484,6 +517,7 @@ int CAM_Module::createTool( const QString& title, const QString& name ) */ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int idx ) { + MSGEL("CAM_Module::createTool(tBar=" << tBar << ", id=" << id << ", idx=" << idx <<")"); if ( !toolMgr() ) return -1; @@ -519,6 +553,7 @@ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int */ int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const int idx ) { + MSGEL("CAM_Module::createTool(tBar=\"" << tBar.toStdString() << "\", id=" << id << ", idx=" << idx <<")"); if ( !toolMgr() ) return -1; @@ -553,6 +588,7 @@ int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const */ int CAM_Module::createTool( const int id, const int tBar, const int idx ) { + MSGEL("CAM_Module::createTool(id=" << id << ", tBar=" << tBar << ", idx=" << idx <<")"); if ( !toolMgr() ) return -1; @@ -586,6 +622,7 @@ int CAM_Module::createTool( const int id, const int tBar, const int idx ) */ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) { + MSGEL("CAM_Module::createTool(id=" << id << ", tBar=\"" << tBar.toStdString() << "\", idx=" << idx <<")"); if ( !toolMgr() ) return -1; @@ -605,6 +642,8 @@ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) */ void CAM_Module::clearTool( const QString& title ) { + DBG_FUN(); + ARG(title); if ( toolMgr() ) toolMgr()->clear( title ); } @@ -637,6 +676,7 @@ void CAM_Module::clearTool( const QString& title ) int CAM_Module::createMenu( const QString& subMenu, const int menu, const int id, const int group, const int idx, QMenu * menuObj ) { + MSGEL("CAM_Module::createMenu(subMenu=\"" << subMenu.toStdString() << "\", menu=" << menu << ", id=" << id << ")"); if ( !menuMgr() ) return -1; @@ -671,6 +711,7 @@ int CAM_Module::createMenu( const QString& subMenu, const int menu, int CAM_Module::createMenu( const QString& subMenu, const QString& menu, const int id, const int group, const int idx ) { + MSGEL("CAM_Module::createMenu(subMenu=\"" << subMenu.toStdString() << "\", menu=\"" << menu.toStdString() << "\", id=" << id << ")"); if ( !menuMgr() ) return -1; @@ -701,6 +742,7 @@ int CAM_Module::createMenu( const QString& subMenu, const QString& menu, */ int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int group, const int idx ) { + MSGEL("CAM_Module::createMenu(menu=" << menu << ", id=" << id << ")"); if ( !a || !menuMgr() ) return -1; @@ -743,6 +785,7 @@ int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int */ int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx ) { + MSGEL("CAM_Module::createMenu(action, menu=\"" << menu.toStdString() << "\", id=" << id << ")"); if ( !a || !menuMgr() ) return -1; @@ -780,6 +823,7 @@ int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const */ int CAM_Module::createMenu( const int id, const int menu, const int group, const int idx ) { + MSGEL("CAM_Module::createMenu(id=" << id << ", menu=" << menu << ")"); if ( !menuMgr() ) return -1; @@ -820,6 +864,7 @@ int CAM_Module::createMenu( const int id, const int menu, const int group, const */ int CAM_Module::createMenu( const int id, const QString& menu, const int group, const int idx ) { + MSGEL("CAM_Module::createMenu(id=" << id << ", menu=\"" << menu.toStdString() << "\")"); if ( !menuMgr() ) return -1; @@ -840,6 +885,7 @@ int CAM_Module::createMenu( const int id, const QString& menu, const int group, */ void CAM_Module::setMenuShown( const bool on ) { + MSGEL("CAM_Module::setMenuShown(on=" << on << ")"); myMenuShown = on; QtxActionMenuMgr* mMgr = menuMgr(); @@ -879,6 +925,7 @@ void CAM_Module::setMenuShown( QAction* a, const bool on ) */ void CAM_Module::setMenuShown( const int id, const bool on ) { + MSGEL("CAM_Module::setMenuShown(id=" << id << ", on=" << on << ")"); setMenuShown( action( id ), on ); } @@ -889,6 +936,7 @@ void CAM_Module::setMenuShown( const int id, const bool on ) */ void CAM_Module::setToolShown( const bool on ) { + MSGEL("CAM_Module::setToolShown(on=" << on << ")"); myToolShown = on; QtxActionToolMgr* tMgr = toolMgr(); @@ -928,6 +976,7 @@ void CAM_Module::setToolShown( QAction* a, const bool on ) */ void CAM_Module::setToolShown( const int id, const bool on ) { + MSGEL("CAM_Module::setToolShown(id=" << id << ", on=" << on << ")"); setToolShown( action( id ), on ); } @@ -1015,6 +1064,7 @@ QAction* CAM_Module::createAction( const int id, const QString& text, const QIco QObject* parent, const bool toggle, QObject* reciever, const char* member, const QString& shortcutAction ) { + MSGEL("CAM_Module::createAction(id=" << id << ", text=\"" << text.toStdString() << "\")"); QtxAction* a = new QtxAction( text, icon, menu, key, parent, toggle, shortcutAction ); a->setStatusTip( tip ); @@ -1034,6 +1084,8 @@ QAction* CAM_Module::createAction( const int id, const QString& text, const QIco */ QtxActionGroup* CAM_Module::createActionGroup( const int id, const bool exclusive ) { + DBG_FUN(); + ARG(id); QtxActionGroup* a = qobject_cast( action( id ) ); if ( !a ) { a = new QtxActionGroup( this ); @@ -1055,6 +1107,7 @@ QtxActionGroup* CAM_Module::createActionGroup( const int id, const bool exclusiv */ int CAM_Module::registerAction( const int id, QAction* a ) { + MSGEL("CAM_Module::registerAction(id=" << id << ")"); int ident = -1; for ( QMap::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && ident == -1; ++it ) if ( it.value() == a ) @@ -1090,6 +1143,8 @@ int CAM_Module::registerAction( const int id, QAction* a ) */ bool CAM_Module::unregisterAction( const int id ) { + DBG_FUN(); + ARG(id); return unregisterAction( action( id ) ); } @@ -1101,6 +1156,7 @@ bool CAM_Module::unregisterAction( const int id ) */ bool CAM_Module::unregisterAction( QAction* a ) { + DBG_FUN(); if ( !a ) return false; if ( menuMgr() ) { @@ -1136,6 +1192,7 @@ QAction* CAM_Module::separator() \brief Update visibility state of the module objects. */ void CAM_Module::updateModuleVisibilityState() { + DBG_FUN(); } @@ -1146,6 +1203,7 @@ void CAM_Module::updateModuleVisibilityState() { */ bool CAM_Module::activateOperation( int /*actionId*/ ) { + DBG_FUN(); return false; } @@ -1156,6 +1214,7 @@ bool CAM_Module::activateOperation( int /*actionId*/ ) */ bool CAM_Module::activateOperation( const QString& /*actionId*/ ) { + DBG_FUN(); return false; } @@ -1167,6 +1226,7 @@ bool CAM_Module::activateOperation( const QString& /*actionId*/ ) */ bool CAM_Module::activateOperation( const QString& /*actionId*/, const QString& /*pluginName*/ ) { + DBG_FUN(); return false; } @@ -1177,6 +1237,7 @@ bool CAM_Module::activateOperation( const QString& /*actionId*/, const QString& */ void CAM_Module::connectToStudy( CAM_Study* camStudy ) { + DBG_FUN(); CAM_Application* app = camStudy ? dynamic_cast( camStudy->application() ) : 0; if( !app ) return; @@ -1213,5 +1274,6 @@ void CAM_Module::connectToStudy( CAM_Study* camStudy ) bool CAM_Module::abortAllOperations() { + DBG_FUN(); return true; } diff --git a/src/CAM/MBDebug.h b/src/CAM/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/CAM/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 49972104e..14bd4e9d2 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -196,6 +196,13 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_Application"; +#include "MBDebug.h" +#include "MBSUIT.h" +//--------------------------------------------------------- + #define FIRST_HELP_ID 1000000 #define HAS_WWW_URL true #define HAS_FORUM_URL true @@ -335,6 +342,7 @@ namespace /*!Create new instance of LightApp_Application.*/ extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication() { + DBG_FUNC(); return new LightApp_Application(); } @@ -353,6 +361,7 @@ LightApp_Application::LightApp_Application() myPrefs( 0 ), myScreenHelper(new LightApp_FullScreenHelper()) { + DBG_FUN(); Q_INIT_RESOURCE( LightApp ); STD_TabDesktop* desk = new STD_TabDesktop(); @@ -465,6 +474,7 @@ LightApp_Application::LightApp_Application() */ LightApp_Application::~LightApp_Application() { + DBG_FUN(); savePreferences(); delete mySelMgr; delete myScreenHelper; @@ -474,6 +484,7 @@ LightApp_Application::~LightApp_Application() /*!Start application.*/ void LightApp_Application::start() { + DBG_FUN(); CAM_Application::start(); updateWindows(); @@ -491,6 +502,7 @@ void LightApp_Application::start() /*!Closeapplication.*/ void LightApp_Application::closeApplication() { + DBG_FUN(); #ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); @@ -502,8 +514,10 @@ void LightApp_Application::closeApplication() QString LightApp_Application::applicationName() const { static QString _app_name; - if ( _app_name.isEmpty() ) + if ( _app_name.isEmpty() ) { _app_name = tr( "APP_NAME" ); + SHOW(_app_name); + } return _app_name; } @@ -523,6 +537,7 @@ QString LightApp_Application::applicationVersion() const { _app_version = GUI_VERSION_STR; } + SHOW(_app_version); } return _app_version; } @@ -530,6 +545,8 @@ QString LightApp_Application::applicationVersion() const /*!Load module by \a name.*/ CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg ) { + DBG_FUN(); + SHOW(name); CAM_Module* mod = CAM_Application::loadModule( name, showMsg ); if ( mod ) { @@ -543,6 +560,8 @@ CAM_Module* LightApp_Application::loadModule( const QString& name, const bool sh /*!Activate module by \a modName*/ bool LightApp_Application::activateModule( const QString& modName ) { + DBG_FUN(); + ARG(modName); QString actName; CAM_Module* prevMod = activeModule(); @@ -618,6 +637,7 @@ void LightApp_Application::createActionForViewer( const int id, void LightApp_Application::createActions() { + DBG_FUN(); CAM_Application::createActions(); SUIT_Desktop* desk = desktop(); @@ -825,6 +845,7 @@ void LightApp_Application::createActions() */ void LightApp_Application::customize() { + DBG_FUN(); // List of modules LightApp_ModuleAction* moduleAction = qobject_cast( action( ModulesListId ) ); // a. regular modules were added in createActions() method @@ -844,6 +865,9 @@ void LightApp_Application::customize() /*!On module activation action.*/ void LightApp_Application::onModuleActivation( const QString& modTitle ) { + DBG_FUN(); + ARG(modTitle); + // Force user to create/open a study before module activation QPixmap icon = moduleIcon( modTitle ); bool cancelled = false; @@ -874,6 +898,7 @@ void LightApp_Application::onModuleActivation( const QString& modTitle ) /*!On module adding action.*/ void LightApp_Application::onModuleAdding() { + DBG_FUN(); // show dialog to browse configuration file QStringList filters = ( QStringList() << tr( "Config files") + " (*.salomex)" << tr( "All files" ) + " (*)" ); QStringList paths = getOpenFileNames( QString(), filters.join( ";;" ), QString(), desktop() ); @@ -911,6 +936,9 @@ void LightApp_Application::onModuleAdding() /*Add user module.*/ bool LightApp_Application::addUserModule( const QString& name, const QString& root, bool interactive ) { + DBG_FUN(); + ARG(name); + ARG(root); if ( name.isEmpty() || root.isEmpty() ) return false; @@ -990,6 +1018,9 @@ bool LightApp_Application::addUserModule( const QString& name, const QString& ro /*!On module removing action.*/ void LightApp_Application::onModuleRemoving( const QString& title ) { + DBG_FUN(); + ARG(title); + QString root = resourceMgr()->stringValue( "user_modules", moduleName( title ) ); QDir rootDirectory = QDir( root ); @@ -1057,6 +1088,7 @@ QString LightApp_Application::defaultModule() const /*!On new window slot.*/ void LightApp_Application::onNewWindow() { + DBG_FUN(); const QObject* obj = sender(); if ( !obj || !obj->inherits( "QAction" ) ) return; @@ -1106,6 +1138,7 @@ void LightApp_Application::onNewWindow() break; #endif } + SHOW(type); if ( !type.isEmpty() ) createViewManager( type ); @@ -1116,6 +1149,7 @@ void LightApp_Application::onNewWindow() */ void LightApp_Application::onNewDoc() { + DBG_FUN(); if ( !checkExistingDoc() ) return; @@ -1130,6 +1164,7 @@ void LightApp_Application::onNewDoc() */ void LightApp_Application::onOpenDoc() { + DBG_FUN(); SUIT_Study* study = activeStudy(); if ( !checkExistingDoc( false ) ) @@ -1159,6 +1194,8 @@ bool LightApp_Application::canOpenDoc( const QString& ) */ bool LightApp_Application::onOpenDoc( const QString& aName ) { + DBG_FUN(); + ARG(aName); if ( !canOpenDoc(aName)) { bool showError = !property("open_study_from_command_line").isValid() || !property("open_study_from_command_line").toBool(); @@ -1207,6 +1244,7 @@ void LightApp_Application::onHelpAbout() */ void LightApp_Application::onSelection() { + DBG_FUN(); //MESSAGE("onSelection") onSelectionChanged(); @@ -1220,6 +1258,7 @@ void LightApp_Application::onSelection() */ void LightApp_Application::setActiveStudy( SUIT_Study* study ) { + DBG_FUN(); CAM_Application::setActiveStudy( study ); } @@ -1228,6 +1267,7 @@ void LightApp_Application::setActiveStudy( SUIT_Study* study ) */ void LightApp_Application::updateCommandsStatus() { + DBG_FUN(); CAM_Application::updateCommandsStatus(); QAction* a = 0; @@ -1352,6 +1392,8 @@ private: void LightApp_Application::showHelp( const QString& path ) { + DBG_FUN(); + ARG(path); SUIT_ResourceMgr* resMgr = resourceMgr(); #if DISABLE_QTXWEBBROWSER @@ -1440,6 +1482,7 @@ void LightApp_Application::onHelpContextModule( const QString& component, */ void LightApp_Application::onSelectionChanged() { + DBG_FUN(); LightApp_Module* m = dynamic_cast( activeModule() ); bool canCopy = m ? m->canCopy() : false; bool canPaste = m ? m->canPaste() : false; @@ -1609,6 +1652,9 @@ PyConsole_Console* LightApp_Application::pythonConsole(const bool force) */ void LightApp_Application::updateObjectBrowser( const bool updateModels ) { + DBG_FUN(); + ARG(updateModels); + // update existing data models if ( updateModels ) { @@ -1653,6 +1699,10 @@ LightApp_Preferences* LightApp_Application::preferences() const */ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create ) { + DBG_FUN(); + ARG(vmType); + ARG(create); + SUIT_ViewManager* aVM = viewManager( vmType ); SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager(); MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM ); @@ -1691,6 +1741,10 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c */ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached ) { + DBG_FUN(); + ARG(vmType); + ARG(detached); + SUIT_ResourceMgr* resMgr = resourceMgr(); SUIT_ViewManager* viewMgr = 0; @@ -1860,6 +1914,9 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w ) { + DBG_FUN(); + ARG(vmType); + SUIT_ResourceMgr* resMgr = resourceMgr(); SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(), @@ -1882,6 +1939,8 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel ) { + DBG_FUN(); + SUIT_ResourceMgr* resMgr = resourceMgr(); SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(), @@ -1910,6 +1969,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theMo */ void LightApp_Application::onCloseView( SUIT_ViewManager* theVM ) { + DBG_FUN(); removeViewManager( theVM ); } @@ -1919,6 +1979,7 @@ void LightApp_Application::onCloseView( SUIT_ViewManager* theVM ) */ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) { + DBG_FUN(); SUIT_DataObject* aRoot = 0; if ( theStudy && theStudy->root() ) { @@ -1951,10 +2012,12 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) */ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) { + DBG_FUN(); SUIT_DataObject* aRoot = 0; if ( theStudy && theStudy->root() ) { aRoot = theStudy->root(); + SHOW(aRoot); //aRoot->dump(); } @@ -1982,6 +2045,7 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) /*!Protected SLOT. On study saved.*/ void LightApp_Application::onStudySaved( SUIT_Study* s ) { + DBG_FUN(); QtxMRUAction* mru = ::qobject_cast( action( MRUId ) ); if ( mru && s ) mru->insert( s->studyName() ); @@ -1992,6 +2056,7 @@ void LightApp_Application::onStudySaved( SUIT_Study* s ) /*!Protected SLOT. On study closed.*/ void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ ) { + DBG_FUN(); /* disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ), this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); @@ -2012,6 +2077,7 @@ void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ ) /*!Protected SLOT.On desktop activated.*/ void LightApp_Application::onDesktopActivated() { + DBG_FUN(); CAM_Application::onDesktopActivated(); LightApp_Module* aModule = dynamic_cast(activeModule()); if(aModule) @@ -2020,6 +2086,7 @@ void LightApp_Application::onDesktopActivated() void LightApp_Application::studyOpened( SUIT_Study* s ) { + DBG_FUN(); CAM_Application::studyOpened( s ); updateWindows(); @@ -2028,6 +2095,7 @@ void LightApp_Application::studyOpened( SUIT_Study* s ) void LightApp_Application::studySaved( SUIT_Study* s ) { + DBG_FUN(); CAM_Application::studyOpened( s ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); if ( aResMgr && activeStudy() ) { @@ -2038,6 +2106,7 @@ void LightApp_Application::studySaved( SUIT_Study* s ) void LightApp_Application::studyCreated( SUIT_Study* s ) { + DBG_FUN(); CAM_Application::studyCreated( s ); updateWindows(); @@ -2085,12 +2154,14 @@ QStringList LightApp_Application::getOpenFileNames( const QString& initial, cons /*!Private SLOT. Update object browser.*/ void LightApp_Application::onRefresh() { + DBG_FUN(); updateObjectBrowser( true ); } /*!Private SLOT. Update actions after rename object.*/ void LightApp_Application::onRenamed() { + DBG_FUN(); activeStudy()->Modified(); updateActions(); } @@ -2164,6 +2235,10 @@ void LightApp_Application::showPreferences( const QStringList& path ) /*!Protected SLOT. On preferences changed.*/ void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param ) { + DBG_FUN(); + ARG(modName); + ARG(section); + ARG(param); LightApp_Module* sMod = 0; CAM_Module* mod = module( modName ); if ( mod && mod->inherits( "LightApp_Module" ) ) @@ -2180,6 +2255,7 @@ void LightApp_Application::onPreferenceChanged( QString& modName, QString& secti /*!Remove all windows from study.*/ void LightApp_Application::beforeCloseDoc( SUIT_Study* s ) { + DBG_FUN(); saveDockWindowsState(); if ( SUIT_DataBrowser* ob = objectBrowser() ) @@ -2199,6 +2275,7 @@ void LightApp_Application::updateActions() */ SUIT_Study* LightApp_Application::createNewStudy() { + DBG_FUN(); LightApp_Study* aStudy = new LightApp_Study( this ); // Set up processing of major study-related events @@ -2216,12 +2293,15 @@ SUIT_Study* LightApp_Application::createNewStudy() */ QWidget* LightApp_Application::createWindow( const int flag ) { + DBG_FUN(); + ARG(flag); QWidget* wid = 0; SUIT_ResourceMgr* resMgr = resourceMgr(); if ( flag == WT_ObjectBrowser ) { + MSGEL("--> create ObjectBrowser"); SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() ); ob->setObjectName( "objectBrowser" ); ob->setSortMenuEnabled( true ); @@ -2267,6 +2347,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) } else if ( flag == WT_InfoPanel) { + MSGEL("--> create InfoPanel"); QtxInfoPanel* ipanel = new QtxInfoPanel( desktop() ); ipanel->setObjectName( "infoPanel" ); ipanel->setWindowTitle( tr( "INFO_PANEL" ) ); @@ -2275,6 +2356,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { + MSGEL("--> create PythonConsole"); PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) ); pyCons->setObjectName( "pythonConsole" ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); @@ -2287,6 +2369,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) #endif else if ( flag == WT_LogWindow ) { + MSGEL("--> create LogWindow"); LogWindow* logWin = new LogWindow( desktop() ); logWin->handleQtMessages( true ); logWin->setObjectName( "logWindow" ); @@ -2401,6 +2484,7 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const */ void LightApp_Application::moduleAdded( CAM_Module* mod ) { + DBG_FUN(); CAM_Application::moduleAdded( mod ); LightApp_Module* lightMod = 0; @@ -2417,6 +2501,7 @@ void LightApp_Application::moduleAdded( CAM_Module* mod ) void LightApp_Application::moduleDeactivated( CAM_Module* /*mod*/ ) { + DBG_FUN(); if ( infoPanel() ) infoPanel()->clear(); } @@ -2440,6 +2525,7 @@ void LightApp_Application::emptyPreferences( const QString& modName ) */ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) { + DBG_FUN(); if ( !pref ) return; @@ -4022,6 +4108,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString */ void LightApp_Application::loadPreferences() { + DBG_FUN(); CAM_Application::loadPreferences(); SUIT_ResourceMgr* aResMgr = resourceMgr(); @@ -4072,6 +4159,7 @@ void LightApp_Application::loadPreferences() */ void LightApp_Application::savePreferences() { + DBG_FUN(); CAM_Application::savePreferences(); saveDockWindowsState(); @@ -4105,6 +4193,7 @@ void LightApp_Application::savePreferences() */ void LightApp_Application::updateDesktopTitle() { + DBG_FUN(); QString aTitle = applicationName(); QString aVer = applicationVersion(); if ( !aVer.isEmpty() ) @@ -4115,6 +4204,7 @@ void LightApp_Application::updateDesktopTitle() aTitle += QString( " - [%1]" ).arg( sName ); } + SHOW(aTitle); desktop()->setWindowTitle( aTitle ); } @@ -4169,6 +4259,7 @@ void LightApp_Application::moduleActionSelected( const int id ) */ void LightApp_Application::afterCloseDoc() { + DBG_FUN(); updateWindows(); CAM_Application::afterCloseDoc(); @@ -4184,6 +4275,9 @@ void LightApp_Application::updateModuleActions() bool LightApp_Application::checkModule( const QString& title ) { + DBG_FUN(); + ARG(title); + if ( title.isEmpty() ) return false; @@ -4283,6 +4377,7 @@ void LightApp_Application::currentViewManagers( QStringList& lst ) const */ void LightApp_Application::updateWindows() { + DBG_FUN(); QMap winMap; currentWindows( winMap ); @@ -4343,9 +4438,15 @@ void LightApp_Application::updateWindows() */ void LightApp_Application::updateViewManagers() { + DBG_FUN(); QStringList lst; currentViewManagers( lst ); + std::cout << "-----Current ViewManagers-----------------" << std::endl; + for (auto it = lst.begin(); it != lst.end(); ++it) + std::cout << "VM-Type: [" << (*it).toStdString() << "]" << std::endl; + std::cout << "------------------------------------------" << std::endl; + for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it ) getViewManager( *it, true ); } @@ -4355,6 +4456,7 @@ void LightApp_Application::updateViewManagers() */ void LightApp_Application::loadDockWindowsState() { + DBG_FUN(); if ( !desktop() ) return; SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -4458,6 +4560,7 @@ void LightApp_Application::loadDockWindowsState() */ void LightApp_Application::saveDockWindowsState() { + DBG_FUN(); if ( !desktop() ) return; @@ -4590,6 +4693,7 @@ QPixmap LightApp_Application::moduleIcon( const QString& moduleTitle, const int */ void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title ) { + MSGEL("LightApp_Application::contextMenuPopup(type=\"" << type.toStdString() << "\")"); //Add "Rename" item LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr(); bool cacheIsOn = selMgr->isSelectionCacheEnabled(); @@ -4635,6 +4739,7 @@ void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopu */ void LightApp_Application::createEmptyStudy() { + DBG_FUN(); CAM_Application::createEmptyStudy(); if ( objectBrowser() ) @@ -4650,6 +4755,8 @@ void LightApp_Application::createEmptyStudy() /*!Set desktop:*/ void LightApp_Application::setDesktop( SUIT_Desktop* desk ) { + DBG_FUN(); + CAM_Application::setDesktop( desk ); if ( desk ) { @@ -4668,6 +4775,7 @@ void LightApp_Application::setDesktop( SUIT_Desktop* desk ) */ bool LightApp_Application::activateModule( CAM_Module* mod ) { + DBG_FUN(); bool res = CAM_Application::activateModule( mod ); if ( objectBrowser() ) @@ -4732,6 +4840,7 @@ void LightApp_Application::onFullScreen(){ */ void LightApp_Application::addViewManager( SUIT_ViewManager* vm ) { + DBG_FUN(); connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onCloseView( SUIT_ViewManager* ) ) ); CAM_Application::addViewManager( vm ); @@ -4742,6 +4851,7 @@ void LightApp_Application::addViewManager( SUIT_ViewManager* vm ) */ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm ) { + DBG_FUN(); disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onCloseView( SUIT_ViewManager* ) ) ); LightApp_Study* aStudy = dynamic_cast(activeStudy()); @@ -4769,6 +4879,7 @@ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm ) */ void LightApp_Application::onRenameWindow() { + DBG_FUN(); if( !desktop() ) return; @@ -4787,6 +4898,7 @@ void LightApp_Application::onRenameWindow() */ void LightApp_Application::onCloseWindow() { + DBG_FUN(); if( !desktop() ) return; @@ -4802,6 +4914,7 @@ void LightApp_Application::onCloseWindow() */ void LightApp_Application::onCloseAllWindow() { + DBG_FUN(); STD_TabDesktop* desk = dynamic_cast( desktop() ); if( !desk ) return; @@ -4820,6 +4933,7 @@ void LightApp_Application::onCloseAllWindow() */ void LightApp_Application::onGroupAllWindow() { + DBG_FUN(); STD_TabDesktop* desk = dynamic_cast( desktop() ); if( !desk ) return; @@ -4834,6 +4948,8 @@ void LightApp_Application::onGroupAllWindow() */ void LightApp_Application::setDefaultStudyName( const QString& theName ) { + DBG_FUN(); + ARG(theName); QStringList anInfoList; modules( anInfoList, false ); @@ -4851,6 +4967,7 @@ void LightApp_Application::setDefaultStudyName( const QString& theName ) */ bool LightApp_Application::event( QEvent* e ) { + DBG_FUN(); if( e && e->type()==2000 ) { SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e; @@ -4875,6 +4992,7 @@ bool LightApp_Application::event( QEvent* e ) /*! Check data object */ bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj) { + DBG_FUN(); if (theObj) { bool isSuitable = !theObj->entry().isEmpty() && @@ -4888,6 +5006,8 @@ bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj) int LightApp_Application::openChoice( const QString& aName ) { + DBG_FUN(); + ARG(aName); int choice = CAM_Application::openChoice( aName ); if ( choice == OpenExist ) // The document is already open. @@ -4903,6 +5023,9 @@ int LightApp_Application::openChoice( const QString& aName ) bool LightApp_Application::openAction( const int choice, const QString& aName ) { + DBG_FUN(); + ARG(choice); + ARG(aName); bool res = false; switch ( choice ) { @@ -4975,6 +5098,7 @@ QStringList LightApp_Application::viewManagersTypes() const */ void LightApp_Application::clearKnownViewManagers() { + DBG_FUN(); QStringList aTypesList = viewManagersTypes(); QList aMgrList; viewManagers( aMgrList ); @@ -5016,6 +5140,7 @@ QString LightApp_Application::browseObjects( const QStringList& theEntryList, const bool theIsApplyAndClose, const bool theIsOptimizedBrowsing ) { + DBG_FUN(); QString aResult; if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() ) { @@ -5066,6 +5191,7 @@ QString LightApp_Application::browseObjects( const QStringList& theEntryList, anObject = aStudy->findObjectByEntry( anEntry ); if( anObject ) { + SHOW2(anObject, SUIT_DataObject*); QModelIndex anIndex = aModel->index( anObject ); anOB->treeView()->scrollTo( anIndex ); } @@ -5138,6 +5264,8 @@ bool LightApp_Application::renameObject( const QString& /*entry*/, const QString /*! Process standard messages from desktop */ void LightApp_Application::onDesktopMessage( const QString& message ) { + DBG_FUN(); + ARG(message); const QString sectionSeparator = "/"; if ( message.toLower() == "updateobjectbrowser" || @@ -5383,6 +5511,7 @@ void LightApp_Application::emitOperationFinished( const QString& theModuleName, void LightApp_Application::updateVisibilityState( DataObjectList& theList, SUIT_ViewModel* theViewModel ) { + DBG_FUN(); if ( !theViewModel || theList.isEmpty() ) return; LightApp_Study* aStudy = dynamic_cast(activeStudy()); @@ -5392,22 +5521,39 @@ void LightApp_Application::updateVisibilityState( DataObjectList& theList, for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) { LightApp_DataObject* obj = dynamic_cast(*itr); + SHOW2(obj, SUIT_DataObject*); + MSGEL("Entry=[" << obj->entry().toStdString() << "] isComponent=" << (aStudy->isComponent( obj->entry() ) ? "Yes" : "No")); if ( !obj || aStudy->isComponent( obj->entry() ) ) continue; QString mname = aStudy->componentDataType(obj->entry()); + SHOW(mname); LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false); if ( aDisplayer ) { Qtx::VisibilityState anObjState = Qtx::UnpresentableState; if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) { if ( aDisplayer->IsDisplayed( obj->entry(), aView ) ) + { + MSGEL("Component=[" << mname.toStdString() << "] Entry=[" << obj->entry().toStdString() << "] - shown"); anObjState = Qtx::ShownState; + } else + { + MSGEL("Component=[" << mname.toStdString() << "] Entry=[" << obj->entry().toStdString() << "] - hidden"); anObjState = Qtx::HiddenState; + } + } + else{ + MSGEL("Component=[" << mname.toStdString() << "] Entry=[" << obj->entry().toStdString() << "]...cannot be displayed"); + //anObjState = Qtx::HiddenState; } aStudy->setVisibilityState( obj->entry(), anObjState ); } + else + { + MSGEL("....no displayer found for component [" << mname.toStdString() << "]!"); + } } } @@ -5417,6 +5563,8 @@ void LightApp_Application::updateVisibilityState( DataObjectList& theList, void LightApp_Application::updatePresentations( const QString& theComponent, const QStringList& theViewManagerTypes ) { + DBG_FUN(); + ARG(theComponent); LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false); if ( aDisplayer ) { LightApp_Study* aStudy = dynamic_cast(activeStudy()); @@ -5439,6 +5587,7 @@ void LightApp_Application::updatePresentations( const QString& theComponent, DataObjectList::const_iterator itObjs = anObjs.begin(); for ( ; itObjs != anObjs.end(); itObjs++ ) { LightApp_DataObject* anObj = dynamic_cast( *itObjs ); + SHOW2(anObj, SUIT_DataObject*); QString anEntry = anObj->entry(); QListIterator itViewMgrs( aViewMgrs ); @@ -5466,10 +5615,12 @@ void LightApp_Application::updatePresentations( const QString& theComponent, */ void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow ) { + DBG_FUN(); SUIT_DataBrowser* anOB = objectBrowser(); if ( !anOB ) return; SUIT_DataObject* rootObj = anOB->root(); + SHOW(rootObj); if ( !rootObj ) return; @@ -5486,6 +5637,7 @@ void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow ) */ void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* ) { + DBG_FUN(); ViewManagerList lst; viewManagers( lst ); if ( lst.count() == 1) { // in case if closed last view window @@ -5500,6 +5652,8 @@ void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* ) */ bool LightApp_Application::checkExistingDoc( bool closeExistingDoc ) { + DBG_FUN(); + ARG(closeExistingDoc); bool result = true; if( activeStudy() ) { int answer = !activeStudy()->isModified() ? 1 : @@ -5557,6 +5711,8 @@ PyConsole_Interp* LightApp_Application::createPyInterp() void LightApp_Application::createHelpItems( const QString& modTitle ) { + DBG_FUN(); + ARG(modTitle); if ( modTitle.isEmpty() ) return; @@ -5641,6 +5797,8 @@ void LightApp_Application::createHelpItems( const QString& modTitle ) void LightApp_Application::removeHelpItems( const QString& modTitle ) { + DBG_FUN(); + ARG(modTitle); QString modName = moduleName( modTitle ); if ( myHelpItems.contains( modName ) ) { diff --git a/src/LightApp/LightApp_DataModel.cxx b/src/LightApp/LightApp_DataModel.cxx index 126ff7ab0..4de186632 100644 --- a/src/LightApp/LightApp_DataModel.cxx +++ b/src/LightApp/LightApp_DataModel.cxx @@ -34,12 +34,19 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_DataModel"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule ) : CAM_DataModel( theModule ) { + DBG_FUN(); myGroupId = 0; if( module() ) myGroupId = qHash( module()->name() ); @@ -50,6 +57,7 @@ LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule ) */ LightApp_DataModel::~LightApp_DataModel() { + DBG_FUN(); } /*! @@ -57,6 +65,7 @@ LightApp_DataModel::~LightApp_DataModel() */ bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList ) { + DBG_FUN(); emit opened(); //TODO: is it really needed? to be removed maybe... return true; } @@ -66,6 +75,7 @@ bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList ) */ bool LightApp_DataModel::save( QStringList& ) { + DBG_FUN(); emit saved(); return true; } @@ -75,6 +85,7 @@ bool LightApp_DataModel::save( QStringList& ) */ bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& ) { + DBG_FUN(); emit saved(); return true; } @@ -85,6 +96,7 @@ bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& ) */ bool LightApp_DataModel::dumpPython( const QString&, CAM_Study*, bool, QStringList& ) { + DBG_FUN(); return true; } @@ -93,6 +105,7 @@ bool LightApp_DataModel::dumpPython( const QString&, CAM_Study*, bool, QStringLi */ bool LightApp_DataModel::close() { + DBG_FUN(); emit closed(); return true; } @@ -102,6 +115,7 @@ bool LightApp_DataModel::close() */ void LightApp_DataModel::build() { + DBG_FUN(); } /*! @@ -109,6 +123,7 @@ void LightApp_DataModel::build() */ void LightApp_DataModel::updateWidgets() { + DBG_FUN(); LightApp_Application* app = dynamic_cast( module()->application() ); if ( app && app->objectBrowser() ) app->objectBrowser()->updateTree( 0, false ); @@ -119,6 +134,7 @@ void LightApp_DataModel::updateWidgets() */ void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* ) { + DBG_FUN(); // san: Previously modelRoot was casted to LightApp_ModuleObject*, // BUT this is incorrect: in full SALOME the model root has different type. // Hopefully LightApp_DataObject* is sufficient here. @@ -205,6 +221,8 @@ int LightApp_DataModel::groupId() const */ void LightApp_DataModel::registerColumn( SUIT_DataBrowser* browser, const QString& name, const int custom_id ) { + DBG_FUN(); + ARG(name); SUIT_AbstractModel* m = dynamic_cast( browser ? browser->model() : 0 ); if( m ) m->registerColumn( groupId(), name, custom_id ); @@ -217,6 +235,8 @@ void LightApp_DataModel::registerColumn( SUIT_DataBrowser* browser, const QStrin */ void LightApp_DataModel::unregisterColumn( SUIT_DataBrowser* browser, const QString& name ) { + DBG_FUN(); + ARG(name); SUIT_AbstractModel* m = dynamic_cast( browser ? browser->model() : 0 ); if( m ) m->unregisterColumn( groupId(), name ); @@ -233,6 +253,7 @@ void LightApp_DataModel::unregisterColumn( SUIT_DataBrowser* browser, const QStr */ CAM_ModuleObject* LightApp_DataModel::createModuleObject( SUIT_DataObject* theRoot ) const { + DBG_FUN(); LightApp_RootObject* aStudyRoot = dynamic_cast( theRoot ); if ( !aStudyRoot ) return 0; diff --git a/src/LightApp/LightApp_DataObject.cxx b/src/LightApp/LightApp_DataObject.cxx index 34f637c21..2483a7ca2 100644 --- a/src/LightApp/LightApp_DataObject.cxx +++ b/src/LightApp/LightApp_DataObject.cxx @@ -36,6 +36,13 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_DataObject"; +#include "MBDebug.h" +#include "MBSUIT.h" +//--------------------------------------------------------- + /*! \class LightApp_DataObject::Key \brief Represents unique data object key for the LightApp_DataObject @@ -113,6 +120,8 @@ LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent ) myCompDataType( "" ), myCompObject( 0 ) { + DBG_FUN(); + ARG(parent); } /*! @@ -120,6 +129,7 @@ LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent ) */ LightApp_DataObject::~LightApp_DataObject() { + DBG_FUN(); } int LightApp_DataObject::groupId() const @@ -221,6 +231,8 @@ bool LightApp_DataObject::renameAllowed( const int id ) const */ bool LightApp_DataObject::setName(const QString& name) { + DBG_FUN(); + ARG(name); LightApp_Module* m = dynamic_cast( module() ); LightApp_RootObject* r = dynamic_cast( root() ); LightApp_Application* app = @@ -318,6 +330,7 @@ QString LightApp_DataObject::text( const int id ) const break; } + MSGEL("LightApp_DataObject::text(id=" << id << ") -> \"" << txt.toStdString() << "\""); return txt; } @@ -488,6 +501,7 @@ LightApp_ModuleObject::LightApp_ModuleObject( SUIT_DataObject* parent ) LightApp_DataObject( parent ), CAM_ModuleObject( parent ) { + DBG_FUN(); } /*! @@ -500,6 +514,7 @@ LightApp_ModuleObject::LightApp_ModuleObject( CAM_DataModel* dm, SUIT_DataObject LightApp_DataObject( parent ), CAM_ModuleObject( dm, parent ) { + DBG_FUN(); } /* @@ -507,6 +522,7 @@ LightApp_ModuleObject::LightApp_ModuleObject( CAM_DataModel* dm, SUIT_DataObject */ LightApp_ModuleObject::~LightApp_ModuleObject() { + DBG_FUN(); } /*! @@ -548,6 +564,7 @@ QString LightApp_ModuleObject::toolTip( const int id ) const */ void LightApp_ModuleObject::insertChild( SUIT_DataObject* obj, int pos ) { + DBG_FUN(); LightApp_DataObject::insertChild( obj, pos ); CAM_DataModel* aModel = dataModel(); @@ -577,6 +594,7 @@ LightApp_RootObject::LightApp_RootObject( LightApp_Study* study ) LightApp_DataObject( 0 ), myStudy( study ) { + DBG_FUN(); } /* @@ -584,6 +602,7 @@ LightApp_RootObject::LightApp_RootObject( LightApp_Study* study ) */ LightApp_RootObject::~LightApp_RootObject() { + DBG_FUN(); } /* @@ -592,6 +611,7 @@ LightApp_RootObject::~LightApp_RootObject() */ void LightApp_RootObject::setStudy( LightApp_Study* study ) { + DBG_FUN(); myStudy = study; } diff --git a/src/LightApp/LightApp_DataOwner.cxx b/src/LightApp/LightApp_DataOwner.cxx index 99f6be61b..bce1b7b40 100644 --- a/src/LightApp/LightApp_DataOwner.cxx +++ b/src/LightApp/LightApp_DataOwner.cxx @@ -22,10 +22,18 @@ #include "LightApp_DataOwner.h" +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_DataOwner"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*!Constructor. Initialize by \a theEntry.*/ LightApp_DataOwner::LightApp_DataOwner( const QString& theEntry ) : myEntry( theEntry ) { + DBG_FUN(); + ARG(theEntry); } #ifndef DISABLE_SALOMEOBJECT @@ -34,12 +42,14 @@ LightApp_DataOwner::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& myEntry(!theIO.IsNull()? theIO->getEntry(): ""), myIO(theIO) { + DBG_FUN(); } #endif /*!Destructor. Do nothing.*/ LightApp_DataOwner::~LightApp_DataOwner() { + DBG_FUN(); } /*!Gets key string, used for data owners comparison.*/ diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index abcfbb757..60ec04352 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -39,11 +39,18 @@ #include "SALOME_InteractiveObject.hxx" #endif +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_Displayer"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Default constructor */ LightApp_Displayer::LightApp_Displayer() { + DBG_FUN(); } /*! @@ -51,6 +58,7 @@ LightApp_Displayer::LightApp_Displayer() */ LightApp_Displayer::~LightApp_Displayer() { + DBG_FUN(); } /*! @@ -62,6 +70,8 @@ LightApp_Displayer::~LightApp_Displayer() void LightApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); + ARG(entry); QStringList aList; aList.append( entry ); Display( aList, updateViewer, theViewFrame ); @@ -76,6 +86,7 @@ void LightApp_Displayer::Display( const QString& entry, const bool updateViewer, void LightApp_Displayer::Display( const QStringList& list, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); QStringList::const_iterator it = list.constBegin(); for ( ; it != list.constEnd(); ++it) @@ -107,6 +118,8 @@ void LightApp_Displayer::Display( const QStringList& list, const bool updateView */ void LightApp_Displayer::Redisplay( const QString& entry, const bool updateViewer ) { + DBG_FUN(); + ARG(entry); // Remove the object permanently ( == true) SUIT_Session* ses = SUIT_Session::session(); SUIT_Application* app = ses->activeApplication(); @@ -145,6 +158,8 @@ void LightApp_Displayer::Erase( const QString& entry, const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); + ARG(entry); QStringList aList; aList.append( entry ); Erase( aList, forced, updateViewer, theViewFrame ); @@ -161,6 +176,7 @@ void LightApp_Displayer::Erase( const QStringList& list, const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); if ( !vf ) @@ -191,6 +207,7 @@ void LightApp_Displayer::Erase( const QStringList& list, const bool forced, */ void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); if ( vf ) { @@ -230,6 +247,7 @@ bool LightApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theView */ void LightApp_Displayer::UpdateViewer() const { + DBG_FUN(); SALOME_View* vf = GetActiveView(); if ( vf ) vf->Repaint(); @@ -243,6 +261,8 @@ void LightApp_Displayer::UpdateViewer() const */ SALOME_Prs* LightApp_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame ) { + DBG_FUN(); + ARG(entry); SALOME_Prs* prs = 0; SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); @@ -258,6 +278,7 @@ SALOME_Prs* LightApp_Displayer::buildPresentation( const QString& entry, SALOME_ */ SALOME_View* LightApp_Displayer::GetActiveView() { + DBG_FUNC(); SUIT_Session* session = SUIT_Session::session(); if ( SUIT_Application* app = session->activeApplication() ) { if ( LightApp_Application* sApp = dynamic_cast( app ) ) { @@ -293,6 +314,7 @@ bool LightApp_Displayer::canBeDisplayed( const QString& entry ) const if( SUIT_ViewManager* vman = sApp->activeViewManager() ) if( SUIT_ViewModel* vmod = vman->getViewModel() ) viewerType = vmod->getType(); + MSGEL(".....LApp_Displayer: [" << entry.toStdString() << "] can be displayed in \"" << viewerType.toStdString() << "\"?"); return canBeDisplayed( entry, viewerType ); } @@ -305,6 +327,9 @@ bool LightApp_Displayer::canBeDisplayed( const QString& entry ) const */ LightApp_Displayer* LightApp_Displayer::FindDisplayer( const QString& mod_name, const bool load ) { + DBG_FUNC(); + ARG(mod_name); + ARG(load); QString mname = LightApp_Application::moduleDisplayer( mod_name ); SUIT_Session* session = SUIT_Session::session(); SUIT_Application* sapp = session ? session->activeApplication() : 0; @@ -338,6 +363,8 @@ LightApp_Displayer* LightApp_Displayer::FindDisplayer( const QString& mod_name, \param load - is module has to be forced loaded */ void LightApp_Displayer::setVisibilityState( const QString& theEntry, Qtx::VisibilityState theState) const { + DBG_FUN(); + ARG(theEntry); LightApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); LightApp_Study* study = app ? dynamic_cast( app->activeStudy() ) : 0; diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index 21e76d437..66574bd03 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -39,17 +39,25 @@ #include #endif +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_Driver"; +#include "MBDebug.h" +//--------------------------------------------------------- + using namespace std; /*! Constructor.*/ LightApp_Driver::LightApp_Driver() : myIsTemp( false ) { + DBG_FUN(); } /*! Destructor.*/ LightApp_Driver::~LightApp_Driver() { + DBG_FUN(); } /*! @@ -57,6 +65,8 @@ LightApp_Driver::~LightApp_Driver() */ bool LightApp_Driver::SaveDatasInFile( const char* theFileName, bool isMultiFile ) { + DBG_FUN(); + ARG(theFileName); int aNbModules = 0; std::map::const_iterator it; for (it = myMap.begin(); it != myMap.end(); ++it) @@ -140,6 +150,8 @@ bool LightApp_Driver::SaveDatasInFile( const char* theFileName, bool isMultiFile */ bool LightApp_Driver::ReadDatasFromFile( const char* theFileName, bool isMultiFile ) { + DBG_FUN(); + ARG(theFileName); #ifdef WIN32 ifstream aFile(theFileName, ios::binary); #else @@ -199,9 +211,12 @@ bool LightApp_Driver::ReadDatasFromFile( const char* theFileName, bool isMultiFi */ std::string LightApp_Driver::GetTmpDir (const char* theURL, const bool isMultiFile) { + DBG_FUN(); + ARG(theURL); std::string anURLDir = GetDirFromPath(theURL); std::string aTmpDir = isMultiFile ? anURLDir : GetTmpDir(); + RET(aTmpDir); return aTmpDir; } @@ -210,6 +225,7 @@ std::string LightApp_Driver::GetTmpDir (const char* theURL, const bool isMultiF */ LightApp_Driver::ListOfFiles LightApp_Driver::GetListOfFiles( const char* theModuleName ) { + DBG_FUN(); ListOfFiles aListOfFiles; std::string aName(theModuleName); @@ -224,6 +240,8 @@ LightApp_Driver::ListOfFiles LightApp_Driver::GetListOfFiles( const char* theMod */ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFiles theListOfFiles ) { + DBG_FUN(); + ARG(theModuleName); std::string aName (theModuleName); myMap[aName] = theListOfFiles; } @@ -234,6 +252,8 @@ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFil void LightApp_Driver::PutFilesToStream( const std::string& theModuleName, unsigned char*& theBuffer, long& theBufferSize, bool theNamesOnly ) { + DBG_FUN(); + ARG(theModuleName); ListOfFiles aFiles = myMap[theModuleName]; // aFiles must contain temporary directory name in its first item // and names of files (relatively the temporary directory) in the others @@ -345,6 +365,7 @@ void LightApp_Driver::PutFilesToStream( const std::string& theModuleName, unsign LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned char* theBuffer, const long theBufferSize, bool theNamesOnly ) { + DBG_FUN(); if(theBufferSize == 0 || theBuffer == 0) return ListOfFiles(); @@ -409,6 +430,7 @@ LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned c */ void LightApp_Driver::RemoveFiles( const ListOfFiles& theFiles, const bool IsDirDeleted) { + DBG_FUN(); int i, aLength = (int)theFiles.size() - 1; //!< TODO: conversion size_t to int if(aLength <= 0) { return; @@ -449,6 +471,8 @@ void LightApp_Driver::RemoveFiles( const ListOfFiles& theFiles, const bool IsDir */ void LightApp_Driver::RemoveTemporaryFiles( const char* theModuleName, const bool IsDirDeleted ) { + DBG_FUN(); + ARG(theModuleName); std::string aModuleName(theModuleName); ListOfFiles aFiles = myMap[aModuleName]; // aFiles must contain temporary directory name in its first item @@ -462,6 +486,7 @@ void LightApp_Driver::RemoveTemporaryFiles( const char* theModuleName, const boo */ void LightApp_Driver::ClearDriverContents() { + DBG_FUN(); std::map::iterator it; for ( it = myMap.begin(); it != myMap.end(); ++it ) { @@ -480,6 +505,7 @@ void LightApp_Driver::ClearDriverContents() */ std::string LightApp_Driver::GetTmpDir() { + DBG_FUN(); if ( myTmpDir.length() != 0 ) return myTmpDir; @@ -541,6 +567,7 @@ std::string LightApp_Driver::GetTmpDir() myTmpDir = aTmpDir.ToCString(); + RET(myTmpDir); return aTmpDir.ToCString(); } diff --git a/src/LightApp/LightApp_GVSelector.cxx b/src/LightApp/LightApp_GVSelector.cxx index eb5bea299..8598c078d 100644 --- a/src/LightApp/LightApp_GVSelector.cxx +++ b/src/LightApp/LightApp_GVSelector.cxx @@ -25,17 +25,25 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_GVSelector"; +#include "MBDebug.h" +//--------------------------------------------------------- + LightApp_GVSelector::LightApp_GVSelector( GraphicsView_Viewer* theViewer, SUIT_SelectionMgr* theSelMgr ) : SUIT_Selector( theSelMgr, theViewer ), myViewer( theViewer ) { + DBG_FUN(); connect( theViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ), this, SLOT( onSelectionChanged( GV_SelectionChangeStatus ) ) ); } LightApp_GVSelector::~LightApp_GVSelector() { + DBG_FUN(); } QString LightApp_GVSelector::type() const @@ -45,6 +53,7 @@ QString LightApp_GVSelector::type() const void LightApp_GVSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const { + DBG_FUN(); if( GraphicsView_ViewPort* aViewport = myViewer->getActiveViewPort() ) for( aViewport->initSelected(); aViewport->moreSelected(); aViewport->nextSelected() ) theList.append( new LightApp_DataOwner( aViewport->selectedObject()->getName() ) ); @@ -52,9 +61,11 @@ void LightApp_GVSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const void LightApp_GVSelector::setSelection( const SUIT_DataOwnerPtrList& /*theList*/ ) { + DBG_FUN(); } void LightApp_GVSelector::onSelectionChanged( GV_SelectionChangeStatus ) { + DBG_FUN(); selectionChanged(); } diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index e5fef3efa..91b66448b 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -100,6 +100,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_Module"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*!Constructor.*/ LightApp_Module::LightApp_Module( const QString& name ) : CAM_Module( name ), @@ -111,11 +117,14 @@ LightApp_Module::LightApp_Module( const QString& name ) myEraseAll( -1 ), myIsFirstActivate( true ) { + DBG_FUN(); + ARG(name); } /*!Destructor.*/ LightApp_Module::~LightApp_Module() { + DBG_FUN(); if ( mySwitchOp ) delete mySwitchOp; } @@ -123,6 +132,7 @@ LightApp_Module::~LightApp_Module() /*!Initialize module.*/ void LightApp_Module::initialize( CAM_Application* app ) { + DBG_FUN(); CAM_Module::initialize( app ); SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0; @@ -143,6 +153,7 @@ void LightApp_Module::viewManagers( QStringList& ) const /*!Context menu popup.*/ void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QString& /*title*/ ) { + DBG_FUN(); LightApp_Selection* sel = createSelection(); sel->init( client, getApp()->selectionMgr() ); @@ -158,6 +169,7 @@ void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QStr void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, SUIT_DataObject* theDataObject ) { + DBG_FUN(); if (!getApp()->objectBrowser()) return; bool upd = getApp()->objectBrowser()->autoUpdate(); @@ -216,6 +228,7 @@ bool LightApp_Module::isSelectionCompatible() /*!Activate module.*/ bool LightApp_Module::activateModule( SUIT_Study* study ) { + DBG_FUN(); bool res = CAM_Module::activateModule( study ); if ( !isSelectionCompatible() )// PAL19290, PAL18352 @@ -258,6 +271,7 @@ bool LightApp_Module::activateModule( SUIT_Study* study ) /*!Deactivate module.*/ bool LightApp_Module::deactivateModule( SUIT_Study* study ) { + DBG_FUN(); delete mySwitchOp; mySwitchOp = 0; @@ -297,6 +311,7 @@ bool LightApp_Module::deactivateModule( SUIT_Study* study ) /*! Redefined to reset internal flags valid for study instance */ void LightApp_Module::studyClosed( SUIT_Study* theStudy ) { + DBG_FUN(); CAM_Module::studyClosed( theStudy ); myIsFirstActivate = true; @@ -351,6 +366,8 @@ LightApp_Application* LightApp_Module::getApp() const */ void LightApp_Module::update( const int theFlags ) { + DBG_FUN(); + ARG(theFlags); if ( theFlags & UF_Model ) { if( CAM_DataModel* aDataModel = dataModel() ) @@ -409,12 +426,14 @@ void LightApp_Module::updateControls() /*!Create new instance of data model and return it.*/ CAM_DataModel* LightApp_Module::createDataModel() { + DBG_FUN(); return new LightApp_DataModel( this ); } /*!Create and return instance of LightApp_Selection.*/ LightApp_Selection* LightApp_Module::createSelection() const { + DBG_FUN(); return new LightApp_Selection(); } @@ -436,6 +455,7 @@ void LightApp_Module::onModelClosed() /*!Gets popup manager.(create if not exist)*/ QtxPopupMgr* LightApp_Module::popupMgr() { + DBG_FUN(); if ( !myPopupMgr ) { myPopupMgr = new QtxPopupMgr( 0, this ); @@ -569,6 +589,8 @@ void LightApp_Module::setPreferenceProperty( const int id, const QString& prop, */ void LightApp_Module::startOperation( const int id ) { + DBG_FUN(); + ARG(id); LightApp_Operation* op = 0; if( myOperations.contains( id ) && reusableOperation( id ) ) op = myOperations[ id ]; @@ -603,6 +625,8 @@ void LightApp_Module::startOperation( const int id ) */ LightApp_Operation* LightApp_Module::createOperation( const int id ) const { + DBG_FUN(); + ARG(id); if( id==-1 ) return 0; @@ -639,6 +663,7 @@ void LightApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ ) */ void LightApp_Module::onOperationDestroyed() { + DBG_FUN(); const QObject* s = sender(); if( s && s->inherits( "LightApp_Operation" ) ) { @@ -668,6 +693,7 @@ LightApp_Displayer* LightApp_Module::displayer() */ void LightApp_Module::onShowHide() { + DBG_FUN(); if( !sender()->inherits( "QAction" ) || !popupMgr() ) return; @@ -796,6 +822,7 @@ bool LightApp_Module::renameObject( const QString& /*entry*/, const QString& /*n */ void LightApp_Module::updateModuleVisibilityState() { + DBG_FUN(); // update visibility state of objects LightApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); if ( !app ) return; @@ -834,6 +861,7 @@ void LightApp_Module::updateModuleVisibilityState() */ void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn ) { + DBG_FUN(); if ( !isActiveModule() ) return; // change visibility of object @@ -859,5 +887,6 @@ void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn void LightApp_Module::onOBDestroyed() { + DBG_FUN(); myIsFirstActivate = true; } diff --git a/src/LightApp/LightApp_OBSelector.cxx b/src/LightApp/LightApp_OBSelector.cxx index 7c4bd88d4..631c9d20d 100644 --- a/src/LightApp/LightApp_OBSelector.cxx +++ b/src/LightApp/LightApp_OBSelector.cxx @@ -34,6 +34,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_OBSelector"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! \class LightApp_OBSelector \brief Object browser selection handler class. @@ -48,6 +54,7 @@ LightApp_OBSelector::LightApp_OBSelector( SUIT_DataBrowser* ob, SUIT_SelectionMg : SUIT_Selector( mgr, ob ), myBrowser( ob ) { + DBG_FUN(); if ( myBrowser ) { connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); } @@ -59,6 +66,7 @@ LightApp_OBSelector::LightApp_OBSelector( SUIT_DataBrowser* ob, SUIT_SelectionMg */ LightApp_OBSelector::~LightApp_OBSelector() { + DBG_FUN(); } /*! @@ -93,6 +101,7 @@ unsigned long LightApp_OBSelector::getModifiedTime() const */ void LightApp_OBSelector::setModified() { + DBG_FUN(); myModifiedTime = clock(); } @@ -101,6 +110,7 @@ void LightApp_OBSelector::setModified() */ void LightApp_OBSelector::onSelectionChanged() { + DBG_FUN(); #ifdef _DEBUG_ QTime t1 = QTime::currentTime(); #endif @@ -118,6 +128,7 @@ void LightApp_OBSelector::onSelectionChanged() */ void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const { + DBG_FUN(); if ( mySelectedList.count() == 0 ) { SUIT_Session* session = SUIT_Session::session(); SUIT_Application* sapp = session ? session->activeApplication() : 0; @@ -145,6 +156,7 @@ void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const } } } + RET(mySelectedList.count()); theList = mySelectedList; } @@ -154,6 +166,7 @@ void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const */ void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) { + DBG_FUN(); if ( !myBrowser ) return; @@ -178,6 +191,7 @@ void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) */ void LightApp_OBSelector::fillEntries( QMap& entries ) { + DBG_FUN(); entries.clear(); if ( !myBrowser ) diff --git a/src/LightApp/LightApp_Operation.cxx b/src/LightApp/LightApp_Operation.cxx index 282d24351..68876ddb6 100644 --- a/src/LightApp/LightApp_Operation.cxx +++ b/src/LightApp/LightApp_Operation.cxx @@ -33,6 +33,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_Operation"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! * \brief Constructor * @@ -43,6 +49,7 @@ LightApp_Operation::LightApp_Operation() myModule( 0 ), myIsAutoResumed( true ) { + DBG_FUN(); } /*! @@ -52,7 +59,7 @@ LightApp_Operation::LightApp_Operation() */ LightApp_Operation::~LightApp_Operation() { - + DBG_FUN(); } /*! @@ -77,6 +84,7 @@ LightApp_Module* LightApp_Operation::module() const */ void LightApp_Operation::setModule( LightApp_Module* theModule ) { + DBG_FUN(); myModule = theModule; setApplication( myModule ? myModule->application() : 0 ); setStudy( application() ? application()->activeStudy() : 0 ); @@ -102,6 +110,7 @@ SUIT_Desktop* LightApp_Operation::desktop() const */ void LightApp_Operation::resumeOperation() { + DBG_FUN(); SUIT_Operation::resumeOperation(); setDialogActive( true ); } @@ -114,6 +123,7 @@ void LightApp_Operation::resumeOperation() */ void LightApp_Operation::startOperation() { + DBG_FUN(); if( selectionMgr() ) connect( selectionMgr(), SIGNAL( selectionChanged() ), SLOT( onSelectionDone() ) ); @@ -130,6 +140,7 @@ void LightApp_Operation::startOperation() */ void LightApp_Operation::suspendOperation() { + DBG_FUN(); SUIT_Operation::suspendOperation(); setDialogActive( false ); } @@ -142,6 +153,7 @@ void LightApp_Operation::suspendOperation() */ void LightApp_Operation::abortOperation() { + DBG_FUN(); SUIT_Operation::abortOperation(); setDialogActive( true ); if ( dlg() ) @@ -159,6 +171,7 @@ void LightApp_Operation::abortOperation() */ void LightApp_Operation::commitOperation() { + DBG_FUN(); SUIT_Operation::commitOperation(); setDialogActive( true ); if ( dlg() ) @@ -191,6 +204,7 @@ LightApp_Dialog* LightApp_Operation::dlg() const */ void LightApp_Operation::activateSelection() { + DBG_FUN(); } /*! @@ -201,6 +215,7 @@ void LightApp_Operation::activateSelection() */ void LightApp_Operation::selectionDone() { + DBG_FUN(); } /*! @@ -235,6 +250,7 @@ LightApp_SelectionMgr* LightApp_Operation::selectionMgr() const */ void LightApp_Operation::onSelectionDone() { + DBG_FUN(); if ( isActive() ) selectionDone(); } @@ -248,6 +264,7 @@ void LightApp_Operation::onSelectionDone() */ void LightApp_Operation::update( const int flags ) { + DBG_FUN(); if ( myModule != 0 ) myModule->update( flags ); } @@ -261,6 +278,8 @@ void LightApp_Operation::update( const int flags ) */ void LightApp_Operation::setDialogActive( const bool active ) { + DBG_FUN(); + ARG(active); if( dlg() ) { if( active ) @@ -295,5 +314,7 @@ bool LightApp_Operation::isAutoResumed() const */ void LightApp_Operation::setAutoResumed( const bool on ) { + DBG_FUN(); + ARG(on); myIsAutoResumed = on; } diff --git a/src/LightApp/LightApp_Selection.cxx b/src/LightApp/LightApp_Selection.cxx index 813b5e3a9..29abb6b2f 100644 --- a/src/LightApp/LightApp_Selection.cxx +++ b/src/LightApp/LightApp_Selection.cxx @@ -37,12 +37,19 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_Selection"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ LightApp_Selection::LightApp_Selection() : myStudy( 0 ) { + DBG_FUN(); } /*! @@ -50,6 +57,7 @@ LightApp_Selection::LightApp_Selection() */ LightApp_Selection::~LightApp_Selection() { + DBG_FUN(); } /*! @@ -57,6 +65,8 @@ LightApp_Selection::~LightApp_Selection() */ void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr) { + DBG_FUN(); + ARG(client); myContext = client; if ( mgr ) { @@ -132,6 +142,7 @@ QString LightApp_Selection::referencedToEntry( const QString& entry ) const */ int LightApp_Selection::count() const { + MSGEL("...numSelObjs = " << (int)myObjects.size()); return myObjects.size(); } @@ -180,6 +191,8 @@ QVariant LightApp_Selection::parameter( const int idx, const QString& p ) const //QVariant LightApp_Selection::contextParameter( const QString& p ) const QVariant LightApp_Selection::parameter( const QString& p ) const { + DBG_FUN(); + ARG(p); QVariant v; if ( p == "client" ) @@ -206,6 +219,9 @@ QVariant LightApp_Selection::parameter( const QString& p ) const //QVariant LightApp_Selection::objectParameter( const int idx, const QString& p ) const QVariant LightApp_Selection::parameter( const int idx, const QString& p ) const { + DBG_FUN(); + ARG(idx); + ARG(p); LightApp_Application* app = 0; if ( myStudy ) app = dynamic_cast( myStudy->application() ); @@ -274,6 +290,8 @@ bool LightApp_Selection::processOwner( const LightApp_DataOwner* /*owner*/ ) QString LightApp_Selection::entry( const int index ) const { QVariant v = objectInfo( index, OI_Entry ); + QString qEntry = v.canConvert( QVariant::String ) ? v.toString() : QString(); + MSGEL("LightApp_Selection::entry(index=" << index << ") -> \"" << qEntry.toStdString() << "\""); return v.canConvert( QVariant::String ) ? v.toString() : QString(); } @@ -335,6 +353,9 @@ QVariant LightApp_Selection::objectInfo( const int idx, const int inf ) const */ void LightApp_Selection::setObjectInfo( const int idx, const int inf, const QVariant& val ) { + DBG_FUN(); + ARG(idx); + ARG(inf); if ( 0 <= idx && idx < myObjects.size() ) myObjects[idx].insert( inf, val ); } diff --git a/src/LightApp/LightApp_SelectionMgr.cxx b/src/LightApp/LightApp_SelectionMgr.cxx index f3d46befa..98d15fd61 100644 --- a/src/LightApp/LightApp_SelectionMgr.cxx +++ b/src/LightApp/LightApp_SelectionMgr.cxx @@ -40,6 +40,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_SelectionMgr"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor. */ @@ -49,6 +55,7 @@ LightApp_SelectionMgr::LightApp_SelectionMgr( LightApp_Application* app, const b myTimeStamp( QTime::currentTime() ), myCacheState( false ) { + DBG_FUN(); } /*! @@ -56,6 +63,7 @@ LightApp_SelectionMgr::LightApp_SelectionMgr( LightApp_Application* app, const b */ LightApp_SelectionMgr::~LightApp_SelectionMgr() { + DBG_FUN(); } /*! @@ -68,6 +76,7 @@ LightApp_Application* LightApp_SelectionMgr::application() const void LightApp_SelectionMgr::setSelected( const SUIT_DataOwnerPtrList& lst, const bool append ) { + DBG_FUN(); SUIT_SelectionMgr::setSelected( lst, append ); myTimeStamp = QTime::currentTime(); @@ -82,6 +91,8 @@ Handle(SALOME_InteractiveObject) LightApp_SelectionMgr::soleSelectedObject( const QString& theType, const bool convertReferences ) const { + DBG_FUN(); + ARG(theType); SALOME_ListIO list; selectedObjects( list, theType, convertReferences, true ); return list.Extent() == 1 ? list.First() : Handle(SALOME_InteractiveObject)(); @@ -95,6 +106,8 @@ void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const bool convertReferences, const bool sole) const { + DBG_FUN(); + ARG(theType); LightApp_Study* study = dynamic_cast( application()->activeStudy() ); if ( !study ) return; @@ -178,6 +191,7 @@ void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, */ void LightApp_SelectionMgr::setSelectedObjects( const SALOME_ListIO& lst, const bool append ) { + DBG_FUN(); SUIT_DataOwnerPtrList owners; for ( SALOME_ListIteratorOfListIO it( lst ); it.More(); it.Next() ) { @@ -264,6 +278,7 @@ void LightApp_SelectionMgr::setSelectedObjects( const QStringList& lst, const bo */ void LightApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel ) { + DBG_FUN(); SUIT_SelectionMgr::selectionChanged( theSel ); myTimeStamp = QTime::currentTime(); @@ -279,6 +294,7 @@ void LightApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel ) void LightApp_SelectionMgr::GetIndexes( const Handle(SALOME_InteractiveObject)& IObject, TColStd_IndexedMapOfInteger& theIndex) { + DBG_FUN(); theIndex.Clear(); SUIT_DataOwnerPtrList aList; @@ -297,6 +313,8 @@ void LightApp_SelectionMgr::GetIndexes( const Handle(SALOME_InteractiveObject)& */ void LightApp_SelectionMgr::GetIndexes( const QString& theEntry, TColStd_IndexedMapOfInteger& theIndex ) { + DBG_FUN(); + ARG(theEntry); theIndex.Clear(); SUIT_DataOwnerPtrList aList; @@ -320,6 +338,7 @@ void LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObj const TColStd_MapOfInteger& theIndexes, bool modeShift) { + DBG_FUN(); SUIT_DataOwnerPtrList remainsOwners; SUIT_DataOwnerPtrList aList; @@ -369,6 +388,7 @@ void LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObj void LightApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject)& IObject, TColStd_IndexedMapOfInteger theIndex, bool append ) { + DBG_FUN(); SUIT_DataOwnerPtrList aList; if ( theIndex.IsEmpty() ) @@ -388,6 +408,7 @@ void LightApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject */ void LightApp_SelectionMgr::selectObjects( MapIOOfMapOfInteger theMapIO, bool append ) { + DBG_FUN(); SUIT_DataOwnerPtrList aList; MapIOOfMapOfInteger::Iterator it(theMapIO); @@ -411,6 +432,7 @@ void LightApp_SelectionMgr::selectObjects( MapIOOfMapOfInteger theMapIO, bool ap */ void LightApp_SelectionMgr::selectedSubOwners( MapEntryOfMapOfInteger& theMap ) { + DBG_FUN(); theMap.Clear(); TColStd_IndexedMapOfInteger anIndexes; @@ -452,6 +474,7 @@ void LightApp_SelectionMgr::selectedSubOwners( MapEntryOfMapOfInteger& theMap ) void LightApp_SelectionMgr::clearSelectionCache() { + DBG_FUN(); myCacheTimes.clear(); myCacheSelection.clear(); } @@ -463,6 +486,8 @@ bool LightApp_SelectionMgr::isSelectionCacheEnabled() const void LightApp_SelectionMgr::setSelectionCacheEnabled( bool on ) { + DBG_FUN(); + ARG(on); if ( myCacheState == on ) return; @@ -476,6 +501,8 @@ void LightApp_SelectionMgr::setSelectionCacheEnabled( bool on ) QList LightApp_SelectionMgr::selectionCache( const QString& type ) const { + DBG_FUN(); + ARG(type); QList res; QStringList types; @@ -530,6 +557,8 @@ QStringList LightApp_SelectionMgr::selectionCache( const QString& type ) const bool LightApp_SelectionMgr::isActualSelectionCache( const QString& type ) const { + DBG_FUN(); + ARG(type); bool ok = true; QStringList types; @@ -546,12 +575,16 @@ bool LightApp_SelectionMgr::isActualSelectionCache( const QString& type ) const QStringList LightApp_SelectionMgr::selectorTypes() const { + DBG_FUN(); QStringList types; QList selectorList; selectors( selectorList ); for ( QList::const_iterator it = selectorList.begin(); it != selectorList.end(); ++it ) { if ( (*it)->isEnabled() ) + { + SHOW((*it)->type()); types.append( (*it)->type() ); + } } return types; } diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index 7930cf385..e4305fad7 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -35,6 +35,12 @@ #include #endif +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "LightApp_ShowHideOp"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ @@ -42,6 +48,7 @@ LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type ) : LightApp_Operation(), myActionType( type ) { + DBG_FUN(); } /*! @@ -49,6 +56,7 @@ LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type ) */ LightApp_ShowHideOp::~LightApp_ShowHideOp() { + DBG_FUN(); } /*! @@ -56,6 +64,7 @@ LightApp_ShowHideOp::~LightApp_ShowHideOp() */ void LightApp_ShowHideOp::startOperation() { + DBG_FUN(); LightApp_Application* app = dynamic_cast( application() ); LightApp_Study* study = app ? dynamic_cast( app->activeStudy() ) : 0; if( !app || !study ) diff --git a/src/LightApp/MBDebug.h b/src/LightApp/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/LightApp/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/LightApp/MBSUIT.h b/src/LightApp/MBSUIT.h new file mode 100644 index 000000000..2212c7b3a --- /dev/null +++ b/src/LightApp/MBSUIT.h @@ -0,0 +1,18 @@ +#ifndef MBSUIT_H +#define MBSUIT_H + +#include + + +//========================================================================== +static void DumpVar(const char *szName, const SUIT_DataObject *value) { + if (value) { + DLOG << "[DataObj]: " << szName << "=" << (void*)value << " name=\"" << value->name().toStdString() << "\" level=" << value->level() + << " pos=" << value->position() << " #child=" << value->childCount() << " what=\"" << value->whatsThis().toStdString() << "\"" << std::endl; + } + else { + DLOG << "[DataObj]: " << szName << "=null" << std::endl; + } +} + +#endif // MBSUIT_H \ No newline at end of file diff --git a/src/OCCViewer/MBDebug.h b/src/OCCViewer/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/OCCViewer/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/OCCViewer/OCCViewer_AISSelector.cxx b/src/OCCViewer/OCCViewer_AISSelector.cxx index a878ec89f..1eb7a571f 100644 --- a/src/OCCViewer/OCCViewer_AISSelector.cxx +++ b/src/OCCViewer/OCCViewer_AISSelector.cxx @@ -22,6 +22,12 @@ #include "OCCViewer_AISSelector.h" +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_AISSelector"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ @@ -32,6 +38,7 @@ OCCViewer_AISSelector::OCCViewer_AISSelector( QObject* parent, myEnableSelection( true ), myEnableMultipleSelection( true ) { + DBG_FUN(); myHilightColor = Quantity_NOC_CYAN1; mySelectColor = Quantity_NOC_GRAY80; @@ -43,6 +50,7 @@ OCCViewer_AISSelector::OCCViewer_AISSelector( QObject* parent, */ OCCViewer_AISSelector::~OCCViewer_AISSelector() { + DBG_FUN(); } /*! @@ -50,6 +58,8 @@ OCCViewer_AISSelector::~OCCViewer_AISSelector() */ void OCCViewer_AISSelector::enableSelection( bool bEnable ) { + DBG_FUN(); + ARG(bEnable); myEnableSelection = bEnable; } @@ -59,6 +69,8 @@ void OCCViewer_AISSelector::enableSelection( bool bEnable ) */ void OCCViewer_AISSelector::enableMultipleSelection( bool bEnable ) { + DBG_FUN(); + ARG(bEnable); myEnableMultipleSelection = bEnable; if ( bEnable ) myEnableSelection = bEnable; } @@ -92,6 +104,7 @@ void OCCViewer_AISSelector::setSelectColor ( Quantity_NameOfColor color ) */ void OCCViewer_AISSelector::setAISContext ( const Handle (AIS_InteractiveContext)& aisContext ) { + DBG_FUN(); myAISContext = aisContext; if ( ! myAISContext.IsNull() ) { const Handle(Prs3d_Drawer)& hStyle = myAISContext->HighlightStyle(); @@ -158,6 +171,7 @@ bool OCCViewer_AISSelector::select () if ( !myEnableSelection ) return false; + DBG_FUN(); bool hadSelection = ( myNumSelected > 0 ); /* select and send notifications */ @@ -178,6 +192,7 @@ bool OCCViewer_AISSelector::select ( int left, int top, int right, int bottom, if ( !myEnableSelection || !myEnableMultipleSelection ) return false; /* selection with rectangle is considered as multiple selection */ + DBG_FUN(); bool hadSelection = ( myNumSelected > 0 ); /* select and send notifications */ @@ -198,6 +213,7 @@ bool OCCViewer_AISSelector::shiftSelect () if ( !myEnableSelection ) return false; + DBG_FUN(); bool hadSelection = ( myNumSelected > 0 ); /* something was selected */ if ( hadSelection && !myEnableMultipleSelection) return false; @@ -222,6 +238,7 @@ bool OCCViewer_AISSelector::shiftSelect ( int left, int top, int right, int bott if ( !myEnableSelection || !myEnableMultipleSelection ) return false; /* selection with rectangle is considered as multiple selection */ + DBG_FUN(); bool hadSelection = ( myNumSelected > 0 ); /* something was selected */ if ( hadSelection && !myEnableMultipleSelection) return false; diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index 3d95c2b02..62d428c14 100644 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -38,12 +38,19 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_VService"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Create native view window for CasCade view [ static ] */ Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view, WId winId ) { + DBG_FUNC(); #if OCC_VERSION_LARGE < 0x07070000 Aspect_Handle aWindowHandle = (Aspect_Handle)winId; #else @@ -66,6 +73,7 @@ Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& */ Handle(V3d_Viewer) OCCViewer_VService::CreateViewer() { + DBG_FUNC(); Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver(new Aspect_DisplayConnection()); return new V3d_Viewer(aGraphicDriver); diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index dd48c0551..9f7e0595f 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -36,9 +36,16 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_ViewFrame"; +#include "MBDebug.h" +//--------------------------------------------------------- + OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel) : OCCViewer_ViewWindow( theDesktop, theModel ), mySplitMode(-1), myPopupRequestedView(0) { + DBG_FUN(); QFrame* centralFrame = new QFrame( this ); setCentralWidget( centralFrame ); @@ -59,6 +66,7 @@ OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Vie OCCViewer_ViewFrame::~OCCViewer_ViewFrame() { + DBG_FUN(); } bool OCCViewer_ViewFrame::event( QEvent* e ) @@ -87,6 +95,7 @@ OCCViewer_ViewWindow* OCCViewer_ViewFrame::getActiveView( ) const //************************************************************************************** void OCCViewer_ViewFrame::setViewManager( SUIT_ViewManager* theMgr ) { + DBG_FUN(); OCCViewer_ViewWindow::setViewManager(theMgr); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setViewManager(theMgr); @@ -96,6 +105,7 @@ void OCCViewer_ViewFrame::setViewManager( SUIT_ViewManager* theMgr ) //************************************************************************************** void OCCViewer_ViewFrame::returnTo3dView() { + DBG_FUN(); OCCViewer_ViewWindow* view = 0; for (int i = BOTTOM_RIGHT; i <= TOP_RIGHT; i++ ) { view = myViews.at(i); @@ -117,6 +127,7 @@ void OCCViewer_ViewFrame::returnTo3dView() //************************************************************************************** void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool isMaximized) { + DBG_FUN(); myMaximizedView = theView; myActiveView = theView; if (isMaximized) { @@ -152,6 +163,7 @@ void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool i //************************************************************************************** void OCCViewer_ViewFrame::createSubViews() { + DBG_FUN(); OCCViewer_Viewer* aModel = dynamic_cast(myManager->getViewModel()); if (!aModel) return; int i = 0; @@ -178,6 +190,7 @@ void OCCViewer_ViewFrame::createSubViews() //************************************************************************************** void OCCViewer_ViewFrame::setSubViewParams( OCCViewer_ViewWindow* theView ) { + DBG_FUN(); Handle(V3d_View) aView = theView->getViewPort()->getView(); Handle(V3d_View) aMainView = myViews.at( MAIN_VIEW )->getViewPort()->getView(); @@ -190,6 +203,7 @@ void OCCViewer_ViewFrame::setSubViewParams( OCCViewer_ViewWindow* theView ) void OCCViewer_ViewFrame::splitSubViews() { + DBG_FUN(); if( mySplitMode == -1 ) return; @@ -317,6 +331,7 @@ void OCCViewer_ViewFrame::updateEnabledDrawMode() void OCCViewer_ViewFrame::setCuttingPlane( bool on, const double x , const double y , const double z, const double dx, const double dy, const double dz) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setCuttingPlane(on, x, y, z, dx, dy, dz); aView->update(); @@ -326,6 +341,7 @@ void OCCViewer_ViewFrame::setCuttingPlane( bool on, const double x , const doubl //************************************************************************************** void OCCViewer_ViewFrame::setCuttingPlane( bool on, const gp_Pln thePln ) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setCuttingPlane(on, thePln); aView->update(); @@ -335,6 +351,7 @@ void OCCViewer_ViewFrame::setCuttingPlane( bool on, const gp_Pln thePln ) //************************************************************************************** void OCCViewer_ViewFrame::setInteractionStyle( const int i ) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setInteractionStyle(i); } @@ -349,6 +366,7 @@ int OCCViewer_ViewFrame::projectionType() const //************************************************************************************** void OCCViewer_ViewFrame::setProjectionType( int t) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setProjectionType(t); } @@ -363,6 +381,7 @@ OCCViewer_ViewWindow::SelectionStyle OCCViewer_ViewFrame::selectionStyle() const //************************************************************************************** void OCCViewer_ViewFrame::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle t) { + DBG_FUN(); foreach(OCCViewer_ViewWindow* aView, myViews) { aView->setSelectionStyle(t); } @@ -377,6 +396,7 @@ int OCCViewer_ViewFrame::stereoType() const //************************************************************************************** void OCCViewer_ViewFrame::setStereoType( int t) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setStereoType(t); } @@ -459,6 +479,7 @@ bool OCCViewer_ViewFrame::isVSync() const //************************************************************************************** void OCCViewer_ViewFrame::setVSync( bool t) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setVSync(t); } @@ -473,6 +494,7 @@ bool OCCViewer_ViewFrame::isQuadBufferSupport() const //************************************************************************************** void OCCViewer_ViewFrame::setQuadBufferSupport( bool t) { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->setQuadBufferSupport(t); } @@ -489,6 +511,7 @@ void OCCViewer_ViewFrame::setZoomingStyle( const int i ) //************************************************************************************** void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView) { + DBG_FUN(); connect( theView, SIGNAL( returnedTo3d( ) ), this, SLOT( returnTo3dView( ) ) ); connect( theView, SIGNAL( maximized( OCCViewer_ViewWindow*, bool ) ), @@ -528,6 +551,7 @@ void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView) // obsolete void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor ) { + DBG_FUN(); if (myPopupRequestedView) myPopupRequestedView->setBackgroundColor(theColor); else { @@ -539,6 +563,7 @@ void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor ) } void OCCViewer_ViewFrame::setBackground( const Qtx::BackgroundData& theBackground ) { + DBG_FUN(); if (myPopupRequestedView) myPopupRequestedView->setBackground(theBackground); else { @@ -551,6 +576,7 @@ void OCCViewer_ViewFrame::setBackground( const Qtx::BackgroundData& theBackgroun void OCCViewer_ViewFrame::onViewFitAll() { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->onViewFitAll(); } @@ -558,6 +584,7 @@ void OCCViewer_ViewFrame::onViewFitAll() void OCCViewer_ViewFrame::onFitAll() { + DBG_FUN(); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->onFitAll(); } @@ -639,6 +666,7 @@ void OCCViewer_ViewFrame::onDumpView() void OCCViewer_ViewFrame::setDropDownButtons( bool on ) { + DBG_FUN(); foreach( OCCViewer_ViewWindow* aView, myViews ) { aView->setDropDownButtons( on ); } @@ -669,6 +697,7 @@ QString OCCViewer_ViewFrame::getVisualParameters() void OCCViewer_ViewFrame::setVisualParameters( const QString& parameters ) { + DBG_FUN(); QStringList params = parameters.split( "|" ); if ( params.count() > 1 ) { int maximizedView = params[0].toInt(); @@ -726,6 +755,8 @@ void OCCViewer_ViewFrame::updateWindowTitle(OCCViewer_ViewWindow* theView) void OCCViewer_ViewFrame::enableSelection( bool isEnabled ) { + DBG_FUN(); + ARG(isEnabled); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->enableSelection(isEnabled); } @@ -733,6 +764,8 @@ void OCCViewer_ViewFrame::enableSelection( bool isEnabled ) void OCCViewer_ViewFrame::enablePreselection( bool isEnabled ) { + DBG_FUN(); + ARG(isEnabled); foreach (OCCViewer_ViewWindow* aView, myViews) { aView->enablePreselection(isEnabled); } @@ -740,6 +773,8 @@ void OCCViewer_ViewFrame::enablePreselection( bool isEnabled ) bool OCCViewer_ViewFrame::enableDrawMode( bool on ) { + DBG_FUN(); + ARG(on); bool prev = false; foreach (OCCViewer_ViewWindow* aView, myViews) { prev = prev || aView->enableDrawMode( on ); diff --git a/src/OCCViewer/OCCViewer_ViewManager.cxx b/src/OCCViewer/OCCViewer_ViewManager.cxx index 6920741f4..b20fcf968 100644 --- a/src/OCCViewer/OCCViewer_ViewManager.cxx +++ b/src/OCCViewer/OCCViewer_ViewManager.cxx @@ -24,6 +24,12 @@ #include "OCCViewer_ViewWindow.h" #include "SUIT_Desktop.h" +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_ViewManager"; +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ @@ -31,6 +37,7 @@ OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* t : SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) ), myIsChainedOperations( false ) { + DBG_FUN(); setTitle( tr( "OCC_VIEW_TITLE" ) ); } @@ -39,6 +46,7 @@ OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* t */ OCCViewer_ViewManager::~OCCViewer_ViewManager() { + DBG_FUN(); } /*! @@ -47,6 +55,7 @@ OCCViewer_ViewManager::~OCCViewer_ViewManager() */ void OCCViewer_ViewManager::contextMenuPopup( QMenu* popup ) { + DBG_FUN(); SUIT_ViewManager::contextMenuPopup( popup ); // if it is necessary invoke method CreatePopup of ViewPort // be sure that existing QPopupMenu menu is used for that. @@ -59,5 +68,7 @@ bool OCCViewer_ViewManager::isChainedOperations() const void OCCViewer_ViewManager::setChainedOperations( bool isChainedOperations ) { + DBG_FUN(); + ARG(isChainedOperations); myIsChainedOperations = isChainedOperations; } diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index f57115479..3491a28d2 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -69,6 +69,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_ViewModel"; +#include "MBDebug.h" +//--------------------------------------------------------- + namespace { void setCappingColor(const Handle(Graphic3d_ClipPlane)& plane, const QColor& color) @@ -129,6 +135,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myClippingDlg(0), myFitter(0) { + DBG_FUN(); // init CasCade viewers myV3dViewer = OCCViewer_VService::CreateViewer(); //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267) @@ -215,6 +222,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) */ OCCViewer_Viewer::~OCCViewer_Viewer() { + DBG_FUN(); myAISContext.Nullify(); myV3dViewer.Nullify(); } @@ -242,6 +250,7 @@ Qtx::BackgroundData OCCViewer_Viewer::background() const */ void OCCViewer_Viewer::setBackgroundColor( const QColor& c ) { + DBG_FUN(); setBackgroundColor( 0, c ); } @@ -251,6 +260,7 @@ void OCCViewer_Viewer::setBackgroundColor( const QColor& c ) */ void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground ) { + DBG_FUN(); setBackground( 0, theBackground ); } @@ -260,6 +270,7 @@ void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground ) */ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) { + DBG_FUN(); if ( view ) { view->initLayout(); view->initSketchers(); @@ -293,6 +304,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) */ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { + DBG_FUN(); // create view frame OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this); // get main view window (created by view frame) @@ -311,6 +323,7 @@ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) */ void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager) { + DBG_FUN(); SUIT_ViewModel::setViewManager(theViewManager); if (theViewManager) { connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), @@ -367,6 +380,7 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE */ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) { + DBG_FUN(); if (!mySelectionEnabled) return; if (theEvent->button() != Qt::LeftButton) return; if (!theWindow->inherits("OCCViewer_ViewWindow")) return; @@ -476,6 +490,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*) { + DBG_FUN(); Standard_Integer aViewsNb = 0; for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews()) ++aViewsNb; @@ -487,6 +502,8 @@ void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*) void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort) { + DBG_FUN(); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); setTrihedronShown( true ); @@ -522,6 +539,7 @@ int OCCViewer_Viewer::interactionStyle() const */ void OCCViewer_Viewer::setInteractionStyle( const int theStyle ) { + DBG_FUN(); myInteractionStyle = theStyle; //!! To be done for view windows if ( !myViewManager ) @@ -550,6 +568,7 @@ int OCCViewer_Viewer::projectionType() const */ void OCCViewer_Viewer::setProjectionType( const int theType ) { + DBG_FUN(); if ( myProjectionType != theType ) { if ( theType != OCCViewer_ViewWindow::Stereo ) myProjectionType = theType; @@ -575,6 +594,7 @@ OCCViewer_ViewWindow::SelectionStyle OCCViewer_Viewer::selectionStyle() const void OCCViewer_Viewer::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle theMode) { + DBG_FUN(); if (mySelectionStyle != theMode) { mySelectionStyle = theMode; if (!myViewManager) @@ -606,6 +626,7 @@ int OCCViewer_Viewer::stereoType() const */ void OCCViewer_Viewer::setStereoType( const int theType ) { + DBG_FUN(); myStereoType = theType; if ( !myViewManager ) @@ -766,6 +787,7 @@ bool OCCViewer_Viewer::isVSync() const */ void OCCViewer_Viewer::setVSync( const bool theEnable ) { + DBG_FUN(); myVSyncMode = theEnable; if ( !myViewManager ) @@ -794,6 +816,7 @@ bool OCCViewer_Viewer::isQuadBufferSupport() const */ void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable ) { + DBG_FUN(); myQuadBufferSupport = theEnable; if ( !myViewManager ) @@ -850,6 +873,7 @@ bool OCCViewer_Viewer::isPreselectionEnabled() const */ void OCCViewer_Viewer::enablePreselection(bool isEnabled) { + DBG_FUN(); myPreselectionEnabled = isEnabled; if ( !myViewManager ) @@ -879,6 +903,7 @@ bool OCCViewer_Viewer::isSelectionEnabled() const */ void OCCViewer_Viewer::enableSelection(bool isEnabled) { + DBG_FUN(); mySelectionEnabled = isEnabled; //!! To be done for view windows @@ -909,6 +934,7 @@ void OCCViewer_Viewer::enableSelection(bool isEnabled) */ void OCCViewer_Viewer::enableMultiselection(bool isEnable) { + DBG_FUN(); myMultiSelectionEnabled = isEnable; //!! To be done for view windows if ( !myViewManager ) @@ -974,6 +1000,7 @@ Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, con void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture, const bool isModulate, const double theScale ) { + DBG_FUN(); myDefaultTextureUsed = isDefault; myClippingTexture = theTexture; myTextureModulated = isModulate; @@ -1028,6 +1055,7 @@ double OCCViewer_Viewer::clippingTextureScale() const */ void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup) { + DBG_FUN(); thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) ); @@ -1059,6 +1087,7 @@ void OCCViewer_Viewer::onDumpView() */ void OCCViewer_Viewer::onChangeBackground() { + DBG_FUN(); OCCViewer_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView()); if ( !aView ) return; @@ -1090,6 +1119,7 @@ void OCCViewer_Viewer::onChangeBackground() */ void OCCViewer_Viewer::update() { + DBG_FUN(); if (!myV3dViewer.IsNull()) myV3dViewer->Update(); @@ -1115,6 +1145,7 @@ void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList) */ void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList) { + DBG_FUN(); AIS_ListIteratorOfListOfInteractive aIt; for (aIt.Initialize(theList); aIt.More(); aIt.Next()) myAISContext->AddOrRemoveSelected(aIt.Value(), false); @@ -1134,6 +1165,7 @@ void OCCViewer_Viewer::performSelectionChanged() */ void OCCViewer_Viewer::setDefaultLights() { + DBG_FUN(); // clear all light sources myV3dViewer->InitDefinedLights(); while ( myV3dViewer->MoreDefinedLights() ) @@ -1233,6 +1265,7 @@ void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj, const QColor& color, bool update ) { + DBG_FUN(); if( !obj.IsNull() ) { Quantity_Color CSFColor = Quantity_Color ( color.red() / 255., @@ -1255,6 +1288,7 @@ void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj, void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj, int mode, bool update ) { + DBG_FUN(); myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update ); if( update ) myV3dViewer->Update(); @@ -1269,6 +1303,7 @@ void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject) void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj, float trans, bool update ) { + DBG_FUN(); myAISContext->SetTransparency( obj, trans, false ); myAISContext->Redisplay( obj, Standard_False, Standard_True ); if( update ) @@ -1459,6 +1494,7 @@ void OCCViewer_Viewer::isos( int& u, int& v ) const */ OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow() { + DBG_FUN(); return new OCCViewer_ViewWindow(0, this); } @@ -1602,6 +1638,7 @@ void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isS */ Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn) { + DBG_FUN(); Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane ); aGraphic3dPlane->SetOn( theIsOn ); aGraphic3dPlane->SetCapping( Standard_True ); @@ -1620,6 +1657,7 @@ Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& theP */ void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList) { + DBG_FUN(); // 1. Remove existing clipping planes myClipPlanes.clear(); myInternalClipPlanes.Clear(); @@ -1690,6 +1728,9 @@ void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) { bool OCCViewer_Viewer::enableDrawMode( bool on ) { + DBG_FUN(); + ARG(on); + //!! To be done for view windows if ( !myViewManager ) return false; diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index 9316db567..d9f28d7c3 100644 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -50,6 +50,12 @@ #undef QT_CLEAN_NAMESPACE #include +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_ViewPort"; +#include "MBDebug.h" +//--------------------------------------------------------- + struct CMapEntry { CMapEntry(); @@ -185,6 +191,7 @@ static Colormap choose_cmap( Display *dpy, XVisualInfo *vi ) OCCViewer_ViewPort::OCCViewer_ViewPort( QWidget* parent ) : QWidget( parent ) { + DBG_FUN(); initialize(); } @@ -193,6 +200,7 @@ OCCViewer_ViewPort::OCCViewer_ViewPort( QWidget* parent ) */ OCCViewer_ViewPort::~OCCViewer_ViewPort() { + DBG_FUN(); cleanup(); } @@ -201,6 +209,7 @@ OCCViewer_ViewPort::~OCCViewer_ViewPort() */ void OCCViewer_ViewPort::initialize() { + DBG_FUN(); myPaintersRedrawing = false; myEnableSketching = true; myEnableTransform = true; @@ -218,6 +227,7 @@ void OCCViewer_ViewPort::initialize() */ void OCCViewer_ViewPort::cleanup() { + DBG_FUN(); } /*! @@ -225,6 +235,7 @@ void OCCViewer_ViewPort::cleanup() */ void OCCViewer_ViewPort::selectVisualId() { + DBG_FUN(); #if !defined WIN32 && !defined __APPLE__ XVisualInfo* pVisualInfo; if ( QX11Info::display() ) @@ -326,6 +337,7 @@ void OCCViewer_ViewPort::selectVisualId() */ void OCCViewer_ViewPort::setBackgroundColor( const QColor& color ) { + DBG_FUN(); QPalette pal = palette(); pal.setColor( QPalette::Background, color ); setPalette( pal ); @@ -354,6 +366,7 @@ bool OCCViewer_ViewPort::isSketchingEnabled() const */ void OCCViewer_ViewPort::setSketchingEnabled( bool enable ) { + DBG_FUN(); myEnableSketching = enable; } @@ -371,6 +384,7 @@ bool OCCViewer_ViewPort::isTransformEnabled() const */ void OCCViewer_ViewPort::setTransformEnabled( bool enable ) { + DBG_FUN(); myEnableTransform = enable; } @@ -474,6 +488,7 @@ bool OCCViewer_ViewPort::synchronize( OCCViewer_ViewPort* ) */ void OCCViewer_ViewPort::onChangeBackground() { + DBG_FUN(); QColor selColor = QColorDialog::getColor ( backgroundColor(), this ); if ( selColor.isValid() ) setBackgroundColor( selColor ); diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 73c60da4f..2410389e6 100644 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -50,6 +50,12 @@ //#include #endif +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_ViewPort3d"; +#include "MBDebug.h" +//--------------------------------------------------------- + static double rx = 0.; static double ry = 0.; static int sx = 0; @@ -67,6 +73,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V myScale( 1.0 ), myIsAdvancedZoomingEnabled( false ) { + DBG_FUN(); // VSR: 01/07/2010 commented to avoid SIGSEGV at SALOME exit //selectVisualId(); @@ -82,6 +89,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V */ OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() { + DBG_FUN(); if ( myCursor ) { delete myCursor; @@ -117,6 +125,7 @@ OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() */ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) { + DBG_FUN(); if ( !setWindow( view ) ) return false; @@ -138,6 +147,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) */ Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view ) { + DBG_FUN(); /* map the new view */ if ( view == activeView() || !mapView( view ) ) return activeView(); @@ -251,6 +261,7 @@ QColor OCCViewer_ViewPort3d::backgroundColor() const */ void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color ) { + DBG_FUN(); Qtx::BackgroundData bg = background(); bg.setColor( color ); setBackground( bg ); @@ -269,6 +280,7 @@ Qtx::BackgroundData OCCViewer_ViewPort3d::background() const */ void OCCViewer_ViewPort3d::setBackground( const Qtx::BackgroundData& bgData ) { + DBG_FUN(); if ( bgData.isValid() ) { myBackground = bgData; updateBackground(); @@ -278,6 +290,7 @@ void OCCViewer_ViewPort3d::setBackground( const Qtx::BackgroundData& bgData ) void OCCViewer_ViewPort3d::updateBackground() { + DBG_FUN(); if ( activeView().IsNull() ) return; if ( !myBackground.isValid() ) return; @@ -378,6 +391,7 @@ void OCCViewer_ViewPort3d::updateBackground() */ void OCCViewer_ViewPort3d::onUpdate() { + DBG_FUN(); if ( !activeView().IsNull() ) activeView()->Update(); } @@ -387,6 +401,7 @@ void OCCViewer_ViewPort3d::onUpdate() */ void OCCViewer_ViewPort3d::fitRect( const QRect& rect ) { + DBG_FUN(); if ( !activeView().IsNull() ) { activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() ); emit vpTransformed( this ); @@ -559,6 +574,7 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e ) */ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e ) { + DBG_FUN(); /* Map before first show to avoid flicker */ if ( !mapped( activeView() ) ) mapView( activeView() ); @@ -581,6 +597,7 @@ void OCCViewer_ViewPort3d::repaintViewAfterMove( ) */ void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool /*withZ*/, bool upd ) { + DBG_FUN(); if ( activeView().IsNull() ) return; @@ -639,6 +656,7 @@ void OCCViewer_ViewPort3d::setAxialScale( double xScale, double yScale, double z */ bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view ) { + DBG_FUN(); if ( !myWindow.IsNull() ) return true; @@ -654,6 +672,7 @@ bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view ) void OCCViewer_ViewPort3d::attachWindow( const Handle(V3d_View)& view, const Handle(Aspect_Window)& window) { + DBG_FUN(); if (!view.IsNull()) { view->SetWindow( window ); updateBackground(); @@ -691,6 +710,7 @@ bool OCCViewer_ViewPort3d::mapped( const Handle(V3d_View)& view ) const */ bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view ) { + DBG_FUN(); bool ok = false; OCCViewer_ViewPort3d* vp3d = qobject_cast( view ); if ( vp3d ) { @@ -748,6 +768,7 @@ QCursor* OCCViewer_ViewPort3d::getDefaultCursor() const */ void OCCViewer_ViewPort3d::setDefaultParams() { + DBG_FUN(); setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background // get ray tracing parameters from preferences diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 94a9f8a08..d3118166d 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -97,6 +97,12 @@ #include "utilities.h" +//--------------------------------------------------------- +#define USE_DEBUG +static const char *dbg_class = "OCCViewer_ViewWindow"; +#include "MBDebug.h" +//--------------------------------------------------------- + // // OpenCV includes // #include // #include @@ -251,6 +257,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel ) : SUIT_ViewWindow( theDesktop ) { + DBG_FUN(); myModel = theModel; myRestoreFlag = 0; myEnableDrawMode = false; @@ -284,6 +291,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, */ OCCViewer_ViewWindow::~OCCViewer_ViewWindow() { + DBG_FUN(); endDrawRect(); qDeleteAll( mySketchers ); } @@ -293,6 +301,7 @@ OCCViewer_ViewWindow::~OCCViewer_ViewWindow() */ void OCCViewer_ViewWindow::initLayout() { + DBG_FUN(); myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC ); myViewPort->installEventFilter(this); setCentralWidget(myViewPort); @@ -444,6 +453,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) */ bool OCCViewer_ViewWindow::enableDrawMode( bool on ) { + DBG_FUN(); bool prev = myDrawRectEnabled; myDrawRectEnabled = on; updateEnabledDrawMode(); @@ -466,6 +476,7 @@ void OCCViewer_ViewWindow::updateEnabledDrawMode() */ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent ) { + DBG_FUN(); myStartX = theEvent->x(); myStartY = theEvent->y(); int anInteractionStyle = interactionStyle(); @@ -688,6 +699,7 @@ void OCCViewer_ViewWindow::activateRotation() */ bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); // Project boundaries points and add to avergae gravity @@ -778,6 +790,7 @@ bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, dou */ void OCCViewer_ViewWindow::activateSetRotationGravity() { + DBG_FUN(); if ( myRotationPointSelection ) { Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); @@ -803,6 +816,7 @@ void OCCViewer_ViewWindow::activateSetRotationGravity() */ void OCCViewer_ViewWindow::updateGravityCoords() { + DBG_FUN(); if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == BBCENTER ) { Standard_Real Xcenter, Ycenter, Zcenter; @@ -898,6 +912,7 @@ void OCCViewer_ViewWindow::activateGlobalPanning() */ void OCCViewer_ViewWindow::activateWindowFit() { + DBG_FUN(); if ( !transformRequested() && !myCursorIsHand ) saveCursor(); /* save old cursor */ @@ -916,6 +931,7 @@ void OCCViewer_ViewWindow::activateWindowFit() */ bool OCCViewer_ViewWindow::setTransformRequested( OperationType op ) { + DBG_FUN(); bool ok = transformEnabled( op ); myOperation = ok ? op : NOVIEWOP; myViewPort->setMouseTracking( myOperation == NOVIEWOP ); @@ -1053,6 +1069,7 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) */ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) { + DBG_FUN(); switch ( myOperation ) { case NOVIEWOP: { @@ -1138,6 +1155,7 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) */ void OCCViewer_ViewWindow::resetState() { + DBG_FUN(); myDrawRect = false; if ( myRotationPointSelection ) @@ -1197,6 +1215,7 @@ void OCCViewer_ViewWindow::endDrawRect() */ void OCCViewer_ViewWindow::createActions() { + DBG_FUN(); if( !toolMgr()->isEmpty() ) return; @@ -1540,6 +1559,7 @@ void OCCViewer_ViewWindow::createActions() */ void OCCViewer_ViewWindow::createToolBar() { + DBG_FUN(); static const char* titles[] = { "LBL_3DTOOLBAR_LABEL", "LBL_XYTOOLBAR_LABEL", @@ -1640,6 +1660,7 @@ void OCCViewer_ViewWindow::createToolBar() */ void OCCViewer_ViewWindow::onViewFitAll() { + DBG_FUN(); myViewPort->fitAll(); } @@ -1648,6 +1669,7 @@ void OCCViewer_ViewWindow::onViewFitAll() */ void OCCViewer_ViewWindow::onFrontView() { + DBG_FUN(); emit vpTransformationStarted ( FRONTVIEW ); Handle(V3d_View) aView3d = myViewPort->getView(); if (myAutomaticZoom) @@ -1666,6 +1688,7 @@ void OCCViewer_ViewWindow::onFrontView() */ void OCCViewer_ViewWindow::onBackView() { + DBG_FUN(); emit vpTransformationStarted ( BACKVIEW ); Handle(V3d_View) aView3d = myViewPort->getView(); if (myAutomaticZoom) @@ -1684,6 +1707,7 @@ void OCCViewer_ViewWindow::onBackView() */ void OCCViewer_ViewWindow::onTopView() { + DBG_FUN(); emit vpTransformationStarted ( TOPVIEW ); Handle(V3d_View) aView3d = myViewPort->getView(); if (myAutomaticZoom) @@ -1702,6 +1726,7 @@ void OCCViewer_ViewWindow::onTopView() */ void OCCViewer_ViewWindow::onBottomView() { + DBG_FUN(); emit vpTransformationStarted ( BOTTOMVIEW ); Handle(V3d_View) aView3d = myViewPort->getView(); if (myAutomaticZoom) @@ -1720,6 +1745,7 @@ void OCCViewer_ViewWindow::onBottomView() */ void OCCViewer_ViewWindow::onLeftView() { + DBG_FUN(); emit vpTransformationStarted ( LEFTVIEW ); Handle(V3d_View) aView3d = myViewPort->getView(); if (myAutomaticZoom) @@ -1738,6 +1764,7 @@ void OCCViewer_ViewWindow::onLeftView() */ void OCCViewer_ViewWindow::onRightView() { + DBG_FUN(); emit vpTransformationStarted ( RIGHTVIEW ); Handle(V3d_View) aView3d = myViewPort->getView(); if (myAutomaticZoom) @@ -1756,6 +1783,7 @@ void OCCViewer_ViewWindow::onRightView() */ void OCCViewer_ViewWindow::onClockWiseView() { + DBG_FUN(); emit vpTransformationStarted ( CLOCKWISEVIEW ); myViewPort->rotateXY( 90. ); emit vpTransformationFinished ( CLOCKWISEVIEW ); @@ -1766,6 +1794,7 @@ void OCCViewer_ViewWindow::onClockWiseView() */ void OCCViewer_ViewWindow::onAntiClockWiseView() { + DBG_FUN(); emit vpTransformationStarted ( ANTICLOCKWISEVIEW ); myViewPort->rotateXY( -90. ); emit vpTransformationFinished ( ANTICLOCKWISEVIEW ); @@ -1778,6 +1807,7 @@ void OCCViewer_ViewWindow::onAntiClockWiseView() */ void OCCViewer_ViewWindow::onResetView() { + DBG_FUN(); emit vpTransformationStarted( RESETVIEW ); bool upd = myViewPort->getView()->SetImmediateUpdate( false ); myViewPort->getView()->Reset( false ); @@ -1795,6 +1825,7 @@ void OCCViewer_ViewWindow::onResetView() */ void OCCViewer_ViewWindow::onProjectionType( QAction* theAction ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); @@ -1824,6 +1855,7 @@ void OCCViewer_ViewWindow::onProjectionType( QAction* theAction ) */ void OCCViewer_ViewWindow::onStereoType( bool activate ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); @@ -1867,6 +1899,7 @@ void OCCViewer_ViewWindow::onStereoType( bool activate ) */ void OCCViewer_ViewWindow::onProjectionType() { + DBG_FUN(); emit vpTransformationStarted( PROJECTION ); if (toolMgr()->action( OrthographicId )->isChecked()) setProjectionType( Orthographic ); @@ -1879,6 +1912,7 @@ void OCCViewer_ViewWindow::onProjectionType() void OCCViewer_ViewWindow::setProjectionType( int mode ) { + DBG_FUN(); QtxAction* anOrthographicAction = dynamic_cast( toolMgr()->action( OrthographicId ) ); QtxAction* aPerspectiveAction = dynamic_cast( toolMgr()->action( PerspectiveId ) ); QtxAction* aStereoAction = dynamic_cast( toolMgr()->action( StereoId ) ); @@ -1941,6 +1975,7 @@ void OCCViewer_ViewWindow::setProjectionType( int mode ) */ void OCCViewer_ViewWindow::onFitAll() { + DBG_FUN(); emit vpTransformationStarted( FITALLVIEW ); if (myModel->fitter()) myModel->fitter()->fitAll(myViewPort->getView()); @@ -1954,6 +1989,7 @@ void OCCViewer_ViewWindow::onFitAll() */ void OCCViewer_ViewWindow::onFitSelection() { + DBG_FUN(); emit vpTransformationStarted( FITSELECTION ); myModel->getAISContext()->FitSelected( getViewPort()->getView() ); emit vpTransformationFinished( FITSELECTION ); @@ -1965,6 +2001,7 @@ void OCCViewer_ViewWindow::onFitSelection() */ void OCCViewer_ViewWindow::onSetRotationPoint( bool on ) { + DBG_FUN(); if (on) { if (!mySetRotationPointDlg) @@ -1997,6 +2034,7 @@ void OCCViewer_ViewWindow::onSetRotationPoint( bool on ) */ void OCCViewer_ViewWindow::onCloneView() { + DBG_FUN(); SUIT_ViewWindow* vw = myManager->createViewWindow(); //vw->show(); emit viewCloned( vw ); @@ -2011,6 +2049,7 @@ void OCCViewer_ViewWindow::onCloneView() */ void OCCViewer_ViewWindow::onAxialScale() { + DBG_FUN(); if ( !myScalingDlg ) myScalingDlg = new OCCViewer_AxialScaleDlg( this , myModel ); @@ -2026,12 +2065,14 @@ void OCCViewer_ViewWindow::onAxialScale() */ void OCCViewer_ViewWindow::onGraduatedAxes() { + DBG_FUN(); myCubeAxesDlg->Update(); myCubeAxesDlg->show(); } void OCCViewer_ViewWindow::onAmbientToogle() { + DBG_FUN(); Handle(V3d_Viewer) viewer = myViewPort->getViewer(); viewer->InitDefinedLights(); while(viewer->MoreDefinedLights()) @@ -2053,6 +2094,7 @@ void OCCViewer_ViewWindow::onAmbientToogle() */ void OCCViewer_ViewWindow::onMemorizeView() { + DBG_FUN(); appendViewAspect( getViewParams() ); } @@ -2061,6 +2103,7 @@ void OCCViewer_ViewWindow::onMemorizeView() */ void OCCViewer_ViewWindow::onRestoreView() { + DBG_FUN(); OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), this ); connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) ); aDlg->exec(); @@ -2075,6 +2118,7 @@ void OCCViewer_ViewWindow::onRestoreView() */ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False ); @@ -2171,6 +2215,7 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base */ void OCCViewer_ViewWindow::setRestoreFlag() { + DBG_FUN(); myRestoreFlag = 1; } @@ -2179,6 +2224,7 @@ void OCCViewer_ViewWindow::setRestoreFlag() */ void OCCViewer_ViewWindow::onTrihedronShow(bool show) { + DBG_FUN(); myModel->setTrihedronShown(show); } @@ -2195,6 +2241,7 @@ void OCCViewer_ViewWindow::onViewCubeShow(bool show) */ void OCCViewer_ViewWindow::onSwitchPreselection( bool on ) { + DBG_FUN(); myPreselectionEnabled = on; myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() ); @@ -2215,6 +2262,7 @@ void OCCViewer_ViewWindow::onSwitchPreselection( bool on ) */ void OCCViewer_ViewWindow::onSwitchSelection( bool on ) { + DBG_FUN(); mySelectionEnabled = on; myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() ); @@ -2239,6 +2287,7 @@ void OCCViewer_ViewWindow::onSwitchSelection( bool on ) void OCCViewer_ViewWindow::onSwitchSelectionStyle(QAction* theAction) { // selection + DBG_FUN(); OCCViewer_ViewSketcher* aSkecher = getSketcher(Polygon); if (aSkecher) { if (theAction == toolMgr()->action(PolygonSelectionStyleId)) { @@ -2264,6 +2313,7 @@ OCCViewer_ViewWindow::SelectionStyle OCCViewer_ViewWindow::selectionStyle() cons void OCCViewer_ViewWindow::setSelectionStyle(SelectionStyle theMode) { + DBG_FUN(); toolMgr()->action(RectangleSelectionStyleId)->setChecked(false); toolMgr()->action(PolygonSelectionStyleId)->setChecked(false); toolMgr()->action(CircleSelectionStyleId)->setChecked(false); @@ -2284,6 +2334,7 @@ void OCCViewer_ViewWindow::setSelectionStyle(SelectionStyle theMode) */ void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on ) { + DBG_FUN(); myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD; // update action state if method is called outside @@ -2297,6 +2348,7 @@ void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on ) */ void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on ) { + DBG_FUN(); myViewPort->setAdvancedZoomingEnabled( on ); // update action state if method is called outside @@ -2320,6 +2372,7 @@ int OCCViewer_ViewWindow::interactionStyle() const */ void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle ) { + DBG_FUN(); onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE ); } @@ -2338,6 +2391,7 @@ int OCCViewer_ViewWindow::zoomingStyle() const */ void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle ) { + DBG_FUN(); onSwitchZoomingStyle( theStyle == 1 ); } @@ -2348,6 +2402,7 @@ void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle ) //#define USE_OLD_IMPLEMENTATION QImage OCCViewer_ViewWindow::dumpView() { + DBG_FUN(); Handle(V3d_View) view = myViewPort->getView(); if ( view.IsNull() ) return QImage(); @@ -2428,6 +2483,7 @@ bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& /*img*/, const QString& fileName, const QString& /*format*/ ) { + DBG_FUN(); bool res = false; QApplication::setOverrideCursor( Qt::WaitCursor ); @@ -2459,6 +2515,7 @@ QString OCCViewer_ViewWindow::filter() const void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const double y, const double z, const double dx, const double dy, const double dz ) { + DBG_FUN(); Handle(V3d_View) view = myViewPort->getView(); if ( view.IsNull() ) return; @@ -2498,6 +2555,7 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const doub void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln ) { + DBG_FUN(); gp_Dir aDir = pln.Axis().Direction(); gp_Pnt aPnt = pln.Location(); setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z()); @@ -2798,6 +2856,7 @@ QString OCCViewer_ViewWindow::getVisualParameters() */ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) { + DBG_FUN(); viewAspect params; ClipPlanesList aClipPlanes; QStringList data = parameters.split( '*' ); @@ -3025,6 +3084,7 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) */ void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent ) { + DBG_FUN(); emit Show( theEvent ); } @@ -3037,6 +3097,7 @@ void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent ) */ void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent ) { + DBG_FUN(); emit Hide( theEvent ); } @@ -3046,6 +3107,7 @@ void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent ) */ void OCCViewer_ViewWindow::saveCursor() { + DBG_FUN(); QCursor* aCursor = NULL; if ( myViewPort ) aCursor = myViewPort->getDefaultCursor(); @@ -3058,6 +3120,7 @@ void OCCViewer_ViewWindow::saveCursor() */ OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type ) { + DBG_FUN(); if ( type == Rect ) return new OCCViewer_RectSketcher( this, type ); if ( type == Polygon ) @@ -3067,6 +3130,7 @@ OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type ) void OCCViewer_ViewWindow::initSketchers() { + DBG_FUN(); if ( mySketchers.isEmpty() ) { mySketchers.append( createSketcher( Rect ) ); @@ -3092,6 +3156,7 @@ OCCViewer_ViewSketcher* OCCViewer_ViewWindow::getSketcher( const int typ ) const */ void OCCViewer_ViewWindow::activateSketching( int type ) { + DBG_FUN(); OCCViewer_ViewPort3d* vp = getViewPort(); if ( !vp ) return; @@ -3127,6 +3192,7 @@ void OCCViewer_ViewWindow::activateSketching( int type ) */ void OCCViewer_ViewWindow::onSketchingStarted() { + DBG_FUN(); } /*! @@ -3134,6 +3200,7 @@ void OCCViewer_ViewWindow::onSketchingStarted() */ void OCCViewer_ViewWindow::onSketchingFinished() { + DBG_FUN(); MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()"); if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept ) { @@ -3208,6 +3275,7 @@ bool OCCViewer_ViewWindow::transformInProcess() const void OCCViewer_ViewWindow::setTransformInProcess( bool bOn ) { + DBG_FUN(); myEventStarted = bOn; } @@ -3216,6 +3284,7 @@ void OCCViewer_ViewWindow::setTransformInProcess( bool bOn ) */ void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on ) { + DBG_FUN(); if ( id != NOVIEWOP ) myStatus.insert( id, on ); } @@ -3229,16 +3298,19 @@ bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const void OCCViewer_ViewWindow::onMaximizedView() { + DBG_FUN(); setMaximized(!isMaximized()); } void OCCViewer_ViewWindow::returnTo3dView() { + DBG_FUN(); setReturnedTo3dView( true ); } void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView) { + DBG_FUN(); if ( !toolMgr()->action( ReturnTo3dViewId ) || toolMgr()->isShown(ReturnTo3dViewId) != isVisible3dView ) return; if ( !isVisible3dView ) @@ -3251,6 +3323,7 @@ void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView) void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) { + DBG_FUN(); QAction* anAction = toolMgr()->action( MaximizedId ); QAction* anAction2 = toolMgr()->action( ReturnTo3dViewId ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -3283,6 +3356,7 @@ bool OCCViewer_ViewWindow::isMaximized() const void OCCViewer_ViewWindow::setSketcherStyle( bool enable ) { + DBG_FUN(); IsSketcherStyle = enable; } @@ -3294,6 +3368,7 @@ bool OCCViewer_ViewWindow::isSketcherStyle() const void OCCViewer_ViewWindow::set2dMode(Mode2dType theType) { + DBG_FUN(); my2dMode = theType; } @@ -3315,6 +3390,7 @@ int OCCViewer_ViewWindow::projectionType() const void OCCViewer_ViewWindow::setStereoType( int type ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); @@ -3335,6 +3411,7 @@ int OCCViewer_ViewWindow::stereoType() const void OCCViewer_ViewWindow::setAnaglyphFilter( int type ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); @@ -3365,6 +3442,7 @@ int OCCViewer_ViewWindow::anaglyphFilter() const void OCCViewer_ViewWindow::setStereographicFocus( int type, double value ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); @@ -3396,6 +3474,7 @@ double OCCViewer_ViewWindow::stereographicFocusValue() const void OCCViewer_ViewWindow::setInterocularDistance( int type, double value ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); @@ -3427,6 +3506,7 @@ double OCCViewer_ViewWindow::interocularDistanceValue() const void OCCViewer_ViewWindow::setReverseStereo( bool reverse ) { + DBG_FUN(); Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); @@ -3447,6 +3527,7 @@ bool OCCViewer_ViewWindow::isReverseStereo() const void OCCViewer_ViewWindow::setVSync( bool enable ) { + DBG_FUN(); Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); if ( !anIntCont.IsNull() ) { Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); @@ -3469,6 +3550,7 @@ bool OCCViewer_ViewWindow::isVSync() const void OCCViewer_ViewWindow::setQuadBufferSupport( bool enable ) { + DBG_FUN(); Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); if ( !anIntCont.IsNull() ) { Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); @@ -3507,6 +3589,7 @@ QColor OCCViewer_ViewWindow::backgroundColor() const // obsolete void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor ) { + DBG_FUN(); if ( myViewPort ) myViewPort->setBackgroundColor( theColor ); } @@ -3517,11 +3600,13 @@ Qtx::BackgroundData OCCViewer_ViewWindow::background() const void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground ) { + DBG_FUN(); if ( myViewPort ) myViewPort->setBackground( theBackground ); } void OCCViewer_ViewWindow::showStaticTrihedron( bool on ) { + DBG_FUN(); if ( myViewPort ) myViewPort->showStaticTrihedron( on ); } @@ -3530,6 +3615,7 @@ void OCCViewer_ViewWindow::showStaticTrihedron( bool on ) */ void OCCViewer_ViewWindow::clearViewAspects() { + DBG_FUN(); myViewAspects.clear(); } @@ -3547,6 +3633,7 @@ const viewAspectList& OCCViewer_ViewWindow::getViewAspects() */ void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams ) { + DBG_FUN(); myViewAspects.append( aParams ); } @@ -3556,6 +3643,7 @@ void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams ) */ void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList ) { + DBG_FUN(); myViewAspects = aViewList; } @@ -3565,6 +3653,7 @@ void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList ) */ SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties() { + DBG_FUN(); SUIT_CameraProperties aProps; Handle(V3d_View) aSourceView = getViewPort()->getView(); @@ -3622,6 +3711,7 @@ SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties() */ void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView ) { + DBG_FUN(); bool blocked = blockSignals( true ); SUIT_CameraProperties aProps = theView->cameraProperties(); @@ -3678,6 +3768,7 @@ bool OCCViewer_ViewWindow::isPreselectionEnabled() const */ void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable ) { + DBG_FUN(); onSwitchPreselection( theIsToEnable ); } @@ -3696,6 +3787,7 @@ bool OCCViewer_ViewWindow::isSelectionEnabled() const */ void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable ) { + DBG_FUN(); onSwitchSelection( theIsToEnable ); } @@ -3709,6 +3801,7 @@ void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable ) */ void OCCViewer_ViewWindow::onClipping (bool theIsOn) { + DBG_FUN(); if(!myModel) return; OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg(); @@ -3747,6 +3840,7 @@ void OCCViewer_ViewWindow::onClipping (bool theIsOn) void OCCViewer_ViewWindow::onRayTracing() { + DBG_FUN(); if( !OCCViewer_Utilities::isDialogOpened( this, OCCViewer_RayTracingDlg::getName() ) ) { QDialog* aDlg = new OCCViewer_RayTracingDlg( this ); if ( aDlg != NULL ) @@ -3756,6 +3850,7 @@ void OCCViewer_ViewWindow::onRayTracing() void OCCViewer_ViewWindow::onEnvTexture() { + DBG_FUN(); if( !OCCViewer_Utilities::isDialogOpened( this, OCCViewer_EnvTextureDlg::getName() ) ) { QDialog* aDlg = new OCCViewer_EnvTextureDlg( this ); if ( aDlg != NULL ) @@ -3765,6 +3860,7 @@ void OCCViewer_ViewWindow::onEnvTexture() void OCCViewer_ViewWindow::onLightSource() { + DBG_FUN(); if( !OCCViewer_Utilities::isDialogOpened( this, OCCViewer_LightSourceDlg::getName() ) ) { QDialog* aDlg = new OCCViewer_LightSourceDlg( this, myModel ); if ( aDlg != NULL ) @@ -3780,6 +3876,7 @@ bool OCCViewer_ViewWindow::isActionVisible( ActionId theId ) const void OCCViewer_ViewWindow::setActionVisible( ActionId theId, bool isVisible ) { + DBG_FUN(); QAction* a = toolMgr()->action( theId ); if( a ) a->setVisible( isVisible ); @@ -3787,6 +3884,7 @@ void OCCViewer_ViewWindow::setActionVisible( ActionId theId, bool isVisible ) void OCCViewer_ViewWindow::projAndPanToGravity(V3d_TypeOfOrientation CamOri) { + DBG_FUN(); const bool USE_XY = true; Handle(V3d_View) aView3d = myViewPort->getView(); @@ -3849,6 +3947,7 @@ bool OCCViewer_ViewWindow::isAutomaticZoom() const void OCCViewer_ViewWindow::setAutomaticZoom(const bool isOn) { + DBG_FUN(); myAutomaticZoom = isOn; } diff --git a/src/Prs/MBDebug.h b/src/Prs/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/Prs/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/Prs/SALOME_Prs.cxx b/src/Prs/SALOME_Prs.cxx index 15385f346..ce77426f5 100644 --- a/src/Prs/SALOME_Prs.cxx +++ b/src/Prs/SALOME_Prs.cxx @@ -25,12 +25,21 @@ #include "SALOME_Prs.h" +//--------------------------------------------------------- +#define USE_DEBUG +#define MB_IGNORE_QT +#define MBCLASSNAME "SALOME_Prs" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ SALOME_Prs::SALOME_Prs(const char* e) : myIsClippable(true) { myEntry = std::string( e ? e : "" ); + DBG_FUN(); + ARG(myEntry); } /*! @@ -49,11 +58,13 @@ void SALOME_Prs::LocalSelectionIn( SALOME_View*, const std::list ) const // base implementation does nothing } +#define MBCLASSNAME "SALOME_OCCPrs" /*! Dispatches display operation to proper Display() method of SALOME_View */ void SALOME_OCCPrs::DisplayIn( SALOME_View* v ) const { + DBG_FUN(); if ( v ) v->Display( this ); } @@ -62,6 +73,7 @@ void SALOME_OCCPrs::DisplayIn( SALOME_View* v ) const */ void SALOME_OCCPrs::EraseIn( SALOME_View* v, const bool forced ) const { + DBG_FUN(); if ( v ) v->Erase( this, forced ); } @@ -70,6 +82,7 @@ void SALOME_OCCPrs::EraseIn( SALOME_View* v, const bool forced ) const */ void SALOME_OCCPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->BeforeDisplay( v, this ); } @@ -78,6 +91,7 @@ void SALOME_OCCPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_OCCPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->AfterDisplay( v, this ); } @@ -86,6 +100,7 @@ void SALOME_OCCPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_OCCPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->BeforeErase( v, this ); } @@ -94,6 +109,7 @@ void SALOME_OCCPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_OCCPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->AfterErase( v, this ); } @@ -102,6 +118,7 @@ void SALOME_OCCPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const { + DBG_FUN(); std::list modes; modes.push_back( mode ); LocalSelectionIn( v, modes ); @@ -112,6 +129,7 @@ void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const */ void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const std::list modes ) const { + DBG_FUN(); if ( v && !modes.empty() ) v->LocalSelection( this, modes ); } @@ -120,14 +138,17 @@ void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const std::list modes */ void SALOME_OCCPrs::Update( SALOME_Displayer* d ) { + DBG_FUN(); if ( d ) d->Update( this ); } +#define MBCLASSNAME "SALOME_VTKPrs" /*! Dispatches display operation to proper Display() method of SALOME_View */ void SALOME_VTKPrs::DisplayIn( SALOME_View* v ) const { + DBG_FUN(); if ( v ) v->Display( this ); } @@ -136,6 +157,7 @@ void SALOME_VTKPrs::DisplayIn( SALOME_View* v ) const */ void SALOME_VTKPrs::EraseIn( SALOME_View* v, const bool forced ) const { + DBG_FUN(); if ( v ) v->Erase( this, forced ); } @@ -144,6 +166,7 @@ void SALOME_VTKPrs::EraseIn( SALOME_View* v, const bool forced ) const */ void SALOME_VTKPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->BeforeDisplay( v, this ); } @@ -152,6 +175,7 @@ void SALOME_VTKPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_VTKPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->AfterDisplay( v, this ); } @@ -160,6 +184,7 @@ void SALOME_VTKPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_VTKPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->BeforeErase( v, this ); } @@ -168,6 +193,7 @@ void SALOME_VTKPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_VTKPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->AfterErase( v, this ); } @@ -176,6 +202,7 @@ void SALOME_VTKPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_VTKPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const { + DBG_FUN(); if ( v ) v->LocalSelection( this, mode ); } @@ -184,14 +211,17 @@ void SALOME_VTKPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const */ void SALOME_VTKPrs::Update( SALOME_Displayer* d ) { + DBG_FUN(); if ( d ) d->Update( this ); } +#define MBCLASSNAME "SALOME_Prs2d" /*! Dispatches display operation to proper Display() method of SALOME_View */ void SALOME_Prs2d::DisplayIn( SALOME_View* v ) const { + DBG_FUN(); if ( v ) v->Display( this ); } @@ -200,6 +230,7 @@ void SALOME_Prs2d::DisplayIn( SALOME_View* v ) const */ void SALOME_Prs2d::EraseIn( SALOME_View* v, const bool forced ) const { + DBG_FUN(); if ( v ) v->Erase( this, forced ); } @@ -208,6 +239,7 @@ void SALOME_Prs2d::EraseIn( SALOME_View* v, const bool forced ) const */ void SALOME_Prs2d::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->BeforeDisplay( v, this ); } @@ -216,6 +248,7 @@ void SALOME_Prs2d::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_Prs2d::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->AfterDisplay( v, this ); } @@ -224,6 +257,7 @@ void SALOME_Prs2d::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_Prs2d::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->BeforeErase( v, this ); } @@ -232,6 +266,7 @@ void SALOME_Prs2d::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_Prs2d::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const { + DBG_FUN(); d->AfterErase( v, this ); } @@ -240,6 +275,7 @@ void SALOME_Prs2d::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const */ void SALOME_Prs2d::LocalSelectionIn( SALOME_View* v, const int mode ) const { + DBG_FUN(); if ( v ) v->LocalSelection( this, mode ); } @@ -248,14 +284,17 @@ void SALOME_Prs2d::LocalSelectionIn( SALOME_View* v, const int mode ) const */ void SALOME_Prs2d::Update( SALOME_Displayer* d ) { + DBG_FUN(); if ( d ) d->Update( this ); } +#define MBCLASSNAME "SALOME_View" /*! Gives control to SALOME_Prs object, so that it could perform double dispatch */ void SALOME_View::Display( SALOME_Displayer* d, const SALOME_Prs* prs ) { + DBG_FUN(); prs->DisplayIn( this ); if ( d ) d->UpdateVisibility( this, prs, true ); } @@ -265,6 +304,7 @@ void SALOME_View::Display( SALOME_Displayer* d, const SALOME_Prs* prs ) */ void SALOME_View::Erase( SALOME_Displayer* d, const SALOME_Prs* prs, const bool forced ) { + DBG_FUN(); prs->EraseIn( this, forced ); if ( d ) d->UpdateVisibility( this, prs, false ); } @@ -274,6 +314,7 @@ void SALOME_View::Erase( SALOME_Displayer* d, const SALOME_Prs* prs, const bool */ void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode ) { + DBG_FUN(); std::list modes; modes.push_back( mode ); LocalSelection( prs, modes ); @@ -284,6 +325,7 @@ void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode ) */ void SALOME_View::LocalSelection( const SALOME_Prs* prs, const std::list modes ) { + DBG_FUN(); prs->LocalSelectionIn( this, modes ); } @@ -292,6 +334,7 @@ void SALOME_View::LocalSelection( const SALOME_Prs* prs, const std::list mo */ void SALOME_View::Display( const SALOME_OCCPrs* ) { + MSGEL("...SALOME_View::Display(SALOME_OCCPrs)"); // MESSAGE( "SALOME_View::Display( const SALOME_OCCPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } @@ -300,6 +343,7 @@ void SALOME_View::Display( const SALOME_OCCPrs* ) */ void SALOME_View::Display( const SALOME_VTKPrs* ) { + MSGEL("...SALOME_View::Display(SALOME_VTKPrs)"); // MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } @@ -308,6 +352,7 @@ void SALOME_View::Display( const SALOME_VTKPrs* ) */ void SALOME_View::Display( const SALOME_Prs2d* ) { + MSGEL("...SALOME_View::Display(SALOME_Prs2d)"); // MESSAGE( "SALOME_View::Display( const SALOME_Prs2d& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } @@ -316,6 +361,7 @@ void SALOME_View::Display( const SALOME_Prs2d* ) */ void SALOME_View::Erase( const SALOME_OCCPrs*, const bool ) { + MSGEL("...SALOME_View::Erase(SALOME_OCCPrs,bool)"); // MESSAGE( "SALOME_View::Erase( const SALOME_OCCPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } @@ -324,6 +370,7 @@ void SALOME_View::Erase( const SALOME_OCCPrs*, const bool ) */ void SALOME_View::Erase( const SALOME_VTKPrs*, const bool ) { + MSGEL("...SALOME_View::Erase(SALOME_VTKPrs,bool)"); // MESSAGE( "SALOME_View::Erase( const SALOME_VTKPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } @@ -332,6 +379,7 @@ void SALOME_View::Erase( const SALOME_VTKPrs*, const bool ) */ void SALOME_View::Erase( const SALOME_Prs2d*, const bool ) { + MSGEL("...SALOME_View::Erase(SALOME_Prs2d,bool)"); // MESSAGE( "SALOME_View::Erase( const SALOME_Prs2d& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } @@ -340,6 +388,7 @@ void SALOME_View::Erase( const SALOME_Prs2d*, const bool ) */ void SALOME_View::EraseAll( SALOME_Displayer* d, const bool ) { + DBG_FUN(); // MESSAGE( "SALOME_View::EraseAll() called!" ); if ( d ) d->UpdateVisibility( this, 0, false ); } @@ -349,6 +398,7 @@ void SALOME_View::EraseAll( SALOME_Displayer* d, const bool ) */ void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int ) { + MSGEL("...SALOME_View::LocalSelection(SALOME_OCCPrs,int)"); // MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called! // Probably, selection is being activated in uncompatible viewframe." ); } @@ -358,6 +408,7 @@ void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int ) */ void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const std::list ) { + MSGEL("...SALOME_View::LocalSelection(SALOME_OCCPrs,list)"); // MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called! // Probably, selection is being activated in uncompatible viewframe." ); } @@ -367,6 +418,7 @@ void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const std::list ) */ void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int ) { + MSGEL("...SALOME_View::LocalSelection(SALOME_VTKPrs,int)"); // MESSAGE( "SALOME_View::LocalSelection( const SALOME_VTKPrs* ) called! // Probably, selection is being activated in uncompatible viewframe." ); } @@ -376,6 +428,7 @@ void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int ) */ void SALOME_View::LocalSelection( const SALOME_Prs2d*, const int ) { + MSGEL("...SALOME_View::LocalSelection(SALOME_Prs2d,int)"); // MESSAGE( "SALOME_View::LocalSelection( const SALOME_Prs2d* ) called! // Probably, selection is being activated in uncompatible viewframe." ); } @@ -385,35 +438,42 @@ void SALOME_View::LocalSelection( const SALOME_Prs2d*, const int ) */ void SALOME_View::GlobalSelection( const bool ) const { + MSGEL("...SALOME_View::GlobalSelection(bool)"); // MESSAGE( "SALOME_View::GlobalSelection() called! // Probably, selection is being activated in uncompatible viewframe." ); } void SALOME_View::BeforeDisplay( SALOME_Displayer* d, const SALOME_Prs* p ) { + DBG_FUN(); p->BeforeDisplayIn( d, this ); } void SALOME_View::AfterDisplay( SALOME_Displayer* d, const SALOME_Prs* p ) { + DBG_FUN(); p->AfterDisplayIn( d, this ); } void SALOME_View::BeforeErase( SALOME_Displayer* d, const SALOME_Prs* p ) { + DBG_FUN(); p->BeforeEraseIn( d, this ); } void SALOME_View::AfterErase ( SALOME_Displayer* d, const SALOME_Prs* p ) { + DBG_FUN(); p->AfterEraseIn( d, this ); } +#define MBCLASSNAME "SALOME_Displayer" /*! Gives control to SALOME_Prs object, so that it could perform double dispatch */ void SALOME_Displayer::UpdatePrs( SALOME_Prs* prs ) { + DBG_FUN(); prs->Update( this ); } @@ -422,6 +482,7 @@ void SALOME_Displayer::UpdatePrs( SALOME_Prs* prs ) */ void SALOME_Displayer::Update( SALOME_OCCPrs* ) { + MSGEL("...SALOME_Displayer::Update(SALOME_OCCPrs)"); // MESSAGE( "SALOME_Displayer::Update( SALOME_OCCPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } @@ -430,6 +491,7 @@ void SALOME_Displayer::Update( SALOME_OCCPrs* ) */ void SALOME_Displayer::Update( SALOME_VTKPrs* ) { + MSGEL("...SALOME_Displayer::Update(SALOME_VTKPrs)"); // MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } @@ -438,6 +500,7 @@ void SALOME_Displayer::Update( SALOME_VTKPrs* ) */ void SALOME_Displayer::Update( SALOME_Prs2d* ) { + MSGEL("...SALOME_Displayer::Update(SALOME_Prs2d)"); // MESSAGE( "SALOME_Displayer::Update( SALOME_Prs2d* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } @@ -446,4 +509,5 @@ void SALOME_Displayer::Update( SALOME_Prs2d* ) */ void SALOME_Displayer::UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool ) { + MSGEL("...SALOME_Displayer::UpdateVisibility(SALOME_View,SALOME_Prs,bool)"); } diff --git a/src/SOCC/MBDebug.h b/src/SOCC/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/SOCC/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/SOCC/SOCC_Prs.cxx b/src/SOCC/SOCC_Prs.cxx index bc8004f36..bc70a8ac0 100644 --- a/src/SOCC/SOCC_Prs.cxx +++ b/src/SOCC/SOCC_Prs.cxx @@ -28,12 +28,20 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SOCC_Prs" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Default constructor */ SOCC_Prs::SOCC_Prs( const char* entry ) : SALOME_OCCPrs( entry ) { + DBG_FUN(); + ARG(entry); myToActivate = true; } @@ -43,6 +51,8 @@ SOCC_Prs::SOCC_Prs( const char* entry ) SOCC_Prs::SOCC_Prs( const char* entry, const Handle(AIS_InteractiveObject)& obj ) : SALOME_OCCPrs( entry ) { + DBG_FUN(); + ARG(entry); AddObject( obj ); } @@ -51,6 +61,7 @@ SOCC_Prs::SOCC_Prs( const char* entry, const Handle(AIS_InteractiveObject)& obj */ SOCC_Prs::~SOCC_Prs() { + DBG_FUN(); myObjects.Clear(); } @@ -67,6 +78,7 @@ void SOCC_Prs::GetObjects( AIS_ListOfInteractive& list ) const */ void SOCC_Prs::AddObject( const Handle(AIS_InteractiveObject)& obj ) { + DBG_FUN(); myObjects.Append( obj ); } @@ -75,6 +87,7 @@ void SOCC_Prs::AddObject( const Handle(AIS_InteractiveObject)& obj ) */ void SOCC_Prs::PrependObject( const Handle(AIS_InteractiveObject)& obj ) { + DBG_FUN(); myObjects.Prepend( obj ); } @@ -83,6 +96,7 @@ void SOCC_Prs::PrependObject( const Handle(AIS_InteractiveObject)& obj ) */ void SOCC_Prs::RemoveFirst() { + DBG_FUN(); myObjects.RemoveFirst(); } @@ -91,6 +105,7 @@ void SOCC_Prs::RemoveFirst() */ void SOCC_Prs::Clear() { + DBG_FUN(); myObjects.Clear(); } diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 5c2c59802..772324fa7 100644 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -49,6 +49,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SOCC_Viewer" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor \param DisplayTrihedron - is trihedron displayed @@ -56,6 +62,7 @@ SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron ) : OCCViewer_Viewer( DisplayTrihedron ) { + DBG_FUN(); } /*! @@ -63,6 +70,7 @@ SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron ) */ SOCC_Viewer::~SOCC_Viewer() { + DBG_FUN(); } /*! @@ -152,6 +160,7 @@ bool SOCC_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& obj ) void SOCC_Viewer::setColor( const Handle(SALOME_InteractiveObject)& obj, const QColor& color, bool update ) { + DBG_FUN(); if(obj.IsNull() || !obj->hasEntry() ) return; @@ -178,6 +187,7 @@ void SOCC_Viewer::setColor( const Handle(SALOME_InteractiveObject)& obj, void SOCC_Viewer::switchRepresentation( const Handle(SALOME_InteractiveObject)& obj, int mode, bool update ) { + DBG_FUN(); if(obj.IsNull() || !obj->hasEntry() ) return; @@ -204,6 +214,7 @@ void SOCC_Viewer::switchRepresentation( const Handle(SALOME_InteractiveObject)& void SOCC_Viewer::setTransparency( const Handle(SALOME_InteractiveObject)& obj, float trans, bool update ) { + DBG_FUN(); if(obj.IsNull() || !obj->hasEntry() ) return; @@ -229,6 +240,7 @@ void SOCC_Viewer::setTransparency( const Handle(SALOME_InteractiveObject)& obj, void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj, const QString& name ) { + DBG_FUN(); AIS_ListOfInteractive List; getAISContext()->DisplayedObjects(List); @@ -266,6 +278,7 @@ void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj, */ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) { + DBG_FUN(); // try do downcast object const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); if ( !anOCCPrs || anOCCPrs->IsNull() ) @@ -365,6 +378,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) */ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool /*forced*/ ) { + DBG_FUN(); // try do downcast object const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); if ( !anOCCPrs || anOCCPrs->IsNull() ) @@ -408,6 +422,7 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool /*forced*/ ) */ void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) { + DBG_FUN(); // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -455,6 +470,8 @@ void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) */ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) { + DBG_FUN(); + ARG(entry); SOCC_Prs* prs = new SOCC_Prs(entry); if ( entry ) { @@ -483,6 +500,7 @@ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) */ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const std::list modes ) { + DBG_FUN(); Handle(AIS_InteractiveContext) ic = getAISContext(); const SOCC_Prs* anOCCPrs = dynamic_cast( thePrs ); @@ -537,6 +555,7 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const std::list modes; modes.push_back( theMode ); LocalSelection( thePrs, modes ); @@ -547,6 +566,7 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode */ void SOCC_Viewer::GlobalSelection( const bool update ) const { + DBG_FUN(); Handle(AIS_InteractiveContext) ic = getAISContext(); if ( !ic.IsNull() ) { @@ -604,5 +624,6 @@ void SOCC_Viewer::Repaint() */ OCCViewer_ViewWindow* SOCC_Viewer::createSubWindow() { + DBG_FUN(); return new SOCC_ViewWindow( 0, this); } diff --git a/src/SOCC/SOCC_ViewWindow.cxx b/src/SOCC/SOCC_ViewWindow.cxx index b3ce040a8..42fc34ddf 100644 --- a/src/SOCC/SOCC_ViewWindow.cxx +++ b/src/SOCC/SOCC_ViewWindow.cxx @@ -26,6 +26,12 @@ #include "SUIT_Accel.h" +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SOCC_ViewWindow" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ @@ -34,6 +40,7 @@ SOCC_ViewWindow OCCViewer_Viewer* theModel) : OCCViewer_ViewWindow( theDesktop, theModel ) { + DBG_FUN(); } /*! @@ -42,6 +49,7 @@ SOCC_ViewWindow SOCC_ViewWindow ::~SOCC_ViewWindow() { + DBG_FUN(); } /*! @@ -52,6 +60,7 @@ bool SOCC_ViewWindow ::action( const int theAction ) { + MSGEL("...SOCC_ViewWindow::action(" << theAction << ")"); const int inc = 10; int cx = 0, cy = 0; if ( theAction == SUIT_Accel::ZoomIn || theAction == SUIT_Accel::ZoomOut || diff --git a/src/SUIT/MBDebug.h b/src/SUIT/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/SUIT/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/SUIT/MBSUIT.h b/src/SUIT/MBSUIT.h new file mode 100644 index 000000000..25e331eeb --- /dev/null +++ b/src/SUIT/MBSUIT.h @@ -0,0 +1,18 @@ +#ifndef MBSUIT_H +#define MBSUIT_H + +#include "SUIT_DataObject.h" + + +//========================================================================== +static void DumpVar(const char *szName, const SUIT_DataObject *value) { + if (value) { + DLOG << "[DataObj]: " << szName << "=" << (void*)value << " name=\"" << value->name().toStdString() << "\" level=" << value->level() + << " pos=" << value->position() << " #child=" << value->childCount() << " what=\"" << value->whatsThis().toStdString() << "\"" << std::endl; + } + else { + DLOG << "[DataObj]: " << szName << "=null" << std::endl; + } +} + +#endif // MBSUIT_H \ No newline at end of file diff --git a/src/SUIT/SUIT_ActionOperation.cxx b/src/SUIT/SUIT_ActionOperation.cxx index 1dc646855..3fab6d9dd 100644 --- a/src/SUIT/SUIT_ActionOperation.cxx +++ b/src/SUIT/SUIT_ActionOperation.cxx @@ -26,6 +26,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SUIT_ActionOperation" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor. */ @@ -33,6 +39,7 @@ SUIT_ActionOperation::SUIT_ActionOperation( SUIT_Application* app ) : SUIT_Operation( app ), myAction( 0 ) { + DBG_FUN(); } /*! @@ -40,6 +47,7 @@ myAction( 0 ) */ SUIT_ActionOperation::~SUIT_ActionOperation() { + DBG_FUN(); } /*! @@ -57,6 +65,7 @@ void SUIT_ActionOperation::setAction( const QString& text, const QIcon& icon, const QString& menuText, QKeySequence accel, QObject* parent, bool toggle ) { + MSGEL("...SUIT_ActionOperation::setAction(\"" << text.toStdString() << "\", \"" << menuText.toStdString() << "\""); setAction( new QtxAction( text, icon, menuText, accel, parent, toggle ) ); } @@ -66,6 +75,7 @@ void SUIT_ActionOperation::setAction( const QString& text, const QIcon& icon, void SUIT_ActionOperation::setAction( const QString& text, const QString& menuText, QKeySequence accel, QObject* parent, bool toggle ) { + MSGEL("...SUIT_ActionOperation::setAction(\"" << text.toStdString() << "\", \"" << menuText.toStdString() << "\""); setAction( new QtxAction( text, menuText, accel, parent, toggle ) ); } diff --git a/src/SUIT/SUIT_DataBrowser.cxx b/src/SUIT/SUIT_DataBrowser.cxx index 190e4a633..d65af2263 100644 --- a/src/SUIT/SUIT_DataBrowser.cxx +++ b/src/SUIT/SUIT_DataBrowser.cxx @@ -26,6 +26,13 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SUIT_DataBrowser" +#include "MBDebug.h" +#include "MBSUIT.h" +//--------------------------------------------------------- + /*! \class SUIT_DataBrowser \brief Object browser customization. @@ -38,6 +45,7 @@ SUIT_DataBrowser::SUIT_DataBrowser( QWidget* parent ) : OB_Browser( parent ) { + DBG_FUN(); init( 0 ); } @@ -49,6 +57,8 @@ SUIT_DataBrowser::SUIT_DataBrowser( QWidget* parent ) SUIT_DataBrowser::SUIT_DataBrowser( SUIT_DataObject* root, QWidget* parent ) : OB_Browser( parent ) { + DBG_FUN(); + ARG(root); init( root ); } @@ -57,6 +67,7 @@ SUIT_DataBrowser::SUIT_DataBrowser( SUIT_DataObject* root, QWidget* parent ) */ SUIT_DataBrowser::~SUIT_DataBrowser() { + DBG_FUN(); } /*! @@ -84,6 +95,8 @@ SUIT_DataObject* SUIT_DataBrowser::root() const */ void SUIT_DataBrowser::setRoot( SUIT_DataObject* r ) { + DBG_FUN(); + ARG(r); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) m->setRoot( r ); @@ -111,6 +124,8 @@ bool SUIT_DataBrowser::autoUpdate() const */ void SUIT_DataBrowser::setAutoUpdate( const bool on ) { + DBG_FUN(); + ARG(on); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) m->setAutoUpdate( on ); @@ -132,6 +147,8 @@ bool SUIT_DataBrowser::updateModified() const */ void SUIT_DataBrowser::setUpdateModified( const bool on ) { + DBG_FUN(); + ARG(on); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) m->setUpdateModified( on ); @@ -145,6 +162,8 @@ void SUIT_DataBrowser::setUpdateModified( const bool on ) */ void SUIT_DataBrowser::updateTree( SUIT_DataObject* obj, const bool /*autoOpen*/ ) { + DBG_FUN(); + ARG(obj); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) { m->updateTree( obj ); @@ -224,6 +243,9 @@ void SUIT_DataBrowser::getSelected( DataObjectList& lst ) const */ void SUIT_DataBrowser::setSelected( const SUIT_DataObject* obj, const bool append ) { + DBG_FUN(); + ARG(obj); + ARG(append); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) { @@ -253,6 +275,8 @@ bool modelIndexLessThan(const QModelIndex& lhs, const QModelIndex& rhs) */ void SUIT_DataBrowser::setSelected( const DataObjectList& lst, const bool append ) { + DBG_FUN(); + ARG(append); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) { @@ -290,6 +314,7 @@ void SUIT_DataBrowser::ensureVisible( SUIT_DataObject* obj ) */ void SUIT_DataBrowser::ensureVisible( const DataObjectList& lst ) { + DBG_FUN(); QtxTreeView* tv = treeView(); SUIT_AbstractModel* treeModel = dynamic_cast( model() ); if ( !tv || !treeModel ) @@ -309,6 +334,7 @@ void SUIT_DataBrowser::ensureVisible( const DataObjectList& lst ) */ void SUIT_DataBrowser::contextMenuPopup( QMenu* menu ) { + DBG_FUN(); createPopupMenu( menu ); } @@ -346,6 +372,7 @@ void SUIT_DataBrowser::setAutoSizeColumns( const bool on ) */ void SUIT_DataBrowser::contextMenuEvent( QContextMenuEvent* e ) { + DBG_FUN(); contextMenuRequest( e ); } @@ -368,6 +395,8 @@ void SUIT_DataBrowser::setResizeOnExpandItem( const bool on ) */ void SUIT_DataBrowser::init( SUIT_DataObject* root ) { + DBG_FUN(); + ARG(root); SUIT_ProxyModel* m = new SUIT_ProxyModel( root, this ); connect( m, SIGNAL( modelUpdated() ), this, SLOT( onModelUpdated() ) ); @@ -428,6 +457,7 @@ void SUIT_DataBrowser::init( SUIT_DataObject* root ) */ void SUIT_DataBrowser::onModelUpdated() { + DBG_FUN(); setModified(); } @@ -439,11 +469,14 @@ void SUIT_DataBrowser::onModelUpdated() */ void SUIT_DataBrowser::onClicked( const QModelIndex& index ) { + DBG_FUN(); + MSGEL("in:[MdlIdx]: index={row=" << index.row() << ", col=" << index.column() << "}"); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) { SUIT_DataObject* obj = m->object( index ); if ( obj ) { + SHOW(obj); emit( clicked( obj ) ); m->emitClicked(obj, index); } @@ -458,10 +491,13 @@ void SUIT_DataBrowser::onClicked( const QModelIndex& index ) */ void SUIT_DataBrowser::onDblClicked( const QModelIndex& index ) { + DBG_FUN(); + MSGEL("in:[MdlIdx]: index={row=" << index.row() << ", col=" << index.column() << "}"); SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) { SUIT_DataObject* obj = m->object( index ); + SHOW(obj); if ( obj ) emit( doubleClicked( obj ) ); } } @@ -472,6 +508,7 @@ void SUIT_DataBrowser::onDblClicked( const QModelIndex& index ) */ void SUIT_DataBrowser::onExpanded( const QModelIndex& /*index*/ ) { + DBG_FUN(); if (myResizeOnExpandItem) { adjustFirstColumnWidth(); adjustColumnsWidth(); @@ -483,6 +520,7 @@ void SUIT_DataBrowser::onExpanded( const QModelIndex& /*index*/ ) \internal */ void SUIT_DataBrowser::onStartEditing() { + DBG_FUN(); DataObjectList sel = getSelected(); SUIT_ProxyModel* m = qobject_cast( model() ); if(treeView() && m && sel.count() == 1){ diff --git a/src/SVTK/MBDebug.h b/src/SVTK/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/SVTK/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/SVTK/SVTK_Prs.cxx b/src/SVTK/SVTK_Prs.cxx index fcb3f4fe8..f81c88832 100644 --- a/src/SVTK/SVTK_Prs.cxx +++ b/src/SVTK/SVTK_Prs.cxx @@ -28,11 +28,19 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_Prs" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Default constructor */ SVTK_Prs::SVTK_Prs( const char* entry ) : SALOME_VTKPrs(entry), myObjects( 0 ) { + DBG_FUN(); + ARG(entry); } /*! @@ -40,6 +48,8 @@ SVTK_Prs::SVTK_Prs( const char* entry ) : SALOME_VTKPrs(entry), myObjects( 0 ) */ SVTK_Prs::SVTK_Prs( const char* entry, const vtkActor* obj ) : SALOME_VTKPrs(entry) { + DBG_FUN(); + ARG(entry); AddObject( obj ); } @@ -48,6 +58,7 @@ SVTK_Prs::SVTK_Prs( const char* entry, const vtkActor* obj ) : SALOME_VTKPrs(ent */ SVTK_Prs:: ~SVTK_Prs() { + DBG_FUN(); if ( myObjects ) myObjects->Delete(); } @@ -64,6 +75,7 @@ vtkActorCollection* SVTK_Prs::GetObjects() const */ void SVTK_Prs::AddObject( const vtkActor* obj ) { + DBG_FUN(); if ( !myObjects) myObjects = vtkActorCollection::New(); myObjects->AddItem( (vtkActor*)obj ); diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index 3d8aa0aa4..e713be951 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -49,6 +49,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_Renderer" +#include "MBDebug.h" +//--------------------------------------------------------- + // undefining min and max because CASCADE's defines them and // it clashes with std::min(), std::max() included in utilities.h #undef min @@ -78,6 +84,7 @@ SVTK_Renderer myTrihedronSize(105), myIsTrihedronRelative(true) { + DBG_FUN(); myDevice->Delete(); myTransform->Delete(); @@ -160,6 +167,7 @@ SVTK_Renderer SVTK_Renderer ::~SVTK_Renderer() { + DBG_FUN(); VTK::ActorCollectionCopy aCopy(GetDevice()->GetActors()); vtkActorCollection* anActors = aCopy.GetActors(); vtkActorCollection* anActors2 = vtkActorCollection::New(); @@ -192,6 +200,7 @@ SVTK_Renderer void* theClientData, void* vtkNotUsed(theCallData)) { + DBG_FUN(); SVTK_Renderer* self = reinterpret_cast(theClientData); switch(theEvent){ @@ -225,6 +234,7 @@ SVTK_Renderer ::Initialize(vtkRenderWindowInteractor* theInteractor, SVTK_Selector* theSelector) { + DBG_FUN(); myInteractor = theInteractor; mySelector = theSelector; SetSelectionTolerance(); @@ -237,6 +247,7 @@ void SVTK_Renderer ::AddActor(VTKViewer_Actor* theActor, bool theIsAdjustActors) { + DBG_FUN(); if(SALOME_Actor* anActor = dynamic_cast(theActor)){ anActor->SetInteractor(myInteractor); anActor->SetTransform(GetTransform()); @@ -266,6 +277,7 @@ void SVTK_Renderer ::RemoveActor(VTKViewer_Actor* theActor, bool theIsAdjustActors) { + DBG_FUN(); if(SALOME_Actor* anActor = dynamic_cast(theActor)){ // Order of the calls are important because VTKViewer_Actor::RemoveFromRender // can leads do destruction of the actor @@ -326,6 +338,8 @@ void SVTK_Renderer ::SetScale( double theScale[3] ) { + DBG_FUN(); + MSGEL("in:[dbl]: theScale=[" << theScale[0] << ", " << theScale[1] << ", " << theScale[2] << "]"); myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] ); AdjustActors(); @@ -409,6 +423,7 @@ bool SVTK_Renderer ::OnAdjustActors() { + DBG_FUN(); bool aTDisplayed = IsTrihedronDisplayed(); bool aCDisplayed = IsCubeAxesDisplayed(); @@ -484,6 +499,7 @@ void SVTK_Renderer ::AdjustActors() { + DBG_FUN(); if(OnAdjustActors()) ::ResetCameraClippingRange(GetDevice()); } @@ -564,6 +580,8 @@ SVTK_Renderer void SVTK_Renderer ::SetTrihedronVisibility( const bool show ) { + DBG_FUN(); + ARG(show); if(show) myTrihedron->VisibilityOn(); else @@ -630,6 +648,7 @@ void SVTK_Renderer ::OnResetView() { + DBG_FUN(); int aTrihedronIsVisible = IsTrihedronDisplayed(); int aCubeAxesIsVisible = IsCubeAxesDisplayed(); @@ -663,6 +682,7 @@ void SVTK_Renderer ::OnFitAll() { + DBG_FUN(); int aTrihedronWasVisible = false; int aCubeAxesWasVisible = false; @@ -702,6 +722,7 @@ SVTK_Renderer */ void SVTK_Renderer::onFitSelection() { + DBG_FUN(); vtkActorCollection* aSelectedCollection = vtkActorCollection::New(); VTK::ActorCollectionCopy aCopy( GetDevice()->GetActors() ); @@ -728,6 +749,7 @@ void SVTK_Renderer::onFitSelection() void SVTK_Renderer::OnFitIObjects(const SALOME_ListIO& objects) { + DBG_FUN(); vtkActorCollection* aSelectedCollection = vtkActorCollection::New(); VTK::ActorCollectionCopy aCopy( GetDevice()->GetActors() ); @@ -770,6 +792,7 @@ void SVTK_Renderer ::OnResetClippingRange() { + DBG_FUN(); return; ::ResetCameraClippingRange(GetDevice()); } @@ -781,6 +804,7 @@ void SVTK_Renderer ::OnFrontView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->SetPosition(1,0,0); aCamera->SetViewUp(0,0,1); @@ -795,6 +819,7 @@ void SVTK_Renderer ::OnBackView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->SetPosition(-1,0,0); aCamera->SetViewUp(0,0,1); @@ -809,6 +834,7 @@ void SVTK_Renderer ::OnTopView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->SetPosition(0,0,1); aCamera->SetViewUp(0,1,0); @@ -823,6 +849,7 @@ void SVTK_Renderer ::OnBottomView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->SetPosition(0,0,-1); aCamera->SetViewUp(0,1,0); @@ -837,6 +864,7 @@ void SVTK_Renderer ::OnLeftView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->SetPosition(0,-1,0); aCamera->SetViewUp(0,0,1); @@ -852,6 +880,7 @@ void SVTK_Renderer ::onClockWiseView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->Roll(-90); aCamera->OrthogonalizeViewUp(); @@ -864,6 +893,7 @@ void SVTK_Renderer ::onAntiClockWiseView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->Roll(90); aCamera->OrthogonalizeViewUp(); @@ -876,6 +906,7 @@ void SVTK_Renderer ::OnRightView() { + DBG_FUN(); vtkCamera* aCamera = GetDevice()->GetActiveCamera(); aCamera->SetPosition(0,1,0); aCamera->SetViewUp(0,0,1); diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index 79b46a20b..35cd1ff4f 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -39,6 +39,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_Selector" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! \return new SVTK_Selector @@ -47,9 +53,11 @@ SVTK_Selector* SVTK_Selector ::New() { + DBG_FUNC(); return new SVTK_SelectorDef(); } +#define MBCLASSNAME "SVTK_SelectorDef" /*! Default constructor */ @@ -58,6 +66,7 @@ SVTK_SelectorDef myPicker(vtkPicker::New()), myCellPicker(vtkCellPicker::New()) { + DBG_FUN(); mySelectionMode = ActorSelection; myDynamicPreselection = true; myPreselectionEnabled = true; @@ -73,6 +82,7 @@ SVTK_SelectorDef SVTK_SelectorDef ::~SVTK_SelectorDef() { + DBG_FUN(); } /*! @@ -102,6 +112,7 @@ void SVTK_SelectorDef ::SetSelectionMode(Selection_Mode theMode) { + DBG_FUN(); if(mySelectionMode != theMode){ mySelectionMode = theMode; myMapIOSubIndex.clear(); @@ -117,6 +128,7 @@ void SVTK_SelectorDef ::ClearIObjects() { + DBG_FUN(); myIO2Actors.clear(); myIObjects.clear(); myMapIOSubIndex.clear(); @@ -166,6 +178,7 @@ bool SVTK_SelectorDef ::AddIObject(const Handle(SALOME_InteractiveObject)& theIO) { + DBG_FUN(); if(!IsSelected(theIO)){ myIObjects.insert(theIO); return true; @@ -181,6 +194,7 @@ bool SVTK_SelectorDef ::AddIObject(SALOME_Actor* theActor) { + DBG_FUN(); const Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); bool anIsIOBound = IsSelected(anIO); @@ -202,6 +216,7 @@ bool SVTK_SelectorDef ::RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) { + DBG_FUN(); bool anIsIOBound = myIObjects.find(theIO) != myIObjects.end(); myIObjects.erase(theIO); @@ -220,6 +235,7 @@ bool SVTK_SelectorDef ::RemoveIObject(SALOME_Actor* theActor) { + DBG_FUN(); const Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); bool anIsActorBound = myIO2Actors.find(anIO) != myIO2Actors.end(); @@ -358,6 +374,7 @@ SVTK_SelectorDef const SVTK_TIndexedMapOfVtkId& theIndices, bool theIsModeShift) { + DBG_FUN(); TMapIOSubIndex::iterator aMapIter = myMapIOSubIndex.find(theIO); if(aMapIter == myMapIOSubIndex.end()){ TIndexedMapOfInteger anEmpty; @@ -393,6 +410,7 @@ SVTK_SelectorDef const SVTK_TVtkIDsMap& theIndices, bool theIsModeShift) { + DBG_FUN(); TMapIOSubIndex::iterator aMapIter = myMapIOSubIndex.find(theIO); if(aMapIter == myMapIOSubIndex.end()){ TIndexedMapOfInteger anEmpty; @@ -429,6 +447,8 @@ SVTK_SelectorDef int theIndex, bool theIsModeShift) { + DBG_FUN(); + ARG(theIndex); TMapIOSubIndex::iterator anIter = myMapIOSubIndex.find(theIO); if(anIter == myMapIOSubIndex.end()){ TIndexedMapOfInteger anEmpty; @@ -464,6 +484,8 @@ SVTK_SelectorDef ::RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, int theIndex) { + DBG_FUN(); + ARG(theIndex); if(IsIndexSelected(theIO,theIndex)){ TMapIOSubIndex::iterator anIter = myMapIOSubIndex.find(theIO); SVTK_TIndexedMapOfVtkId& aMapIndex = anIter->second.myMap; @@ -478,6 +500,7 @@ void SVTK_SelectorDef ::ClearIndex() { + DBG_FUN(); myMapIOSubIndex.clear(); } @@ -520,6 +543,7 @@ SVTK_SelectorDef const SVTK_IndexedMapOfVtkIds& theIds, bool theIsModeShift) { + DBG_FUN(); TMapIOSubCompositeIndex::iterator aMapIter = myMapIOSubCompositeIndex.find( theIO ); if( aMapIter == myMapIOSubCompositeIndex.end() ) { SVTK_IndexedMapOfVtkIds anEmpty; @@ -552,6 +576,7 @@ SVTK_SelectorDef SVTK_ListOfVtk theIds, bool theIsModeShift) { + DBG_FUN(); TMapIOSubCompositeIndex::iterator anIter = myMapIOSubCompositeIndex.find( theIO ); if( anIter == myMapIOSubCompositeIndex.end() ) { SVTK_IndexedMapOfVtkIds anEmpty; @@ -586,6 +611,7 @@ SVTK_SelectorDef ::RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, SVTK_ListOfVtk theIds ) { + DBG_FUN(); if(IsCompositeIndexSelected( theIO, theIds ) ) { TMapIOSubCompositeIndex::iterator anIter = myMapIOSubCompositeIndex.find( theIO ); SVTK_IndexedMapOfVtkIds& aMapIndex = anIter->second; @@ -618,6 +644,7 @@ void SVTK_SelectorDef ::ClearCompositeIndex() { + DBG_FUN(); myMapIOSubCompositeIndex.clear(); } @@ -630,6 +657,7 @@ void SVTK_SelectorDef ::SetFilter(const Handle(VTKViewer_Filter)& theFilter) { + DBG_FUN(); myFilters.insert(TFilters::value_type(theFilter->GetId(),theFilter)); } @@ -652,6 +680,7 @@ void SVTK_SelectorDef ::RemoveFilter(const TFilterID theId) { + DBG_FUN(); if(IsFilterPresent(theId)) myFilters.erase(theId); } @@ -698,6 +727,7 @@ vtkActorCollection* SVTK_SelectorDef ::Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const { + DBG_FUN(); vtkActorCollection* aListActors = NULL; if ( GetDynamicPreSelection() ) { diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index ddecab3dd..0a6b4142e 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -39,6 +39,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_SignalHandler" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ @@ -47,6 +53,7 @@ SVTK_SignalHandler QObject(theMainWindow), myMainWindow(theMainWindow) { + DBG_FUN(); SVTK_RenderWindowInteractor* anInteractor = theMainWindow->GetInteractor(); connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)), @@ -73,6 +80,7 @@ SVTK_SignalHandler SVTK_SignalHandler ::~SVTK_SignalHandler() { + DBG_FUN(); } /*! @@ -93,6 +101,7 @@ void SVTK_SignalHandler ::Repaint(bool theUpdateTrihedron) { + DBG_FUN(); myMainWindow->Repaint(theUpdateTrihedron); } @@ -142,6 +151,7 @@ void SVTK_SignalHandler ::onSelectionChanged() { + DBG_FUN(); VTK::ActorCollectionCopy aCopy(myMainWindow->getRenderer()->GetActors()); vtkActorCollection* anActors = aCopy.GetActors(); @@ -160,6 +170,8 @@ SVTK_SignalHandler myMainWindow->Repaint(false); } + +#define MBCLASSNAME "SVTK_View" /*! Constructor */ @@ -167,6 +179,7 @@ SVTK_View ::SVTK_View(SVTK_ViewWindow* theMainWindow) : SVTK_SignalHandler(theMainWindow) { + DBG_FUN(); } /*! @@ -175,6 +188,7 @@ SVTK_View SVTK_View ::~SVTK_View() { + DBG_FUN(); } /*! @@ -184,6 +198,7 @@ void SVTK_View ::unHighlightAll() { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEach(aCopy.GetActors(), @@ -203,6 +218,7 @@ SVTK_View bool theIsHighlight, bool /*theIsUpdate*/ ) { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEachIf(aCopy.GetActors(), @@ -219,6 +235,8 @@ Handle(SALOME_InteractiveObject) SVTK_View ::FindIObject(const char* theEntry) { + DBG_FUN(); + ARG(theEntry); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); SALOME_Actor* anActor = @@ -330,6 +348,8 @@ SVTK_View ::rename(const Handle(SALOME_InteractiveObject)& theIObject, const QString& theName) { + DBG_FUN(); + ARG(theName); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEachIf(aCopy.GetActors(), @@ -356,6 +376,8 @@ void SVTK_View ::SetDisplayMode(int theMode) { + DBG_FUN(); + ARG(theMode); if(theMode == 0) ChangeRepresentationToWireframe(); else if (theMode == 1) @@ -377,6 +399,8 @@ SVTK_View ::SetDisplayMode(const Handle(SALOME_InteractiveObject)& theIObject, int theMode) { + DBG_FUN(); + ARG(theMode); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEachIf(aCopy.GetActors(), @@ -392,6 +416,7 @@ void SVTK_View ::ChangeRepresentationToWireframe() { + DBG_FUN(); VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ChangeRepresentationToWireframe(aCopy.GetActors()); } @@ -403,6 +428,7 @@ void SVTK_View ::ChangeRepresentationToSurface() { + DBG_FUN(); VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ChangeRepresentationToSurface(aCopy.GetActors()); } @@ -414,6 +440,7 @@ void SVTK_View ::ChangeRepresentationToSurfaceWithEdges() { + DBG_FUN(); VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ChangeRepresentationToSurfaceWithEdges(aCopy.GetActors()); } @@ -426,6 +453,7 @@ void SVTK_View ::ChangeRepresentationToWireframe(vtkActorCollection* theCollection) { + DBG_FUN(); using namespace SVTK; ForEach(theCollection, TSetFunction @@ -441,6 +469,7 @@ void SVTK_View ::ChangeRepresentationToSurface(vtkActorCollection* theCollection) { + DBG_FUN(); using namespace SVTK; ForEach(theCollection, TSetFunction @@ -456,6 +485,7 @@ void SVTK_View ::ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* theCollection) { + DBG_FUN(); using namespace SVTK; ForEach(theCollection, TSetFunction @@ -491,6 +521,7 @@ void SVTK_View ::EraseAll() { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEach(aCopy.GetActors(), @@ -505,6 +536,7 @@ void SVTK_View ::DisplayAll() { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEach(aCopy.GetActors(), @@ -522,6 +554,7 @@ SVTK_View ::Erase(SALOME_Actor* theActor, bool theIsUpdate) { + DBG_FUN(); SVTK::TErase()(theActor); if(theIsUpdate) @@ -539,6 +572,7 @@ SVTK_View ::Erase(const Handle(SALOME_InteractiveObject)& theIObject, bool theIsUpdate) { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEachIf(aCopy.GetActors(), @@ -556,6 +590,7 @@ SVTK_View ::Display(SALOME_Actor* theActor, bool theIsUpdate) { + DBG_FUN(); GetRenderer()->AddActor(theActor); theActor->SetVisibility(true); @@ -571,6 +606,7 @@ SVTK_View ::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool theIsUpdate) { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEachIf(aCopy.GetActors(), @@ -588,6 +624,7 @@ void SVTK_View ::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject) { + DBG_FUN(); EraseAll(); Display(theIObject); } @@ -617,6 +654,7 @@ SVTK_View ::Remove(const Handle(SALOME_InteractiveObject)& theIObject, bool theIsUpdate) { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEachIf(aCopy.GetActors(), @@ -634,6 +672,7 @@ SVTK_View ::Remove(SALOME_Actor* theActor, bool theIsUpdate) { + DBG_FUN(); GetRenderer()->RemoveActor(theActor); if(theIsUpdate) Repaint(); @@ -646,6 +685,7 @@ void SVTK_View ::RemoveAll(bool theIsUpdate) { + DBG_FUN(); vtkRenderer* aRenderer = getRenderer(); VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); if(vtkActorCollection* anActors = aCopy.GetActors()){ @@ -691,6 +731,7 @@ SVTK_View ::SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject, float theTrans) { + DBG_FUN(); double anOpacity = 1.0 - theTrans; using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); @@ -710,6 +751,7 @@ SVTK_View ::SetColor(const Handle(SALOME_InteractiveObject)& theIObject, const QColor& theColor) { + DBG_FUN(); double aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.}; using namespace SVTK; @@ -754,6 +796,7 @@ SVTK_View ::SetMaterial(const Handle(SALOME_InteractiveObject)& theIObject, vtkProperty* thePropF, vtkProperty* thePropB) { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); std::vector aProps; @@ -809,6 +852,7 @@ SVTK_View */ void SVTK_View::GetVisible( SALOME_ListIO& theList ) { + DBG_FUN(); using namespace SVTK; VTK::ActorCollectionCopy aCopy(getRenderer()->GetActors()); ForEach(aCopy.GetActors(), diff --git a/src/SVTK/SVTK_ViewManager.cxx b/src/SVTK/SVTK_ViewManager.cxx index c2001ec00..d4a3a3fed 100644 --- a/src/SVTK/SVTK_ViewManager.cxx +++ b/src/SVTK/SVTK_ViewManager.cxx @@ -25,12 +25,19 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_ViewManager" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ SVTK_ViewManager::SVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop ) : SUIT_ViewManager( study, theDesktop, new SVTK_Viewer() ) { + DBG_FUN(); setTitle( VTKViewer_ViewManager::tr( "VTK_VIEW_TITLE" ) ); } @@ -39,6 +46,7 @@ SVTK_ViewManager::SVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop */ SVTK_ViewManager::~SVTK_ViewManager() { + DBG_FUN(); } /*! diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 67519dd80..35e31564e 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -51,11 +51,18 @@ // VSR: Uncomment below line to allow texture background support in VTK viewer #define VTK_ENABLE_TEXTURED_BACKGROUND +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_Viewer" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Constructor */ SVTK_Viewer::SVTK_Viewer() { + DBG_FUN(); myTrihedronSize = 105; myTrihedronRelative = true; myIsStaticTrihedronVisible = true; @@ -80,6 +87,7 @@ SVTK_Viewer::SVTK_Viewer() */ SVTK_Viewer::~SVTK_Viewer() { + DBG_FUN(); } /*! Get data for supported background modes: gradient types, identifiers and supported image formats */ @@ -131,6 +139,7 @@ QColor SVTK_Viewer::backgroundColor() const //! Set background color to the viewer [obsolete] void SVTK_Viewer::setBackgroundColor( const QColor& c ) { + DBG_FUN(); Qtx::BackgroundData bg = background(); bg.setColor( c ); setBackground( bg ); @@ -150,6 +159,7 @@ Qtx::BackgroundData SVTK_Viewer::background() const */ void SVTK_Viewer::setBackground( const Qtx::BackgroundData& theBackground ) { + DBG_FUN(); myDefaultBackground = theBackground.isValid() ? theBackground : Qtx::BackgroundData( Qt::black ); QVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ @@ -166,6 +176,7 @@ void SVTK_Viewer::setBackground( const Qtx::BackgroundData& theBackground ) */ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) { + DBG_FUN(); TViewWindow* aViewWindow = new TViewWindow(theDesktop); aViewWindow->Initialize(this); @@ -268,6 +279,8 @@ int SVTK_Viewer::projectionMode() const */ void SVTK_Viewer::setProjectionMode( const int theMode ) { + DBG_FUN(); + ARG(theMode); if ( myProjMode != theMode ) { if ( theMode != SVTK_ViewWindow::Stereo ) myProjMode = theMode; @@ -352,6 +365,8 @@ bool SVTK_Viewer::isQuadBufferSupport() const */ void SVTK_Viewer::setQuadBufferSupport( const bool theEnable ) { + DBG_FUN(); + ARG(theEnable); if ( myQuadBufferSupport != theEnable ) { myQuadBufferSupport = theEnable; @@ -516,6 +531,7 @@ void SVTK_Viewer::setSpacemouseButtons( const int theBtn1, const int theBtn2, co */ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) { + DBG_FUN(); SUIT_ViewModel::setViewManager(theViewManager); if ( !theViewManager ) @@ -539,6 +555,7 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) */ void SVTK_Viewer::contextMenuPopup( QMenu* thePopup ) { + DBG_FUN(); thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) ); @@ -578,6 +595,8 @@ void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/ */ void SVTK_Viewer::enableSelection(bool isEnabled) { + DBG_FUN(); + ARG(isEnabled); mySelectionEnabled = isEnabled; //!! To be done for view windows @@ -664,6 +683,7 @@ void SVTK_Viewer::onChangeBackground() */ void SVTK_Viewer::Display( const SALOME_VTKPrs* prs ) { + DBG_FUN(); // try do downcast object if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ if(aPrs->IsNull()) @@ -708,6 +728,7 @@ void SVTK_Viewer::Display( const SALOME_VTKPrs* prs ) */ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) { + DBG_FUN(); // try do downcast object if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ if(aPrs->IsNull()) @@ -747,6 +768,7 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) */ void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) { + DBG_FUN(); QVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) @@ -794,6 +816,8 @@ void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) */ SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry ) { + DBG_FUN(); + ARG(entry); SVTK_Prs* prs = new SVTK_Prs( entry ); if ( entry ) { if(SVTK_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) @@ -837,6 +861,7 @@ bool SVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& io ) */ void SVTK_Viewer::GetVisible( SALOME_ListIO& theList ) { + DBG_FUN(); // here we collect object if it is disaplaed even one view QVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) @@ -851,6 +876,7 @@ void SVTK_Viewer::GetVisible( SALOME_ListIO& theList ) */ void SVTK_Viewer::Repaint() { + DBG_FUN(); // if (theUpdateTrihedron) onAdjustTrihedron(); QVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) @@ -862,15 +888,18 @@ void SVTK_Viewer::Repaint() void SVTK_Viewer::onActorAdded(VTKViewer_Actor* theActor) { + DBG_FUN(); emit actorAdded((SVTK_ViewWindow*)sender(), theActor); } void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor) { + DBG_FUN(); emit actorRemoved((SVTK_ViewWindow*)sender(), theActor); } void SVTK_Viewer::onViewCreated( SUIT_ViewWindow* view) { + DBG_FUN(); #ifdef VGL_WORKAROUND if ( SVTK_ViewWindow* svw = dynamic_cast( view ) ) QTimer::singleShot(500, [svw] () { svw->Repaint(); } ); diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 3f2b5bbd6..63a0af406 100644 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -112,6 +112,12 @@ #include #endif +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SVTK_ViewWindow" +#include "MBDebug.h" +//--------------------------------------------------------- + // Use workaround for rendering transparent object over MESA #define USE_WORKAROUND_FOR_MESA @@ -145,6 +151,7 @@ SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop): myEventCallbackCommand(vtkCallbackCommand::New()), myDumpImage(QImage()) { + DBG_FUN(); setWindowFlags( windowFlags() & ~Qt::Window ); // specific of vtkSmartPointer myKeyFreeInteractorStyle->Delete(); @@ -155,6 +162,7 @@ SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop): */ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) { + DBG_FUN(); myModel = theModel; myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor"); @@ -273,6 +281,7 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) void SVTK_ViewWindow::Initialize(SVTK_View* theView, SVTK_ViewModelBase* theModel) { + DBG_FUN(); connect(theView,SIGNAL(KeyPressed(QKeyEvent*)), this,SLOT(onKeyPressed(QKeyEvent*)) ); connect(theView,SIGNAL(KeyReleased(QKeyEvent*)), @@ -298,6 +307,7 @@ void SVTK_ViewWindow::Initialize(SVTK_View* theView, */ SVTK_ViewWindow::~SVTK_ViewWindow() { + DBG_FUN(); myRecorder->Delete(); myAxesWidget->Delete(); } @@ -364,6 +374,7 @@ SVTK_Selector* SVTK_ViewWindow::GetSelector() const */ void SVTK_ViewWindow::onFrontView() { + DBG_FUN(); GetRenderer()->OnFrontView(); Repaint(); emit transformed( this ); @@ -374,6 +385,7 @@ void SVTK_ViewWindow::onFrontView() */ void SVTK_ViewWindow::onBackView() { + DBG_FUN(); GetRenderer()->OnBackView(); Repaint(); emit transformed( this ); @@ -384,6 +396,7 @@ void SVTK_ViewWindow::onBackView() */ void SVTK_ViewWindow::onTopView() { + DBG_FUN(); GetRenderer()->OnTopView(); Repaint(); emit transformed( this ); @@ -394,6 +407,7 @@ void SVTK_ViewWindow::onTopView() */ void SVTK_ViewWindow::onBottomView() { + DBG_FUN(); GetRenderer()->OnBottomView(); Repaint(); emit transformed( this ); @@ -404,6 +418,7 @@ void SVTK_ViewWindow::onBottomView() */ void SVTK_ViewWindow::onLeftView() { + DBG_FUN(); GetRenderer()->OnLeftView(); Repaint(); emit transformed( this ); @@ -414,6 +429,7 @@ void SVTK_ViewWindow::onLeftView() */ void SVTK_ViewWindow::onRightView() { + DBG_FUN(); GetRenderer()->OnRightView(); Repaint(); emit transformed( this ); @@ -424,6 +440,7 @@ void SVTK_ViewWindow::onRightView() */ void SVTK_ViewWindow::onClockWiseView() { + DBG_FUN(); GetRenderer()->onClockWiseView(); Repaint(); emit transformed( this ); @@ -434,6 +451,7 @@ void SVTK_ViewWindow::onClockWiseView() */ void SVTK_ViewWindow::onAntiClockWiseView() { + DBG_FUN(); GetRenderer()->onAntiClockWiseView(); Repaint(); emit transformed( this ); @@ -444,6 +462,7 @@ void SVTK_ViewWindow::onAntiClockWiseView() */ void SVTK_ViewWindow::onResetView() { + DBG_FUN(); GetRenderer()->OnResetView(); Repaint(); emit transformed( this ); @@ -454,6 +473,7 @@ void SVTK_ViewWindow::onResetView() */ void SVTK_ViewWindow::onFitAll() { + DBG_FUN(); GetRenderer()->OnFitAll(); Repaint(); emit transformed( this ); @@ -464,6 +484,7 @@ void SVTK_ViewWindow::onFitAll() */ void SVTK_ViewWindow::onFitSelection() { + DBG_FUN(); GetRenderer()->onFitSelection(); Repaint(); emit transformed( this ); @@ -474,6 +495,7 @@ void SVTK_ViewWindow::onFitSelection() */ void SVTK_ViewWindow::onFitIObjects(const SALOME_ListIO& objects) { + DBG_FUN(); GetRenderer()->OnFitIObjects(objects); Repaint(); emit transformed( this ); @@ -484,6 +506,7 @@ void SVTK_ViewWindow::onFitIObjects(const SALOME_ListIO& objects) */ void SVTK_ViewWindow::onSelectionChanged() { + DBG_FUN(); myView->onSelectionChanged(); } @@ -493,6 +516,7 @@ void SVTK_ViewWindow::onSelectionChanged() */ void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode) { + DBG_FUN(); GetSelector()->SetSelectionMode(theMode); } @@ -560,6 +584,8 @@ Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEnt void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO, bool theImmediatly) { + DBG_FUN(); + ARG(theImmediatly); myView->Display(theIO,theImmediatly); } @@ -571,6 +597,8 @@ void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO, void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, bool theImmediatly) { + DBG_FUN(); + ARG(theImmediatly); myView->Erase(theIO,theImmediatly); } @@ -580,6 +608,7 @@ void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, */ void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) { + DBG_FUN(); myView->DisplayOnly(theIO); } @@ -588,6 +617,7 @@ void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) */ void SVTK_ViewWindow::DisplayAll() { + DBG_FUN(); myView->DisplayAll(); } @@ -596,6 +626,7 @@ void SVTK_ViewWindow::DisplayAll() */ void SVTK_ViewWindow::EraseAll() { + DBG_FUN(); myView->EraseAll(); } @@ -605,6 +636,7 @@ void SVTK_ViewWindow::EraseAll() */ void SVTK_ViewWindow::setBackgroundColor( const QColor& c ) { + DBG_FUN(); Qtx::BackgroundData bg = background(); bg.setColor( c ); setBackground( bg ); @@ -624,6 +656,7 @@ QColor SVTK_ViewWindow::backgroundColor() const */ void SVTK_ViewWindow::setBackground( const Qtx::BackgroundData& bgData ) { + DBG_FUN(); bool ok = false; if ( bgData.isValid() ) { @@ -824,6 +857,7 @@ void SVTK_ViewWindow::GetScale( double theScale[3] ) */ void SVTK_ViewWindow::SetScale( double theScale[3] ) { + DBG_FUN(); GetRenderer()->SetScale( theScale ); Repaint(); emit transformed( this ); @@ -850,6 +884,7 @@ bool SVTK_ViewWindow::isCubeAxesDisplayed() */ void SVTK_ViewWindow::onViewTrihedron(bool show) { + DBG_FUN(); GetRenderer()->SetTrihedronVisibility(show); Repaint(); } @@ -893,6 +928,8 @@ double SVTK_ViewWindow::GetTrihedronSize() const */ void SVTK_ViewWindow::SetProjectionMode(const int theMode) { + DBG_FUN(); + ARG(theMode); QtxAction* aParallelAction = dynamic_cast( toolMgr()->action( ParallelModeId ) ); QtxAction* aProjectionAction = dynamic_cast( toolMgr()->action( ProjectionModeId ) ); QtxAction* aStereoAction = dynamic_cast( toolMgr()->action( StereoModeId ) ); @@ -963,6 +1000,7 @@ void SVTK_ViewWindow::SetProjectionMode(const int theMode) */ void SVTK_ViewWindow::SetStereoType(const int theType) { + DBG_FUN(); vtkRenderWindow* aWindow = getRenderWindow(); switch (theType ) { case CrystalEyes: @@ -1001,6 +1039,7 @@ void SVTK_ViewWindow::SetStereoType(const int theType) */ void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter) { + DBG_FUN(); vtkRenderWindow* aWindow = getRenderWindow(); switch (theFilter ) { case RedCyan: @@ -1021,6 +1060,7 @@ void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter) */ void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable) { + DBG_FUN(); vtkRenderWindow* aWindow = getRenderWindow(); aWindow->SetStereoCapableWindow((int)theEnable); } @@ -1097,6 +1137,7 @@ void SVTK_ViewWindow::activateProjectionMode(int theMode) */ void SVTK_ViewWindow::SetInteractionStyle(const int theStyle) { + DBG_FUN(); onSwitchInteractionStyle( theStyle==1 ); } @@ -1106,6 +1147,7 @@ void SVTK_ViewWindow::SetInteractionStyle(const int theStyle) */ void SVTK_ViewWindow::SetZoomingStyle(const int theStyle) { + DBG_FUN(); onSwitchZoomingStyle( theStyle==1 ); } @@ -1115,6 +1157,7 @@ void SVTK_ViewWindow::SetZoomingStyle(const int theStyle) */ void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode ) { + DBG_FUN(); onSwitchPreSelectionMode( theMode ); } @@ -1124,6 +1167,7 @@ void SVTK_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode ) */ void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable ) { + DBG_FUN(); GetSelector()->SetSelectionEnabled( theEnable ); QtxAction* a = getAction( EnableSelectionId ); if ( a->isChecked() != theEnable) @@ -1147,6 +1191,7 @@ void SVTK_ViewWindow::SetSelectionEnabled( bool theEnable ) */ void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn) { + DBG_FUN(); if (theOn) { // check if style is already set if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() ) @@ -1177,6 +1222,7 @@ void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn) */ void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn ) { + DBG_FUN(); if( myDefaultInteractorStyle.GetPointer() ) myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn ); if( myKeyFreeInteractorStyle.GetPointer() ) @@ -1194,6 +1240,7 @@ void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn ) */ void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode ) { + DBG_FUN(); GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection ); GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled ); @@ -1209,6 +1256,7 @@ void SVTK_ViewWindow::onSwitchPreSelectionMode( int theMode ) */ void SVTK_ViewWindow::onEnableSelection( bool on ) { + DBG_FUN(); SVTK_Viewer* aViewer = dynamic_cast(myModel); if(aViewer) aViewer->enableSelection(on); @@ -1221,6 +1269,7 @@ void SVTK_ViewWindow::onEnableSelection( bool on ) */ void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode) { + DBG_FUN(); if ( (SVTK_InteractorStyle*)GetInteractorStyle() ) ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode); } @@ -1235,6 +1284,7 @@ void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1, const int theBtn2, const int theBtn3) { + DBG_FUN(); int val = theBtn1; myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val); val = theBtn2; @@ -1281,6 +1331,7 @@ void SVTK_ViewWindow::onAdjustCubeAxes() void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow ) { + DBG_FUN(); if ( otherViewWindow ) { bool blocked = blockSignals( true ); doSetVisualParameters( otherViewWindow->getVisualParameters(), true ); @@ -1317,6 +1368,7 @@ void SVTK_ViewWindow::onMousePressed(QMouseEvent* event) */ void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event) { + DBG_FUN(); emit mouseReleased( this, event ); } @@ -1343,6 +1395,7 @@ void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, bool theUpdate, bool theIsAdjustActors ) { + DBG_FUN(); GetRenderer()->AddActor(theActor, theIsAdjustActors); if(theUpdate) Repaint(); @@ -1356,6 +1409,7 @@ void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate, bool theIsAdjustActors ) { + DBG_FUN(); GetRenderer()->RemoveActor(theActor, theIsAdjustActors); if ( myDefaultInteractorStyle ) myDefaultInteractorStyle->FreeActors(); @@ -1658,6 +1712,7 @@ void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, Q void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor) { + DBG_FUNC(); if ( !actor ) return; @@ -1755,6 +1810,7 @@ void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor) */ void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params ) { + DBG_FUNC(); if ( !actor ) return; @@ -1897,6 +1953,7 @@ QString SVTK_ViewWindow::getVisualParameters() */ void SVTK_ViewWindow::setVisualParameters( const QString& parameters ) { + DBG_FUN(); //printf("#### %s\n", qPrintable(parameters)); SVTK_RenderWindowInteractor* anInteractor = GetInteractor(); if ( anInteractor->isVisible() ) { @@ -1913,6 +1970,7 @@ void SVTK_ViewWindow::setVisualParameters( const QString& parameters ) */ void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly ) { + DBG_FUN(); double pos[3], focalPnt[3], viewUp[3], parScale = 1.0, scale[3]; @@ -2112,6 +2170,7 @@ void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMo */ void SVTK_ViewWindow::onProjectionMode( QAction* theAction ) { + DBG_FUN(); int aMode = Parallel; if (theAction == toolMgr()->action( ProjectionModeId )) aMode = Projection; @@ -2132,6 +2191,7 @@ void SVTK_ViewWindow::onProjectionMode( QAction* theAction ) */ void SVTK_ViewWindow::onStereoMode( bool activate ) { + DBG_FUN(); if (activate) { toolMgr()->action( ProjectionModeId )->setChecked(true); vtkCamera* aCamera = getRenderer()->GetActiveCamera(); @@ -2165,6 +2225,7 @@ void SVTK_ViewWindow::onStereoMode( bool activate ) */ void SVTK_ViewWindow::onProjectionMode() { + DBG_FUN(); if (toolMgr()->action( ParallelModeId )->isChecked()) SetProjectionMode( Parallel); if (toolMgr()->action( ProjectionModeId )->isChecked()) @@ -2184,6 +2245,7 @@ void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher) */ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) { + DBG_FUN(); QtxAction* anAction; QtxActionToolMgr* mgr = toolMgr(); @@ -2735,6 +2797,7 @@ void SVTK_ViewWindow::onViewParameters(bool theIsActivate) */ void SVTK_ViewWindow::showEvent( QShowEvent * theEvent ) { + DBG_FUN(); emit Show( theEvent ); } @@ -2743,6 +2806,7 @@ void SVTK_ViewWindow::showEvent( QShowEvent * theEvent ) */ void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent ) { + DBG_FUN(); emit Hide( theEvent ); } @@ -2761,6 +2825,7 @@ void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject), void* theClientData, void* /*theCallData*/) { + DBG_FUN(); SVTK_ViewWindow* self = reinterpret_cast(theClientData); if(self) self->emitTransformed(); @@ -2819,6 +2884,7 @@ SUIT_CameraProperties SVTK_ViewWindow::cameraProperties() */ void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView ) { + DBG_FUN(); bool blocked = blockSignals( true ); SUIT_CameraProperties aProps = theView->cameraProperties(); diff --git a/src/SalomeApp/MBDebug.h b/src/SalomeApp/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/SalomeApp/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 1e9492add..bc715233d 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -113,6 +113,12 @@ #include #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SalomeApp_Application" +#include "MBDebug.h" +//--------------------------------------------------------- + std::unique_ptr SalomeApp_Application::_ns; /*!Internal class that updates object browser item properties */ @@ -200,6 +206,7 @@ namespace /*!Constructor.*/ SalomeApp_Application::SalomeApp_Application(SALOME_NamingService_Abstract *ns):myIsCloseFromExit( false ),myToIgnoreMessages( false ) { + DBG_FUN(); if(!ns) _ns.reset(new SALOME_NamingService(orb())); else @@ -211,6 +218,7 @@ SalomeApp_Application::SalomeApp_Application(SALOME_NamingService_Abstract *ns): */ SalomeApp_Application::~SalomeApp_Application() { + DBG_FUN(); // Do not destroy. It's a singleton ! //SALOME_EventFilter::Destroy(); } @@ -237,6 +245,7 @@ QStringList __getArgsList(QString argsString) /*!Start application.*/ void SalomeApp_Application::start() { + DBG_FUN(); // process the command line options before start: to createActions in accordance to the options static bool isFirst = true; if ( isFirst ) { @@ -328,6 +337,7 @@ void SalomeApp_Application::start() /*!Create actions:*/ void SalomeApp_Application::createActions() { + DBG_FUN(); LightApp_Application::createActions(); SUIT_Desktop* desk = desktop(); @@ -420,6 +430,7 @@ void SalomeApp_Application::createActions() */ void SalomeApp_Application::onExit() { + DBG_FUN(); //MessageLocker ml( myToIgnoreMessages ); bool killServers = false; @@ -441,6 +452,7 @@ void SalomeApp_Application::onExit() /*!SLOT. Create a document.*/ void SalomeApp_Application::onNewDoc() { + DBG_FUN(); MessageLocker ml( myToIgnoreMessages ); LightApp_Application::onNewDoc(); @@ -449,6 +461,7 @@ void SalomeApp_Application::onNewDoc() /*!SLOT. Load document.*/ void SalomeApp_Application::onLoadDoc() { + DBG_FUN(); MessageLocker ml( myToIgnoreMessages ); QString studyName; @@ -509,6 +522,7 @@ void SalomeApp_Application::onLoadDoc() /*!SLOT. Unload document.*/ void SalomeApp_Application::onUnloadDoc( bool ask ) { + DBG_FUN(); if ( ask ) { activeStudy()->abortAllOperations(); if ( activeStudy()->isModified() ) { @@ -534,6 +548,7 @@ void SalomeApp_Application::onUnloadDoc( bool ask ) /*!SLOT. Create new study and load script*/ void SalomeApp_Application::onNewWithScript() { + DBG_FUN(); QStringList filtersList; filtersList.append(tr("PYTHON_FILES_FILTER")); filtersList.append(tr("ALL_FILES_FILTER")); @@ -562,6 +577,8 @@ void SalomeApp_Application::onNewWithScript() /*!SLOT. Load document with \a aName.*/ bool SalomeApp_Application::onLoadDoc( const QString& aName ) { + DBG_FUN(); + ARG(aName); if ( !LightApp_Application::closeDoc() ) return false; @@ -598,6 +615,8 @@ bool SalomeApp_Application::onLoadDoc( const QString& aName ) /*!SLOT. Parse message for desktop.*/ void SalomeApp_Application::onDesktopMessage( const QString& message ) { + DBG_FUN(); + ARG(message); if ( myToIgnoreMessages ) return; // a message from SALOMEDS is caused by GUI action @@ -632,6 +651,8 @@ void SalomeApp_Application::onDesktopMessage( const QString& message ) /*!On module activation action.*/ void SalomeApp_Application::onModuleActivation( const QString& modName ) { + DBG_FUN(); + ARG(modName); if (!activeStudy() && !modName.isEmpty()) getStudy()->Init(); @@ -641,6 +662,7 @@ void SalomeApp_Application::onModuleActivation( const QString& modName ) /*!SLOT. Copy objects to study maneger from selection maneger..*/ void SalomeApp_Application::onCopy() { + DBG_FUN(); LightApp_Application::onCopy(); SALOME_ListIO list; @@ -672,6 +694,7 @@ void SalomeApp_Application::onCopy() /*!SLOT. Paste objects to study maneger from selection manager.*/ void SalomeApp_Application::onPaste() { + DBG_FUN(); LightApp_Application::onPaste(); SALOME_ListIO list; @@ -719,6 +742,7 @@ bool SalomeApp_Application::isPossibleToClose( bool& closePermanently ) /*! Check if the study is locked */ void SalomeApp_Application::onCloseDoc( bool ask ) { + DBG_FUN(); if(getStudy()->IsStudyLocked()) { if ( SUIT_MessageBox::question( desktop(), QObject::tr( "WRN_WARNING" ), @@ -738,6 +762,7 @@ void SalomeApp_Application::onCloseDoc( bool ask ) /*!SLOT. Reload document from the file.*/ bool SalomeApp_Application::onReopenDoc() { + DBG_FUN(); MessageLocker ml( myToIgnoreMessages ); return LightApp_Application::onReopenDoc(); @@ -747,6 +772,7 @@ bool SalomeApp_Application::onReopenDoc() /*!SLOT. Load document.*/ void SalomeApp_Application::onOpenDoc() { + DBG_FUN(); MessageLocker ml( myToIgnoreMessages ); LightApp_Application::onOpenDoc(); @@ -755,6 +781,8 @@ void SalomeApp_Application::onOpenDoc() /*!SLOT. Load document.*/ bool SalomeApp_Application::onOpenDoc(const QString& name) { + DBG_FUN(); + ARG(name); MessageLocker ml( myToIgnoreMessages ); return LightApp_Application::onOpenDoc(name); @@ -763,6 +791,7 @@ bool SalomeApp_Application::onOpenDoc(const QString& name) /*!Sets enable or disable some actions on selection changed.*/ void SalomeApp_Application::onSelectionChanged() { + DBG_FUN(); SALOME_ListIO list; LightApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(list); @@ -795,6 +824,7 @@ void SalomeApp_Application::onSelectionChanged() /*!Delete references.*/ void SalomeApp_Application::onDeleteInvalidReferences() { + DBG_FUN(); SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects( aList, QString(), false ); @@ -822,6 +852,7 @@ void SalomeApp_Application::onDeleteInvalidReferences() /*!Private SLOT. */ void SalomeApp_Application::onOpenWith() { + DBG_FUN(); QApplication::setOverrideCursor( Qt::WaitCursor ); SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); @@ -845,6 +876,7 @@ void SalomeApp_Application::onOpenWith() */ SUIT_Study* SalomeApp_Application::createNewStudy() { + DBG_FUN(); SalomeApp_Study* aStudy = new SalomeApp_Study( this ); // Set up processing of major study-related events @@ -869,6 +901,7 @@ SUIT_Study* SalomeApp_Application::createNewStudy() */ void SalomeApp_Application::updateCommandsStatus() { + DBG_FUN(); LightApp_Application::updateCommandsStatus(); // Dump study menu @@ -949,6 +982,7 @@ public: /*!Private SLOT. On dump study.*/ void SalomeApp_Application::onDumpStudy( ) { + DBG_FUN(); SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); if ( !appStudy ) return; @@ -1003,6 +1037,7 @@ void SalomeApp_Application::onDumpStudy( ) /*!Private SLOT. On load script.*/ void SalomeApp_Application::onLoadScript( ) { + DBG_FUN(); if ( getStudy()->GetProperties()->IsLocked() ) { SUIT_MessageBox::warning( desktop(), QObject::tr("WRN_WARNING"), @@ -1035,6 +1070,7 @@ void SalomeApp_Application::onLoadScript( ) /*!Private SLOT. On save GUI state.*/ void SalomeApp_Application::onSaveGUIState() { + DBG_FUN(); SalomeApp_Study* study = dynamic_cast( activeStudy() ); if ( study ) { SalomeApp_VisualState( this ).storeState(); @@ -1047,6 +1083,8 @@ void SalomeApp_Application::onSaveGUIState() /*!Public SLOT. Performs some actions when dockable windows are triggered.*/ void SalomeApp_Application::onDockWindowVisibilityChanged( bool theIsVisible ) { + DBG_FUN(); + ARG(theIsVisible); LightApp_Application::onDockWindowVisibilityChanged( theIsVisible ); QAction* send = ::qobject_cast( sender() ); if ( !send ) @@ -1059,6 +1097,8 @@ void SalomeApp_Application::onDockWindowVisibilityChanged( bool theIsVisible ) /*!Create window.*/ QWidget* SalomeApp_Application::createWindow( const int flag ) { + DBG_FUN(); + ARG(flag); QWidget* wid = 0; #ifndef DISABLE_PYCONSOLE if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag); @@ -1162,6 +1202,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) /*!Create preferences.*/ void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) { + DBG_FUN(); LightApp_Application::createPreferences(pref); if ( !pref ) @@ -1191,6 +1232,7 @@ void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) /*!Update desktop title.*/ void SalomeApp_Application::updateDesktopTitle() { + DBG_FUN(); QString aTitle = applicationName(); QString aVer = applicationVersion(); if ( !aVer.isEmpty() ) @@ -1208,11 +1250,13 @@ void SalomeApp_Application::updateDesktopTitle() { } } + SHOW(aTitle); desktop()->setWindowTitle( aTitle ); } int SalomeApp_Application::closeChoice( const QString& /*docName*/ ) { + DBG_FUN(); QStringList buttons; QMap choices; int idx = 0; @@ -1238,6 +1282,8 @@ int SalomeApp_Application::closeChoice( const QString& /*docName*/ ) bool SalomeApp_Application::closeAction( const int choice, bool& closePermanently ) { + DBG_FUN(); + ARG(choice); bool res = true; switch( choice ) { @@ -1268,6 +1314,8 @@ bool SalomeApp_Application::closeAction( const int choice, bool& closePermanentl int SalomeApp_Application::openChoice( const QString& aName ) { + DBG_FUN(); + ARG(aName); int choice = LightApp_Application::openChoice( aName ); if ( QFileInfo( aName ).exists() ) { @@ -1298,6 +1346,9 @@ int SalomeApp_Application::openChoice( const QString& aName ) bool SalomeApp_Application::openAction( const int aChoice, const QString& aName ) { + DBG_FUN(); + ARG(aChoice); + ARG(aName); bool res = false; int choice = aChoice; switch ( choice ) @@ -1330,6 +1381,7 @@ bool SalomeApp_Application::openAction( const int aChoice, const QString& aName */ QMap SalomeApp_Application::activateModuleActions() const { + DBG_FUN(); QMap opmap = LightApp_Application::activateModuleActions(); opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) ); @@ -1349,6 +1401,8 @@ QMap SalomeApp_Application::activateModuleActions() const */ void SalomeApp_Application::moduleActionSelected( const int id ) { + DBG_FUN(); + ARG(id); switch ( id ) { case LoadStudyId: onLoadDoc(); @@ -1404,6 +1458,7 @@ SALOME_LifeCycleCORBA* SalomeApp_Application::lcc() /*!Private SLOT. On preferences.*/ void SalomeApp_Application::onProperties() { + DBG_FUN(); SalomeApp_Study* study = dynamic_cast( activeStudy() ); if( !study ) return; @@ -1426,6 +1481,8 @@ void SalomeApp_Application::onProperties() /*!Insert items in popup, which necessary for current application*/ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title ) { + DBG_FUN(); + ARG(type); LightApp_SelectionMgr* mgr = selectionMgr(); bool cacheIsOn = mgr->isSelectionCacheEnabled(); mgr->setSelectionCacheEnabled( true ); @@ -1528,6 +1585,8 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop 3. update object browser if it exists */ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) { + DBG_FUN(); + ARG(updateModels); // update "non-existing" (not loaded yet) data models SalomeApp_Study* study = dynamic_cast(activeStudy()); if ( study ) @@ -1560,6 +1619,7 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) /*!Display Catalog Genenerator dialog */ void SalomeApp_Application::onCatalogGen() { + DBG_FUN(); ToolsGUI_CatalogGeneratorDlg aDlg( desktop() ); aDlg.exec(); } @@ -1567,6 +1627,7 @@ void SalomeApp_Application::onCatalogGen() /*!Display Registry Display dialog */ void SalomeApp_Application::onRegDisplay() { + DBG_FUN(); CORBA::ORB_var anOrb = orb(); ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop() ); regWnd->show(); @@ -1577,6 +1638,7 @@ void SalomeApp_Application::onRegDisplay() /*!find original object by double click on item */ void SalomeApp_Application::onDblClick( SUIT_DataObject* theObj ) { + DBG_FUN(); // Issue 21379: References are supported at LightApp_DataObject level LightApp_DataObject* obj = dynamic_cast( theObj ); @@ -1603,6 +1665,8 @@ void SalomeApp_Application::onDblClick( SUIT_DataObject* theObj ) */ SUIT_ViewManager* SalomeApp_Application::newViewManager(const QString& type) { + DBG_FUN(); + ARG(type); return createViewManager(type); } @@ -1628,6 +1692,7 @@ int getSelectedSavePoint( const LightApp_SelectionMgr* selMgr ) /*!Called on Restore GUI State popup command*/ void SalomeApp_Application::onRestoreGUIState() { + DBG_FUN(); int savePoint = ::getSelectedSavePoint( selectionMgr() ); if ( savePoint == -1 ) return; @@ -1637,6 +1702,7 @@ void SalomeApp_Application::onRestoreGUIState() /*!Called on Delete GUI State popup command*/ void SalomeApp_Application::onDeleteGUIState() { + DBG_FUN(); int savePoint = ::getSelectedSavePoint( selectionMgr() ); if ( savePoint == -1 ) return; @@ -1651,6 +1717,7 @@ void SalomeApp_Application::onDeleteGUIState() /*!Called on New study operation*/ void SalomeApp_Application::onStudyCreated( SUIT_Study* study ) { + DBG_FUN(); LightApp_Application::onStudyCreated( study ); //#ifndef DISABLE_PYCONSOLE @@ -1666,6 +1733,7 @@ void SalomeApp_Application::onStudyCreated( SUIT_Study* study ) /*!Called on Open study operation*/ void SalomeApp_Application::onStudyOpened( SUIT_Study* study ) { + DBG_FUN(); LightApp_Application::onStudyOpened( study ); //#ifndef DISABLE_PYCONSOLE @@ -1687,6 +1755,7 @@ void SalomeApp_Application::onStudyOpened( SUIT_Study* study ) /*! updateSavePointDataObjects: syncronize data objects that correspond to save points (gui states)*/ void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study ) { + DBG_FUN(); SUIT_DataBrowser* ob = objectBrowser(); LightApp_SelectionMgr* selMgr = selectionMgr(); @@ -1781,6 +1850,8 @@ bool SalomeApp_Application::checkDataObject(LightApp_DataObject* theObj) */ bool SalomeApp_Application::useStudy( const QString& theName ) { + DBG_FUN(); + ARG(theName); createEmptyStudy(); SalomeApp_Study* aStudy = dynamic_cast( activeStudy() ); bool res = false; @@ -1794,6 +1865,7 @@ bool SalomeApp_Application::useStudy( const QString& theName ) /*! Show/hide object browser colums according to preferences */ void SalomeApp_Application::objectBrowserColumnsVisibility() { + DBG_FUN(); if ( objectBrowser() ) for ( int i = SalomeApp_DataObject::EntryId; i < SalomeApp_DataObject::LastId; i++ ) { @@ -1806,6 +1878,7 @@ void SalomeApp_Application::objectBrowserColumnsVisibility() /*! Set SalomeApp_NoteBook pointer */ void SalomeApp_Application::setNoteBook( SalomeApp_NoteBook* theNoteBook ) { + DBG_FUN(); myNoteBook = theNoteBook; } @@ -1835,6 +1908,7 @@ SalomeApp_NoteBook* SalomeApp_Application::getNoteBook() const */ void SalomeApp_Application::createExtraActions() { + DBG_FUN(); myExtActions.clear(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -1872,6 +1946,7 @@ void SalomeApp_Application::createExtraActions() */ void SalomeApp_Application::onExtAction() { + DBG_FUN(); QAction* aAction = ::qobject_cast(sender()); if (!aAction) return; @@ -1925,6 +2000,8 @@ bool SalomeApp_Application::renameAllowed( const QString& entry) const */ bool SalomeApp_Application::renameObject( const QString& /*entry*/, const QString& name ) { + DBG_FUN(); + ARG(name); SalomeApp_Study* aStudy = dynamic_cast( activeStudy() ); int savePoint = ::getSelectedSavePoint( selectionMgr() ); @@ -1951,6 +2028,7 @@ bool SalomeApp_Application::renameObject( const QString& /*entry*/, const QStrin //============================================================================ void SalomeApp_Application::onUpdateStudy() { + DBG_FUN(); QApplication::setOverrideCursor( Qt::WaitCursor ); if( !updateStudy() ) @@ -1967,6 +2045,7 @@ void SalomeApp_Application::onUpdateStudy() //============================================================================ bool SalomeApp_Application::updateStudy() { + DBG_FUN(); SalomeApp_Study* study = dynamic_cast( activeStudy() ); if ( !study || !myNoteBook ) return false; @@ -2054,6 +2133,9 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript, const QString& theStudyName, bool theIsStudySaved ) { + DBG_FUN(); + ARG(theDumpScript); + ARG(theStudyName); bool ok = true; // create a new study @@ -2105,6 +2187,7 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript, */ void SalomeApp_Application::afterCloseDoc() { + DBG_FUN(); #ifndef DISABLE_PYCONSOLE // emit signal to restore study from Python script if ( myNoteBook ) { @@ -2118,6 +2201,7 @@ void SalomeApp_Application::afterCloseDoc() bool SalomeApp_Application::canOpenDoc( const QString& url ) { + DBG_FUN(); _PTR(Study) aStudyDS = getStudy(); if ( aStudyDS ) return aStudyDS->CanOpen( url.toUtf8().data() ); @@ -2137,6 +2221,7 @@ bool SalomeApp_Application::checkExistingDoc() PyConsole_Interp* SalomeApp_Application::createPyInterp() { + DBG_FUN(); return new SalomeApp_PyInterp( resourceMgr() ); } @@ -2144,6 +2229,7 @@ PyConsole_Interp* SalomeApp_Application::createPyInterp() void SalomeApp_Application::ensureShaperIsActivated() { + DBG_FUN(); SalomeApp_Study* study = dynamic_cast(activeStudy()); _PTR(Study) studyDS = getStudy(); if ( study && studyDS ) @@ -2162,6 +2248,9 @@ void SalomeApp_Application::ensureShaperIsActivated() void SalomeApp_Application::addCatalogue( const QString& moduleName, const QString& catalogue ) { + DBG_FUN(); + ARG(moduleName); + ARG(catalogue); CORBA::Object_var obj = namingService()->Resolve( "/Kernel/ModulCatalog" ); SALOME_ModuleCatalog::ModuleCatalog_var moduleCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow( obj ); QFileInfo fi( catalogue ); diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 18893bb9c..407573510 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -38,6 +38,12 @@ #include #include CORBA_SERVER_HEADER(SALOME_Exception) +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SalomeApp_DataModel" +#include "MBDebug.h" +//--------------------------------------------------------- + typedef _PTR(SObject) kerPtr; typedef SUIT_DataObject* suitPtr; @@ -75,6 +81,7 @@ SalomeApp_DataModelSync::SalomeApp_DataModelSync( _PTR( Study ) aStudy, SUIT_Dat : myStudy( aStudy ), myRoot( aRoot ) { + DBG_FUN(); } /*! @@ -82,6 +89,7 @@ SalomeApp_DataModelSync::SalomeApp_DataModelSync( _PTR( Study ) aStudy, SUIT_Dat */ bool SalomeApp_DataModelSync::isCorrect( const kerPtr& so ) const { + DBG_FUN(); #ifdef WITH_SALOMEDS_OBSERVER // with GUI observers this function is not needed anymore return true; @@ -110,6 +118,7 @@ suitPtr SalomeApp_DataModelSync::createItem( const kerPtr& so, const suitPtr& parent, const suitPtr& after ) const { + DBG_FUN(); if( !isCorrect( so ) ) return 0; @@ -133,6 +142,7 @@ suitPtr SalomeApp_DataModelSync::createItem( const kerPtr& so, */ void SalomeApp_DataModelSync::deleteItemWithChildren( const suitPtr& p ) const { + DBG_FUN(); if( !p ) return; @@ -183,6 +193,7 @@ suitPtr SalomeApp_DataModelSync::nullTrg() const */ QList SalomeApp_DataModelSync::children( const kerPtr& obj ) const { + DBG_FUN(); QList ch; _PTR( GenericAttribute ) anAttr; @@ -217,6 +228,7 @@ QList SalomeApp_DataModelSync::children( const kerPtr& obj ) const */ QList SalomeApp_DataModelSync::children( const suitPtr& p ) const { + DBG_FUN(); QList ch; if ( p ) ch = p->children(); @@ -238,6 +250,7 @@ suitPtr SalomeApp_DataModelSync::parent( const suitPtr& p ) const */ void SalomeApp_DataModelSync::updateItem( const kerPtr&, const suitPtr& ) const { + DBG_FUN(); } /*! @@ -264,6 +277,7 @@ void showTree( SUIT_DataObject* root ) SalomeApp_DataModel::SalomeApp_DataModel( CAM_Module* theModule ) : LightApp_DataModel( theModule ) { + DBG_FUN(); } /*! @@ -271,6 +285,7 @@ SalomeApp_DataModel::SalomeApp_DataModel( CAM_Module* theModule ) */ SalomeApp_DataModel::~SalomeApp_DataModel() { + DBG_FUN(); } /*! @@ -278,6 +293,8 @@ SalomeApp_DataModel::~SalomeApp_DataModel() */ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study, QStringList ) { + DBG_FUN(); + ARG(name); SalomeApp_Study* aDoc = dynamic_cast( study ); if ( !aDoc ) return false; @@ -300,6 +317,7 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study, QStringLi */ bool SalomeApp_DataModel::create( CAM_Study* theStudy ) { + DBG_FUN(); update(NULL, (LightApp_Study*)theStudy); return true; } @@ -309,6 +327,7 @@ bool SalomeApp_DataModel::create( CAM_Study* theStudy ) */ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) { + DBG_FUN(); SalomeApp_Study* aSStudy = dynamic_cast(study); LightApp_RootObject* studyRoot = 0; _PTR(SComponent) sobj; @@ -343,6 +362,7 @@ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) */ SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sobj, SalomeApp_Study* study ) { + DBG_FUNC(); if( !study || !study->root() || !sobj ) return 0; @@ -380,6 +400,7 @@ SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sob */ void SalomeApp_DataModel::updateTree( const _PTR( SComponent )& comp, SalomeApp_Study* study ) { + DBG_FUN(); SalomeApp_ModuleObject* aNewRoot = dynamic_cast( synchronize( comp, study ) ); if( aNewRoot ) { @@ -401,6 +422,7 @@ SalomeApp_Module* SalomeApp_DataModel::getModule() const */ SalomeApp_Study* SalomeApp_DataModel::getStudy() const { + DBG_FUN(); if(!root()) return 0; LightApp_RootObject* aRoot = dynamic_cast( root()->root() ); if ( !aRoot ) @@ -416,6 +438,7 @@ SalomeApp_Study* SalomeApp_DataModel::getStudy() const */ QString SalomeApp_DataModel::getRootEntry( SalomeApp_Study* study ) const { + DBG_FUN(); QString anEntry; if ( root() && root()->root() ) { // data model already in a study SalomeApp_DataObject* anObj = dynamic_cast( root() ); diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 7b53c2b5c..7786cb9c1 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -50,15 +50,23 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SalomeApp_Module" +#include "MBDebug.h" +//--------------------------------------------------------- + /*!Constructor.*/ SalomeApp_Module::SalomeApp_Module( const QString& name ) : LightApp_Module( name ) { + DBG_FUN(); } /*!Destructor.*/ SalomeApp_Module::~SalomeApp_Module() { + DBG_FUN(); } /*!Gets application.*/ @@ -70,12 +78,14 @@ SalomeApp_Application* SalomeApp_Module::getApp() const /*!Create new instance of data model and return it.*/ CAM_DataModel* SalomeApp_Module::createDataModel() { + DBG_FUN(); return new SalomeApp_DataModel(this); } /*!Create and return instance of LightApp_Selection.*/ LightApp_Selection* SalomeApp_Module::createSelection() const { + DBG_FUN(); return LightApp_Module::createSelection(); } @@ -87,6 +97,7 @@ LightApp_Selection* SalomeApp_Module::createSelection() const */ void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_ListIO& dest ) const { + DBG_FUN(); SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if( !study ) { @@ -137,6 +148,7 @@ void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_Li */ void SalomeApp_Module::storeVisualParameters(int /*savePoint*/) { + DBG_FUN(); } /*! @@ -147,4 +159,5 @@ void SalomeApp_Module::storeVisualParameters(int /*savePoint*/) */ void SalomeApp_Module::restoreVisualParameters(int /*savePoint*/) { + DBG_FUN(); } diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index c5a054551..349557c0b 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -60,6 +60,12 @@ #include #include CORBA_SERVER_HEADER(SALOME_Exception) +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SalomeApp_Study" +#include "MBDebug.h" +//--------------------------------------------------------- + //#define NOTIFY_BY_EVENT class ObserverEvent : public QEvent @@ -84,6 +90,7 @@ public: Observer_i( SalomeApp_Study* aStudy):QObject(aStudy) { + DBG_FUN(); myStudy=aStudy; fillEntryMap(); } @@ -96,6 +103,7 @@ public: virtual void notifyObserverID(const char* theID, CORBA::Long event) { + DBG_FUN(); #ifdef NOTIFY_BY_EVENT QCoreApplication::postEvent(this,new ObserverEvent(theID,event)); #else @@ -105,6 +113,7 @@ public: virtual bool event(QEvent *event) { + DBG_FUN(); if (event->type() == QEvent::User ) { //START_TIMING(notify); @@ -121,6 +130,7 @@ public: switch(event) { case 1: { //Add sobject + MSGEL("...Add SObject: theID=\"" << theID << "\", event=" << event); _PTR(SObject) aSObj = SalomeApp_Application::getStudy()->FindObjectID(theID); _PTR(SComponent) aSComp = aSObj->GetFatherComponent(); @@ -282,6 +292,7 @@ public: } case 2: { // Remove sobject + MSGEL("...Remove SObject: theID=\"" << theID << "\", event=" << event); EntryMapIter it = entry2SuitObject.find( theID ); if ( it != entry2SuitObject.end() ) { @@ -300,6 +311,7 @@ public: } case 0: { //modify sobject + MSGEL("...Modify SObject: theID=\"" << theID << "\", event=" << event); //MESSAGE("Want to modify an object " << theID); EntryMapIter it = entry2SuitObject.find( theID ); if ( it != entry2SuitObject.end() ) @@ -315,6 +327,7 @@ public: } case 5: //IOR of the object modified { + MSGEL("...IOR of SObject modified: theID=\"" << theID << "\", event=" << event); EntryMapIter it = entry2SuitObject.find( theID ); if ( it != entry2SuitObject.end() ) suit_obj = it->second; @@ -338,6 +351,7 @@ public: #ifndef DISABLE_PYCONSOLE case 6: //NoteBook variables were modified { + MSGEL("...NoteBook variable modified: theID=\"" << theID << "\", event=" << event); myStudy->onNoteBookVarUpdate( QString( theID.c_str() ) ); break; } @@ -349,6 +363,7 @@ public: private: void fillEntryMap() { + DBG_FUN(); entry2SuitObject.clear(); SUIT_DataObject* o = myStudy->root(); while (o) { @@ -391,6 +406,7 @@ private: SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) : LightApp_Study( app ), myObserver( 0 ) { + DBG_FUN(); myStudyDS = SalomeApp_Application::getStudy(); } @@ -399,6 +415,7 @@ SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) */ SalomeApp_Study::~SalomeApp_Study() { + DBG_FUN(); if ( myObserver ) { PortableServer::ObjectId_var oid = myObserver->_default_POA()->servant_to_id( myObserver ); myObserver->_default_POA()->deactivate_object( oid.in() ); @@ -409,6 +426,8 @@ SalomeApp_Study::~SalomeApp_Study() #ifndef DISABLE_PYCONSOLE void SalomeApp_Study::onNoteBookVarUpdate( QString theVarName) { + DBG_FUN(); + ARG(theVarName); emit notebookVarUpdated( theVarName ); } #endif @@ -418,6 +437,7 @@ void SalomeApp_Study::onNoteBookVarUpdate( QString theVarName) */ QString SalomeApp_Study::studyName() const { + DBG_FUN(); // redefined from SUIT_Study to update study name properly since // it can be changed outside of GUI // TEMPORARILY SOLUTION: better to be implemented with help of SALOMEDS observers @@ -447,6 +467,8 @@ _PTR(Study) SalomeApp_Study::studyDS() const */ bool SalomeApp_Study::createDocument( const QString& theStr ) { + DBG_FUN(); + ARG(theStr); MESSAGE( "createDocument" ); setStudyName( QString::fromUtf8(myStudyDS->URL().c_str()) ); @@ -477,6 +499,8 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) */ bool SalomeApp_Study::openDocument( const QString& theFileName ) { + DBG_FUN(); + ARG(theFileName); MESSAGE( "openDocument" ); // read HDF file @@ -547,6 +571,8 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) */ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) { + DBG_FUN(); + ARG(theStudyName); MESSAGE( "loadDocument" ); setRoot( new SalomeApp_RootObject( this ) ); // create myRoot @@ -597,6 +623,8 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) */ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { + DBG_FUN(); + ARG(theFileName); bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", false ); if ( store ) SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); @@ -641,6 +669,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) */ bool SalomeApp_Study::saveDocument() { + DBG_FUN(); bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); if ( store ) SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState(); @@ -683,6 +712,8 @@ bool SalomeApp_Study::saveDocument() */ void SalomeApp_Study::closeDocument(bool permanently) { + DBG_FUN(); + ARG(permanently); LightApp_Study::closeDocument(permanently); // close SALOMEDS document @@ -721,6 +752,8 @@ bool SalomeApp_Study::dump( const QString& theFileName, bool isMultiFile, bool toSaveGUI ) { + DBG_FUN(); + ARG(theFileName); int savePoint = 0; _PTR(AttributeParameter) ap; _PTR(IParameters) ip = ClientFactory::getIParameters(ap); @@ -792,6 +825,7 @@ bool SalomeApp_Study::isModified() const */ void SalomeApp_Study::Modified() { + DBG_FUN(); myStudyDS->Modified(); LightApp_Study::Modified(); } @@ -815,6 +849,9 @@ bool SalomeApp_Study::isSaved() const */ void SalomeApp_Study::saveModuleData( QString theModuleName, int type, QStringList theListOfFiles ) { + DBG_FUN(); + ARG(theModuleName); + ARG(type); int aNb = theListOfFiles.count(); if ( aNb == 0 ) return; @@ -837,6 +874,9 @@ void SalomeApp_Study::saveModuleData( QString theModuleName, int type, QStringLi */ void SalomeApp_Study::openModuleData( QString theModuleName, int type, QStringList& theListOfFiles ) { + DBG_FUN(); + ARG(theModuleName); + ARG(type); std::vector aListOfFiles = GetListOfFiles( theModuleName.toStdString().c_str(), type ); int i, aLength = (int)aListOfFiles.size() - 1; //!< TODO: conversion from size_t to int @@ -856,6 +896,7 @@ void SalomeApp_Study::openModuleData( QString theModuleName, int type, QStringLi */ bool SalomeApp_Study::saveStudyData( const QString& /*theFileName*/, int type ) { + DBG_FUN(); ModelList list; dataModels( list ); QListIterator it( list ); while ( it.hasNext() ){ @@ -874,6 +915,7 @@ bool SalomeApp_Study::saveStudyData( const QString& /*theFileName*/, int type ) */ bool SalomeApp_Study::openStudyData( const QString& /*theFileName*/, int /*type*/ ) { + DBG_FUN(); return true; } @@ -889,6 +931,7 @@ bool SalomeApp_Study::openStudyData( const QString& /*theFileName*/, int /*type* CAM_ModuleObject* SalomeApp_Study::createModuleObject( LightApp_DataModel* theDataModel, SUIT_DataObject* theParent ) const { + DBG_FUN(); SalomeApp_Study* that = const_cast( this ); // Ensure that SComponent instance is published in the study for the given module @@ -926,6 +969,7 @@ CAM_ModuleObject* SalomeApp_Study::createModuleObject( LightApp_DataModel* theDa */ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) { + DBG_FUN(); MESSAGE("SalomeApp_Study::dataModelInserted() : module name() = " << dm->module()->name().toStdString()); CAM_Study::dataModelInserted(dm); @@ -938,6 +982,7 @@ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) */ void SalomeApp_Study::addComponent(const CAM_DataModel* dm) { + DBG_FUN(); SalomeApp_Module* aModule = dynamic_cast( dm->module() ); // 1. aModule == 0 means that this is a light module (no CORBA enigine) if (!aModule) { @@ -985,6 +1030,8 @@ void SalomeApp_Study::addComponent(const CAM_DataModel* dm) */ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm ) { + DBG_FUN(); + ARG(studyName); if (!dm) return false; @@ -1058,6 +1105,9 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm */ std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleName, int type ) const { + DBG_FUN(); + ARG(theModuleName); + ARG(type); // Issue 21377 - using separate engine for each type of light module SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); if (aDefaultEngine) @@ -1077,6 +1127,9 @@ std::vector SalomeApp_Study::GetListOfFiles( const char* theModuleN void SalomeApp_Study::SetListOfFiles ( const char* theModuleName, int type, const std::vector theListOfFiles ) { + DBG_FUN(); + ARG(theModuleName); + ARG(type); // Issue 21377 - using separate engine for each type of light module SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false ); if (aDefaultEngine) @@ -1088,6 +1141,8 @@ void SalomeApp_Study::SetListOfFiles ( const char* theModuleName, int type, */ std::string SalomeApp_Study::GetTmpDir ( const char* theURL, const bool isMultiFile ) { + DBG_FUN(); + ARG(theURL); std::string anURLDir = SALOMEDS_Tool::GetDirFromPath(theURL); std::string aTmpDir = isMultiFile ? anURLDir : SALOMEDS_Tool::GetTmpDir(); return aTmpDir; @@ -1098,6 +1153,8 @@ std::string SalomeApp_Study::GetTmpDir ( const char* theURL, const bool isMulti */ void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, bool isMultiFile, bool force ) { + DBG_FUN(); + ARG(theModuleName); if (isMultiFile) return; @@ -1128,6 +1185,8 @@ void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, bool isM */ void SalomeApp_Study::updateFromNotebook( const QString& theFileName, bool isSaved ) { + DBG_FUN(); + ARG(theFileName); setStudyName(theFileName); studyDS()->URL(theFileName.toStdString()); setIsSaved( isSaved ); @@ -1136,6 +1195,8 @@ void SalomeApp_Study::updateFromNotebook( const QString& theFileName, bool isSav LightApp_DataObject* SalomeApp_Study::findObjectByEntry( const QString& theEntry ) { + DBG_FUN(); + ARG(theEntry); LightApp_DataObject* o = 0; if ( myObserver ) { o = dynamic_cast( myObserver->findObject( theEntry.toUtf8().constData() ) ); @@ -1152,6 +1213,7 @@ LightApp_DataObject* SalomeApp_Study::findObjectByEntry( const QString& theEntry */ void SalomeApp_Study::deleteReferencesTo( _PTR( SObject ) obj ) { + DBG_FUN(); _PTR(StudyBuilder) sb = studyDS()->NewBuilder(); std::vector<_PTR(SObject)> aRefs = studyDS()->FindDependances( obj ); for( size_t i=0, n=aRefs.size(); iFindObjectID( entry.toStdString() ); _PTR(SObject) refobj; @@ -1204,6 +1268,8 @@ bool SalomeApp_Study::isComponent( const QString& entry ) const */ void SalomeApp_Study::children( const QString& entry, QStringList& child_entries ) const { + DBG_FUN(); + ARG(entry); _PTR(SObject) SO = studyDS()->FindObjectID( entry.toStdString() ); _PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( SO ) ); anIter->InitEx( true ); @@ -1221,6 +1287,7 @@ void SalomeApp_Study::children( const QString& entry, QStringList& child_entries */ void SalomeApp_Study::components( QStringList& comps ) const { + DBG_FUN(); for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More(); it->Next() ) { _PTR(SComponent) aComponent ( it->Value() ); @@ -1237,6 +1304,8 @@ void SalomeApp_Study::components( QStringList& comps ) const */ QString SalomeApp_Study::centry( const QString& comp ) const { + DBG_FUN(); + ARG(comp); QString e; for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More() && e.isEmpty(); it->Next() ) { @@ -1244,6 +1313,7 @@ QString SalomeApp_Study::centry( const QString& comp ) const if ( aComponent && comp == aComponent->ComponentDataType().c_str() ) e = aComponent->GetID().c_str(); } + RET(e); return e; } @@ -1252,6 +1322,7 @@ QString SalomeApp_Study::centry( const QString& comp ) const */ std::vector SalomeApp_Study::getSavePoints() { + DBG_FUN(); std::vector v; _PTR(SObject) so = studyDS()->FindComponent( getVisualComponentName().toLatin1().constData() ); @@ -1274,6 +1345,8 @@ std::vector SalomeApp_Study::getSavePoints() */ void SalomeApp_Study::removeSavePoint(int savePoint) { + DBG_FUN(); + ARG(savePoint); if(savePoint <= 0) return; _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName().toLatin1().constData(), savePoint); _PTR(SObject) so = AP->GetSObject(); @@ -1296,6 +1369,9 @@ QString SalomeApp_Study::getNameOfSavePoint(int savePoint) */ void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint) { + DBG_FUN(); + ARG(savePoint); + ARG(nameOfSavePoint); _PTR(AttributeParameter) AP = studyDS()->GetCommonParameters(getVisualComponentName().toLatin1().constData(), savePoint); _PTR(IParameters) ip = ClientFactory::getIParameters(AP); ip->setProperty("AP_SAVEPOINT_NAME", nameOfSavePoint.toStdString()); @@ -1306,6 +1382,8 @@ void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSav */ void SalomeApp_Study::restoreState(int savePoint) { + DBG_FUN(); + ARG(savePoint); SalomeApp_VisualState((SalomeApp_Application*)application()).restoreState(savePoint); } @@ -1315,6 +1393,7 @@ void SalomeApp_Study::restoreState(int savePoint) */ void SalomeApp_Study::updateModelRoot( const CAM_DataModel* dm ) { + DBG_FUN(); LightApp_Study::updateModelRoot( dm ); // calling updateSavePointDataObjects in order to set correct order of "Gui states" object diff --git a/src/VTKViewer/MBDebug.h b/src/VTKViewer/MBDebug.h new file mode 100644 index 000000000..bde273ff5 --- /dev/null +++ b/src/VTKViewer/MBDebug.h @@ -0,0 +1,244 @@ +#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 MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (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 +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// 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) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << 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::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}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) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index 1c40f6601..8c054bb2d 100644 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -44,6 +44,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_Actor" +#include "MBDebug.h" +//--------------------------------------------------------- + #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -74,6 +80,7 @@ VTKViewer_Actor myIsPreselected(false), myIsHighlighted(false) { + DBG_FUN(); VTKViewer_Actor::GetDefaultPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); @@ -87,6 +94,7 @@ VTKViewer_Actor VTKViewer_Actor ::~VTKViewer_Actor() { + DBG_FUN(); SetPreviewProperty(NULL); myGeomFilter->Delete(); @@ -118,7 +126,9 @@ void VTKViewer_Actor ::setName(const char* theName) { + DBG_FUN(); myName = theName; + ARG(myName); } /*! @@ -128,6 +138,7 @@ void VTKViewer_Actor ::AddToRender(vtkRenderer* theRenderer) { + DBG_FUN(); theRenderer->AddActor(this); } @@ -138,6 +149,7 @@ void VTKViewer_Actor ::RemoveFromRender(vtkRenderer* theRenderer) { + DBG_FUN(); theRenderer->RemoveActor(this); } @@ -157,6 +169,7 @@ void VTKViewer_Actor ::SetTransform(VTKViewer_Transform* theTransform) { + DBG_FUN(); myTransformFilter->SetTransform(theTransform); } @@ -168,6 +181,7 @@ void VTKViewer_Actor ::SetMapper(vtkMapper* theMapper) { + DBG_FUN(); InitPipeLine(theMapper); } @@ -178,6 +192,7 @@ void VTKViewer_Actor ::InitPipeLine(vtkMapper* theMapper) { + DBG_FUN(); if(theMapper){ int anId = 0; myPassFilter[ anId ]->SetInputData( theMapper->GetInput() ); @@ -211,6 +226,9 @@ void VTKViewer_Actor ::Render(vtkRenderer *ren, vtkMapper* m) { + //DBG_FUN(); + MSGEL("...VTKViewer_Actor::Render()"); + if(vtkDataSet* aDataSet = GetInput()){ static double PERCENTS_OF_DETAILS = 0.50; vtkIdType aNbOfPoints = vtkIdType(aDataSet->GetNumberOfPoints()*PERCENTS_OF_DETAILS); @@ -244,6 +262,7 @@ void VTKViewer_Actor ::SetResolveCoincidentTopology(bool theIsResolve) { + DBG_FUN(); myIsResolveCoincidentTopology = theIsResolve; } @@ -256,6 +275,7 @@ VTKViewer_Actor ::SetPolygonOffsetParameters(double factor, double units) { + DBG_FUN(); myPolygonOffsetFactor = factor; myPolygonOffsetUnits = units; } @@ -367,6 +387,8 @@ void VTKViewer_Actor ::SetRepresentation(int theMode) { + DBG_FUN(); + ARG(theMode); using namespace VTKViewer::Representation; switch(myRepresentation){ case Points : @@ -502,6 +524,8 @@ void VTKViewer_Actor ::SetInfinitive(bool theIsInfinite) { + DBG_FUN(); + ARG(theIsInfinite); myIsInfinite = theIsInfinite; } @@ -581,6 +605,8 @@ void VTKViewer_Actor ::SetOpacity(double theOpacity) { + DBG_FUN(); + ARG(theOpacity); myOpacity = theOpacity; GetProperty()->SetOpacity(theOpacity); } @@ -602,6 +628,8 @@ VTKViewer_Actor double g, double b) { + DBG_FUN(); + MSGEL("RGB=(" << r << ", " << g << ", " << b << ")"); GetProperty()->SetColor(r,g,b); } @@ -612,6 +640,7 @@ void VTKViewer_Actor ::SetColor(const double theRGB[3]) { + MSGEL("RGB=(" << theRGB[0] << ", " << theRGB[1] << ", " << theRGB[2] << ")"); SetColor(theRGB[0],theRGB[1],theRGB[2]); } @@ -678,6 +707,8 @@ void VTKViewer_Actor ::setDisplayMode(int theMode) { + DBG_FUN(); + ARG(theMode); SetRepresentation(theMode + 1); myDisplayMode = GetRepresentation() - 1; } @@ -720,6 +751,7 @@ void VTKViewer_Actor ::SetPreSelected(bool thePreselect) { + //DBG_FUN(); myIsPreselected = thePreselect; } @@ -737,6 +769,7 @@ VTKViewer_Actor * On/Off representation 2D quadratic element as arked polygon */ void VTKViewer_Actor::SetQuadraticArcMode(bool theFlag){ + DBG_FUN(); myGeomFilter->SetQuadraticArcMode(theFlag); } @@ -750,6 +783,7 @@ bool VTKViewer_Actor::GetQuadraticArcMode() const{ * Set Max angle for representation 2D quadratic element as arked polygon */ void VTKViewer_Actor::SetQuadraticArcAngle(double theMaxAngle){ + DBG_FUN(); myGeomFilter->SetQuadraticArcAngle(theMaxAngle); } diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx index 52fb68958..ce86cf6ed 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.cxx +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -38,6 +38,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_AppendFilter" +#include "MBDebug.h" +//--------------------------------------------------------- + #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -49,17 +55,22 @@ vtkStandardNewMacro(VTKViewer_AppendFilter) VTKViewer_AppendFilter ::VTKViewer_AppendFilter() { + DBG_FUN(); myDoMappingFlag = false; } VTKViewer_AppendFilter ::~VTKViewer_AppendFilter() -{} +{ + DBG_FUN(); +} void VTKViewer_AppendFilter ::SetDoMappingFlag(const bool theFlag) { + DBG_FUN(); + ARG(theFlag); if(myDoMappingFlag == theFlag) return; @@ -79,6 +90,7 @@ void VTKViewer_AppendFilter ::SetSharedPointsDataSet(vtkPointSet* thePointsDataSet) { + DBG_FUN(); if(GetSharedPointsDataSet() == thePointsDataSet) return; @@ -101,6 +113,7 @@ VTKViewer_AppendFilter vtkInformationVector **inputVector, vtkInformationVector *outputVector) { + DBG_FUN(); int aRet = 0; if(GetSharedPointsDataSet()) aRet = MakeOutput(request,inputVector,outputVector); @@ -118,6 +131,7 @@ void VTKViewer_AppendFilter ::DoMapping() { + DBG_FUN(); myNodeRanges.clear(); myCellRanges.clear(); @@ -258,6 +272,7 @@ VTKViewer_AppendFilter vtkInformationVector **inputVector, vtkInformationVector *outputVector) { + DBG_FUN(); int idx; vtkIdType numPts, numCells, cellId; // vtkCellData *cd; @@ -333,6 +348,7 @@ VTKViewer_AppendFilter int VTKViewer_AppendFilter::FillInputPortInformation(int, vtkInformation *info) { + DBG_FUN(); info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet"); info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1); return 1; diff --git a/src/VTKViewer/VTKViewer_ArcBuilder.cxx b/src/VTKViewer/VTKViewer_ArcBuilder.cxx index aae0074f9..781a1fbbc 100644 --- a/src/VTKViewer/VTKViewer_ArcBuilder.cxx +++ b/src/VTKViewer/VTKViewer_ArcBuilder.cxx @@ -38,6 +38,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_ArcBuilder" +#include "MBDebug.h" +//--------------------------------------------------------- + #define PRECISION 10e-4 #define ANGLE_PRECISION 0.5 //#define _MY_DEBUG_ @@ -230,6 +236,7 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, myAngle(theAngle), myStatus(Arc_Error) { + DBG_FUN(); Vec V1(thePnt2.GetXYZ().X()-thePnt1.GetXYZ().X(), thePnt2.GetXYZ().Y()-thePnt1.GetXYZ().Y(), thePnt2.GetXYZ().Z()-thePnt1.GetXYZ().Z()); @@ -349,7 +356,9 @@ VTKViewer_ArcBuilder::VTKViewer_ArcBuilder(const Pnt& thePnt1, * Destructor */ VTKViewer_ArcBuilder::~VTKViewer_ArcBuilder() -{} +{ + DBG_FUN(); +} /* @@ -357,6 +366,7 @@ VTKViewer_ArcBuilder::~VTKViewer_ArcBuilder() */ vtkUnstructuredGrid* VTKViewer_ArcBuilder::BuildGrid(const PntList& theList) const { + DBG_FUN(); int aListsize = (int)theList.size(); //!< TODO: conversion from size_t to int vtkUnstructuredGrid* aGrid = NULL; @@ -392,6 +402,7 @@ vtkUnstructuredGrid* VTKViewer_ArcBuilder::TransformGrid(vtkUnstructuredGrid* theGrid, const Vec& theAxis, const double angle) const { + DBG_FUN(); vtkTransform *aTransform = vtkTransform::New(); aTransform->RotateWXYZ(angle, theAxis.GetXYZ().X(), theAxis.GetXYZ().Y(), theAxis.GetXYZ().Z()); vtkTransformFilter* aTransformFilter = vtkTransformFilter::New(); @@ -423,6 +434,7 @@ double InterpolateScalarValue(int index, int count, double firstValue, double mi vtkUnstructuredGrid* VTKViewer_ArcBuilder::BuildArc(std::vector& theScalarValues) { + DBG_FUN(); double x1 = myPnt1.GetXYZ().X(); double x2 = myPnt2.GetXYZ().X(); double x3 = myPnt3.GetXYZ().X(); double y1 = myPnt1.GetXYZ().Y(); double y2 = myPnt2.GetXYZ().Y(); double y3 = myPnt3.GetXYZ().Y(); double z = myPnt1.GetXYZ().Z(); //Points on plane || XOY diff --git a/src/VTKViewer/VTKViewer_CellCenters.cxx b/src/VTKViewer/VTKViewer_CellCenters.cxx index 12125e091..1414e1220 100644 --- a/src/VTKViewer/VTKViewer_CellCenters.cxx +++ b/src/VTKViewer/VTKViewer_CellCenters.cxx @@ -33,6 +33,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_CellCenters" +#include "MBDebug.h" +//--------------------------------------------------------- + vtkStandardNewMacro(VTKViewer_CellCenters) /*! @@ -46,6 +52,7 @@ vtkStandardNewMacro(VTKViewer_CellCenters) */ VTKViewer_CellCenters::VTKViewer_CellCenters() { + DBG_FUN(); } /*! @@ -56,6 +63,7 @@ int VTKViewer_CellCenters::RequestData( vtkInformationVector **inputVector, vtkInformationVector *outputVector) { + DBG_FUN(); // get the info objects vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); vtkInformation *outInfo = outputVector->GetInformationObject(0); diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index b857571df..787b9e143 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -43,6 +43,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_Triangulator" +#include "MBDebug.h" +//--------------------------------------------------------- + #ifdef _DEBUG_ static int DEBUG_TRIA_EXECUTE = 0; #else @@ -84,13 +90,16 @@ VTKViewer_Triangulator myPointIds(NULL), myFaceIds(vtkIdList::New()), myPoints(vtkPoints::New()) -{} +{ + DBG_FUN(); +} //---------------------------------------------------------------------------- VTKViewer_Triangulator ::~VTKViewer_Triangulator() { + DBG_FUN(); myCellIds->Delete(); myFaceIds->Delete(); myPoints->Delete(); @@ -103,6 +112,7 @@ VTKViewer_Triangulator ::InitPoints(vtkUnstructuredGrid *theInput, vtkIdType theCellId) { + DBG_FUN(); myPoints->Reset(); myPoints->Modified(); // the VTK bug @@ -205,6 +215,7 @@ VTKViewer_Triangulator std::vector< std::vector >& theDimension2VTK2ObjIds, bool theIsCheckConvex) { + DBG_FUN(); vtkPoints *aPoints = InitPoints(theInput, theCellId); vtkIdType aNumPts = GetNbOfPoints(); if(DEBUG_TRIA_EXECUTE) cout<<"Triangulator - aNumPts = "<Allocate(VTK_CELL_SIZE); myTriangulator->PreSortedOff(); } @@ -609,6 +622,7 @@ VTKViewer_OrderedTriangulator VTKViewer_OrderedTriangulator ::~VTKViewer_OrderedTriangulator() { + DBG_FUN(); myTriangle->Delete(); myBoundaryTris->Delete(); myTriangulator->Delete(); @@ -621,6 +635,7 @@ VTKViewer_OrderedTriangulator ::InitPoints(vtkUnstructuredGrid *theInput, vtkIdType theCellId) { + DBG_FUN(); myBoundaryTris->Reset(); vtkPoints* aPoints = VTKViewer_Triangulator::InitPoints(theInput, theCellId); @@ -688,6 +703,7 @@ VTKViewer_OrderedTriangulator } +#define MBCLASSNAME "VTKViewer_DelaunayTriangulator" //---------------------------------------------------------------------------- VTKViewer_DelaunayTriangulator ::VTKViewer_DelaunayTriangulator(): @@ -696,6 +712,7 @@ VTKViewer_DelaunayTriangulator myDelaunay3D(vtkDelaunay3D::New()), myPolyData(NULL) { + DBG_FUN(); myUnstructuredGrid->Initialize(); myUnstructuredGrid->Allocate(); myUnstructuredGrid->SetPoints(myPoints); @@ -710,6 +727,7 @@ VTKViewer_DelaunayTriangulator VTKViewer_DelaunayTriangulator ::~VTKViewer_DelaunayTriangulator() { + DBG_FUN(); myUnstructuredGrid->Delete(); myGeometryFilter->Delete(); myDelaunay3D->Delete(); @@ -722,6 +740,7 @@ VTKViewer_DelaunayTriangulator ::InitPoints(vtkUnstructuredGrid *theInput, vtkIdType theCellId) { + DBG_FUN(); vtkPoints* aPoints = VTKViewer_Triangulator::InitPoints(theInput, theCellId); myPoints->Modified(); diff --git a/src/VTKViewer/VTKViewer_DataSetMapper.cxx b/src/VTKViewer/VTKViewer_DataSetMapper.cxx index 4ffd3c270..dbf6f6e1e 100644 --- a/src/VTKViewer/VTKViewer_DataSetMapper.cxx +++ b/src/VTKViewer/VTKViewer_DataSetMapper.cxx @@ -23,11 +23,18 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_DataSetMapper" +#include "MBDebug.h" +//--------------------------------------------------------- + vtkStandardNewMacro(VTKViewer_DataSetMapper) //---------------------------------------------------------------------------- VTKViewer_DataSetMapper::VTKViewer_DataSetMapper() { + DBG_FUN(); this->MarkerEnabled = false; this->BallEnabled = false; this->BallScale = 1; @@ -39,11 +46,13 @@ VTKViewer_DataSetMapper::VTKViewer_DataSetMapper() //---------------------------------------------------------------------------- VTKViewer_DataSetMapper::~VTKViewer_DataSetMapper() { + DBG_FUN(); } //---------------------------------------------------------------------------- void VTKViewer_DataSetMapper::Render(vtkRenderer *ren, vtkActor *act) { + DBG_FUN(); // just to create VTKViewer_PolyDataMapper instead of vtkPolyDataMapper if( this->PolyDataMapper == NULL ) { @@ -68,6 +77,7 @@ void VTKViewer_DataSetMapper::Render(vtkRenderer *ren, vtkActor *act) //----------------------------------------------------------------------------- void VTKViewer_DataSetMapper::SetMarkerEnabled( bool theMarkerEnabled ) { + DBG_FUN(); this->MarkerEnabled = theMarkerEnabled; if( this->PolyDataMapper ) if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast( this->PolyDataMapper ) ) @@ -78,6 +88,7 @@ void VTKViewer_DataSetMapper::SetMarkerEnabled( bool theMarkerEnabled ) //----------------------------------------------------------------------------- void VTKViewer_DataSetMapper::SetBallEnabled( bool theBallEnabled ) { + DBG_FUN(); this->BallEnabled = theBallEnabled; if( this->PolyDataMapper ) if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast( this->PolyDataMapper ) ) @@ -87,6 +98,7 @@ void VTKViewer_DataSetMapper::SetBallEnabled( bool theBallEnabled ) //----------------------------------------------------------------------------- void VTKViewer_DataSetMapper::SetBallScale( double theBallScale ) { + DBG_FUN(); this->BallScale = theBallScale; if( this->PolyDataMapper ) if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast( this->PolyDataMapper ) ) @@ -96,6 +108,7 @@ void VTKViewer_DataSetMapper::SetBallScale( double theBallScale ) //---------------------------------------------------------------------------- void VTKViewer_DataSetMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale ) { + DBG_FUN(); this->MarkerType = theMarkerType; this->MarkerScale = theMarkerScale; if( this->PolyDataMapper ) @@ -106,6 +119,7 @@ void VTKViewer_DataSetMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK:: //---------------------------------------------------------------------------- void VTKViewer_DataSetMapper::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture ) { + DBG_FUN(); this->MarkerType = VTK::MT_USER; this->MarkerId = theMarkerId; this->MarkerTexture = theMarkerTexture; diff --git a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx index 0cc0d1883..23c0dbd26 100644 --- a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx +++ b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx @@ -39,6 +39,12 @@ #include "utilities.h" +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_ExtractUnstructuredGrid" +#include "MBDebug.h" +//--------------------------------------------------------- + #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -52,14 +58,20 @@ vtkStandardNewMacro(VTKViewer_ExtractUnstructuredGrid) VTKViewer_ExtractUnstructuredGrid::VTKViewer_ExtractUnstructuredGrid(): myExtractionMode(eCells), myChangeMode(ePassAll), myStoreMapping( false ), myPassAll( false ) -{} +{ + DBG_FUN(); +} VTKViewer_ExtractUnstructuredGrid::~VTKViewer_ExtractUnstructuredGrid() -{} +{ + DBG_FUN(); +} void VTKViewer_ExtractUnstructuredGrid::RegisterCell(vtkIdType theCellId) { + DBG_FUN(); + ARG2(theCellId, long); if ( myCellIds.insert(theCellId).second ) Modified(); } @@ -67,6 +79,8 @@ void VTKViewer_ExtractUnstructuredGrid::RegisterCell(vtkIdType theCellId) void VTKViewer_ExtractUnstructuredGrid::RegisterCellsWithType(vtkIdType theCellType) { + DBG_FUN(); + ARG2(theCellType, long); if ( myCellTypes.insert(theCellType).second ) Modified(); } @@ -74,6 +88,8 @@ void VTKViewer_ExtractUnstructuredGrid::RegisterCellsWithType(vtkIdType theCellT void VTKViewer_ExtractUnstructuredGrid::SetStoreMapping(int theStoreMapping) { + DBG_FUN(); + ARG(theStoreMapping); if ( myStoreMapping != ( theStoreMapping != 0 )) { myStoreMapping = theStoreMapping != 0; @@ -93,6 +109,7 @@ vtkIdType VTKViewer_ExtractUnstructuredGrid::GetInputId(vtkIdType theOutId) cons void VTKViewer_ExtractUnstructuredGrid::BuildOut2InMap() { + DBG_FUN(); if ( myPassAll || !myOut2InId.empty() ) return; vtkUnstructuredGrid *anInput = dynamic_cast< vtkUnstructuredGrid*>( this->GetInput() ); @@ -293,6 +310,7 @@ inline vtkIdType InsertCell(vtkUnstructuredGrid *theInput, VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId/*, VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId*/) { + //DBG_FUNC(); vtkCell *aCell = theInput->GetCell(theCellId); vtkIdType aCellType = aCell->GetCellType(); vtkIdType aCellId = -1; @@ -350,6 +368,7 @@ inline void InsertPointCell(vtkCellArray *theConnectivity, VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId/*, VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId*/) { + //DBG_FUNC(); theIdList->SetId(0,theCellId); theConnectivity->InsertNextCell(theIdList); theCellTypesArray->InsertNextValue(VTK_VERTEX); @@ -364,6 +383,7 @@ int VTKViewer_ExtractUnstructuredGrid::RequestData(vtkInformation *vtkNotUsed(re vtkInformationVector **inputVector, vtkInformationVector *outputVector) { + DBG_FUN(); // get the info objects vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); vtkInformation *outInfo = outputVector->GetInformationObject(0); diff --git a/src/VTKViewer/VTKViewer_Filter.cxx b/src/VTKViewer/VTKViewer_Filter.cxx index 2acbfdab5..6e5d019bb 100644 --- a/src/VTKViewer/VTKViewer_Filter.cxx +++ b/src/VTKViewer/VTKViewer_Filter.cxx @@ -26,6 +26,12 @@ #include "VTKViewer_Filter.h" +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_Filter" +#include "MBDebug.h" +//--------------------------------------------------------- + IMPLEMENT_STANDARD_RTTIEXT(VTKViewer_Filter, Standard_Transient) /*! @@ -37,12 +43,14 @@ IMPLEMENT_STANDARD_RTTIEXT(VTKViewer_Filter, Standard_Transient) /*!Constructor.*/ VTKViewer_Filter::VTKViewer_Filter() { + DBG_FUN(); myActor = 0; } /*!Virtual Destructor.*/ VTKViewer_Filter::~VTKViewer_Filter() { + DBG_FUN(); } /*!Check correctness of \a theCellId for actor \a theActor by @@ -62,5 +70,7 @@ bool VTKViewer_Filter::IsValid( VTKViewer_Actor* theActor, const vtkIdType theCe */ void VTKViewer_Filter::SetActor( VTKViewer_Actor* theActor ) { + DBG_FUN(); + ARG2(theActor, void*); myActor = theActor; } diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index b038c3206..385420787 100644 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -59,6 +59,12 @@ #include "utilities.h" +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_GeometryFilter" +#include "MBDebug.h" +//--------------------------------------------------------- + #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -105,6 +111,7 @@ VTKViewer_GeometryFilter myMaxArcAngle(2), myIsBuildArc(false) { + DBG_FUN(); static int forceDelegateToVtk = -1; if ( forceDelegateToVtk < 0 ) { @@ -117,7 +124,9 @@ VTKViewer_GeometryFilter VTKViewer_GeometryFilter ::~VTKViewer_GeometryFilter() -{} +{ + DBG_FUN(); +} /*! * \brief Return true for only one volume including a given edge @@ -170,6 +179,7 @@ struct vtkExcludedFaces // computed in vtkGeometryFilter::UnstructuredGridExecute) and original cell ids (mesh cells) void VTKViewer_GeometryFilter ::FillVTK2ObjIds(vtkPolyData *output) { + DBG_FUN(); vtkDataArray* vtkOriginalCellIds = output->GetCellData()->GetArray("vtkOriginalCellIds"); @@ -192,6 +202,7 @@ VTKViewer_GeometryFilter vtkInformationVector **inputVector, vtkInformationVector *outputVector) { + DBG_FUN(); // get the info objects vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); @@ -309,8 +320,9 @@ int VTKViewer_GeometryFilter ::UnstructuredGridExecute(vtkDataSet *dataSetInput, vtkPolyData *output, - vtkInformation */*outInfo*/) + vtkInformation * /*outInfo*/) { + DBG_FUN(); vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput; vtkCellArray *Connectivity = input->GetCells(); // Check input @@ -1361,6 +1373,7 @@ VTKViewer_GeometryFilter TVectorId& /*theVTK2ObjIds*/, TMapOfVectorId& theDimension2VTK2ObjIds ) { + //DBG_FUNC(); //theVTK2ObjIds.push_back( theCellId ); int aDimension = 0; @@ -1391,6 +1404,8 @@ void VTKViewer_GeometryFilter ::SetInside(int theShowInside) { + DBG_FUN(); + ARG(theShowInside); if(myShowInside == theShowInside) return; @@ -1410,6 +1425,8 @@ void VTKViewer_GeometryFilter ::SetWireframeMode(int theIsWireframeMode) { + DBG_FUN(); + ARG(theIsWireframeMode); if(myIsWireframeMode == theIsWireframeMode) return; @@ -1429,6 +1446,8 @@ void VTKViewer_GeometryFilter ::SetStoreMapping(int theStoreMapping) { + DBG_FUN(); + ARG(theStoreMapping); if(myStoreMapping == theStoreMapping) return; @@ -1458,6 +1477,7 @@ void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId, TMapOfVectorId& theDimension2VTK2ObjIds, bool triangulate) { + DBG_FUN(); vtkIdType aCellType = VTK_POLYGON; vtkIdType *aNewPoints = NULL; vtkIdType aNbPoints = 0; @@ -1640,6 +1660,8 @@ void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId, void VTKViewer_GeometryFilter::SetQuadraticArcMode(bool theFlag) { + DBG_FUN(); + ARG(theFlag); if(myIsBuildArc != theFlag) { myIsBuildArc = theFlag; this->Modified(); @@ -1652,6 +1674,8 @@ bool VTKViewer_GeometryFilter::GetQuadraticArcMode() const void VTKViewer_GeometryFilter::SetQuadraticArcAngle(double theMaxAngle) { + DBG_FUN(); + ARG(theMaxAngle); if(myMaxArcAngle != theMaxAngle) { myMaxArcAngle = theMaxAngle; this->Modified(); @@ -1674,6 +1698,8 @@ int VTKViewer_GeometryFilter::GetAppendCoincident3D() const { } void VTKViewer_GeometryFilter::SetAppendCoincident3D(int theFlag) { + DBG_FUN(); + ARG(theFlag); if(myAppendCoincident3D != theFlag){ myAppendCoincident3D = theFlag; this->Modified(); diff --git a/src/VTKViewer/VTKViewer_OpenGLRenderer.cxx b/src/VTKViewer/VTKViewer_OpenGLRenderer.cxx index 1d4091556..e715f96d5 100644 --- a/src/VTKViewer/VTKViewer_OpenGLRenderer.cxx +++ b/src/VTKViewer/VTKViewer_OpenGLRenderer.cxx @@ -47,10 +47,17 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_OpenGLRenderer" +#include "MBDebug.h" +//--------------------------------------------------------- + vtkStandardNewMacro(VTKViewer_OpenGLRenderer) VTKViewer_OpenGLRenderer::VTKViewer_OpenGLRenderer() { + DBG_FUN(); this->GradientType = HorizontalGradient; #ifdef VTK_OPENGL2 @@ -65,10 +72,12 @@ VTKViewer_OpenGLRenderer::VTKViewer_OpenGLRenderer() VTKViewer_OpenGLRenderer::~VTKViewer_OpenGLRenderer() { + DBG_FUN(); } void VTKViewer_OpenGLRenderer::SetGradientType( const int theGradientType ) { + DBG_FUN(); this->GradientType = theGradientType; } @@ -161,6 +170,8 @@ void VTKViewer_OpenGLRenderer::GetCornersColor(Vec2D& cornersColor) void VTKViewer_OpenGLRenderer::Clear(void) { + MSGEL("...VTKViewer_OpenGLRenderer::Clear()"); + vtkOpenGLRenderer::Clear(); #ifdef VTK_OPENGL2 if (this->OpenGLHelper.IsInitialized()) diff --git a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx index c0a4fe207..487931d8a 100644 --- a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx +++ b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx @@ -46,6 +46,12 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_PolyDataMapper" +#include "MBDebug.h" +//--------------------------------------------------------- + #ifndef WIN32 # ifndef GLX_GLXEXT_LEGACY # define GLX_GLXEXT_LEGACY @@ -120,6 +126,7 @@ void MessageCallback( GLenum /*source*/, //----------------------------------------------------------------------------- VTKViewer_PolyDataMapper::VTKViewer_PolyDataMapper() { + DBG_FUN(); Q_INIT_RESOURCE( VTKViewer ); this->ExtensionsInitialized = ES_None; @@ -149,6 +156,7 @@ VTKViewer_PolyDataMapper::VTKViewer_PolyDataMapper() //----------------------------------------------------------------------------- VTKViewer_PolyDataMapper::~VTKViewer_PolyDataMapper() { + DBG_FUN(); if( PointSpriteTexture > 0 ) glDeleteTextures( 1, &PointSpriteTexture ); @@ -160,6 +168,7 @@ VTKViewer_PolyDataMapper::~VTKViewer_PolyDataMapper() //----------------------------------------------------------------------------- int VTKViewer_PolyDataMapper::InitShader() { + DBG_FUN(); #ifdef VTK_OPENGL2 #if defined(WIN32) && defined(UNICODE) std::wstring wFilePath = std::wstring(_wgetenv(L"GUI_ROOT_DIR")) + L"/share/salome/resources/gui/Point"; @@ -212,6 +221,8 @@ int VTKViewer_PolyDataMapper::InitShader() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::SetMarkerEnabled( bool theMarkerEnabled ) { + DBG_FUN(); + ARG(theMarkerEnabled); if( this->MarkerEnabled == theMarkerEnabled ) return; @@ -225,6 +236,10 @@ namespace VTK { //---------------------------------------------------------------------------- vtkSmartPointer MakeTexture( const char* theMainTexture, const char* theAlphaTexture ) { + DBG_FUNC(); + ARG(theMainTexture); + ARG(theAlphaTexture); + if( !theMainTexture || !theAlphaTexture ) return 0; @@ -285,6 +300,7 @@ bool VTKViewer_PolyDataMapper::GetBallEnabled() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::SetBallEnabled( bool theBallEnabled ) { + DBG_FUN(); if( this->BallEnabled == theBallEnabled ) return; else @@ -317,6 +333,8 @@ double VTKViewer_PolyDataMapper::GetBallScale() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::SetBallScale( double theBallScale ) { + DBG_FUN(); + ARG(theBallScale); if( this->BallScale == theBallScale ) return; this->BallScale = theBallScale; @@ -325,6 +343,7 @@ void VTKViewer_PolyDataMapper::SetBallScale( double theBallScale ) //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale ) { + DBG_FUN(); if( this->MarkerType == theMarkerType && this->MarkerScale == theMarkerScale ) return; @@ -357,6 +376,7 @@ void VTKViewer_PolyDataMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK: //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture ) { + DBG_FUN(); if( this->MarkerType == VTK::MT_USER && this->MarkerId == theMarkerId ) return; @@ -391,6 +411,7 @@ int VTKViewer_PolyDataMapper::GetMarkerTexture() //----------------------------------------------------------------------------- int VTKViewer_PolyDataMapper::InitExtensions() { + DBG_FUN(); #ifdef VTK_OPENGL2 int n = 0; std::ostringstream strm; @@ -420,6 +441,7 @@ int VTKViewer_PolyDataMapper::InitExtensions() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::InitPointSprites() { + DBG_FUN(); glEnable( GL_POINT_SPRITE_ARB ); glEnable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB ); @@ -444,6 +466,7 @@ void VTKViewer_PolyDataMapper::InitPointSprites() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::CleanupPointSprites() { + DBG_FUN(); glPopAttrib(); glDisable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB ); @@ -453,6 +476,7 @@ void VTKViewer_PolyDataMapper::CleanupPointSprites() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::InitTextures() { + DBG_FUN(); if( !this->ImageData.GetPointer() ) return; @@ -490,6 +514,7 @@ void VTKViewer_PolyDataMapper::InitTextures() //----------------------------------------------------------------------------- void VTKViewer_PolyDataMapper::RenderPiece( vtkRenderer* ren, vtkActor* act ) { + DBG_FUN(); bool isUsePointSprites = (this->MarkerEnabled && this->MarkerType != VTK::MT_NONE) || this->BallEnabled; if( isUsePointSprites ) @@ -818,6 +843,7 @@ namespace VTK //----------------------------------------------------------------------------- int VTKViewer_PolyDataMapper::Draw( vtkRenderer* ren, vtkActor* act ) { + DBG_FUN(); int noAbort = 1; if( (!this->MarkerEnabled || this->MarkerType == VTK::MT_NONE || !this->ImageData.GetPointer()) && !this->BallEnabled) return MAPPER_SUPERCLASS::Draw( ren, act ); @@ -844,6 +870,7 @@ void VTKViewer_PolyDataMapper::RenderPieceDraw( vtkRenderer* ren, vtkActor* act #endif void VTKViewer_PolyDataMapper::InternalDraw(vtkRenderer* ren, vtkActor* act ) { + DBG_FUN(); vtkUnsignedCharArray* colors = NULL; vtkPolyData* input = this->GetInput(); vtkPoints* points; diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index 61499c944..b1af3d1b2 100644 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -36,6 +36,12 @@ #include #endif +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_RenderWindow" +#include "MBDebug.h" +//--------------------------------------------------------- + /*!Constructor. Create render window with parant \a parent and name \a name. *\param parent - parent window *\param name - render window name. @@ -43,6 +49,7 @@ VTKViewer_RenderWindow::VTKViewer_RenderWindow(QWidget* parent, const char* name) : QWidget(parent, Qt::FramelessWindowHint ) { + DBG_FUN(); setObjectName( name ); setAttribute( Qt::WA_DeleteOnClose ); @@ -58,6 +65,7 @@ QWidget(parent, Qt::FramelessWindowHint ) /*!Destructor.*/ VTKViewer_RenderWindow::~VTKViewer_RenderWindow() { + DBG_FUN(); myRW->Delete(); } @@ -70,7 +78,9 @@ void VTKViewer_RenderWindow::paintEvent(QPaintEvent* /*theEvent*/) /*!Resize render window.*/ void VTKViewer_RenderWindow::resizeEvent(QResizeEvent* /*theEvent*/) { + DBG_FUN(); int aWidth = myRW->GetSize()[0], aHeight = myRW->GetSize()[1]; + MSGEL("size = " << aWidth << " x " << aHeight); if(vtkRenderWindowInteractor* aRWI = myRW->GetInteractor()) aRWI->UpdateSize(width(), height()); if(aWidth != width() || aHeight != height()){ @@ -140,6 +150,7 @@ void VTKViewer_RenderWindow::wheelEvent(QWheelEvent* event) /*!Reaction on change background color.*/ void VTKViewer_RenderWindow::onChangeBackgroundColor() { + DBG_FUN(); //float red, green, blue; double backint[3]; @@ -162,6 +173,7 @@ void VTKViewer_RenderWindow::onChangeBackgroundColor() /*!Emit content menu requested.*/ void VTKViewer_RenderWindow::contextMenuEvent ( QContextMenuEvent * e ) { + DBG_FUN(); if ( e->reason() != QContextMenuEvent::Mouse ) emit contextMenuRequested( e ); } diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index 6629447e1..3f4218e80 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -54,9 +54,16 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_RenderWindowInteractor" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Create new instance of VTKViewer_RenderWindowInteractor*/ VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() { + DBG_FUNC(); vtkObject *ret = vtkObjectFactory::CreateInstance("VTKViewer_RenderWindowInteractor") ; if( ret ) { return dynamic_cast(ret) ; @@ -67,6 +74,7 @@ VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() /*!Constructor.*/ VTKViewer_RenderWindowInteractor::VTKViewer_RenderWindowInteractor() { + DBG_FUN(); this->Enabled = 0 ; this->mTimer = new QTimer( this ) ; myDisplayMode = 0; @@ -99,6 +107,7 @@ VTKViewer_RenderWindowInteractor::VTKViewer_RenderWindowInteractor() /*!Destructor.*/ VTKViewer_RenderWindowInteractor::~VTKViewer_RenderWindowInteractor() { + DBG_FUN(); delete mTimer ; if ( GetRenderWindow() ) { @@ -141,6 +150,7 @@ void VTKViewer_RenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) */ void VTKViewer_RenderWindowInteractor::Initialize() { + DBG_FUN(); // // We cannot do much unless there is a render window // associated with this interactor. @@ -194,6 +204,7 @@ void VTKViewer_RenderWindowInteractor::Initialize() /*!Sets view window and add to it selection actors.*/ void VTKViewer_RenderWindowInteractor::setViewWindow(VTKViewer_ViewWindow* theViewWnd){ + DBG_FUN(); myViewWnd = theViewWnd; if ( myViewWnd ) { @@ -206,6 +217,7 @@ void VTKViewer_RenderWindowInteractor::setViewWindow(VTKViewer_ViewWindow* theVi /*!Move selection actors to view window.*/ void VTKViewer_RenderWindowInteractor::MoveInternalActors() { + DBG_FUN(); myViewWnd->MoveActor(myCellActor); myViewWnd->MoveActor(myEdgeActor); myViewWnd->MoveActor(myPointActor); @@ -213,6 +225,7 @@ void VTKViewer_RenderWindowInteractor::MoveInternalActors() /*!Sets interactor style.*/ void VTKViewer_RenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver *theInteractor){ + DBG_FUN(); myInteractorStyle = dynamic_cast(theInteractor); vtkRenderWindowInteractor::SetInteractorStyle(theInteractor); } @@ -226,6 +239,7 @@ void VTKViewer_RenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver void VTKViewer_RenderWindowInteractor::SetSelectionProp(const double& theRed, const double& theGreen, const double& theBlue, const int& theWidth) { + DBG_FUN(); myCellActor->GetProperty()->SetColor(theRed, theGreen, theBlue); myCellActor->GetProperty()->SetLineWidth(theWidth); @@ -239,6 +253,7 @@ void VTKViewer_RenderWindowInteractor::SetSelectionProp(const double& theRed, co */ void VTKViewer_RenderWindowInteractor::SetSelectionTolerance(const double& theTolNodes, const double& theTolItems) { + DBG_FUN(); myTolNodes = theTolNodes; myTolItems = theTolItems; @@ -259,6 +274,7 @@ void VTKViewer_RenderWindowInteractor::SetSelectionTolerance(const double& theTo */ void VTKViewer_RenderWindowInteractor::Enable() { + DBG_FUN(); // // Do not need to do anything if already enabled. // @@ -273,6 +289,7 @@ void VTKViewer_RenderWindowInteractor::Enable() /*!See Enable().*/ void VTKViewer_RenderWindowInteractor::Disable() { + DBG_FUN(); if( ! this->Enabled ) { return ; } @@ -288,6 +305,7 @@ void VTKViewer_RenderWindowInteractor::Disable() */ void VTKViewer_RenderWindowInteractor::Start() { + DBG_FUN(); // // We do not allow this interactor to control the // event loop. Only the QtApplication objects are @@ -392,6 +410,7 @@ void VTKViewer_RenderWindowInteractor::LeftButtonPressed(const QMouseEvent *even *If render window enabled. */ void VTKViewer_RenderWindowInteractor::LeftButtonReleased(const QMouseEvent *event) { + DBG_FUN(); if( ! this->Enabled ) { return ; } @@ -418,6 +437,7 @@ void VTKViewer_RenderWindowInteractor::MiddleButtonPressed(const QMouseEvent *ev *If render window enabled. */ void VTKViewer_RenderWindowInteractor::MiddleButtonReleased(const QMouseEvent *event) { + DBG_FUN(); if( ! this->Enabled ) { return ; } @@ -444,6 +464,7 @@ void VTKViewer_RenderWindowInteractor::RightButtonPressed(const QMouseEvent *eve *Emit context menu requested, if interactor style state equal VTK_INTERACTOR_STYLE_CAMERA_NONE. */ void VTKViewer_RenderWindowInteractor::RightButtonReleased(const QMouseEvent *event) { + DBG_FUN(); if( ! this->Enabled ) { return ; } @@ -480,6 +501,7 @@ int VTKViewer_RenderWindowInteractor::GetDisplayMode() { /*!Sets display mode.*/ void VTKViewer_RenderWindowInteractor::SetDisplayMode(int theMode) { + DBG_FUN(); if(theMode == 0) ChangeRepresentationToWireframe(); else if (theMode == 1) @@ -494,6 +516,7 @@ void VTKViewer_RenderWindowInteractor::SetDisplayMode(int theMode) { /*!Change all actors to wireframe*/ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe() { + DBG_FUN(); using namespace VTK; ActorCollectionCopy aCopy(GetRenderer()->GetActors()); ChangeRepresentationToWireframe(aCopy.GetActors()); @@ -502,6 +525,7 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe() /*!Change all actors to surface*/ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface() { + DBG_FUN(); using namespace VTK; ActorCollectionCopy aCopy(GetRenderer()->GetActors()); ChangeRepresentationToSurface(aCopy.GetActors()); @@ -510,6 +534,7 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface() /*!Change all actors to surface with edges*/ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurfaceWithEdges() { + DBG_FUN(); using namespace VTK; ActorCollectionCopy aCopy(GetRenderer()->GetActors()); ChangeRepresentationToSurfaceWithEdges(aCopy.GetActors()); @@ -520,6 +545,7 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurfaceWithEdges() */ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe(vtkActorCollection* theCollection) { + DBG_FUN(); using namespace VTK; ForEach(theCollection, TSetFunction @@ -532,6 +558,7 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe(vtkActorC */ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCollection* theCollection) { + DBG_FUN(); using namespace VTK; ForEach(theCollection, TSetFunction @@ -544,6 +571,7 @@ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCol */ void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* theCollection) { + DBG_FUN(); using namespace VTK; ForEach(theCollection, TSetFunction @@ -562,6 +590,7 @@ vtkRenderer* VTKViewer_RenderWindowInteractor::GetRenderer() /*!Do nothing*/ void VTKViewer_RenderWindowInteractor::EraseAll() { + DBG_FUN(); } /*!Display all actors. @@ -569,6 +598,7 @@ void VTKViewer_RenderWindowInteractor::EraseAll() */ void VTKViewer_RenderWindowInteractor::DisplayAll() { + DBG_FUN(); using namespace VTK; ActorCollectionCopy aCopy(GetRenderer()->GetActors()); ForEach(aCopy.GetActors(),TSetVisibility(true)); @@ -579,11 +609,13 @@ void VTKViewer_RenderWindowInteractor::DisplayAll() /*!Do nothing*/ void VTKViewer_RenderWindowInteractor::Erase( VTKViewer_Actor* /*SActor*/, bool /*update*/) { + DBG_FUN(); } /*!Remove \a SActor from renderer and emit update window, if \a updateViewer - true*/ void VTKViewer_RenderWindowInteractor::Remove( VTKViewer_Actor* SActor, bool updateViewer ) { + DBG_FUN(); if ( SActor != 0 ) { GetRenderer()->RemoveViewProp( SActor ); @@ -597,6 +629,7 @@ void VTKViewer_RenderWindowInteractor::Remove( VTKViewer_Actor* SActor, bool upd */ void VTKViewer_RenderWindowInteractor::RemoveAll( const bool updateViewer ) { + DBG_FUN(); using namespace VTK; vtkRenderer* aRenderer = GetRenderer(); ActorCollectionCopy aCopy(aRenderer->GetActors()); @@ -622,6 +655,7 @@ void VTKViewer_RenderWindowInteractor::RemoveAll( const bool updateViewer ) */ void VTKViewer_RenderWindowInteractor::Display( VTKViewer_Actor* theActor, bool update) { + DBG_FUN(); GetRenderer()->AddActor(theActor); theActor->SetVisibility(true); @@ -647,6 +681,7 @@ struct TUpdateAction{ /*!Update all actors from renderer and emit render window modified.*/ void VTKViewer_RenderWindowInteractor::Update() { + DBG_FUN(); using namespace VTK; vtkRenderer* aRen = GetRenderer(); ActorCollectionCopy aCopy(aRen->GetActors()); @@ -707,6 +742,7 @@ void VTKViewer_RenderWindowInteractor::setActorData(const TIndexedMapOfVtkId& th VTKViewer_Actor * theActor, TUpdateActor theFun) { + DBG_FUN(); (*theFun)(theMapIndex,theMapActor,theActor); double aPos[3]; theMapActor->GetPosition(aPos); diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index 8fc6451db..29879ba1c 100644 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -32,11 +32,18 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_Utilities" +#include "MBDebug.h" +//--------------------------------------------------------- + /*!@see vtkRenderer::ResetCamera(double bounds[6]) method*/ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint) -{ +{ + DBG_FUNC(); if(!theRenderer) return; @@ -109,6 +116,7 @@ int ComputeVisiblePropBounds(vtkRenderer* theRenderer, double theBounds[6]) { + DBG_FUNC(); VTK::ActorCollectionCopy aCopy(theRenderer->GetActors()); vtkActorCollection* aCollection = aCopy.GetActors(); return ComputeBounds( aCollection, theBounds ); @@ -118,6 +126,7 @@ ComputeVisiblePropBounds(vtkRenderer* theRenderer, int ComputeBounds(vtkActorCollection* theCollection, double theBounds[6]) { + DBG_FUNC(); int aCount = 0; theBounds[0] = theBounds[2] = theBounds[4] = VTK_FLOAT_MAX; @@ -176,6 +185,7 @@ ComputeBounds(vtkActorCollection* theCollection, double theBounds[6]) void ResetCameraClippingRange(vtkRenderer* theRenderer) { + DBG_FUNC(); if(!theRenderer || !theRenderer->VisibleActorCount()) return; vtkCamera* anActiveCamera = theRenderer->GetActiveCamera(); @@ -221,6 +231,7 @@ ComputeTrihedronSize( vtkRenderer* theRenderer, const double theSize, const double theSizeInPercents ) { + DBG_FUNC(); // calculating diagonal of visible props of the renderer double bnd[ 6 ]; if ( ComputeVisiblePropBounds( theRenderer, bnd ) == 0 ) @@ -244,6 +255,7 @@ ComputeTrihedronSize( vtkRenderer* theRenderer, bool IsBBEmpty(vtkRenderer* theRenderer) { + DBG_FUNC(); if(!theRenderer) return false; @@ -286,6 +298,8 @@ bool isBoundValid(double* theBounds) { bool ComputeBBCenter(vtkRenderer* theRenderer, double theCenter[3]) { + //DBG_FUNC(); + MSGEL("...ComputeBBCenter()"); theCenter[0] = theCenter[1] = theCenter[2] = 0.0; if(!theRenderer) diff --git a/src/VTKViewer/VTKViewer_ViewManager.cxx b/src/VTKViewer/VTKViewer_ViewManager.cxx index 60a44b36b..33e488943 100644 --- a/src/VTKViewer/VTKViewer_ViewManager.cxx +++ b/src/VTKViewer/VTKViewer_ViewManager.cxx @@ -23,17 +23,25 @@ #include "VTKViewer_ViewManager.h" #include "VTKViewer_ViewModel.h" +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_ViewManager" +#include "MBDebug.h" +//--------------------------------------------------------- + /*!Constructor.Initialize SIUT_ViewManager by \a study and \a theDesktop. * Create new instance of VTKViewer_Viewer and set view model by it. */ VTKViewer_ViewManager::VTKViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop ) : SUIT_ViewManager( study, theDesktop, new VTKViewer_Viewer() ) { + DBG_FUN(); setTitle( tr( "VTK_VIEW_TITLE" ) ); } /*!Destructor.*/ VTKViewer_ViewManager::~VTKViewer_ViewManager() { + DBG_FUN(); /*!Do nothing.*/ } diff --git a/src/VTKViewer/VTKViewer_ViewModel.cxx b/src/VTKViewer/VTKViewer_ViewModel.cxx index 027dd0da6..1c1569ae8 100644 --- a/src/VTKViewer/VTKViewer_ViewModel.cxx +++ b/src/VTKViewer/VTKViewer_ViewModel.cxx @@ -35,11 +35,18 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_Viewer" +#include "MBDebug.h" +//--------------------------------------------------------- + // VSR: Uncomment below line to allow texture background support in VTK viewer #define VTK_ENABLE_TEXTURED_BACKGROUND bool _InitializeVtkWarningsCall() { + DBG_FUNC(); char* isOn = getenv( "VTK_WARNINGS_IS_ON" ); if ( !isOn || strcmp( isOn, "1" ) ) vtkObject::GlobalWarningDisplayOff(); @@ -54,16 +61,19 @@ VTKViewer_Viewer::VTKViewer_Viewer() : SUIT_ViewModel(), myDefaultBackground( Qtx::BackgroundData( Qt::black ) ) { + DBG_FUN(); } /*!Destructor.*/ VTKViewer_Viewer::~VTKViewer_Viewer() { + DBG_FUN(); } /*! Get data for supported background modes: gradient types, identifiers and supported image formats */ QString VTKViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList ) { + DBG_FUNC(); gradList << tr( "GT_HORIZONTALGRADIENT" ) << tr( "GT_VERTICALGRADIENT" ) << tr( "GT_FIRSTDIAGONALGRADIENT" ) @@ -95,6 +105,7 @@ QColor VTKViewer_Viewer::backgroundColor() const /*!Sets background color [obsolete]*/ void VTKViewer_Viewer::setBackgroundColor( const QColor& c ) { + DBG_FUN(); Qtx::BackgroundData bg = background(); bg.setColor( c ); setBackground( bg ); @@ -109,12 +120,14 @@ Qtx::BackgroundData VTKViewer_Viewer::background() const /*!Sets default background data.*/ void VTKViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground ) { + DBG_FUN(); myDefaultBackground = theBackground.isValid() ? theBackground : Qtx::BackgroundData( Qt::black ); } /*!Create new instance of VTKViewer_ViewWindow, sets background color and return pointer to it.*/ SUIT_ViewWindow* VTKViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { + DBG_FUN(); VTKViewer_ViewWindow* vw = new VTKViewer_ViewWindow( theDesktop, this ); vw->setBackground( myDefaultBackground ); return vw; @@ -123,6 +136,7 @@ SUIT_ViewWindow* VTKViewer_Viewer::createView( SUIT_Desktop* theDesktop ) /*!Sets view manager and connect slots.*/ void VTKViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager) { + DBG_FUN(); SUIT_ViewModel::setViewManager(theViewManager); connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); @@ -137,6 +151,7 @@ void VTKViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager) /*!Insert context into popup menu.*/ void VTKViewer_Viewer::contextMenuPopup(QMenu* thePopup) { + DBG_FUN(); thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) ); @@ -208,6 +223,8 @@ void VTKViewer_Viewer::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) /*!Sets flag to enable selection \a isEnable.*/ void VTKViewer_Viewer::enableSelection(bool isEnabled) { + DBG_FUN(); + ARG(isEnabled); mySelectionEnabled = isEnabled; //!! To be done for view windows } @@ -215,6 +232,8 @@ void VTKViewer_Viewer::enableSelection(bool isEnabled) /*!Sets flag to multi selection enable \a isEnable.*/ void VTKViewer_Viewer::enableMultiselection(bool isEnable) { + DBG_FUN(); + ARG(isEnable); myMultiSelectionEnabled = isEnable; //!! To be done for view windows } @@ -230,6 +249,7 @@ void VTKViewer_Viewer::onDumpView() /*!On change back ground color event.*/ void VTKViewer_Viewer::onChangeBackground() { + DBG_FUN(); VTKViewer_ViewWindow* aView = (VTKViewer_ViewWindow*)(myViewManager->getActiveView()); if ( !aView ) return; @@ -258,6 +278,7 @@ void VTKViewer_Viewer::onChangeBackground() /*!On show tool bar event.*/ void VTKViewer_Viewer::onShowToolbar() { + DBG_FUN(); VTKViewer_ViewWindow* aView = (VTKViewer_ViewWindow*)(myViewManager->getActiveView()); if ( aView ) aView->getToolBar()->show(); diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index 0a02c85f5..0f710a24f 100644 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -51,6 +51,12 @@ #include #include +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "VTKViewer_ViewWindow" +#include "MBDebug.h" +//--------------------------------------------------------- + /*! Construction*/ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, VTKViewer_Viewer* theModel, @@ -58,6 +64,8 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, VTKViewer_RenderWindowInteractor* rw ) : SUIT_ViewWindow( theDesktop ) { + DBG_FUN(); + myModel = theModel; myTrihedron = VTKViewer_Trihedron::New(); @@ -129,6 +137,7 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, /*!Destructor.*/ VTKViewer_ViewWindow::~VTKViewer_ViewWindow() { + DBG_FUN(); myTransform->Delete(); // In order to ensure that the interactor unregisters // this RenderWindow, we assign a NULL RenderWindow to @@ -175,12 +184,14 @@ void VTKViewer_ViewWindow::activateGlobalPanning() /*!Activates 'fit area' transformation*/ void VTKViewer_ViewWindow::activateWindowFit() { + DBG_FUN(); myRWInteractor->GetInteractorStyle()->startFitArea(); } /*!Create actions:*/ void VTKViewer_ViewWindow::createActions() { + DBG_FUN(); if (!myActionsMap.isEmpty()) return; SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -317,6 +328,7 @@ void VTKViewer_ViewWindow::createActions() /*!Create tool bar.*/ void VTKViewer_ViewWindow::createToolBar() { + DBG_FUN(); myToolBar->addAction( myActionsMap[DumpId] ); myToolBar->addAction( myActionsMap[TrihedronShowId] ); @@ -352,6 +364,7 @@ void VTKViewer_ViewWindow::createToolBar() /*!On front view event.*/ void VTKViewer_ViewWindow::onFrontView() { + DBG_FUN(); vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition(1,0,0); camera->SetViewUp(0,0,1); @@ -362,6 +375,7 @@ void VTKViewer_ViewWindow::onFrontView() /*!On back view slot.*/ void VTKViewer_ViewWindow::onBackView() { + DBG_FUN(); vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition(-1,0,0); camera->SetViewUp(0,0,1); @@ -372,6 +386,7 @@ void VTKViewer_ViewWindow::onBackView() /*!On back view slot.*/ void VTKViewer_ViewWindow::onTopView() { + DBG_FUN(); vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition(0,0,1); camera->SetViewUp(0,1,0); @@ -382,6 +397,7 @@ void VTKViewer_ViewWindow::onTopView() /*!On bottom view slot.*/ void VTKViewer_ViewWindow::onBottomView() { + DBG_FUN(); vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition(0,0,-1); camera->SetViewUp(0,1,0); @@ -392,6 +408,7 @@ void VTKViewer_ViewWindow::onBottomView() /*!On left view slot.*/ void VTKViewer_ViewWindow::onLeftView() { + DBG_FUN(); vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition(0,-1,0); camera->SetViewUp(0,0,1); @@ -402,6 +419,7 @@ void VTKViewer_ViewWindow::onLeftView() /*!On right view slot.*/ void VTKViewer_ViewWindow::onRightView() { + DBG_FUN(); vtkCamera* camera = myRenderer->GetActiveCamera(); camera->SetPosition(0,1,0); camera->SetViewUp(0,0,1); @@ -414,6 +432,7 @@ void VTKViewer_ViewWindow::onRightView() */ void VTKViewer_ViewWindow::onClockWiseView() { + DBG_FUN(); vtkCamera* aCamera = myRenderer->GetActiveCamera(); aCamera->Roll(-90); aCamera->OrthogonalizeViewUp(); @@ -425,6 +444,7 @@ void VTKViewer_ViewWindow::onClockWiseView() */ void VTKViewer_ViewWindow::onAntiClockWiseView() { + DBG_FUN(); vtkCamera* aCamera = myRenderer->GetActiveCamera(); aCamera->Roll(90); aCamera->OrthogonalizeViewUp(); @@ -434,6 +454,7 @@ void VTKViewer_ViewWindow::onAntiClockWiseView() /*!On reset view slot.*/ void VTKViewer_ViewWindow::onResetView() { + DBG_FUN(); int aTriedronIsVisible = isTrihedronDisplayed(); myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn ); ::ResetCamera(myRenderer,true); @@ -451,6 +472,7 @@ void VTKViewer_ViewWindow::onResetView() /*!On fit all slot.*/ void VTKViewer_ViewWindow::onFitAll() { + DBG_FUN(); myRWInteractor->GetInteractorStyle()->ViewFitAll(); Repaint(); } @@ -458,6 +480,7 @@ void VTKViewer_ViewWindow::onFitAll() /*!On fit selection slot.*/ void VTKViewer_ViewWindow::onFitSelection() { + DBG_FUN(); myRWInteractor->GetInteractorStyle()->ViewFitSelection(); Repaint(); } @@ -465,6 +488,7 @@ void VTKViewer_ViewWindow::onFitSelection() /*!Set background color of the viewport [obsolete]*/ void VTKViewer_ViewWindow::setBackgroundColor( const QColor& c ) { + DBG_FUN(); Qtx::BackgroundData bg = background(); bg.setColor( c ); setBackground( bg ); @@ -479,6 +503,7 @@ QColor VTKViewer_ViewWindow::backgroundColor() const /*!Set background of the viewport*/ void VTKViewer_ViewWindow::setBackground( const Qtx::BackgroundData& bgData ) { + DBG_FUN(); bool ok = false; if ( bgData.isValid() ) { @@ -721,6 +746,7 @@ void VTKViewer_ViewWindow::onMouseDoubleClicked( QMouseEvent* event ) *Move Internal actors, if \a theMoveInternalActors is true. */ void VTKViewer_ViewWindow::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors ){ + DBG_FUN(); theActor->AddToRender(myRenderer); theActor->SetTransform(myTransform); if(theMoveInternalActors) @@ -731,6 +757,7 @@ void VTKViewer_ViewWindow::InsertActor( VTKViewer_Actor* theActor, bool theMoveI *@see InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors ) */ void VTKViewer_ViewWindow::AddActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ ){ + DBG_FUN(); InsertActor(theActor); if(theUpdate) Repaint(); @@ -738,6 +765,7 @@ void VTKViewer_ViewWindow::AddActor( VTKViewer_Actor* theActor, bool theUpdate / /*!Remove \a theActor from renderer and pepaint, if \a theUpdate is true.*/ void VTKViewer_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ ){ + DBG_FUN(); theActor->RemoveFromRender(myRenderer); if(theUpdate) Repaint(); @@ -746,6 +774,7 @@ void VTKViewer_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, bool theUpdat /*!@see RemoveActor() and InsertActor().*/ void VTKViewer_ViewWindow::MoveActor( VTKViewer_Actor* theActor) { + DBG_FUN(); RemoveActor(theActor); InsertActor(theActor,true); } @@ -753,6 +782,7 @@ void VTKViewer_ViewWindow::MoveActor( VTKViewer_Actor* theActor) /*!On trihedron show slot.*/ void VTKViewer_ViewWindow::onTrihedronShow() { + DBG_FUN(); if (isTrihedronDisplayed()) myTrihedron->VisibilityOff(); else @@ -791,6 +821,7 @@ QString VTKViewer_ViewWindow::getVisualParameters() */ void VTKViewer_ViewWindow::setVisualParameters( const QString& parameters ) { + DBG_FUN(); QStringList paramsLst = parameters.split( '*' ); if ( paramsLst.size() == 13 ) { double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];