1 #include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
4 // -------------------------------------------------------------------------
5 cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
6 MPRWithDifferentWindows(
10 vtkRenderWindow* auxWin
13 this->m_Windows[ 0 ] = xWin;
14 this->m_Windows[ 1 ] = yWin;
15 this->m_Windows[ 2 ] = zWin;
16 this->m_Windows[ 3 ] = auxWin;
19 this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( );
22 for( int i = 0; i < 4; ++i )
24 if( this->m_Windows[ i ] == NULL )
28 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
29 this->m_Renderers[ i ]->SetBackground( 0.1, 0.3, 0.8 );
30 this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
32 // Image styles (just for 2D windows)
35 this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( );
36 this->m_Styles[ i ]->Configure(
37 this->m_MPRActors->GetSliceActors( i ), this->m_MPRActors
41 SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i );
42 this->m_Styles[ i ]->SetModeToNavigation( );
47 if( this->m_Windows[ 3 ] != NULL )
48 this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 );
50 for( int i = 0; i < 3; ++i )
52 for( int j = 0; j < 3; ++j )
55 this->m_Windows[ i ] != NULL &&
56 this->m_Windows[ j ] != NULL &&
60 AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) );
63 if( this->m_Windows[ 3 ] != NULL )
65 AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) );
70 // -------------------------------------------------------------------------
71 cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
72 ~MPRWithDifferentWindows( )
76 // -------------------------------------------------------------------------
77 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
78 SetImage( vtkImageData* image )
80 this->m_MPRActors->SetInputData( image );
81 this->m_MPRActors->PushDataInto(
82 this->m_Renderers[ 0 ],
83 this->m_Renderers[ 1 ],
84 this->m_Renderers[ 2 ],
85 this->m_Renderers[ 3 ]
88 // Correct cameras positions
89 vtkCamera* zCam = this->m_Renderers[ 2 ]->GetActiveCamera( );
90 zCam->SetViewUp( 0, -1, 0 );
91 zCam->SetPosition( 0, 0, -1 );
92 zCam->SetFocalPoint( 0, 0, 0 );
95 this->ResetCameras( );
99 // -------------------------------------------------------------------------
100 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
101 SetModeToNavigation( )
103 for( unsigned int i = 0; i < 3; ++i )
105 if( this->m_Styles[ i ].GetPointer( ) != NULL )
106 this->m_Styles[ i ]->SetModeToNavigation( );
111 // -------------------------------------------------------------------------
112 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
113 SetModeToDeformation( )
115 for( unsigned int i = 0; i < 3; ++i )
117 if( this->m_Styles[ i ].GetPointer( ) != NULL )
118 this->m_Styles[ i ]->SetModeToDeformation( );
123 // -------------------------------------------------------------------------
124 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
125 ResetCamera( const int& id )
128 if( this->m_Windows[ id ] != NULL )
129 this->m_Renderers[ id ]->ResetCamera( );
132 // -------------------------------------------------------------------------
133 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
136 for( int i = 0; i < 4; ++i )
137 if( this->m_Windows[ i ] != NULL )
138 this->m_Renderers[ i ]->ResetCamera( );
141 // -------------------------------------------------------------------------
142 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
143 Render( const int& id )
146 if( this->m_Windows[ id ] != NULL )
147 this->m_Windows[ id ]->Render( );
150 // -------------------------------------------------------------------------
151 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
154 for( int i = 0; i < 4; ++i )
155 if( this->m_Windows[ i ] != NULL )
156 this->m_Windows[ i ]->Render( );
159 // -------------------------------------------------------------------------
160 vtkRenderer* cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
161 GetRenderer( const int& id ) const
164 return( this->m_Renderers[ id ] );
169 // -------------------------------------------------------------------------
170 void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
171 Add3DActor( vtkProp3D* prop )
173 if( this->m_Renderers[ 3 ] != NULL )
175 this->m_Renderers[ 3 ]->AddActor( prop );
176 this->ResetCamera( 3 );