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://oncora1.lyon.fnclcc.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 ======================================================================-====*/
20 #include "vvThreadedFilter.h"
21 #include "vvProgressDialog.h"
24 #include <QMessageBox>
26 //------------------------------------------------------------------------------
27 vvThreadedFilter::vvThreadedFilter():
30 DD("vvThreadedFilter");
33 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 vvThreadedFilter::~vvThreadedFilter()
40 //------------------------------------------------------------------------------
43 //------------------------------------------------------------------------------
44 void vvThreadedFilter::SetFilter(clitk::ImageToImageGenericFilterBase * f)
49 //------------------------------------------------------------------------------
52 //------------------------------------------------------------------------------
53 void vvThreadedFilter::Update()
55 assert(m_Filter != NULL);
57 // Show a progress bar while computing
58 vvProgressDialog progress("Computing ...",100);
59 connect(&progress, SIGNAL(rejected()), this, SLOT(reject()));
61 this->setTerminationEnabled(true);
63 while (this->isRunning()) {
64 DD(this->isRunning());
65 m_FilterBase = m_Filter->GetFilterBase(); // get filterbase only after Update
66 if (m_FilterBase != NULL) {
67 progress.SetProgress(m_FilterBase->GetCurrentStepNumber(),
68 m_FilterBase->GetNumberOfSteps());
69 if (temp != m_FilterBase->GetCurrentStepName()) {
70 progress.AddToText(m_FilterBase->GetCurrentStepName());
72 temp = m_FilterBase->GetCurrentStepName();
74 this->wait(200); // in milisecond
75 qApp->processEvents();
79 //------------------------------------------------------------------------------
82 //------------------------------------------------------------------------------
83 void vvThreadedFilter::run()
85 assert(m_Filter != NULL);
88 //------------------------------------------------------------------------------
91 //------------------------------------------------------------------------------
92 void vvThreadedFilter::reject()
94 DD("vvThreadedFilter::reject");
96 // if (m_Filter != NULL) {
97 // m_Filter->MustStop();
99 DD("after terminate");
101 //------------------------------------------------------------------------------