1 #include "vtkImageViewer2_XYZ.h"
2 #include "vtkRenderer.h"
3 #include "vtkImageActor.h"
4 //-------------------------------------------------------------------
5 //-------------------------------------------------------------------
6 //-------------------------------------------------------------------
7 vtkImageViewer2_XYZ::vtkImageViewer2_XYZ()
9 _vtkimageviewer2= vtkImageViewer2::New();
10 _vtkimageviewer2->GetRenderer()->GradientBackgroundOn();
11 _vtkimageviewer2->GetRenderer()->SetBackground( 0.33 , 0.33 , 0.33 );
12 _vtkimageviewer2->GetRenderer()->SetBackground2( 0.66 , 0.66 , 0.66 );
14 //-------------------------------------------------------------------
15 vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
17 //_vtkimageviewer2->Delete();
19 //-------------------------------------------------------------------
20 void vtkImageViewer2_XYZ::SetExtentDimension(int x1,int x2,
31 //-------------------------------------------------------------------
32 void vtkImageViewer2_XYZ::SetXSlice(int slice)
34 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
35 imageActor->SetDisplayExtent(slice, slice, _y1, _y2, _z1, _z2 );
37 //-------------------------------------------------------------------
38 void vtkImageViewer2_XYZ::SetYSlice(int slice)
40 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
41 imageActor->SetDisplayExtent(_x1, _x2, slice, slice, _z1, _z2 );
43 //-------------------------------------------------------------------
44 void vtkImageViewer2_XYZ::SetZSlice(int slice)
46 #if (VTK_MAJOR_VERSION >= 5)
47 // _vtkimageviewer2->SetSlice( slice );
48 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
49 imageActor->SetDisplayExtent(_x1, _x2, _y1, _y2, slice, slice );
51 _vtkimageviewer2->SetZSlice( slice );
56 //-------------------------------------------------------------------
57 int vtkImageViewer2_XYZ::GetXSlice()
59 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
60 return imageActor->GetDisplayExtent()[0];
62 //-------------------------------------------------------------------
63 int vtkImageViewer2_XYZ::GetYSlice()
65 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
66 return imageActor->GetDisplayExtent()[2];
68 //-------------------------------------------------------------------
69 int vtkImageViewer2_XYZ::GetZSlice()
73 #if (VTK_MAJOR_VERSION >= 5)
74 result= _vtkimageviewer2->GetSlice( );
76 result= _vtkimageviewer2->GetZSlice( );
82 //-------------------------------------------------------------------
83 vtkImageViewer2 *vtkImageViewer2_XYZ::GetVtkImageViewer2()
85 return _vtkimageviewer2;
88 void vtkImageViewer2_XYZ::setColorTransferFunction(vtkColorTransferFunction* colortable){
90 vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _vtkimageviewer2->GetWindowLevel();
92 if(colortable!=NULL&&colortable->GetSize()>0){
93 imagemaptowindowlevel->SetLookupTable(colortable);