// clitk include
#include "clitkPortability.h"
-// std include
-//#include <config.h>
-//#include <cstdlib>
-//#include <algorithm>
-//#include <iostream>
-//#include <string>
-//#include <fstream>
-//#include <sstream>
-//#include <vector>
-//#include <math.h>
-//#include <typeinfo>
-//#include <utility>
-//#include <algorithm>
-
// itk include (include std)
#include <itkContinuousIndex.h>
#include <itkMacro.h>
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 <joel.schaerer@creatis.insa-lyon.fr>
- David Sarrut <david.sarrut@creatis.insa-lyon.fr>
+ David Sarrut <david.sarrut@creatis.insa-lyon.fr>
Copyright (C) 2008
Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
else if (mInputVVImages.size() > n)
return typename ImageType::Pointer(const_cast<ImageType*>(vvImageToITK<ImageType>(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);
+ }
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class FilterType>
clitk::ImageToImageGenericFilter<FilterType>::ImageToImageGenericFilter(std::string filterName) :
- ImageToImageGenericFilterBase(filterName),
- mImageTypesManager(static_cast<FilterType*>(this))
+ ImageToImageGenericFilterBase(filterName),
+ mImageTypesManager(static_cast<FilterType*>(this))
{
}
//--------------------------------------------------------------------
mImageTypesManager.DoIt(mDim, mNbOfComponents, mPixelTypeName);
return true;
}
+//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
template<class FilterType>
bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype)
{
- return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]);
+ return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]);
}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
template<class FilterType>
bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType()
{
- return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]);
+ return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]);
}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
template<class FilterType>
std::string clitk::ImageToImageGenericFilter<FilterType>::GetAvailableImageTypes() {
- std::ostringstream oss;
- oss << "The filter <" << mFilterName << "> manages:" << std::endl;
+ std::ostringstream oss;
+ oss << "The filter <" << mFilterName << "> manages:" << std::endl;
- typedef typename ImageTypesManager<FilterType>::MapOfImageComponentsToFunctionType::const_iterator MCompItType;
- typedef typename ImageTypesManager<FilterType>::MapOfImageDimensionToFunctionType::const_iterator MDimItType;
- typedef typename ImageTypesManager<FilterType>::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<FilterType>::MapOfImageComponentsToFunctionType::const_iterator MCompItType;
+ typedef typename ImageTypesManager<FilterType>::MapOfImageDimensionToFunctionType::const_iterator MDimItType;
+ typedef typename ImageTypesManager<FilterType>::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();
}
//--------------------------------------------------------------------
void BinarizeImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a) {
mArgsInfo=a;
SetIOVerbose(mArgsInfo.verbose_flag);
-
if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
if (mArgsInfo.input_given) {
if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(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);
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
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
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
)
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
#include "vvMesh.h"
#include "vvStructSelector.h"
#include "vvMeshReader.h"
-#include "vvCropDialog.h"
#include "vvConstants.h"
#ifdef CLITK_VV_USE_BDCM
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"));
}
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());
}
//------------------------------------------------------------------------------
-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() {
//------------------------------------------------------------------------------
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;
}
void SaveSOScreenshot();
void ShowContextMenu(QPoint point);
- void CropImage();
+ // void CropImage();
void SplitImage();
void CloseImage();
void ReloadImage();
vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
vtkStandardNewMacro(vvSlicer);
+//------------------------------------------------------------------------------
vvSlicer::vvSlicer()
{
mImage = NULL;
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) {
SetContourSlice();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::ToggleContourSuperposition()
{
for (std::vector<vvMeshActor*>::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<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
i!=mSurfaceCutActors.end();i++)
delete (*i);
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
{
mCurrent[0] = x;
mCurrent[2] = z;
mCurrentTSlice = t;
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetImage(vvImage::Pointer image)
{
if (image->GetVTKImages().size())
ca->SetText(0,mFileName.c_str());
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetOverlay(vvImage::Pointer overlay)
{
if (overlay->GetVTKImages().size())
SetTSlice(mCurrentTSlice);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetFusion(vvImage::Pointer fusion)
{
if (fusion->GetVTKImages().size())
SetTSlice(mCurrentTSlice);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
{
if (actor_type == "vector")
this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
UpdateDisplayExtent();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVF(vvImage::Pointer vf)
{
if (vf->GetVTKImages().size())
SetTSlice(mCurrentTSlice);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
{
mLandmarks = 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)
{
mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
}
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVFSubSampling(int sub)
{
if (mVOIFilter)
UpdateDisplayExtent();
Render();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVFScale(int scale)
{
mScale = scale;
UpdateDisplayExtent();
Render();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetVFLog(int log)
{
mVFLog = log;
UpdateDisplayExtent();
Render();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetTSlice(int t)
{
if (t < 0)
(*i)->SetTimeSlice(mCurrentTSlice);
UpdateDisplayExtent();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
int vvSlicer::GetTSlice()
{
return mCurrentTSlice;
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvSlicer::SetSliceOrientation(int orientation)
{
//if 2D image, force to watch in Axial View
}
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:
}
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int vfExtent[6])
{
vtkImageData* image=this->GetInput();
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();
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();
mFusion->GetSpacing()[2];
ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
{
bool out = false;
extent[i+1] = refExtent[i];
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::UpdateOrientation()
{
// Set the camera position
}
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::SetOpacity(double s)
{
this->GetImageActor()->SetOpacity(s);
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
{
this->Superclass::SetRenderWindow(rw);
SetSliceOrientation(2-(orientation%3));
ResetCamera();
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::ResetCamera()
{
if (this->GetInput())
this->GetRenderer()->GetActiveCamera()->SetParallelScale(bmax/2);
}
}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
void vvSlicer::SetDisplayMode(bool i)
{
this->GetImageActor()->SetVisibility(i);
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());
}
}
//----------------------------------------------------------------------------
+
//----------------------------------------------------------------------------
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])
int mVFLog;
bool mUseReducedExtent;
int * mReducedExtent;
+ int * mInitialExtent;
private:
void UpdateOrientation();
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
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
bool vvToolBinarize::close() {
RemoveVTKObjects();
//------------------------------------------------------------------------------
void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
mCurrentSlicerManager = m;
- // Common
- mCurrentImage = mCurrentSlicerManager->GetImage();
// Specific for this gui
mThresholdSlider1->SetValue(0);
DD(good);
*/
+ mArgsInfo.imagetypes_flag = 0;
mArgsInfo.upper_given = 0;
mArgsInfo.lower_given = 0;
bool inverseBGandFG = false;
}
else mArgsInfo.mode_arg = (char*)"FG";
- mArgsInfo.verbose_flag = true;
+ mArgsInfo.verbose_flag = false;
// Required (even if not used)
mArgsInfo.input_given = 0;
//------------------------------------------------------------------------------
void vvToolBinarize::apply() {
if (!mCurrentSlicerManager) close();
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
GetArgsInfoFromGUI();
// Main filter
clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>::Pointer filter =
- clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>::New();
+ clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>::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();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
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;i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
mImageContour[i]->update(m1);
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
// GUI Initialization
Ui_vvToolCropImage::setupUi(mToolWidget);
- mReducedExtent = new int[6]; // TO CHANGE !! nb dim
- // Connect
- connect(xminSlider, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoved(int)));
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-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; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mReducedExtent);
+ mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent();
+ mCurrentSlicerManager->GetSlicer(i)->Render();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
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; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+ mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(true);
+ }
- // TODO : set min/max
- std::vector<int> 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<int> 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<vtkImageData*>::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<vtkImageData*>::const_iterator i=image->GetVTKImages().begin();
+ i!=image->GetVTKImages().end();i++)
{
- vtkSmartPointer<vtkImageClip> filter=vtkSmartPointer<vtkImageClip>::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<vtkImageTranslateExtent> translate=vtkSmartPointer<vtkImageTranslateExtent>::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<vtkImageClip> filter=vtkSmartPointer<vtkImageClip>::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<vtkImageTranslateExtent> translate=vtkSmartPointer<vtkImageTranslateExtent>::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();
}
//------------------------------------------------------------------------------
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
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() {
protected:
Ui::vvToolCropImage ui;
int * mReducedExtent;
+ int * mInitialExtent;
+ int mExtentSize;
+ void UpdateExtent();
}; // end class vvToolCropImage
//------------------------------------------------------------------------------
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
//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-void vvToolInputSelectorWidget::SetToolTip(QString s) {
- setToolTip(s);
-}
-//------------------------------------------------------------------------------
-
-
//------------------------------------------------------------------------------
void vvToolInputSelectorWidget::accept() {
mInputSelectionButtonBox->setEnabled(false);
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
void Initialize(std::vector<vvSlicerManager*> l, int index);
int GetSelectedInputIndex() { return mCurrentIndex; }
- void SetToolTip(QString s);
public slots:
void accept();
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
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; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
if (mFilter->CheckImageType(s->GetNumberOfDimensions(),
// Common
int index = mToolInputSelectionWidget->GetSelectedInputIndex();
mCurrentSlicerManager = mSlicerManagersCompatible[index];
+ mCurrentImage = mCurrentSlicerManager->GetImage();
mToolWidget->setEnabled(true);
if (!mCurrentSlicerManager) close();
InputIsSelected(mCurrentSlicerManager);