]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkMPR3DView.cxx
index 72acc37357cecda89316bb71e61249e69fda0da9..32994c7743cd664add4ba747482f79d945312227 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 #include "wxVtkMPR3DView.h"
 
 #include "vtkDataSetMapper.h"
 #include "vtkInteractorStyleBaseView.h"
 #include <vtkImageReslice.h>
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
 
 
 //----------------------------------------------------------------------------
@@ -31,7 +52,7 @@ class vtkWindowLevelImagePlaneWidgetCallback : public vtkCommand
         public:
           static vtkWindowLevelImagePlaneWidgetCallback *New()
           { 
-                  return new vtkWindowLevelImagePlaneWidgetCallback; 
+                  return new vtkWindowLevelImagePlaneWidgetCallback;
           }
        
           void Execute( vtkObject *caller, unsigned long ev, void *callData )
@@ -59,19 +80,15 @@ class vtkWindowLevelImagePlaneWidgetCallback : public vtkCommand
                                   _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY(xyzv[1]);
                                   _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ(xyzv[2]);
                           } else {
-                                  
-                                  
                                   vtkImageData *image = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
                                   double spc[3];
                                   if(image)
                                   {
                                           image->GetSpacing(spc);
                                   }
-                                  
                                   double normal[3];
                                   slicePosition = ipw->GetSlicePosition();
                                   ipw->GetNormal(normal);
-                                  
                                   // FreePlaneX
                                   if ((normal[0]==1)&&(normal[1]==0)&&(normal[2]==0))
                                   {
@@ -89,28 +106,20 @@ class vtkWindowLevelImagePlaneWidgetCallback : public vtkCommand
                                   }
                           }// ipw->GetCursorDataStatus
                   }// ev
-                       
                   if (needRefresh)     
                   {
                           vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
                           isbv->SetParent_refresh_waiting();
                           isbv->EvaluateToRefresh();
                   }
-                       
           } // Execute
-       
                vtkWindowLevelImagePlaneWidgetCallback(){}
                wxVtkMPR3DView *_wxvtkmpr3Dview;
 };
 
-
-
 //-------------------------------------------------------------------
 //-------------------------------------------------------------------
 //-------------------------------------------------------------------
-
-
-
 wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
 {
        _wxvtk3Dbaseview                        =       wxvtk3Dbaseview;
@@ -122,7 +131,6 @@ wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
        _vtkplane                                       =       NULL;
        _probe                                          =       NULL;
        _contourMapper                          =       NULL;
-
        _planeWidgetX                           =       NULL;
        _planeWidgetY                           =       NULL;
        _planeWidgetZ                           =       NULL;
@@ -130,27 +138,26 @@ wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
        //Free Planes
 }
 
