]> Creatis software - clitk.git/blob - vv/vvToolCreatorBase.h
- binarize tool
[clitk.git] / vv / vvToolCreatorBase.h
1 /*=========================================================================
2
3   Program:   vv
4   Module:    $RCSfile: vvToolCreatorBase.h,v $
5   Language:  C++
6   Date:      $Date: 2010/01/29 13:54:37 $
7   Version:   $Revision: 1.1 $
8   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
9
10   Copyright (C) 2008
11   Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12   CREATIS-LRMN http://www.creatis.insa-lyon.fr
13
14   This program is free software: you can redistribute it and/or modify
15   it under the terms of the GNU General Public License as published by
16   the Free Software Foundation, version 3 of the License.
17
18   This program is distributed in the hope that it will be useful,
19   but WITHOUT ANY WARRANTY; without even the implied warranty of
20   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21   GNU General Public License for more details.
22
23   You should have received a copy of the GNU General Public License
24   along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
26   =========================================================================*/
27
28 #ifndef VVTOOLCREATORBASE_H
29 #define VVTOOLCREATORBASE_H
30
31 #include "clitkCommon.h"
32 #include <QObject>
33
34 // For vvMainWindowToolInfo
35 #include "vvMainWindow.h"
36 class vvMainWindow;
37 // struct vvMainWindowToolInfo;
38 class QAction;
39
40 //------------------------------------------------------------------------------
41 class vvToolCreatorBase: public QObject {
42   Q_OBJECT
43   public:
44
45   vvToolCreatorBase(QString name);
46   virtual ~vvToolCreatorBase() {;}
47   
48   virtual void Initialize(vvMainWindow * m);
49   virtual void UpdateEnabledTool();
50   template<class ToolType> void CreateTool();
51   virtual void MenuSpecificToolSlot() = 0;
52   
53   QString mToolName;
54   QString mToolMenuName;
55   QString mToolIconFilename;
56   QString mToolTip;
57   QAction * mAction;
58
59   vvMainWindow * mMainWindow;
60
61 public slots:
62   virtual void MenuToolSlot() { MenuSpecificToolSlot(); }
63 };
64 //------------------------------------------------------------------------------
65
66 //------------------------------------------------------------------------------
67 template<class ToolType>
68 class vvToolCreator: public vvToolCreatorBase {
69 public:
70   vvToolCreator(QString name):vvToolCreatorBase(name) {;}
71   virtual void Initialize(vvMainWindow * m);
72   static vvToolCreator<ToolType> * mSingleton;
73   virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
74 };
75 //------------------------------------------------------------------------------
76
77
78 //------------------------------------------------------------------------------
79 #define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
80 //------------------------------------------------------------------------------
81
82
83 //------------------------------------------------------------------------------
84 #define ADD_TOOL(NAME)                                          \
85   template<>                                                    \
86   vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton =       \
87     new vvToolCreator<NAME>(#NAME);
88 //------------------------------------------------------------------------------
89
90 #include "vvToolCreatorBase.txx"
91
92 #endif
93