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://www.centreleonberard.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 ===========================================================================*/
18 /*=========================================================================
21 Module: $RCSfile: vvToolMIP.cxx,v $
23 Date: $Date: 2011/04/15 08:29:21 $
24 Version: $Revision: 1.3 $
25 Author : Bharath Navalpakkam (Bharath.Navalpakkam@creatis.insa-lyon.fr)
28 Léon Bérard cancer center http://www.centreleonberard.fr
29 CREATIS http://www.creatis.insa-lyon.fr
31 This program is free software: you can redistribute it and/or modify
32 it under the terms of the GNU General Public License as published by
33 the Free Software Foundation, version 3 of the License.
35 This program is distributed in the hope that it will be useful,
36 but WITHOUT ANY WARRANTY; without even the implied warranty of
37 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 GNU General Public License for more details.
40 You should have received a copy of the GNU General Public License
41 along with this program. If not, see <http://www.gnu.org/licenses/>.
43 =========================================================================*/
45 #include <QMessageBox>
48 #include <itkMaximumProjectionImageFilter.h>
50 #include "vvToolMIP.h"
51 #include "vvSlicerManager.h"
53 #include "vvToolInputSelectorWidget.h"
54 #include "clitkMIPGenericFilter.h"
56 //------------------------------------------------------------------------------
57 // Create the tool and automagically
59 //------------------------------------------------------------------------------
61 //------------------------------------------------------------------------------
62 vvToolMIP::vvToolMIP(vvMainWindowBase * parent, Qt::WindowFlags f)
63 :vvToolWidgetBase(parent,f),
64 vvToolBase<vvToolMIP>(parent),
68 Ui_vvToolMIP::setupUi(mToolWidget);
69 //mFilter=clitk::MIPGenericFilter::New(); //Causes a segfault. Why? (joel 26/10/2010)
70 mFilter=new clitk::MIPGenericFilter;
73 // Set how many inputs are needed for this tool
74 //AddInputSelector("Select one image", mFilter);
75 AddInputSelector("Select one image");
78 //------------------------------------------------------------------------------
79 vvToolMIP::~vvToolMIP()
82 //------------------------------------------------------------------------------
83 void vvToolMIP::Initialize()
86 SetToolMenuName("Maximum Intensity Projection");
87 SetToolIconFilename(":common/icons/mip.png");
88 SetToolTip("Compute the maximum intensity projection of an image.");
89 SetToolExperimental(false);
91 //------------------------------------------------------------------------------
93 void vvToolMIP::apply()
95 if (!mCurrentSlicerManager) close();
96 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
98 clitk::MIPGenericFilter::args_info_type args_info;
99 cmdline_parser_clitkMIP_init(&args_info);
100 args_info.dimension_arg=this->dimensionSpinBox->value();
101 args_info.dimension_given=true;
102 clitk::MIPGenericFilter* filter= dynamic_cast<clitk::MIPGenericFilter*>(mFilter.GetPointer());
103 filter->SetArgsInfo(args_info);
104 filter->SetInputVVImage(mCurrentImage);
106 vvImage::Pointer output = filter->GetOutputVVImage();
107 std::ostringstream osstream;
108 osstream << "MIPed_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
109 AddImage(output,osstream.str());
110 QApplication::restoreOverrideCursor();
113 //------------------------------------------------------------------------------
114 void vvToolMIP::InputIsSelected(vvSlicerManager *m)
116 mCurrentSlicerManager =m;
117 if (m->GetDimension() <3) {
118 QMessageBox::information(this, "Wrong image dimension","Sorry, only work with 3D or 4D images.");
122 this->dimensionSpinBox->setMaximum(m->GetDimension()-1);
125 //-----------------------------------------------------------------------------