From 218f969afcab817217d1cb456400ed9d88c742fc Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 30 Mar 2012 15:18:14 +0200 Subject: [PATCH] Add GetToolCreatorFromName --- vv/vvToolManager.cxx | 24 ++++++++++++++++++++++++ vv/vvToolManager.h | 6 ++++++ 2 files changed, 30 insertions(+) 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 -- 2.47.1