1 /*=========================================================================
4 Module: $RCSfile: vvToolSimpleInputSelectorWidget.cxx,v $
6 Date: $Date: 2010/03/17 11:23:46 $
7 Version: $Revision: 1.1 $
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 "vvSlicerManager.h"
34 //------------------------------------------------------------------------------
35 vvToolSimpleInputSelectorWidget::vvToolSimpleInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
39 mSlicerManagerList.clear();
41 //------------------------------------------------------------------------------
44 //------------------------------------------------------------------------------
45 void vvToolSimpleInputSelectorWidget::Initialize() {
46 // Connect signals & slots
47 connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
48 connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
49 connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int)));
50 DD("vvToolSimpleInputSelectorWidget::Initialize");
51 DD(mSlicerManagerList.size());
52 if (mSlicerManagerList.size() == 1) {
53 DD("Initialize::accept");
57 //------------------------------------------------------------------------------
60 //------------------------------------------------------------------------------
61 void vvToolSimpleInputSelectorWidget::SetInputList(const std::vector<vvSlicerManager*> & l, int index) {
62 DD("vvToolSimpleInputSelectorWidget::SetInputList");
64 mInputSequenceBox->clear();
65 for(unsigned int i=0; i<l.size(); i++)
66 mSlicerManagerList.push_back(l[i]);
67 mCurrentIndex = index;
68 for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
69 mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
71 mInputSequenceBox->setCurrentIndex(mCurrentIndex);
72 if (mSlicerManagerList.size() == 0) {
74 DD("no input > error message");
78 //------------------------------------------------------------------------------
81 //------------------------------------------------------------------------------
82 void vvToolSimpleInputSelectorWidget::setEnabled(bool b) {
83 QWidget::setEnabled(b);
84 mInputSelectionButtonBox->setEnabled(b);
85 mInputSequenceBox->setEnabled(b);
87 //------------------------------------------------------------------------------
90 //------------------------------------------------------------------------------
91 void vvToolSimpleInputSelectorWidget::accept() {
92 mInputSelectionButtonBox->setEnabled(false);
93 mInputSequenceBox->setEnabled(false);
96 //------------------------------------------------------------------------------
99 //------------------------------------------------------------------------------
100 void vvToolSimpleInputSelectorWidget::reject() {
101 DD("vvToolSimpleInputSelectorWidget::reject()");
104 //------------------------------------------------------------------------------
107 //------------------------------------------------------------------------------
108 void vvToolSimpleInputSelectorWidget::changeInput(int index) {
112 mCurrentIndex = index;
113 vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
114 unsigned int d = mCurrentImage->GetNumberOfDimensions();
117 for(unsigned int i=0; i<d-1; i++) {
118 size.append(QString("%1").arg(mCurrentImage->GetSize()[i]));
120 spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i]));
123 size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1]));
124 spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1]));
125 mLabelInputInfo->setText(QString("Image: %1D %2 %3 %4")
127 .arg(mCurrentImage->GetScalarTypeAsString().c_str())
131 //------------------------------------------------------------------------------
134 //------------------------------------------------------------------------------
135 vvSlicerManager * vvToolSimpleInputSelectorWidget::GetSelectedInput() {
136 return mSlicerManagerList[GetSelectedInputIndex()];
138 //------------------------------------------------------------------------------