-
 //-------------------------------------------------------------------
 wxVtkMPR3DView::~wxVtkMPR3DView()
 {
        VisiblePointWidget( false );
-       VisiblePlaneWidget( false );
-
-       if(_pointWidget!=NULL){
+//     VisiblePlaneWidget( false );
+       if(_pointWidget!=NULL)
+       {
                _pointWidget->Delete();
        }
-       if(_planeWidget!=NULL){
+       if(_planeWidget!=NULL)
+       {
                _planeWidget->Delete();
        }
-
-       if(_vtkplane!=NULL){
+       if(_vtkplane!=NULL)
+       {
                _vtkplane->Delete();
                _probe->Delete();
                _contourMapper->Delete();
                _contourPlaneActor->Delete();
        }
-
 }
 
 //-------------------------------------------------------------------
@@ -158,154 +165,93 @@ void wxVtkMPR3DView::RemoveActor(vtkActor* actor)
 {
        _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
 }
-
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc)
-{
-       if(ext == NULL){
-               _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
-               _wxvtk3Dbaseview->GetCamera()->Dolly(2.0);
-               
-//EED 21 mars 2012  FLIP probleme  ..PLOP..
-               _wxvtk3Dbaseview->GetCamera()->Roll(180);
-               _wxvtk3Dbaseview->GetCamera()->Yaw(180+30);
-               _wxvtk3Dbaseview->GetCamera()->Pitch(-22);
-               
-       }else{
-               
-               /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
-               double y = (spc[1])*(origin[1]+(double)ext[3]);
-               double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/
-               /*double x0=(spc[0])*((double)ext[0]+origin[0]);
-               double x1=(spc[0])*((double)ext[1]+origin[0]);
-               double y0=(spc[1])*((double)ext[2]+origin[1]);
-               double y1=(spc[1])*((double)ext[3]+origin[1]);
-               double z0=(spc[2])*((double)ext[4]+origin[2]);
-               double z1=(spc[2])*((double)ext[5]+origin[2]);*/
-               
-               double x0=(spc[0])*((double)ext[0]);
-               double x1=(spc[0])*((double)ext[1]);
-               double y0=(spc[1])*((double)ext[2]);
-               double y1=(spc[1])*((double)ext[3]);
-               double z0=(spc[2])*((double)ext[4]);
-               double z1=(spc[2])*((double)ext[5]);
-
-               _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1);
-               //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z);
-               _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
-               
-       }
-       
-}
-
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::Configure()
 {
        vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-
        _wxvtk3Dbaseview->Configure();
        _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
-
-//EED 27 Mai 2009
-//     _wxvtk3Dbaseview->GetRenderer()->Clear();
-
        // Actors are added to the renderer.
        vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
        _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
-//     _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0)  );    // _saggital
-//     _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1)  );    // _axial
-//     _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2)  );    // _coronal
-
-
-       // An initial camera view is created.  The Dolly() method moves
-       // the camera towards the FocalPoint, thereby enlarging the image.
-       _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
-       this->ResetCamera();
-
-
-       // Set a background color for the renderer and set the size of the
-       // render window (expressed in pixels).
-       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
-//EED 23oct2010        _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
-
-       // Note that when camera movement occurs (as it does in the Dolly()
-       // method), the clipping planes often need adjusting. Clipping planes
-       // consist of two planes: near and far along the view direction. The
-       // near plane clips out objects in front of the plane; the far plane
-       // clips out objects behind the plane. This way only what is drawn
-       // between the planes is actually rendered.
-       _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
-
-
-       // vtkPointWidget
-       //if(_myCallback!=NULL){
-               //_myCallback->Delete();
 
-       //}
        vtkmyPWCallback_3DPointWidget *_myCallback = vtkmyPWCallback_3DPointWidget::New();
        _myCallback->SetWxVtkMPR3DView(this);
-
-
        if(imageData){
-               if(_pointWidget==NULL){
+               if(_pointWidget==NULL)
+               {
                        _pointWidget = vtkPointWidget::New();
                }
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                _pointWidget->SetInput( imageData );
+#else
+               _pointWidget->SetInputData( imageData );
+#endif
                _myCallback->SetVtkPointWidget(_pointWidget);
                _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
                _pointWidget->AllOff();
                _pointWidget->PlaceWidget();
-
                _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
-
                if(_planeWidget==NULL)
                {
                        _planeWidget = vtkPlaneWidget::New();
                }
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                _planeWidget->SetInput( imageData );
+#else
+               _planeWidget->SetInputData( imageData );
+#endif
 
                _myCallback->SetVtkPlaneWidget(_planeWidget);
-
                _planeWidget->NormalToXAxisOn();
                _planeWidget->SetResolution(50);
                _planeWidget->SetRepresentationToOutline();
-
                int dim[3];
-
                imageData->GetDimensions(dim);
                int px=(dim[0]/2);
                int py=(dim[1]/2);
                int pz=(dim[2]/2);
                int dd=20;
                _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
+               if(_vtkplane==NULL)
+               {
+                       _vtkplane               = vtkPolyData::New();
+                       _probe                  = vtkProbeFilter::New();
+                       _contourMapper  = vtkPolyDataMapper::New();
 
-               if(_vtkplane==NULL){
-                       _vtkplane = vtkPolyData::New();
-
-                       _probe = vtkProbeFilter::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                        _probe->SetInput(_vtkplane);
-
-                       _contourMapper = vtkPolyDataMapper::New();
-
                        _contourMapper->SetInput( _probe->GetPolyDataOutput() );
+#else
+                       _myCallback->SetVtkPolyData(_vtkplane);
+                       _myCallback->SetVtkProbeFilter(_probe);
+                       _planeWidget->GetPolyData(_vtkplane);
+                       _probe->SetInputData(_vtkplane);
+                       _probe->SetSourceData(imageData);
+//                     _probe->Update();
+                       _contourMapper->SetInputData( _probe->GetPolyDataOutput() );
+#endif
 
                        _contourPlaneActor = vtkActor::New();
                        _contourPlaneActor->SetMapper(_contourMapper);
-
                        _contourPlaneActor->VisibilityOff();
-
                        _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
                        _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
-
                        _planeWidget->Off();
                        _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
-
                }
-
                _planeWidget->GetPolyData(_vtkplane);
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                _probe->SetSource( imageData );
+#else
+               _probe->SetSourceData( imageData );
+#endif
                _contourMapper->SetScalarRange( imageData->GetScalarRange() );
-
        ConfigureFreePlanes();
        }
 
@@ -317,25 +263,44 @@ void wxVtkMPR3DView::Configure()
 
 // PlaneWidget
 
+
+// An initial camera view is created.  The Dolly() method moves
+       // the camera towards the FocalPoint, thereby enlarging the image.
+//     _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
+
+       // Note that when camera movement occurs (as it does in the Dolly()
+       // method), the clipping planes often need adjusting. Clipping planes
+       // consist of two planes: near and far along the view direction. The
+       // near plane clips out objects in front of the plane; the far plane
+       // clips out objects behind the plane. This way only what is drawn
+       // between the planes is actually rendered.
+
+//EED 27/05/2013
+//     _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
+
+//EED 27/05/2013
+//      this->ResetCamera();
+       _wxvtk3Dbaseview->ResetCamera();
+
+       // Set a background color for the renderer and set the size of the
+       // render window (expressed in pixels).
+       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
+//EED 23oct2010        _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
 }
 
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::ConfigureFreePlanes()
 {
-
        // The shared picker enables us to use 3 planes at one time
        // and gets the picking order right
        vtkCellPicker* picker = vtkCellPicker::New();
        picker->SetTolerance(0.005);
-
        // The 3 image plane widgets
        _planeWidgetX = GetPlaneWidget('x', 1, 0, 0, picker);
        _planeWidgetY = GetPlaneWidget('y', 1, 1, 0, picker);
        _planeWidgetZ = GetPlaneWidget('z', 0, 0, 1, picker);
-
        _planeWidgetY->SetLookupTable(_planeWidgetX->GetLookupTable());
        _planeWidgetZ->SetLookupTable(_planeWidgetX->GetLookupTable());
-
        picker->UnRegister(NULL);
 
        // ColorWindow ColorLevel Callback
@@ -351,12 +316,60 @@ void wxVtkMPR3DView::ConfigureFreePlanes()
        _planeWidgetZ->AddObserver(vtkCommand::InteractionEvent, wlipwc );      
 }
 
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::SetImage()
+{
+       vtkImageData *imageData                                 = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+       // Orthogonal planes B&W
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+       _planeWidgetX->SetInput( imageData );
+       _planeWidgetY->SetInput( imageData );
+       _planeWidgetZ->SetInput( imageData );
+       // -- Plane widget
+       _probe->SetSource( imageData );
+#else
+
+
+       double colorWindow      = _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorWindow();
+       double colorLevel       = _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorLevel();
+
+       double spc[3];
+       vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+       if(image)
+       {
+               image->GetSpacing(spc);
+       }else{
+               spc[0] = 0;
+               spc[1] = 0;
+               spc[2] = 0;
+       }
+       double x = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
+       double y = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
+       double z = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
+
+       _planeWidgetX->SetInputData( imageData );
+       _planeWidgetX->SetWindowLevel(colorWindow,colorLevel,1);
+       _planeWidgetX->SetSlicePosition( x*spc[0] );
+       _planeWidgetY->SetInputData( imageData );
+       _planeWidgetY->SetWindowLevel(colorWindow,colorLevel,1);
+       _planeWidgetY->SetSlicePosition( y*spc[1] );
+       _planeWidgetZ->SetInputData( imageData );
+       _planeWidgetZ->SetWindowLevel(colorWindow,colorLevel,1);
+       _planeWidgetZ->SetSlicePosition( z*spc[2] );
+
+       // -- Plane widget
+       _probe->SetSourceData( imageData );
+#endif
+       _vtkmpr3Ddataviewer->SetImage();
+}
+
 //-------------------------------------------------------------------
 vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker)
 {
-       vtkProperty* prop1                                      = 0;
-       vtkImagePlaneWidget* planeWidget        = 0;
-       planeWidget                                                     = vtkImagePlaneWidget::New();
+       vtkProperty* prop1                                      = NULL;
+       vtkImagePlaneWidget* planeWidget        = vtkImagePlaneWidget::New();
        planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
        planeWidget->EnabledOff();
        vtkImageData *image                                     = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
@@ -364,7 +377,13 @@ vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey,
        double xSpacing = 0, ySpacing = 0, zSpacing = 0;
        if(image)
        {
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                planeWidget->SetInput( image );
+#else
+               planeWidget->SetInputData( image );
+#endif
                image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
                image->GetSpacing(xSpacing, ySpacing, zSpacing);
        }
@@ -411,13 +430,44 @@ void wxVtkMPR3DView::FreePlaneVisible(int plane, bool ok)
 {
        if(_planeWidgetX)
        {
-               if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
-               if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
-               if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
+       if (ok==true)
+        {
+//EED 21/07/2013
+//                     1. Make backup of actors
+//                     2. Putting out all the actors
+//                     3. Add vtkImagageActor in first place
+//                     4. Putting again the originals actors
+//                     5. Refresh
+
+                       // step 1, step 2
+               vtkActorCollection *tmpCollection    = vtkActorCollection::New();
+                       vtkActorCollection *collectionActors =  _wxvtk3Dbaseview->GetRenderer()->GetActors();
+               int i,size=collectionActors->GetNumberOfItems();
+                       for (i=0; i<size; i++)
+                       {
+                               tmpCollection->AddItem ( (vtkActor*)collectionActors->GetItemAsObject(0)  );                    
+                               _wxvtk3Dbaseview->GetRenderer()->RemoveActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+
+                       // step 3
+                       if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
+                       if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
+                       if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
+
+                       // step 4
+                        for (i=0; i<size; i++)
+                       {
+                               _wxvtk3Dbaseview->GetRenderer()->AddActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+                       tmpCollection->Delete();
+
+                       // step 5 Refresh
+                       _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render();
+        } // if ok
                if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff();
                if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff();
                if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff();
-       }
+       } // if  _planeWidgetX
 }
 
 //-------------------------------------------------------------------
@@ -435,7 +485,7 @@ void wxVtkMPR3DView::FreePlaneInteraction(bool ok)
                        _planeWidgetY->InteractionOff();
                        _planeWidgetZ->InteractionOff();
                }
-       } // if _planeWidgetX
+       } // if _planeWidgetXVisiblePointWidget
 }
 
 
