1 /*=========================================================================
4 Module: $RCSfile: vvToolInputSelectorWidget.cxx,v $
6 Date: $Date: 2010/03/24 10:48:18 $
7 Version: $Revision: 1.5 $
8 Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS http://www.creatis.insa-lyon.fr
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.
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.
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/>.
26 =========================================================================*/
28 #ifndef VVTOOLINPUTSELECTORWIDGET_CXX
29 #define VVTOOLINPUTSELECTORWIDGET_CXX
31 #include "vvToolSimpleInputSelectorWidget.h"
32 #include "vvToolInputSelectorWidget.h"
33 #include "vvSlicerManager.h"
35 //------------------------------------------------------------------------------
36 vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
40 mNumberOfAcceptedInputs = 0;
42 //------------------------------------------------------------------------------
44 //------------------------------------------------------------------------------
45 int vvToolInputSelectorWidget::GetNumberOfInput() {
46 return mListOfSimpleInputWidget.size();
48 //------------------------------------------------------------------------------
51 //------------------------------------------------------------------------------
52 void vvToolInputSelectorWidget::AddInputSelector(QString & s,
53 const std::vector<vvSlicerManager*> & l,
56 // DD("ICICICICICICICIC AddInputSelector ADD layout");
59 vvToolSimpleInputSelectorWidget * input = new vvToolSimpleInputSelectorWidget;
60 mListOfSimpleInputWidget.push_back(input);
61 mSkipInput.push_back(false);
64 input->EnableAllowSkip(allowSkip);
67 std::vector<vvSlicerManager*> * ll = new std::vector<vvSlicerManager*>;
68 for(unsigned int i=0; i<l.size(); i++)
72 input->SetInputList(*ll, index);
73 input->setObjectName(QString::fromUtf8("TOTO"));
74 mVerticalLayout->addWidget(input);
77 if (GetNumberOfInput() == 1) input->setEnabled(true);
78 else input->setEnabled(false);
79 //DD(GetNumberOfInput());
81 // Connect signals & slots
82 connect(input, SIGNAL(accepted()), this, SLOT(accept()));
83 connect(input, SIGNAL(rejected()), this, SLOT(reject()));
84 connect(input, SIGNAL(sigskip()), this, SLOT(skip()));
86 //------------------------------------------------------------------------------
89 //------------------------------------------------------------------------------
90 void vvToolInputSelectorWidget::Initialize() {
91 for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++)
92 mListOfSimpleInputWidget[i]->Initialize();
94 //------------------------------------------------------------------------------
97 //------------------------------------------------------------------------------
98 void vvToolInputSelectorWidget::accept() {
99 // DD("vvToolInputSelectorWidget::accept");
100 //DD(mNumberOfAcceptedInputs);
101 mNumberOfAcceptedInputs++;
102 if (mNumberOfAcceptedInputs == GetNumberOfInput()) {
108 // for(unsigned int i=mNumberOfAcceptedInputs; i<mListOfSimpleInputWidget.size(); i++) {
109 // mListOfSimpleInputWidget[i]->Initialize();
110 mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(true);
114 //------------------------------------------------------------------------------
117 //------------------------------------------------------------------------------
118 void vvToolInputSelectorWidget::reject() {
119 // DD("vvToolInputSelectorWidget::reject");
120 if (mNumberOfAcceptedInputs != 0) {
121 // for(unsigned int i=mNumberOfAcceptedInputs; i<mListOfSimpleInputWidget.size(); i++) {
122 // mListOfSimpleInputWidget[i]->Initialize();
123 // DD(mNumberOfAcceptedInputs);
124 mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(false);
125 mListOfSimpleInputWidget[mNumberOfAcceptedInputs-1]->setEnabled(true);
126 mNumberOfAcceptedInputs--;
133 //------------------------------------------------------------------------------
136 //------------------------------------------------------------------------------
137 void vvToolInputSelectorWidget::skip() {
139 mSkipInput[mNumberOfAcceptedInputs] = true;
140 accept();//mNumberOfAcceptedInputs++;
142 //------------------------------------------------------------------------------
145 //------------------------------------------------------------------------------
146 std::vector<vvSlicerManager*> & vvToolInputSelectorWidget::GetSelectedInputs() {
147 std::vector<vvSlicerManager*> * l = new std::vector<vvSlicerManager*>;
148 for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++) {
150 l->push_back(mListOfSimpleInputWidget[i]->GetSelectedInput());
154 //------------------------------------------------------------------------------
157 //------------------------------------------------------------------------------
158 void vvToolInputSelectorWidget::AnImageIsBeingClosed(vvSlicerManager * m) {
159 // DD("TODO : verify that the image still exist !!");
162 //------------------------------------------------------------------------------