1 /*=========================================================================
4 Module: $RCSfile: vvToolBase.h,v $
6 Date: $Date: 2010/01/29 13:54:37 $
7 Version: $Revision: 1.1 $
8 Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS http://www.creatis.insa-lyon.fr
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.
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.
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/>.
26 =========================================================================*/
31 #include "vvToolCreatorBase.h"
32 #include "vvToolInputSelectorWidget.h"
33 #include "clitkImageToImageGenericFilter.h"
35 //------------------------------------------------------------------------------
36 template<class ToolType>
39 static void Initialize(); // can't be virtual, must be overwritten
40 void UpdateInfoFromMainWindow();
41 vvMainWindowToolInfo * mMainWindowToolInfo;
43 static void SetToolName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolName = n; }
44 static void SetToolMenuName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolMenuName = n; }
45 static void SetToolIconFilename(QString n) { vvToolCreator<ToolType>::mSingleton->mToolIconFilename = n; }
46 static void SetToolTip(QString n) { vvToolCreator<ToolType>::mSingleton->mToolTip = n; }
48 void InitializeListOfInputImages();
49 void InitializeListOfInputImages(vvToolInputSelectorWidget * w,
50 clitk::ImageToImageGenericFilterBase * f);
51 std::vector<vvSlicerManager*> mSlicerManagersCompatible;
52 unsigned int mCurrentIndex;
54 vvImage::Pointer mCurrentImage;
55 vvSlicerManager * mCurrentSliceManager;
56 clitk::ImageToImageGenericFilterBase * mFilter;
59 //------------------------------------------------------------------------------
62 //------------------------------------------------------------------------------
63 template<class ToolType>
64 void vvToolBase<ToolType>::UpdateInfoFromMainWindow() {
65 mMainWindowToolInfo = vvToolCreator<ToolType>::mSingleton->mMainWindow->GetInfoForTool();
67 //------------------------------------------------------------------------------
70 //------------------------------------------------------------------------------
71 template<class ToolType>
72 void vvToolBase<ToolType>::Initialize() {
73 SetToolName("Unnamed tool");
74 SetToolMenuName("Unnamed tool");
75 SetToolIconFilename("");
76 SetToolTip("Unamed tool.");
78 //------------------------------------------------------------------------------
81 //------------------------------------------------------------------------------
82 template<class ToolType>
83 void vvToolBase<ToolType>::InitializeListOfInputImages(vvToolInputSelectorWidget * w,
84 clitk::ImageToImageGenericFilterBase * f) {
86 InitializeListOfInputImages();
87 w->Initialize(mSlicerManagersCompatible, mCurrentIndex);
88 w->SetToolTip(mFilter->GetAvailableImageTypes().c_str());
90 //------------------------------------------------------------------------------
92 //------------------------------------------------------------------------------
93 template<class ToolType>
94 void vvToolBase<ToolType>::InitializeListOfInputImages() {
95 UpdateInfoFromMainWindow();
97 std::vector<vvSlicerManager*> & mSlicerManagers = *mMainWindowToolInfo->mSlicerManagers;
98 mCurrentIndex = mMainWindowToolInfo->mSlicerManagerCurrentIndex;
101 // HERE : Check if image is ok (dimension, type etc ...)
104 mFilter->PrintAvailableImageTypes();
108 /// if not set, do not check filter type
109 std::cerr << "*** ERROR, set mFilter member in the vvTool class before calling InitializeListOfInputImages" << std::endl;
113 //unsigned int previousIndex = mInputSequenceBox->mCurrentIndex();
114 mSlicerManagersCompatible.clear();
115 // mInputSequenceBox->clear();
116 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
118 vvImage * image = mSlicerManagers[i]->GetImage();
120 if ((mFilter->CheckDimension(image->GetNumberOfDimensions()) &&
121 mFilter->CheckPixelType(image->GetScalarTypeAsString()))) {
122 mSlicerManagersCompatible.push_back(mSlicerManagers[i]);
123 if (mCurrentIndex == i) {
124 mCurrentIndex = mSlicerManagersCompatible.size()-1;
128 std::cerr << mSlicerManagers[i]->GetFileName().c_str() << " not compatible image" << std::endl;
129 if (mCurrentIndex == i) {
135 //------------------------------------------------------------------------------