1 #include <cpExtensions/QT/MPR3DWidget.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/Visualization/ImageOutlineActor.h>
6 #include <cpExtensions/Visualization/MPR3DActors.h>
7 #include <cpExtensions/Visualization/LUTImageActor.h>
8 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
11 #include <vtkImageData.h>
12 #include <vtkPolyData.h>
14 // -------------------------------------------------------------------------
15 cpExtensions::QT::MPR3DWidget::
16 MPR3DWidget( QWidget* parent, Qt::WindowFlags f )
17 : Superclass( parent, f ),
21 vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( );
24 // -------------------------------------------------------------------------
25 cpExtensions::QT::MPR3DWidget::
30 // -------------------------------------------------------------------------
31 void cpExtensions::QT::MPR3DWidget::
32 SetImage( vtkImageData* image, const std::string& name )
34 if( this->m_ImageName != "" )
36 // TODO: Clear visualization
40 this->m_Actors->SetImage( image );
41 this->m_ImageName = name;
43 vtkSmartPointer< vtkPropCollection > props =
44 vtkSmartPointer< vtkPropCollection >::New( );
45 props->AddItem( this->m_Actors->GetWindowLevelImageActor( 0 ) );
46 props->AddItem( this->m_Actors->GetWindowLevelImageActor( 1 ) );
47 props->AddItem( this->m_Actors->GetWindowLevelImageActor( 2 ) );
48 this->AddViewProps( props, name );
49 this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 0 ), name );
50 this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 1 ), name );
51 this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 2 ), name );
56 // -------------------------------------------------------------------------
57 void cpExtensions::QT::MPR3DWidget::
58 Add( vtkDataSet* data, const std::string& name )
60 auto image = dynamic_cast< vtkImageData* >( data );
61 auto pdata = dynamic_cast< vtkPolyData* >( data );
64 if( this->m_ImageName != "" )
68 this->SetImage( image, name );
70 else if( pdata != NULL )
72 this->AddViewProp( this->m_Actors->AddMesh( pdata ), name );
74 if( this->m_ImageName == "" )
82 auto image = dynamic_cast< vtkImageData* >( data );
83 auto pdata = dynamic_cast< vtkPolyData* >( data );
86 this->m_Actors->AddLUTImage( image );
87 vtkSmartPointer< vtkPropCollection > coll =
88 vtkSmartPointer< vtkPropCollection >::New( );
89 coll->AddItem( this->m_Actors->GetLUTImageActor( 0 ) );
90 coll->AddItem( this->m_Actors->GetLUTImageActor( 1 ) );
91 coll->AddItem( this->m_Actors->GetLUTImageActor( 2 ) );
92 this->AddViewProps( coll, name );
95 else if( pdata != NULL )
102 // -------------------------------------------------------------------------
103 void cpExtensions::QT::MPR3DWidget::
104 SetSliceNumber( int orientation, int slice )
106 this->m_Actors->SetSliceNumber( orientation, slice );
110 // -------------------------------------------------------------------------
111 void cpExtensions::QT::MPR3DWidget::
112 SetSlicesNumbers( int x, int y, int z )
114 this->m_Actors->SetSliceNumber( 0, x );
115 this->m_Actors->SetSliceNumber( 1, y );
116 this->m_Actors->SetSliceNumber( 2, z );
120 // -------------------------------------------------------------------------
121 void cpExtensions::QT::MPR3DWidget::
122 SetScalarRange( double r[ 2 ] )
126 // -------------------------------------------------------------------------
127 void cpExtensions::QT::MPR3DWidget::
128 SetWindowLevel( double wl[ 2 ] )
132 // -------------------------------------------------------------------------
133 void cpExtensions::QT::MPR3DWidget::
134 SetImageOpacity( double o )
138 // -------------------------------------------------------------------------
139 void cpExtensions::QT::MPR3DWidget::
140 SetImageInterpolation( unsigned char i )
144 #endif // cpExtensions_QT4