]> Creatis software - clitk.git/commitdiff
Modified overlay image actor to use a blending which takes the maximum per color...
authorsrit <srit>
Sun, 16 May 2010 18:40:17 +0000 (18:40 +0000)
committersrit <srit>
Sun, 16 May 2010 18:40:17 +0000 (18:40 +0000)
vv/CMakeLists.txt
vv/qt_ui/vvOverlayPanel.ui
vv/vvBlendImageActor.cxx [new file with mode: 0755]
vv/vvBlendImageActor.h [new file with mode: 0755]
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h

index 6c7f8fe2205baa40097fbce84d68bfc77c355070..5af8f2686399e8df4a16794e9828474289c8f8b5 100644 (file)
@@ -118,6 +118,7 @@ SET(vv_SRCS
   vvStructureSetActor.cxx
   vvROIActor.cxx
   vvToolResample.cxx
+  vvBlendImageActor.cxx
   )
 
 QT4_WRAP_CPP(vv_SRCS 
index 3f48f9ad5a59bc145140c9ce7a1ea48a9cf0e256..76ef967128d98d0f4ab143e194561edb9b131457 100644 (file)
@@ -260,7 +260,7 @@ p, li { white-space: pre-wrap; }
       <item row="1" column="2">
        <widget class="QSlider" name="colorHorizontalSlider">
         <property name="maximum">
-         <number>180</number>
+         <number>359</number>
         </property>
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
diff --git a/vv/vvBlendImageActor.cxx b/vv/vvBlendImageActor.cxx
new file mode 100755 (executable)
index 0000000..f28ba32
--- /dev/null
@@ -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 <vtkOpenGLRenderWindow.h>
+#include <vtkOpenGLExtensionManager.h>
+#include <vtkOpenGLRenderer.h>
+#include <vtkOpenGL.h>
+#include <vtkgl.h>
+#include <vtkObjectFactory.h>
+
+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<vtkOpenGLRenderWindow*>(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 (executable)
index 0000000..8df964a
--- /dev/null
@@ -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 <vtkActor.h>
+#include <vtkSmartPointer.h>
+#include <vtkOpenGLImageActor.h>
+
+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
index 9a2eec41414a0a8193322717ed71bbf47dc7881d..1de1738c030f39925a49c96fe740945d07bea407 100644 (file)
@@ -34,6 +34,7 @@
 #include <vtkImageMapToWindowLevelColors.h>
 #include <vtkImageData.h>
 #include <vtkImageActor.h>
+#include <vvBlendImageActor.h>
 #include <vtkToolkits.h>
 #include <vtkObjectFactory.h>
 #include <vtkPointData.h>
@@ -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);
index ff0d2698e0d8a6700a6b8ca5b7ad0f28108580b6..3ccf8effcdb4e49206e577620255b4361ef2e0b5 100644 (file)
@@ -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<vtkImageMapToWindowLevelColors> mOverlayMapper;
-    vtkSmartPointer<vtkImageActor> mOverlayActor;
+    vtkSmartPointer<vvBlendImageActor> mOverlayActor;
     vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
     vtkSmartPointer<vtkImageActor> mFusionActor;
     vtkSmartPointer<vtkCornerAnnotation> ca;
index ca66064e1f64608fe0f4d1e225926ffcc1ac67ee..4ba327b91c745444d1a80746033adbb90d286e47 100644 (file)
@@ -26,6 +26,7 @@
 #include "vvImageReader.h"
 #include "vvMesh.h"
 #include "vvImageMapToWLColors.h"
+#include "vvBlendImageActor.h"
 
 #include <vtkImageActor.h>
 #include <vtkImageData.h>
index 5d8d5d2d846890c35e024f99e5e988bbf20ca3c4..5eaaa57ce389bfd2fa9d3b7fe2bc8a6c87af2517 100644 (file)
@@ -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;