# vvToolFooWithWidgetBase.cxx
vvToolCropImage.cxx
vvToolBinarize.cxx
+ vvToolSimpleInputSelectorWidget.cxx
vvToolInputSelectorWidget.cxx
vvImageContour.cxx
)
# vvToolFoo.h
# vvToolFooWithWidgetBase.h
vvToolBinarize.h
+ vvToolSimpleInputSelectorWidget.h
vvToolInputSelectorWidget.h
vvToolWidgetBase.h
vvToolCropImage.h
# qt_ui/vvToolFoo.ui
qt_ui/vvToolCropImage.ui
qt_ui/vvToolBinarize.ui
+ qt_ui/vvToolSimpleInputSelectorWidget.ui
qt_ui/vvToolInputSelectorWidget.ui
)
<rect>
<x>0</x>
<y>0</y>
- <width>276</width>
- <height>98</height>
+ <width>676</width>
+ <height>381</height>
</rect>
</property>
<property name="font">
<property name="autoFillBackground">
<bool>false</bool>
</property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>2</number>
- </property>
- <item row="0" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Select input image</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <property name="margin">
- <number>2</number>
- </property>
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QComboBox" name="mInputSequenceBox">
- <property name="font">
- <font>
- <pointsize>11</pointsize>
- </font>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="mLabelInputInfo">
- <property name="font">
- <font>
- <pointsize>11</pointsize>
- </font>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="text">
- <string>3D image
-Pixel type short
-bla bla</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="mInputSelectionButtonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
+ <layout class="QVBoxLayout" name="mVerticalLayout"/>
</widget>
<resources/>
<connections/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
- <zorder>splitter</zorder>
- <zorder>buttonBox</zorder>
- <zorder>mToolInputSelectionWidget</zorder>
- <zorder>groupBox</zorder>
</widget>
<customwidgets>
<customwidget>
Program: vv
Module: $RCSfile: vvToolBinarize.cxx,v $
Language: C++
- Date: $Date: 2010/03/05 10:32:33 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.12 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
mBGSlider->SetText("Background value");
// Main filter
- mFilter = new clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>; //DS PUT IN BASECLASS ?
+ mFilter = new clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>;
+
+ // Set how many inputs are needed for this tool
+ AddInputSelector(mFilter);
}
//------------------------------------------------------------------------------
else {
for(unsigned int i=0; i<mImageContour.size(); i++) {
mImageContour[i]->showActors();
- mImageContourLower[i]->showActors();
+ if (mRadioButtonLowerThan->isChecked())
+ mImageContourLower[i]->showActors();
}
if (mCurrentSlicerManager)
mCurrentSlicerManager->Render();
//------------------------------------------------------------------------------
void vvToolBinarize::reject() {
+ DD("vvToolBinarize::reject");
RemoveVTKObjects();
return vvToolWidgetBase::reject();
}
//------------------------------------------------------------------------------
+// void vvToolBinarize::InputIsSelected(std::vector<vvSlicerManager *> & m) {
+// DD("vvToolBinarize::InputIsSelected vector in binarize");
+// DD(m.size());
+// }
void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
mCurrentSlicerManager = m;
Program: vv
Module: $RCSfile: vvToolBinarize.h,v $
Language: C++
- Date: $Date: 2010/03/05 10:32:33 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.9 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
static void Initialize();
void InputIsSet(bool b);
void GetArgsInfoFromGUI();
+ virtual void InputIsSelected(vvSlicerManager * m);
+ // virtual void InputIsSelected(std::vector<vvSlicerManager *> & m);
//-----------------------------------------------------
public slots:
void valueChangedT1(double v);
void valueChangedT2(double v);
void UpdateSlice(int slicer,int slices);
- void InputIsSelected(vvSlicerManager * m);
void enableLowerThan(bool b);
void useFGBGtoggled(bool);
void InteractiveDisplayToggled(bool b);
Program: vv
Module: $RCSfile: vvToolCropImage.cxx,v $
Language: C++
- Date: $Date: 2010/03/01 15:38:09 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.4 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
// GUI Initialization
Ui_vvToolCropImage::setupUi(mToolWidget);
+ // Set how many inputs are needed for this tool
+ AddInputSelector();
}
//------------------------------------------------------------------------------
mReducedExtent = mCurrentSlicerManager->GetImage()->GetFirstVTKImageData()->GetWholeExtent();
for(int i=0; i<6; i++) mInitialExtent[i] = mReducedExtent[i];
for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+ DD(i);
+ DD(mReducedExtent[i]);
+ DD(mInitialExtent[i]);
mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(true);
}
// connect(tmaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderTMaxValueChanged(int)));
// connect(mIntensitySlider, SIGNAL(valueChanged(double)), this, SLOT(autoCropValueChanged(double)));
+ UpdateExtent();
}
//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolInputSelectorWidget.cxx,v $
Language: C++
- Date: $Date: 2010/03/01 15:38:09 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.4 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
#ifndef VVTOOLINPUTSELECTORWIDGET_CXX
#define VVTOOLINPUTSELECTORWIDGET_CXX
+#include "vvToolSimpleInputSelectorWidget.h"
#include "vvToolInputSelectorWidget.h"
#include "vvSlicerManager.h"
vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
QWidget(parent, f) {
setupUi(this);
-
setEnabled(true);
+ mNumberOfAcceptedInputs = 0;
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+int vvToolInputSelectorWidget::GetNumberOfInput() {
+ return mListOfSimpleInputWidget.size();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::AddInputSelector(const std::vector<vvSlicerManager*> & l, int index) {
+ DD("ICICICICICICICIC AddInputSelector ADD layout");
+ DD(index);
+ DD(l.size());
+ vvToolSimpleInputSelectorWidget * input = new vvToolSimpleInputSelectorWidget;
+ mListOfSimpleInputWidget.push_back(input);
+
+ // copy list
+ std::vector<vvSlicerManager*> * ll = new std::vector<vvSlicerManager*>;
+ for(unsigned int i=0; i<l.size(); i++)
+ ll->push_back(l[i]);
+
+ // add
+ input->SetInputList(*ll, index);
+ input->setObjectName(QString::fromUtf8("TOTO"));
+ mVerticalLayout->addWidget(input);
+
+ // Enable or disable
+ if (GetNumberOfInput() == 1) input->setEnabled(true);
+ else input->setEnabled(false);
+ DD(GetNumberOfInput());
// 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)));
+ connect(input, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(input, SIGNAL(rejected()), this, SLOT(reject()));
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int index) {
- mInputSequenceBox->clear();
- mSlicerManagerList = l;
- mCurrentIndex = index;
- for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
- mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
- }
- mInputSequenceBox->setCurrentIndex(mCurrentIndex);
- if (mSlicerManagerList.size() == 0) {
- // TODO !!!
- DD("no input > error message");
- reject();
- }
- if (mSlicerManagerList.size() == 1) {
- accept();
- }
+void vvToolInputSelectorWidget::Initialize() {
+ for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++)
+ mListOfSimpleInputWidget[i]->Initialize();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolInputSelectorWidget::accept() {
- mInputSelectionButtonBox->setEnabled(false);
- mInputSequenceBox->setEnabled(false);
- emit accepted();
+ DD("vvToolInputSelectorWidget::accept");
+ DD(mNumberOfAcceptedInputs);
+ mNumberOfAcceptedInputs++;
+ if (mNumberOfAcceptedInputs == GetNumberOfInput()) {
+ setEnabled(false);
+ emit accepted();
+ }
+ else {
+ DD("accepted");
+ // for(unsigned int i=mNumberOfAcceptedInputs; i<mListOfSimpleInputWidget.size(); i++) {
+ // mListOfSimpleInputWidget[i]->Initialize();
+ mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(true);
+ //}
+ }
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolInputSelectorWidget::reject() {
- emit rejected();
+ DD("vvToolInputSelectorWidget::reject");
+ if (mNumberOfAcceptedInputs != 0) {
+ // for(unsigned int i=mNumberOfAcceptedInputs; i<mListOfSimpleInputWidget.size(); i++) {
+ // mListOfSimpleInputWidget[i]->Initialize();
+ DD(mNumberOfAcceptedInputs);
+ mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(false);
+ mListOfSimpleInputWidget[mNumberOfAcceptedInputs-1]->setEnabled(true);
+ mNumberOfAcceptedInputs--;
+ //}
+ }
+ else {
+ emit rejected();
+ }
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolInputSelectorWidget::changeInput(int index) {
- mCurrentIndex = index;
- vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
- unsigned int d = mCurrentImage->GetNumberOfDimensions();
- QString size;
- QString spacing;
- for(unsigned int i=0; i<d-1; i++) {
- size.append(QString("%1").arg(mCurrentImage->GetSize()[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));
+std::vector<vvSlicerManager*> & vvToolInputSelectorWidget::GetSelectedInputs() {
+ std::vector<vvSlicerManager*> * l = new std::vector<vvSlicerManager*>;
+ for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++)
+ l->push_back(mListOfSimpleInputWidget[i]->GetSelectedInput());
+ return *l;
}
//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::AnImageIsBeingClosed(vvSlicerManager * m) {
+ DD("TODO : verify that the image still exist !!");
+ // for(int i=0; i<
+}
+//------------------------------------------------------------------------------
+
+
#endif
Program: vv
Module: $RCSfile: vvToolInputSelectorWidget.h,v $
Language: C++
- Date: $Date: 2010/03/01 15:38:09 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.5 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
#include <QtDesigner/QDesignerExportWidget>
#include <QDialog>
#include "ui_vvToolInputSelectorWidget.h"
-#include "vvImage.h"
class vvSlicerManager;
+class vvToolSimpleInputSelectorWidget;
//------------------------------------------------------------------------------
class vvToolInputSelectorWidget: public QWidget, private Ui::vvToolInputSelectorWidget
vvToolInputSelectorWidget(QWidget * parent=0, Qt::WindowFlags f=0);
~vvToolInputSelectorWidget() {}
- void Initialize(std::vector<vvSlicerManager*> l, int index);
- int GetSelectedInputIndex() { return mCurrentIndex; }
+ void AddInputSelector(const std::vector<vvSlicerManager*> & l, int index);
+ void Initialize();
+ std::vector<vvSlicerManager*> & GetSelectedInputs();
+ void AnImageIsBeingClosed(vvSlicerManager * m);
+ int GetNumberOfInput();
public slots:
- void accept();
+ void accept(); // to change ! in something like acceptOneMoreInput
void reject();
- void changeInput(int i);
signals:
void accepted();
void rejected();
protected:
+ void AddInputSelector(vvToolSimpleInputSelectorWidget * input,
+ std::vector<vvSlicerManager*> l, int index);
Ui::vvToolInputSelectorWidget ui;
std::vector<vvSlicerManager*> mSlicerManagerList;
int mCurrentIndex;
vvSlicerManager * mCurrentSliceManager;
-
+ int mNumberOfAcceptedInputs;
+ std::vector<vvToolSimpleInputSelectorWidget *> mListOfSimpleInputWidget;
}; // end class vvToolInputSelectorWidget
//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolWidgetBase.cxx,v $
Language: C++
- Date: $Date: 2010/03/01 15:38:09 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2008
mMainWindowBase = parent;
setModal(false);
setAttribute(Qt::WA_DeleteOnClose);
+ mCurrentSlicerManager = 0;
// GUI Initialization
setupUi(this);
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+// void vvToolWidgetBase::SetNumberOfNeededInputs(int nb) {
+// mNumberOfInputs = nb;
+// mListOfFilters.resize(nb);
+// for(int i=0; i<mNumberOfInputs; i++) mListOfFilters[i] = 0;
+// }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::AddInputSelector(clitk::ImageToImageGenericFilterBase * f) {
+ DD("AddInputSelector with filter");
+ DD(mMainWindowBase->GetSlicerManagers().size());
+ int j=0;
+ mFilter = f;
+ mSlicerManagersCompatible.clear();
+ // mToolInputSelectionWidget->setToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str()));
+ for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
+ DD(i);
+ vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
+ if (mFilter->CheckImageType(s->GetNumberOfDimensions(),
+ s->GetNumberOfScalarComponents(),
+ s->GetScalarTypeAsString())) {
+ mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+ if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
+ j++;
+ }
+ }
+ mToolInputSelectionWidget->AddInputSelector(mSlicerManagersCompatible, mCurrentCompatibleIndex);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::AddInputSelector() {
+ DD("AddInput without filter");
+ DD(mMainWindowBase->GetSlicerManagers().size());
+ mSlicerManagersCompatible.clear();
+ for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
+ mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+ }
+ mToolInputSelectionWidget->AddInputSelector(mMainWindowBase->GetSlicerManagers(),
+ mMainWindowBase->GetSlicerManagerCurrentIndex());
+}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvToolWidgetBase::show() {
if (!mIsInitialized) {
- InitializeInputs();
+ DD("show -> init");
+ mToolInputSelectionWidget->Initialize();
+ mIsInitialized = true;
}
QDialog::show();
}
//------------------------------------------------------------------------------
bool vvToolWidgetBase::close() {
+ DD("vvToolWidgetBase::close()");
return QDialog::close();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) {
+ mToolInputSelectionWidget->AnImageIsBeingClosed(m);
if (m == mCurrentSlicerManager) {
close();
}
//------------------------------------------------------------------------------
void vvToolWidgetBase::InitializeInputs() {
+ /*
if (mFilter) {
int j=0;
mToolInputSelectionWidget->setToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str()));
for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
if (mFilter->CheckImageType(s->GetNumberOfDimensions(),
- s->GetNumberOfScalarComponents(),
- s->GetScalarTypeAsString())) {
- mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
- if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
- j++;
+ s->GetNumberOfScalarComponents(),
+ s->GetScalarTypeAsString())) {
+ mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+ if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
+ j++;
}
}
}
mCurrentCompatibleIndex = mMainWindowBase->GetSlicerManagerCurrentIndex();
}
mToolInputSelectionWidget->Initialize(mSlicerManagersCompatible,
- mCurrentCompatibleIndex);
+ mCurrentCompatibleIndex);
mIsInitialized = true;
+ */
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+// void vvToolWidgetBase::SetNumberOfNeededInputs(int i) {
+// DD("SetNumberOfNeededInputs");
+// DD(i);
+// }
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvToolWidgetBase::InputIsSelected() {
- // Common
- int index = mToolInputSelectionWidget->GetSelectedInputIndex();
- mCurrentSlicerManager = mSlicerManagersCompatible[index];
+ DD("InputIsSelected");
+ buttonBox->setEnabled(true);
+ std::vector<vvSlicerManager*> & l = mToolInputSelectionWidget->GetSelectedInputs();
+ mCurrentSlicerManager = l[0];
mCurrentImage = mCurrentSlicerManager->GetImage();
mToolWidget->setEnabled(true);
if (!mCurrentSlicerManager) close();
- InputIsSelected(mCurrentSlicerManager);
+ if (l.size() == 1) InputIsSelected(mCurrentSlicerManager);
+ else InputIsSelected(l);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) {
+ std::cerr << "You MUST overwrite this method vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) if you use one single input" << std::endl;
+ exit(0);
}
//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InputIsSelected(std::vector<vvSlicerManager*> & l) {
+ buttonBox->setEnabled(true);
+ DD("InputIsSelected(vector)");
+ DD(l.size());
+ if (l.size() == 1) InputIsSelected(l[0]);
+ else {
+ std::cerr << "You MUST overwrite this method vvToolWidgetBase::InputIsSelected(vector<vvSlicerManager *> m) if you use several input" << std::endl;
+ exit(0);
+ }
+}
+//------------------------------------------------------------------------------
Program: vv
Module: $RCSfile: vvToolWidgetBase.h,v $
Language: C++
- Date: $Date: 2010/03/01 07:37:25 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2010/03/17 11:22:18 $
+ Version: $Revision: 1.3 $
Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr)
Copyright (C) 2010
vvToolWidgetBase(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
~vvToolWidgetBase();
- virtual void InputIsSelected(vvSlicerManager *m) = 0;
+ virtual void InputIsSelected(vvSlicerManager *m);
+ virtual void InputIsSelected(std::vector<vvSlicerManager*> & l);
+ void AddInputSelector(clitk::ImageToImageGenericFilterBase * f);
+ void AddInputSelector();
public slots:
virtual void apply() = 0;