]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
changes in viewers, now is possible to initialize them with out an image but the...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMPRBaseData.cxx
index 9ec150285bf768281eb8bf1911601030e3b22724..e1b7c370dec6bffd60f649ef9622cb86dc43fd17 100644 (file)
@@ -27,6 +27,12 @@ vtkMPRBaseData::vtkMPRBaseData()
   _x=0;
   _y=0;
   _z=0;
+  _x1 = 0;
+  _x2 = 0;
+  _y1 = 0;
+  _y2 = 0;
+  _z1 = 0;
+  _z2 = 0;
   _transformOrientation = NULL;
   _marImageData = NULL;
 }
@@ -43,11 +49,12 @@ void vtkMPRBaseData::Configure()
        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();
+               
+       }
+       if(_transformOrientation==NULL){
+               _transformOrientation=vtkTransform::New();
        }
+       _transformOrientation->Identity();
 }
 //-------------------------------------------------------------------
 void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2)
@@ -95,7 +102,7 @@ void vtkMPRBaseData::SetX(double x)
 {
        //int dim[3];
        int ext[6];
-
+       double* origin;
        vtkImageData* img = _marImageData->GetImageData();
        if(img!=NULL){
                /*img->GetDimensions(dim);
@@ -109,14 +116,16 @@ void vtkMPRBaseData::SetX(double x)
                }
                _x=x;*/
                img->GetExtent(ext);
+               origin = img->GetOrigin();
                if (x < ext[0])
                {
-                       x=ext[0];
+                       x=ext[0] + origin[0];
                }
                if (x > ext[1])
                {
-                       x=ext[1];
+                       x=ext[1] + origin[0];
                }
+               
                _x=x;
        }
 }
@@ -128,6 +137,7 @@ void vtkMPRBaseData::SetY(double y)
 {
        //int dim[3];
        int ext[6];
+       double* origin;
        vtkImageData* img = _marImageData->GetImageData();
        if(img!=NULL){
                /*img->GetDimensions(dim);
@@ -141,13 +151,14 @@ void vtkMPRBaseData::SetY(double y)
                }
                _y=y;*/
                img->GetExtent(ext);
+               origin = img->GetOrigin();
                if (y<ext[2])
                {
-                       y=ext[2];
+                       y=ext[2] + origin[1];
                }
                if (y > ext[3])
                {
-                       y=ext[3];
+                       y=ext[3] + origin[1];
                }
                _y=y;
        }