#include #include #include #include #include #include // ------------------------------------------------------------------------- cpExtensions::Visualization::SeedWidgetCorrector* cpExtensions::Visualization::SeedWidgetCorrector:: New( ) { return( new cpExtensions::Visualization::SeedWidgetCorrector ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::SeedWidgetCorrector:: Configure( vtkCellPicker* picker ) { this->m_Picker = picker; } // ------------------------------------------------------------------------- void cpExtensions::Visualization::SeedWidgetCorrector:: Execute( vtkObject* caller, unsigned long eventId, void* arguments ) { vtkSeedWidget* wdg = dynamic_cast< vtkSeedWidget* >( caller ); if( wdg == NULL || this->m_Picker == NULL ) return; if( eventId == vtkCommand::PlacePointEvent ) { // Get newly added handle and its associated objects int hId = *( reinterpret_cast< int* >( arguments ) ); vtkHandleWidget* hWdg = wdg->GetSeed( hId ); if( hWdg == NULL ) return; vtkHandleRepresentation* hRep = dynamic_cast< vtkHandleRepresentation* >( hWdg->GetRepresentation( ) ); if( hRep == NULL ) return; // Get clicked point and 3D scene double p[ 3 ]; hRep->GetDisplayPosition( p ); vtkRenderWindowInteractor* iren = wdg->GetInteractor( ); if( iren == NULL ) return; vtkRenderer* ren = iren->FindPokedRenderer( int( p[ 0 ] ), int( p[ 1 ] ) ); if( ren == NULL ) return; // Correct point with given picker double q[ 3 ]; this->m_Picker->Pick( p[ 0 ], p[ 1 ], p[ 2 ], ren ); this->m_Picker->GetPickPosition( q ); hRep->SetWorldPosition( q ); } // fi } // ------------------------------------------------------------------------- cpExtensions::Visualization::SeedWidgetCorrector:: SeedWidgetCorrector( ) : vtkCommand( ), m_Picker( NULL ) { } // ------------------------------------------------------------------------- cpExtensions::Visualization::SeedWidgetCorrector:: ~SeedWidgetCorrector( ) { } // eof - $RCSfile$