#include #ifdef cpExtensions_QT4 #include #include #include #include #include #include // ------------------------------------------------------------------------- cpExtensions::QT::MPR3DWidget:: MPR3DWidget( QWidget* parent, Qt::WindowFlags f ) : Superclass( parent, f ), m_ImageName( "" ) { } // ------------------------------------------------------------------------- cpExtensions::QT::MPR3DWidget:: ~MPR3DWidget( ) { for( auto a = this->m_Actors.begin( ); a != this->m_Actors.end( ); ++a ) delete *a; this->m_Actors.clear( ); } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: Clear( ) { this->RemoveViewProps( ); this->m_ImageName = ""; } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: SetImage( vtkImageData* image, const std::string& name ) { if( name == "" ) return; if( this->m_ImageName != "" ) this->Clear( ); this->m_ImageName = name; for( unsigned int o = 0; o < 3; ++o ) { this->m_WLActors[ o ] = vtkSmartPointer< TWLActor >::New( ); this->m_WLActors[ o ]->SetImage( image ); this->m_WLActors[ o ]->SetOrientation( o ); this->m_OLActors[ o ] = vtkSmartPointer< TOLActor >::New( ); this->m_OLActors[ o ]->SetBounds( o, image->GetBounds( )[ o << 1 ], image->GetBounds( ) ); this->AddViewProp( this->m_WLActors[ o ], this->m_ImageName ); this->AddAuxViewProp( this->m_OLActors[ o ], this->m_ImageName ); this->ResetCamera( ); } // rof } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: Add( vtkDataSet* data, const std::string& name ) { auto image = dynamic_cast< vtkImageData* >( data ); auto pdata = dynamic_cast< vtkPolyData* >( data ); if( image != NULL ) { /* TODO if( this->m_ImageName != "" ) { } else this->SetImage( image, name ); */ } else if( pdata != NULL ) { TActor* actor = new TActor( ); actor->SetMesh( pdata ); this->m_Actors.push_back( actor ); this->AddViewProp( actor->GetActor( ), name ); this->Render( ); if( this->m_ImageName == "" ) this->ResetCamera( ); } // fi } // ------------------------------------------------------------------------- cpExtensions::QT::MPR3DWidget:: TWLActor* cpExtensions::QT::MPR3DWidget:: GetImageActor( int o ) { return( this->m_WLActors[ o % 3 ] ); } // ------------------------------------------------------------------------- const cpExtensions::QT::MPR3DWidget:: TWLActor* cpExtensions::QT::MPR3DWidget:: GetImageActor( int o ) const { return( this->m_WLActors[ o % 3 ] ); } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: SetSliceNumber( int orientation, int slice ) { int o = orientation % 3; this->m_WLActors[ o ]->SetSliceNumber( slice ); this->m_OLActors[ o ]->SetBounds( o, this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ], this->m_WLActors[ o ]->GetImage( )->GetBounds( ) ); this->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::QT::MPR3DWidget:: SetSlicesNumbers( int x, int y, int z ) { int s[] = { x, y, z }; for( int o = 0; o < 3; ++o ) { this->m_WLActors[ o ]->SetSliceNumber( s[ o ] ); this->m_OLActors[ o ]->SetBounds( o, this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ], this->m_WLActors[ o ]->GetImage( )->GetBounds( ) ); } // rof this->Render( ); } #endif // cpExtensions_QT4 // eof - $RCSfile$