@@ -449,12 +499,11 @@ void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortab
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::Refresh()   // virtual
 {
-       _vtkmpr3Ddataviewer     ->      Refresh();
+       _vtkmpr3Ddataviewer->Refresh();
        if (_wxvtkmpr3DviewCntrlPanel!=NULL)
        {
                _wxvtkmpr3DviewCntrlPanel->Refresh();
        }
-
 }
 
 //-------------------------------------------------------------------
@@ -462,25 +511,21 @@ void wxVtkMPR3DView::RefreshView()   // virtual
 {
        double spc[3];
        vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
-
-       if(image){
+       if(image)
+       {
                image->GetSpacing(spc);
        }else{
                spc[0] = 0;
                spc[1] = 0;
                spc[2] = 0;
        }
-       //this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
+//     GetVtkMPR3DDataViewer()->Configure();
 
        //double nx=1,ny=0,nz=0; // JPRx
        Refresh();
-       double x=GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
-       double y=GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
-       double z=GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
-
-       SetColorWindow( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorWindow() );
-       SetColorLevel( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorLevel() );
-
+       double x = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
+       double y = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
+       double z = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
 
        double normal[3];
        // FreePlaneX
@@ -488,25 +533,44 @@ void wxVtkMPR3DView::RefreshView()   // virtual
        if ((normal[0]==1)&&(normal[1]==0)&&(normal[2]==0))
        {
                _planeWidgetX->SetSlicePosition( x*spc[0] );
+//EED 2016/02/19
+//             _planeWidgetX->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
+               _planeWidgetX->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
        }
        // FreePlaneY
        _planeWidgetY->GetNormal(normal);
        if ((normal[0]==0)&&(normal[1]==1)&&(normal[2]==0))
        {
                _planeWidgetY->SetSlicePosition( y*spc[1] );
+//EED 2016/02/19
+               _planeWidgetY->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
+               _planeWidgetY->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
        }
        // FreePlaneZ
        _planeWidgetZ->GetNormal(normal);
        if ((normal[0]==0)&&(normal[1]==0)&&(normal[2]==1))
        {
                _planeWidgetZ->SetSlicePosition( z*spc[2] );
+//EED 2016/02/19
+               _planeWidgetZ->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
+               _planeWidgetZ->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() );
        }
-               
-       x=x*spc[0];
-       y=y*spc[1];
-       z=z*spc[2];
 
-       if(_pointWidget){
+       SetWindowColorLevel(_vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorWindow() , _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorLevel() );
+
+       x = x*spc[0];
+       y = y*spc[1];
+       z = z*spc[2];
+       if(_pointWidget)
+       {
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               _pointWidget->SetInput( image );
+#else
+               _pointWidget->SetInputData( image );
+#endif
+               _pointWidget->PlaceWidget();
+
                _pointWidget->SetPosition( x,y,z );
                double in[3];
                double normal[3];
@@ -517,7 +581,18 @@ void wxVtkMPR3DView::RefreshView()   // virtual
                _planeWidget->SetCenter( x,y,z );
                _planeWidget->UpdatePlacement();
                _planeWidget->GetPolyData(_vtkplane);
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               // ..
+#else
+               _probe->Update();
+#endif
        }
+
+       if (_wxvtkmpr3DviewCntrlPanel!=NULL)
+       {
+               _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel(false);
+       } // if _wxvtkmpr3DviewCntrlPanel
 }
 
 //-------------------------------------------------------------------
@@ -534,7 +609,8 @@ vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
 //-------------------------------------------------------------------
 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
 {
-       if(_wxvtk3Dbaseview==NULL){
+       if(_wxvtk3Dbaseview==NULL)
+       {
                throw "wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
        }
        return _wxvtk3Dbaseview;
@@ -542,7 +618,8 @@ wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
 //-------------------------------------------------------------------
 
 //-------------------------------------------------------------------
-void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
+void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible)
+{
        /*if(visible == false)
                printf("CPR: wxVtkMPR3DView::VisibleImageActor-> visibleActor == false \n");
        else
@@ -552,13 +629,43 @@ void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
        }
        */
        if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
-               if (visible==false){
+               if (visible==false)
+               {
                        _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition)  );
                } else {
+//EED 21/07/2013
+//                     1. Make backup of actors
+//                     2. Putting out all the actors
+//                     3. Add vtkImagageActor in first place
+//                     4. Putting again the originals actors
+//                     5. Refresh
+
+//EED 4 nov 2015  (For Estelle)
+// This works in ViewerNV with nTymeView=6
+// Because the others modules (5) generate also more actors with an OutLineFilter -> Actor
+//showOutlineActor(false);
+                       // step 1, step 2
+                       vtkActorCollection *tmpCollection    = vtkActorCollection::New();
+                       vtkActorCollection *collectionActors =  _wxvtk3Dbaseview->GetRenderer()->GetActors();
+                       int i,size=collectionActors->GetNumberOfItems();
+                       for (i=0; i<size; i++)
+                       {
+                               tmpCollection->AddItem ( (vtkActor*)collectionActors->GetItemAsObject(0)  );                    
+                               _wxvtk3Dbaseview->GetRenderer()->RemoveActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+                       // step 3
                        _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition)  );
-               }
+                       // step 4
+                        for (i=0; i<size; i++)
+                       {
+                               _wxvtk3Dbaseview->GetRenderer()->AddActor( (vtkProp*)tmpCollection->GetItemAsObject(i) );
+                       } // for
+                       tmpCollection->Delete();
+                       // step 5 Refresh
+                       _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render();
+               } // if visible
                _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
