From 7d75fa08ff542ba0c30fdf47001c1652cb7ac159 Mon Sep 17 00:00:00 2001 From: schaerer Date: Tue, 6 Apr 2010 12:13:44 +0000 Subject: [PATCH] ported the resampler to the new tool framework --- vv/CMakeLists.txt | 6 +- vv/icons/resample.png | Bin 0 -> 258 bytes vv/qt_ui/vvMainWindow.ui | 1 - vv/qt_ui/vvToolResample.ui | 1123 +++++++++++++++++ vv/qt_ui/vvTools.ui | 4 +- vv/vvIcons.qrc | 1 + vv/vvMainWindow.cxx | 13 - vv/vvMainWindow.h | 1 - ...ResamplerDialog.cxx => vvToolResample.cxx} | 179 ++- vv/{vvResamplerDialog.h => vvToolResample.h} | 33 +- 10 files changed, 1233 insertions(+), 128 deletions(-) create mode 100644 vv/icons/resample.png create mode 100644 vv/qt_ui/vvToolResample.ui rename vv/{vvResamplerDialog.cxx => vvToolResample.cxx} (82%) rename vv/{vvResamplerDialog.h => vvToolResample.h} (80%) diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 160fe69..43d7d82 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -71,7 +71,6 @@ SET(vv_SRCS vvQProgressDialogITKCommand.cxx vvQDicomSeriesSelector.cxx QTreePushButton.cxx - vvResamplerDialog.cxx vvSegmentationDialog.cxx vvSurfaceViewerDialog.cxx vvMainWindowBase.cxx @@ -116,6 +115,7 @@ SET(vv_SRCS # vvToolStructureSetManager.cxx # vvStructureSetActor.cxx # vvROIActor.cxx + vvToolResample.cxx ) QT4_WRAP_CPP(vv_SRCS @@ -130,7 +130,6 @@ QT4_WRAP_CPP(vv_SRCS vvHelpDialog.h vvProgressDialog.h vvQDicomSeriesSelector.h - vvResamplerDialog.h vvSegmentationDialog.h vvSurfaceViewerDialog.h vvDeformationDialog.h @@ -150,6 +149,7 @@ QT4_WRAP_CPP(vv_SRCS # vvToolStructureSetManager.h # vvStructureSetActor.h # vvROIActor.h + vvToolResample.h ) QT4_WRAP_UI(vv_UI_CXX @@ -164,7 +164,6 @@ QT4_WRAP_UI(vv_UI_CXX qt_ui/vvDicomSeriesSelector.ui qt_ui/vvSegmentationDialog.ui qt_ui/vvSurfaceViewerDialog.ui - qt_ui/vvResamplerDialog.ui qt_ui/vvDeformationDialog.ui qt_ui/vvStructSelector.ui qt_ui/vvDummyWindow.ui #For testing @@ -177,6 +176,7 @@ QT4_WRAP_UI(vv_UI_CXX qt_ui/vvToolBinarize.ui qt_ui/vvToolImageArithm.ui # qt_ui/vvToolStructureSetManager.ui + qt_ui/vvToolResample.ui ) SET(vvUI_RCCS vvIcons.qrc) diff --git a/vv/icons/resample.png b/vv/icons/resample.png new file mode 100644 index 0000000000000000000000000000000000000000..deaf4163277d8f6e54aaeed6a748bf7f9c10a765 GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4kiW$h8qca7Z?~A7>k44ofy`glX=O&z`&N| z?e4 Tools - diff --git a/vv/qt_ui/vvToolResample.ui b/vv/qt_ui/vvToolResample.ui new file mode 100644 index 0000000..09596da --- /dev/null +++ b/vv/qt_ui/vvToolResample.ui @@ -0,0 +1,1123 @@ + + + vvToolResample + + + + 0 + 0 + 566 + 477 + + + + Form + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 4 + + + + + + + File format + + + + + + + .mhd + + + + + + + + + + + Dimension + + + + + + + TextLabel + + + + + + + + + + + Pixel Type + + + + + + + TextLabel + + + + + + + + + + + Size + + + + + + + TextLabel + + + + + + + + + + + Spacing + + + + + + + TextLabel + + + + + + + + + + + Memory size + + + + + + + TextLabel + + + + + + + + + + + Display result? + + + + + + + + + + true + + + false + + + + + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + + + + 0 + 0 + + + + Size : + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 5 + + + 2 + + + 0 + + + + + + 0 + 0 + + + + x : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Qt::LeftToRight + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + y : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Qt::LeftToRight + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + z : + + + + + + + true + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Qt::LeftToRight + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + Scale size : + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + + + + 50 + 16777215 + + + + true + + + + + + + + 0 + 0 + + + + % + + + + + + + + + + Qt::Horizontal + + + + 50 + 41 + + + + + + + + Iso-size : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + true + + + + + + + Qt::Horizontal + + + + 50 + 23 + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Spacing : + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 5 + + + 2 + + + 0 + + + + + + 0 + 0 + + + + x : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Qt::LeftToRight + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + y : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Qt::LeftToRight + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + z : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Qt::LeftToRight + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + Scale spacing : + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + + + + 50 + 16777215 + + + + true + + + + + + + + 0 + 0 + + + + % + + + + + + + + + + Qt::Horizontal + + + + 50 + 20 + + + + + + + + + 0 + 0 + + + + Iso-spacing : + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + true + + + + + + + Qt::Horizontal + + + + 50 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + Apply Gaussian Filter + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + + 0 + 0 + + + + Gaussian width : + + + + + + + + 40 + 16777215 + + + + + + + + + 40 + 16777215 + + + + + + + false + + + + + + + + 40 + 16777215 + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + Default pixel value : + + + + + + + + 50 + 16777215 + + + + 0.0 + + + + + + + Qt::Horizontal + + + + 121 + 21 + + + + + + + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + Interpolation : + + + + + + + + NN + + + + + Linear + + + + + BSpline + + + + + Blut (faster BSpline) + + + + + + + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + BSpline order : + + + + + + + 5 + + + 3 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + BLUT sampling factor : + + + + + + + 30 + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Output :</span></p></body></html> + + + + + + + + + Size + + + + + + + TextLabel + + + + + + + + + + + Spacing + + + + + + + TextLabel + + + + + + + + + + + Memory size + + + + + + + TextLabel + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + diff --git a/vv/qt_ui/vvTools.ui b/vv/qt_ui/vvTools.ui index f8cd76b..4796321 100644 --- a/vv/qt_ui/vvTools.ui +++ b/vv/qt_ui/vvTools.ui @@ -147,8 +147,8 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Status : <span style=" font-size:10pt; font-weight:600;">*not save*</span></p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt;">Status : </span><span style=" font-weight:600;">*not saved*</span></p></body></html> diff --git a/vv/vvIcons.qrc b/vv/vvIcons.qrc index c3d2df7..9f7c895 100644 --- a/vv/vvIcons.qrc +++ b/vv/vvIcons.qrc @@ -7,6 +7,7 @@ icons/8b.png icons/1b.png icons/binarize.png + icons/resample.png icons/crop.png icons/splashscreen2.png icons/splashscreen.PNG diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 516c736..9914710 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -33,7 +33,6 @@ #include "vvSlicer.h" #include "vvInteractorStyleNavigator.h" #include "vvImageWriter.h" -#include "vvResamplerDialog.h" #include "vvSegmentationDialog.h" #include "vvSurfaceViewerDialog.h" #include "vvDeformationDialog.h" @@ -255,8 +254,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation())); /////////////////////////////////////////////// - contextMenu.addAction(actionResampler); - connect(actionResampler,SIGNAL(triggered()),this,SLOT(ResampleCurrentImage())); connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage())); connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch())); /////////////////////////////////////////////// @@ -2719,16 +2716,6 @@ void vvMainWindow::UpdateRenderWindows() { } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvMainWindow::ResampleCurrentImage() { - vvResamplerDialog resampler; - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - resampler.SetSlicerManagers(mSlicerManagers,index); - if (resampler.exec()) - AddImage(resampler.GetOutput(),resampler.GetOutputFileName()); -} -//------------------------------------------------------------------------------ - //------------------------------------------------------------------------------ void vvMainWindow::SegmentationOnCurrentImage() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index acacde8..60d37d6 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -88,7 +88,6 @@ public slots: void VectorChanged(int visibility, double x, double y, double z, double value); void OverlayChanged(int visibility, double valueOver, double valueRef); void FusionChanged(int visibility, double value); - void ResampleCurrentImage(); void SegmentationOnCurrentImage(); void SurfaceViewerLaunch(); diff --git a/vv/vvResamplerDialog.cxx b/vv/vvToolResample.cxx similarity index 82% rename from vv/vvResamplerDialog.cxx rename to vv/vvToolResample.cxx index 9e4c3ae..202d04e 100644 --- a/vv/vvResamplerDialog.cxx +++ b/vv/vvToolResample.cxx @@ -16,60 +16,32 @@ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ -#ifndef _VVRESAMPLERDIALOG_CXX -#define _VVRESAMPLERDIALOG_CXX - -#include "vvResamplerDialog.h" -#include "clitkImageResampleGenericFilter.h" +#include "vvToolResample.h" #include "vvSlicer.h" +#include "vvToolCreator.h" #include #include #define COLUMN_IMAGE_NAME 7 -//==================================================================== -vvResamplerDialog::vvResamplerDialog(QWidget * parent, Qt::WindowFlags f) - :QDialog(parent,f), Ui::vvResamplerDialog() { - - // initialization - setupUi(this); - Init(); - - // Connect signals & slots - connect(this, SIGNAL(accepted()), this, SLOT(Resample())); - connect(mImagesComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(UpdateCurrentInputImage())); - - connect(sizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); - connect(scaleSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); - connect(isoSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); - connect(spacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); - connect(scaleSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); - connect(isoSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); - - connect(xSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize())); - connect(ySizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize())); - connect(zSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize())); - connect(xSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing())); - connect(ySpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing())); - connect(zSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing())); - connect(scaleSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromScale())); - connect(scaleSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromScale())); - connect(isoSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromIso())); - connect(isoSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromIso())); +ADD_TOOL(vvToolResample); - connect(gaussianFilterCheckBox,SIGNAL(stateChanged(int)),this,SLOT(UpdateGaussianFilter())); - connect(interpolationComboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(UpdateInterpolation())); -} //==================================================================== +vvToolResample::vvToolResample(vvMainWindowBase * parent, Qt::WindowFlags f): + vvToolWidgetBase(parent,f), + vvToolBase(parent), + Ui::vvToolResample() +{ + Ui_vvToolResample::setupUi(mToolWidget); -//==================================================================== -void vvResamplerDialog::Init() { + mFilter = clitk::ImageResampleGenericFilter::New(); mLastError =""; mInputFileFormat = ""; ComponentType = ""; mPixelType = ""; + mCurrentSlicerManager=NULL; mInputSize.resize(0); mInputSpacing.resize(0); @@ -114,21 +86,50 @@ void vvResamplerDialog::Init() { mInputSizeLabel->setPalette(qPalette); mInputSpacingLabel->setPalette(qPalette); - UpdateCurrentInputImage(); + // Set how many inputs are needed for this tool + AddInputSelector("Select an image to resample", mFilter); + + // Connect signals & slots + + connect(sizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); + connect(scaleSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); + connect(isoSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); + connect(spacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); + connect(scaleSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); + connect(isoSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing())); + + connect(xSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize())); + connect(ySizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize())); + connect(zSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize())); + connect(xSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing())); + connect(ySpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing())); + connect(zSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing())); + connect(scaleSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromScale())); + connect(scaleSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromScale())); + connect(isoSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromIso())); + connect(isoSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromIso())); + + connect(gaussianFilterCheckBox,SIGNAL(stateChanged(int)),this,SLOT(UpdateGaussianFilter())); + connect(interpolationComboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(UpdateInterpolation())); } //==================================================================== //==================================================================== -void vvResamplerDialog::UpdateCurrentInputImage() { - // Set current image & index - mCurrentIndex = mImagesComboBox->currentIndex(); - if (mCurrentIndex == -1) { - mCurrentImage = NULL; - return ; - } - mCurrentImage = mSlicerManagers[mCurrentIndex]->GetSlicer(0)->GetImage(); +void vvToolResample::Initialize() { + SetToolName("Resample Image"); + SetToolMenuName("Resample"); + SetToolIconFilename(":/common/icons/resample.png"); + SetToolTip("Resample image with various interpolation methods."); +} +//==================================================================== + +//==================================================================== +void vvToolResample::InputIsSelected(vvSlicerManager* m) { + + mCurrentSlicerManager = m; + mCurrentImage = mCurrentSlicerManager->GetSlicer(0)->GetImage(); if (mCurrentImage.IsNull()) return; - mInputFileName = mSlicerManagers[mCurrentIndex]->GetFileName().c_str(); + mInputFileName = mCurrentSlicerManager->GetFileName().c_str(); // Set current information mPixelType = mCurrentImage->GetScalarTypeAsString().c_str(); @@ -168,7 +169,7 @@ void vvResamplerDialog::UpdateCurrentInputImage() { //==================================================================== //==================================================================== -void vvResamplerDialog::UpdateOutputInfo() { +void vvToolResample::UpdateOutputInfo() { mOutputSizeLabel->setText(GetVectorIntAsString(mOutputSize)); mOutputSpacingLabel->setText(GetVectorDoubleAsString(mOutputSpacing)); mOutputMemoryLabel->setText(GetSizeInBytes(mOutputSize)); @@ -176,7 +177,7 @@ void vvResamplerDialog::UpdateOutputInfo() { //==================================================================== //==================================================================== -QString vvResamplerDialog::GetSizeInBytes(std::vector & size) { +QString vvToolResample::GetSizeInBytes(std::vector & size) { int t = 1; for (unsigned int i=0; iGetScalarSize()*mCurrentImage->GetNumberOfScalarComponents(); @@ -202,7 +203,7 @@ QString vvResamplerDialog::GetSizeInBytes(std::vector & size) { //==================================================================== //==================================================================== -QString vvResamplerDialog::GetVectorDoubleAsString(std::vector vectorDouble) { +QString vvToolResample::GetVectorDoubleAsString(std::vector vectorDouble) { QString result; for (unsigned int i= 0; i vectorDou //==================================================================== //==================================================================== -QString vvResamplerDialog::GetVectorIntAsString(std::vector vectorInt) { +QString vvToolResample::GetVectorIntAsString(std::vector vectorInt) { QString result; for (unsigned int i= 0; i vectorInt) { //==================================================================== //==================================================================== -void vvResamplerDialog::FillSizeEdit(std::vector size) { +void vvToolResample::FillSizeEdit(std::vector size) { xSizeLineEdit->setText(QString::number(size[0])); ySizeLineEdit->setText(QString::number(size[1])); if (size.size() > 2) @@ -235,7 +236,7 @@ void vvResamplerDialog::FillSizeEdit(std::vector size) { //==================================================================== //==================================================================== -void vvResamplerDialog::FillSpacingEdit(std::vector spacing) { +void vvToolResample::FillSpacingEdit(std::vector spacing) { xSpacingLineEdit->setText(QString::number(spacing[0])); ySpacingLineEdit->setText(QString::number(spacing[1])); if (spacing.size() > 2) @@ -244,7 +245,7 @@ void vvResamplerDialog::FillSpacingEdit(std::vector spacing) { //==================================================================== //==================================================================== -void vvResamplerDialog::UpdateOutputSizeAndSpacing() { +void vvToolResample::UpdateOutputSizeAndSpacing() { mOutputSize.resize(mDimension); mOutputSize = mInputSize; mOutputSpacing.resize(mDimension); @@ -264,7 +265,7 @@ void vvResamplerDialog::UpdateOutputSizeAndSpacing() { //==================================================================== //==================================================================== -void vvResamplerDialog::UpdateControlSizeAndSpacing() { +void vvToolResample::UpdateControlSizeAndSpacing() { scaleSizeLineEdit->setText(""); scaleSpacingLineEdit->setText(""); isoSizeLineEdit->setText(""); @@ -308,7 +309,7 @@ void vvResamplerDialog::UpdateControlSizeAndSpacing() { //==================================================================== //==================================================================== -void vvResamplerDialog::ComputeNewSpacingFromSize() { +void vvToolResample::ComputeNewSpacingFromSize() { double newSpacing = mInputSpacing[0]*mInputSize[0]; xSpacingLineEdit->setText(QString::number(newSpacing/xSizeLineEdit->text().toDouble())); newSpacing = mInputSpacing[1]*mInputSize[1]; @@ -323,7 +324,7 @@ void vvResamplerDialog::ComputeNewSpacingFromSize() { //==================================================================== //==================================================================== -void vvResamplerDialog::ComputeNewSizeFromSpacing() { +void vvToolResample::ComputeNewSizeFromSpacing() { double newSize = mInputSpacing[0]*mInputSize[0]; xSizeLineEdit->setText(QString::number(newSize/xSpacingLineEdit->text().toDouble())); newSize = mInputSpacing[1]*mInputSize[1]; @@ -338,7 +339,7 @@ void vvResamplerDialog::ComputeNewSizeFromSpacing() { //==================================================================== //==================================================================== -void vvResamplerDialog::ComputeNewSpacingFromScale() { +void vvToolResample::ComputeNewSpacingFromScale() { xSpacingLineEdit->setText(QString::number(mInputSpacing[0]*scaleSpacingLineEdit->text().toDouble()/100)); ySpacingLineEdit->setText(QString::number(mInputSpacing[1]*scaleSpacingLineEdit->text().toDouble()/100)); if (mDimension > 2) @@ -348,7 +349,7 @@ void vvResamplerDialog::ComputeNewSpacingFromScale() { //==================================================================== //==================================================================== -void vvResamplerDialog::ComputeNewSizeFromScale() { +void vvToolResample::ComputeNewSizeFromScale() { xSizeLineEdit->setText(QString::number(mInputSize[0]*scaleSizeLineEdit->text().toDouble()/100)); ySizeLineEdit->setText(QString::number(mInputSize[1]*scaleSizeLineEdit->text().toDouble()/100)); if (mDimension > 2) @@ -358,7 +359,7 @@ void vvResamplerDialog::ComputeNewSizeFromScale() { //==================================================================== //==================================================================== -void vvResamplerDialog::ComputeNewSpacingFromIso() { +void vvToolResample::ComputeNewSpacingFromIso() { xSpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble())); ySpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble())); if (mDimension > 2) @@ -368,7 +369,7 @@ void vvResamplerDialog::ComputeNewSpacingFromIso() { //==================================================================== //==================================================================== -void vvResamplerDialog::ComputeNewSizeFromIso() { +void vvToolResample::ComputeNewSizeFromIso() { xSizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble())); ySizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble())); if (mDimension > 2) @@ -378,7 +379,7 @@ void vvResamplerDialog::ComputeNewSizeFromIso() { //==================================================================== //==================================================================== -void vvResamplerDialog::UpdateInterpolation() { +void vvToolResample::UpdateInterpolation() { if (interpolationComboBox->currentText() == "BSpline") { bSplineLabel->show(); bSplineOrderSpinBox->show(); @@ -401,7 +402,7 @@ void vvResamplerDialog::UpdateInterpolation() { //==================================================================== //==================================================================== -void vvResamplerDialog::UpdateGaussianFilter() { +void vvToolResample::UpdateGaussianFilter() { if (gaussianFilterCheckBox->isChecked()) { gaussianFilterLabel->show(); xGaussianLineEdit->show(); @@ -418,18 +419,9 @@ void vvResamplerDialog::UpdateGaussianFilter() { } //==================================================================== -//==================================================================== -void vvResamplerDialog::SetSlicerManagers(std::vector & m,int current_image_index) { - mSlicerManagers = m; - for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { - mImagesComboBox->addItem(mSlicerManagers[i]->GetFileName().c_str()); - } - mImagesComboBox->setCurrentIndex(current_image_index); -} -//==================================================================== //==================================================================== -void vvResamplerDialog::Resample() { +void vvToolResample::apply() { // Get resampler options std::vector sigma; @@ -437,36 +429,33 @@ void vvResamplerDialog::Resample() { sigma.push_back(yGaussianLineEdit->text().toDouble()); if (mDimension > 2) sigma.push_back(zGaussianLineEdit->text().toDouble()); - - // Create resampler filter - clitk::ImageResampleGenericFilter::Pointer filter = clitk::ImageResampleGenericFilter::New(); - filter->SetOutputSize(mOutputSize); - filter->SetOutputSpacing(mOutputSpacing); - filter->SetInterpolationName(interpolationComboBox->currentText().toLower().toStdString()); + mFilter->SetOutputSize(mOutputSize); + mFilter->SetOutputSpacing(mOutputSpacing); + mFilter->SetInterpolationName(interpolationComboBox->currentText().toLower().toStdString()); if (interpolationComboBox->currentText() == "BSpline") - filter->SetBSplineOrder(bSplineOrderSpinBox->value()); + mFilter->SetBSplineOrder(bSplineOrderSpinBox->value()); else if (interpolationComboBox->currentText() == "Blut (faster BSpline)") { - filter->SetInterpolationName("blut"); - filter->SetBSplineOrder(bSplineOrderSpinBox->value()); - filter->SetBLUTSampling(bLUTSpinBox->value()); + mFilter->SetInterpolationName("blut"); + mFilter->SetBSplineOrder(bSplineOrderSpinBox->value()); + mFilter->SetBLUTSampling(bLUTSpinBox->value()); } if (gaussianFilterCheckBox->isChecked()) - filter->SetGaussianSigma(sigma); - // filter->SetOutputFileName(OutputFileName.toStdString()); - filter->SetDefaultPixelValue(defaultPixelValueLineEdit->text().toDouble()); - filter->SetInputVVImage(mCurrentImage); + mFilter->SetGaussianSigma(sigma); + // mFilter->SetOutputFileName(OutputFileName.toStdString()); + mFilter->SetDefaultPixelValue(defaultPixelValueLineEdit->text().toDouble()); + mFilter->SetInputVVImage(mCurrentImage); // Go ! - filter->Update(); - mOutput = filter->GetOutputVVImage(); + mFilter->Update(); + mOutput = mFilter->GetOutputVVImage(); + AddImage(mOutput,GetOutputFileName()); + close(); } //==================================================================== -std::string vvResamplerDialog::GetOutputFileName() +std::string vvToolResample::GetOutputFileName() { - QFileInfo info(mImagesComboBox->currentText()); + QFileInfo info(QString(mCurrentSlicerManager->GetFileName().c_str())); return (info.path().toStdString() + "/resampled_" + info.fileName().toStdString()); } -#endif /* end #define _vvResamplerDialog_CXX */ - diff --git a/vv/vvResamplerDialog.h b/vv/vvToolResample.h similarity index 80% rename from vv/vvResamplerDialog.h rename to vv/vvToolResample.h index a5c7dd6..5a72a41 100644 --- a/vv/vvResamplerDialog.h +++ b/vv/vvToolResample.h @@ -15,25 +15,31 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ -#ifndef _VVRESAMPLERDIALOG_H -#define _VVRESAMPLERDIALOG_H -#include "ui_vvResamplerDialog.h" +#ifndef _vvToolResample_h +#define _vvToolResample_h +#include "ui_vvToolResample.h" #include "clitkCommon.h" #include "vvImage.h" #include "vvSlicerManager.h" +#include "vvToolWidgetBase.h" +#include "vvToolBase.h" +#include "clitkImageResampleGenericFilter.h" #include #include //==================================================================== -class vvResamplerDialog : public QDialog, private Ui::vvResamplerDialog { +class vvToolResample : + public vvToolWidgetBase, + public vvToolBase, + private Ui::vvToolResample +{ Q_OBJECT public: // constructor - destructor - vvResamplerDialog(QWidget * parent=0, Qt::WindowFlags f=0); - void SetSlicerManagers(std::vector & m,int current_image_index); + vvToolResample(vvMainWindowBase * parent=0, Qt::WindowFlags f=0); // Get output result vvImage::Pointer GetOutput() { @@ -43,10 +49,11 @@ public: return display_result->checkState() > 0; } std::string GetOutputFileName(); + static void Initialize(); + void apply(); public slots: // void SetImagesList(QTreeWidget * tree); - void Resample(); void UpdateControlSizeAndSpacing(); void ComputeNewSizeFromSpacing(); void ComputeNewSizeFromScale(); @@ -56,13 +63,14 @@ public slots: void ComputeNewSpacingFromIso(); void UpdateInterpolation(); void UpdateGaussianFilter(); - void UpdateCurrentInputImage(); + void InputIsSelected(vvSlicerManager* m); protected: - Ui::vvResamplerDialog ui; - std::vector mSlicerManagers; + Ui::vvToolResample ui; vvImage::Pointer mOutput; + clitk::ImageResampleGenericFilter::Pointer mFilter; + vvSlicerManager* mCurrentSlicerManager; vvImage::Pointer mCurrentImage; int mCurrentIndex; @@ -83,7 +91,6 @@ protected: QStringList OutputListFormat; - void Init(); void UpdateInputInfo(); void UpdateOutputInfo(); void UpdateOutputFormat(); @@ -95,8 +102,8 @@ protected: QString GetVectorDoubleAsString(std::vector vectorDouble); QString GetVectorIntAsString(std::vector vectorInt); -}; // end class vvResamplerDialog +}; // end class vvToolResample //==================================================================== -#endif /* end #define _VVRESAMPLERDIALOG_H */ +#endif -- 2.47.1