X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FVTKWidgets%2FLineWidget.cxx;fp=plugins%2FVTKWidgets%2FLineWidget.cxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=24928e614d68235fb2ea477c0a0f9098f0efd5b4;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/plugins/VTKWidgets/LineWidget.cxx b/plugins/VTKWidgets/LineWidget.cxx deleted file mode 100644 index 24928e6..0000000 --- a/plugins/VTKWidgets/LineWidget.cxx +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -void cpPluginsVTKWidgets::LineWidget:: -Clear( ) -{ -} - -// ------------------------------------------------------------------------- -void cpPluginsVTKWidgets::LineWidget:: -SetEnabled( bool v ) -{ - auto wdg = this->GetVTK< vtkLineWidget2 >( ); - if( wdg != NULL ) - { - wdg->SetEnabled( v ); - wdg->GetInteractor( )->Render( ); - - } // fi -} - -// ------------------------------------------------------------------------- -bool cpPluginsVTKWidgets::LineWidget:: -GetEnabled( ) const -{ - auto wdg = this->GetVTK< const vtkLineWidget2 >( ); - if( wdg != NULL ) - { - vtkLineWidget2* w = const_cast< vtkLineWidget2* >( wdg ); - return( w->GetEnabled( ) != 0 ); - } - else - return( false ); -} - -// ------------------------------------------------------------------------- -cpPluginsVTKWidgets::LineWidget:: -LineWidget( ) - : Superclass( ) -{ - typedef cpPlugins::Pipeline::DataObject _TData; - typedef cpInstances::DataObjects::Mesh _TMesh; - - this->_ConfigureInput< _TData >( "Input", false, false ); - this->_ConfigureOutput< _TMesh >( "Output" ); - - // Create output data - auto line = this->_CreateVTK< vtkPolyData >( ); - line->SetPoints( vtkSmartPointer< vtkPoints >::New( ) ); - line->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) ); - line->SetLines( vtkSmartPointer< vtkCellArray >::New( ) ); - line->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) ); - line->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) ); - this->GetOutput( "Output" )->SetVTK( line ); -} - -// ------------------------------------------------------------------------- -cpPluginsVTKWidgets::LineWidget:: -~LineWidget( ) -{ -} - -// ------------------------------------------------------------------------- -void cpPluginsVTKWidgets::LineWidget:: -_GenerateData( ) -{ - if( this->m_Interactors.size( ) == 0 ) - this->_Error( "Give at least one valid interactor." ); - - auto image = this->GetInputData< vtkImageData >( "Input" ); - if( image != NULL ) this->_GD_Image( image ); - else this->_Error( "Do not know how to create this widget." ); -} - -// ------------------------------------------------------------------------- -cpPluginsVTKWidgets::LineWidget:: -TValidProps cpPluginsVTKWidgets::LineWidget:: -_GetValidActors( vtkObject* source ) -{ - TValidProps valid_props; - auto iIt = this->m_Interactors.begin( ); - for( ; iIt != this->m_Interactors.end( ); ++iIt ) - { - auto r = ( *iIt )->GetInteractorStyle( )->GetCurrentRenderer( ); - if( r != NULL ) - { - auto props = r->GetViewProps( ); - if( props != NULL ) - { - props->InitTraversal( ); - while( vtkProp* prop = props->GetNextProp( ) ) - { - auto image_actor = dynamic_cast< vtkImageSlice* >( prop ); - auto mesh_actor = dynamic_cast< vtkActor* >( prop ); - vtkObject* input = NULL; - if( image_actor != NULL ) - { - auto mapper = image_actor->GetMapper( ); - if( mapper != NULL ) - input = mapper->GetInput( ); - } - else if( mesh_actor != NULL ) - { - auto mapper = mesh_actor->GetMapper( ); - if( mapper != NULL ) - input = mapper->GetInput( ); - - } // fi - if( input != NULL ) - valid_props[ *iIt ].insert( prop ); - - } // elihw - - } // fi - - } // fi - - } // rof - return( valid_props ); -} - -// ------------------------------------------------------------------------- -void cpPluginsVTKWidgets::LineWidget:: -_GD_Image( vtkImageData* image ) -{ - auto valid_props = this->_GetValidActors( image ); - if( valid_props.size( ) == 0 ) - this->_Error( "Given image does not have a valid associated actor." ); - - vtkSmartPointer< vtkLineWidget2 > wdg = this->GetVTK< vtkLineWidget2 >( ); - if( wdg.GetPointer( ) == NULL ) - { - auto vIt = valid_props.begin( ); - auto actor = dynamic_cast< vtkImageSlice* >( *( vIt->second.begin( ) ) ); - - double bnds[ 6 ]; - actor->GetBounds( bnds ); - double p0[ 3 ], p1[ 3 ]; - p0[ 0 ] = bnds[ 0 ]; - p0[ 1 ] = bnds[ 2 ]; - p0[ 2 ] = bnds[ 4 ]; - p1[ 0 ] = bnds[ 1 ]; - p1[ 1 ] = bnds[ 3 ]; - p1[ 2 ] = bnds[ 5 ]; - - auto rep = vtkSmartPointer< vtkLineRepresentation >::New( ); - rep->SetPoint1WorldPosition( p0 ); - rep->SetPoint2WorldPosition( p1 ); - rep->PlaceWidget( bnds ); - - wdg = this->_CreateVTK< vtkLineWidget2 >( ); - wdg->SetInteractor( valid_props.begin( )->first ); - wdg->SetRepresentation( rep ); - wdg->EnabledOn( ); - } - else - dynamic_cast< vtkLineRepresentation* >( wdg->GetRepresentation( ) )-> - GetPolyData( this->GetOutputData< vtkPolyData >( "Output" ) ); -} - -// eof - $RCSfile$