]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageActor.cxx
Architecture updated.
[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 #include <vtkPropCollection.h>
42 #include <typeinfo>
43
44 // -------------------------------------------------------------------------
45 void cpExtensions::Visualization::ImageActor::
46 SetSliceNumber( int slice )
47 {
48   static int mySlice;
49   auto image = this->m_Mapper->GetInput( );
50   if( image != NULL )
51   {
52     // Update slice
53     int s = slice;
54     if( s < this->m_Mapper->GetSliceNumberMinValue( ) )
55       s = this->m_Mapper->GetSliceNumberMinValue( );
56     if( s > this->m_Mapper->GetSliceNumberMaxValue( ) )
57       s = this->m_Mapper->GetSliceNumberMaxValue( );
58     this->m_Mapper->SetSliceNumber( s );
59
60     // Update display extent
61     /* TODO
62        int ext[ 6 ];
63        image->GetExtent( ext );
64        int o = this->m_Mapper->GetOrientation( );
65        ext[ o << 1 ] = ext[ ( o << 1 ) + 1 ] = s;
66        this->SetDisplayExtent( ext );
67     */
68
69     // Propagate modifications
70     this->Modified( );
71     mySlice = slice;
72     this->InvokeEvent( vtkCommand::InteractionEvent, &mySlice );
73
74   } // fi
75 }
76
77 // -------------------------------------------------------------------------
78 vtkPlane* cpExtensions::Visualization::ImageActor::
79 GetSlicePlane( )
80 {
81   return( this->m_Mapper->GetSlicePlane( ) );
82 }
83
84 // -------------------------------------------------------------------------
85 const vtkPlane* cpExtensions::Visualization::ImageActor::
86 GetSlicePlane( ) const
87 {
88   return( this->m_Mapper->GetSlicePlane( ) );
89 }
90
91 // -------------------------------------------------------------------------
92 cpExtensions::Visualization::ImageActor::
93 ImageActor( )
94   : Superclass( )
95 {
96   this->m_Mapper = vtkSmartPointer< ImageSliceMapper >::New( );
97   this->SetMapper( this->m_Mapper );
98 }
99
100 // -------------------------------------------------------------------------
101 cpExtensions::Visualization::ImageActor::
102 ~ImageActor( )
103 {
104 }
105
106 // eof - $RCSfile$