From 26c6b8e9d0333a9e0be98c3fb9d57f133477d97d Mon Sep 17 00:00:00 2001 From: srit Date: Sun, 16 May 2010 18:40:17 +0000 Subject: [PATCH] Modified overlay image actor to use a blending which takes the maximum per color component => overlay only enabled for hue value of 0, 60, ... --- vv/CMakeLists.txt | 1 + vv/qt_ui/vvOverlayPanel.ui | 2 +- vv/vvBlendImageActor.cxx | 63 ++++++++++++++++++++++++++++++++++++++ vv/vvBlendImageActor.h | 46 ++++++++++++++++++++++++++++ vv/vvSlicer.cxx | 5 +-- vv/vvSlicer.h | 5 +-- vv/vvSlicerManager.cxx | 1 + vv/vvSlicerManager.h | 2 +- 8 files changed, 119 insertions(+), 6 deletions(-) create mode 100755 vv/vvBlendImageActor.cxx create mode 100755 vv/vvBlendImageActor.h diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 6c7f8fe..5af8f26 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -118,6 +118,7 @@ SET(vv_SRCS vvStructureSetActor.cxx vvROIActor.cxx vvToolResample.cxx + vvBlendImageActor.cxx ) QT4_WRAP_CPP(vv_SRCS diff --git a/vv/qt_ui/vvOverlayPanel.ui b/vv/qt_ui/vvOverlayPanel.ui index 3f48f9a..76ef967 100644 --- a/vv/qt_ui/vvOverlayPanel.ui +++ b/vv/qt_ui/vvOverlayPanel.ui @@ -260,7 +260,7 @@ p, li { white-space: pre-wrap; } - 180 + 359 Qt::Horizontal diff --git a/vv/vvBlendImageActor.cxx b/vv/vvBlendImageActor.cxx new file mode 100755 index 0000000..f28ba32 --- /dev/null +++ b/vv/vvBlendImageActor.cxx @@ -0,0 +1,63 @@ + /*========================================================================= + 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://oncora1.lyon.fnclcc.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 + ======================================================================-====*/ + +#include "vvBlendImageActor.h" + +#include +#include +#include +#include +#include +#include + +vtkStandardNewMacro(vvBlendImageActor); + +vvBlendImageActor::vvBlendImageActor() +{ +} + +vvBlendImageActor::~vvBlendImageActor() +{ +} + +// Actual actor render method. +void vvBlendImageActor::Render(vtkRenderer *ren) +{ + //Change blending to maximum per component instead of weighted sum + vtkOpenGLRenderWindow *renwin = dynamic_cast(ren->GetRenderWindow()); + vtkOpenGLExtensionManager *extensions = renwin->GetExtensionManager(); + if (extensions->ExtensionSupported("GL_EXT_blend_minmax")) + { + extensions->LoadExtension("GL_EXT_blend_minmax"); + vtkgl::BlendEquationEXT( vtkgl::MAX ); + } + + //Call normal render + vtkOpenGLImageActor::Render(ren); + + //Move back blending to weighted sum + if (vtkgl::BlendEquationEXT!=0) + { + vtkgl::BlendEquationEXT( vtkgl::FUNC_ADD ); + } +} + +void vvBlendImageActor::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); +} diff --git a/vv/vvBlendImageActor.h b/vv/vvBlendImageActor.h new file mode 100755 index 0000000..8df964a --- /dev/null +++ b/vv/vvBlendImageActor.h @@ -0,0 +1,46 @@ + /*========================================================================= + 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://oncora1.lyon.fnclcc.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 VVBLENDIMAGEACTOR_H +#define VVBLENDIMAGEACTOR_H + +#include +#include +#include + +class vvBlendImageActor : public vtkOpenGLImageActor +{ +public: + static vvBlendImageActor *New(); + vtkTypeMacro(vvBlendImageActor, vtkOpenGLImageActor); + virtual void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Implement base class method. + void Render(vtkRenderer *ren); + +protected: + vvBlendImageActor(); + ~vvBlendImageActor(); + +private: + vvBlendImageActor(const vvBlendImageActor&); // Not implemented. + void operator=(const vvBlendImageActor&); // Not implemented. +}; + +#endif diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 9a2eec4..1de1738 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -155,7 +156,7 @@ vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper() { //------------------------------------------------------------------------------ -vtkImageActor* vvSlicer::GetOverlayActor() { +vvBlendImageActor* vvSlicer::GetOverlayActor() { return mOverlayActor.GetPointer(); } //------------------------------------------------------------------------------ @@ -323,7 +324,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) if (!mOverlayActor) { - mOverlayActor = vtkImageActor::New(); + mOverlayActor = vvBlendImageActor::New(); mOverlayActor->SetInput(mOverlayMapper->GetOutput()); mOverlayActor->SetPickable(0); mOverlayActor->SetVisibility(false); diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index ff0d269..3ccf8ef 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -34,6 +34,7 @@ class vtkPolyDataMapper2D; class vtkProperty2D; class vtkClipPolyData; class vtkImageActor; +class vvBlendImageActor; class vtkBox; class vtkCornerAnnotation; class vtkExtractVOI; @@ -67,7 +68,7 @@ public: } vtkImageMapToWindowLevelColors* GetOverlayMapper(); - vtkImageActor* GetOverlayActor() ; + vvBlendImageActor* GetOverlayActor() ; vtkImageMapToWindowLevelColors* GetFusionMapper() ; vtkImageActor* GetFusionActor() ; vtkActor* GetVFActor() ; @@ -179,7 +180,7 @@ protected: vvLandmarks* mLandmarks; vtkSmartPointer mOverlayMapper; - vtkSmartPointer mOverlayActor; + vtkSmartPointer mOverlayActor; vtkSmartPointer mFusionMapper; vtkSmartPointer mFusionActor; vtkSmartPointer ca; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index ca66064..4ba327b 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -26,6 +26,7 @@ #include "vvImageReader.h" #include "vvMesh.h" #include "vvImageMapToWLColors.h" +#include "vvBlendImageActor.h" #include #include diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 5d8d5d2..5eaaa57 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -115,7 +115,7 @@ class vvSlicerManager : public QObject { void SetColorMap(int colormap); void SetPreset(int preset); void SetOverlayColor(int color) { - mOverlayColor = color; + mOverlayColor = (color/60)*60; //SR: new vvBlendImageActor needs 0 or 255 per component } void SetFusionOpacity(int opacity) { mFusionOpacity = opacity; -- 2.47.1