#include "SeedWidget.h" #include #include #include // ------------------------------------------------------------------------- void cpPluginsWidgets::SeedWidget::WidgetData:: Configure( vtkRenderWindowInteractor* interactor, vtkImageActor* actor ) { this->Placer = vtkSmartPointer< vtkImageActorPointPlacer >::New( ); this->Handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( ); this->Seed = vtkSmartPointer< vtkSeedRepresentation >::New( ); this->Widget = vtkSmartPointer< cpExtensions::Interaction::SeedWidget >::New( ); this->Placer->SetImageActor( actor ); this->Handle->GetProperty( )->SetColor( 1, 0, 0 ); this->Handle->SetPointPlacer( this->Placer ); this->Seed->SetHandleRepresentation( this->Handle ); this->Widget->SetRepresentation( this->Seed ); this->Widget->SetInteractor( interactor ); } // ------------------------------------------------------------------------- void cpPluginsWidgets::SeedWidget::WidgetData:: On( ) { this->Widget->On( ); } // ------------------------------------------------------------------------- void cpPluginsWidgets::SeedWidget::WidgetData:: Off( ) { this->Widget->Off( ); } // ------------------------------------------------------------------------- itk::ModifiedTimeType cpPluginsWidgets::SeedWidget:: GetMTime( ) const { this->Modified( ); return( this->Superclass::GetMTime( ) ); } // ------------------------------------------------------------------------- cpPluginsWidgets::SeedWidget:: SeedWidget( ) : Superclass( ), m_Configured( false ) { this->_AddOutput< cpPlugins::DataObject >( "Output" ); } // ------------------------------------------------------------------------- cpPluginsWidgets::SeedWidget:: ~SeedWidget( ) { } // ------------------------------------------------------------------------- void cpPluginsWidgets::SeedWidget:: _GenerateData( ) { if( this->m_Configured ) { auto points = this->_CreateVTK< vtkPoints >( ); for( auto wIt = this->m_Widgets.begin( ); wIt != this->m_Widgets.end( ); ++wIt ) { double pos[ 3 ]; for( unsigned int i = 0; i < wIt->Seed->GetNumberOfSeeds( ); ++i ) { wIt->Seed->GetSeedWorldPosition( i, pos ); points->InsertNextPoint( pos ); } // rof } // rof this->GetOutput( "Output" )->SetVTK( points ); } else { std::vector< vtkRenderWindowInteractor* > ints; if( this->m_MPRViewer != NULL ) { ints.push_back( this->m_MPRViewer->GetInteractor( 0 ) ); ints.push_back( this->m_MPRViewer->GetInteractor( 1 ) ); ints.push_back( this->m_MPRViewer->GetInteractor( 2 ) ); } // fi if( this->m_SingleInteractor != NULL ) ints.push_back( this->m_SingleInteractor ); for( auto iIt = ints.begin( ); iIt != ints.end( ); ++iIt ) { auto ren = ( *iIt )->GetInteractorStyle( )->GetCurrentRenderer( ); if( ren != NULL ) { auto props = ren->GetViewProps( ); if( props != NULL ) { props->InitTraversal( ); vtkProp* prop; while( ( prop = props->GetNextProp( ) ) != NULL ) { auto actor = dynamic_cast< vtkImageActor* >( prop ); if( actor != NULL ) { WidgetData d; d.Configure( *iIt, actor ); d.On( ); this->m_Widgets.push_back( d ); this->m_Configured = true; } // fi } // elihw } // fi } // fi } // rof } // fi if( !( this->m_Configured ) ) this->_Error( "Could not create valid widget: are there any valid actors?" ); } // eof - $RCSfile$