]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx
changes in viewers
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkMPR3DDataViewer.cxx
index 07c0ec1d1274530fcc15cc1ecedf00f33c688859..25f66eddeb88da0fa22d32ecd32bef63ebafed70 100644 (file)
@@ -145,155 +145,149 @@ void vtkMPR3DDataViewer::Configure()
        if(_vtkmprbasedata->GetImageData()){
                _vtkmprbasedata->GetImageData()->GetScalarRange(range);
                max = range[1];
-       }else{
-               max = 1;
-       }
-       
-       
-       
-
-       _ctFunVectorPoint.clear();
-       _ctFunVectorPoint.push_back(max*0/4);
-       _ctFunVectorPoint.push_back(max*1/4);
-       _ctFunVectorPoint.push_back(max*2/4);
-       _ctFunVectorPoint.push_back(max*3/4);
-       _ctFunVectorPoint.push_back(max*4/4);
-
-       _ctFunVectorRed.clear();
-       _ctFunVectorRed.push_back(0.0);
-       _ctFunVectorRed.push_back(1.0);
-       _ctFunVectorRed.push_back(0.0);
-       _ctFunVectorRed.push_back(0.0);
-       _ctFunVectorRed.push_back(0.0);
-
-       _ctFunVectorGreen.clear();
-       _ctFunVectorGreen.push_back(0.0);
-       _ctFunVectorGreen.push_back(0.0);
-       _ctFunVectorGreen.push_back(0.0);
-       _ctFunVectorGreen.push_back(1.0);
-       _ctFunVectorGreen.push_back(0.2);
-
-       _ctFunVectorBlue.clear();
-       _ctFunVectorBlue.push_back(0.0);
-       _ctFunVectorBlue.push_back(0.0);
-       _ctFunVectorBlue.push_back(1.0);
-       _ctFunVectorBlue.push_back(0.0);
-       _ctFunVectorBlue.push_back(0.0);
-
-
-       if(_ctfun==NULL){
-               _ctfun = vtkColorTransferFunction::New();
-       }
-       _ctfun->RemoveAllPoints();
-
-       int i,size=_ctFunVectorPoint.size();
-       for (i=0;i<size;i++)
-       {
-               _ctfun->AddRGBPoint( _ctFunVectorPoint[i] , _ctFunVectorRed[i],_ctFunVectorGreen[i],_ctFunVectorBlue[i]);
                
-       }
-/*
-       _ctfun->AddRGBPoint( 100 ,0 ,0,0);
-       _ctfun->AddRGBPoint( 200 ,1 ,0,0);
-       _ctfun->AddRGBPoint( 300 ,0 ,1,0);
-       _ctfun->AddRGBPoint( 400 ,0 ,0,1);
-*/
-//     void *p=this; // JPRx
-
-  // Create the first of the three planes. The filter vtkImageMapToColors
-  // maps the data through the corresponding lookup table created above.  The
-  // vtkImageActor is a type of vtkProp and conveniently displays an image on
-  // a single quadrilateral plane. It does this using texture mapping and as
-  // a result is quite fast. (Note: the input image has to be unsigned char
-  // values, which the vtkImageMapToColors produces.) Note also that by
-  // specifying the DisplayExtent, the pipeline requests data of this extent
-  // and the vtkImageMapToColors only processes a slice of data.
-       
-       if(_saggitalColors==NULL){
-               _saggitalColors = vtkImageMapToColors::New();
-       }
-       _saggitalColors->RemoveAllInputs();
-       
-       if(_vtkmprbasedata->GetImageData()){
+               
+               _ctFunVectorPoint.clear();
+               _ctFunVectorPoint.push_back(max*0/4);
+               _ctFunVectorPoint.push_back(max*1/4);
+               _ctFunVectorPoint.push_back(max*2/4);
+               _ctFunVectorPoint.push_back(max*3/4);
+               _ctFunVectorPoint.push_back(max*4/4);
+
+               _ctFunVectorRed.clear();
+               _ctFunVectorRed.push_back(0.0);
+               _ctFunVectorRed.push_back(1.0);
+               _ctFunVectorRed.push_back(0.0);
+               _ctFunVectorRed.push_back(0.0);
+               _ctFunVectorRed.push_back(0.0);
+
+               _ctFunVectorGreen.clear();
+               _ctFunVectorGreen.push_back(0.0);
+               _ctFunVectorGreen.push_back(0.0);
+               _ctFunVectorGreen.push_back(0.0);
+               _ctFunVectorGreen.push_back(1.0);
+               _ctFunVectorGreen.push_back(0.2);
+
+               _ctFunVectorBlue.clear();
+               _ctFunVectorBlue.push_back(0.0);
+               _ctFunVectorBlue.push_back(0.0);
+               _ctFunVectorBlue.push_back(1.0);
+               _ctFunVectorBlue.push_back(0.0);
+               _ctFunVectorBlue.push_back(0.0);
+
+
+               if(_ctfun==NULL){
+                       _ctfun = vtkColorTransferFunction::New();
+               }
+               _ctfun->RemoveAllPoints();
+
+               int i,size=_ctFunVectorPoint.size();
+               for (i=0;i<size;i++)
+               {
+                       _ctfun->AddRGBPoint( _ctFunVectorPoint[i] , _ctFunVectorRed[i],_ctFunVectorGreen[i],_ctFunVectorBlue[i]);
+                       
+               }
+       /*
+               _ctfun->AddRGBPoint( 100 ,0 ,0,0);
+               _ctfun->AddRGBPoint( 200 ,1 ,0,0);
+               _ctfun->AddRGBPoint( 300 ,0 ,1,0);
+               _ctfun->AddRGBPoint( 400 ,0 ,0,1);
+       */
+       //      void *p=this; // JPRx
+
+       // Create the first of the three planes. The filter vtkImageMapToColors
+       // maps the data through the corresponding lookup table created above.  The
+       // vtkImageActor is a type of vtkProp and conveniently displays an image on
+       // a single quadrilateral plane. It does this using texture mapping and as
+       // a result is quite fast. (Note: the input image has to be unsigned char
+       // values, which the vtkImageMapToColors produces.) Note also that by
+       // specifying the DisplayExtent, the pipeline requests data of this extent
+       // and the vtkImageMapToColors only processes a slice of data.
+               
+               if(_saggitalColors==NULL){
+                       _saggitalColors = vtkImageMapToColors::New();
+               }
+               _saggitalColors->RemoveAllInputs();
                _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() );
