]> Creatis software - clitk.git/commitdiff
ROI Debug
authortbaudier <thomas.baudier@etu.unistra.fr>
Mon, 30 Nov 2015 13:01:03 +0000 (14:01 +0100)
committertbaudier <thomas.baudier@etu.unistra.fr>
Mon, 30 Nov 2015 13:01:03 +0000 (14:01 +0100)
Real-time Display Delay Debug
Add test tool (display a sphere in front of the image)

vv/qt_ui/vvToolTest.ui [new file with mode: 0644]
vv/vvBinaryImageOverlayActor.cxx
vv/vvImageContour.cxx
vv/vvToolTest.cxx [new file with mode: 0644]
vv/vvToolTest.h [new file with mode: 0644]

diff --git a/vv/qt_ui/vvToolTest.ui b/vv/qt_ui/vvToolTest.ui
new file mode 100644 (file)
index 0000000..01279b5
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolTest</class>
+ <widget class="QWidget" name="vvToolTest">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>433</width>
+    <height>222</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Test sphere</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="Line" name="line_3">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 74aabac8dc4212d2e3a27ae6248c7c966ec7837b..1af316dedf168b7c28c256b73c84c4a157526c53 100644 (file)
@@ -35,7 +35,7 @@
 
 //------------------------------------------------------------------------------
 vvBinaryImageOverlayActor::vvBinaryImageOverlayActor()
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mTSlice = -1;
   mSlice = 0;
   mColor.resize(3);
@@ -53,7 +53,7 @@ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor()
 
 //------------------------------------------------------------------------------
 vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor()
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mImageActorList.clear();
 }
 //------------------------------------------------------------------------------
@@ -61,7 +61,7 @@ vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::RemoveActors()
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   for (unsigned int i = 0; i < mImageActorList.size(); i++) {
     if (mSlicer != 0) {
       if (mSlicer != NULL) {
@@ -79,7 +79,7 @@ void vvBinaryImageOverlayActor::RemoveActors()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetColor(double r, double g, double b)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mColor[0] = r;
   mColor[1] = g;
   mColor[2] = b;
@@ -89,7 +89,7 @@ void vvBinaryImageOverlayActor::SetColor(double r, double g, double b)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mSlicer = slicer;
 }
 //------------------------------------------------------------------------------
@@ -97,7 +97,7 @@ void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   if (!mSlicer) {
     std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl;
     exit(0);
@@ -164,7 +164,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetOpacity(double d)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mAlpha = d;
 }
 //------------------------------------------------------------------------------
@@ -206,7 +206,7 @@ void vvBinaryImageOverlayActor::SetOpacity(double d)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mImage = image;
   if (modeBG) {
     mBackgroundValue = bg;
@@ -222,7 +222,7 @@ void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::HideActors()
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   for(unsigned int i=0; i<mImageActorList.size(); i++) {
@@ -236,7 +236,7 @@ void vvBinaryImageOverlayActor::HideActors()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::ShowActors()
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   mTSlice = mSlicer->GetTSlice();
@@ -252,7 +252,7 @@ void vvBinaryImageOverlayActor::ShowActors()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::UpdateColor()
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
     // how many intensity ?
@@ -271,7 +271,7 @@ void vvBinaryImageOverlayActor::UpdateColor()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice, bool force)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   if (!mSlicer) return;
 
   if (!force) {
@@ -297,7 +297,6 @@ void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice, bool force)
 #else
   mSlicer->ClipDisplayedExtent(maskExtent, mMapperList[mTSlice]->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT()));
 #endif
-mSlicer->Print(cout);
   SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], mDepth);
 
   // set previous slice
