]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageActor.cxx
yet another refactoring
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageActor.cxx
1 #include <cpExtensions/Visualization/ImageActor.h>
2 #include <cpExtensions/Visualization/ImageSliceMapper.h>
3
4 #include <vtkCommand.h>
5 #include <vtkImageData.h>
6
7 // -------------------------------------------------------------------------
8 void cpExtensions::Visualization::ImageActor::
9 Modified( )
10 {
11   if( this->m_Mapper->GetNumberOfInputConnections( 0 ) > 0 )
12   {
13     this->m_Mapper->Modified( );
14     this->m_Mapper->Update( );
15     this->Superclass::Modified( );
16
17   } // fi
18 }
19
20 // -------------------------------------------------------------------------
21 int cpExtensions::Visualization::ImageActor::
22 GetOrientation( ) const
23 {
24   return( this->m_Mapper->GetOrientation( ) );
25 }
26
27 // -------------------------------------------------------------------------
28 void cpExtensions::Visualization::ImageActor::
29 SetOrientation( int orientation )
30 {
31   this->m_Mapper->SetOrientation( ( orientation < 3 )? orientation: 2 );
32   this->Modified( );
33 }
34
35 // -------------------------------------------------------------------------
36 int cpExtensions::Visualization::ImageActor::
37 GetSliceNumber( ) const
38 {
39   return( this->m_Mapper->GetSliceNumber( ) );
40 }
41
42 // -------------------------------------------------------------------------
43 void cpExtensions::Visualization::ImageActor::
44 SetSliceNumber( int slice )
45 {
46   static int s = 0;
47   auto image = this->m_Mapper->GetInput( );
48   if( image != NULL )
49   {
50     // Update slice
51     s = slice;
52     if( s < this->m_Mapper->GetSliceNumberMinValue( ) )
53       s = this->m_Mapper->GetSliceNumberMinValue( );
54     if( s > this->m_Mapper->GetSliceNumberMaxValue( ) )
55       s = this->m_Mapper->GetSliceNumberMaxValue( );
56     this->m_Mapper->SetSliceNumber( s );
57     this->InvokeEvent( vtkCommand::InteractionEvent, &s );
58
59     // Propagate modifications
60     this->Modified( );
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$