]> Creatis software - creaMaracasVisu.git/blobdiff - lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanagerdata.h
no message
[creaMaracasVisu.git] / lib / Kernel / VTKObjects / VolumeRenderer / volumerenderermanagerdata.h
index ad0ba5f372df05978f7edbf96078bf974e26edb2..87b1b74569fff152840378249c86c4e432c6c5a8 100644 (file)
@@ -2,8 +2,10 @@
 #ifndef VolumeRendererManagerData_H_
 #define VolumeRendererManagerData_H_
 
+#include "vtkCommand.h"
 #include <vtkVolumeRayCastCompositeFunction.h>
 #include <vtkPlanes.h>
+#include <vtkVolumeMapper.h>
 #include <vtkVolumeRayCastMapper.h>
 #include <vtkVolumeProperty.h>
 #include <vtkVolume.h>
 #include <vtkRenderer.h>
 #include <vtkVolumeRayCastMIPFunction.h>
 #include <vtkLookupTable.h>
+#include <vtkBoxWidget.h>
+#include <vtkAbstractMapper.h>
+
+#if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
+  #include <vtkGPUVolumeRayCastMapper.h>
+#endif
+
+
 #include <vector>
 
 
-class VolumeRendererManagerData  {
+// Callback for moving the planes from the box widget to the mapper
+class vtkBoxWidgetCallback : public vtkCommand
+{
+public:
+  static vtkBoxWidgetCallback *New()
+    { return new vtkBoxWidgetCallback; }
+  virtual void Execute(vtkObject *caller, unsigned long, void*)
+    {
+      vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
+      if (this->Mapper)
+        {
+        vtkPlanes *planes = vtkPlanes::New();
+        widget->GetPlanes(planes);
+        this->Mapper->SetClippingPlanes(planes);
+        planes->Delete();
+        }
+    }
+  void SetMapper(vtkAbstractMapper* m)
+    { this->Mapper = m; }
+
+protected:
+  vtkBoxWidgetCallback()
+    { this->Mapper = 0; }
+
+  //vtkVolumeRayCastMapper *Mapper;
+  vtkAbstractMapper *Mapper;
+};
+
+
+class VolumeRendererManagerData  : public vtkObject{
 
 public:
         VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
         VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
+        VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname="");
         ~VolumeRendererManagerData();
 
         /**
@@ -71,6 +111,10 @@ public:
         **     Volume Opacity
         **/
         void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
+        /**
+        **     Volume Opacity
+        **/
+        void setVolumeOpacity(std::vector<double> greylevel,double value);
 
         vtkPiecewiseFunction* GetTransferFunction(){
                 return _tfun;
@@ -84,6 +128,8 @@ public:
 
         void SetLookupTable(vtkLookupTable* lookuptable);
 
+        void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
+        void DisableBoundingBox();
 protected:
         /**
          * Prop 3D (data actor)
@@ -104,14 +150,27 @@ private:
 
         vtkVolumeRayCastCompositeFunction      *_compositeFunction;
         vtkPlanes                                                      *_volumePlanes;
-        vtkVolumeRayCastMapper                         *_volumeMapper;
+        vtkVolumeRayCastMapper                     *_volumeMapper;
+       
+       
+#if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6)
+               vtkGPUVolumeRayCastMapper           *_volumeMappergpu;
+#else  
+               vtkVolumeRayCastMapper                      *_volumeMappergpu;
+#endif 
+       
+       
         vtkVolumeProperty                                      *_volumeProperty;
         vtkVolume                                                      *_newvol;
         vtkPiecewiseFunction* _tfun;
         vtkColorTransferFunction* _ctfun;
         vtkVolumeRayCastMIPFunction* _MIPFunction;
+        /**
+        ** boxwidget to control the volume
+        **/
+        vtkBoxWidget* _boxWidgetS1;
 
-        void Initialize(vtkImageData* vol, std::string dataname);
+        void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
 
 
 };