-       }
+       } // if visible 
 }
 
 
@@ -571,8 +678,8 @@ void wxVtkMPR3DView::VisiblePointWidget( bool visible )
                        _pointWidget->On();
                } else {
                        _pointWidget->Off();
-               }
-       }
+               } // visible
+       } // _pointWidget
 }
 
 //-------------------------------------------------------------------
@@ -583,12 +690,12 @@ void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
                {
                        _planeWidget->On();
                        _contourPlaneActor->VisibilityOn();
-
                } else {
                        _planeWidget->Off();
-                       _contourPlaneActor->VisibilityOff();
-               }
-       }
+                       _contourPlaneActor->VisibilityOff();                    
+               } // if visible
+               _wxvtk3Dbaseview->GetRenderer()->GetRenderWindow()->Render();
+       } // _planeWidget
 }
 
 //CPR: Method added 30 Nov 2009
@@ -598,11 +705,9 @@ void wxVtkMPR3DView::showOutlineActor(bool value)
        if(value == true)
        {
                _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
-       }
-       else
-       {
+       } else {
                _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _outlineActor );
-       }
+       } // value
 }
 
 //-------------------------------------------------------------------
@@ -618,18 +723,13 @@ void wxVtkMPR3DView::InitOrientationPointWidget()
 }
 
 //-------------------------------------------------------------------
