1 #include <cpExtensions/QT/MPR3DWidget.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/Visualization/ImageOutlineActor.h>
6 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
8 #include <vtkImageData.h>
12 #include <cpExtensions/Visualization/MPR3DActors.h>
13 #include <cpExtensions/Visualization/LUTImageActor.h>
16 #include <vtkPolyData.h>
19 // -------------------------------------------------------------------------
20 cpExtensions::QT::MPR3DWidget::
21 MPR3DWidget( QWidget* parent, Qt::WindowFlags f )
22 : Superclass( parent, f ),
27 vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( );
31 // -------------------------------------------------------------------------
32 cpExtensions::QT::MPR3DWidget::
37 // -------------------------------------------------------------------------
38 void cpExtensions::QT::MPR3DWidget::
41 this->RemoveViewProps( );
42 this->m_ImageName = "";
45 // -------------------------------------------------------------------------
46 void cpExtensions::QT::MPR3DWidget::
47 SetImage( vtkImageData* image, const std::string& name )
51 if( this->m_ImageName != "" )
53 this->m_ImageName = name;
55 for( unsigned int o = 0; o < 3; ++o )
57 this->m_WLActors[ o ] = vtkSmartPointer< TWLActor >::New( );
58 this->m_WLActors[ o ]->SetImage( image );
59 this->m_WLActors[ o ]->SetOrientation( o );
61 this->m_OLActors[ o ] = vtkSmartPointer< TOLActor >::New( );
62 this->m_OLActors[ o ]->SetBounds(
63 o, image->GetBounds( )[ o << 1 ], image->GetBounds( )
66 this->AddViewProp( this->m_WLActors[ o ], this->m_ImageName );
67 this->AddAuxViewProp( this->m_OLActors[ o ], this->m_ImageName );
73 // -------------------------------------------------------------------------
74 cpExtensions::QT::MPR3DWidget::
75 TWLActor* cpExtensions::QT::MPR3DWidget::
76 GetImageActor( int o )
78 return( this->m_WLActors[ o % 3 ] );
81 // -------------------------------------------------------------------------
82 const cpExtensions::QT::MPR3DWidget::
83 TWLActor* cpExtensions::QT::MPR3DWidget::
84 GetImageActor( int o ) const
86 return( this->m_WLActors[ o % 3 ] );
89 // -------------------------------------------------------------------------
90 void cpExtensions::QT::MPR3DWidget::
91 SetSliceNumber( int orientation, int slice )
93 int o = orientation % 3;
94 this->m_WLActors[ o ]->SetSliceNumber( slice );
95 this->m_OLActors[ o ]->SetBounds(
97 this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ],
98 this->m_WLActors[ o ]->GetImage( )->GetBounds( )
103 // -------------------------------------------------------------------------
104 void cpExtensions::QT::MPR3DWidget::
105 SetSlicesNumbers( int x, int y, int z )
107 int s[] = { x, y, z };
108 for( int o = 0; o < 3; ++o )
110 this->m_WLActors[ o ]->SetSliceNumber( s[ o ] );
111 this->m_OLActors[ o ]->SetBounds(
113 this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ],
114 this->m_WLActors[ o ]->GetImage( )->GetBounds( )
121 // -------------------------------------------------------------------------
123 void cpExtensions::QT::MPR3DWidget::
124 SetImage( vtkImageData* image, const std::string& name )
126 if( this->m_ImageName != "" )
128 // TODO: Clear visualization
132 this->m_Actors->SetImage( image );
133 this->m_ImageName = name;
135 vtkSmartPointer< vtkPropCollection > props =
136 vtkSmartPointer< vtkPropCollection >::New( );
137 props->AddItem( this->m_Actors->GetWindowLevelImageActor( 0 ) );
138 props->AddItem( this->m_Actors->GetWindowLevelImageActor( 1 ) );
139 props->AddItem( this->m_Actors->GetWindowLevelImageActor( 2 ) );
140 this->AddViewProps( props, name );
141 this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 0 ), name );
142 this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 1 ), name );
143 this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 2 ), name );
144 this->ResetCamera( );
148 // -------------------------------------------------------------------------
149 void cpExtensions::QT::MPR3DWidget::
150 Add( vtkDataSet* data, const std::string& name )
152 auto image = dynamic_cast< vtkImageData* >( data );
153 auto pdata = dynamic_cast< vtkPolyData* >( data );
156 if( this->m_ImageName != "" )
160 this->SetImage( image, name );
162 else if( pdata != NULL )
164 this->AddViewProp( this->m_Actors->AddMesh( pdata ), name );
166 if( this->m_ImageName == "" )
167 this->ResetCamera( );
173 auto image = dynamic_cast< vtkImageData* >( data );
174 auto pdata = dynamic_cast< vtkPolyData* >( data );
177 this->m_Actors->AddLUTImage( image );
178 vtkSmartPointer< vtkPropCollection > coll =
179 vtkSmartPointer< vtkPropCollection >::New( );
180 coll->AddItem( this->m_Actors->GetLUTImageActor( 0 ) );
181 coll->AddItem( this->m_Actors->GetLUTImageActor( 1 ) );
182 coll->AddItem( this->m_Actors->GetLUTImageActor( 2 ) );
183 this->AddViewProps( coll, name );
186 else if( pdata != NULL )
192 // -------------------------------------------------------------------------
193 void cpExtensions::QT::MPR3DWidget::
194 SetSliceNumber( int orientation, int slice )
196 this->m_Actors->SetSliceNumber( orientation, slice );
200 // -------------------------------------------------------------------------
201 void cpExtensions::QT::MPR3DWidget::
202 SetSlicesNumbers( int x, int y, int z )
204 this->m_Actors->SetSliceNumber( 0, x );
205 this->m_Actors->SetSliceNumber( 1, y );
206 this->m_Actors->SetSliceNumber( 2, z );
210 // -------------------------------------------------------------------------
211 void cpExtensions::QT::MPR3DWidget::
212 SetScalarRange( double r[ 2 ] )
214 this->m_Actors->SetScalarRange( r );
218 // -------------------------------------------------------------------------
219 void cpExtensions::QT::MPR3DWidget::
220 SetWindowLevel( double wl[ 2 ] )
222 this->m_Actors->SetWindowLevel( wl );
226 // -------------------------------------------------------------------------
227 void cpExtensions::QT::MPR3DWidget::
228 SetImageOpacity( double o )
230 this->m_Actors->SetImageOpacity( o );
234 // -------------------------------------------------------------------------
235 void cpExtensions::QT::MPR3DWidget::
236 SetImageInterpolation( unsigned char i )
238 this->m_Actors->SetImageInterpolation( i );
243 #endif // cpExtensions_QT4