-       }
-//    _saggitalColors->SetLookupTable(_bwLut);
-       
-    _saggitalColors->SetLookupTable(_ctfun);
-       
+               
+       //    _saggitalColors->SetLookupTable(_bwLut);
+               
+               _saggitalColors->SetLookupTable(_ctfun);
+               
 
-       if(_saggital==NULL){
-               _saggital = vtkImageActor::New();
-               _saggital->SetInput(_saggitalColors->GetOutput());
-       }       
-       //_saggitalColors->Update();
-    
+               if(_saggital==NULL){
+                       _saggital = vtkImageActor::New();
+                       _saggital->SetInput(_saggitalColors->GetOutput());
+               }       
+               //_saggitalColors->Update();
+       
 
 
-  // Create the second (axial) plane of the three planes. We use the
-  // same approach as before except that the extent differs.
+       // Create the second (axial) plane of the three planes. We use the
+       // same approach as before except that the extent differs.
 
-       
-       if(_axialColors==NULL){
-               _axialColors = vtkImageMapToColors::New();
-       }
+               
+               if(_axialColors==NULL){
+                       _axialColors = vtkImageMapToColors::New();
+               }
 
-       _axialColors->RemoveAllInputs();
-       if(_vtkmprbasedata->GetImageData()){
+               _axialColors->RemoveAllInputs();
                _axialColors->SetInput( _vtkmprbasedata->GetImageData() );
-       }
-//    _axialColors->SetLookupTable(_hueLut);
-    _axialColors->SetLookupTable(_ctfun);
+       //    _axialColors->SetLookupTable(_hueLut);
+               _axialColors->SetLookupTable(_ctfun);
 
-       if(_axial==NULL){
-               _axial = vtkImageActor::New();
-               _axial->SetInput(_axialColors->GetOutput());
-       }
+               if(_axial==NULL){
+                       _axial = vtkImageActor::New();
+                       _axial->SetInput(_axialColors->GetOutput());
+               }
+               
+               //_axialColors->Update();
        
-       //_axialColors->Update();
-    
 
