1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
19 #include "vvToolCreatorBase.h"
20 #include "vvToolManager.h"
24 //------------------------------------------------------------------------------
25 vvToolCreatorBase::vvToolCreatorBase(QString name): mExperimental(false)
27 mUseContextMenu = false;
29 vvToolManager::GetInstance()->AddTool(this);
31 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 void vvToolCreatorBase::MenuToolSlot()
36 mSender = QObject::sender();
37 MenuSpecificToolSlot();
39 //------------------------------------------------------------------------------
42 //------------------------------------------------------------------------------
43 void vvToolCreatorBase::InsertToolInMenu(vvMainWindowBase * m)
46 if (mUseContextMenu) {
47 InsertToolInContextMenu();
51 if (mToolIconFilename == "noicon")
52 mAction = new QAction(QString("&").append(mToolMenuName), this);
54 mAction = new QAction(QIcon(mToolIconFilename),
55 QString("&").append(mToolMenuName), this);
56 mAction->setStatusTip(mToolTip);
58 connect(mAction, SIGNAL(triggered()), this, SLOT(MenuToolSlot()));
60 mMainWindow->GetExperimentalToolMenu()->addAction(mAction);
62 mMainWindow->GetToolMenu()->addAction(mAction);
64 //------------------------------------------------------------------------------
67 //------------------------------------------------------------------------------
68 void vvToolCreatorBase::InsertToolInContextMenu()
70 mMainWindow->GetContextMenu()->addMenu(mToolMenu);
71 for(unsigned int i=0; i<mListOfActions.size(); i++) {
72 connect(mListOfActions[i], SIGNAL(triggered()), this, SLOT(MenuToolSlot()));
75 //------------------------------------------------------------------------------
78 //------------------------------------------------------------------------------
79 void vvToolCreatorBase::addMenuToContextMenu(QMenu * m)
82 for(int i=0; i<m->actions().size(); i++) {
83 mListOfActions.push_back(m->actions()[i]);
85 mUseContextMenu = true;
87 //------------------------------------------------------------------------------