1 /*=========================================================================
4 Module: $RCSfile: vvToolMIP.cxx,v $
6 Date: $Date: 2010/10/26 12:37:58 $
7 Version: $Revision: 1.1 $
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()
66 //------------------------------------------------------------------------------
67 void vvToolMIP::Initialize()
70 SetToolMenuName("Maximum Intensity Projection");
71 SetToolIconFilename(":common/icons/ducky.png");
72 SetToolTip("Compute the maximum intensity projection of an image.");
73 SetToolExperimental(true);
75 //------------------------------------------------------------------------------
77 void vvToolMIP::apply()
79 if (!mCurrentSlicerManager) close();
80 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
82 clitk::MIPGenericFilter::args_info_type args_info;
83 cmdline_parser_clitkMIP_init(&args_info);
84 args_info.dimension_arg=this->dimensionSpinBox->value();
85 args_info.dimension_given=true;
86 clitk::MIPGenericFilter* filter= dynamic_cast<clitk::MIPGenericFilter*>(mFilter);
87 filter->SetArgsInfo(args_info);
88 filter->SetInputVVImage(mCurrentImage);
90 vvImage::Pointer output = filter->GetOutputVVImage();
91 std::ostringstream osstream;
92 osstream << "MIPed_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
93 AddImage(output,osstream.str());
94 QApplication::restoreOverrideCursor();
97 //------------------------------------------------------------------------------
98 void vvToolMIP::InputIsSelected(vvSlicerManager *m)
100 mCurrentSlicerManager =m;
101 this->dimensionSpinBox->setMaximum(m->GetDimension()-1);
104 //-----------------------------------------------------------------------------