]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkImageViewer2_XYZ.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkImageViewer2_XYZ.cxx
1 #include "vtkImageViewer2_XYZ.h"
2 #include "vtkRenderer.h"
3 #include "vtkImageActor.h"
4 //-------------------------------------------------------------------
5 //-------------------------------------------------------------------
6 //-------------------------------------------------------------------
7 vtkImageViewer2_XYZ::vtkImageViewer2_XYZ()
8 {
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 );  
13 }
14 //-------------------------------------------------------------------
15 vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
16 {
17         //_vtkimageviewer2->Delete();
18 }
19 //-------------------------------------------------------------------
20 void vtkImageViewer2_XYZ::SetExtentDimension(int x1,int x2,
21                                                                                          int y1,int y2,
22                                                                                          int z1,int z2)
23 {
24         _x1=x1;
25         _x2=x2;
26         _y1=y1;
27         _y2=y2;
28         _z1=z1;
29         _z2=z2;
30 }
31 //-------------------------------------------------------------------
32 void vtkImageViewer2_XYZ::SetXSlice(int slice)
33 {
34         vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
35         imageActor->SetDisplayExtent(slice, slice, _y1, _y2, _z1, _z2 );  
36 }
37 //-------------------------------------------------------------------
38 void vtkImageViewer2_XYZ::SetYSlice(int slice)
39 {
40         vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
41         imageActor->SetDisplayExtent(_x1, _x2, slice, slice, _z1, _z2 );  
42 }
43 //-------------------------------------------------------------------
44 void vtkImageViewer2_XYZ::SetZSlice(int slice)
45 {
46 #if (VTK_MAJOR_VERSION >= 5)
47 //              _vtkimageviewer2->SetSlice( slice );
48         vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
49         imageActor->SetDisplayExtent(_x1, _x2, _y1, _y2, slice, slice );  
50 #else
51                 _vtkimageviewer2->SetZSlice( slice );
52 #endif
53
54
55 }
56 //-------------------------------------------------------------------
57 int vtkImageViewer2_XYZ::GetXSlice()
58 {
59         vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
60         return imageActor->GetDisplayExtent()[0];
61 }
62 //-------------------------------------------------------------------
63 int vtkImageViewer2_XYZ::GetYSlice()
64 {
65         vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
66         return imageActor->GetDisplayExtent()[2];
67 }
68 //-------------------------------------------------------------------
69 int vtkImageViewer2_XYZ::GetZSlice()
70 {
71
72          int result;
73 #if (VTK_MAJOR_VERSION >= 5)
74                 result= _vtkimageviewer2->GetSlice( );
75 #else
76                 result= _vtkimageviewer2->GetZSlice( );
77 #endif
78
79         
80         return result;
81 }
82 //-------------------------------------------------------------------
83 vtkImageViewer2 *vtkImageViewer2_XYZ::GetVtkImageViewer2()
84 {
85         return _vtkimageviewer2;
86 }
87
88 void vtkImageViewer2_XYZ::setColorTransferFunction(vtkColorTransferFunction* colortable){
89
90         vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _vtkimageviewer2->GetWindowLevel();
91
92         if(colortable!=NULL&&colortable->GetSize()>0){
93                 imagemaptowindowlevel->SetLookupTable(colortable);
94         }
95
96 }