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://www.centreleonberard.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
21 #include "vvToolSimpleInputSelectorWidget.h"
22 #include "vvToolInputSelectorWidget.h"
23 #include "vvSlicerManager.h"
25 //------------------------------------------------------------------------------
26 vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
31 mNumberOfAcceptedInputs = 0;
33 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 int vvToolInputSelectorWidget::GetNumberOfInput()
38 return mListOfSimpleInputWidget.size();
40 //------------------------------------------------------------------------------
43 //------------------------------------------------------------------------------
44 void vvToolInputSelectorWidget::AddInputSelector(QString & s,
45 const std::vector<vvSlicerManager*> & l,
49 // Create a input selector widget
50 vvToolSimpleInputSelectorWidget * input = new vvToolSimpleInputSelectorWidget;
51 mListOfSimpleInputWidget.push_back(input);
52 mSkipInput.push_back(false);
54 input->EnableAllowSkip(allowSkip);
56 // Copy the list of slicermanager
57 std::vector<vvSlicerManager*> * ll = new std::vector<vvSlicerManager*>;
58 for(unsigned int i=0; i<l.size(); i++)
62 input->SetInputList(*ll, index);
63 mVerticalLayout->addWidget(input);
66 if (GetNumberOfInput() == 1) input->setEnabled(true);
67 else input->setEnabled(false);
69 // Connect signals & slots
70 connect(input, SIGNAL(accepted()), this, SLOT(accept()));
71 connect(input, SIGNAL(rejected()), this, SLOT(reject()));
72 connect(input, SIGNAL(sigskip()), this, SLOT(skip()));
74 //------------------------------------------------------------------------------
77 //------------------------------------------------------------------------------
78 void vvToolInputSelectorWidget::Initialize()
80 for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++)
81 mListOfSimpleInputWidget[i]->Initialize();
83 //------------------------------------------------------------------------------
86 //------------------------------------------------------------------------------
87 void vvToolInputSelectorWidget::accept()
89 mNumberOfAcceptedInputs++;
90 if (mNumberOfAcceptedInputs == GetNumberOfInput()) {
94 mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(true);
97 //------------------------------------------------------------------------------
100 //------------------------------------------------------------------------------
101 void vvToolInputSelectorWidget::reject()
103 if (mNumberOfAcceptedInputs != 0) {
104 mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(false);
105 mListOfSimpleInputWidget[mNumberOfAcceptedInputs-1]->setEnabled(true);
106 mNumberOfAcceptedInputs--;
111 //------------------------------------------------------------------------------
114 //------------------------------------------------------------------------------
115 void vvToolInputSelectorWidget::skip()
117 mSkipInput[mNumberOfAcceptedInputs] = true;
120 //------------------------------------------------------------------------------
123 //------------------------------------------------------------------------------
124 std::vector<vvSlicerManager*> & vvToolInputSelectorWidget::GetSelectedInputs()
126 std::vector<vvSlicerManager*> * l = new std::vector<vvSlicerManager*>;
127 for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++) {
129 l->push_back(mListOfSimpleInputWidget[i]->GetSelectedInput());
133 //------------------------------------------------------------------------------
136 //------------------------------------------------------------------------------
137 void vvToolInputSelectorWidget::AnImageIsBeingClosed(vvSlicerManager * m)
139 // DD("TODO : verify that the image still exist !!");
142 //------------------------------------------------------------------------------