]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx
no message
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkMPR2DView.cxx
index b5279649f1df3dd5de6860d4c7c225bdc0d33018..247113eba042eaa7eca7d54e038665e6b4c17cf8 100644 (file)
@@ -42,13 +42,6 @@ vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata()
 //-------------------------------------------------------------------
 void wxVtkMPR2DView::Configure(){
        wxVtk2DBaseView::Configure();
-
-       if(_interactorstylemprview==NULL)       
-       {
-               _interactorstylemprview = new vtkInteractorStyleMPRView();
-               ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstylemprview );
-       }
-       
        
 
        int x1,x2,y1,y2,z1,z2;
@@ -56,6 +49,12 @@ void wxVtkMPR2DView::Configure(){
 
        double spc[3];
        vtkImageData* img =  GetVtkmprbasedata()->GetImageData();
+       if(_interactorstylemprview==NULL)       
+       {
+               _interactorstylemprview = new vtkInteractorStyleMPRView();
+               ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstylemprview );
+       }
+       
        if(img!=NULL){
                double* origin = img->GetOrigin();
                img->GetExtent(x1,x2,y1,y2,z1,z2);
@@ -75,6 +74,9 @@ void wxVtkMPR2DView::Configure(){
                z2 = (int)(z2*spc[2]);
 
                _visibleAxis = true;
+               
+               
+               
        }
        
        // Axe A
@@ -95,8 +97,6 @@ void wxVtkMPR2DView::Configure(){
                _lineAMapper->SetInput(_pdA);
                _lineAMapper->ImmediateModeRenderingOn();
                _lineAActor->SetMapper(_lineAMapper);
-               
-               _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
        }       
        
        vtkCellArray *linesA = vtkCellArray::New();
@@ -108,10 +108,6 @@ void wxVtkMPR2DView::Configure(){
        linesA->Delete();  //do not delete lines ??
 //             _lineAActor->GetProperty()->BackfaceCullingOn();
        
-       
-
-
-       
 
 // Axe B
        if(_lineBActor==NULL){
@@ -127,8 +123,6 @@ void wxVtkMPR2DView::Configure(){
                _ptsB->SetPoint(1,  1000        ,  1000 ,  1000 );
                
 //             _lineBActor->GetProperty()->BackfaceCullingOn();
-               
-               _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
        }
        
        vtkCellArray *linesB;
@@ -146,56 +140,60 @@ void wxVtkMPR2DView::Configure(){
        _lineBMapper->ImmediateModeRenderingOn();
 
 
-       vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
-       
-//EED 17Avril2009
-/*             
-       if (_direction==0) {
-               camera->SetViewUp               (   0   ,    -1         ,     0         );
-               camera->SetPosition             ( -10000,(y1+y2)/2      , (z1+z2)/2     ); 
-               camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
-               camera->SetParallelScale( (z2-z1)/3.0 );
-       }
+       if(_imageViewer2XYZ){
+               _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
+               _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
+               vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
+               
+       //EED 17Avril2009
+       /*              
+               if (_direction==0) {
+                       camera->SetViewUp               (   0   ,    -1         ,     0         );
+                       camera->SetPosition             ( -10000,(y1+y2)/2      , (z1+z2)/2     ); 
+                       camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
+                       camera->SetParallelScale( (z2-z1)/3.0 );
+               }
 
-       if (_direction==1) { 
-               camera->SetViewUp               (       0               ,       0       ,       -1              );
-               camera->SetPosition             ((x1+x2)/2      , 10000 , (z1+z2)/2     ); 
-               camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
-               camera->SetParallelScale( (x2-x1)/3.0 );
-       }
+               if (_direction==1) { 
+                       camera->SetViewUp               (       0               ,       0       ,       -1              );
+                       camera->SetPosition             ((x1+x2)/2      , 10000 , (z1+z2)/2     ); 
+                       camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
+                       camera->SetParallelScale( (x2-x1)/3.0 );
+               }
 
-       if (_direction==2) { 
-               camera->SetViewUp               (       0               ,       -1              ,       0       );
-               camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     , -10000); 
-               camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       ); 
-               camera->SetParallelScale( (x2-x1)/3.0 );
-       }
-*/
+               if (_direction==2) { 
+                       camera->SetViewUp               (       0               ,       -1              ,       0       );
+                       camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     , -10000); 
+                       camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       ); 
+                       camera->SetParallelScale( (x2-x1)/3.0 );
+               }
+       */
 
-       if (_direction==0) {    // YZ
-               camera->SetViewUp               (   0   ,     1         ,     0         );
-               camera->SetPosition             (  10000,(y1+y2)/2      , (z1+z2)/2     ); 
-               camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
-               camera->SetParallelScale( (z2-z1)/3.0 );
-       }
-       
-       if (_direction==1) {    // XZ
-               camera->SetViewUp               (       0               ,       0       ,       -1              );
-               camera->SetPosition             ((x1+x2)/2      , 10000 , (z1+z2)/2     ); 
-               camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
-               camera->SetParallelScale( (x2-x1)/3.0 );
-       }
-       
-       if (_direction==2) {    // XY
-               camera->SetViewUp               (       0               ,       1               ,       0       );
-               camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     ,  10000); 
-               camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       ); 
-               camera->SetParallelScale( (x2-x1)/3.0 );
-       }
-       
+               if (_direction==0) {    // YZ
+                       camera->SetViewUp               (   0   ,     1         ,     0         );
+                       camera->SetPosition             (  10000,(y1+y2)/2      , (z1+z2)/2     ); 
+                       camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
+                       camera->SetParallelScale( (z2-z1)/3.0 );
+               }
+               
+               if (_direction==1) {    // XZ
+                       camera->SetViewUp               (       0               ,       0       ,       -1              );
+                       camera->SetPosition             ((x1+x2)/2      , 10000 , (z1+z2)/2     ); 
+                       camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
+                       camera->SetParallelScale( (x2-x1)/3.0 );
+               }
+               
+               if (_direction==2) {    // XY
+                       camera->SetViewUp               (       0               ,       1               ,       0       );
+                       camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     ,  10000); 
+                       camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       ); 
+                       camera->SetParallelScale( (x2-x1)/3.0 );
+               }
+               
 
-//     _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
-//     _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
+       //      _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
+       //      _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
+       }
 
 }
 
@@ -267,22 +265,24 @@ void wxVtkMPR2DView::Refresh()
                if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
 
                        if (_direction==0) {    // YZ 
-                               _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) ); 
+                               if(_imageViewer2XYZ)
+                                       _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) ); 
                                _ptsA->SetPoint(0, x2, y1  , z );
                                _ptsA->SetPoint(1, x2, y2  , z );
                                _ptsB->SetPoint(0, x2, y   , z1);
                                _ptsB->SetPoint(1, x2, y   , z2);
                        }
                        if (_direction==1) {    // XZ
-                               _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) ); 
+                               if(_imageViewer2XYZ)
+                                       _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) ); 
                            _ptsA->SetPoint(0, x1 , y2 , z );
                                _ptsA->SetPoint(1, x2 , y2 , z );
                                _ptsB->SetPoint(0, x  , y2 , z1);
                                _ptsB->SetPoint(1, x  , y2 , z2);
                        }
                        if (_direction==2) {    // XY
-                               _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) ); 
-                               _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) ); 
+                               if(_imageViewer2XYZ)
+                                       _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) ); 
                        //      _ptsA->SetPoint(0, x1 , y , -z2 );
                        //      _ptsA->SetPoint(1, x2 , y , -z2 );
                        //      _ptsB->SetPoint(0, x  , y1, -z2 );