]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx
#3162 creaMaracasVisu Bug New Normal - Threshold layer
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtk2DBaseView.cxx
index fe3b8513deaa5cf49f02c1d594f587ddf77d00b8..3879377f94e3ba33d93aae257bed0007e9f3e8e8 100644 (file)
@@ -1,8 +1,34 @@
+/*# ---------------------------------------------------------------------
+#
+# 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 "wxVtk2DBaseView.h"
 
 #include "vtkInfoTextImage.h"
 #include "vtkInteractorStyleBaseView2D.h"
 #include "vtkInfoTextImageInteractor.h"
+#include "vtkImageActor.h"
 
 
 wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent)
@@ -20,7 +46,6 @@ wxVtk2DBaseView::~wxVtk2DBaseView()
        {
           delete _vtkIinfoTextImage;
        }
-
        if (_imageViewer2XYZ!=NULL)
        {
           delete _imageViewer2XYZ;
@@ -35,19 +60,17 @@ void wxVtk2DBaseView::TransformCoordinate_spacing_ViewToModel(double &X,double &
 //     GetVtkBaseData()->GetImageData()->GetSpacing(spc);
 //JCP 04/08/10 W/O Image this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
        vtkImageData* image = this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput();
-       if(image){
+       if(image)
+       {
                image->GetSpacing(spc);
        }else{
                spc[0] = 1;
                spc[1] = 1;
                spc[2] = 1;
        }
-
-
        X = X / spc[0];
        Y = Y / spc[1];
        Z = Z / spc[2];
-
 }
 
 //-------------------------------------------------------------------
@@ -69,7 +92,6 @@ void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double &
        X=X*spc[0];
        Y=Y*spc[1];
        Z=Z*spc[2];
-
 }
 
 //-------------------------------------------------------------------
@@ -79,10 +101,10 @@ void wxVtk2DBaseView::ResetView()
        double spx = 0,spy = 0,spz = 0;
        int x1 = 1,x2 = 1,y1 = 1,y2 = 1,z1 = 1,z2 = 1;
        wxVtkBaseView::Configure();
-
        wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
        vtkImageData *imageData = GetVtkBaseData()->GetImageData();
-       if(imageData){
+       if(imageData)
+       {
                imageData->UpdateInformation();
                imageData->SetUpdateExtent( imageData->GetWholeExtent());
                imageData->Update();
@@ -90,8 +112,7 @@ void wxVtk2DBaseView::ResetView()
                imageData->GetSpacing (spx,spy,spz);
                imageData->GetExtent (x1,x2,y1,y2,z1,z2);
        }
-
-
+printf("//EED wxVtk2DBaseView::ResetView %d %d    %d %d     %d %d \n",x1,x2,y1,y2,z1,z2);
        _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
        _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
 
@@ -122,17 +143,21 @@ void wxVtk2DBaseView::ResetView()
 
 }
 
-
-
 //-------------------------------------------------------------------
 void wxVtk2DBaseView::SetImageToVtkViewer(vtkImageData *imageData)
 {
+       int ext[6];
+       imageData->Update();
+       imageData->GetWholeExtent(ext);
        if (_imageViewer2XYZ!=NULL)
        {
+               _imageViewer2XYZ->SetExtentDimension( ext[0],ext[1],ext[2],ext[3],ext[4],ext[5] );
                _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( imageData );
        } // if _imageViewer2XYZ
-}
 
+       GetRenderer()->GetActiveCamera()->SetClippingRange(0.01, 1000000);
+
+}
 
 //-------------------------------------------------------------------
 void wxVtk2DBaseView::Configure(bool okimage)
@@ -169,7 +194,6 @@ void wxVtk2DBaseView::Configure(bool okimage)
                //////////////
        }
 
-
        vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData();
        if (imageData!=NULL)
        {
@@ -206,11 +230,9 @@ void wxVtk2DBaseView::Configure(bool okimage)
 //_collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
 //_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel ()->SetLookupTable(_collookup );
 
-
 // EED 17 Oct 2007
 //                     SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
 
-
                        vtkImageViewer2 *IV2            =       _imageViewer2XYZ->GetVtkImageViewer2();
                        vtkCamera               *camera         =       IV2->GetRenderer()->GetActiveCamera();
 
@@ -218,7 +240,7 @@ void wxVtk2DBaseView::Configure(bool okimage)
 //EED 21 mars 2012     FLIP problem  ..PLOP..
                        
                        // XY
-                       camera->SetViewUp               ( spx*0                 , -spy*1                        , spz*0         );
+                       camera->SetViewUp               ( spx*0                 , -spy*1                , spz*0         );
                        camera->SetPosition             ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , -spz*10000    );
                        camera->SetFocalPoint   ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0         );
 /*
@@ -249,29 +271,15 @@ void wxVtk2DBaseView::Configure(bool okimage)
 
 //-------------------------------------------------------------------
 
-int    wxVtk2DBaseView::GetActualSlice()  // virtual
+int wxVtk2DBaseView::GetActualSlice()  // virtual
 {
-   return (int)(_vtkbasedata->GetZ());
+   return (int)(GetVtkBaseData()->GetZ());
 }
 
 //-------------------------------------------------------------------
 void wxVtk2DBaseView::SetActualSlice(int slice)  // Virtual
 {
-   _vtkbasedata->SetZ(slice);
-}
-
-//-------------------------------------------------------------------
-
-vtkBaseData *wxVtk2DBaseView::GetVtkBaseData()
-{
-   return _vtkbasedata;
-}
-
-//-------------------------------------------------------------------
-
-void wxVtk2DBaseView::SetVtkBaseData(vtkBaseData *vtkbasedata)
-{
-   _vtkbasedata=vtkbasedata;
+   GetVtkBaseData()->SetZ(slice);
 }
 
 //-------------------------------------------------------------------
@@ -282,14 +290,13 @@ void wxVtk2DBaseView::UpdateColorWindowLevel()
        
 //     vtkImageViewer2 *vtkimageviewer2        = _imageViewer2XYZ->GetVtkImageViewer2();               
        
-       
        vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel();
-       imagemaptowindowlevel->SetWindow( _vtkbasedata->GetColorWindow() );
-       imagemaptowindowlevel->SetLevel( _vtkbasedata->GetColorLevel() );
+       imagemaptowindowlevel->SetWindow( GetVtkBaseData()->GetColorWindow() );
+       imagemaptowindowlevel->SetLevel( GetVtkBaseData()->GetColorLevel() );
        
 // EED Borrame
-//     vtkimageviewer2->SetColorWindow( _vtkbasedata->GetColorWindow() );
-//     vtkimageviewer2->SetColorLevel(  _vtkbasedata->GetColorLevel() );
+//     vtkimageviewer2->SetColorWindow( GetVtkBaseData()->GetColorWindow() );
+//     vtkimageviewer2->SetColorLevel(  GetVtkBaseData()->GetColorLevel() );
        _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->Modified();
 }
 
@@ -298,6 +305,9 @@ void wxVtk2DBaseView::Refresh()
 {
        int z = (int)(GetVtkBaseData()->GetZ());
        _imageViewer2XYZ->SetZSlice( z );
+//EED 2016/02/19
+       vtkImageActor *imageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
+       imageactor->SetInterpolate( GetVtkBaseData()->GetInterpolate() );
        //EED 01nov2012
        UpdateColorWindowLevel();       
        wxVtkBaseView::Refresh();
@@ -307,12 +317,10 @@ void wxVtk2DBaseView::Refresh()
 void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview)
 {
        SetInteractorStyleBaseView(interactorstylebaseview);
-
        wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
        interactorstylebaseview->SetInteractor ( iren );
        iren->SetInteractorStyle(interactorstylebaseview);
        interactorstylebaseview->SetwxVtkBaseView(this);
-
        vtkMaracasImageViewer2Callback * cbk = vtkMaracasImageViewer2Callback::New();
        cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2();
        interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk );
@@ -361,7 +369,7 @@ void wxVtk2DBaseView::setColorTransferFunction(vtkColorTransferFunction* colorta
 void wxVtk2DBaseView::SetColorWindow(double level)
 {
 //     _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow(level);
-       _vtkbasedata->SetColorWindow(level);    
+       GetVtkBaseData()->SetColorWindow(level);        
        this->Refresh();
 }
 
@@ -369,7 +377,14 @@ void wxVtk2DBaseView::SetColorWindow(double level)
 void wxVtk2DBaseView::SetColorLevel(double level)
 {
 //     _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel(level);
-       _vtkbasedata->SetColorLevel(level);
+       GetVtkBaseData()->SetColorLevel(level);
+       this->Refresh();
+}
+
+//-------------------------------------------------------------------
+void wxVtk2DBaseView::SetInterpolate(bool iterpolate)
+{
+       GetVtkBaseData()->SetInterpolate( iterpolate );
        this->Refresh();
 }