]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMPRBaseData.cxx
index 67dfe61647d14e761ac2cd68ea7c8f2871521e1c..f3217a2e5b2f801419ea11328f6f542898987425 100644 (file)
@@ -35,7 +35,7 @@ vtkBaseData::~vtkBaseData()
 void vtkBaseData::SetMarImageData(marImageData *marimagedata)
 {
        _marImageData = marimagedata;
-       Configure();
+       //Configure();
 }
 
 //-------------------------------------------------------------------
@@ -57,26 +57,40 @@ void vtkBaseData::Configure()  // virtual
 
 //-------------------------------------------------------------------
 void vtkBaseData::SetZ(double z){
-       int maxZ;
+       //int maxZ;
 
 //     int dim[3];
 //     _marImageData->GetDimensions(dim);
 //     maxZ=dim[2];
 
        int ext[6];
-       _marImageData->GetImageData()->GetWholeExtent(ext);
-       maxZ=ext[5]-ext[4]+1;
+       vtkImageData* img = _marImageData->GetImageData();
+       if(img!=NULL){
+               /*img->GetWholeExtent(ext);
+               maxZ=ext[5]-ext[4]+1;
 
-       if (z>=maxZ)
-       {
-               z=maxZ-1;
-       }
-       if (z<=0)
-       {
-               z=0;
-       }
+               if (z>=maxZ)
+               {
+                       //z=maxZ-1;
+               }
+               if (z<=0)
+               {
+                       z=0;
+               }
 
-       _z=z;
+               _z=z;*/
+               img->GetExtent(ext);
+               if (z > ext[5])
+               {
+                       z = ext[5];
+               }
+               if (z < ext[4])
+               {
+                       z = ext[4];
+               }
+
+               _z=z;
+       }
 }
 //-------------------------------------------------------------------
 double vtkBaseData::GetZ()
@@ -100,7 +114,7 @@ void vtkBaseData::SetT(double t)
        {
                t=0;
        }
-       _t=t;
+       _t=(int)t;
 }
 
 //-------------------------------------------------------------------
@@ -112,6 +126,7 @@ vtkMPRBaseData::vtkMPRBaseData()
   _y=0;
   _z=0;
   _transformOrientation = NULL;
+  _marImageData = NULL;
 }
 //-------------------------------------------------------------------
 vtkMPRBaseData::~vtkMPRBaseData()
@@ -122,9 +137,15 @@ vtkMPRBaseData::~vtkMPRBaseData()
 //-------------------------------------------------------------------
 void vtkMPRBaseData::Configure()
 {
-       _marImageData->GetImageData()->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2);
-       _transformOrientation=vtkTransform::New();
-       _transformOrientation->Identity();
+       vtkImageData* img = _marImageData->GetImageData();
+       if(img !=NULL){
+               img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2);
+       //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<<std::endl;
+               if(_transformOrientation==NULL){
+                       _transformOrientation=vtkTransform::New();
+               }
+               _transformOrientation->Identity();
+       }
 }
 //-------------------------------------------------------------------
 void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2)
@@ -156,6 +177,7 @@ int vtkMPRBaseData::GetMaxPositionZ( )
 //-------------------------------------------------------------------
 double vtkMPRBaseData::GetX()
 {
+
        return _x;
 }
 //-------------------------------------------------------------------
@@ -164,38 +186,73 @@ double    vtkMPRBaseData::GetY()
        return _y;
 }
 //-------------------------------------------------------------------
