]> Creatis software - creaMaracasVisu.git/blobdiff - lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanagerdata.h
changes to volume rendering base
[creaMaracasVisu.git] / lib / Kernel / VTKObjects / VolumeRenderer / volumerenderermanagerdata.h
index ad0ba5f372df05978f7edbf96078bf974e26edb2..802372840ebf7e83e949c8cf89cba99e1f812f0e 100644 (file)
 #include <vtkVolumeRayCastMIPFunction.h>
 #include <vtkLookupTable.h>
 #include <vector>
+#include <vtkBoxWidget.h>
+#include <vtkGPUVolumeRayCastMapper.h>
+#include "vtkCommand.h"
 
+// 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(vtkGPUVolumeRayCastMapper* m)
+    { this->Mapper = m; }
+
+protected:
+  vtkBoxWidgetCallback()
+    { this->Mapper = 0; }
+
+  //vtkVolumeRayCastMapper *Mapper;
+  vtkGPUVolumeRayCastMapper *Mapper;
+};
 
-class VolumeRendererManagerData  {
+
+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 +103,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 +120,8 @@ public:
 
         void SetLookupTable(vtkLookupTable* lookuptable);
 
+        void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
+        void DisableBoundingBox();
 protected:
         /**
          * Prop 3D (data actor)
@@ -105,13 +143,18 @@ private:
         vtkVolumeRayCastCompositeFunction      *_compositeFunction;
         vtkPlanes                                                      *_volumePlanes;
         vtkVolumeRayCastMapper                         *_volumeMapper;
+        vtkGPUVolumeRayCastMapper                               *_volumeMappergpu;
         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);
 
 
 };