1 #include <cpExtensions/Visualization/MPRWithDifferentWindows.h>
4 // -------------------------------------------------------------------------
5 cpExtensions::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 )
26 this->m_Renderers[ i ] = NULL;
32 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
33 this->m_Renderers[ i ]->SetBackground( 0.1, 0.3, 0.8 );
34 this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
36 // Image styles (just for 2D windows)
39 this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( );
40 this->m_Styles[ i ]->Configure(
41 this->m_MPRActors->GetSliceActors( i ), this->m_MPRActors
45 SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i );
46 this->m_Styles[ i ]->SetModeToNavigation( );
51 if( this->m_Windows[ 3 ] != NULL )
52 this->m_Renderers[ 3 ]->SetBackground( 0.2, 0.2, 0.2 );
54 for( int i = 0; i < 3; ++i )
56 for( int j = 0; j < 3; ++j )
59 this->m_Windows[ i ] != NULL &&
60 this->m_Windows[ j ] != NULL &&
64 AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) );
67 if( this->m_Windows[ 3 ] != NULL )
69 AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) );
74 // -------------------------------------------------------------------------
75 cpExtensions::Visualization::MPRWithDifferentWindows::
76 ~MPRWithDifferentWindows( )
80 // -------------------------------------------------------------------------
81 void cpExtensions::Visualization::MPRWithDifferentWindows::
82 SetImage( vtkImageData* image )
84 this->m_MPRActors->SetInputData( image );
85 this->m_MPRActors->PushDataInto(
86 this->m_Renderers[ 0 ],
87 this->m_Renderers[ 1 ],
88 this->m_Renderers[ 2 ],
89 this->m_Renderers[ 3 ]
92 // Correct cameras positions
94 vtkCamera* zCam = this->m_Renderers[ 2 ]->GetActiveCamera( );
95 zCam->SetViewUp( 0, -1, 0 );
96 zCam->SetPosition( 0, 0, -1 );
97 zCam->SetFocalPoint( 0, 0, 0 );
101 this->ResetCameras( );
105 // -------------------------------------------------------------------------
106 void cpExtensions::Visualization::MPRWithDifferentWindows::
107 SetModeToNavigation( )
109 for( unsigned int i = 0; i < 3; ++i )
111 if( this->m_Styles[ i ].GetPointer( ) != NULL )
112 this->m_Styles[ i ]->SetModeToNavigation( );
117 // -------------------------------------------------------------------------
118 void cpExtensions::Visualization::MPRWithDifferentWindows::
119 SetModeToDeformation( )
121 for( unsigned int i = 0; i < 3; ++i )
123 if( this->m_Styles[ i ].GetPointer( ) != NULL )
124 this->m_Styles[ i ]->SetModeToDeformation( );
129 // -------------------------------------------------------------------------
130 void cpExtensions::Visualization::MPRWithDifferentWindows::
131 ResetCamera( const int& id )
134 if( this->m_Windows[ id ] != NULL )
135 this->m_Renderers[ id ]->ResetCamera( );
138 // -------------------------------------------------------------------------
139 void cpExtensions::Visualization::MPRWithDifferentWindows::
142 for( int i = 0; i < 4; ++i )
143 if( this->m_Windows[ i ] != NULL )
144 this->m_Renderers[ i ]->ResetCamera( );
147 // -------------------------------------------------------------------------
148 void cpExtensions::Visualization::MPRWithDifferentWindows::
149 Render( const int& id )
152 if( this->m_Windows[ id ] != NULL )
153 this->m_Windows[ id ]->Render( );
156 // -------------------------------------------------------------------------
157 void cpExtensions::Visualization::MPRWithDifferentWindows::
160 for( int i = 0; i < 4; ++i )
161 if( this->m_Windows[ i ] != NULL )
162 this->m_Windows[ i ]->Render( );
165 // -------------------------------------------------------------------------
166 vtkRenderer* cpExtensions::Visualization::MPRWithDifferentWindows::
167 GetRenderer( const int& id ) const
170 return( this->m_Renderers[ id ] );
175 // -------------------------------------------------------------------------
176 void cpExtensions::Visualization::MPRWithDifferentWindows::
177 Add3DActor( vtkProp3D* prop )
179 if( this->m_Renderers[ 3 ] != NULL )
181 this->m_Renderers[ 3 ]->AddActor( prop );
182 this->ResetCamera( 3 );