From 98bdb72d057c122863776f8c3fb74659e8c87beb Mon Sep 17 00:00:00 2001 From: dsarrut Date: Mon, 1 Mar 2010 15:37:41 +0000 Subject: [PATCH] - autotool --- common/clitkCommon.h | 14 -- common/clitkImageToImageGenericFilter.txx | 62 +++-- filters/clitkBinarizeImageGenericFilter.txx | 19 +- vv/CMakeLists.txt | 15 +- vv/vvMainWindow.cxx | 35 ++- vv/vvMainWindow.h | 2 +- vv/vvSlicer.cxx | 125 +++++++++- vv/vvSlicer.h | 1 + vv/vvToolBinarize.cxx | 21 +- vv/vvToolCropImage.cxx | 258 ++++++++++++++++---- vv/vvToolCropImage.h | 19 +- vv/vvToolInputSelectorWidget.cxx | 11 +- vv/vvToolInputSelectorWidget.h | 5 +- vv/vvToolWidgetBase.cxx | 7 +- 14 files changed, 422 insertions(+), 172 deletions(-) diff --git a/common/clitkCommon.h b/common/clitkCommon.h index c4d772d..3a12a00 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -14,20 +14,6 @@ // clitk include #include "clitkPortability.h" -// std include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - // itk include (include std) #include #include diff --git a/common/clitkImageToImageGenericFilter.txx b/common/clitkImageToImageGenericFilter.txx index 7959ba3..6febe19 100644 --- a/common/clitkImageToImageGenericFilter.txx +++ b/common/clitkImageToImageGenericFilter.txx @@ -3,10 +3,10 @@ Program: vv Module: $RCSfile: clitkImageToImageGenericFilter.txx,v $ Language: C++ - Date: $Date: 2010/02/18 14:47:20 $ - Version: $Revision: 1.6 $ + Date: $Date: 2010/03/01 15:37:41 $ + Version: $Revision: 1.7 $ Author : Joel Schaerer - David Sarrut + David Sarrut Copyright (C) 2008 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr @@ -49,10 +49,10 @@ typename ImageType::Pointer clitk::ImageToImageGenericFilterBase::GetInput(unsig else if (mInputVVImages.size() > n) return typename ImageType::Pointer(const_cast(vvImageToITK(mInputVVImages[n]).GetPointer())); else - { - assert(false); //No input, this shouldn't happen - return typename ImageType::Pointer(NULL); - } + { + assert(false); //No input, this shouldn't happen + return typename ImageType::Pointer(NULL); + } } //-------------------------------------------------------------------- @@ -60,8 +60,8 @@ typename ImageType::Pointer clitk::ImageToImageGenericFilterBase::GetInput(unsig //-------------------------------------------------------------------- template clitk::ImageToImageGenericFilter::ImageToImageGenericFilter(std::string filterName) : - ImageToImageGenericFilterBase(filterName), - mImageTypesManager(static_cast(this)) + ImageToImageGenericFilterBase(filterName), + mImageTypesManager(static_cast(this)) { } //-------------------------------------------------------------------- @@ -83,39 +83,47 @@ bool clitk::ImageToImageGenericFilter::Update() { mImageTypesManager.DoIt(mDim, mNbOfComponents, mPixelTypeName); return true; } +//-------------------------------------------------------------------- + //-------------------------------------------------------------------- template bool clitk::ImageToImageGenericFilter::CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) { - return static_cast(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]); + return static_cast(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]); } +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- template bool clitk::ImageToImageGenericFilter::CheckImageType() { - return static_cast(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]); + return static_cast(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]); } +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- template std::string clitk::ImageToImageGenericFilter::GetAvailableImageTypes() { - std::ostringstream oss; - oss << "The filter <" << mFilterName << "> manages:" << std::endl; + std::ostringstream oss; + oss << "The filter <" << mFilterName << "> manages:" << std::endl; - typedef typename ImageTypesManager::MapOfImageComponentsToFunctionType::const_iterator MCompItType; - typedef typename ImageTypesManager::MapOfImageDimensionToFunctionType::const_iterator MDimItType; - typedef typename ImageTypesManager::MapOfPixelTypeToFunctionType::const_iterator MPixelItType; - for (MDimItType i=mImageTypesManager.mMapOfImageTypeToFunction.begin(); - i!=mImageTypesManager.mMapOfImageTypeToFunction.end(); - i++) { - for (MCompItType j=(*i).second.begin(); j!= (*i).second.end(); j++) { - for (MPixelItType k=(*j).second.begin(); k!= (*j).second.end(); k++) { - oss << "Dim: " << (*i).first - << ", Components: " << (*j).first - << ", Type: " << (*k).first << std::endl; - } - } + typedef typename ImageTypesManager::MapOfImageComponentsToFunctionType::const_iterator MCompItType; + typedef typename ImageTypesManager::MapOfImageDimensionToFunctionType::const_iterator MDimItType; + typedef typename ImageTypesManager::MapOfPixelTypeToFunctionType::const_iterator MPixelItType; + for (MDimItType i=mImageTypesManager.mMapOfImageTypeToFunction.begin(); + i!=mImageTypesManager.mMapOfImageTypeToFunction.end(); + i++) { + for (MCompItType j=(*i).second.begin(); j!= (*i).second.end(); j++) { + for (MPixelItType k=(*j).second.begin(); k!= (*j).second.end(); k++) { + oss << "Dim: " << (*i).first + << ", Components: " << (*j).first + << ", Type: " << (*k).first << std::endl; + } } - return oss.str(); + } + return oss.str(); } //-------------------------------------------------------------------- diff --git a/filters/clitkBinarizeImageGenericFilter.txx b/filters/clitkBinarizeImageGenericFilter.txx index 206b143..cb4e7b9 100644 --- a/filters/clitkBinarizeImageGenericFilter.txx +++ b/filters/clitkBinarizeImageGenericFilter.txx @@ -46,7 +46,6 @@ namespace clitk void BinarizeImageGenericFilter::SetArgsInfo(const args_info_type & a) { mArgsInfo=a; SetIOVerbose(mArgsInfo.verbose_flag); - if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes(); if (mArgsInfo.input_given) { @@ -83,15 +82,15 @@ namespace clitk if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast(mArgsInfo.lower_arg)); if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast(mArgsInfo.upper_arg)); - DD(mArgsInfo.lower_given); - DD(mArgsInfo.upper_given); - DD(mArgsInfo.lower_arg); - DD(mArgsInfo.upper_arg); - DD(mArgsInfo.fg_arg); - DD(mArgsInfo.bg_arg); - DD(mArgsInfo.fg_given); - DD(mArgsInfo.bg_given); - DD(mArgsInfo.mode_arg); + // DD(mArgsInfo.lower_given); + // DD(mArgsInfo.upper_given); + // DD(mArgsInfo.lower_arg); + // DD(mArgsInfo.upper_arg); + // DD(mArgsInfo.fg_arg); + // DD(mArgsInfo.bg_arg); + // DD(mArgsInfo.fg_given); + // DD(mArgsInfo.bg_given); + // DD(mArgsInfo.mode_arg); // <<<<<<< clitkBinarizeImageGenericFilter.txx // DD(mArgsInfo.useFG_flag); diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index d704adc..2f6eb0e 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -97,15 +97,14 @@ SET(vv_SRCS vvMeshActor.cxx vvMeshReader.cxx vvStructSelector.cxx - vvCropDialog.cxx vvMidPosition.cxx vvImageMapToWLColors.cxx vvIntensityValueSlider.cxx vvToolManager.cxx vvToolCreatorBase.cxx vvToolWidgetBase.cxx - vvToolFoo.cxx - vvToolFooWithWidgetBase.cxx +# vvToolFoo.cxx +# vvToolFooWithWidgetBase.cxx vvToolCropImage.cxx vvToolBinarize.cxx vvToolInputSelectorWidget.cxx @@ -130,11 +129,10 @@ QT4_WRAP_CPP(vv_SRCS vvDeformationDialog.h vvSlicerManager.h vvStructSelector.h - vvCropDialog.h vvIntensityValueSlider.h vvToolCreatorBase.h - vvToolFoo.h - vvToolFooWithWidgetBase.h +# vvToolFoo.h +# vvToolFooWithWidgetBase.h vvToolBinarize.h vvToolInputSelectorWidget.h vvToolWidgetBase.h @@ -156,12 +154,11 @@ QT4_WRAP_UI(vv_UI_CXX qt_ui/vvResamplerDialog.ui qt_ui/vvDeformationDialog.ui qt_ui/vvStructSelector.ui - qt_ui/vvCropDialog.ui qt_ui/vvDummyWindow.ui #For testing qt_ui/vvIntensityValueSlider.ui qt_ui/vvToolWidgetBase.ui - qt_ui/vvToolFoo.ui - qt_ui/vvToolCropImage.ui +# qt_ui/vvToolFoo.ui +# qt_ui/vvToolCropImage.ui qt_ui/vvToolBinarize.ui qt_ui/vvToolInputSelectorWidget.ui ) diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 9d179e3..89319bc 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/03/01 07:37:25 $ - Version: $Revision: 1.13 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.14 $ Author : Pierre Seroul (pierre.seroul@gmail.com) Copyright (C) 200COLUMN_IMAGE_NAME @@ -54,7 +54,6 @@ #include "vvMesh.h" #include "vvStructSelector.h" #include "vvMeshReader.h" -#include "vvCropDialog.h" #include "vvConstants.h" #ifdef CLITK_VV_USE_BDCM @@ -142,10 +141,10 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { contextMenu.addSeparator(); - QAction* actionCrop_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/crop.png")), - tr("Crop Current Image")); - connect(actionCrop_image,SIGNAL(triggered()),this,SLOT(CropImage())); - contextActions.push_back(actionCrop_image); + // QAction* actionCrop_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/crop.png")), + // tr("Crop Current Image")); + // connect(actionCrop_image,SIGNAL(triggered()),this,SLOT(CropImage())); + // contextActions.push_back(actionCrop_image); QAction* actionSplit_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/cut.png")), tr("Split Current Image")); @@ -1088,8 +1087,8 @@ void vvMainWindow::ImageInfoChanged() { } windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); - DD(mSlicerManagers[index]->GetColorMap()); - DD(mSlicerManagers[index]->GetPreset()); + // DD(mSlicerManagers[index]->GetColorMap()); + // DD(mSlicerManagers[index]->GetPreset()); presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); @@ -1552,13 +1551,13 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column) { } //------------------------------------------------------------------------------ -void vvMainWindow::CropImage() -{ - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - vvCropDialog crop(mSlicerManagers,index); - if(crop.exec()) - AddImage(crop.GetOutput(),"cropped.mhd"); -} +// void vvMainWindow::CropImage() +// { +// int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); +// vvCropDialog crop(mSlicerManagers,index); +// if(crop.exec()) +// AddImage(crop.GetOutput(),"cropped.mhd"); +// } //------------------------------------------------------------------------------ void vvMainWindow::SplitImage() { @@ -2772,13 +2771,9 @@ void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) { //------------------------------------------------------------------------------ void vvMainWindow::UpdateCurrentSlicer() { - DD("UpdateCurrentSlicer"); int index = -1; - DD(DataTree->selectedItems().size()); if (DataTree->selectedItems().size() > 0) { index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - DD(DataTree->selectedItems()[0]); - DD(index); } mSlicerManagerCurrentIndex = index; } diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index d929374..df525fc 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -131,7 +131,7 @@ public slots: void SaveSOScreenshot(); void ShowContextMenu(QPoint point); - void CropImage(); + // void CropImage(); void SplitImage(); void CloseImage(); void ReloadImage(); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 66a62ed..60ff1e4 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -74,6 +74,7 @@ vtkCxxRevisionMacro(vvSlicer, "DummyRevision"); vtkStandardNewMacro(vvSlicer); +//------------------------------------------------------------------------------ vvSlicer::vvSlicer() { mImage = NULL; @@ -145,26 +146,50 @@ vvSlicer::vvSlicer() this->WindowLevel = vvImageMapToWLColors::New(); this->InstallPipeline(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper() { return mOverlayMapper.GetPointer(); } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ vtkImageActor* vvSlicer::GetOverlayActor() { return mOverlayActor.GetPointer(); } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper() { return mFusionMapper.GetPointer(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ vtkImageActor* vvSlicer::GetFusionActor() { return mFusionActor.GetPointer(); } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ vtkActor* vvSlicer::GetVFActor() { return mVFActor.GetPointer(); } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ vtkCornerAnnotation* vvSlicer::GetAnnotation() { return ca.GetPointer(); } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvSlicer::EnableReducedExtent(bool b) { @@ -194,34 +219,54 @@ void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate) SetContourSlice(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::ToggleContourSuperposition() { for (std::vector::iterator i=mSurfaceCutActors.begin(); i!=mSurfaceCutActors.end();i++) (*i)->ToggleSuperposition(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetCursorColor(int r,int g, int b) { pdmA->GetProperty()->SetColor(r,g,b); } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ void vvSlicer::SetCursorVisibility(bool s) { pdmA->SetVisibility(s); } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ bool vvSlicer::GetCursorVisibility() { return pdmA->GetVisibility(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ vvSlicer::~vvSlicer() { for (std::vector::iterator i=mSurfaceCutActors.begin(); i!=mSurfaceCutActors.end();i++) delete (*i); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetCurrentPosition(double x, double y, double z, int t) { mCurrent[0] = x; @@ -229,7 +274,10 @@ void vvSlicer::SetCurrentPosition(double x, double y, double z, int t) mCurrent[2] = z; mCurrentTSlice = t; } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetImage(vvImage::Pointer image) { if (image->GetVTKImages().size()) @@ -241,7 +289,10 @@ void vvSlicer::SetImage(vvImage::Pointer image) ca->SetText(0,mFileName.c_str()); } } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetOverlay(vvImage::Pointer overlay) { if (overlay->GetVTKImages().size()) @@ -276,7 +327,10 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) SetTSlice(mCurrentTSlice); } } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetFusion(vvImage::Pointer fusion) { if (fusion->GetVTKImages().size()) @@ -302,7 +356,10 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) SetTSlice(mCurrentTSlice); } } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis) { if (actor_type == "vector") @@ -321,7 +378,10 @@ void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_ind this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis); UpdateDisplayExtent(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetVF(vvImage::Pointer vf) { if (vf->GetVTKImages().size()) @@ -373,7 +433,10 @@ void vvSlicer::SetVF(vvImage::Pointer vf) SetTSlice(mCurrentTSlice); } } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetLandmarks(vvLandmarks* landmarks) { mLandmarks = landmarks; @@ -420,7 +483,9 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks) this->GetRenderer()->AddActor(mLandActor); } } +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ //FIXME: this function leaks memory, we should fix it someday :) void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index) { @@ -455,7 +520,10 @@ void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index) mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index); } } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetVFSubSampling(int sub) { if (mVOIFilter) @@ -466,7 +534,10 @@ void vvSlicer::SetVFSubSampling(int sub) UpdateDisplayExtent(); Render(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetVFScale(int scale) { mScale = scale; @@ -475,7 +546,10 @@ void vvSlicer::SetVFScale(int scale) UpdateDisplayExtent(); Render(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetVFLog(int log) { mVFLog = log; @@ -487,7 +561,10 @@ void vvSlicer::SetVFLog(int log) UpdateDisplayExtent(); Render(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetTSlice(int t) { if (t < 0) @@ -517,12 +594,18 @@ void vvSlicer::SetTSlice(int t) (*i)->SetTimeSlice(mCurrentTSlice); UpdateDisplayExtent(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ int vvSlicer::GetTSlice() { return mCurrentTSlice; } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvSlicer::SetSliceOrientation(int orientation) { //if 2D image, force to watch in Axial View @@ -574,10 +657,6 @@ void vvSlicer::UpdateDisplayExtent() } else w_ext = input->GetWholeExtent(); - DD(w_ext[0]); - DD(w_ext[1]); - DD(w_ext[2]); - switch (this->SliceOrientation) { case vtkImageViewer2::SLICE_ORIENTATION_XY: @@ -780,7 +859,10 @@ void vvSlicer::UpdateDisplayExtent() } } } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int vfExtent[6]) { vtkImageData* image=this->GetInput(); @@ -799,7 +881,10 @@ void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z ClipDisplayedExtent(vfExtent,mVOIFilter->GetInput()->GetWholeExtent()); } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6]) { vtkImageData* image=this->GetInput(); @@ -817,7 +902,10 @@ void vvSlicer::ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1, mOverlay->GetSpacing()[2]; ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent()); } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int fusExtent[6]) { vtkImageData* image=this->GetInput(); @@ -835,7 +923,10 @@ void vvSlicer::ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,i mFusion->GetSpacing()[2]; ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent()); } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6]) { bool out = false; @@ -870,7 +961,10 @@ void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6]) extent[i+1] = refExtent[i]; } } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::UpdateOrientation() { // Set the camera position @@ -899,12 +993,18 @@ void vvSlicer::UpdateOrientation() } } } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::SetOpacity(double s) { this->GetImageActor()->SetOpacity(s); } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw) { this->Superclass::SetRenderWindow(rw); @@ -934,7 +1034,10 @@ void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw) SetSliceOrientation(2-(orientation%3)); ResetCamera(); } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::ResetCamera() { if (this->GetInput()) @@ -947,7 +1050,10 @@ void vvSlicer::ResetCamera() this->GetRenderer()->GetActiveCamera()->SetParallelScale(bmax/2); } } +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- void vvSlicer::SetDisplayMode(bool i) { this->GetImageActor()->SetVisibility(i); @@ -1110,8 +1216,10 @@ void vvSlicer::Render() std::stringstream val; val << value; worldPos += "data value : " + val.str(); - worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " + world3.str() + " " + temps.str(); - worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " + pixel3.str() + " " + temps.str(); + worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " + + world3.str() + " " + temps.str(); + worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " + + pixel3.str() + " " + temps.str(); } ca->SetText(1,worldPos.c_str()); } @@ -1143,6 +1251,7 @@ void vvSlicer::UpdateCursorPosition() } //---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicer::UpdateLandmarks() { @@ -1165,11 +1274,7 @@ 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 e96a5b1..1d42e37 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -210,6 +210,7 @@ protected: int mVFLog; bool mUseReducedExtent; int * mReducedExtent; + int * mInitialExtent; private: void UpdateOrientation(); diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index 2d6a410..4f91d19 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/03/01 07:37:25 $ - Version: $Revision: 1.9 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.10 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -114,6 +114,7 @@ void vvToolBinarize::RemoveVTKObjects() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ bool vvToolBinarize::close() { RemoveVTKObjects(); @@ -153,8 +154,6 @@ void vvToolBinarize::useFGBGtoggled(bool) { //------------------------------------------------------------------------------ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) { mCurrentSlicerManager = m; - // Common - mCurrentImage = mCurrentSlicerManager->GetImage(); // Specific for this gui mThresholdSlider1->SetValue(0); @@ -209,6 +208,7 @@ void vvToolBinarize::GetArgsInfoFromGUI() { DD(good); */ + mArgsInfo.imagetypes_flag = 0; mArgsInfo.upper_given = 0; mArgsInfo.lower_given = 0; bool inverseBGandFG = false; @@ -241,7 +241,7 @@ void vvToolBinarize::GetArgsInfoFromGUI() { } else mArgsInfo.mode_arg = (char*)"FG"; - mArgsInfo.verbose_flag = true; + mArgsInfo.verbose_flag = false; // Required (even if not used) mArgsInfo.input_given = 0; @@ -256,20 +256,22 @@ void vvToolBinarize::GetArgsInfoFromGUI() { //------------------------------------------------------------------------------ void vvToolBinarize::apply() { if (!mCurrentSlicerManager) close(); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); GetArgsInfoFromGUI(); // Main filter clitk::BinarizeImageGenericFilter::Pointer filter = - clitk::BinarizeImageGenericFilter::New(); + clitk::BinarizeImageGenericFilter::New(); filter->SetArgsInfo(mArgsInfo); filter->SetInputVVImage(mCurrentImage); filter->Update(); - // Output ??? + // Output vvImage::Pointer output = filter->GetOutputVVImage(); std::ostringstream osstream; osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; AddImage(output,osstream.str()); + QApplication::restoreOverrideCursor(); close(); } //------------------------------------------------------------------------------ @@ -284,12 +286,9 @@ void vvToolBinarize::valueChangedT2(double v) { //------------------------------------------------------------------------------ void vvToolBinarize::valueChangedT1(double v) { - // DD(v); if (!mCurrentSlicerManager) close(); -// DD(mCurrentSlicerManager->GetSlicer(0)); mThresholdSlider2->SetMinimum(v); - int m1 = (int)lrint(v); - + int m1 = (int)lrint(v); if (!mInteractiveDisplayIsEnabled) return; for(int i=0;iNumberOfSlicers(); i++) { mImageContour[i]->update(m1); diff --git a/vv/vvToolCropImage.cxx b/vv/vvToolCropImage.cxx index a8cec28..ba97489 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/03/01 07:37:25 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.3 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -50,10 +50,7 @@ vvToolCropImage::vvToolCropImage(vvMainWindowBase * parent, Qt::WindowFlags f): // GUI Initialization Ui_vvToolCropImage::setupUi(mToolWidget); - mReducedExtent = new int[6]; // TO CHANGE !! nb dim - // Connect - connect(xminSlider, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoved(int))); } //------------------------------------------------------------------------------ @@ -66,11 +63,101 @@ vvToolCropImage::~vvToolCropImage() { //------------------------------------------------------------------------------ -void vvToolCropImage::sliderMoved(int s) { - DD(s); +bool vvToolCropImage::close() { + for(int i=0; i<6; i++) mReducedExtent[i] = mInitialExtent[i]; + UpdateExtent(); + return vvToolWidgetBase::close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::reject() { + for(int i=0; i<6; i++) mReducedExtent[i] = mInitialExtent[i]; + UpdateExtent(); + return vvToolWidgetBase::reject(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderXMinValueChanged(int s) { + xmaxSlider->setMinimum(xminSlider->value()); mReducedExtent[0] = xminSlider->value(); + UpdateExtent(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderXMaxValueChanged(int s) { + xminSlider->setMaximum(xmaxSlider->value()); + mReducedExtent[1] = xmaxSlider->value(); + UpdateExtent(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderYMinValueChanged(int s) { + ymaxSlider->setMinimum(yminSlider->value()); + mReducedExtent[2] = yminSlider->value(); + UpdateExtent(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderYMaxValueChanged(int s) { + yminSlider->setMaximum(ymaxSlider->value()); + mReducedExtent[3] = ymaxSlider->value(); + UpdateExtent(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderZMinValueChanged(int s) { + zmaxSlider->setMinimum(zminSlider->value()); + mReducedExtent[4] = zminSlider->value(); + UpdateExtent(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::sliderZMaxValueChanged(int s) { + zminSlider->setMaximum(zmaxSlider->value()); + mReducedExtent[5] = zmaxSlider->value(); + UpdateExtent(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// void vvToolCropImage::sliderTMinValueChanged(int s) { +// tmaxSlider->setMinimum(tminSlider->value()); +// mReducedExtent[6] = tminSlider->value(); +// UpdateExtent(); +// } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// void vvToolCropImage::sliderTMaxValueChanged(int s) { +// tminSlider->setMaximum(tmaxSlider->value()); +// mReducedExtent[7] = tmaxSlider->value(); +// UpdateExtent(); +// } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::UpdateExtent() { for(int i=0; iNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mReducedExtent); + mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); + mCurrentSlicerManager->GetSlicer(i)->Render(); } } //------------------------------------------------------------------------------ @@ -78,68 +165,135 @@ void vvToolCropImage::sliderMoved(int s) { //------------------------------------------------------------------------------ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) { - DD("InputIsSelected"); + // Change interface according to number of dimension + mExtentSize = 2*slicer->GetDimension(); + // if (slicer->GetDimension()<4) { + // mTLabel1->setHidden(true); + // mTLabel2->setHidden(true); + // tminSlider->setHidden(true); + // tmaxSlider->setHidden(true); + // spin_tmin->setHidden(true); + // spin_tmax->setHidden(true); + // } + if (slicer->GetDimension()<3) { + mZLabel1->setHidden(true); + mZLabel2->setHidden(true); + zminSlider->setHidden(true); + zmaxSlider->setHidden(true); + spin_zmin->setHidden(true); + spin_zmax->setHidden(true); + } + + // Record initial extend + mReducedExtent = new int[mExtentSize]; + mInitialExtent = new int[mExtentSize]; mReducedExtent = mCurrentSlicerManager->GetImage()->GetFirstVTKImageData()->GetWholeExtent(); - DD(mReducedExtent[0]); - DD(mReducedExtent[1]); - + for(int i=0; i<6; i++) mInitialExtent[i] = mReducedExtent[i]; + for(int i=0; iNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(true); + } - // 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); + // Not now .... + // mIntensitySlider->SetImage(mCurrentImage); + //mIntensitySlider->setEnabled(false); + + // Set initial sliders values + 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); + + if (slicer->GetDimension() >2) { 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); + } + + // if (slicer->GetDimension() >3) { + // tminSlider->setMaximum(imsize[3]-1); + // tmaxSlider->setMaximum(imsize[3]-1); + // tmaxSlider->setValue(imsize[3]-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); + + if (slicer->GetDimension() >2) { spin_zmin->setMaximum(imsize[2]-1); spin_zmax->setMaximum(imsize[2]-1); spin_zmax->setValue(imsize[2]-1); + } + + // if (slicer->GetDimension() >3) { + // spin_tmin->setMaximum(imsize[3]-1); + // spin_tmax->setMaximum(imsize[3]-1); + // spin_tmax->setValue(imsize[3]-1); + // } + + // Connect + connect(xminSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderXMinValueChanged(int))); + connect(xmaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderXMaxValueChanged(int))); + connect(yminSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderYMinValueChanged(int))); + connect(ymaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderYMaxValueChanged(int))); + connect(zminSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderZMinValueChanged(int))); + connect(zmaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderZMaxValueChanged(int))); + // connect(tminSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderTMinValueChanged(int))); + // connect(tmaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderTMaxValueChanged(int))); + + // connect(mIntensitySlider, SIGNAL(valueChanged(double)), this, SLOT(autoCropValueChanged(double))); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolCropImage::autoCropValueChanged(double v) { + // DD(v); + // vvImageToITKImageVector -> TODO a generic method + // then sliceriterator on each dimension from in to max + // ==> make a clitkGenericFilter even for the regular apply ... } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ 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++) + + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + vvImage::Pointer mResult=vvImage::New(); + 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); + 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"); - + QApplication::restoreOverrideCursor(); + std::ostringstream osstream; + osstream << "Crop_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; + AddImage(mResult, osstream.str()); close(); } //------------------------------------------------------------------------------ diff --git a/vv/vvToolCropImage.h b/vv/vvToolCropImage.h index 42b85b7..ebd5b83 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/03/01 07:37:25 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.3 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -51,7 +51,17 @@ class vvToolCropImage: public slots: virtual void apply(); - void sliderMoved(int s); + virtual bool close(); + virtual void reject(); + void sliderXMinValueChanged(int s); + void sliderXMaxValueChanged(int s); + void sliderYMinValueChanged(int s); + void sliderYMaxValueChanged(int s); + void sliderZMinValueChanged(int s); + void sliderZMaxValueChanged(int s); + // void sliderTMinValueChanged(int s); + // void sliderTMaxValueChanged(int s); + void autoCropValueChanged(double v); //----------------------------------------------------- static void Initialize() { @@ -64,6 +74,9 @@ public slots: protected: Ui::vvToolCropImage ui; int * mReducedExtent; + int * mInitialExtent; + int mExtentSize; + void UpdateExtent(); }; // end class vvToolCropImage //------------------------------------------------------------------------------ diff --git a/vv/vvToolInputSelectorWidget.cxx b/vv/vvToolInputSelectorWidget.cxx index 217b53b..482c241 100644 --- a/vv/vvToolInputSelectorWidget.cxx +++ b/vv/vvToolInputSelectorWidget.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolInputSelectorWidget.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.2 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.3 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -67,13 +67,6 @@ void vvToolInputSelectorWidget::Initialize(std::vector l, int //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvToolInputSelectorWidget::SetToolTip(QString s) { - setToolTip(s); -} -//------------------------------------------------------------------------------ - - //------------------------------------------------------------------------------ void vvToolInputSelectorWidget::accept() { mInputSelectionButtonBox->setEnabled(false); diff --git a/vv/vvToolInputSelectorWidget.h b/vv/vvToolInputSelectorWidget.h index 0c02651..80a6bde 100644 --- a/vv/vvToolInputSelectorWidget.h +++ b/vv/vvToolInputSelectorWidget.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolInputSelectorWidget.h,v $ Language: C++ - Date: $Date: 2010/02/24 11:42:42 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.4 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -45,7 +45,6 @@ class vvToolInputSelectorWidget: public QWidget, private Ui::vvToolInputSelector void Initialize(std::vector l, int index); int GetSelectedInputIndex() { return mCurrentIndex; } - void SetToolTip(QString s); public slots: void accept(); diff --git a/vv/vvToolWidgetBase.cxx b/vv/vvToolWidgetBase.cxx index c853c75..080e298 100644 --- a/vv/vvToolWidgetBase.cxx +++ b/vv/vvToolWidgetBase.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolWidgetBase.cxx,v $ Language: C++ - Date: $Date: 2010/02/24 11:43:37 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010/03/01 15:38:09 $ + Version: $Revision: 1.2 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -96,7 +96,7 @@ void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) { void vvToolWidgetBase::InitializeInputs() { if (mFilter) { int j=0; - mToolInputSelectionWidget->SetToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str())); + mToolInputSelectionWidget->setToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str())); for(unsigned int i=0; iGetSlicerManagers().size(); i++) { vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage(); if (mFilter->CheckImageType(s->GetNumberOfDimensions(), @@ -124,6 +124,7 @@ void vvToolWidgetBase::InputIsSelected() { // Common int index = mToolInputSelectionWidget->GetSelectedInputIndex(); mCurrentSlicerManager = mSlicerManagersCompatible[index]; + mCurrentImage = mCurrentSlicerManager->GetImage(); mToolWidget->setEnabled(true); if (!mCurrentSlicerManager) close(); InputIsSelected(mCurrentSlicerManager); -- 2.47.1