-void wxVtkMPR3DView::SetColorWindow(double colorWindow)
+void wxVtkMPR3DView::SetWindowColorLevel(double colorWindow , double colorLevel)
 {
-       double colorLevel = _planeWidgetX->GetLevel();
        _planeWidgetX->SetWindowLevel(colorWindow,colorLevel);
+       _planeWidgetY->SetWindowLevel(colorWindow,colorLevel);
+       _planeWidgetZ->SetWindowLevel(colorWindow,colorLevel);
 }
 
-//-------------------------------------------------------------------
-void wxVtkMPR3DView::SetColorLevel(double colorLevel)
-{
-       double colorWindow = _planeWidgetX->GetWindow();
-       _planeWidgetX->SetWindowLevel(colorWindow,colorLevel);
-}
 
 //-------------------------------------------------------------------
 // EED 25 Janvier 2007 testLoic
@@ -644,7 +744,12 @@ void wxVtkMPR3DView::TestLoic1()
        double spc[3];
        vtkimagedata->GetSpacing(spc);
 
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        vtkimagedata->Update();
+#else
+       // ..
+#endif
 
 
         double p[3], n[3];
@@ -664,20 +769,41 @@ void wxVtkMPR3DView::TestLoic1()
     pSource->Update( );
 
     vtkProbeFilter* slices = vtkProbeFilter::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     slices->SetInput( ( vtkDataSet* )pSource->GetOutput( ) );
     slices->SetSource( vtkimagedata );
     slices->Update( );
     pSource->Delete( );
