X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolSimpleInputSelectorWidget.cxx;h=9ecadb40872fd7ddbcbae817f60357f42489760a;hb=HEAD;hp=fcc1361814f36939f679258bd3e6650f3367732b;hpb=34490f432219fe05c7ae19c4cf012b5529d784dc;p=clitk.git diff --git a/vv/vvToolSimpleInputSelectorWidget.cxx b/vv/vvToolSimpleInputSelectorWidget.cxx index fcc1361..9ecadb4 100644 --- a/vv/vvToolSimpleInputSelectorWidget.cxx +++ b/vv/vvToolSimpleInputSelectorWidget.cxx @@ -1,41 +1,35 @@ /*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Program: vv - Module: $RCSfile: vvToolSimpleInputSelectorWidget.cxx,v $ - Language: C++ - Date: $Date: 2010/03/24 10:48:18 $ - Version: $Revision: 1.2 $ - Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.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 software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. - 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 . - - =========================================================================*/ + It is distributed under dual licence + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ #ifndef VVTOOLINPUTSELECTORWIDGET_CXX #define VVTOOLINPUTSELECTORWIDGET_CXX +// vv #include "vvToolSimpleInputSelectorWidget.h" #include "vvSlicerManager.h" + +// qt #include //------------------------------------------------------------------------------ vvToolSimpleInputSelectorWidget::vvToolSimpleInputSelectorWidget(QWidget * parent, Qt::WindowFlags f): - QWidget(parent, f) { - setupUi(this); + QWidget(parent, f) +{ + setupUi(this); setEnabled(true); mSlicerManagerList.clear(); } @@ -43,41 +37,51 @@ vvToolSimpleInputSelectorWidget::vvToolSimpleInputSelectorWidget(QWidget * paren //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::Initialize() { - // Connect signals & slots +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))); - changeInput(0); + connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int))); if (mSlicerManagerList.size() == 1) { if (!mAllowSkip) accept(); } + if (mSlicerManagerList.size() == 0) { + reject(); + } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::SetText(QString & s) { +void vvToolSimpleInputSelectorWidget::SetText(QString & s) +{ mGroupBox->setTitle(s); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::EnableAllowSkip(bool b) { +void vvToolSimpleInputSelectorWidget::EnableAllowSkip(bool b) +{ mAllowSkip = b; if (mAllowSkip) { - mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Discard); + mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Ignore); connect(mInputSelectionButtonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(skip(QAbstractButton*))); - } - else + } else mInputSelectionButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::SetInputList(const std::vector & l, int index) { +void vvToolSimpleInputSelectorWidget::SetInputList(const std::vector & l, int index) +{ + if (l.size() == 0) { + // TODO !!! + DD("no input > error message"); + reject(); + } 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(); - } + changeInput(mCurrentIndex); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::setEnabled(bool b) { +void vvToolSimpleInputSelectorWidget::setEnabled(bool b) +{ QWidget::setEnabled(b); mInputSelectionButtonBox->setEnabled(b); mInputSequenceBox->setEnabled(b); + } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::accept() { +void vvToolSimpleInputSelectorWidget::accept() +{ mInputSelectionButtonBox->setEnabled(false); mInputSequenceBox->setEnabled(false); emit accepted(); @@ -115,24 +118,29 @@ void vvToolSimpleInputSelectorWidget::accept() { //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::reject() { +void vvToolSimpleInputSelectorWidget::reject() +{ emit rejected(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::skip(QAbstractButton* b) { - if (b->text() == "Discard") emit sigskip(); +void vvToolSimpleInputSelectorWidget::skip(QAbstractButton* b) +{ + if (b->text() == "Ignore") emit sigskip(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvToolSimpleInputSelectorWidget::changeInput(int index) { +void vvToolSimpleInputSelectorWidget::changeInput(int index) +{ if (index<0) return; + if (index>=(int)mSlicerManagerList.size()) return; mCurrentIndex = index; vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage(); + if (mCurrentImage == NULL) return; unsigned int d = mCurrentImage->GetNumberOfDimensions(); QString size; QString spacing; @@ -144,9 +152,9 @@ void vvToolSimpleInputSelectorWidget::changeInput(int index) { } 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") + mLabelInputInfo->setText(QString("%1D %2\n%3\n%4") .arg(d) - .arg(mCurrentImage->GetScalarTypeAsString().c_str()) + .arg(mCurrentImage->GetScalarTypeAsITKString().c_str()) .arg(size) .arg(spacing)); } @@ -154,7 +162,8 @@ void vvToolSimpleInputSelectorWidget::changeInput(int index) { //------------------------------------------------------------------------------ -vvSlicerManager * vvToolSimpleInputSelectorWidget::GetSelectedInput() { +vvSlicerManager * vvToolSimpleInputSelectorWidget::GetSelectedInput() +{ return mSlicerManagerList[GetSelectedInputIndex()]; } //------------------------------------------------------------------------------