@@ -312,7 +311,7 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation,
                                              int slice,
                                              int * inExtent,
                                              int * outExtent)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   switch (orientation) {
   case vtkImageViewer2::SLICE_ORIENTATION_XY:
     for(int i=0; i<4; i++) outExtent[i] = inExtent[i];
@@ -334,7 +333,7 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation,
 
 //----------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   for(int i=0; i<3; i++) {
     double a = (image->GetOrigin()[i] + inExtent[i*2]*image->GetSpacing()[i] - 
                 overlay->GetOrigin()[i]) / overlay->GetSpacing()[i];
@@ -362,7 +361,7 @@ void vvBinaryImageOverlayActor::SetDisplayExtentAndCameraPosition(int orientatio
                                                                  int * extent,
                                                                  vtkImageActor * actor,
                                                                  double position)
-{ cout << __func__ << endl;
+{ //out << __func__ << endl;
   /* FIXME
      Error according to camera orientation
    */
index c4c8c565379558161328e9e4a75530ce8f0ac8bb..e391bbba61a1e6ba85da0d5186270da65e022b9e 100644 (file)
@@ -408,7 +408,6 @@ void vvImageContour::UpdateActor(vtkActor * actor,
   // DD(mDepth);
   // position[orientation] = -mDepth;
   // actor->SetPosition(position);
-  squares->Update();
   mapper->Update();
 }
 //------------------------------------------------------------------------------
diff --git a/vv/vvToolTest.cxx b/vv/vvToolTest.cxx
new file mode 100644 (file)
index 0000000..e583ac4
--- /dev/null
@@ -0,0 +1,306 @@
+/*=========================================================================
+  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 "vvToolTest.h"
+#include "vvSlicerManager.h"
+#include "vvSlicer.h"
+#include "vvToolInputSelectorWidget.h"
+
+// clitk
+#include "clitkBinarizeImageGenericFilter.h"
+
+// vtk
+#include <vtkImageActor.h>
+#include <vtkCamera.h>
+#include <vtkImageClip.h>
+#include <vtkRenderWindow.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkRenderer.h>
+#include <vtkSphereSource.h>
+#include <vtkProperty.h>
+
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolTest);
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::Initialize()
+{ cout << __func__ << endl;
+  SetToolName("Test");
+  SetToolMenuName("Test");
+  SetToolIconFilename(":/common/icons/binarize.png");
+  SetToolTip("try to display a sphere.");
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolTest::vvToolTest(vvMainWindowBase * parent, Qt::WindowFlags f)
+  :vvToolWidgetBase(parent,f),
+   vvToolBase<vvToolTest>(parent),
+   Ui::vvToolTest()
+{ cout << __func__ << endl;
+  // GUI Initialization
+
+  // Connect signals & slots
+  
+  // Main filter
+  mFilter = clitk::BinarizeImageGenericFilter::New();
+
+  // Set how many inputs are needed for this tool
+  AddInputSelector("Select one image", mFilter);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolTest::~vvToolTest()
+{ cout << __func__ << endl;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+/*
+void vvToolTest::InteractiveDisplayToggled(bool b)
+{ cout << __func__ << endl;
+  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();
+  }
+}
+*/
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+bool vvToolTest::close()
+{ cout << __func__ << endl;
+  return vvToolWidgetBase::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::reject()
+{ cout << __func__ << endl;
+  // DD("vvToolBinarize::reject");
+  return vvToolWidgetBase::reject();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+void vvToolTest::InputIsSelected(vvSlicerManager * m)
+{ cout << __func__ << endl;
+  mCurrentSlicerManager = m;
+
+
+  vtkSmartPointer<vtkSphereSource> sphereSource = 
+      vtkSmartPointer<vtkSphereSource>::New();
+  sphereSource->SetCenter(0, 0, 0);
+  //sphereSource->SetCenter(235.351, 175.781, 141.0);
+  sphereSource->SetRadius(10.0);
+  sphereSource->Update();
+  vtkSmartPointer<vtkPolyDataMapper> sphereMapper =
+      vtkSmartPointer<vtkPolyDataMapper>::New();
+  sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
+  vtkSmartPointer<vtkActor> sphereActor = 
+      vtkSmartPointer<vtkActor>::New();
+  sphereActor->SetMapper(sphereMapper);
+  sphereActor->GetProperty()->SetColor(1.0, 0.0, 0.0);
+  sphereActor->GetProperty()->SetOpacity(0.995);
+  sphereActor->SetPosition(235.351, 175.781, -10);
+  
+  
+  // VTK Renderer
+  vtkSmartPointer<vtkRenderer> sphereRenderer = 
+      vtkSmartPointer<vtkRenderer>::New();
+  // Add Actor to renderer
+  for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->GetRenderer()->AddActor(sphereActor);
+  }
+  //sphereRenderer->AddActor(sphereActor); //mettre le vvSlicer
+   
+  // VTK/Qt wedded
+  //this->qvtkWidgetLeft->GetRenderWindow()->AddRenderer(leftRenderer);
+
+  // VTK objects for interactive display
+  valueChangedT1();
+
+  //connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1()));
+
+  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(UpdateSlice(int, int)));
+
+  //  connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
+  //InteractiveDisplayToggled(mInteractiveDisplayIsEnabled);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// void vvToolBinarize::LeftButtonReleaseEvent(int slicer) {
+//   DD("LeftButtonReleaseEvent");
+//   for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+//     if (i == slicer);
+//     mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render();
+//   }
+// }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::apply()
+{ cout << __func__ << endl;
+  if (!mCurrentSlicerManager) close();
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  //GetArgsInfoFromGUI();  
+  
+  // Main filter
+
+
+
+  // Output
+  QApplication::restoreOverrideCursor();
+  close();
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolTest::UpdateSlice(int slicer,int slices)
+{ cout << __func__ << endl;
+  Update(slicer);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolTest::Update(int slicer)
+{ cout << __func__ << endl;
+  if (!mCurrentSlicerManager) close();
+  mCurrentSlicerManager->Render();
+  //mImageContour[slicer]->Update(mThresholdSlider1->GetValue());
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/* void vvToolTest::GetArgsInfoFromGUI()
+{ cout << __func__ << endl;
+
+  /* //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_clitkBinarizeImage_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;
+
+  // // Required (even if not used)
+  // mArgsInfo.input_given = 0;
+  // mArgsInfo.output_given = 0;
+
+  // mArgsInfo.input_arg = new char;
+  // mArgsInfo.output_arg = new char;
+} */
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::valueChangedT1()
+{ cout << __func__ << endl;
+  //  DD("valueChangedT1");
+  if (!mCurrentSlicerManager) close();
+  for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    //mImageContour[i]->Update(v);
+  }
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolTest.h b/vv/vvToolTest.h
new file mode 100644 (file)
index 0000000..f28a181
--- /dev/null
@@ -0,0 +1,62 @@
+/*=========================================================================
+  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 VVTOOLTEST_H
+#define VVTOOLTEST_H
+
+#include <QtUiPlugin/QDesignerExportWidget>
+
+#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
+#include "vvImageContour.h"
+#include "ui_vvToolTest.h"
+
+
+//------------------------------------------------------------------------------
+class vvToolTest:
+  public vvToolWidgetBase,
+  public vvToolBase<vvToolTest>,
+  private Ui::vvToolTest 
+{
+  Q_OBJECT
+    public:
+  vvToolTest(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+  ~vvToolTest();
+
+  //-----------------------------------------------------
+  static void Initialize();
+  //void GetArgsInfoFromGUI();
+  virtual void InputIsSelected(vvSlicerManager * m);
+
+  //-----------------------------------------------------
+  public slots:
+  virtual bool close();
+  virtual void reject();
+  virtual void apply();
+  void UpdateSlice(int slicer,int slices);
+  void valueChangedT1();
+
+ protected:
+  Ui::vvToolTest ui;
+  
+  void Update(int slicer);
+
+}; // end class vvToolTest
+//------------------------------------------------------------------------------
+
+#endif
+