X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FKernel%2FVTKObjects%2FViewerWidgets%2Fimageplanewidget.cxx;h=3e044e99c19a4e7343687ef8938eb4e5625807f5;hb=HEAD;hp=4e81652ff7f21402b8702a03c4864e9d62917965;hpb=962d2237c57a96d4a644da68b967abbbe1288840;p=creaMaracasVisu.git diff --git a/lib/Kernel/VTKObjects/ViewerWidgets/imageplanewidget.cxx b/lib/Kernel/VTKObjects/ViewerWidgets/imageplanewidget.cxx index 4e81652..3e044e9 100644 --- a/lib/Kernel/VTKObjects/ViewerWidgets/imageplanewidget.cxx +++ b/lib/Kernel/VTKObjects/ViewerWidgets/imageplanewidget.cxx @@ -1,14 +1,53 @@ +/*# --------------------------------------------------------------------- +# +# 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 "imageplanewidget.h" +#include "vtkSmartPointer.h" +#include "vector" +#include "vtkImageActor.h" +#include "vtkImageAppendComponents.h" +#include "vtkRenderWindowInteractor.h" +#include "vtkTextProperty.h" + +using namespace std; + ImagePlaneWidget::ImagePlaneWidget() { _img = 0; _xwidget = 0; _ywidget = 0; _zwidget = 0; + m_Interactor = 0; + _imageactorx = 0; + _imageactory = 0; + _imageactorz = 0; } void ImagePlaneWidget::initialize(vtkRenderWindowInteractor* interactor){ + m_Interactor = interactor; // Plane widget _xwidget = vtkImagePlaneWidget::New( ); _ywidget = vtkImagePlaneWidget::New( ); @@ -18,8 +57,49 @@ void ImagePlaneWidget::initialize(vtkRenderWindowInteractor* interactor){ _xwidget->SetInteractor( interactor ); _ywidget->SetInteractor( interactor ); _zwidget->SetInteractor( interactor ); + +} +bool ImagePlaneWidget::showImageActors(bool show){ + if(show && m_Interactor){ + if(!_imageactorx){ + initializeImageActors(); + } + m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactorx); + m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactory); + m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->AddViewProp(_imageactorz); + return true; + }else if(_imageactorx){ + m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactorx); + m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactory); + m_Interactor->GetRenderWindow ()->GetRenderers ()->GetFirstRenderer ()->RemoveViewProp(_imageactorz); + return true; + } + + return false; } +void ImagePlaneWidget::initializeImageActors(){ + + int *w_ext = _img->GetWholeExtent(); + //cout<SetInput(_img); + xslice = (w_ext[4] + w_ext[5])/2; + _imageactorx->SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], xslice, xslice); + + + _imageactory = vtkImageActor::New(); + _imageactory->SetInput(_img); + yslice = (w_ext[2] + w_ext[3])/2; + _imageactory->SetDisplayExtent(w_ext[0], w_ext[1], yslice, yslice, w_ext[4], w_ext[5]); + + _imageactorz = vtkImageActor::New(); + _imageactorz->SetInput(_img); + zslice = (w_ext[0] + w_ext[1])/2; + _imageactorz->SetDisplayExtent(zslice, zslice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]); + + +} void ImagePlaneWidget::setImage(vtkImageData* img){ _img = img; @@ -35,29 +115,31 @@ void ImagePlaneWidget::setImage(vtkImageData* img){ _xwidget->SetInput( _img ); _xwidget->SetPlaneOrientationToXAxes( ); _xwidget->SetSliceIndex( sliceX ); - //_xwidget->TextureInterpolateOff(); + _xwidget->TextureInterpolateOff(); _xwidget->SetResliceInterpolateToLinear(); _xwidget->On( ); _xwidget->DisplayTextOn(); - + _xwidget->GetTextProperty()->SetColor(0.3, 0.3, 0.3); _ywidget->Off( ); _ywidget->SetInput( _img ); _ywidget->SetPlaneOrientationToYAxes( ); _ywidget->SetSliceIndex( sliceY ); - //_ywidget->TextureInterpolateOff(); + _ywidget->TextureInterpolateOff(); _ywidget->SetResliceInterpolateToLinear(); _ywidget->DisplayTextOn(); + _ywidget->GetTextProperty()->SetColor(0.3, 0.3, 0.3); _ywidget->On( ); _zwidget->Off( ); _zwidget->SetInput( _img ); _zwidget->SetPlaneOrientationToZAxes( ); _zwidget->SetSliceIndex( sliceZ ); - //_zwidget->TextureInterpolateOff(); + _zwidget->TextureInterpolateOff(); _zwidget->SetResliceInterpolateToLinear(); _zwidget->DisplayTextOn(); - _zwidget->On( ); + _zwidget->On( ); + _zwidget->GetTextProperty()->SetColor(0.3, 0.3, 0.3); } void ImagePlaneWidget::SetLookupTable(vtkLookupTable *lookuptable){ @@ -93,3 +175,23 @@ void ImagePlaneWidget::invariant(){ throw "The widgets are not initialized"; } } + + +void ImagePlaneWidget::setSliceXImageActor(int value){ + int *w_ext = _img->GetWholeExtent(); + xslice = value; + _imageactorx->SetDisplayExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], xslice, xslice); + m_Interactor->Render(); +} +void ImagePlaneWidget::setSliceYImageActor(int value){ + int *w_ext = _img->GetWholeExtent(); + yslice = value; + _imageactory->SetDisplayExtent(w_ext[0], w_ext[1], yslice, yslice, w_ext[4], w_ext[5]); + m_Interactor->Render(); +} +void ImagePlaneWidget::setSliceZImageActor(int value){ + int *w_ext = _img->GetWholeExtent(); + zslice = value; + _imageactorz->SetDisplayExtent(zslice, zslice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]); + m_Interactor->Render(); +}