From e502d745ac4c73037ef615931db2dcbf36a94341 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Wed, 30 Dec 2015 15:00:48 +0100 Subject: [PATCH] Add the profile display and the saving a text file --- tools/clitkProfileImageGenericFilter.cxx | 90 +++--- tools/clitkProfileImageGenericFilter.h | 17 +- vv/qt_ui/vvToolProfile.ui | 160 +++------- vv/qt_ui/vvToolWidgetBase.ui | 11 +- vv/vvToolProfile.cxx | 367 ++++++++--------------- vv/vvToolProfile.h | 24 +- 6 files changed, 252 insertions(+), 417 deletions(-) diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx index 3c6d6b7..1eb58c2 100644 --- a/tools/clitkProfileImageGenericFilter.cxx +++ b/tools/clitkProfileImageGenericFilter.cxx @@ -34,6 +34,8 @@ #include + + namespace clitk { @@ -57,6 +59,30 @@ void ProfileImageGenericFilter::InitializeImageType() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +vtkFloatArray* ProfileImageGenericFilter::GetArrayX() +{ + return(mArrayX); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +vtkFloatArray* ProfileImageGenericFilter::GetArrayY() +{ + return(mArrayY); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +vtkFloatArray* ProfileImageGenericFilter::GetCoord() +{ + return(mCoord); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- void ProfileImageGenericFilter::SetArgsInfo(const args_info_type & a) { @@ -88,7 +114,11 @@ ProfileImageGenericFilter::UpdateWithInputImageType() typename InputImageType::Pointer input = this->template GetInput(0); typedef typename InputImageType::PixelType PixelType; typedef typename InputImageType::IndexType IndexType; - typedef itk::Image OutputImageType; + + mArrayX = vtkSmartPointer::New(); + mArrayY = vtkSmartPointer::New(); + mCoord = vtkSmartPointer::New(); + mCoord->SetNumberOfComponents(InputImageType::ImageDimension); //Iterator IndexType pointBegin, pointEnd; @@ -100,54 +130,26 @@ ProfileImageGenericFilter::UpdateWithInputImageType() itk::LineConstIterator itProfile(input, pointBegin, pointEnd); itProfile.GoToBegin(); + int lineNumber(1); + double *tuple; + tuple = new double[InputImageType::ImageDimension]; + while (!itProfile.IsAtEnd()) - { + { + // Fill in the table + mArrayX->InsertNextTuple1(lineNumber); + mArrayY->InsertNextTuple1(itProfile.Get()); + + for (int i=0; iInsertNextTuple(tuple); + ++lineNumber; ++itProfile; } - - // Filter - //typedef itk::BinaryThresholdImageFilter BinaryThresholdImageFilterType; - //typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New(); - //thresholdFilter->SetInput(input); - /*thresholdFilter->SetInsideValue(mArgsInfo.fg_arg); - - if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast(mArgsInfo.lower_arg)); - if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast(mArgsInfo.upper_arg)); - - Three modes : - - FG -> only use FG value for pixel in the Foreground (or Inside), keep input values for outside - - BG -> only use BG value for pixel in the Background (or Outside), keep input values for inside - - both -> use FG and BG (real binary image) - if (mArgsInfo.mode_arg == std::string("both")) { - thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg); - thresholdFilter->Update(); - typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput(); - this->template SetNextOutput(outputImage); - } else { - typename InputImageType::Pointer outputImage; - thresholdFilter->SetOutsideValue(0); - if (mArgsInfo.mode_arg == std::string("BG")) { - typedef itk::MaskImageFilter maskFilterType; - typename maskFilterType::Pointer maskFilter = maskFilterType::New(); - maskFilter->SetInput1(input); - maskFilter->SetInput2(thresholdFilter->GetOutput()); - maskFilter->SetOutsideValue(mArgsInfo.bg_arg); - maskFilter->Update(); - outputImage = maskFilter->GetOutput(); - } else { - typedef itk::MaskNegatedImageFilter maskFilterType; - typename maskFilterType::Pointer maskFilter = maskFilterType::New(); - maskFilter->SetInput1(input); - maskFilter->SetInput2(thresholdFilter->GetOutput()); - maskFilter->SetOutsideValue(mArgsInfo.fg_arg); - maskFilter->Update(); - outputImage = maskFilter->GetOutput(); - } - // Write/Save results - this->template SetNextOutput(outputImage); - }*/ + delete [] tuple; } //-------------------------------------------------------------------- diff --git a/tools/clitkProfileImageGenericFilter.h b/tools/clitkProfileImageGenericFilter.h index e251ff5..573a41c 100644 --- a/tools/clitkProfileImageGenericFilter.h +++ b/tools/clitkProfileImageGenericFilter.h @@ -23,6 +23,9 @@ #include "clitkImageToImageGenericFilter.h" #include "clitkProfileImage_ggo.h" +#include +#include + //-------------------------------------------------------------------- namespace clitk { @@ -34,8 +37,8 @@ namespace clitk public: //-------------------------------------------------------------------- typedef ProfileImageGenericFilter Self; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; + typedef itk::SmartPointer Pointer; + typedef itk::SmartPointer ConstPointer; typedef args_info_clitkProfileImage args_info_type; //-------------------------------------------------------------------- @@ -51,12 +54,22 @@ namespace clitk // Main function called each time the filter is updated template void UpdateWithInputImageType(); + + vtkFloatArray* GetArrayX(); + vtkFloatArray* GetArrayY(); + vtkFloatArray* GetCoord(); protected: ProfileImageGenericFilter(); template void InitializeImageType(); args_info_type mArgsInfo; + + vtkSmartPointer mArrayX; + vtkSmartPointer mArrayY; + vtkSmartPointer mCoord; + + }; // end class //-------------------------------------------------------------------- diff --git a/vv/qt_ui/vvToolProfile.ui b/vv/qt_ui/vvToolProfile.ui index 3d6af50..f9edb6d 100644 --- a/vv/qt_ui/vvToolProfile.ui +++ b/vv/qt_ui/vvToolProfile.ui @@ -6,8 +6,8 @@ 0 0 - 433 - 222 + 437 + 452 @@ -21,15 +21,15 @@ 6 - - - - Select point 1 - - - - - + + + + + + Select point 2 + + + @@ -37,6 +37,10 @@ + + + + @@ -46,14 +50,7 @@ - - - - Select point 2 - - - - + @@ -77,8 +74,15 @@ - - + + + + + + Select point 1 + + + @@ -86,6 +90,10 @@ + + + + @@ -109,115 +117,29 @@ - - - Resulting binary image: + + + + 0 + 300 + + + + true - - - - - - Use FG - - - false - - - - - - - false - - - - - - - - - - - Use BG - - - true - - - - - - - - - - - - Qt::Horizontal - - - - - - - true - - - Interactive (unchek to disable on the fly contours drawing) - - - true - - - - vvIntensityValueSlider + QVTKWidget QWidget -
vvIntensityValueSlider.h
- 1 +
QVTKWidget.h
- - - mCheckBoxUseBG - toggled(bool) - mBGSlider - setEnabled(bool) - - - 79 - 203 - - - 395 - 225 - - - - - mCheckBoxUseFG - toggled(bool) - mFGSlider - setEnabled(bool) - - - 63 - 177 - - - 242 - 177 - - - - + diff --git a/vv/qt_ui/vvToolWidgetBase.ui b/vv/qt_ui/vvToolWidgetBase.ui index 944fea4..69a6896 100644 --- a/vv/qt_ui/vvToolWidgetBase.ui +++ b/vv/qt_ui/vvToolWidgetBase.ui @@ -6,7 +6,7 @@ 0 0 - 179 + 194 62
@@ -19,7 +19,14 @@ Qt::Vertical - + + + + 16777215 + 200 + + + diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx index b9c34c9..2e07d61 100644 --- a/vv/vvToolProfile.cxx +++ b/vv/vvToolProfile.cxx @@ -22,14 +22,15 @@ #include "vvSlicer.h" #include "vvToolInputSelectorWidget.h" -// clitk -#include "clitkProfileImageGenericFilter.h" - // vtk #include #include #include #include +#include +#include +#include +#include //------------------------------------------------------------------------------ @@ -59,7 +60,6 @@ vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f) { // GUI Initialization Ui_vvToolProfile::setupUi(mToolWidget); - //mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); // Connect signals & slots connect(mSelectPoint1Button, SIGNAL(clicked()), this, SLOT(selectPoint1())); @@ -68,16 +68,21 @@ vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f) connect(mComputeProfileButton, SIGNAL(clicked()), this, SLOT(computeProfile())); // Initialize some widget - //mThresholdSlider1->SetText(""); - //mThresholdSlider2->SetText(""); - //mFGSlider->SetText("Foreground value"); - //mBGSlider->SetText("Background value"); - + ProfileWidget->hide(); mPoint1 = NULL; mPoint2 = NULL; - point1Selected = false; - point2Selected = false; + mPoint1Selected = false; + mPoint2Selected = false; + + mView = vtkSmartPointer::New(); + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(false); + chart->SetRenderEmpty(true); + mView->GetScene()->AddItem(chart); + this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + ProfileWidget->show(); // Main filter mFilter = clitk::ProfileImageGenericFilter::New(); @@ -99,7 +104,20 @@ vvToolProfile::~vvToolProfile() void vvToolProfile::selectPoint1() { QString position = ""; - point1Selected = false; + + if (mPoint1Selected) { + ProfileWidget->hide(); + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(false); + chart->SetRenderEmpty(true); + mView->GetScene()->ClearItems(); + mView->GetScene()->AddItem(chart); + this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + ProfileWidget->show(); + } + + mPoint1Selected = false; if(mCurrentSlicerManager) { if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { double *pos; @@ -114,7 +132,7 @@ void vvToolProfile::selectPoint1() position += QString::number(pos[i],'f',1) + " "; mPoint1[i] = index[i]; } - point1Selected = true; + mPoint1Selected = true; } } mPosPoint1Label->setText(position); @@ -127,7 +145,20 @@ void vvToolProfile::selectPoint1() void vvToolProfile::selectPoint2() { QString position = ""; - point2Selected = false; + + if (mPoint2Selected) { + ProfileWidget->hide(); + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(false); + chart->SetRenderEmpty(true); + mView->GetScene()->ClearItems(); + mView->GetScene()->AddItem(chart); + this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + ProfileWidget->show(); + } + + mPoint2Selected = false; if(mCurrentSlicerManager) { if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { double *pos; @@ -142,7 +173,7 @@ void vvToolProfile::selectPoint2() position += QString::number(pos[i],'f',1) + " "; mPoint2[i] = index[i]; } - point2Selected = true; + mPoint2Selected = true; } } mPosPoint2Label->setText(position); @@ -153,12 +184,12 @@ void vvToolProfile::selectPoint2() //------------------------------------------------------------------------------ bool vvToolProfile::isPointsSelected() { - if (point1Selected && point2Selected) + if (mPoint1Selected && mPoint2Selected) mComputeProfileButton->setEnabled(true); else mComputeProfileButton->setEnabled(false); - return (point1Selected && point2Selected); + return (mPoint1Selected && mPoint2Selected); } //------------------------------------------------------------------------------ @@ -170,15 +201,43 @@ void vvToolProfile::computeProfile() QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); GetArgsInfoFromGUI(); + ProfileWidget->hide(); // Main filter - clitk::ProfileImageGenericFilter::Pointer filter = clitk::ProfileImageGenericFilter::New(); - filter->SetInputVVImage(mCurrentImage); - filter->SetArgsInfo(mArgsInfo); - filter->Update(); + mFilter->SetInputVVImage(mCurrentImage); + mFilter->SetArgsInfo(mArgsInfo); + mFilter->Update(); - QApplication::restoreOverrideCursor(); + vtkSmartPointer table = vtkSmartPointer::New(); + vtkSmartPointer arrX = vtkSmartPointer::New(); + vtkSmartPointer arrY = vtkSmartPointer::New(); + arrX = mFilter->GetArrayX(); + arrY = mFilter->GetArrayY(); + arrX->SetName("Voxel"); + arrY->SetName("Intensity"); + table->AddColumn(arrX); + table->AddColumn(arrY); + + mView->GetRenderer()->SetBackground(1.0, 1.0, 1.0); + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(true); + mView->GetScene()->ClearItems(); + mView->GetScene()->AddItem(chart); + vtkPlot *line = chart->AddPlot(vtkChart::LINE); +#if VTK_MAJOR_VERSION <= 5 + line->SetInput(table, 0, 1); +#else + line->SetInputData(table, 0, 1); +#endif + line->SetColor(0, 255, 0, 255); + line->SetWidth(1.0); + + this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + ProfileWidget->show(); + + QApplication::restoreOverrideCursor(); } //------------------------------------------------------------------------------ @@ -186,43 +245,30 @@ void vvToolProfile::computeProfile() //------------------------------------------------------------------------------ void vvToolProfile::cancelPoints() { + ProfileWidget->hide(); + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(false); + chart->SetRenderEmpty(true); + mView->GetScene()->ClearItems(); + mView->GetScene()->AddItem(chart); + this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + ProfileWidget->show(); + QString position = ""; mPosPoint1Label->setText(position); mPosPoint2Label->setText(position); - point1Selected = false; - point2Selected = false; + mPoint1Selected = false; + mPoint2Selected = false; mComputeProfileButton->setEnabled(false); isPointsSelected(); } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvToolProfile::InteractiveDisplayToggled(bool b) -{ - /*mInteractiveDisplayIsEnabled = b; - if (!mInteractiveDisplayIsEnabled) { - RemoveVTKObjects(); - } else { - for(unsigned int i=0; iShowActors(); - if (mRadioButtonLowerThan->isChecked()) - mImageContourLower[i]->ShowActors(); - } - if (mCurrentSlicerManager) - mCurrentSlicerManager->Render(); - }*/ -} -//------------------------------------------------------------------------------ - - //------------------------------------------------------------------------------ void vvToolProfile::RemoveVTKObjects() { - for(unsigned int i=0; iHideActors(); - mImageContourLower[i]->HideActors(); - } if (mCurrentSlicerManager) mCurrentSlicerManager->Render(); } @@ -260,40 +306,6 @@ void vvToolProfile::reject() //------------------------------------------------------------------------------ -void vvToolProfile::enableLowerThan(bool b) -{ - /*if (!b) { - mThresholdSlider1->resetMaximum(); - for(unsigned int i=0; iHideActors(); - } - mCurrentSlicerManager->Render(); - } else { - valueChangedT1(mThresholdSlider1->GetValue()); - valueChangedT2(mThresholdSlider2->GetValue()); - for(unsigned int i=0; iShowActors(); - } - mCurrentSlicerManager->Render(); - }*/ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolProfile::useFGBGtoggled(bool) -{ - if (!mCheckBoxUseBG->isChecked() && !mCheckBoxUseFG->isChecked()) - mCheckBoxUseBG->toggle(); -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// void vvToolProfile::InputIsSelected(std::vector & m) { -// DD("vvToolProfile::InputIsSelected vector in Profile"); -// DD(m.size()); -// } void vvToolProfile::InputIsSelected(vvSlicerManager * m) { mCurrentSlicerManager = m; @@ -302,93 +314,9 @@ void vvToolProfile::InputIsSelected(vvSlicerManager * m) mPoint2 = new int[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()]; mComputeProfileButton->setEnabled(false); - - // Specific for this gui - //mThresholdSlider1->SetValue(0); - //mThresholdSlider2->SetValue(0); - //mThresholdSlider1->SetImage(mCurrentImage); - //mThresholdSlider2->SetImage(mCurrentImage); - //mFGSlider->SetImage(mCurrentImage); - //mBGSlider->SetImage(mCurrentImage); - // DD(mCurrentSlicerManager->GetFileName().c_str()); - // mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); - // mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); - // mBGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); - // mBGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); - - // Output is uchar ... - /*mFGSlider->SetMaximum(255); - mFGSlider->SetMinimum(0); - mBGSlider->SetMaximum(255); - mBGSlider->SetMinimum(0); - - mFGSlider->SetValue(1); - mBGSlider->SetValue(0); - mFGSlider->SetSingleStep(1); - mBGSlider->SetSingleStep(1); - - // VTK objects for interactive display - for(int i=0; iGetNumberOfSlicers(); i++) { - mImageContour.push_back(vvImageContour::New()); - mImageContour[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); - mImageContour[i]->SetColor(1.0, 0.0, 0.0); - mImageContour[i]->SetDepth(0); // to be in front of (whe used with ROI tool) - mImageContourLower.push_back(vvImageContour::New()); - mImageContourLower[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); - mImageContourLower[i]->SetColor(0.0, 0.0, 1.0); - mImageContourLower[i]->SetDepth(100); // to be in front of (whe used with ROI tool) - } - //valueChangedT1(mThresholdSlider1->GetValue()); - - //connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double))); - //connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double))); - - //connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); - //connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); - - //connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int))); - - // connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); - InteractiveDisplayToggled(mInteractiveDisplayIsEnabled); */ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// void vvToolProfile::LeftButtonReleaseEvent(int slicer) { -// DD("LeftButtonReleaseEvent"); -// for(int i=0; iGetNumberOfSlicers(); i++) { -// if (i == slicer); -// mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render(); -// } -// } -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolProfile::UpdateOrientation(int slicer,int orientation) -{ - Update(slicer); -} -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -void vvToolProfile::UpdateSlice(int slicer,int slices) -{ - Update(slicer); } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvToolProfile::Update(int slicer) -{ - //if (!mInteractiveDisplayIsEnabled) return; - if (!mCurrentSlicerManager) close(); - //mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); - //if (mRadioButtonLowerThan->isChecked()) - // mImageContourLower[slicer]->Update(mThresholdSlider2->GetValue()); -} -//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolProfile::GetArgsInfoFromGUI() @@ -405,34 +333,7 @@ void vvToolProfile::GetArgsInfoFromGUI() DD(good); */ cmdline_parser_clitkProfileImage_init(&mArgsInfo); // Initialisation to default - //bool inverseBGandFG = false; - - //mArgsInfo.lower_given = 1; - /*mArgsInfo.lower_arg = mThresholdSlider1->GetValue(); - if (mRadioButtonLowerThan->isChecked()) { - mArgsInfo.upper_given = 1; - mArgsInfo.upper_arg = mThresholdSlider2->GetValue(); - if (mArgsInfo.upper_argGetValue(); - mArgsInfo.bg_arg = mBGSlider->GetValue(); - if (inverseBGandFG) { - mArgsInfo.fg_arg = mFGSlider->GetValue(); - mArgsInfo.bg_arg = mBGSlider->GetValue(); - } - mArgsInfo.fg_given = 1; - mArgsInfo.bg_given = 1; - - if (mCheckBoxUseBG->isChecked()) { - if (mCheckBoxUseFG->isChecked()) mArgsInfo.mode_arg = (char*)"both"; - else mArgsInfo.mode_arg = (char*)"BG"; - } else mArgsInfo.mode_arg = (char*)"FG"; -*/ mArgsInfo.verbose_flag = false; mArgsInfo.point1_arg = mPoint1; @@ -453,56 +354,52 @@ void vvToolProfile::GetArgsInfoFromGUI() //------------------------------------------------------------------------------ void vvToolProfile::apply() { - if (!mCurrentSlicerManager) close(); + if (!mCurrentSlicerManager || !isPointsSelected()) { + close(); + return; + } + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - GetArgsInfoFromGUI(); + + // Output + std::string fileName = "Profiled_" + mCurrentSlicerManager->GetSlicer(0)->GetFileName() + ".txt"; + ofstream fileOpen(fileName.c_str(), std::ofstream::trunc); - // Main filter - clitk::ProfileImageGenericFilter::Pointer filter = - clitk::ProfileImageGenericFilter::New(); - filter->SetInputVVImage(mCurrentImage); - filter->SetArgsInfo(mArgsInfo); - filter->Update(); + if(!fileOpen) { + cerr << "Error during saving" << endl; + QApplication::restoreOverrideCursor(); + close(); + + return; + } + vtkSmartPointer arrX = vtkSmartPointer::New(); + vtkSmartPointer arrY = vtkSmartPointer::New(); + vtkSmartPointer coords = vtkSmartPointer::New(); + arrX = mFilter->GetArrayX(); + arrY = mFilter->GetArrayY(); + coords = mFilter->GetCoord(); + double *tuple; + tuple = new double[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()]; + int i(0); + + while (iGetNumberOfTuples()) { + fileOpen << arrX->GetTuple(i)[0] << "\t" << arrY->GetTuple(i)[0] << "\t" ; + + coords->GetTuple(i, tuple); + for (int j=0; jGetImage()->GetNumberOfDimensions() ; ++j) { + fileOpen << tuple[j] << "\t" ; + } + fileOpen << endl; + ++i; + } + + delete [] tuple; + fileOpen.close(); - // Output - vvImage::Pointer output = filter->GetOutputVVImage(); - std::ostringstream osstream; - osstream << "Profiled_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; - AddImage(output,osstream.str()); QApplication::restoreOverrideCursor(); close(); } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvToolProfile::valueChangedT2(double v) -{ - /*// DD("valueChangedT2"); - if (mRadioButtonLowerThan->isChecked()) { - mThresholdSlider1->SetMaximum(v); - if (!mInteractiveDisplayIsEnabled) return; - for(int i=0;iGetNumberOfSlicers(); i++) { - mImageContourLower[i]->Update(v); - } - mCurrentSlicerManager->Render(); - }*/ -} -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -void vvToolProfile::valueChangedT1(double v) -{ - /*// DD("valueChangedT1"); - if (!mCurrentSlicerManager) close(); - mThresholdSlider2->SetMinimum(v); - // int m1 = (int)lrint(v); - if (!mInteractiveDisplayIsEnabled) return; - for(int i=0;iGetNumberOfSlicers(); i++) { - mImageContour[i]->Update(v); - } - mCurrentSlicerManager->Render();*/ -} -//------------------------------------------------------------------------------ diff --git a/vv/vvToolProfile.h b/vv/vvToolProfile.h index ecccf06..072dc3a 100644 --- a/vv/vvToolProfile.h +++ b/vv/vvToolProfile.h @@ -26,6 +26,10 @@ #include "ui_vvToolProfile.h" #include "clitkProfileImage_ggo.h" +#include "clitkProfileImageGenericFilter.h" +#include +#include +#include //------------------------------------------------------------------------------ class vvToolProfile: @@ -50,14 +54,6 @@ class vvToolProfile: virtual void apply(); virtual bool close(); virtual void reject(); - void valueChangedT1(double v); - void valueChangedT2(double v); - void UpdateOrientation(int slicer, int orientation); - void UpdateSlice(int slicer,int slices); - void enableLowerThan(bool b); - void useFGBGtoggled(bool); - void InteractiveDisplayToggled(bool b); - // void LeftButtonReleaseEvent(int slicer); void selectPoint1(); void selectPoint2(); @@ -69,16 +65,14 @@ class vvToolProfile: virtual void closeEvent(QCloseEvent *event); Ui::vvToolProfile ui; args_info_clitkProfileImage mArgsInfo; - std::vector mImageContour; - std::vector mImageContourLower; - bool mInteractiveDisplayIsEnabled; int* mPoint1; int* mPoint2; - bool point1Selected; - bool point2Selected; - - void Update(int slicer); + bool mPoint1Selected; + bool mPoint2Selected; + vtkSmartPointer mView; + clitk::ProfileImageGenericFilter::Pointer mFilter; + }; // end class vvToolProfile //------------------------------------------------------------------------------ -- 2.47.1