From: David Sarrut Date: Fri, 30 Mar 2012 13:18:14 +0000 (+0200) Subject: Add GetToolCreatorFromName X-Git-Tag: v1.3.0~52^2~10 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=218f969afcab817217d1cb456400ed9d88c742fc;p=clitk.git Add GetToolCreatorFromName --- diff --git a/vv/vvToolManager.cxx b/vv/vvToolManager.cxx index 01835f8..4c64057 100644 --- a/vv/vvToolManager.cxx +++ b/vv/vvToolManager.cxx @@ -65,3 +65,27 @@ void vvToolManager::EnableToolsInMenu(vvMainWindowBase * m, bool enable){ } } } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolCreatorBase * vvToolManager::GetToolCreatorFromName(QString toolTypeName) +{ + std::vector & v = vvToolManager::GetInstance()->GetListOfTools(); + int index=-1; + for(uint i=0; imToolName.toStdString()); + if (v[i]->mToolName == toolTypeName) { + index = i; + } + } + if (index == -1) { + std::cerr << "Error, ToolCreator named '" << toolTypeName.toStdString() + << "' does not exist. Abort." << std::endl; + return NULL; + } + return v[index]; +} +//------------------------------------------------------------------------------ + + diff --git a/vv/vvToolManager.h b/vv/vvToolManager.h index 82d2e5b..26b99c0 100644 --- a/vv/vvToolManager.h +++ b/vv/vvToolManager.h @@ -21,6 +21,8 @@ class vvToolCreatorBase; class vvMainWindowBase; +class QString; +class vvToolBaseBase; //------------------------------------------------------------------------------ // Manage a list of ToolCreator. Each tool will be automagically @@ -43,6 +45,10 @@ public: /// Called in MainWindow, make the tools enabled/disabled static void EnableToolsInMenu(vvMainWindowBase * m, bool enable); + std::vector & GetListOfTools() { return mListOfTools; } + + vvToolCreatorBase * GetToolCreatorFromName(QString toolTypeName); + protected: /// Singleton object pointer