+/**
+**     Calculates the value of the slider and the layer in the image that is spouse to show
+**/
 void vtkMPRBaseData::SetX(double x)
 {
-       int dim[3];
-       _marImageData->GetImageData()->GetDimensions(dim);
-       if (x<0)
-       {
-               x=0;
+       //int dim[3];
+       int ext[6];
+
+       vtkImageData* img = _marImageData->GetImageData();
+       if(img!=NULL){
+               /*img->GetDimensions(dim);
+               if (x<0)
+               {
+                       x=0;
+               }
+               if (x>=dim[0])
+               {
+                       x=dim[0]-1;
+               }
+               _x=x;*/
+               img->GetExtent(ext);
+               if (x < ext[0])
+               {
+                       x=ext[0];
+               }
+               if (x > ext[1])
+               {
+                       x=ext[1];
+               }
+               _x=x;
        }
-       if (x>=dim[0])
-       {
-               x=dim[0]-1;
-       };
-       _x=x;
 }
 //-------------------------------------------------------------------
+/**
+**     Calculates the value of the slider and the layer in the image that is spouse to show
+**/
 void vtkMPRBaseData::SetY(double y)
 {
-       int dim[3];
-       _marImageData->GetImageData()->GetDimensions(dim);
-       if (y<0)
-       {
-               y=0;
+       //int dim[3];
+       int ext[6];
+       vtkImageData* img = _marImageData->GetImageData();
+       if(img!=NULL){
+               /*img->GetDimensions(dim);
+               if (y<0)
+               {
+                       y=0;
+               }
+               if (y>=dim[1])
+               {
+                       y=dim[1]-1;
+               }
+               _y=y;*/
+               img->GetExtent(ext);
+               if (y<ext[2])
+               {
+                       y=ext[2];
+               }
+               if (y > ext[3])
+               {
+                       y=ext[3];
+               }
+               _y=y;
        }
-       if (y>=dim[1])
-       {
-               y=dim[1]-1;
-       };
-       _y=y;
 }
 //-------------------------------------------------------------------
 vtkTransform *vtkMPRBaseData::GetTransformOrientation()
-{
+{      
        return _transformOrientation; 
 }
 //-------------------------------------------------------------------
@@ -226,6 +283,18 @@ vtkMPR3DDataViewer::vtkMPR3DDataViewer()
        _visiblePosition[1]=false;
        _visiblePosition[2]=false;
        _ctfun = NULL;
+       _vtkmprbasedata=NULL;
+
+       _ctfun=NULL;
+       _saggitalColors=NULL;
+       _saggital=NULL;
+       _axialColors=NULL;
+       _axial=NULL;
+       _coronalColors=NULL;
+       _coronal=NULL;
+       _mapOutline=NULL;
+       _outline=NULL;
+       _outlineData=NULL;
 }
 //-------------------------------------------------------------------
 vtkMPR3DDataViewer::~vtkMPR3DDataViewer()
@@ -272,7 +341,7 @@ void vtkMPR3DDataViewer::Refresh()
        int x = (int)(_vtkmprbasedata->GetX());
        int y = (int)(_vtkmprbasedata->GetY());
        int z = (int)(_vtkmprbasedata->GetZ());
-
+       std::cout<<" vtkMPR3DDataViewer::Refresh() x="<<x<<" y= "<<y<<" z= "<<z;
        SetPositionX( x );
        SetPositionY( y );
        SetPositionZ( z );
@@ -350,25 +419,28 @@ void vtkMPR3DDataViewer::Configure()
        _vtkmprbasedata->GetImageData()->GetScalarRange(range);
        double max = range[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);
@@ -376,7 +448,10 @@ void vtkMPR3DDataViewer::Configure()
        _ctFunVectorBlue.push_back(0.0);
 
 
-       _ctfun = vtkColorTransferFunction::New();
+       if(_ctfun==NULL){
+               _ctfun = vtkColorTransferFunction::New();
+       }
+       _ctfun->RemoveAllPoints();
 
        int i,size=_ctFunVectorPoint.size();
        for (i=0;i<size;i++)
@@ -390,7 +465,7 @@ void vtkMPR3DDataViewer::Configure()
        _ctfun->AddRGBPoint( 300 ,0 ,1,0);
        _ctfun->AddRGBPoint( 400 ,0 ,0,1);
 */
-       void *p=this;
+//     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
@@ -400,45 +475,92 @@ void vtkMPR3DDataViewer::Configure()
   // 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.
-       _saggitalColors = vtkImageMapToColors::New();
+       
+       if(_saggitalColors==NULL){
+               _saggitalColors = vtkImageMapToColors::New();
+       }
+       _saggitalColors->RemoveAllInputs();
+       
     _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() );
 //    _saggitalColors->SetLookupTable(_bwLut);
+       
     _saggitalColors->SetLookupTable(_ctfun);
-       _saggital = vtkImageActor::New();
-    _saggital->SetInput(_saggitalColors->GetOutput());
+
+       
+
+       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.
-       _axialColors = vtkImageMapToColors::New();
+
+       
+       if(_axialColors==NULL){
+               _axialColors = vtkImageMapToColors::New();
+       }
+
+       _axialColors->RemoveAllInputs();
     _axialColors->SetInput( _vtkmprbasedata->GetImageData() );
 //    _axialColors->SetLookupTable(_hueLut);
     _axialColors->SetLookupTable(_ctfun);
-       _axial = vtkImageActor::New();
-    _axial->SetInput(_axialColors->GetOutput());
+
+       if(_axial==NULL){
+               _axial = vtkImageActor::New();
+               _axial->SetInput(_axialColors->GetOutput());
+       }
+       
+       //_axialColors->Update();
+    
 
        // Create the third (coronal) plane of the three planes. We use 
   // the same approach as before except that the extent differs.
-       _coronalColors = vtkImageMapToColors::New();
+       if(_coronalColors==NULL){
+               _coronalColors = vtkImageMapToColors::New();
+       }
+       _coronalColors->RemoveAllInputs();
     _coronalColors->SetInput( _vtkmprbasedata->GetImageData() );
 //    _coronalColors->SetLookupTable(_satLut);
     _coronalColors->SetLookupTable(_ctfun);
-       _coronal = vtkImageActor::New();
-    _coronal->SetInput(_coronalColors->GetOutput());
+
+       if(_coronal==NULL){
+               _coronal = vtkImageActor::New();
+               _coronal->SetInput(_coronalColors->GetOutput());
+       }
+       
+    
 
   // An outline provides context around the data.
   //
-       _outlineData = vtkOutlineFilter::New();
+       if(_outlineData==NULL){
+               _outlineData = vtkOutlineFilter::New();
+       }
+       _outlineData->RemoveAllInputs();
     _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
-       _mapOutline = vtkPolyDataMapper::New();
-    _mapOutline->SetInput(_outlineData->GetOutput());
-       _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);
+       }
+       
+    
 
        int ext[6];
        _vtkmprbasedata->GetImageData()->GetExtent(ext);
 
+       
 
 
 }