return( new Self( ) );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+AddCursorCommand( TCursorCommand command, void* data )
+{
+ this->m_CursorCommands.push_back(
+ std::pair< TCursorCommand, void* >( command, data )
+ );
+ this->Modified( );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
AddInputConnection( vtkAlgorithmOutput* aout, int axis )
{
+ // Get input vtkImageData
+ if( aout == NULL )
+ return;
+ vtkAlgorithm* producer = aout->GetProducer( );
vtkImageData* data = dynamic_cast< vtkImageData* >(
- aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+ producer->GetOutputDataObject( aout->GetIndex( ) )
);
if( data == NULL )
return;
+ // Try to infere if input comes from a color mapping filter
vtkImageMapToColors* new_map =
- dynamic_cast< vtkImageMapToColors* >( aout->GetProducer( ) );
+ dynamic_cast< vtkImageMapToColors* >( producer );
if( new_map == NULL )
{
- // Configure LUT
+ // Configure LUT, if possible (NULL is returned if not)
this->_ConfigureNewLUT( data );
- new_map = *( this->ImageMaps.rbegin( ) );
+ new_map = *( this->m_ImageMaps.rbegin( ) );
if( new_map != NULL )
{
new_map->SetInputConnection( aout );
} // fi
}
else
- this->ImageMaps.push_back( new_map );
+ this->m_ImageMaps.push_back( new_map );
// Create mapper and actors
vtkSmartPointer< vtkImageSliceMapper > mapper =
mapper->SetInputConnection( new_map->GetOutputPort( ) );
else
mapper->SetInputConnection( aout );
- this->SliceMappers.push_back( mapper );
+ this->m_SliceMappers.push_back( mapper );
this->_ConfigureNewInput( axis );
}
void cpExtensions::Visualization::ImageSliceActors::
AddInputData( vtkImageData* data, int axis )
{
- // Configure LUT
+ // Configure LUT, if possible (NULL is returned if not)
this->_ConfigureNewLUT( data );
- vtkImageMapToColors* new_map = *( this->ImageMaps.rbegin( ) );
+ vtkImageMapToColors* new_map = *( this->m_ImageMaps.rbegin( ) );
if( new_map != NULL )
{
new_map->SetInputData( data );
mapper->SetInputConnection( new_map->GetOutputPort( ) );
else
mapper->SetInputData( data );
- this->SliceMappers.push_back( mapper );
+ this->m_SliceMappers.push_back( mapper );
this->_ConfigureNewInput( axis );
}
this->RemoveAllItems( );
// Delete all images
- this->ImageMaps.clear( );
- this->SliceMappers.clear( );
- this->ImageActors.clear( );
- this->AssociatedSlices.clear( );
- this->AssociatedActors.clear( );
+ this->m_ImageMaps.clear( );
+ this->m_SliceMappers.clear( );
+ this->m_ImageActors.clear( );
+ this->m_AssociatedSlices.clear( );
+ this->m_AssociatedActors.clear( );
// Reconfigure unique objects
- this->Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->CursorActor = vtkSmartPointer< vtkActor >::New( );
- this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
- this->Plane = vtkSmartPointer< vtkPolyData >::New( );
- this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
- this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
- this->TextBuffer[ 0 ] = '\0';
+ this->m_Cursor = vtkSmartPointer< vtkPolyData >::New( );
+ this->m_CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->m_CursorActor = vtkSmartPointer< vtkActor >::New( );
+ this->m_PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
+ this->m_Plane = vtkSmartPointer< vtkPolyData >::New( );
+ this->m_PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->m_TextActor = vtkSmartPointer< vtkTextActor >::New( );
+ this->m_PlaneActor = vtkSmartPointer< vtkActor >::New( );
+ this->m_TextBuffer[ 0 ] = '\0';
// Unique objects configuration
vtkSmartPointer< vtkPoints > cursor_points =
cursor_lines->InsertNextCell( 2 );
cursor_lines->InsertCellPoint( 6 );
cursor_lines->InsertCellPoint( 7 );
- this->Cursor->SetPoints( cursor_points );
- this->Cursor->SetLines( cursor_lines );
- this->CursorMapper->SetInputData( this->Cursor );
- this->CursorActor->SetMapper( this->CursorMapper );
+ this->m_Cursor->SetPoints( cursor_points );
+ this->m_Cursor->SetLines( cursor_lines );
+ this->m_CursorMapper->SetInputData( this->m_Cursor );
+ this->m_CursorActor->SetMapper( this->m_CursorMapper );
vtkSmartPointer< vtkPoints > plane_points =
vtkSmartPointer< vtkPoints >::New( );
plane_lines->InsertCellPoint( 2 );
plane_lines->InsertCellPoint( 3 );
plane_lines->InsertCellPoint( 0 );
- this->Plane->SetPoints( plane_points );
- this->Plane->SetLines( plane_lines );
+ this->m_Plane->SetPoints( plane_points );
+ this->m_Plane->SetLines( plane_lines );
- this->PlaneMapper->SetInputData( this->Plane );
- this->PlaneActor->SetMapper( this->PlaneMapper );
+ this->m_PlaneMapper->SetInputData( this->m_Plane );
+ this->m_PlaneActor->SetMapper( this->m_PlaneMapper );
- this->TextActor->SetTextScaleModeToNone( );
- vtkTextProperty* textprop = this->TextActor->GetTextProperty( );
+ this->m_TextActor->SetTextScaleModeToNone( );
+ vtkTextProperty* textprop = this->m_TextActor->GetTextProperty( );
textprop->SetColor( 1, 1, 1 );
textprop->SetFontFamilyToCourier( );
textprop->SetFontSize( 18 );
textprop->ShadowOff( );
textprop->SetJustificationToLeft( );
textprop->SetVerticalJustificationToBottom( );
- vtkCoordinate* coord = this->TextActor->GetPositionCoordinate( );
+ vtkCoordinate* coord = this->m_TextActor->GetPositionCoordinate( );
coord->SetCoordinateSystemToNormalizedViewport( );
coord->SetValue( 0.01, 0.01 );
+
+ // Update actor collection
+ this->AddItem( this->m_CursorActor );
+ this->AddItem( this->m_TextActor );
+ this->AddItem( this->m_PlaneActor );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
AssociateSlice( Self* other )
{
- this->AssociatedSlices.push_back( other );
+ this->m_AssociatedSlices.push_back( other );
this->Modified( );
}
vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
GetStyle( )
{
- return( this->Style.GetPointer( ) );
+ return( this->m_Style.GetPointer( ) );
}
// -------------------------------------------------------------------------
const vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
GetStyle( ) const
{
- return( this->Style.GetPointer( ) );
+ return( this->m_Style.GetPointer( ) );
}
// -------------------------------------------------------------------------
// Update style
if( force_style )
- if( rwi->GetInteractorStyle( ) != this->Style.GetPointer( ) )
- rwi->SetInteractorStyle( this->Style );
+ {
+ this->_ConfigureStyle( );
+ rwi->SetInteractorStyle( this->m_Style );
+
+ } // fi
// Update actors
- unsigned int N = this->GetNumberOfImageActors( );
- for( unsigned int n = 0; n < N; ++n )
- renderer->AddActor( this->GetImageActor( n ) );
- renderer->AddActor( this->CursorActor );
- renderer->AddActor( this->PlaneActor );
- renderer->AddActor( this->TextActor );
- renderer->Modified( );
+# error USE vtkActorCollection interface
+ /* TODO
+ for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
+ renderer->AddActor( this->GetImageActor( n ) );
+ renderer->AddActor( this->m_CursorActor );
+ renderer->AddActor( this->m_PlaneActor );
+ renderer->AddActor( this->m_TextActor );
+ renderer->Modified( );
+ */
// Configure camera
vtkCamera* camera = renderer->GetActiveCamera( );
- if( camera == NULL )
- return;
-
- // Parallel projections are better when displaying 2D images
- if( force_style )
+ if( camera != NULL && force_style )
{
+ // Parallel projections are better when displaying 2D images
int axis = this->GetAxis( );
camera->ParallelProjectionOn( );
camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
if( renderer != NULL )
{
// Update actors
- unsigned int N = this->GetNumberOfImageActors( );
- for( unsigned int n = 0; n < N; ++n )
- renderer->RemoveActor( this->GetImageActor( n ) );
- renderer->RemoveActor( this->CursorActor );
- renderer->RemoveActor( this->PlaneActor );
- renderer->RemoveActor( this->TextActor );
- renderer->Modified( );
+# error USE vtkActorCollection interface
+ /* TODO
+ for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
+ renderer->RemoveActor( this->GetImageActor( n ) );
+ renderer->RemoveActor( this->m_CursorActor );
+ renderer->RemoveActor( this->m_PlaneActor );
+ renderer->RemoveActor( this->m_TextActor );
+ renderer->Modified( );
+ */
} // fi
+ if( rwi != NULL )
+ rwi->Render( );
}
// -------------------------------------------------------------------------
unsigned int cpExtensions::Visualization::ImageSliceActors::
GetNumberOfImageActors( ) const
{
- return( this->ImageActors.size( ) );
+ return( this->m_ImageActors.size( ) );
}
// -------------------------------------------------------------------------
vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
GetImageActor( unsigned int id )
{
- if( id < this->ImageActors.size( ) )
- return( this->ImageActors[ id ] );
+ if( id < this->m_ImageActors.size( ) )
+ return( this->m_ImageActors[ id ] );
else
return( NULL );
}
const vtkImageActor* cpExtensions::Visualization::ImageSliceActors::
GetImageActor( unsigned int id ) const
{
- if( id < this->ImageActors.size( ) )
- return( this->ImageActors[ id ] );
+ if( id < this->m_ImageActors.size( ) )
+ return( this->m_ImageActors[ id ] );
else
return( NULL );
}
vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
GetTextActor( )
{
- return( this->TextActor );
+ return( this->m_TextActor );
}
// -------------------------------------------------------------------------
const vtkTextActor* cpExtensions::Visualization::ImageSliceActors::
GetTextActor( ) const
{
- return( this->TextActor );
+ return( this->m_TextActor );
}
// -------------------------------------------------------------------------
vtkActor* cpExtensions::Visualization::ImageSliceActors::
GetPlaneActor( )
{
- return( this->PlaneActor );
+ return( this->m_PlaneActor );
}
// -------------------------------------------------------------------------
const vtkActor* cpExtensions::Visualization::ImageSliceActors::
GetPlaneActor( ) const
{
- return( this->PlaneActor );
+ return( this->m_PlaneActor );
}
// -------------------------------------------------------------------------
vtkPlane* cpExtensions::Visualization::ImageSliceActors::
GetPlaneFunction( )
{
- return( this->PlaneFunction );
+ return( this->m_PlaneFunction );
}
// -------------------------------------------------------------------------
const vtkPlane* cpExtensions::Visualization::ImageSliceActors::
GetPlaneFunction( ) const
{
- return( this->PlaneFunction );
+ return( this->m_PlaneFunction );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
AddActor( vtkAlgorithm* algorithm, vtkActor* actor )
{
- this->AssociatedActors.push_back( TAssociatedActor( algorithm, actor ) );
+ this->m_AssociatedActors.push_back( TAssociatedActor( algorithm, actor ) );
this->AddItem( actor );
}
{
if( this->Interpolate != v )
{
- for( unsigned int i = 0; i < this->ImageActors.size( ); ++i )
- this->ImageActors[ i ]->SetInterpolate( v );
+ for( unsigned int i = 0; i < this->m_ImageActors.size( ); ++i )
+ this->m_ImageActors[ i ]->SetInterpolate( v );
this->Interpolate = v;
this->Modified( );
double* cpExtensions::Visualization::ImageSliceActors::
GetDisplayBounds( ) const
{
- if( this->ImageActors.size( ) > 0 )
- return( this->ImageActors[ 0 ]->GetDisplayBounds( ) );
+ if( this->m_ImageActors.size( ) > 0 )
+ return( this->m_ImageActors[ 0 ]->GetDisplayBounds( ) );
else
return( NULL );
}
void cpExtensions::Visualization::ImageSliceActors::
GetDisplayBounds( double bounds[ 6 ] ) const
{
- if( this->ImageActors.size( ) == 0 )
+ if( this->m_ImageActors.size( ) == 0 )
{
bounds[ 0 ] = bounds[ 2 ] = bounds[ 4 ] = double( -1 );
bounds[ 1 ] = bounds[ 3 ] = bounds[ 5 ] = double( -1 );
}
else
- this->ImageActors[ 0 ]->GetDisplayBounds( bounds );
+ this->m_ImageActors[ 0 ]->GetDisplayBounds( bounds );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
ResetCursor( )
{
- vtkPoints* points = this->Cursor->GetPoints( );
+ vtkPoints* points = this->m_Cursor->GetPoints( );
points->SetPoint( 0, 0, 0, 0 );
points->SetPoint( 1, 0, 0, 0 );
points->SetPoint( 2, 0, 0, 0 );
points->SetPoint( 5, 0, 0, 0 );
points->SetPoint( 6, 0, 0, 0 );
points->SetPoint( 7, 0, 0, 0 );
- this->Cursor->Modified( );
- this->CursorMapper->Modified( );
- this->CursorActor->Modified( );
+ this->m_Cursor->Modified( );
+ this->m_CursorMapper->Modified( );
+ this->m_CursorActor->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
SetCursor( double pos[ 3 ] )
{
- if( this->SliceMappers.size( ) == 0 )
+ if( this->m_SliceMappers.size( ) == 0 )
return;
// Get ordered axes
int ma2 = a2 << 1;
double bounds[ 6 ];
- this->SliceMappers[ 0 ]->GetInput( )->GetBounds( bounds );
+ this->m_SliceMappers[ 0 ]->GetInput( )->GetBounds( bounds );
double
p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ],
p2[ a2 ] = p6[ a2 ] = bounds[ ma2 ];
p3[ a2 ] = p7[ a2 ] = bounds[ ma2 + 1 ];
- vtkPoints* points = this->Cursor->GetPoints( );
+ vtkPoints* points = this->m_Cursor->GetPoints( );
points->SetPoint( 0, p0 );
points->SetPoint( 1, p1 );
points->SetPoint( 2, p2 );
points->SetPoint( 5, p5 );
points->SetPoint( 6, p6 );
points->SetPoint( 7, p7 );
- this->Cursor->Modified( );
- this->CursorMapper->Modified( );
- this->CursorActor->Modified( );
+ this->m_Cursor->Modified( );
+ this->m_CursorMapper->Modified( );
+ this->m_CursorActor->Modified( );
}
// -------------------------------------------------------------------------
vtkImageMapToColors* cpExtensions::Visualization::ImageSliceActors::
GetImageMap( unsigned int id )
{
- if( id < this->ImageMaps.size( ) )
- return( this->ImageMaps[ id ].GetPointer( ) );
+ if( id < this->m_ImageMaps.size( ) )
+ return( this->m_ImageMaps[ id ].GetPointer( ) );
else
return( NULL );
}
const vtkImageMapToColors* cpExtensions::Visualization::ImageSliceActors::
GetImageMap( unsigned int id ) const
{
- if( id < this->ImageMaps.size( ) )
- return( this->ImageMaps[ id ].GetPointer( ) );
+ if( id < this->m_ImageMaps.size( ) )
+ return( this->m_ImageMaps[ id ].GetPointer( ) );
else
return( NULL );
}
double cpExtensions::Visualization::ImageSliceActors::
GetWindow( ) const
{
- if( this->ImageMaps.size( ) > 0 )
+ if( this->m_ImageMaps.size( ) > 0 )
{
- if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
{
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >(
- this->ImageMaps[ 0 ]->GetLookupTable( )
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
);
if( lut != NULL )
return( lut->GetWindow( ) );
double cpExtensions::Visualization::ImageSliceActors::
GetLevel( ) const
{
- if( this->ImageMaps.size( ) > 0 )
+ if( this->m_ImageMaps.size( ) > 0 )
{
- if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
{
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >(
- this->ImageMaps[ 0 ]->GetLookupTable( )
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
);
if( lut != NULL )
return( lut->GetLevel( ) );
void cpExtensions::Visualization::ImageSliceActors::
SetWindow( double w )
{
- if( this->ImageMaps.size( ) > 0 )
+ if( this->m_ImageMaps.size( ) > 0 )
{
- if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
{
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >(
- this->ImageMaps[ 0 ]->GetLookupTable( )
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
);
if( lut != NULL )
{
*/
lut->SetWindow( w );
lut->Build( );
- this->ImageMaps[ 0 ]->Modified( );
+ this->m_ImageMaps[ 0 ]->Modified( );
this->Modified( );
} // fi
void cpExtensions::Visualization::ImageSliceActors::
SetLevel( double l )
{
- if( this->ImageMaps.size( ) > 0 )
+ if( this->m_ImageMaps.size( ) > 0 )
{
- if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
{
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >(
- this->ImageMaps[ 0 ]->GetLookupTable( )
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
);
if( lut != NULL )
{
*/
lut->SetLevel( l );
lut->Build( );
- this->ImageMaps[ 0 ]->Modified( );
+ this->m_ImageMaps[ 0 ]->Modified( );
this->Modified( );
} // fi
void cpExtensions::Visualization::ImageSliceActors::
SetWindowLevel( double w, double l )
{
- if( this->ImageMaps.size( ) > 0 )
+ if( this->m_ImageMaps.size( ) > 0 )
{
- if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
{
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >(
- this->ImageMaps[ 0 ]->GetLookupTable( )
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
);
if( lut != NULL )
{
lut->SetWindow( w );
lut->SetLevel( l );
lut->Build( );
- this->ImageMaps[ 0 ]->Modified( );
+ this->m_ImageMaps[ 0 ]->Modified( );
this->Modified( );
} // fi
void cpExtensions::Visualization::ImageSliceActors::
SetLookupTable( unsigned int id, vtkLookupTable* lut )
{
- if( id < this->ImageMaps.size( ) && id > 0 )
+ if( id < this->m_ImageMaps.size( ) && id > 0 )
{
- if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+ if( this->m_ImageMaps[ id ].GetPointer( ) != NULL )
{
- this->ImageMaps[ id ]->SetLookupTable( lut );
- this->ImageMaps[ id ]->Modified( );
+ this->m_ImageMaps[ id ]->SetLookupTable( lut );
+ this->m_ImageMaps[ id ]->Modified( );
this->Modified( );
} // fi
static const double _OPACITY = double( 0.6 );
// Check ID consistency
- if( id == 0 || id >= this->ImageMaps.size( ) )
+ if( id == 0 || id >= this->m_ImageMaps.size( ) )
return;
// Get image scalar range
- vtkAlgorithmOutput* aout = this->ImageMaps[ id ]->GetOutputPort( );
+ vtkAlgorithmOutput* aout = this->m_ImageMaps[ id ]->GetOutputPort( );
vtkImageData* image = dynamic_cast< vtkImageData* >(
aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
);
int cpExtensions::Visualization::ImageSliceActors::
GetAxis( ) const
{
- if( this->SliceMappers.size( ) > 0 )
- return( this->SliceMappers[ 0 ]->GetOrientation( ) );
+ if( this->m_SliceMappers.size( ) > 0 )
+ return( this->m_SliceMappers[ 0 ]->GetOrientation( ) );
else
return( -1 );
}
int cpExtensions::Visualization::ImageSliceActors::
GetSliceNumber( ) const
{
- if( this->SliceMappers.size( ) > 0 )
- return( this->SliceMappers[ 0 ]->GetSliceNumber( ) );
+ if( this->m_SliceMappers.size( ) > 0 )
+ return( this->m_SliceMappers[ 0 ]->GetSliceNumber( ) );
else
return( -1 );
}
int cpExtensions::Visualization::ImageSliceActors::
GetSliceNumberMinValue( ) const
{
- if( this->SliceMappers.size( ) > 0 )
- return( this->SliceMappers[ 0 ]->GetSliceNumberMinValue( ) );
+ if( this->m_SliceMappers.size( ) > 0 )
+ return( this->m_SliceMappers[ 0 ]->GetSliceNumberMinValue( ) );
else
return( -1 );
}
int cpExtensions::Visualization::ImageSliceActors::
GetSliceNumberMaxValue( ) const
{
- if( this->SliceMappers.size( ) > 0 )
- return( this->SliceMappers[ 0 ]->GetSliceNumberMaxValue( ) );
+ if( this->m_SliceMappers.size( ) > 0 )
+ return( this->m_SliceMappers[ 0 ]->GetSliceNumberMaxValue( ) );
else
return( -1 );
}
void cpExtensions::Visualization::ImageSliceActors::
SetSliceNumber( const int& slice )
{
- unsigned int nImages = this->SliceMappers.size( );
+ unsigned int nImages = this->m_SliceMappers.size( );
if( nImages == 0 )
return;
// Change visualization extent
for( unsigned int i = 0; i < nImages; ++i )
{
- this->SliceMappers[ i ]->SetSliceNumber( slice );
- this->SliceMappers[ i ]->Modified( );
- this->ImageActors[ i ]->Modified( );
- this->SliceMappers[ i ]->Update( );
+ this->m_SliceMappers[ i ]->SetSliceNumber( slice );
+ this->m_SliceMappers[ i ]->Modified( );
+ this->m_ImageActors[ i ]->Modified( );
+ this->m_SliceMappers[ i ]->Update( );
} // rof
// Compute plane
- vtkAlgorithm* algo = this->SliceMappers[ 0 ]->GetInputAlgorithm( );
+ vtkAlgorithm* algo = this->m_SliceMappers[ 0 ]->GetInputAlgorithm( );
vtkInformation* info = algo->GetOutputInformation( 0 );
int ext[ 6 ];
double ori[ 3 ], spac[ 3 ], pos[ 3 ];
info->Get( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT( ), ext );
info->Get( vtkDataObject::ORIGIN( ), ori );
info->Get( vtkDataObject::SPACING( ), spac );
- this->SliceMappers[ 0 ]->GetSlicePlane( )->GetOrigin( pos );
+ this->m_SliceMappers[ 0 ]->GetSlicePlane( )->GetOrigin( pos );
// Prevent obscuring voxels by offsetting the plane geometry
double xbnds[ ] =
} // fi
// Plane function origin
- this->PlaneFunction->SetOrigin( pos );
+ this->m_PlaneFunction->SetOrigin( pos );
// Configure visualization and implicit plane orientation
- int axis = this->SliceMappers[ 0 ]->GetOrientation( );
- this->PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
- this->PlaneActor->GetProperty( )->SetLineWidth( 2 );
- vtkPoints* plane_points = this->Plane->GetPoints( );
+ int axis = this->m_SliceMappers[ 0 ]->GetOrientation( );
+ this->m_PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
+ this->m_PlaneActor->GetProperty( )->SetLineWidth( 2 );
+ vtkPoints* plane_points = this->m_Plane->GetPoints( );
if( axis == 0 ) // YZ, x-normal
{
- this->PlaneFunction->SetNormal( 1, 0, 0 );
+ this->m_PlaneFunction->SetNormal( 1, 0, 0 );
plane_points->SetPoint( 0, pos[ 0 ], ybnds[ 0 ], zbnds[ 0 ] );
plane_points->SetPoint( 1, pos[ 0 ], ybnds[ 1 ], zbnds[ 0 ] );
plane_points->SetPoint( 2, pos[ 0 ], ybnds[ 1 ], zbnds[ 1 ] );
plane_points->SetPoint( 3, pos[ 0 ], ybnds[ 0 ], zbnds[ 1 ] );
- this->PlaneActor->GetProperty( )->SetColor( 1, 0, 0 );
+ this->m_PlaneActor->GetProperty( )->SetColor( 1, 0, 0 );
}
else if( axis == 1 ) // ZX, y-normal
{
- this->PlaneFunction->SetNormal( 0, 1, 0 );
+ this->m_PlaneFunction->SetNormal( 0, 1, 0 );
plane_points->SetPoint( 0, xbnds[ 0 ], pos[ 1 ], zbnds[ 0 ] );
plane_points->SetPoint( 1, xbnds[ 0 ], pos[ 1 ], zbnds[ 1 ] );
plane_points->SetPoint( 2, xbnds[ 1 ], pos[ 1 ], zbnds[ 1 ] );
plane_points->SetPoint( 3, xbnds[ 1 ], pos[ 1 ], zbnds[ 0 ] );
- this->PlaneActor->GetProperty( )->SetColor( 0, 1, 0 );
+ this->m_PlaneActor->GetProperty( )->SetColor( 0, 1, 0 );
}
else // XY, z-normal
{
- this->PlaneFunction->SetNormal( 0, 0, 1 );
+ this->m_PlaneFunction->SetNormal( 0, 0, 1 );
plane_points->SetPoint( 0, xbnds[ 0 ], ybnds[ 0 ], pos[ 2 ] );
plane_points->SetPoint( 1, xbnds[ 1 ], ybnds[ 0 ], pos[ 2 ] );
plane_points->SetPoint( 2, xbnds[ 1 ], ybnds[ 1 ], pos[ 2 ] );
plane_points->SetPoint( 3, xbnds[ 0 ], ybnds[ 1 ], pos[ 2 ] );
- this->PlaneActor->GetProperty( )->SetColor( 0, 0, 1 );
+ this->m_PlaneActor->GetProperty( )->SetColor( 0, 0, 1 );
} // fi
- this->PlaneFunction->Modified( );
- this->Plane->Modified( );
- this->PlaneMapper->Modified( );
- this->PlaneActor->Modified( );
+ this->m_PlaneFunction->Modified( );
+ this->m_Plane->Modified( );
+ this->m_PlaneMapper->Modified( );
+ this->m_PlaneActor->Modified( );
// Prepare other actors to update
/* TODO
this->UpdateText( );
// Associated slices
- for( unsigned int i = 0; i < this->AssociatedSlices.size( ); ++i )
- if( this->AssociatedSlices[ i ]->GetAxis( ) == this->GetAxis( ) )
- this->AssociatedSlices[ i ]->SetSliceNumber( slice );
+ for( unsigned int i = 0; i < this->m_AssociatedSlices.size( ); ++i )
+ if( this->m_AssociatedSlices[ i ]->GetAxis( ) == this->GetAxis( ) )
+ this->m_AssociatedSlices[ i ]->SetSliceNumber( slice );
}
// -------------------------------------------------------------------------
SetSlice( double* pos )
{
vtkImageData* image;
- if( this->ImageMaps[ 0 ] != NULL )
+ if( this->m_ImageMaps[ 0 ] != NULL )
image =
- dynamic_cast< vtkImageData* >( this->ImageMaps[ 0 ]->GetInput( ) );
+ dynamic_cast< vtkImageData* >( this->m_ImageMaps[ 0 ]->GetInput( ) );
else
- image = this->SliceMappers[ 0 ]->GetInput( );
+ image = this->m_SliceMappers[ 0 ]->GetInput( );
int ijk[ 3 ];
double pcoords[ 3 ];
void cpExtensions::Visualization::ImageSliceActors::
UpdateText( )
{
- if( this->SliceMappers.size( ) > 0 )
+ if( this->m_SliceMappers.size( ) > 0 )
{
char axis;
- int axId = this->SliceMappers[ 0 ]->GetOrientation( );
+ int axId = this->m_SliceMappers[ 0 ]->GetOrientation( );
if ( axId == 0 ) axis = 'X';
else if( axId == 1 ) axis = 'Y';
else if( axId == 2 ) axis = 'Z';
std::sprintf(
- this->TextBuffer, "Axis: %c (%d)",
- axis, this->SliceMappers[ 0 ]->GetSliceNumber( )
+ this->m_TextBuffer, "Axis: %c (%d)",
+ axis, this->m_SliceMappers[ 0 ]->GetSliceNumber( )
);
}
else
- this->TextBuffer[ 0 ] = '\0';
- this->TextActor->SetInput( this->TextBuffer );
- this->TextActor->Modified( );
+ this->m_TextBuffer[ 0 ] = '\0';
+ this->m_TextActor->SetInput( this->m_TextBuffer );
+ this->m_TextActor->Modified( );
this->Modified( );
}
UpdateText( double pos[ 3 ] )
{
/* TODO
- if( this->SliceMappers.size( ) > 0 )
+ if( this->m_SliceMappers.size( ) > 0 )
{
char axis;
- int axId = this->SliceMappers[ 0 ]->GetOrientation( );
+ int axId = this->m_SliceMappers[ 0 ]->GetOrientation( );
if ( axId == 0 ) axis = 'X';
else if( axId == 1 ) axis = 'Y';
else if( axId == 2 ) axis = 'Z';
int slice = this->GetSliceNumber( );
vtkImageData* image;
- if( this->ImageMaps[ 0 ] != NULL )
+ if( this->m_ImageMaps[ 0 ] != NULL )
image =
- dynamic_cast< vtkImageData* >( this->ImageMaps[ 0 ]->GetInput( ) );
+ dynamic_cast< vtkImageData* >( this->m_ImageMaps[ 0 ]->GetInput( ) );
else
- image = this->SliceMappers[ 0 ]->GetInput( );
+ image = this->m_SliceMappers[ 0 ]->GetInput( );
int ijk[ 3 ];
double pcoords[ 3 ];
);
str << ")";
std::sprintf(
- this->TextBuffer, "Axis: %c (%d)\nPixel %s",
+ this->m_TextBuffer, "Axis: %c (%d)\nPixel %s",
axis, slice, str.str( ).c_str( )
);
} // fi
}
else
- this->TextBuffer[ 0 ] = '\0';
- this->TextActor->SetInput( this->TextBuffer );
- this->TextActor->Modified( );
+ this->m_TextBuffer[ 0 ] = '\0';
+ this->m_TextActor->SetInput( this->m_TextBuffer );
+ this->m_TextActor->Modified( );
this->Modified( );
*/
}
void cpExtensions::Visualization::ImageSliceActors::
UpdateText( const double& w, const double& l )
{
- if( this->SliceMappers.size( ) > 0 )
+ if( this->m_SliceMappers.size( ) > 0 )
{
char axis;
- int axId = this->SliceMappers[ 0 ]->GetOrientation( );
+ int axId = this->m_SliceMappers[ 0 ]->GetOrientation( );
if ( axId == 0 ) axis = 'X';
else if( axId == 1 ) axis = 'Y';
else if( axId == 2 ) axis = 'Z';
std::sprintf(
- this->TextBuffer, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
- axis, this->SliceMappers[ 0 ]->GetSliceNumber( ), w, l
+ this->m_TextBuffer, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
+ axis, this->m_SliceMappers[ 0 ]->GetSliceNumber( ), w, l
);
}
else
- this->TextBuffer[ 0 ] = '\0';
- this->TextActor->SetInput( this->TextBuffer );
- this->TextActor->Modified( );
+ this->m_TextBuffer[ 0 ] = '\0';
+ this->m_TextActor->SetInput( this->m_TextBuffer );
+ this->m_TextActor->Modified( );
this->Modified( );
}
this->Clear( );
this->SlicesCommand = NULL;
-
- // Connect this view with a controller
- this->Style = vtkSmartPointer< ImageInteractorStyle >::New( );
- this->Style->AssociateView( this );
- this->Style->SetMouseMoveCommand( Self::_MouseMoveCommand );
- this->Style->SetMouseClickCommand( Self::_MouseClickCommand );
- this->Style->SetMouseDoubleClickCommand( Self::_MouseDoubleClickCommand );
- this->Style->SetMouseWheelCommand( Self::_MouseWheelCommand );
- this->Style->SetKeyCommand( Self::_KeyCommand );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+_ConfigureStyle( )
+{
+ // Connect this view with a controller
+ this->m_Style = vtkSmartPointer< ImageInteractorStyle >::New( );
+ this->m_Style->AddMouseMoveCommand( Self::_MouseMoveCommand, this );
+ this->m_Style->AddMouseClickCommand( Self::_MouseClickCommand, this );
+ this->m_Style->AddMouseDoubleClickCommand(
+ Self::_MouseDoubleClickCommand, this
+ );
+ this->m_Style->AddMouseWheelCommand( Self::_MouseWheelCommand, this );
+ this->m_Style->AddKeyCommand( Self::_KeyCommand, this );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_ConfigureNewLUT( vtkImageData* data )
{
// Does the new LUT is a window-level one?
- unsigned int nImgs = this->ImageMaps.size( );
+ unsigned int nImgs = this->m_ImageMaps.size( );
unsigned int nCmps = data->GetNumberOfScalarComponents( );
if( nCmps > 1 )
{
- this->ImageMaps.push_back( NULL );
+ this->m_ImageMaps.push_back( NULL );
return;
} // fi
// Create LUT filter
- this->ImageMaps.push_back( vtkSmartPointer< vtkImageMapToColors >::New( ) );
+ this->m_ImageMaps.push_back( vtkSmartPointer< vtkImageMapToColors >::New( ) );
if( nImgs == 0 )
{
double range[ 2 ];
lut->SetWindow( range[ 1 ] - range[ 0 ] );
lut->SetLevel( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) );
lut->Build( );
- this->ImageMaps[ 0 ]->SetLookupTable( lut );
+ this->m_ImageMaps[ 0 ]->SetLookupTable( lut );
this->MinWindow = double( 0 );
this->MaxWindow = range[ 1 ] - range[ 0 ];
void cpExtensions::Visualization::ImageSliceActors::
_ConfigureNewInput( int axis )
{
- unsigned int nImages = this->ImageActors.size( );
+ unsigned int nImages = this->m_ImageActors.size( );
// Configure mapper
- vtkImageSliceMapper* mapper = this->SliceMappers[ nImages ];
+ vtkImageSliceMapper* mapper = this->m_SliceMappers[ nImages ];
if( nImages == 0 )
mapper->SetOrientation( axis );
else
- mapper->SetOrientation( this->SliceMappers[ 0 ]->GetOrientation( ) );
+ mapper->SetOrientation( this->m_SliceMappers[ 0 ]->GetOrientation( ) );
mapper->Update( );
// Create actor
vtkSmartPointer< vtkImageActor > actor =
vtkSmartPointer< vtkImageActor >::New( );
- this->ImageActors.push_back( actor );
+ this->m_ImageActors.push_back( actor );
actor->SetMapper( mapper );
actor->SetInterpolate( this->Interpolate );
actor->Modified( );
if( nImages == 0 )
- {
- this->AddItem( this->CursorActor );
- this->AddItem( this->PlaneActor );
- this->AddItem( this->TextActor );
- this->Style->AssociateImageActor( actor );
-
- } // fi
+ this->m_Style->AssociateImageActor( actor );
this->AddItem( actor );
if( nImages > 1 )
if( !alt && !ctr && sft )
{
double bounds[ 6 ];
- actors->SliceMappers[ 0 ]->GetBounds( bounds );
+ actors->m_SliceMappers[ 0 ]->GetBounds( bounds );
int a0 = actors->GetAxis( );
int a1 = ( a0 + 1 ) % 3;
else if( !alt && ctr && !sft && actors->SlicesCommand != NULL )
{
actors->SlicesCommand( pos, actors->GetAxis( ), actors->SlicesData );
- for( unsigned int i = 0; i < actors->CursorCommands.size( ); ++i )
- actors->CursorCommands[ i ].first(
+ for( unsigned int i = 0; i < actors->m_CursorCommands.size( ); ++i )
+ actors->m_CursorCommands[ i ].first(
pos,
actors->GetAxis( ),
- actors->CursorCommands[ i ].second
+ actors->m_CursorCommands[ i ].second
);
} // fi