X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolMedianFilter.cxx;h=70bbb7792ef14896b6800ed17bc94e84632eb944;hb=2d5b3631dbb64aaf5868d90ac9b1006dd7f4dcef;hp=0d698557a9a0c88e2b420bf37ea5ebd516aecad4;hpb=fd7fe88962bece8d68d850acac8474ee440a1f7d;p=clitk.git diff --git a/vv/vvToolMedianFilter.cxx b/vv/vvToolMedianFilter.cxx index 0d69855..70bbb77 100644 --- a/vv/vvToolMedianFilter.cxx +++ b/vv/vvToolMedianFilter.cxx @@ -1,174 +1,171 @@ - /*========================================================================= - - Program: vv - Module: $RCSfile: vvToolMedianFilter.cxx,v $ - Language: C++ - Date: $Date: 2010/04/09 09:53:27 $ - Version: $Revision: 1.1 $ - Author : Bharath Navalpakkam (Bharath.Navalpakkam@creatis.insa-lyon.fr) - - Copyright (C) 2010 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS http://www.creatis.insa-lyon.fr - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, version 3 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - =========================================================================*/ - - #include "vvToolMedianFilter.h" - #include "vvSlicerManager.h" - #include "vvSlicer.h" - #include "vvToolInputSelectorWidget.h" - #include - - - //------------------------------------------------------------------------------ - // Create the tool and automagically - ADD_TOOL(vvToolMedianFilter); - //------------------------------------------------------------------------------ - - //------------------------------------------------------------------------------ - vvToolMedianFilter::vvToolMedianFilter(vvMainWindowBase * parent, Qt::WindowFlags f) - :vvToolWidgetBase(parent,f), - vvToolBase(parent), - Ui::vvToolMedianFilter() - { - - // Setup the UI - - Ui_vvToolMedianFilter::setupUi(mToolWidget); - - mFilter = new clitk::MedianImageGenericFilter; - - - - // Main filter - - // Set how many inputs are needed for this tool - AddInputSelector("Select one image", mFilter); - } - - //------------------------------------------------------------------------------ - vvToolMedianFilter::~vvToolMedianFilter() { - } - //------------------------------------------------------------------------------ - - +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================*/ +/*========================================================================= + + Program: vv + Module: $RCSfile: vvToolMedianFilter.cxx,v $ + Language: C++ + Date: $Date: 2010/10/22 07:38:05 $ + Version: $Revision: 1.5 $ + Author : Bharath Navalpakkam (Bharath.Navalpakkam@creatis.insa-lyon.fr) + + Copyright (C) 2010 + Léon Bérard cancer center http://www.centreleonberard.fr + CREATIS http://www.creatis.insa-lyon.fr + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 3 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + =========================================================================*/ + +#include "vvToolMedianFilter.h" +#include "vvSlicerManager.h" +#include "vvSlicer.h" +#include "vvToolInputSelectorWidget.h" +#include "clitkMedianImageGenericFilter.h" + +//------------------------------------------------------------------------------ +// Create the tool and automagically +ADD_TOOL(vvToolMedianFilter); +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +vvToolMedianFilter::vvToolMedianFilter(vvMainWindowBase * parent, Qt::WindowFlags f) + :vvToolWidgetBase(parent,f), + vvToolBase(parent), + Ui::vvToolMedianFilter() +{ + // Setup the UI + Ui_vvToolMedianFilter::setupUi(mToolWidget); + mFilter = new clitk::MedianImageGenericFilter; - void vvToolMedianFilter::Initialize() { - SetToolName("MedianFilter"); - SetToolMenuName("MedianFilter"); - SetToolIconFilename(":/new/prefix1/icons/ducky.png"); - SetToolTip("Make 'MedianFilter' on an image."); - } - //------------------------------------------------------------------------------ + // Main filter + // Set how many inputs are needed for this tool + AddInputSelector("Select one image", mFilter); +} - void vvToolMedianFilter::apply() { +//------------------------------------------------------------------------------ +vvToolMedianFilter::~vvToolMedianFilter() +{ +} +//------------------------------------------------------------------------------ +void vvToolMedianFilter::Initialize() +{ + SetToolName("MedianFilter"); + SetToolMenuName("MedianFilter"); + SetToolIconFilename(":common/icons/ducky.png"); + SetToolTip("Make 'MedianFilter' on an image."); + SetToolExperimental(true); +} +//------------------------------------------------------------------------------ - GetArgsInfoFromGUI(); +void vvToolMedianFilter::apply() +{ - if (!mCurrentSlicerManager) close(); + GetArgsInfoFromGUI(); + if (!mCurrentSlicerManager) close(); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // Main filter - clitk::MedianImageGenericFilter::Pointer filter = - clitk::MedianImageGenericFilter::New(); - - - filter->SetInputVVImage(mCurrentImage); + clitk::MedianImageGenericFilter::Pointer filter = + clitk::MedianImageGenericFilter::New(); + filter->SetInputVVImage(mCurrentImage); filter->SetArgsInfo(mArgsInfo); - filter->EnableReadOnDisk(false); filter->Update(); - - // Output vvImage::Pointer output = filter->GetOutputVVImage(); std::ostringstream osstream; osstream << "MedianFiltered_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - AddImage(output,osstream.str()); + AddImage(output,osstream.str()); QApplication::restoreOverrideCursor(); close(); - - - } - - //------------------------------------------------------------------------------ - - void vvToolMedianFilter::GetArgsInfoFromGUI() { - - /* //KEEP THIS FOR READING GGO FROM FILE - int argc=1; - std::string a = "toto"; - char * const* argv = new char*; - //a.c_str(); - struct cmdline_parser_params p; - p.check_required = 0; - int good = cmdline_parser_ext(argc, argv, &args_info, &p); - DD(good); - */ - mArgsInfo.radius_given=0; - mArgsInfo.verbose_flag = false; - // mArgsInfo.radius_arg = new int[3]; - +} +//------------------------------------------------------------------------------ +void vvToolMedianFilter::GetArgsInfoFromGUI() +{ + /* //KEEP THIS FOR READING GGO FROM FILE + int argc=1; + std::string a = "toto"; + char * const* argv = new char*; + //a.c_str(); + struct cmdline_parser_params p; + p.check_required = 0; + int good = cmdline_parser_ext(argc, argv, &args_info, &p); + DD(good); + */ + mArgsInfo.radius_given=0; + mArgsInfo.verbose_flag = false; + // mArgsInfo.radius_arg = new int[3]; // Required (even if not used) - mArgsInfo.input_given = 0; - mArgsInfo.output_given = 0; - - mArgsInfo.input_arg=new char; - mArgsInfo.output_arg = new char; - - + mArgsInfo.input_given = 0; + mArgsInfo.output_given = 0; + mArgsInfo.input_arg=new char; + mArgsInfo.output_arg = new char; mArgsInfo.config_given=0; mArgsInfo.verbose_given=0; - - - // mArgsInfo.radius_arg[0]=1; - // mArgsInfo.radius_arg[1]=1; - // mArgsInfo.radius_arg[2]=1; - - } - //------------------------------------------------------------------------------ -void vvToolMedianFilter::InputIsSelected(vvSlicerManager *m){ +} +//------------------------------------------------------------------------------ +void vvToolMedianFilter::InputIsSelected(vvSlicerManager *m) +{ mCurrentSlicerManager =m; // Specific for this gui - mArgsInfo.radius_arg = new int[3]; - connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH1())); - connect(horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH2())); - connect(horizontalSlider_3, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH3())); - - - + int checkdimensions=mCurrentSlicerManager->GetDimension(); + if(checkdimensions<3) { + horizontalSlider_3->hide(); + spinBox_3->hide(); + mArgsInfo.radius_arg[2]=0; + connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateH1slider())); + connect(horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(UpdateH2slider())); + } else { + horizontalSlider->show(); + horizontalSlider_2->show(); + horizontalSlider_3->show(); + connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateH1slider())); + connect(horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(UpdateH2slider())); + connect(horizontalSlider_3, SIGNAL(valueChanged(int)), this, SLOT(UpdateH3slider())); + } } - //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- -void vvToolMedianFilter::UpdatevalueH1() +void vvToolMedianFilter::UpdateH1slider() { + mArgsInfo.radius_arg[0]=horizontalSlider->value(); - QString string1 = QString::number(mArgsInfo.radius_arg[0]); - lineEdit->setText(string1); + spinBox->setValue(mArgsInfo.radius_arg[0]); } -void vvToolMedianFilter::UpdatevalueH2() +void vvToolMedianFilter::UpdateH2slider() { - mArgsInfo.radius_arg[1]=horizontalSlider_2->value(); - QString string2 = QString::number(mArgsInfo.radius_arg[1]); - lineEdit_2->setText(string2); + mArgsInfo.radius_arg[1]=horizontalSlider_2->value(); + spinBox_2->setValue(mArgsInfo.radius_arg[1]); } -void vvToolMedianFilter::UpdatevalueH3() +void vvToolMedianFilter::UpdateH3slider() { - mArgsInfo.radius_arg[2]=horizontalSlider_3->value(); - QString string3 = QString::number(mArgsInfo.radius_arg[2]); - lineEdit_3->setText(string3); - + mArgsInfo.radius_arg[2]=horizontalSlider_3->value(); + spinBox_3->setValue(mArgsInfo.radius_arg[2]); }