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):
29 mSlicerManagerList.clear();
31 //------------------------------------------------------------------------------
34 //------------------------------------------------------------------------------
35 void vvToolSimpleInputSelectorWidget::Initialize() {
36 // Connect signals & slots
37 connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
38 connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
39 connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int)));
40 if (mSlicerManagerList.size() == 1) {
41 if (!mAllowSkip) accept();
43 if (mSlicerManagerList.size() == 0) {
47 //------------------------------------------------------------------------------
50 //------------------------------------------------------------------------------
51 void vvToolSimpleInputSelectorWidget::SetText(QString & s) {
52 mGroupBox->setTitle(s);
54 //------------------------------------------------------------------------------
57 //------------------------------------------------------------------------------
58 void vvToolSimpleInputSelectorWidget::EnableAllowSkip(bool b) {
61 mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Discard);
62 connect(mInputSelectionButtonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(skip(QAbstractButton*)));
65 mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
67 //------------------------------------------------------------------------------
70 //------------------------------------------------------------------------------
71 void vvToolSimpleInputSelectorWidget::SetInputList(const std::vector<vvSlicerManager*> & l, int index) {
74 DD("no input > error message");
77 mInputSequenceBox->clear();
78 for(unsigned int i=0; i<l.size(); i++)
79 mSlicerManagerList.push_back(l[i]);
80 mCurrentIndex = index;
81 for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
82 mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
84 mInputSequenceBox->setCurrentIndex(mCurrentIndex);
85 changeInput(mCurrentIndex);
87 //------------------------------------------------------------------------------
90 //------------------------------------------------------------------------------
91 void vvToolSimpleInputSelectorWidget::setEnabled(bool b) {
92 QWidget::setEnabled(b);
93 mInputSelectionButtonBox->setEnabled(b);
94 mInputSequenceBox->setEnabled(b);
96 //------------------------------------------------------------------------------
99 //------------------------------------------------------------------------------
100 void vvToolSimpleInputSelectorWidget::accept() {
101 mInputSelectionButtonBox->setEnabled(false);
102 mInputSequenceBox->setEnabled(false);
105 //------------------------------------------------------------------------------
109 //------------------------------------------------------------------------------
110 void vvToolSimpleInputSelectorWidget::reject() {
113 //------------------------------------------------------------------------------
116 //------------------------------------------------------------------------------
117 void vvToolSimpleInputSelectorWidget::skip(QAbstractButton* b) {
118 if (b->text() == "Discard") emit sigskip();
120 //------------------------------------------------------------------------------
123 //------------------------------------------------------------------------------
124 void vvToolSimpleInputSelectorWidget::changeInput(int index) {
126 mCurrentIndex = index;
127 vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
128 unsigned int d = mCurrentImage->GetNumberOfDimensions();
131 for(unsigned int i=0; i<d-1; i++) {
132 size.append(QString("%1").arg(mCurrentImage->GetSize()[i]));
134 spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i]));
137 size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1]));
138 spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1]));
139 mLabelInputInfo->setText(QString("Image: %1D %2 %3 %4")
141 .arg(mCurrentImage->GetScalarTypeAsString().c_str())
145 //------------------------------------------------------------------------------
148 //------------------------------------------------------------------------------
149 vvSlicerManager * vvToolSimpleInputSelectorWidget::GetSelectedInput() {
150 return mSlicerManagerList[GetSelectedInputIndex()];
152 //------------------------------------------------------------------------------