]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
2108 Bug Volume Rendering widget options are not stable
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / LayerImageBase.cxx
index ee8a7fc05c54faee672f02d9ba9ce1a757f41369..d340e7f71f0ff5c13a83bad8da12ac0e03b7796a 100644 (file)
@@ -1,3 +1,27 @@
+/*# ---------------------------------------------------------------------
+#
+# 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.
+# ------------------------------------------------------------------------ */
 
 /**
  *  \file
 
 #include "LayerImageBase.h"
 
+
+//---------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------
+
+ColorLayerImageBasevtkInteractor::ColorLayerImageBasevtkInteractor(LayerImageBase* layerImageBase)
+{
+    _layerImageBase=layerImageBase;
+}
+
+//---------------------------------------------------------------------------------------------
+ColorLayerImageBasevtkInteractor::~ColorLayerImageBasevtkInteractor()
+{
+}
+
+
+//---------------------------------------------------------------------------------------------
+bool ColorLayerImageBasevtkInteractor::OnMouseMove()
+{
+       printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove \n");
+    if  (_vtkInteractorStyleBaseView->GetRefresh_waiting()==true)
+    {
+        _layerImageBase->GetvtkImageReslice()->Modified();
+    }
+
+    return true;
+}
+
+
+//---------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------
+
+
+
 LayerImageBase::LayerImageBase()
 {
        _actorPresent                   =       false;
-       _Z                                              =       0;
+       _Z                              =       0;
        _thresholdTable                 =       NULL;
        _thresholdMapper                =       NULL;
        _thresholdActor                 =       NULL;
-       _image                                  =       NULL;
-       _baseView               =   NULL;
+       _image                          =       NULL;
+       _baseView                       =       NULL;
        _imageReslicer                  =       vtkImageReslice::New();
 
 }
@@ -59,7 +118,14 @@ void LayerImageBase::SetImage(vtkImageData* image)
 //----------------------------------------------------------------------------
 void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview)
 {
+       printf("EED LayerImageBase::SetwxVtkBaseView start baseview:%p \n", baseview);
+
        _baseView = baseview;
+
+    vtkInteractorStyleBaseView *isbv    = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView());
+    isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) );
+       
+       printf("EED LayerImageBase::SetwxVtkBaseView end \n");
 }
 
 //----------------------------------------------------------------------------
@@ -71,6 +137,7 @@ wxVtkBaseView *LayerImageBase::GetwxVtkBaseView()
 //----------------------------------------------------------------------------
 void LayerImageBase::Refresh()
 {
+    printf("EED LayerImageBase::Refresh\n");
     if (_baseView!=NULL)
     {
         _baseView->Refresh();
@@ -106,7 +173,9 @@ int LayerImageBase::CleanZ(int z)
 //----------------------------------------------------------------------------
 void LayerImageBase::onThreshold()
 {
-
+       
+       printf("EED LayerImageBase::onThreshold start \n");
+       
        if ((_image!=NULL) && (_baseView!=NULL))
        {
                int z=CleanZ( GetZ() );
@@ -129,7 +198,7 @@ void LayerImageBase::onThreshold()
                                _thresholdActor = vtkImageActor::New( );
                                _thresholdActor->SetOpacity( 0.6 );
                                _thresholdActor->InterpolateOn(  );
-                               _thresholdActor->SetPosition( 0,0, 900-1 );
+                               _thresholdActor->SetPosition( 0,0, -900-1 );
                        } // _thresholdActor
                        _baseView->GetRenderer()->AddActor( _thresholdActor );
                        _actorPresent = true;
@@ -140,7 +209,8 @@ void LayerImageBase::onThreshold()
                _imageReslicer->SetInformationInput( GetImage() );
                _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
                _imageReslicer->SetOutputDimensionality(2);
-               _imageReslicer->SetInterpolationModeToLinear();
+//             _imageReslicer->SetInterpolationModeToLinear();
+               _imageReslicer->SetInterpolationModeToNearestNeighbor();
                _imageReslicer->SetResliceAxesOrigin(0,0,z);
 
                vtkImageData *img = _imageReslicer->GetOutput();
@@ -150,7 +220,12 @@ void LayerImageBase::onThreshold()
                _thresholdMapper->SetInput( img );
                _thresholdMapper->SetLookupTable( _thresholdTable );
                _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+
+               printf("EED LayerImageBase::onThreshold working \n");
+               
+               
                } // _image
+       printf("EED LayerImageBase::onThreshold end");
 }
 
 
@@ -200,6 +275,16 @@ void LayerImageBase::onThresholdRemove()
        }
 }
 
+//----------------------------------------------------------------------------
+vtkLookupTable *LayerImageBase::GetvtkLookupTable()
+{
+    return _thresholdTable;
+}
+
+vtkImageReslice *LayerImageBase::GetvtkImageReslice()
+{
+    return _imageReslicer;
+}