+#else
+    slices->SetInputData( ( vtkDataSet* )pSource->GetOutput( ) );
+    slices->SetSourceData( vtkimagedata );
+#endif
 
        vtkStructuredPoints   *stPoints = vtkStructuredPoints::New();
        stPoints -> GetPointData( )->SetScalars(  slices->GetOutput()->GetPointData()->GetScalars()  );
        stPoints -> SetDimensions( sizeIma, sizeIma, 1 );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        stPoints -> SetScalarType( vtkimagedata->GetScalarType() );
        stPoints -> SetScalarTypeToShort();
        stPoints -> Update();
+#else
+       vtkInformation* info=stPoints->GetInformation();
+       vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_SHORT, 1);
+#endif
+
+
 
        vtkImageChangeInformation  *change = vtkImageChangeInformation ::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        change    -> SetInput( stPoints );
+#else
+       change    -> SetInputData( stPoints );
+#endif
        change    -> Update();    //important
 
        double _range[2];
@@ -701,7 +827,12 @@ void wxVtkMPR3DView::TestLoic1()
 
 
        vtkMetaImageWriter *writer = vtkMetaImageWriter::New( );
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        writer->SetInput( stPoints );
+#else
+       writer->SetInputData( stPoints );
+#endif
        writer->SetFileName( "C:/Users/Images/temp_EED/image.mhd" );
        writer->SetFileDimensionality( 2 );
        writer->Write( );