-       // Create the third (coronal) plane of the three planes. We use 
-  // the same approach as before except that the extent differs.
-       if(_coronalColors==NULL){
-               _coronalColors = vtkImageMapToColors::New();
-       }
-       _coronalColors->RemoveAllInputs();
-       if(_vtkmprbasedata->GetImageData()){
+               // Create the third (coronal) plane of the three planes. We use 
+       // the same approach as before except that the extent differs.
+               if(_coronalColors==NULL){
+                       _coronalColors = vtkImageMapToColors::New();
+               }
+               _coronalColors->RemoveAllInputs();
                _coronalColors->SetInput( _vtkmprbasedata->GetImageData() );
-       }
-//    _coronalColors->SetLookupTable(_satLut);
-    _coronalColors->SetLookupTable(_ctfun);
+       //    _coronalColors->SetLookupTable(_satLut);
+               _coronalColors->SetLookupTable(_ctfun);
 
-       if(_coronal==NULL){
-               _coronal = vtkImageActor::New();
-               _coronal->SetInput(_coronalColors->GetOutput());
-       }
+               if(_coronal==NULL){
+                       _coronal = vtkImageActor::New();
+                       _coronal->SetInput(_coronalColors->GetOutput());
+               }
+               
        
-    
 
-  // An outline provides context around the data.
-  //
-       if(_outlineData==NULL){
-               _outlineData = vtkOutlineFilter::New();
-       }
-       _outlineData->RemoveAllInputs();
-       if(_vtkmprbasedata->GetImageData()){
-               _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
+       // An outline provides context around the data.
+       //
+               if(_outlineData==NULL){
+                       _outlineData = vtkOutlineFilter::New();
+               }
+               _outlineData->RemoveAllInputs();
+               if(_vtkmprbasedata->GetImageData()){
+                       _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
+               }
+
+               if(_mapOutline==NULL){
+                       _mapOutline = vtkPolyDataMapper::New();
+                       _mapOutline->SetInput(_outlineData->GetOutput());
+               }
+               _mapOutline->Update();    
+               //_mapOutline->RemoveAllInputs();
+       
+               if(_outline==NULL){
+                       _outline = vtkActor::New();
+                       _outline->SetMapper(_mapOutline);
+                       _outline->GetProperty()->SetColor(0,0,0);
+               }
        }
+       
+       
 
-       if(_mapOutline==NULL){
-               _mapOutline = vtkPolyDataMapper::New();
-               _mapOutline->SetInput(_outlineData->GetOutput());
-       }
-       _mapOutline->Update();    
-       //_mapOutline->RemoveAllInputs();
-    
-       if(_outline==NULL){
-               _outline = vtkActor::New();
-               _outline->SetMapper(_mapOutline);
-               _outline->GetProperty()->SetColor(0,0,0);
-       }
+       
        
     
 
@@ -325,19 +319,25 @@ vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_axial()
 void vtkMPR3DDataViewer::SetPositionX(int pos){
        int x1,x2,y1,y2,z1,z2;
        _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
-       _saggital->SetDisplayExtent( pos , pos , y1 ,y2 , z1 , z2 );
+       if(_saggital){
+               _saggital->SetDisplayExtent( pos , pos , y1 ,y2 , z1 , z2 );
+       }
 }
 //------------------------------------------------------------------------
 void vtkMPR3DDataViewer::SetPositionY(int pos){
        int x1,x2,y1,y2,z1,z2;
        _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
-       _coronal->SetDisplayExtent(x1,x2, pos,pos, z1,z2);
+       if(_coronal){
+               _coronal->SetDisplayExtent(x1,x2, pos,pos, z1,z2);
+       }
 }
 //------------------------------------------------------------------------
 void vtkMPR3DDataViewer::SetPositionZ(int pos){
        int x1,x2,y1,y2,z1,z2;
        _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
-       _axial->SetDisplayExtent(x1,x2, y1,y2, pos,pos);
+       if(_axial){
+               _axial->SetDisplayExtent(x1,x2, y1,y2, pos,pos);
+       }
 }
 //-------------------------------------------------------------------
 void vtkMPR3DDataViewer::SetVisiblePosition(int idPosition, bool visible)
@@ -351,8 +351,10 @@ bool vtkMPR3DDataViewer::GetVisiblePosition(int idPosition)
 }
 
 void vtkMPR3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
-       _saggitalColors->SetLookupTable(colortable);
-        _coronalColors->SetLookupTable(colortable);
-       _axialColors->SetLookupTable(colortable);
+       if(_saggitalColors){
+               _saggitalColors->SetLookupTable(colortable);
+               _coronalColors->SetLookupTable(colortable);
+               _axialColors->SetLookupTable(colortable);
+       }
 }