#include <clitkCommon.h>
+
+
namespace clitk
{
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetArrayX()
+{
+ return(mArrayX);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetArrayY()
+{
+ return(mArrayY);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetCoord()
+{
+ return(mCoord);
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void ProfileImageGenericFilter::SetArgsInfo(const args_info_type & a)
{
typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
typedef typename InputImageType::PixelType PixelType;
typedef typename InputImageType::IndexType IndexType;
- typedef itk::Image<uchar, InputImageType::ImageDimension> OutputImageType;
+
+ mArrayX = vtkSmartPointer<vtkFloatArray>::New();
+ mArrayY = vtkSmartPointer<vtkFloatArray>::New();
+ mCoord = vtkSmartPointer<vtkFloatArray>::New();
+ mCoord->SetNumberOfComponents(InputImageType::ImageDimension);
//Iterator
IndexType pointBegin, pointEnd;
itk::LineConstIterator<InputImageType> 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; i<InputImageType::ImageDimension; ++i) {
+ tuple[i] = itProfile.GetIndex()[i];
+ }
+ mCoord->InsertNextTuple(tuple);
+ ++lineNumber;
++itProfile;
}
-
- // Filter
- //typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
- //typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
- //thresholdFilter->SetInput(input);
- /*thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
-
- if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
- if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(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<OutputImageType>(outputImage);
- } else {
- typename InputImageType::Pointer outputImage;
- thresholdFilter->SetOutsideValue(0);
- if (mArgsInfo.mode_arg == std::string("BG")) {
- typedef itk::MaskImageFilter<InputImageType,OutputImageType> 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<InputImageType,OutputImageType> 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<InputImageType>(outputImage);
- }*/
+ delete [] tuple;
}
//--------------------------------------------------------------------
<rect>
<x>0</x>
<y>0</y>
- <width>433</width>
- <height>222</height>
+ <width>437</width>
+ <height>452</height>
</rect>
</property>
<property name="windowTitle">
<property name="horizontalSpacing">
<number>6</number>
</property>
- <item row="1" column="1">
- <widget class="QToolButton" name="mSelectPoint1Button">
- <property name="text">
- <string>Select point 1</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="mSelectPoint2Button">
+ <property name="text">
+ <string>Select point 2</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QLabel" name="Point2">
<property name="text">
</property>
</widget>
</item>
+ </layout>
+ </item>
+ <item row="2" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mPosPoint2Label">
<property name="text">
</item>
</layout>
</item>
- <item row="2" column="1">
- <widget class="QPushButton" name="mSelectPoint2Button">
- <property name="text">
- <string>Select point 2</string>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
+ <item row="3" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QToolButton" name="mCancelPointsButton">
</item>
</layout>
</item>
- <item row="1" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QPushButton" name="mSelectPoint1Button">
+ <property name="text">
+ <string>Select point 1</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QLabel" name="Point1">
<property name="text">
</property>
</widget>
</item>
+ </layout>
+ </item>
+ <item row="1" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mPosPoint1Label">
<property name="text">
</widget>
</item>
<item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Resulting binary image:</string>
+ <widget class="QVTKWidget" name="ProfileWidget" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>300</height>
+ </size>
+ </property>
+ <property name="mouseTracking">
+ <bool>true</bool>
</property>
</widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QCheckBox" name="mCheckBoxUseFG">
- <property name="text">
- <string>Use FG</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="vvIntensityValueSlider" name="mFGSlider" native="true">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QCheckBox" name="mCheckBoxUseBG">
- <property name="text">
- <string>Use BG</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="vvIntensityValueSlider" name="mBGSlider" native="true"/>
- </item>
- </layout>
- </item>
</layout>
</item>
- <item>
- <widget class="Line" name="line_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="mCheckBoxInteractiveDisplay">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Interactive (unchek to disable on the fly contours drawing)</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
</layout>
</widget>
<customwidgets>
<customwidget>
- <class>vvIntensityValueSlider</class>
+ <class>QVTKWidget</class>
<extends>QWidget</extends>
- <header>vvIntensityValueSlider.h</header>
- <container>1</container>
+ <header>QVTKWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
- <connections>
- <connection>
- <sender>mCheckBoxUseBG</sender>
- <signal>toggled(bool)</signal>
- <receiver>mBGSlider</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>79</x>
- <y>203</y>
- </hint>
- <hint type="destinationlabel">
- <x>395</x>
- <y>225</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>mCheckBoxUseFG</sender>
- <signal>toggled(bool)</signal>
- <receiver>mFGSlider</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>63</x>
- <y>177</y>
- </hint>
- <hint type="destinationlabel">
- <x>242</x>
- <y>177</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
#include "vvSlicer.h"
#include "vvToolInputSelectorWidget.h"
-// clitk
-#include "clitkProfileImageGenericFilter.h"
-
// vtk
#include <vtkImageActor.h>
#include <vtkCamera.h>
#include <vtkImageClip.h>
#include <vtkRenderWindow.h>
+#include <vtkChartXY.h>
+#include <vtkPlot.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderer.h>
//------------------------------------------------------------------------------
{
// GUI Initialization
Ui_vvToolProfile::setupUi(mToolWidget);
- //mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked();
// Connect signals & slots
connect(mSelectPoint1Button, SIGNAL(clicked()), this, SLOT(selectPoint1()));
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<vtkContextView>::New();
+ vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::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();
void vvToolProfile::selectPoint1()
{
QString position = "";
- point1Selected = false;
+
+ if (mPoint1Selected) {
+ ProfileWidget->hide();
+ vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::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;
position += QString::number(pos[i],'f',1) + " ";
mPoint1[i] = index[i];
}
- point1Selected = true;
+ mPoint1Selected = true;
}
}
mPosPoint1Label->setText(position);
void vvToolProfile::selectPoint2()
{
QString position = "";
- point2Selected = false;
+
+ if (mPoint2Selected) {
+ ProfileWidget->hide();
+ vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::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;
position += QString::number(pos[i],'f',1) + " ";
mPoint2[i] = index[i];
}
- point2Selected = true;
+ mPoint2Selected = true;
}
}
mPosPoint2Label->setText(position);
//------------------------------------------------------------------------------
bool vvToolProfile::isPointsSelected()
{
- if (point1Selected && point2Selected)
+ if (mPoint1Selected && mPoint2Selected)
mComputeProfileButton->setEnabled(true);
else
mComputeProfileButton->setEnabled(false);
- return (point1Selected && point2Selected);
+ return (mPoint1Selected && mPoint2Selected);
}
//------------------------------------------------------------------------------
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<vtkTable> table = vtkSmartPointer<vtkTable>::New();
+ vtkSmartPointer<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
+ vtkSmartPointer<vtkFloatArray> arrY = vtkSmartPointer<vtkFloatArray>::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<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::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();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolProfile::cancelPoints()
{
+ ProfileWidget->hide();
+ vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::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; i<mImageContour.size(); i++) {
- mImageContour[i]->ShowActors();
- if (mRadioButtonLowerThan->isChecked())
- mImageContourLower[i]->ShowActors();
- }
- if (mCurrentSlicerManager)
- mCurrentSlicerManager->Render();
- }*/
-}
-//------------------------------------------------------------------------------
-
-
//------------------------------------------------------------------------------
void vvToolProfile::RemoveVTKObjects()
{
- for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContour[i]->HideActors();
- mImageContourLower[i]->HideActors();
- }
if (mCurrentSlicerManager)
mCurrentSlicerManager->Render();
}
//------------------------------------------------------------------------------
-void vvToolProfile::enableLowerThan(bool b)
-{
- /*if (!b) {
- mThresholdSlider1->resetMaximum();
- for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContourLower[i]->HideActors();
- }
- mCurrentSlicerManager->Render();
- } else {
- valueChangedT1(mThresholdSlider1->GetValue());
- valueChangedT2(mThresholdSlider2->GetValue());
- for(unsigned int i=0; i<mImageContour.size(); i++) {
- mImageContourLower[i]->ShowActors();
- }
- mCurrentSlicerManager->Render();
- }*/
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-void vvToolProfile::useFGBGtoggled(bool)
-{
- if (!mCheckBoxUseBG->isChecked() && !mCheckBoxUseFG->isChecked())
- mCheckBoxUseBG->toggle();
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-// void vvToolProfile::InputIsSelected(std::vector<vvSlicerManager *> & m) {
-// DD("vvToolProfile::InputIsSelected vector in Profile");
-// DD(m.size());
-// }
void vvToolProfile::InputIsSelected(vvSlicerManager * m)
{
mCurrentSlicerManager = 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; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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()
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_arg<mArgsInfo.lower_arg) {
- mArgsInfo.upper_given = 0;
- DD("TODO : lower thres greater than greater thres ! Ignoring ");
- }
- }
-
- mArgsInfo.fg_arg = mFGSlider->GetValue();
- 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;
//------------------------------------------------------------------------------
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<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
+ vtkSmartPointer<vtkFloatArray> arrY = vtkSmartPointer<vtkFloatArray>::New();
+ vtkSmartPointer<vtkFloatArray> coords = vtkSmartPointer<vtkFloatArray>::New();
+ arrX = mFilter->GetArrayX();
+ arrY = mFilter->GetArrayY();
+ coords = mFilter->GetCoord();
+ double *tuple;
+ tuple = new double[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ int i(0);
+
+ while (i<arrX->GetNumberOfTuples()) {
+ fileOpen << arrX->GetTuple(i)[0] << "\t" << arrY->GetTuple(i)[0] << "\t" ;
+
+ coords->GetTuple(i, tuple);
+ for (int j=0; j<mCurrentSlicerManager->GetImage()->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;i<mCurrentSlicerManager->GetNumberOfSlicers(); 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;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
- mImageContour[i]->Update(v);
- }
- mCurrentSlicerManager->Render();*/
-}
-//------------------------------------------------------------------------------