X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxVtk2DBaseView.cxx;h=941b3ef3ae0d5f7c1e9e1d190d80e4bf3bbe33fa;hb=659bcd2c2a608cfb8c5854ffe84e9248871df9a1;hp=af726f120d87331ddc6485ca6667e6d5a1f072c9;hpb=69c806e632999e11e12e8626609f4192d3aec364;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx index af726f1..941b3ef 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx @@ -31,8 +31,8 @@ #include "vtkImageActor.h" -wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent) -:wxVtkBaseView(parent) +wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent,bool TDxWindow) +:wxVtkBaseView(parent,TDxWindow) { _imageViewer2XYZ = NULL; _vtkIinfoTextImage = NULL; @@ -97,18 +97,22 @@ void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double & //------------------------------------------------------------------- void wxVtk2DBaseView::ResetView() { - printf("EED 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(); + crea::wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); vtkImageData *imageData = GetVtkBaseData()->GetImageData(); if(imageData) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imageData->UpdateInformation(); imageData->SetUpdateExtent( imageData->GetWholeExtent()); imageData->Update(); _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData ); +#else + _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData(imageData ); +#endif imageData->GetSpacing (spx,spy,spz); imageData->GetExtent (x1,x2,y1,y2,z1,z2); } @@ -118,7 +122,7 @@ void wxVtk2DBaseView::ResetView() //EED 24oct2010 _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->Modified(); - _imageViewer2XYZ->GetVtkImageViewer2()->Render(); +//EED2120-06-23 _imageViewer2XYZ->GetVtkImageViewer2()->Render(); ////////////// //RaC 04-2010 Look for the description of new changes in vtkInteractorStyleBaseView2D constructor. @@ -135,22 +139,29 @@ void wxVtk2DBaseView::ResetView() vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ(); style2D->SetInteractorScrollZ(_vtkInteractorScrollZ); - SetInteractorStyleImage( style2D ); - - // RaC - ////////////// + vtkInteractorZoomCamera *_vtkInteractorZoomCamera = new vtkInteractorZoomCamera(); + style2D->SetInteractorZoomCamera(_vtkInteractorZoomCamera); + SetInteractorStyleImage( style2D ); } //------------------------------------------------------------------- void wxVtk2DBaseView::SetImageToVtkViewer(vtkImageData *imageData) { int ext[6]; - imageData->GetWholeExtent(ext); - _imageViewer2XYZ->SetExtentDimension( ext[0],ext[1],ext[2],ext[3],ext[4],ext[5] ); if (_imageViewer2XYZ!=NULL) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + imageData->Update(); + imageData->GetWholeExtent(ext); + _imageViewer2XYZ->SetExtentDimension( ext[0],ext[1],ext[2],ext[3],ext[4],ext[5] ); _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( imageData ); +#else + imageData->GetExtent(ext); + _imageViewer2XYZ->SetExtentDimension( ext[0],ext[1],ext[2],ext[3],ext[4],ext[5] ); + _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( imageData ); +#endif } // if _imageViewer2XYZ GetRenderer()->GetActiveCamera()->SetClippingRange(0.01, 1000000); @@ -168,7 +179,7 @@ void wxVtk2DBaseView::Configure(bool okimage) if (_imageViewer2XYZ==NULL) { _imageViewer2XYZ = new vtkImageViewer2_XYZ(); - wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); + crea::wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren ); ////////////// @@ -186,6 +197,9 @@ void wxVtk2DBaseView::Configure(bool okimage) vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ(); style2D->SetInteractorScrollZ(_vtkInteractorScrollZ); + vtkInteractorZoomCamera *_vtkInteractorZoomCamera = new vtkInteractorZoomCamera(); + style2D->SetInteractorZoomCamera(_vtkInteractorZoomCamera); + SetInteractorStyleImage( style2D ); // RaC @@ -195,9 +209,16 @@ void wxVtk2DBaseView::Configure(bool okimage) vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData(); if (imageData!=NULL) { + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imageData->UpdateInformation(); imageData->SetUpdateExtent( imageData->GetWholeExtent()); imageData->Update(); +#else + //... +#endif + if (okimage==true){ imageData->GetSpacing (spx,spy,spz); imageData->GetExtent (x1,x2,y1,y2,z1,z2); @@ -250,7 +271,10 @@ void wxVtk2DBaseView::Configure(bool okimage) camera->SetClippingRange( 0.01 , 1000000 ); camera->ComputeViewPlaneNormal(); - camera->SetParallelScale( spx*(x2-x1)/3.0 ); + + double cameraparallelScale=spx*(x2-x1)/3.0; + camera->SetParallelScale( cameraparallelScale ); + GetVtkBaseData()->SetCameraParallelScale( cameraparallelScale ); // text information over the graphic window if(_vtkIinfoTextImage == NULL){ @@ -286,18 +310,19 @@ void wxVtk2DBaseView::UpdateColorWindowLevel() //EED 24oct2010 //EED 02nov2012 -// vtkImageViewer2 *vtkimageviewer2 = _imageViewer2XYZ->GetVtkImageViewer2(); - vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel(); imagemaptowindowlevel->SetWindow( GetVtkBaseData()->GetColorWindow() ); imagemaptowindowlevel->SetLevel( GetVtkBaseData()->GetColorLevel() ); - -// EED Borrame -// vtkimageviewer2->SetColorWindow( GetVtkBaseData()->GetColorWindow() ); -// vtkimageviewer2->SetColorLevel( GetVtkBaseData()->GetColorLevel() ); _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->Modified(); } +//------------------------------------------------------------------- +void wxVtk2DBaseView::UpdateCameraParallelScale() +{ + vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera(); + camera->SetParallelScale( GetVtkBaseData()->GetCameraParallelScale() ); +} + //------------------------------------------------------------------- void wxVtk2DBaseView::Refresh() { @@ -308,6 +333,7 @@ void wxVtk2DBaseView::Refresh() imageactor->SetInterpolate( GetVtkBaseData()->GetInterpolate() ); //EED 01nov2012 UpdateColorWindowLevel(); + UpdateCameraParallelScale(); wxVtkBaseView::Refresh(); } @@ -315,7 +341,7 @@ void wxVtk2DBaseView::Refresh() void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview) { SetInteractorStyleBaseView(interactorstylebaseview); - wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); + crea::wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); interactorstylebaseview->SetInteractor ( iren ); iren->SetInteractorStyle(interactorstylebaseview); interactorstylebaseview->SetwxVtkBaseView(this); @@ -379,9 +405,50 @@ void wxVtk2DBaseView::SetColorLevel(double level) this->Refresh(); } +//------------------------------------------------------------------- +void wxVtk2DBaseView::SetInterpolate(bool iterpolate) +{ + GetVtkBaseData()->SetInterpolate( iterpolate ); + this->Refresh(); +} + //------------------------------------------------------------------- int wxVtk2DBaseView::GetDirection() // virtual { return 2; } +//------------------------------------------------------------------- +void wxVtk2DBaseView::GetNormal(double normal[3] ) // virtual +{ + if (GetDirection()==0 ) + { + normal[0]=1; + normal[1]=0; + normal[2]=0; + } // if + if (GetDirection()==1 ) + { + normal[0]=0; + normal[1]=1; + normal[2]=0; + } // if + if (GetDirection()==2 ) + { + normal[0]=0; + normal[1]=0; + normal[2]=1; + } // if +} + + +//------------------------------------------------------------------- +void wxVtk2DBaseView::SetOpacityText(double opacity) +{ + if (_vtkIinfoTextImage!=NULL) + { + _vtkIinfoTextImage->SetOpacity( opacity ); + } +} + +