+/*# ---------------------------------------------------------------------
+#
+# 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
- * \brief Class bbtk::ThresholdImageView .
+ * \file
+ * \brief Class bbtk::ThresholdImageView .
*/
#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;
+ _image = NULL;
+ _baseView = NULL;
_imageReslicer = vtkImageReslice::New();
}
}
//----------------------------------------------------------------------------
-int LayerImageBase::GetZ()
+int LayerImageBase::GetZ() // virtual
{
return _Z;
}
//----------------------------------------------------------------------------
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");
}
//----------------------------------------------------------------------------
return _baseView;
}
+//----------------------------------------------------------------------------
+void LayerImageBase::Refresh()
+{
+ printf("EED LayerImageBase::Refresh\n");
+ if (_baseView!=NULL)
+ {
+ _baseView->Refresh();
+ }
+}
//----------------------------------------------------------------------------
return _thresholdTable;
}
+//----------------------------------------------------------------------------
+int LayerImageBase::CleanZ(int z)
+{
+ int ext[6];
+ _image->GetWholeExtent(ext);
+ if (z<0)
+ {
+ z=0;
+ }
+
+ if ( z > (ext[5]-ext[4]) )
+ {
+ z=ext[5]-ext[4];
+ }
+
+ return z;
+}
//----------------------------------------------------------------------------
void LayerImageBase::onThreshold()
{
- int z = GetZ();
- if (!GetActorPresent())
- {
- if (_thresholdTable==NULL)
- {
- //Lookup Table
- _thresholdTable = vtkLookupTable::New();
- } // _thresholdTable
-
- if (_thresholdMapper==NULL)
- {
- _thresholdMapper = vtkImageMapToColors::New( );
- }
-
- if (_thresholdActor==NULL)
+ printf("EED LayerImageBase::onThreshold start \n");
+
+ if ((_image!=NULL) && (_baseView!=NULL))
+ {
+ int z=CleanZ( GetZ() );
+
+ if (!GetActorPresent())
{
- _thresholdActor = vtkImageActor::New( );
- _thresholdActor->SetOpacity( 0.6 );
- _thresholdActor->InterpolateOn( );
- _thresholdActor->SetPosition( 0,0, 900-1 );
- } // _thresholdActor
+ if (_thresholdTable==NULL)
+ {
+ //Lookup Table
+ _thresholdTable = vtkLookupTable::New();
+ } // _thresholdTable
+
+ if (_thresholdMapper==NULL)
+ {
+ _thresholdMapper = vtkImageMapToColors::New( );
+ }
+
+ if (_thresholdActor==NULL)
+ {
+ _thresholdActor = vtkImageActor::New( );
+ _thresholdActor->SetOpacity( 0.6 );
+ _thresholdActor->InterpolateOn( );
+ _thresholdActor->SetPosition( 0,0, -900-1 );
+ } // _thresholdActor
+ _baseView->GetRenderer()->AddActor( _thresholdActor );
+ _actorPresent = true;
+ } // !GetActorPresent()
+
+ ConfigLookupTable(); // virtual method
+ _imageReslicer->SetInput( GetImage() );
+ _imageReslicer->SetInformationInput( GetImage() );
+ _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+ _imageReslicer->SetOutputDimensionality(2);
+// _imageReslicer->SetInterpolationModeToLinear();
+ _imageReslicer->SetInterpolationModeToNearestNeighbor();
+ _imageReslicer->SetResliceAxesOrigin(0,0,z);
+
+ vtkImageData *img = _imageReslicer->GetOutput();
+// img->Update();
+// img->UpdateInformation();
+
+ _thresholdMapper->SetInput( img );
+ _thresholdMapper->SetLookupTable( _thresholdTable );
+ _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+
+ printf("EED LayerImageBase::onThreshold working \n");
- _baseView->GetRenderer()->AddActor( _thresholdActor );
- _actorPresent = true;
- } // !GetActorPresent()
-
- ConfigLookupTable(); // virtual method
- _imageReslicer->SetInput( GetImage() );
- _imageReslicer->SetInformationInput( GetImage() );
- _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- _imageReslicer->SetOutputDimensionality(2);
- _imageReslicer->SetInterpolationModeToLinear();
- _imageReslicer->SetResliceAxesOrigin(0,0,z);
-
- vtkImageData *img = _imageReslicer->GetOutput();
- img->Update();
- img->UpdateInformation();
-
- _thresholdMapper->SetInput( img );
- _thresholdMapper->SetLookupTable( _thresholdTable );
- _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+ } // _image
+ printf("EED LayerImageBase::onThreshold end");
}
else
{
_thresholdActor->InterpolateOff( );
- }
+ }
}
}
wxVtkBaseView * baseView = _baseView;
baseView->GetRenderer()->RemoveActor( _thresholdActor );
_actorPresent = false;
- }
+ }
}
+//----------------------------------------------------------------------------
+vtkLookupTable *LayerImageBase::GetvtkLookupTable()
+{
+ return _thresholdTable;
+}
+
+vtkImageReslice *LayerImageBase::GetvtkImageReslice()
+{
+ return _imageReslicer;
+}