]> Creatis software - clitk.git/blob - vv/vvToolInputSelectorWidget.cxx
- autotool
[clitk.git] / vv / vvToolInputSelectorWidget.cxx
1 /*=========================================================================
2
3   Program:   vv
4   Module:    $RCSfile: vvToolInputSelectorWidget.cxx,v $
5   Language:  C++
6   Date:      $Date: 2010/03/01 15:38:09 $
7   Version:   $Revision: 1.3 $
8   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
9
10   Copyright (C) 2010
11   Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12   CREATIS                   http://www.creatis.insa-lyon.fr
13
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.
17
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.
22
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/>.
25
26   =========================================================================*/
27
28 #ifndef VVTOOLINPUTSELECTORWIDGET_CXX
29 #define VVTOOLINPUTSELECTORWIDGET_CXX
30
31 #include "vvToolInputSelectorWidget.h"
32 #include "vvSlicerManager.h"
33
34 //------------------------------------------------------------------------------
35 vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
36   QWidget(parent, f) {
37   setupUi(this);  
38
39   setEnabled(true);
40
41   // Connect signals & slots  
42   connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
43   connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
44   connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int)));  
45 }
46 //------------------------------------------------------------------------------
47
48
49 //------------------------------------------------------------------------------
50 void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int index) {
51   mInputSequenceBox->clear();
52   mSlicerManagerList = l;
53   mCurrentIndex = index;
54   for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
55     mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
56   }
57   mInputSequenceBox->setCurrentIndex(mCurrentIndex);
58   if (mSlicerManagerList.size() == 0) {
59     // TODO !!!
60     DD("no input > error message");
61     reject();
62   }
63   if (mSlicerManagerList.size() == 1) {
64     accept();
65   }
66 }
67 //------------------------------------------------------------------------------
68
69
70 //------------------------------------------------------------------------------
71 void vvToolInputSelectorWidget::accept() {
72   mInputSelectionButtonBox->setEnabled(false);
73   mInputSequenceBox->setEnabled(false);
74   emit accepted();
75 }
76 //------------------------------------------------------------------------------
77
78
79 //------------------------------------------------------------------------------
80 void vvToolInputSelectorWidget::reject() {
81   emit rejected();
82 }
83 //------------------------------------------------------------------------------
84
85
86 //------------------------------------------------------------------------------
87 void vvToolInputSelectorWidget::changeInput(int index) {
88   mCurrentIndex = index;
89   vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
90   unsigned int d = mCurrentImage->GetNumberOfDimensions();
91   QString size;
92   QString spacing;
93   for(unsigned int i=0; i<d-1; i++) {
94     size.append(QString("%1").arg(mCurrentImage->GetSize()[i]));
95     size.append("x");
96     spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i]));
97     spacing.append("x");
98   }
99   size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1]));
100   spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1]));
101   mLabelInputInfo->setText(QString("Image: %1D %2   %3    %4")
102                            .arg(d)
103                            .arg(mCurrentImage->GetScalarTypeAsString().c_str())
104                            .arg(size)
105                            .arg(spacing));
106 }
107 //------------------------------------------------------------------------------
108
109 #endif
110