1 /*=========================================================================
4 Module: $RCSfile: vvToolMIP.cxx,v $
6 Date: $Date: 2011/04/15 08:29:21 $
7 Version: $Revision: 1.3 $
8 Author : Bharath Navalpakkam (Bharath.Navalpakkam@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 =========================================================================*/
28 #include <QMessageBox>
31 #include <itkMaximumProjectionImageFilter.h>
33 #include "vvToolMIP.h"
34 #include "vvSlicerManager.h"
36 #include "vvToolInputSelectorWidget.h"
37 #include "clitkMIPGenericFilter.h"
39 //------------------------------------------------------------------------------
40 // Create the tool and automagically
42 //------------------------------------------------------------------------------
44 //------------------------------------------------------------------------------
45 vvToolMIP::vvToolMIP(vvMainWindowBase * parent, Qt::WindowFlags f)
46 :vvToolWidgetBase(parent,f),
47 vvToolBase<vvToolMIP>(parent),
51 Ui_vvToolMIP::setupUi(mToolWidget);
52 //mFilter=clitk::MIPGenericFilter::New(); //Causes a segfault. Why? (joel 26/10/2010)
53 mFilter=new clitk::MIPGenericFilter;
56 // Set how many inputs are needed for this tool
57 //AddInputSelector("Select one image", mFilter);
58 AddInputSelector("Select one image");
61 //------------------------------------------------------------------------------
62 vvToolMIP::~vvToolMIP()
65 //------------------------------------------------------------------------------
66 void vvToolMIP::Initialize()
69 SetToolMenuName("Maximum Intensity Projection");
70 SetToolIconFilename(":common/icons/mip.png");
71 SetToolTip("Compute the maximum intensity projection of an image.");
72 SetToolExperimental(false);
74 //------------------------------------------------------------------------------
76 void vvToolMIP::apply()
78 if (!mCurrentSlicerManager) close();
79 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
81 clitk::MIPGenericFilter::args_info_type args_info;
82 cmdline_parser_clitkMIP_init(&args_info);
83 args_info.dimension_arg=this->dimensionSpinBox->value();
84 args_info.dimension_given=true;
85 clitk::MIPGenericFilter* filter= dynamic_cast<clitk::MIPGenericFilter*>(mFilter.GetPointer());
86 filter->SetArgsInfo(args_info);
87 filter->SetInputVVImage(mCurrentImage);
89 vvImage::Pointer output = filter->GetOutputVVImage();
90 std::ostringstream osstream;
91 osstream << "MIPed_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
92 AddImage(output,osstream.str());
93 QApplication::restoreOverrideCursor();
96 //------------------------------------------------------------------------------
97 void vvToolMIP::InputIsSelected(vvSlicerManager *m)
99 mCurrentSlicerManager =m;
100 if (m->GetDimension() <3) {
101 QMessageBox::information(this, "Wrong image dimension","Sorry, only work with 3D or 4D images.");
105 this->dimensionSpinBox->setMaximum(m->GetDimension()-1);
108 //-----------------------------------------------------------------------------