WRAP_GGO(clitkBinarizeImage_GGO_C clitkBinarizeImage.ggo)
add_library(clitkBinarizeImageLib clitkBinarizeImageGenericFilter.cxx ${clitkBinarizeImage_GGO_C})
+WRAP_GGO(clitkProfileImage_GGO_C clitkProfileImage.ggo)
+add_library(clitkProfileImageLib clitkProfileImageGenericFilter.cxx ${clitkProfileImage_GGO_C})
+
WRAP_GGO(clitkImageArithm_GGO_C clitkImageArithm.ggo)
add_library(clitkImageArithmImageLib clitkImageArithmGenericFilter.cxx ${clitkImageArithm_GGO_C})
add_executable(clitkBinarizeImage clitkBinarizeImage.cxx)
target_link_libraries(clitkBinarizeImage clitkBinarizeImageLib clitkCommon)
set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinarizeImage)
+
+ add_executable(clitkProfileImage clitkProfileImage.cxx)
+ target_link_libraries(clitkProfileImage clitkProfileImageLib clitkCommon)
+ set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkProfileImage)
WRAP_GGO(clitkVFResample_GGO_C clitkVFResample.ggo)
add_executable(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C})
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+// clitk
+#include "clitkProfileImage_ggo.h"
+#include "clitkProfileImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+ // Init command line
+ GGO(clitkProfileImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ typedef clitk::ProfileImageGenericFilter FilterType;
+ FilterType::Pointer filter = FilterType::New();
+
+ filter->SetArgsInfo(args_info);
+
+ CLITK_TRY_CATCH_EXIT(filter->Update());
+
+ return EXIT_SUCCESS;
+} // This is the end, my friend
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkProfileImage.ggo
+package "clitkProfileImage"
+version "1.0"
+purpose "Save the profile between 2 points of the input image in the output text file"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+option "imagetypes" - "Display allowed image types" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output texte filename" string yes
+option "point1" f "First point (mm)" int yes multiple(-4)
+option "point2" s "Second point (mm)" int yes multiple(-4)
+
+
+
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkProfileImageGenericFilter_cxx
+#define clitkProfileImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkProfileImageGenericFilter.cxx
+ * @author Thomas Baudier <thomas.baudier@creatis.insa-lyon.fr>
+ * @date 22 dec 2015
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkProfileImageGenericFilter.h"
+
+// itk include
+#include <itkLineIterator.h>
+
+#include <clitkCommon.h>
+
+
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+ProfileImageGenericFilter::ProfileImageGenericFilter():
+ ImageToImageGenericFilter<Self>("ProfileImage")
+{
+ InitializeImageType<2>();
+ InitializeImageType<3>();
+ InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<unsigned int Dim>
+void ProfileImageGenericFilter::InitializeImageType()
+{
+ ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetArrayX()
+{
+ return(mArrayX);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetArrayY()
+{
+ return(mArrayY);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetCoord()
+{
+ return(mCoord);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void ProfileImageGenericFilter::SetArgsInfo(const args_info_type & a)
+{
+ mArgsInfo=a;
+ if (mArgsInfo.verbose_given)
+ SetIOVerbose(mArgsInfo.verbose_flag);
+ if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag)
+ this->PrintAvailableImageTypes();
+
+ if (mArgsInfo.input_given) {
+ SetInputFilename(mArgsInfo.input_arg);
+ }
+ if (mArgsInfo.output_given) {
+ SetOutputFilename(mArgsInfo.output_arg);
+ }
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class InputImageType>
+void
+ProfileImageGenericFilter::UpdateWithInputImageType()
+{
+
+ // Reading input
+ typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+ typedef typename InputImageType::PixelType PixelType;
+ typedef typename InputImageType::IndexType IndexType;
+
+ mArrayX = vtkSmartPointer<vtkFloatArray>::New();
+ mArrayY = vtkSmartPointer<vtkFloatArray>::New();
+ mCoord = vtkSmartPointer<vtkFloatArray>::New();
+ mCoord->SetNumberOfComponents(InputImageType::ImageDimension);
+
+ //Iterator
+ IndexType pointBegin, pointEnd;
+
+ for (int i = 0; i < mArgsInfo.point1_given; ++i) {
+ pointBegin[i] = mArgsInfo.point1_arg[i];
+ pointEnd[i] = mArgsInfo.point2_arg[i];
+ }
+
+ 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;
+ }
+
+ delete [] tuple;
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkProfileImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+#ifndef clitkProfileImageGenericFilter_h
+#define clitkProfileImageGenericFilter_h
+
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+#include "clitkProfileImage_ggo.h"
+
+#include <vtkIntArray.h>
+#include <vtkFloatArray.h>
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+ class ITK_EXPORT ProfileImageGenericFilter:
+ public ImageToImageGenericFilter<ProfileImageGenericFilter>
+ {
+
+ public:
+ //--------------------------------------------------------------------
+ typedef ProfileImageGenericFilter Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+ typedef args_info_clitkProfileImage args_info_type;
+
+ //--------------------------------------------------------------------
+ // Method for creation through the object factory
+ // and Run-time type information (and related methods)
+ itkNewMacro(Self);
+ itkTypeMacro(ProfileImageGenericFilter, LightObject);
+
+ //--------------------------------------------------------------------
+ void SetArgsInfo(const args_info_type & a);
+
+ //--------------------------------------------------------------------
+ // Main function called each time the filter is updated
+ template<class InputImageType>
+ void UpdateWithInputImageType();
+
+ vtkFloatArray* GetArrayX();
+ vtkFloatArray* GetArrayY();
+ vtkFloatArray* GetCoord();
+
+ protected:
+ ProfileImageGenericFilter();
+ template<unsigned int Dim> void InitializeImageType();
+ args_info_type mArgsInfo;
+
+
+ vtkSmartPointer<vtkFloatArray> mArrayX;
+ vtkSmartPointer<vtkFloatArray> mArrayY;
+ vtkSmartPointer<vtkFloatArray> mCoord;
+
+
+ }; // end class
+ //--------------------------------------------------------------------
+
+} // end namespace clitk
+//--------------------------------------------------------------------
+
+#endif // #define clitkProfileImageGenericFilter_h
vvToolConvert ## with dummy vvToolConvert.ui
vvToolROIManager
vvToolSegmentation
+ vvToolProfile
## these ones are for tests (not working)
# vvToolTest
# vvToolFoo
# Future issues : when tool depend on other tools ... how to manage that ?
# >> add the relevant $_LIBS variable to the tool that has dependencies?
set(vvToolBinarize_LIBS clitkBinarizeImageLib)
+set(vvToolProfile_LIBS clitkProfileImageLib)
set(vvToolResample_LIBS clitkResampleImageLib)
set(vvToolConvert_LIBS clitkImageConvertLib)
set(vvToolExtractPatient_LIBS clitkSegmentationGgoLib)
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolProfile</class>
+ <widget class="QWidget" name="vvToolProfile">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>437</width>
+ <height>452</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Profile image</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="horizontalSpacing">
+ <number>6</number>
+ </property>
+ <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">
+ <string>Point2 (mm): </string>
+ </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">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QToolButton" name="mCancelPointsButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="mComputeProfileButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Compute Profile</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <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">
+ <string>Point1 (mm): </string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="mPosPoint1Label">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <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>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QVTKWidget</class>
+ <extends>QWidget</extends>
+ <header>QVTKWidget.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
<rect>
<x>0</x>
<y>0</y>
- <width>179</width>
+ <width>194</width>
<height>62</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true"/>
+ <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
<widget class="QWidget" name="mToolWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<file>icons/8b.png</file>
<file>icons/1b.png</file>
<file>icons/binarize.png</file>
+ <file>icons/profile.png</file>
<file>icons/resample.png</file>
<file>icons/crop.png</file>
<file>icons/splashscreen2.png</file>
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ ===========================================================================**/
+
+// vv
+#include "vvToolProfile.h"
+#include "vvSlicerManager.h"
+#include "vvSlicer.h"
+#include "vvToolInputSelectorWidget.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>
+
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolProfile);
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::Initialize()
+{
+ SetToolName("Profile");
+ SetToolMenuName("Intensity Profile");
+ SetToolIconFilename(":/common/icons/profile.png");
+ SetToolTip("Display the intensity profile between 2 points of the image.");
+ SetToolExperimental(false);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f)
+ :vvToolWidgetBase(parent,f),
+ vvToolBase<vvToolProfile>(parent),
+ Ui::vvToolProfile()
+{
+ // GUI Initialization
+ Ui_vvToolProfile::setupUi(mToolWidget);
+
+ // Connect signals & slots
+ connect(mSelectPoint1Button, SIGNAL(clicked()), this, SLOT(selectPoint1()));
+ connect(mSelectPoint2Button, SIGNAL(clicked()), this, SLOT(selectPoint2()));
+ connect(mCancelPointsButton, SIGNAL(clicked()), this, SLOT(cancelPoints()));
+ connect(mComputeProfileButton, SIGNAL(clicked()), this, SLOT(computeProfile()));
+
+ // Initialize some widget
+ ProfileWidget->hide();
+ mPoint1 = NULL;
+ mPoint2 = NULL;
+
+ 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();
+
+ // Set how many inputs are needed for this tool
+ AddInputSelector("Select one image", mFilter);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolProfile::~vvToolProfile()
+{
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::selectPoint1()
+{
+ QString position = "";
+
+ 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;
+ int *index;
+ pos = new double [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+
+ for (int i=0; i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions(); ++i) {
+ pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+ index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i];
+
+ position += QString::number(pos[i],'f',1) + " ";
+ mPoint1[i] = index[i];
+ }
+ mPoint1Selected = true;
+ }
+ }
+ mPosPoint1Label->setText(position);
+ isPointsSelected();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::selectPoint2()
+{
+ QString position = "";
+
+ 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;
+ int *index;
+ pos = new double [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+
+ for (int i=0; i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions(); ++i) {
+ pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+ index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i];
+
+ position += QString::number(pos[i],'f',1) + " ";
+ mPoint2[i] = index[i];
+ }
+ mPoint2Selected = true;
+ }
+ }
+ mPosPoint2Label->setText(position);
+ isPointsSelected();
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+bool vvToolProfile::isPointsSelected()
+{
+ if (mPoint1Selected && mPoint2Selected)
+ mComputeProfileButton->setEnabled(true);
+ else
+ mComputeProfileButton->setEnabled(false);
+
+ return (mPoint1Selected && mPoint2Selected);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::computeProfile()
+{
+ if (!mCurrentSlicerManager) close();
+
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ GetArgsInfoFromGUI();
+ ProfileWidget->hide();
+
+ // Main filter
+ mFilter->SetInputVVImage(mCurrentImage);
+ mFilter->SetArgsInfo(mArgsInfo);
+ mFilter->Update();
+
+ 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);
+ mPoint1Selected = false;
+ mPoint2Selected = false;
+ mComputeProfileButton->setEnabled(false);
+ isPointsSelected();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::RemoveVTKObjects()
+{
+ if (mCurrentSlicerManager)
+ mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+bool vvToolProfile::close()
+{
+ // RemoveVTKObjects();
+ return vvToolWidgetBase::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::closeEvent(QCloseEvent *event)
+{
+ RemoveVTKObjects();
+ event->accept();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::reject()
+{
+ // DD("vvToolProfile::reject");
+ RemoveVTKObjects();
+ delete [] mPoint1;
+ delete [] mPoint2;
+ return vvToolWidgetBase::reject();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::InputIsSelected(vvSlicerManager * m)
+{
+ mCurrentSlicerManager = m;
+
+ mPoint1 = new int[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ mPoint2 = new int[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+
+ mComputeProfileButton->setEnabled(false);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::GetArgsInfoFromGUI()
+{
+
+ /* //KEEP THIS FOR READING GGO FROM FILE
+ int argc=1;
+ std::string a = "toto";
+ char * const* argv = new char*;
+ //a.c_str();
+ struct cmdline_parser_params p;
+ p.check_required = 0;
+ int good = cmdline_parser_ext(argc, argv, &args_info, &p);
+ DD(good);
+ */
+ cmdline_parser_clitkProfileImage_init(&mArgsInfo); // Initialisation to default
+
+ mArgsInfo.verbose_flag = false;
+
+ mArgsInfo.point1_arg = mPoint1;
+ mArgsInfo.point2_arg = mPoint2;
+ mArgsInfo.point1_given = mCurrentSlicerManager->GetImage()->GetNumberOfDimensions();
+ mArgsInfo.point2_given = mCurrentSlicerManager->GetImage()->GetNumberOfDimensions();
+
+ // Required (even if not used)
+ mArgsInfo.input_given = 0;
+ mArgsInfo.output_given = 0;
+
+ mArgsInfo.input_arg = new char;
+ mArgsInfo.output_arg = new char;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::apply()
+{
+ if (!mCurrentSlicerManager || !isPointsSelected()) {
+ close();
+ return;
+ }
+
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
+ // Output
+ std::string fileName = "Profiled_" + mCurrentSlicerManager->GetSlicer(0)->GetFileName() + ".txt";
+ ofstream fileOpen(fileName.c_str(), std::ofstream::trunc);
+
+ 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();
+
+ QApplication::restoreOverrideCursor();
+ close();
+}
+//------------------------------------------------------------------------------
+
+
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef VVTOOLPROFILE_H
+#define VVTOOLPROFILE_H
+
+#include <QtUiPlugin/QDesignerExportWidget>
+
+#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
+#include "vvImageContour.h"
+#include "ui_vvToolProfile.h"
+
+#include "clitkProfileImage_ggo.h"
+#include "clitkProfileImageGenericFilter.h"
+#include <vtkTable.h>
+#include <vtkContextView.h>
+#include <vtkContextScene.h>
+
+//------------------------------------------------------------------------------
+class vvToolProfile:
+ public vvToolWidgetBase,
+ public vvToolBase<vvToolProfile>,
+ private Ui::vvToolProfile
+{
+ Q_OBJECT
+ public:
+ vvToolProfile(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+ ~vvToolProfile();
+
+ //-----------------------------------------------------
+ static void Initialize();
+ void GetArgsInfoFromGUI();
+ virtual void InputIsSelected(vvSlicerManager * m);
+
+ bool isPointsSelected();
+
+ //-----------------------------------------------------
+ public slots:
+ virtual void apply();
+ virtual bool close();
+ virtual void reject();
+
+ void selectPoint1();
+ void selectPoint2();
+ void cancelPoints();
+ void computeProfile();
+
+ protected:
+ void RemoveVTKObjects();
+ virtual void closeEvent(QCloseEvent *event);
+ Ui::vvToolProfile ui;
+ args_info_clitkProfileImage mArgsInfo;
+
+ int* mPoint1;
+ int* mPoint2;
+ bool mPoint1Selected;
+ bool mPoint2Selected;
+ vtkSmartPointer<vtkContextView> mView;
+ clitk::ProfileImageGenericFilter::Pointer mFilter;
+
+
+}; // end class vvToolProfile
+//------------------------------------------------------------------------------
+
+#endif
+