From c7c62b61f99ae5c36563613b9a7b4b3b2ec3648b Mon Sep 17 00:00:00 2001 From: dsarrut Date: Mon, 1 Mar 2010 07:37:20 +0000 Subject: [PATCH] - toolbase + binarize --- filters/clitkBinarizeImageGenericFilter.txx | 6 +- tools/clitkSignalMeanPositionTracking.ggo | 2 +- vv/CMakeLists.txt | 2 + vv/qt_ui/vvToolBinarize.ui | 7 +- vv/qt_ui/vvToolCrop.ui | 199 +++++++++++++++++- vv/qt_ui/vvToolCropImage.ui | 213 +++++++++++++++++++- vv/qt_ui/vvToolFoo.ui | 41 +--- vv/vvImageContour.cxx | 39 ++-- vv/vvImageContour.h | 22 +- vv/vvIntensityValueSlider.cxx | 21 +- vv/vvMainWindow.cxx | 6 +- vv/vvSlicer.cxx | 31 ++- vv/vvSlicer.h | 5 + vv/vvToolBase.h | 8 +- vv/vvToolBinarize.cxx | 56 ++++- vv/vvToolBinarize.h | 35 +--- vv/vvToolCropImage.cxx | 96 ++++++++- vv/vvToolCropImage.h | 16 +- vv/vvToolWidgetBase.h | 6 +- 19 files changed, 653 insertions(+), 158 deletions(-) diff --git a/filters/clitkBinarizeImageGenericFilter.txx b/filters/clitkBinarizeImageGenericFilter.txx index 835decc..206b143 100644 --- a/filters/clitkBinarizeImageGenericFilter.txx +++ b/filters/clitkBinarizeImageGenericFilter.txx @@ -22,7 +22,7 @@ namespace clitk template BinarizeImageGenericFilter::BinarizeImageGenericFilter(): ImageToImageGenericFilter("Binarize") { - // InitializeImageType<2>(); + InitializeImageType<2>(); InitializeImageType<3>(); InitializeImageType<4>(); } @@ -33,9 +33,9 @@ namespace clitk template template void BinarizeImageGenericFilter::InitializeImageType() { - //ADD_IMAGE_TYPE(Dim, char); + ADD_IMAGE_TYPE(Dim, char); ADD_IMAGE_TYPE(Dim, short); - //ADD_IMAGE_TYPE(Dim, int); + ADD_IMAGE_TYPE(Dim, int); //ADD_IMAGE_TYPE(Dim, float); } //-------------------------------------------------------------------- diff --git a/tools/clitkSignalMeanPositionTracking.ggo b/tools/clitkSignalMeanPositionTracking.ggo index 46baa88..20072ab 100644 --- a/tools/clitkSignalMeanPositionTracking.ggo +++ b/tools/clitkSignalMeanPositionTracking.ggo @@ -1,5 +1,5 @@ #File clitkSignalMeanPositionTracking.ggo -Package "clitkSignalMeanPositionTracking" +package "clitkSignalMeanPositionTracking" version "1.0" purpose "See Ruan 2008, compute mean position from a signal" diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 8797f8c..d704adc 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -105,6 +105,7 @@ SET(vv_SRCS vvToolCreatorBase.cxx vvToolWidgetBase.cxx vvToolFoo.cxx + vvToolFooWithWidgetBase.cxx vvToolCropImage.cxx vvToolBinarize.cxx vvToolInputSelectorWidget.cxx @@ -133,6 +134,7 @@ QT4_WRAP_CPP(vv_SRCS vvIntensityValueSlider.h vvToolCreatorBase.h vvToolFoo.h + vvToolFooWithWidgetBase.h vvToolBinarize.h vvToolInputSelectorWidget.h vvToolWidgetBase.h diff --git a/vv/qt_ui/vvToolBinarize.ui b/vv/qt_ui/vvToolBinarize.ui index c58f085..eb5f9bd 100644 --- a/vv/qt_ui/vvToolBinarize.ui +++ b/vv/qt_ui/vvToolBinarize.ui @@ -113,13 +113,16 @@ - + - false + true Interactive (unchek to disable on the fly contours drawing) + + true + diff --git a/vv/qt_ui/vvToolCrop.ui b/vv/qt_ui/vvToolCrop.ui index 9a4fa74..0f59687 100644 --- a/vv/qt_ui/vvToolCrop.ui +++ b/vv/qt_ui/vvToolCrop.ui @@ -6,8 +6,8 @@ 0 0 - 192 - 169 + 394 + 220 @@ -123,5 +123,198 @@ - + + + xminSlider + sliderMoved(int) + spin_xmin + setValue(int) + + + 83 + 23 + + + 334 + 25 + + + + + spin_xmin + valueChanged(int) + xminSlider + setValue(int) + + + 334 + 25 + + + 86 + 19 + + + + + xmaxSlider + sliderMoved(int) + spin_xmax + setValue(int) + + + 99 + 54 + + + 334 + 61 + + + + + spin_xmax + valueChanged(int) + xmaxSlider + setValue(int) + + + 334 + 60 + + + 97 + 54 + + + + + yminSlider + sliderMoved(int) + spin_ymin + setValue(int) + + + 102 + 89 + + + 334 + 95 + + + + + spin_ymin + valueChanged(int) + yminSlider + setValue(int) + + + 334 + 82 + + + 111 + 84 + + + + + ymaxSlider + sliderMoved(int) + spin_ymax + setValue(int) + + + 72 + 121 + + + 334 + 125 + + + + + spin_ymax + valueChanged(int) + ymaxSlider + setValue(int) + + + 334 + 123 + + + 86 + 117 + + + + + zminSlider + sliderMoved(int) + spin_zmin + setValue(int) + + + 64 + 156 + + + 334 + 159 + + + + + spin_zmin + valueChanged(int) + zminSlider + setValue(int) + + + 334 + 158 + + + 85 + 159 + + + + + zmaxSlider + sliderMoved(int) + spin_zmax + setValue(int) + + + 75 + 188 + + + 334 + 189 + + + + + spin_zmax + valueChanged(int) + zmaxSlider + setValue(int) + + + 334 + 188 + + + 80 + 192 + + + + diff --git a/vv/qt_ui/vvToolCropImage.ui b/vv/qt_ui/vvToolCropImage.ui index e7c0619..7f27048 100644 --- a/vv/qt_ui/vvToolCropImage.ui +++ b/vv/qt_ui/vvToolCropImage.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 472 + 292 @@ -23,13 +23,6 @@ - - - - Qt::Horizontal - - - @@ -118,10 +111,210 @@ + + + + Qt::Horizontal + + + - + + + spin_xmin + valueChanged(int) + xminSlider + setValue(int) + + + 412 + 37 + + + 308 + 37 + + + + + xminSlider + sliderMoved(int) + spin_xmin + setValue(int) + + + 227 + 38 + + + 418 + 39 + + + + + xmaxSlider + sliderMoved(int) + spin_xmax + setValue(int) + + + 311 + 82 + + + 412 + 85 + + + + + yminSlider + sliderMoved(int) + spin_ymin + setValue(int) + + + 321 + 126 + + + 412 + 128 + + + + + ymaxSlider + sliderMoved(int) + spin_ymax + setValue(int) + + + 246 + 171 + + + 417 + 167 + + + + + zminSlider + sliderMoved(int) + spin_zmin + setValue(int) + + + 291 + 214 + + + 412 + 213 + + + + + zmaxSlider + sliderMoved(int) + spin_zmax + setValue(int) + + + 250 + 257 + + + 415 + 253 + + + + + spin_xmax + valueChanged(int) + xmaxSlider + setValue(int) + + + 412 + 83 + + + 285 + 84 + + + + + spin_ymin + valueChanged(int) + yminSlider + setValue(int) + + + 412 + 126 + + + 304 + 127 + + + + + spin_ymax + valueChanged(int) + ymaxSlider + setValue(int) + + + 412 + 165 + + + 305 + 169 + + + + + spin_zmin + valueChanged(int) + zminSlider + setValue(int) + + + 412 + 213 + + + 319 + 210 + + + + + spin_zmax + valueChanged(int) + zmaxSlider + setValue(int) + + + 413 + 259 + + + 308 + 254 + + + + diff --git a/vv/qt_ui/vvToolFoo.ui b/vv/qt_ui/vvToolFoo.ui index 9748f2b..eab637a 100644 --- a/vv/qt_ui/vvToolFoo.ui +++ b/vv/qt_ui/vvToolFoo.ui @@ -13,37 +13,16 @@ Form - - - - 150 - 90 - 75 - 23 - - - - Foo ! - - + + + + + Foo ! + + + + - - - pushButton - clicked() - vvToolFoo - close() - - - 220 - 135 - - - 100 - -18 - - - - + diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 85a9f2b..88924c1 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvImageContour.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.4 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -28,9 +28,12 @@ #include "vvImageContour.h" #include #include +#include #include #include #include +#include +#include //------------------------------------------------------------------------------ vvImageContour::vvImageContour() { @@ -57,7 +60,6 @@ void vvImageContour::setSlicer(vvSlicer * slicer) { mSlicer = slicer; for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { - // DD(numImage); vtkImageClip * mClipper = vtkImageClip::New(); vtkMarchingSquares * mSquares = vtkMarchingSquares::New(); vtkPolyDataMapper * mSquaresMapper = vtkPolyDataMapper::New(); @@ -77,31 +79,42 @@ void vvImageContour::setSlicer(vvSlicer * slicer) { mSquaresList.push_back(mSquares); mClipperList.push_back(mClipper); } - //mSquares->Update(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::removeActors() { - // DD("removeActors"); +void vvImageContour::hideActors() { if (!mSlicer) return; mSlice = mSlicer->GetSlice(); - // DD(mSlice); for(unsigned int i=0; iVisibilityOff(); - //mSquaresActorList[i]->Update(); } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::update(int value) { - // DD(value); +void vvImageContour::showActors() { if (!mSlicer) return; mSlice = mSlicer->GetSlice(); + mTSlice = mSlicer->GetTSlice(); + // for(unsigned int i=0; iVisibilityOn(); + update(mValue); + //} +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvImageContour::update(int value) { + mValue= value; + if (!mSlicer) return; + // how to not update if not visible ? + + mSlice = mSlicer->GetSlice(); // Only change actor visibility if tslice change if (mTSlice != mSlicer->GetTSlice()) { if (mTSlice != -1) @@ -133,36 +146,30 @@ void vvImageContour::update(int value) { if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > mSlice) { mSquaresActor->SetPosition(1,0,0); - // mSquaresActor2->SetPosition(1,0,0); } else { mSquaresActor->SetPosition(-1,0,0); - // mSquaresActor2->SetPosition(-1,0,0); } break; case 2: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > mSlice) { mSquaresActor->SetPosition(0,1,0); - // mSquaresActor2->SetPosition(0,1,0); } else { mSquaresActor->SetPosition(0,-1,0); - // mSquaresActor2->SetPosition(0,-1,0); } break; case 4: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > mSlice) { mSquaresActor->SetPosition(0,0,1); - // mSquaresActor2->SetPosition(0,0,1); } else { mSquaresActor->SetPosition(0,0,-1); - // mSquaresActor2->SetPosition(0,0,-1); } break; } diff --git a/vv/vvImageContour.h b/vv/vvImageContour.h index be96b05..3bf4a6e 100644 --- a/vv/vvImageContour.h +++ b/vv/vvImageContour.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvImageContour.h,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.4 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -28,34 +28,30 @@ #ifndef VVIMAGECONTOUR_H #define VVIMAGECONTOUR_H -#include -#include -#include -#include -#include -#include -#include - #include "clitkCommon.h" #include "vvSlicer.h" +class vtkImageClip; +class vtkMarchingSquares; +class vtkActor; //------------------------------------------------------------------------------ class vvImageContour { // Q_OBJECT - public: + public: vvImageContour(); ~vvImageContour(); void setSlicer(vvSlicer * slicer); - // vtkActor * getActor() { return mSquaresActor;} void update(int value); - void removeActors(); + void hideActors(); + void showActors(); protected: vvSlicer * mSlicer; int mSlice; int mTSlice; + int mValue; std::vector mClipperList; std::vector mSquaresList; diff --git a/vv/vvIntensityValueSlider.cxx b/vv/vvIntensityValueSlider.cxx index 55ae8f2..c1973af 100644 --- a/vv/vvIntensityValueSlider.cxx +++ b/vv/vvIntensityValueSlider.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvIntensityValueSlider.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.4 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -26,7 +26,6 @@ =========================================================================*/ #include "vvIntensityValueSlider.h" -#include "clitkCommon.h" //------------------------------------------------------------------------------ vvIntensityValueSlider::vvIntensityValueSlider(QWidget * parent, Qt::WindowFlags f) @@ -47,15 +46,12 @@ vvIntensityValueSlider::vvIntensityValueSlider(QWidget * parent, Qt::WindowFlags //------------------------------------------------------------------------------ vvIntensityValueSlider::~vvIntensityValueSlider() { - // DD("Delete vvIntensityValueSlider"); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvIntensityValueSlider::valueChangedFromSpinBox(double v) { - // DD("valueChangedFromSpinBox"); - // DD(v); mSlider->setValue(v); mValue = v; emit valueChanged(v); @@ -65,11 +61,7 @@ void vvIntensityValueSlider::valueChangedFromSpinBox(double v) { //------------------------------------------------------------------------------ void vvIntensityValueSlider::valueChangedFromSlider(int v) { - // DD("valueChangedFromSlider"); - // DD(v); - // DD(v*mSliderFactor); mSpinBox->setValue(v*mSliderFactor); - // emit valueChanged(v*mSliderFactor); } //------------------------------------------------------------------------------ @@ -120,13 +112,6 @@ void vvIntensityValueSlider::SetMinimum(double min) { //------------------------------------------------------------------------------ void vvIntensityValueSlider::Update() { - // DD(mImage->GetScalarTypeAsString()); -// DD(mImage->GetFirstVTKImageData()->GetScalarTypeMax()); -// DD(mImage->GetFirstVTKImageData()->GetScalarTypeMin()); - - // double max = mImage->GetFirstVTKImageData()->GetScalarTypeMax(); -// double min = mImage->GetFirstVTKImageData()->GetScalarTypeMin(); - if (mImage->IsScalarTypeInteger()) { mSpinBox->setSingleStep(1.0); @@ -137,8 +122,6 @@ void vvIntensityValueSlider::Update() { mImage->GetFirstVTKImageData()->GetScalarRange(range); mMin = range[0]; mMax = range[1]; - // DD(mMax); -// DD(mMin); mSlider->setMaximum(mMax); mSlider->setMinimum(mMin); mSpinBox->setMaximum(mMax); diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 924bf19..9d179e3 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvMainWindow.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.12 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.13 $ Author : Pierre Seroul (pierre.seroul@gmail.com) Copyright (C) 200COLUMN_IMAGE_NAME @@ -2350,7 +2350,7 @@ void vvMainWindow::NOVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); - //mSlicerManagers[i]->UpdateSlice(0); // <-- NO ! too much update... + mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? break; } } diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 35897dd..66a62ed 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -78,6 +78,7 @@ vvSlicer::vvSlicer() { mImage = NULL; mCurrentTSlice = 0; + mUseReducedExtent = false; mCurrent[0] = -VTK_DOUBLE_MAX; mCurrent[1] = -VTK_DOUBLE_MAX; @@ -165,6 +166,21 @@ vtkCornerAnnotation* vvSlicer::GetAnnotation() { return ca.GetPointer(); } +//------------------------------------------------------------------------------ +void vvSlicer::EnableReducedExtent(bool b) { + mUseReducedExtent = b; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvSlicer::SetReducedExtent(int * ext) { + mReducedExtent = ext; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate) { @@ -551,7 +567,16 @@ void vvSlicer::UpdateDisplayExtent() return; } input->UpdateInformation(); - int *w_ext = input->GetWholeExtent(); + int *w_ext;// = input->GetWholeExtent(); + + if (mUseReducedExtent) { + w_ext = mReducedExtent; + } + else w_ext = input->GetWholeExtent(); + + DD(w_ext[0]); + DD(w_ext[1]); + DD(w_ext[2]); switch (this->SliceOrientation) { @@ -1140,7 +1165,11 @@ void vvSlicer::UpdateLandmarks() //---------------------------------------------------------------------------- void vvSlicer::SetSlice(int slice) { + DD("vvSlicer::SetSlice"); + DD(slice); int *range = this->GetSliceRange(); + DD(range[0]); + DD(range[1]); if (range) { if (slice < range[0]) diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 7060b25..e96a5b1 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -162,6 +162,9 @@ public: virtual void SetColorWindow(double s); virtual void SetColorLevel(double s); + void EnableReducedExtent(bool b); + void SetReducedExtent(int * ext); + protected: vvSlicer(); ~vvSlicer(); @@ -205,6 +208,8 @@ protected: int mSubSampling; int mScale; int mVFLog; + bool mUseReducedExtent; + int * mReducedExtent; private: void UpdateOrientation(); diff --git a/vv/vvToolBase.h b/vv/vvToolBase.h index 005217f..e86b040 100644 --- a/vv/vvToolBase.h +++ b/vv/vvToolBase.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolBase.h,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.4 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -43,6 +43,10 @@ public: static void SetToolIconFilename(QString n) { vvToolCreator::mSingleton->mToolIconFilename = n; } static void SetToolTip(QString n) { vvToolCreator::mSingleton->mToolTip = n; } + void AddImage(vvImage::Pointer image,std::string filename) { + CREATOR(ToolType)->GetMainWindow()->AddImage(image,filename); + } + }; //------------------------------------------------------------------------------ diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index bccf021..2d6a410 100644 --- a/vv/vvToolBinarize.cxx +++ b/vv/vvToolBinarize.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolBinarize.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.8 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.9 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -61,6 +61,7 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f) { // GUI Initialization Ui_vvToolBinarize::setupUi(mToolWidget); + mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); // Connect signals & slots connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double))); @@ -68,6 +69,7 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f) connect(mRadioButtonLowerThan, SIGNAL(toggled(bool)), this, SLOT(enableLowerThan(bool))); connect(mCheckBoxUseFG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); connect(mCheckBoxUseBG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); + connect(mCheckBoxInteractiveDisplay, SIGNAL(toggled(bool)), this, SLOT(InteractiveDisplayToggled(bool))); // Initialize some widget mThresholdSlider1->SetText(""); @@ -87,6 +89,47 @@ vvToolBinarize::~vvToolBinarize() { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvToolBinarize::InteractiveDisplayToggled(bool b) { + mInteractiveDisplayIsEnabled = b; + if (!mInteractiveDisplayIsEnabled) { + RemoveVTKObjects(); + } + else { + for(unsigned int i=0; ishowActors(); + if (mCurrentSlicerManager) + mCurrentSlicerManager->Render(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolBinarize::RemoveVTKObjects() { + for(unsigned int i=0; ihideActors(); + if (mCurrentSlicerManager) + mCurrentSlicerManager->Render(); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +bool vvToolBinarize::close() { + RemoveVTKObjects(); + return vvToolWidgetBase::close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolBinarize::reject() { + RemoveVTKObjects(); + return vvToolWidgetBase::reject(); +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvToolBinarize::enableLowerThan(bool b) { if (!b) { @@ -143,6 +186,7 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) { //------------------------------------------------------------------------------ void vvToolBinarize::UpdateSlice(int slicer,int slices) { + if (!mInteractiveDisplayIsEnabled) return; if (!mCurrentSlicerManager) close(); for(int i=0;iNumberOfSlicers(); i++) { mImageContour[i]->update(mThresholdSlider1->GetValue()); @@ -184,7 +228,6 @@ void vvToolBinarize::GetArgsInfoFromGUI() { mArgsInfo.fg_arg = mFGSlider->GetValue(); mArgsInfo.bg_arg = mBGSlider->GetValue(); - // DD(inverseBGandFG); if (inverseBGandFG) { mArgsInfo.fg_arg = mFGSlider->GetValue(); mArgsInfo.bg_arg = mBGSlider->GetValue(); @@ -225,8 +268,8 @@ void vvToolBinarize::apply() { // Output ??? vvImage::Pointer output = filter->GetOutputVVImage(); std::ostringstream osstream; - osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName(); - CREATOR(vvToolBinarize)->GetMainWindow()->AddImage(output,osstream.str()); + osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; + AddImage(output,osstream.str()); close(); } //------------------------------------------------------------------------------ @@ -246,7 +289,8 @@ void vvToolBinarize::valueChangedT1(double v) { // DD(mCurrentSlicerManager->GetSlicer(0)); mThresholdSlider2->SetMinimum(v); int m1 = (int)lrint(v); - + + if (!mInteractiveDisplayIsEnabled) return; for(int i=0;iNumberOfSlicers(); i++) { mImageContour[i]->update(m1); } diff --git a/vv/vvToolBinarize.h b/vv/vvToolBinarize.h index f29d119..0453ad1 100644 --- a/vv/vvToolBinarize.h +++ b/vv/vvToolBinarize.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolBinarize.h,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.7 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -29,7 +29,6 @@ #define VVTOOLBINARIZE_H #include -//#include #include "vvToolBase.h" #include "vvToolWidgetBase.h" @@ -37,15 +36,6 @@ #include "ui_vvToolBinarize.h" #include "clitkBinarizeImage_ggo.h" -#include "vtkMarchingSquares.h" -#include "vtkImageClip.h" -#include "vtkMarchingCubes.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkActor.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" - //------------------------------------------------------------------------------ class vvToolBinarize: public vvToolWidgetBase, @@ -64,32 +54,23 @@ class vvToolBinarize: //----------------------------------------------------- public slots: - void apply(); + virtual void apply(); + virtual bool close(); + virtual void reject(); 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); - virtual bool close() { DD("vvToolBinarize::close"); - for(unsigned int i=0; iremoveActors(); - if (mCurrentSlicerManager) - mCurrentSlicerManager->Render(); - return vvToolWidgetBase::close(); } - - virtual void reject() { DD("vvToolBinarize::reject"); - for(unsigned int i=0; iremoveActors(); - if (mCurrentSlicerManager) - mCurrentSlicerManager->Render(); - return vvToolWidgetBase::reject(); } - + void InteractiveDisplayToggled(bool b); protected: + void RemoveVTKObjects(); Ui::vvToolBinarize ui; args_info_clitkBinarizeImage mArgsInfo; std::vector mImageContour; + bool mInteractiveDisplayIsEnabled; }; // end class vvToolBinarize //------------------------------------------------------------------------------ diff --git a/vv/vvToolCropImage.cxx b/vv/vvToolCropImage.cxx index 126a46f..a8cec28 100644 --- a/vv/vvToolCropImage.cxx +++ b/vv/vvToolCropImage.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolCropImage.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:43:37 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.2 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -26,6 +26,14 @@ =========================================================================*/ #include "vvToolCropImage.h" +#include +#include +#include +#include +#include +#include +#include +#include "vvSlicer.h" //------------------------------------------------------------------------------ // Create the tool and automagically (I like this word) insert it in @@ -39,13 +47,13 @@ vvToolCropImage::vvToolCropImage(vvMainWindowBase * parent, Qt::WindowFlags f): vvToolWidgetBase(parent, f), vvToolBase(parent), Ui::vvToolCropImage() { + // GUI Initialization Ui_vvToolCropImage::setupUi(mToolWidget); + mReducedExtent = new int[6]; // TO CHANGE !! nb dim - // Initialize the input selection - //UpdateInfoFromMainWindow(); - // InitializeListOfInputImages(*mMainWindowToolInfo->mSlicerManagers, -// mMainWindowToolInfo->mSlicerManagerCurrentIndex); + // Connect + connect(xminSlider, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoved(int))); } //------------------------------------------------------------------------------ @@ -57,8 +65,82 @@ vvToolCropImage::~vvToolCropImage() { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderMoved(int s) { + DD(s); + mReducedExtent[0] = xminSlider->value(); + for(int i=0; iNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mReducedExtent); + } +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) { - DD("InputIsSelected"); + DD("InputIsSelected"); + + mReducedExtent = mCurrentSlicerManager->GetImage()->GetFirstVTKImageData()->GetWholeExtent(); + DD(mReducedExtent[0]); + DD(mReducedExtent[1]); + + + // TODO : set min/max + std::vector imsize = mCurrentSlicerManager->GetImage()->GetSize(); + xminSlider->setMaximum(imsize[0]-1); + xmaxSlider->setMaximum(imsize[0]-1); + xmaxSlider->setValue(imsize[0]-1); + yminSlider->setMaximum(imsize[1]-1); + ymaxSlider->setMaximum(imsize[1]-1); + ymaxSlider->setValue(imsize[1]-1); + zminSlider->setMaximum(imsize[2]-1); + zmaxSlider->setMaximum(imsize[2]-1); + zmaxSlider->setValue(imsize[2]-1); + spin_xmin->setMaximum(imsize[0]-1); + spin_xmax->setMaximum(imsize[0]-1); + spin_xmax->setValue(imsize[0]-1); + spin_ymin->setMaximum(imsize[1]-1); + spin_ymax->setMaximum(imsize[1]-1); + spin_ymax->setValue(imsize[1]-1); + spin_zmin->setMaximum(imsize[2]-1); + spin_zmax->setMaximum(imsize[2]-1); + spin_zmax->setValue(imsize[2]-1); } //------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::apply() { + DD("apply"); + + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + vvImage::Pointer mResult=vvImage::New(); + //vvSlicerManager * current=mSlicerManagers[inputSequenceBox->currentIndex()]; + vvImage::Pointer image= mCurrentSlicerManager->GetImage(); + for (std::vector::const_iterator i=image->GetVTKImages().begin(); + i!=image->GetVTKImages().end();i++) + { + vtkSmartPointer filter=vtkSmartPointer::New(); + ///Vtk is very weird, you need to "translate the extent" to get the correct origin + //http://markmail.org/message/vndc2tr6kcabiakp#query:vtkImageClip%20origin+page:1+mid:6na7y57floutklvz+state:results + vtkSmartPointer translate=vtkSmartPointer::New(); + filter->SetInput(*i); + filter->SetOutputWholeExtent(xminSlider->value(),xmaxSlider->value(), + yminSlider->value(),ymaxSlider->value(), + zminSlider->value(),zmaxSlider->value()); + translate->SetTranslation(-xminSlider->value(),-yminSlider->value(),-zminSlider->value()); + translate->SetInput(filter->GetOutput()); + filter->ClipDataOn(); //Really create a cropped copy of the image + translate->Update(); + vtkImageData* output=vtkImageData::New(); + output->ShallowCopy(translate->GetOutput()); + mResult->AddImage(output); + } + QApplication::restoreOverrideCursor(); + + AddImage(mResult,"crop.mhd"); + + close(); +} +//------------------------------------------------------------------------------ + diff --git a/vv/vvToolCropImage.h b/vv/vvToolCropImage.h index c039653..42b85b7 100644 --- a/vv/vvToolCropImage.h +++ b/vv/vvToolCropImage.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolCropImage.h,v $ Language: C++ - Date: $Date: 2010/02/24 11:43:37 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.2 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -47,17 +47,11 @@ class vvToolCropImage: vvToolCropImage(vvMainWindowBase * parent=0, Qt::WindowFlags f=0); ~vvToolCropImage(); - //----------------------------------------------------- - typedef vvToolCropImage Self; - bool close() { return QWidget::close(); } virtual void InputIsSelected(vvSlicerManager *m); - //void AnImageIsBeingClosed(vvSlicerManager * m) { vvToolWidgetBase::TTAnImageIsBeingClosed(m); } - - void bar() { DD("crop::bar"); } - public slots: - void apply() { DD("Apply"); } + virtual void apply(); + void sliderMoved(int s); //----------------------------------------------------- static void Initialize() { @@ -69,7 +63,7 @@ public slots: protected: Ui::vvToolCropImage ui; - + int * mReducedExtent; }; // end class vvToolCropImage //------------------------------------------------------------------------------ diff --git a/vv/vvToolWidgetBase.h b/vv/vvToolWidgetBase.h index 225b5f2..4c5ca4d 100644 --- a/vv/vvToolWidgetBase.h +++ b/vv/vvToolWidgetBase.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolWidgetBase.h,v $ Language: C++ - Date: $Date: 2010/02/24 11:43:37 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010/03/01 07:37:25 $ + Version: $Revision: 1.2 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -48,10 +48,10 @@ class vvToolWidgetBase: public slots: virtual void apply() = 0; + virtual bool close(); void InputIsSelected(); void AnImageIsBeingClosed(vvSlicerManager * m); void show(); - virtual bool close(); protected: void InitializeInputs(); -- 2.47.1