From 61d57d331b0459560f6714c0c6bb8298868a662e Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 17 Mar 2010 11:23:38 +0000 Subject: [PATCH] - new multiple input selector --- vv/qt_ui/vvToolSimpleInputSelectorWidget.ui | 238 ++++++++++++++++++++ vv/vvToolSimpleInputSelectorWidget.cxx | 141 ++++++++++++ vv/vvToolSimpleInputSelectorWidget.h | 72 ++++++ 3 files changed, 451 insertions(+) create mode 100644 vv/qt_ui/vvToolSimpleInputSelectorWidget.ui create mode 100644 vv/vvToolSimpleInputSelectorWidget.cxx create mode 100644 vv/vvToolSimpleInputSelectorWidget.h diff --git a/vv/qt_ui/vvToolSimpleInputSelectorWidget.ui b/vv/qt_ui/vvToolSimpleInputSelectorWidget.ui new file mode 100644 index 0000000..449c9de --- /dev/null +++ b/vv/qt_ui/vvToolSimpleInputSelectorWidget.ui @@ -0,0 +1,238 @@ + + + vvToolSimpleInputSelectorWidget + + + + 0 + 0 + 573 + 125 + + + + Form + + + + 0 + + + + + + 75 + true + + + + Select reference image + + + + 9 + + + 2 + + + 0 + + + + + + 0 + + + + + + + + 50 + false + + + + Already open + + + + 1 + + + + + + 11 + 50 + false + + + + + Bidon image number 1 + + + + + + + + + + + + 50 + false + + + + OR + + + false + + + + + + + false + + + + 50 + false + + + + Open a new file + + + + 3 + + + 3 + + + 3 + + + 1 + + + + + Or open a new one + + + + + + + ... + + + + + + + /home/toto/truc.mhd + + + + + + + + + + + + + + + + 0 + + + + + + + + 11 + 50 + false + + + + QFrame::NoFrame + + + 3D image Pixel type short bla bla + + + + + + + + 50 + false + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + + + + + + + mRadioButtonLowerThan + toggled(bool) + groupBox_3 + setEnabled(bool) + + + 296 + 102 + + + 528 + 122 + + + + + mRadioButtonLowerThan + toggled(bool) + mInputSequenceBox + setDisabled(bool) + + + 269 + 93 + + + 214 + 93 + + + + + diff --git a/vv/vvToolSimpleInputSelectorWidget.cxx b/vv/vvToolSimpleInputSelectorWidget.cxx new file mode 100644 index 0000000..70700fc --- /dev/null +++ b/vv/vvToolSimpleInputSelectorWidget.cxx @@ -0,0 +1,141 @@ +/*========================================================================= + + Program: vv + Module: $RCSfile: vvToolSimpleInputSelectorWidget.cxx,v $ + Language: C++ + Date: $Date: 2010/03/17 11:23:46 $ + Version: $Revision: 1.1 $ + Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) + + Copyright (C) 2010 + Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + CREATIS http://www.creatis.insa-lyon.fr + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 3 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + =========================================================================*/ + +#ifndef VVTOOLINPUTSELECTORWIDGET_CXX +#define VVTOOLINPUTSELECTORWIDGET_CXX + +#include "vvToolSimpleInputSelectorWidget.h" +#include "vvSlicerManager.h" + +//------------------------------------------------------------------------------ +vvToolSimpleInputSelectorWidget::vvToolSimpleInputSelectorWidget(QWidget * parent, Qt::WindowFlags f): + QWidget(parent, f) { + setupUi(this); + setEnabled(true); + mSlicerManagerList.clear(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolSimpleInputSelectorWidget::Initialize() { + // Connect signals & slots + connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int))); + DD("vvToolSimpleInputSelectorWidget::Initialize"); + DD(mSlicerManagerList.size()); + if (mSlicerManagerList.size() == 1) { + DD("Initialize::accept"); + accept(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolSimpleInputSelectorWidget::SetInputList(const std::vector & l, int index) { + DD("vvToolSimpleInputSelectorWidget::SetInputList"); + DD(index); + mInputSequenceBox->clear(); + for(unsigned int i=0; iaddItem(mSlicerManagerList[i]->GetFileName().c_str()); + } + mInputSequenceBox->setCurrentIndex(mCurrentIndex); + if (mSlicerManagerList.size() == 0) { + // TODO !!! + DD("no input > error message"); + reject(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolSimpleInputSelectorWidget::setEnabled(bool b) { + QWidget::setEnabled(b); + mInputSelectionButtonBox->setEnabled(b); + mInputSequenceBox->setEnabled(b); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolSimpleInputSelectorWidget::accept() { + mInputSelectionButtonBox->setEnabled(false); + mInputSequenceBox->setEnabled(false); + emit accepted(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolSimpleInputSelectorWidget::reject() { + DD("vvToolSimpleInputSelectorWidget::reject()"); + emit rejected(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolSimpleInputSelectorWidget::changeInput(int index) { + DD("changeInput"); + DD(index); + if (index<0) return; + mCurrentIndex = index; + vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage(); + unsigned int d = mCurrentImage->GetNumberOfDimensions(); + QString size; + QString spacing; + for(unsigned int i=0; iGetSize()[i])); + size.append("x"); + spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i])); + spacing.append("x"); + } + size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1])); + spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1])); + mLabelInputInfo->setText(QString("Image: %1D %2 %3 %4") + .arg(d) + .arg(mCurrentImage->GetScalarTypeAsString().c_str()) + .arg(size) + .arg(spacing)); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvSlicerManager * vvToolSimpleInputSelectorWidget::GetSelectedInput() { + return mSlicerManagerList[GetSelectedInputIndex()]; +} +//------------------------------------------------------------------------------ + +#endif + diff --git a/vv/vvToolSimpleInputSelectorWidget.h b/vv/vvToolSimpleInputSelectorWidget.h new file mode 100644 index 0000000..4410b0d --- /dev/null +++ b/vv/vvToolSimpleInputSelectorWidget.h @@ -0,0 +1,72 @@ +/*========================================================================= + + Program: vv + Module: $RCSfile: vvToolSimpleInputSelectorWidget.h,v $ + Language: C++ + Date: $Date: 2010/03/17 11:23:45 $ + Version: $Revision: 1.1 $ + Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) + + Copyright (C) 2010 + Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + CREATIS http://www.creatis.insa-lyon.fr + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 3 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + =========================================================================*/ + +#ifndef VVTOOLSIMPLEINPUTSELECTORWIDGET_H +#define VVTOOLSIMPLEINPUTSELECTORWIDGET_H + +#include +#include +#include "ui_vvToolSimpleInputSelectorWidget.h" + +class vvSlicerManager; + +//------------------------------------------------------------------------------ +class vvToolSimpleInputSelectorWidget: public QWidget, private Ui::vvToolSimpleInputSelectorWidget +{ + Q_OBJECT + public: + vvToolSimpleInputSelectorWidget(QWidget * parent=0, Qt::WindowFlags f=0); + ~vvToolSimpleInputSelectorWidget() {} + + void SetInputList(const std::vector & l, int index); + void Initialize(); + int GetSelectedInputIndex() { return mCurrentIndex; } + vvSlicerManager * GetSelectedInput(); + + public slots: + void accept(); + void reject(); + void setEnabled(bool b); + + signals: + void accepted(); + void rejected(); + + protected slots: + void changeInput(int i); + + protected: + Ui::vvToolSimpleInputSelectorWidget ui; + std::vector mSlicerManagerList; + int mCurrentIndex; + vvSlicerManager * mCurrentSliceManager; + +}; // end class vvToolSimpleInputSelectorWidget +//------------------------------------------------------------------------------ + +#endif + -- 2.45.1