]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageActor.cxx
...
[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 s = 0;
46   auto image = this->m_Mapper->GetInput( );
47   if( image != NULL )
48   {
49     // Update slice
50     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     this->InvokeEvent( vtkCommand::InteractionEvent, &s );
57
58     // Propagate modifications
59     this->Modified( );
60
61   } // fi
62 }
63
64 // -------------------------------------------------------------------------
65 vtkPlane* cpExtensions::Visualization::ImageActor::
66 GetSlicePlane( )
67 {
68   return( this->m_Mapper->GetSlicePlane( ) );
69 }
70
71 // -------------------------------------------------------------------------
72 const vtkPlane* cpExtensions::Visualization::ImageActor::
73 GetSlicePlane( ) const
74 {
75   return( this->m_Mapper->GetSlicePlane( ) );
76 }
77
78 // -------------------------------------------------------------------------
79 cpExtensions::Visualization::ImageActor::
80 ImageActor( )
81   : Superclass( )
82 {
83   this->m_Mapper = vtkSmartPointer< ImageSliceMapper >::New( );
84   this->SetMapper( this->m_Mapper );
85 }
86
87 // -------------------------------------------------------------------------
88 cpExtensions::Visualization::ImageActor::
89 ~ImageActor( )
90 {
91 }
92
93 // eof - $RCSfile$