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 ======================================================================-====*/
18 #ifndef VVTOOLINPUTSELECTORWIDGET_CXX
19 #define VVTOOLINPUTSELECTORWIDGET_CXX
20 #include "vvToolSimpleInputSelectorWidget.h"
21 #include "vvSlicerManager.h"
22 #include <QAbstractButton>
24 //------------------------------------------------------------------------------
25 vvToolSimpleInputSelectorWidget::vvToolSimpleInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
30 mSlicerManagerList.clear();
32 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 void vvToolSimpleInputSelectorWidget::Initialize()
38 // Connect signals & slots
39 connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
40 connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
41 connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int)));
42 if (mSlicerManagerList.size() == 1) {
43 if (!mAllowSkip) accept();
45 if (mSlicerManagerList.size() == 0) {
49 //------------------------------------------------------------------------------
52 //------------------------------------------------------------------------------
53 void vvToolSimpleInputSelectorWidget::SetText(QString & s)
55 mGroupBox->setTitle(s);
57 //------------------------------------------------------------------------------
60 //------------------------------------------------------------------------------
61 void vvToolSimpleInputSelectorWidget::EnableAllowSkip(bool b)
65 mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Discard);
66 connect(mInputSelectionButtonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(skip(QAbstractButton*)));
68 mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
70 //------------------------------------------------------------------------------
73 //------------------------------------------------------------------------------
74 void vvToolSimpleInputSelectorWidget::SetInputList(const std::vector<vvSlicerManager*> & l, int index)
78 DD("no input > error message");
81 mInputSequenceBox->clear();
82 for(unsigned int i=0; i<l.size(); i++)
83 mSlicerManagerList.push_back(l[i]);
84 mCurrentIndex = index;
85 for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
86 mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
88 mInputSequenceBox->setCurrentIndex(mCurrentIndex);
89 changeInput(mCurrentIndex);
91 //------------------------------------------------------------------------------
94 //------------------------------------------------------------------------------
95 void vvToolSimpleInputSelectorWidget::setEnabled(bool b)
97 QWidget::setEnabled(b);
98 mInputSelectionButtonBox->setEnabled(b);
99 mInputSequenceBox->setEnabled(b);
101 //------------------------------------------------------------------------------
104 //------------------------------------------------------------------------------
105 void vvToolSimpleInputSelectorWidget::accept()
107 mInputSelectionButtonBox->setEnabled(false);
108 mInputSequenceBox->setEnabled(false);
111 //------------------------------------------------------------------------------
115 //------------------------------------------------------------------------------
116 void vvToolSimpleInputSelectorWidget::reject()
120 //------------------------------------------------------------------------------
123 //------------------------------------------------------------------------------
124 void vvToolSimpleInputSelectorWidget::skip(QAbstractButton* b)
126 if (b->text() == "Discard") emit sigskip();
128 //------------------------------------------------------------------------------
131 //------------------------------------------------------------------------------
132 void vvToolSimpleInputSelectorWidget::changeInput(int index)
135 mCurrentIndex = index;
136 vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
137 unsigned int d = mCurrentImage->GetNumberOfDimensions();
140 for(unsigned int i=0; i<d-1; i++) {
141 size.append(QString("%1").arg(mCurrentImage->GetSize()[i]));
143 spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i]));
146 size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1]));
147 spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1]));
148 mLabelInputInfo->setText(QString("Image: %1D %2 %3 %4")
150 .arg(mCurrentImage->GetScalarTypeAsString().c_str())
154 //------------------------------------------------------------------------------
157 //------------------------------------------------------------------------------
158 vvSlicerManager * vvToolSimpleInputSelectorWidget::GetSelectedInput()
160 return mSlicerManagerList[GetSelectedInputIndex()];
162 //------------------------------------------------------------------------------