X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FvtkPlane2DView.cxx;h=3c715ae038aa09f20939c2d2a435b0050d3a7a76;hb=25e3adf442d6a8d357d52410267445c54426c525;hp=86e8fa3a02486d6b0a2f3391b1a079f5403be945;hpb=a4ee3758aa0477f677fb981e2c4d6e29995e8db8;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx index 86e8fa3..3c715ae 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx @@ -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 "vtkPlane2DView.h" #include "vtkCellArray.h" @@ -37,24 +62,22 @@ vtkPlane2DView::vtkPlane2DView( wxWindow *parent) _imageResult = NULL; // line horizontal - _pts = NULL; - _lineActor = NULL; - _lineMapper = NULL; - _pd = NULL; + _pts = NULL; + _lineActor = NULL; + _lineMapper = NULL; + _pd = NULL; - _interactorstyleplane2D = false; + _interactorstyleplane2D = NULL; } //------------------------------------------------------------------- vtkPlane2DView::~vtkPlane2DView() { ResetPlane(); - // Horizontal Line if (_pts != NULL) { _pts -> Delete(); } if (_lineActor != NULL) { _lineActor -> Delete(); } if (_lineMapper != NULL) { _lineMapper -> Delete(); } if (_pd != NULL) { _pd -> Delete(); } - _transform1 -> Delete(); _transform2 -> Delete(); } @@ -72,12 +95,14 @@ void vtkPlane2DView::ResetBack() } //------------------------------------------------------------------- -void vtkPlane2DView::ResetPlane(){ +void vtkPlane2DView::ResetPlane() +{ if (_pSource !=NULL) { _pSource -> Delete(); } if (_3Dslices !=NULL) { _3Dslices -> Delete(); } if (_stPoints !=NULL) { _stPoints -> Delete(); } if (_change !=NULL) { _change -> Delete(); } } + //------------------------------------------------------------------- vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata() { @@ -133,7 +158,6 @@ void vtkPlane2DView::SetPSource(int sizeIma){ //------------------------------------------------------------------- void vtkPlane2DView::ExtractPlane() { - double x = GetVtkmprbasedata()->GetX(); double y = GetVtkmprbasedata()->GetY(); double z = GetVtkmprbasedata()->GetZ(); @@ -198,48 +222,66 @@ void vtkPlane2DView::ExtractPlane() } //------------------------------------------------------------------- - void vtkPlane2DView::Extract_One_PlaneVTK() { vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData(); SetPSource(_sizeIma); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) ); _3Dslices -> SetSource( imagedata ); +#else + _3Dslices -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) ); + _3Dslices -> SetSourceData( imagedata ); +#endif + _3Dslices -> Update( ); _stPoints -> GetPointData( )->SetScalars( _3Dslices->GetOutput()->GetPointData()->GetScalars() ); _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _stPoints -> SetScalarType( imagedata->GetScalarType() ); _stPoints -> SetScalarTypeToShort(); _stPoints -> Update(); // _change -> SetInput( _stPoints ); // _change -> Update(); //important _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints ); +#else +printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n"); +printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n"); +printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n"); +printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n"); +printf("EED Warning! vtkPlane2DView::Extract_One_PlaneVTK VTK 5->7 ???? SetScalarTypeToShort \n"); + vtkInformation* info=_stPoints->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_SHORT, 1); + _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _stPoints ); + +#endif + + // _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() ); // vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor(); } //------------------------------------------------------------------- - void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) { - int mipWidth; double sp; int sizeWidth = (_mip_width*2)+1 ; int deltaPixel; int iWidth,itmp,tmpSizeWith; - double spc[3]; vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData(); SetPSource(_sizeIma); imagedata->GetSpacing(spc); - bool heightDefinition=false; if (_mip_width<3) { heightDefinition=true; } - if (heightDefinition==true) { mipWidth = _mip_width; @@ -252,49 +294,50 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) sizeWidth = tmpSizeWith; deltaPixel = 4; } - - - std::vector< vtkProbeFilter* > slicesLST; - _pSource->Push( -mipWidth * sp ); _pSource->Update(); - for ( iWidth=0 ; iWidth SetInput( ( vtkDataSet* )_pSource->GetOutput( ) ); slice -> SetSource( imagedata ); +#else + slice -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) ); + slice -> SetSourceData( imagedata ); +#endif slice -> Update( ); slicesLST.push_back( slice ); _pSource->Push( sp ); } - if (_imageResult ==NULL) { _imageResult = vtkImageData::New(); _imageResult -> SetDimensions(_sizeIma,_sizeIma,1); _imageResult -> SetSpacing(1,1,1); - _imageResult -> SetScalarType( imagedata->GetScalarType() ); _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + _imageResult -> SetScalarType( imagedata->GetScalarType() ); _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0); _imageResult -> AllocateScalars(); _imageResult -> Update(); - } +#else + _imageResult -> AllocateScalars(imagedata->GetScalarType(),1); +#endif + } unsigned short *pTemp; unsigned short *pResult; pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); - int iPixels , sizePixels = _sizeIma*_sizeIma; for(iPixels=0 ; iPixelsGetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0); - pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); pResult[iPixels] = pTemp[iPixels]; - for (iWidth=1;iWidthGetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0); @@ -304,7 +347,6 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) pResult[iPixels] = pTemp[iPixels]; } } - if (deltaPixel!=1) { for (itmp=1;itmpDelete(); } - _imageResult->Modified(); - _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult ); - +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( _imageResult ); +#else + _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _imageResult ); +#endif } //------------------------------------------------------------------- @@ -339,12 +382,27 @@ void vtkPlane2DView::Configure( ) _stPoints = vtkStructuredPoints::New( ); _change = vtkImageChangeInformation::New(); - wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); + crea::wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); ExtractPlane(); // SetActive(false); _imageViewer2XYZ -> GetVtkImageViewer2() -> SetupInteractor ( iren ); - SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() ); + ////////////// + //RaC 04-2010 Look for the description of new changes in vtkInteractorStyleBaseView2D constructor. + // + // Previous version + // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() ); + // + // Actual version + vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New(); + manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel(); + style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel ); + vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ(); + style2D->SetInteractorScrollZ(_vtkInteractorScrollZ); + SetInteractorStyleImage( style2D ); + + // RaC + ////////////// _interactorstyleplane2D = new vtkInteractorStylePlane2D(); ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstyleplane2D ); @@ -367,8 +425,6 @@ void vtkPlane2DView::Configure( ) _vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage); _vtkInfoTextImage->Configure(); ((vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView())->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D); - - } //------------------------------------------------------------------- @@ -389,7 +445,12 @@ void vtkPlane2DView::HorizontalLine() lines->Delete(); //do not delete lines ?? _lineActor = vtkActor::New(); _lineMapper = vtkPolyDataMapper::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _lineMapper->SetInput(_pd); +#else + _lineMapper->SetInputData(_pd); +#endif _lineMapper->ImmediateModeRenderingOn(); _lineActor->SetMapper(_lineMapper); _lineActor->GetProperty()->BackfaceCullingOn(); @@ -406,6 +467,7 @@ void vtkPlane2DView::RotationStart() vtkTransform *transform = mprbasedata->GetTransformOrientation(); _transform1->SetMatrix( transform->GetMatrix() ); } + //------------------------------------------------------------------- void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang) { @@ -439,6 +501,7 @@ void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang) void vtkPlane2DView::Refresh( ) { ExtractPlane(); + UpdateColorWindowLevel(); wxVtkBaseView::Refresh(); } //------------------------------------------------------------------- @@ -518,19 +581,16 @@ void vtkPlane2DView::SetVisibleLine(bool ok) } _lineActor->GetProperty()->SetOpacity(opacity); } + // ---------------------------------------------------------------------------- -void vtkPlane2DView::TransfromeCoordViewWorld2(double &X, double &Y, double &Z) +void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z) { double spc[3]; GetVtkmprbasedata()->GetImageData()->GetSpacing(spc); - double xx = X; double yy = Y; double zz = 0; - - TransfromeCoordScreenToWorld(xx,yy,zz); - - + TransFromCoordScreenToWorld(xx,yy,zz); vtkTransform *transf1 = vtkTransform::New(); transf1->Identity(); vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation(); @@ -541,12 +601,10 @@ void vtkPlane2DView::TransfromeCoordViewWorld2(double &X, double &Y, double &Z) in[1] = xx - center; in[2] = yy - center; in[3] = 0; - transf1->MultiplyPoint(in,out); transf1->Delete(); - X = out[0] + GetVtkmprbasedata()->GetX() ; Y = out[1] + GetVtkmprbasedata()->GetY() ; Z = out[2] + GetVtkmprbasedata()->GetZ() ; +} -} \ No newline at end of file