]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/OrthoNormalBase.cxx
9a02c0b56fb1d2d98124db3a778eae78b5b2f133
[cpPlugins.git] / lib / cpPlugins / OrthoNormalBase.cxx
1 #include <cpPlugins/OrthoNormalBase.h>
2
3 #include <vtkCaptionActor2D.h>
4 #include <vtkMatrix4x4.h>
5 #include <vtkTextProperty.h>
6
7 // -------------------------------------------------------------------------
8 void cpPlugins::OrthoNormalBase::
9 SetITK( itk::LightObject* o )
10 {
11   // WARNING: Do nothing since itk::Matrix does not belong to the
12   // itk::LightObject hierarchy.
13 }
14
15 // -------------------------------------------------------------------------
16 void cpPlugins::OrthoNormalBase::
17 SetVTK( vtkObjectBase* o )
18 {
19   auto matrix = dynamic_cast< vtkMatrix4x4* >( o );
20   if( matrix !=  NULL )
21     this->Superclass::SetVTK( matrix );
22 }
23
24 // -------------------------------------------------------------------------
25 cpPlugins::OrthoNormalBase::
26 OrthoNormalBase( )
27   : Superclass( )
28 {
29   vtkSmartPointer< vtkTextProperty > t1, t2, t3;
30
31   t1 = vtkSmartPointer< vtkTextProperty >::New( );
32   t2 = vtkSmartPointer< vtkTextProperty >::New( );
33   t3 = vtkSmartPointer< vtkTextProperty >::New( );
34
35   t1->ItalicOff( );
36   t1->ShadowOff( );
37   t1->SetFontFamilyToTimes( );
38   t2->ShallowCopy( t1 );
39   t3->ShallowCopy( t1 );
40
41   this->m_BaseActor = vtkSmartPointer< vtkAxesActor >::New( );
42   this->m_BaseActor->GetXAxisCaptionActor2D( )->SetCaptionTextProperty( t1 );
43   this->m_BaseActor->GetYAxisCaptionActor2D( )->SetCaptionTextProperty( t2 );
44   this->m_BaseActor->GetZAxisCaptionActor2D( )->SetCaptionTextProperty( t3 );
45   this->m_BaseActor->SetShaftTypeToLine( );
46   this->m_BaseActor->SetXAxisLabelText( "x" );
47   this->m_BaseActor->SetYAxisLabelText( "y" );
48   this->m_BaseActor->SetZAxisLabelText( "z" );
49   this->m_BaseActor->SetTotalLength( 1.0, 1.0, 1.0 );
50 }
51
52 // -------------------------------------------------------------------------
53 cpPlugins::OrthoNormalBase::
54 ~OrthoNormalBase( )
55 {
56 }
57
58 // -------------------------------------------------------------------------
59 void cpPlugins::OrthoNormalBase::
60 _CreateVTKActor( ) const
61 {
62   auto matrix =
63     const_cast< vtkMatrix4x4* >( this->GetVTK< vtkMatrix4x4 >( ) );
64   if( matrix != NULL )
65   {
66     this->m_BaseActor->SetUserMatrix( matrix );
67     this->m_Actor = this->m_BaseActor.GetPointer( );
68     this->m_Actor->Modified( );
69
70   } // fi
71 }
72
73 // eof - $RCSfile$