From c1677d6877a1649bb1fed16141bcebb48487b157 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Mon, 30 Nov 2015 14:01:03 +0100 Subject: [PATCH] ROI Debug Real-time Display Delay Debug Add test tool (display a sphere in front of the image) --- vv/qt_ui/vvToolTest.ui | 28 +++ vv/vvBinaryImageOverlayActor.cxx | 31 ++-- vv/vvImageContour.cxx | 1 - vv/vvToolTest.cxx | 306 +++++++++++++++++++++++++++++++ vv/vvToolTest.h | 62 +++++++ 5 files changed, 411 insertions(+), 17 deletions(-) create mode 100644 vv/qt_ui/vvToolTest.ui create mode 100644 vv/vvToolTest.cxx create mode 100644 vv/vvToolTest.h diff --git a/vv/qt_ui/vvToolTest.ui b/vv/qt_ui/vvToolTest.ui new file mode 100644 index 0000000..01279b5 --- /dev/null +++ b/vv/qt_ui/vvToolTest.ui @@ -0,0 +1,28 @@ + + + vvToolTest + + + + 0 + 0 + 433 + 222 + + + + Test sphere + + + + + + Qt::Horizontal + + + + + + + + diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index 74aabac..1af316d 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -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; iGetSlice(); 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 */ diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index c4c8c56..e391bbb 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -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 index 0000000..e583ac4 --- /dev/null +++ b/vv/vvToolTest.cxx @@ -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 +#include +#include +#include +#include +#include +#include +#include + + +//------------------------------------------------------------------------------ +// 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(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; iShowActors(); + 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 sphereSource = + vtkSmartPointer::New(); + sphereSource->SetCenter(0, 0, 0); + //sphereSource->SetCenter(235.351, 175.781, 141.0); + sphereSource->SetRadius(10.0); + sphereSource->Update(); + vtkSmartPointer sphereMapper = + vtkSmartPointer::New(); + sphereMapper->SetInputConnection(sphereSource->GetOutputPort()); + vtkSmartPointer sphereActor = + vtkSmartPointer::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 sphereRenderer = + vtkSmartPointer::New(); + // Add Actor to renderer + for(int i=0;iGetNumberOfSlicers(); 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; iGetNumberOfSlicers(); 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_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; + + // // 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;iGetNumberOfSlicers(); i++) { + //mImageContour[i]->Update(v); + } + mCurrentSlicerManager->Render(); +} +//------------------------------------------------------------------------------ diff --git a/vv/vvToolTest.h b/vv/vvToolTest.h new file mode 100644 index 0000000..f28a181 --- /dev/null +++ b/vv/vvToolTest.h @@ -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 + +#include "vvToolBase.h" +#include "vvToolWidgetBase.h" +#include "vvImageContour.h" +#include "ui_vvToolTest.h" + + +//------------------------------------------------------------------------------ +class vvToolTest: + public vvToolWidgetBase, + public vvToolBase, + 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 + -- 2.47.1