1 /*=========================================================================
4 Module: $RCSfile: vvToolMedianFilter.cxx,v $
6 Date: $Date: 2010/04/09 09:53:27 $
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 "vvToolMedianFilter.h"
29 #include "vvSlicerManager.h"
31 #include "vvToolInputSelectorWidget.h"
32 #include <clitkMedianImageGenericFilter.h>
35 //------------------------------------------------------------------------------
36 // Create the tool and automagically
37 ADD_TOOL(vvToolMedianFilter);
38 //------------------------------------------------------------------------------
40 //------------------------------------------------------------------------------
41 vvToolMedianFilter::vvToolMedianFilter(vvMainWindowBase * parent, Qt::WindowFlags f)
42 :vvToolWidgetBase(parent,f),
43 vvToolBase<vvToolMedianFilter>(parent),
44 Ui::vvToolMedianFilter()
49 Ui_vvToolMedianFilter::setupUi(mToolWidget);
51 mFilter = new clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>;
57 // Set how many inputs are needed for this tool
58 AddInputSelector("Select one image", mFilter);
61 //------------------------------------------------------------------------------
62 vvToolMedianFilter::~vvToolMedianFilter() {
64 //------------------------------------------------------------------------------
68 void vvToolMedianFilter::Initialize() {
69 SetToolName("MedianFilter");
70 SetToolMenuName("MedianFilter");
71 SetToolIconFilename(":/new/prefix1/icons/ducky.png");
72 SetToolTip("Make 'MedianFilter' on an image.");
74 //------------------------------------------------------------------------------
76 void vvToolMedianFilter::apply() {
80 if (!mCurrentSlicerManager) close();
81 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
83 clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>::Pointer filter =
84 clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>::New();
87 filter->SetInputVVImage(mCurrentImage);
88 filter->SetArgsInfo(mArgsInfo);
90 filter->EnableReadOnDisk(false);
95 vvImage::Pointer output = filter->GetOutputVVImage();
96 std::ostringstream osstream;
97 osstream << "MedianFiltered_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
98 AddImage(output,osstream.str());
99 QApplication::restoreOverrideCursor();
105 //------------------------------------------------------------------------------
107 void vvToolMedianFilter::GetArgsInfoFromGUI() {
109 /* //KEEP THIS FOR READING GGO FROM FILE
111 std::string a = "toto";
112 char * const* argv = new char*;
114 struct cmdline_parser_params p;
115 p.check_required = 0;
116 int good = cmdline_parser_ext(argc, argv, &args_info, &p);
119 mArgsInfo.radius_given=0;
120 mArgsInfo.verbose_flag = false;
121 // mArgsInfo.radius_arg = new int[3];
123 // Required (even if not used)
124 mArgsInfo.input_given = 0;
125 mArgsInfo.output_given = 0;
127 mArgsInfo.input_arg=new char;
128 mArgsInfo.output_arg = new char;
131 mArgsInfo.config_given=0;
132 mArgsInfo.verbose_given=0;
135 // mArgsInfo.radius_arg[0]=1;
136 // mArgsInfo.radius_arg[1]=1;
137 // mArgsInfo.radius_arg[2]=1;
140 //------------------------------------------------------------------------------
141 void vvToolMedianFilter::InputIsSelected(vvSlicerManager *m){
142 mCurrentSlicerManager =m;
143 // Specific for this gui
145 mArgsInfo.radius_arg = new int[3];
146 connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH1()));
147 connect(horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH2()));
148 connect(horizontalSlider_3, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH3()));
154 //-----------------------------------------------------------------------------
156 void vvToolMedianFilter::UpdatevalueH1()
158 mArgsInfo.radius_arg[0]=horizontalSlider->value();
159 QString string1 = QString::number(mArgsInfo.radius_arg[0]);
160 lineEdit->setText(string1);
162 void vvToolMedianFilter::UpdatevalueH2()
164 mArgsInfo.radius_arg[1]=horizontalSlider_2->value();
165 QString string2 = QString::number(mArgsInfo.radius_arg[1]);
166 lineEdit_2->setText(string2);
168 void vvToolMedianFilter::UpdatevalueH3()
170 mArgsInfo.radius_arg[2]=horizontalSlider_3->value();
171 QString string3 = QString::number(mArgsInfo.radius_arg[2]);
172 lineEdit_3->setText(string3);