]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageActor.cxx
Start contour tracer widget debugging: change interactor style.
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageActor.cxx
1 #include <cpExtensions/Visualization/ImageActor.h>
2 #include <cpExtensions/Visualization/ImageSliceMapper.h>
3
4 #include <vtkImageData.h>
5
6 // -------------------------------------------------------------------------
7 void cpExtensions::Visualization::ImageActor::
8 Modified( )
9 {
10   if( this->m_Mapper->GetNumberOfInputConnections( 0 ) > 0 )
11   {
12     this->m_Mapper->Modified( );
13     this->m_Mapper->Update( );
14     this->Superclass::Modified( );
15
16   } // fi
17 }
18
19 // -------------------------------------------------------------------------
20 int cpExtensions::Visualization::ImageActor::
21 GetOrientation( ) const
22 {
23   return( this->m_Mapper->GetOrientation( ) );
24 }
25
26 // -------------------------------------------------------------------------
27 void cpExtensions::Visualization::ImageActor::
28 SetOrientation( int orientation )
29 {
30   this->m_Mapper->SetOrientation( ( orientation < 3 )? orientation: 2 );
31   this->Modified( );
32 }
33
34 // -------------------------------------------------------------------------
35 int cpExtensions::Visualization::ImageActor::
36 GetSliceNumber( ) const
37 {
38   return( this->m_Mapper->GetSliceNumber( ) );
39 }
40
41 // -------------------------------------------------------------------------
42 void cpExtensions::Visualization::ImageActor::
43 SetSliceNumber( int slice )
44 {
45   static int mySlice;
46   auto image = this->m_Mapper->GetInput( );
47   if( image != NULL )
48   {
49     // Update slice
50     int s = slice;
51     if( s < this->m_Mapper->GetSliceNumberMinValue( ) )
52       s = this->m_Mapper->GetSliceNumberMinValue( );
53     if( s > this->m_Mapper->GetSliceNumberMaxValue( ) )
54       s = this->m_Mapper->GetSliceNumberMaxValue( );
55     this->m_Mapper->SetSliceNumber( s );
56
57     // Propagate modifications
58     this->Modified( );
59     mySlice = slice;
60     this->InvokeEvent( vtkCommand::InteractionEvent, &mySlice );
61
62   } // fi
63 }
64
65 // -------------------------------------------------------------------------
66 vtkPlane* cpExtensions::Visualization::ImageActor::
67 GetSlicePlane( )
68 {
69   return( this->m_Mapper->GetSlicePlane( ) );
70 }
71
72 // -------------------------------------------------------------------------
73 const vtkPlane* cpExtensions::Visualization::ImageActor::
74 GetSlicePlane( ) const
75 {
76   return( this->m_Mapper->GetSlicePlane( ) );
77 }
78
79 // -------------------------------------------------------------------------
80 cpExtensions::Visualization::ImageActor::
81 ImageActor( )
82   : Superclass( )
83 {
84   this->m_Mapper = vtkSmartPointer< ImageSliceMapper >::New( );
85   this->SetMapper( this->m_Mapper );
86 }
87
88 // -------------------------------------------------------------------------
89 cpExtensions::Visualization::ImageActor::
90 ~ImageActor( )
91 {
92 }
93
94 // eof - $RCSfile$