+++ /dev/null
-#include <cpExtensions/Visualization/CursorActors.h>
-#include <cpExtensions/Visualization/LineSource.h>
-
-#include <vtkActor.h>
-#include <vtkPolyDataMapper.h>
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::CursorActors::
-Self* cpExtensions::Visualization::CursorActors::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-Modified( )
-{
- for( unsigned int i = 0; i < 2; ++i )
- {
- if( this->m_Lines[ i ].GetPointer( ) != NULL )
- {
- this->m_Lines[ i ]->Modified( );
- this->m_Mappers[ i ]->Modified( );
- this->m_Actors[ i ]->Modified( );
-
- } // fi
-
- } // rof
- this->Superclass::Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-SetImageBounds( double* bounds )
-{
- this->m_Bounds[ 0 ] = bounds[ 0 ];
- this->m_Bounds[ 1 ] = bounds[ 1 ];
- this->m_Bounds[ 2 ] = bounds[ 2 ];
- this->m_Bounds[ 3 ] = bounds[ 3 ];
- this->m_Bounds[ 4 ] = bounds[ 4 ];
- this->m_Bounds[ 5 ] = bounds[ 5 ];
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-SetImageOrientation( int orientation )
-{
- this->m_Orientation = orientation % 3;
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-SetCursor( double* pos, bool neg )
-{
- static const double _eps = 1e-3;
- double pnts[ 4 ][ 3 ];
- if( this->m_Orientation == 0 )
- {
- pnts[ 0 ][ 1 ] = this->m_Bounds[ 2 ];
- pnts[ 1 ][ 1 ] = this->m_Bounds[ 3 ];
- pnts[ 0 ][ 2 ] = pnts[ 1 ][ 2 ] = pos[ 2 ];
-
- pnts[ 2 ][ 1 ] = pnts[ 3 ][ 1 ] = pos[ 1 ];
- pnts[ 2 ][ 2 ] = this->m_Bounds[ 4 ];
- pnts[ 3 ][ 2 ] = this->m_Bounds[ 5 ];
-
- pnts[ 0 ][ 0 ] = pnts[ 1 ][ 0 ] =
- pnts[ 2 ][ 0 ] = pnts[ 3 ][ 0 ] =
- pos[ 0 ] + ( double( neg? -1: 1 ) * _eps );
- }
- else if( this->m_Orientation == 1 )
- {
- pnts[ 0 ][ 0 ] = pnts[ 1 ][ 0 ] = pos[ 0 ];
- pnts[ 0 ][ 2 ] = this->m_Bounds[ 4 ];
- pnts[ 1 ][ 2 ] = this->m_Bounds[ 5 ];
-
- pnts[ 2 ][ 0 ] = this->m_Bounds[ 0 ];
- pnts[ 3 ][ 0 ] = this->m_Bounds[ 1 ];
- pnts[ 2 ][ 2 ] = pnts[ 3 ][ 2 ] = pos[ 2 ];
-
- pnts[ 0 ][ 1 ] = pnts[ 1 ][ 1 ] =
- pnts[ 2 ][ 1 ] = pnts[ 3 ][ 1 ] =
- pos[ 1 ] + ( double( neg? -1: 1 ) * _eps );
- }
- else if( this->m_Orientation == 2 )
- {
- pnts[ 0 ][ 0 ] = this->m_Bounds[ 0 ];
- pnts[ 1 ][ 0 ] = this->m_Bounds[ 1 ];
- pnts[ 0 ][ 1 ] = pnts[ 1 ][ 1 ] = pos[ 1 ];
-
- pnts[ 2 ][ 0 ] = pnts[ 3 ][ 0 ] = pos[ 0 ];
- pnts[ 2 ][ 1 ] = this->m_Bounds[ 2 ];
- pnts[ 3 ][ 1 ] = this->m_Bounds[ 3 ];
-
- pnts[ 0 ][ 2 ] = pnts[ 1 ][ 2 ] =
- pnts[ 2 ][ 2 ] = pnts[ 3 ][ 2 ] =
- pos[ 2 ] + ( double( neg? -1: 1 ) * _eps );
-
- } // fi
-
- this->m_Lines[ 0 ]->SetPoint1( pnts[ 0 ] );
- this->m_Lines[ 0 ]->SetPoint2( pnts[ 1 ] );
- this->m_Lines[ 1 ]->SetPoint1( pnts[ 2 ] );
- this->m_Lines[ 1 ]->SetPoint2( pnts[ 3 ] );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-vtkProperty* cpExtensions::Visualization::CursorActors::
-GetProperty( unsigned int i )
-{
- return( this->m_Actors[ i % 2 ]->GetProperty( ) );
-}
-
-// -------------------------------------------------------------------------
-const vtkProperty* cpExtensions::Visualization::CursorActors::
-GetProperty( unsigned int i ) const
-{
- return( this->m_Actors[ i % 2 ]->GetProperty( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-SetVisibility( int v )
-{
- this->m_Actors[ 0 ]->SetVisibility( v );
- this->m_Actors[ 1 ]->SetVisibility( v );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-VisibilityOn( )
-{
- this->m_Actors[ 0 ]->VisibilityOn( );
- this->m_Actors[ 1 ]->VisibilityOn( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::CursorActors::
-VisibilityOff( )
-{
- this->m_Actors[ 0 ]->VisibilityOff( );
- this->m_Actors[ 1 ]->VisibilityOff( );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::CursorActors::
-CursorActors( )
- : Superclass( )
-{
- this->m_Bounds[ 0 ] = this->m_Bounds[ 1 ] = this->m_Bounds[ 2 ] =
- this->m_Bounds[ 3 ] = this->m_Bounds[ 4 ] = this->m_Bounds[ 5 ] =
- double( 0 );
-
- for( unsigned int i = 0; i < 2; ++i )
- {
- this->m_Lines[ i ] = vtkSmartPointer< LineSource >::New( );
- this->m_Mappers[ i ] = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->m_Actors[ i ] = vtkSmartPointer< vtkActor >::New( );
- this->m_Mappers[ i ]->SetInputConnection(
- this->m_Lines[ i ]->GetOutputPort( )
- );
- this->m_Actors[ i ]->SetMapper( this->m_Mappers[ i ] );
- this->AddItem( this->m_Actors[ i ] );
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::CursorActors::
-~CursorActors( )
-{
-}
-
-// eof - $RCSfile$