@@ -709,7 +840,14 @@ void wxVtkMPR3DView::TestLoic1()
 
 
        vtkDataSetMapper *_3DSliceMapper = vtkDataSetMapper::New( );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _3DSliceMapper->SetInput(change->GetOutput( ) );
+#else
+       _3DSliceMapper->SetInputData(change->GetOutput( ) );
+#endif
+
        _3DSliceMapper->SetLookupTable( _bwlookup );
        _3DSliceMapper->SetScalarRange( _range );
        _3DSliceMapper->ImmediateModeRenderingOn( );
@@ -760,18 +898,26 @@ void wxVtkMPR3DView::TestLoic2()
         vtkPlane *slicePlane = vtkPlane::New();
                                this->_planeWidget->GetPlane( slicePlane );
 
-
         vtkCutter* sliceCutter = vtkCutter::New();
                vtkImageData *vtkimagedata =  this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                 sliceCutter->SetInput( vtkimagedata );
+#else
+                sliceCutter->SetInputData( vtkimagedata );
+#endif
                 sliceCutter->SetCutFunction( slicePlane );
 
 //EED
 //        vtkLookupTable *lut = BuildHueWeightBaseMap();
 
-
         vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
-                slice->SetInput( sliceCutter->GetOutput() );
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               slice->SetInput( sliceCutter->GetOutput() );
+#else
+               slice->SetInputData( sliceCutter->GetOutput() );
+#endif
         double range[2];
 // EED
 //                slice->Update();
@@ -785,16 +931,20 @@ void wxVtkMPR3DView::TestLoic2()
 //                sliceActor->SetMapper( slice );
 
         vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                 contourMapper->SetInput( sliceCutter->GetOutput() );
+#else
+                contourMapper->SetInputData( sliceCutter->GetOutput() );
+#endif
+
                 contourMapper->SetScalarRange( range );
   //              contourMapper->SetLookupTable( lut );
 
-
         vtkActor *contourActor = vtkActor::New();
                 contourActor->SetMapper( contourMapper );
 
-
-
  // The usual rendering stuff.
   vtkCamera *camera = vtkCamera::New();
       camera->SetPosition(1,1,1);
@@ -820,5 +970,25 @@ void wxVtkMPR3DView::TestLoic2()
   iren->Start();
 }
 
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::SetBackGroundType(int type)
+{
+       if (_wxvtk3Dbaseview!=NULL)
+       {
+               if (type==0)
+               {
+                       _wxvtk3Dbaseview->GetRenderer()->GradientBackgroundOff();
+                       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0 , 0 , 0 );
+               } // if type
+               if (type==1)
+               {
+                       _wxvtk3Dbaseview->GetRenderer()->GradientBackgroundOn();
+                       _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.33 , 0.33 , 0.33 );
+                       _wxvtk3Dbaseview->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
+               } // if type
+               _wxvtk3Dbaseview->Refresh();
+       }// if _wxvtk3Dbaseview
+       
+}