]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx
Bug #1373
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkClipping3DDataViewer.cxx
index 800f8be546d499af73ae2bef0223cb0deb87a55e..901a7d7d4c6bb1f5aaa518917c3ef17d57b3b1a7 100644 (file)
@@ -16,9 +16,13 @@ vtkClipping3DDataViewer::vtkClipping3DDataViewer()
        _interpolation=false;
        _shade=false;
 
+    _volumerendererdata = VolumeRendererData::New();
     _volumeMapper = vtkVolumeRayCastMapper::New();
     _newvol = vtkVolume::New();
     _volumeProperty = vtkVolumeProperty::New();
+    _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
+        _compositeFunctionMIP = vtkVolumeRayCastMIPFunction::New();
+
 }
 //-------------------------------------------------------------------
 vtkClipping3DDataViewer::~vtkClipping3DDataViewer()
@@ -162,6 +166,15 @@ void vtkClipping3DDataViewer::SetVisibleVolume(bool visiblevolume)
        _visibleVolume = visiblevolume;
 }
 
+bool vtkClipping3DDataViewer::GetVisibleVolumeBox()
+{
+       return _visibleVolumeBox;
+}
+//-------------------------------------------------------------------
+void vtkClipping3DDataViewer::SetVisibleVolumeBox(bool visibleBox)
+{
+       _visibleVolumeBox = visibleBox;
+}
 
 //-------------------------------------------------------------------
 void vtkClipping3DDataViewer::Configure_Tissue()
@@ -235,8 +248,6 @@ void vtkClipping3DDataViewer::Configure_Volume()
 {
   // Volume
 
-
-
  /** if(_newvol != NULL)
   {
     _newvol->Delete();
@@ -244,15 +255,13 @@ void vtkClipping3DDataViewer::Configure_Volume()
     _volumeProperty->Delete();
   }*/
 
-
-
   _tfun = vtkPiecewiseFunction::New();
   _ctfun = vtkColorTransferFunction::New();
 
        double range[2];
        this->_vtkmprbasedata->GetImageData()->GetScalarRange(range);
        double max = range[1];
-
+       
        /*
        adding the poinst of the transference function
        */
@@ -313,61 +322,25 @@ void vtkClipping3DDataViewer::Configure_Volume()
 
        // EED 13/03/2011
 
-  _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
-       vtkVolumeRayCastMIPFunction* _compositeFunctionMIP = vtkVolumeRayCastMIPFunction::New();
-
-
  // _volumeMapper = vtkVolumeRayCastMapper::New();
        _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
 
-if(_isRayCasting)
-{
-    cout<<"JPRG::vtkClipping3DDataViewer::Configure_Volume::isRayCasting"<<endl;
     _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
 
-}
-else if(_isMIP)
-{
-    cout<<"JPRG::vtkClipping3DDataViewer::Configure_Volume::isMIP"<<endl;
-    _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
-}
-
+   // _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
+       
 //
-
        _volumeMapper->SetClippingPlanes( _volumePlanes );
        _volumeMapper->AutoAdjustSampleDistancesOn();
 
+    _volumeProperty->SetInterpolationTypeToNearest();
     //_volumeProperty = vtkVolumeProperty::New();
        _volumeProperty->SetColor(_ctfun);
        _volumeProperty->SetScalarOpacity( _tfun );
 
 // EED 31/03/2008
-
        _volumeProperty->DisableGradientOpacityOn();
 
-if(_interpolation)
-{
-    _volumeProperty->SetInterpolationTypeToLinear();
-}
-else
-{
-    _volumeProperty->SetInterpolationTypeToNearest();
-}
-
-if(_shade)
-{
-    _volumeProperty->ShadeOn();
-}
-else
-{
-    _volumeProperty->ShadeOff();
-}
-
-//     _
-
-
-//     _
-
 
 //     _volumeProperty->SetInterpolationTypeToNearest();
 //     _volumeProperty->ShadeOff();
@@ -380,19 +353,100 @@ else
        _newvol->SetMapper(_volumeMapper );
        _newvol->SetProperty(_volumeProperty );
 
-  _observerV = boxSurfaceObserver::New();
+    _observerV = boxSurfaceObserver::New();
        _observerV->SetPlanes( _volumePlanes );
        _observerV->SetActor( _newvol );
        _observerV->SetvtkVolumeRayCastMapper( _volumeMapper );
 }
 
 
+void vtkClipping3DDataViewer::Configure_VolumeBox()
+{
+       _volumerendererdata->SetImageData(_vtkmprbasedata->GetImageData());
+
+
+    vector<double> *gv = this->GetGreyValuesTransferenceFVector();
+    vector<double> *op = this->GetIntensityValuesTransferenceFVector();
+
+    _volumerendererdata->SetLookUpTable((vtkLookupTable*)(_ctfun));
+    _volumerendererdata->OpacityChanged(*gv, *op);
+
+    //_wxvtkclipping3Dview->VisibleVolumeActor( false );
+    //_volumerendererdata->ShowVolume(event.IsChecked() );
+       //_volumerendererdata->BoundingBoxChanged(event.IsChecked() );
+}
+
+void vtkClipping3DDataViewer::SetRenderer(vtkRenderer* renderer)
+{
+    _volumerendererdata->SetRenderer(renderer);
+
+}
+
+void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interactor)
+{
+
+    _volumerendererdata->SetInteractor(interactor);
+}
+
+
+void vtkClipping3DDataViewer::BoxActorChanged(bool changed)
+{
+    vector<double> *gv = this->GetGreyValuesTransferenceFVector();
+    vector<double> *op = this->GetIntensityValuesTransferenceFVector();
+
+   _volumerendererdata->ShowVolume(changed);
+    _volumerendererdata->OpacityChanged(*gv, *op);
+    _volumerendererdata->BoundingBoxChanged(changed);
+
+}
+
+void vtkClipping3DDataViewer::UpdateVolumeBox(vector<double> gf, vector<double> vf, vtkColorTransferFunction* ctfun)
+{
+        _volumerendererdata->SetLookUpTable((vtkLookupTable*)(ctfun));
+        _volumerendererdata->OpacityChanged(gf, vf);
+}
+
+
+void vtkClipping3DDataViewer::updateVolume()
+{
+
+    if(_isRayCasting)
+    {
+        _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+        _volumerendererdata->changeCompositeMIPFunction(0);
+    }
+    else if(_isMIP)
+    {
+        _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
+        _volumerendererdata->changeCompositeMIPFunction(1);
+    }
+
+    if(_interpolation)
+    {
+        _volumeProperty->SetInterpolationTypeToLinear();
+    }
+    else
+    {
+        _volumeProperty->SetInterpolationTypeToNearest();
+    }
+
+    if(_shade)
+    {
+        _volumeProperty->ShadeOn();
+    }
+    else
+    {
+        _volumeProperty->ShadeOff();
+    }
+
+}
+
 //-------------------------------------------------------------------
 void vtkClipping3DDataViewer::Configure()
 {
        Configure_Tissue();
        Configure_Volume();
-
+    Configure_VolumeBox();
   // An outline provides context around the data.
   //
        _outlineData = vtkOutlineFilter::New();