// Set up the interaction
vtkSmartPointer< vtkRenderWindowInteractor > interactor =
vtkSmartPointer< vtkRenderWindowInteractor >::New( );
- // interactor->SetInteractorStyle( style );
window->SetInteractor( interactor );
// Create slice actors
vtkSmartPointer< TSliceActors > image_actors =
vtkSmartPointer< TSliceActors >::New( );
- image_actors->AddInputData( image->GetVTK< vtkImageData >( ) );
+ image_actors->AddInputData(
+ image->GetVTK< vtkImageData >( ), 2,
+ TSliceActors::LUTType_WindowLevel
+ );
image_actors->PushActorsInto( window );
// Begin interaction
#include <cpExtensions/Visualization/BaseInteractorStyle.h>
+#include <cmath>
+
#include <vtkCallbackCommand.h>
+#include <vtkCamera.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindowInteractor.h>
// -------------------------------------------------------------------------
const long cpExtensions::Visualization::BaseInteractorStyle::MouseButtonEvent::
std::exit( 1 );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnMouseMove( )
+{
+ // Get current position on the associated actors
+ vtkRenderWindowInteractor* rwi = this->GetInteractor( );
+ if( rwi == NULL )
+ return;
+
+ // Get modifiers
+ bool alt = ( rwi->GetAltKey( ) == 1 );
+ bool ctr = ( rwi->GetControlKey( ) == 1 );
+ bool sft = ( rwi->GetShiftKey( ) == 1 );
+ ButtonID button = this->GetButtonID( );
+
+ // Invoke possible generic events
+ if( button == Self::ButtonID_Right )
+ {
+ if( !alt && !ctr && !sft )
+ {
+ this->FindPokedRenderer(
+ rwi->GetEventPosition( )[ 0 ],
+ rwi->GetEventPosition( )[ 1 ]
+ );
+ this->Dolly( );
+
+ } // fi
+ }
+ else if( button == Self::ButtonID_Middle )
+ {
+ if( !alt && !ctr && !sft )
+ {
+ this->FindPokedRenderer(
+ rwi->GetEventPosition( )[ 0 ],
+ rwi->GetEventPosition( )[ 1 ]
+ );
+ this->Pan( );
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnLeftButtonDown( )
+{
+ this->ActiveButton = Self::ButtonID_Left;
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnLeftButtonUp( )
+{
+ this->ActiveButton = Self::ButtonID_None;
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnMiddleButtonDown( )
+{
+ this->ActiveButton = Self::ButtonID_Middle;
+
+ // Get current position on the associated actors
+ vtkRenderWindowInteractor* rwi = this->GetInteractor( );
+ if( rwi == NULL )
+ return;
+
+ // Get modifiers
+ bool alt = ( rwi->GetAltKey( ) == 1 );
+ bool ctr = ( rwi->GetControlKey( ) == 1 );
+ bool sft = ( rwi->GetShiftKey( ) == 1 );
+
+ if( !alt && !ctr && !sft )
+ this->StartPan( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnMiddleButtonUp( )
+{
+ this->ActiveButton = Self::ButtonID_None;
+
+ // Get current position on the associated actors
+ vtkRenderWindowInteractor* rwi = this->GetInteractor( );
+ if( rwi == NULL )
+ return;
+
+ // Get modifiers
+ bool alt = ( rwi->GetAltKey( ) == 1 );
+ bool ctr = ( rwi->GetControlKey( ) == 1 );
+ bool sft = ( rwi->GetShiftKey( ) == 1 );
+
+ switch( this->State )
+ {
+ case VTKIS_PAN:
+ this->EndPan( );
+ break;
+ default:
+ break;
+ } // hctiws
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnRightButtonDown( )
+{
+ this->ActiveButton = Self::ButtonID_Right;
+
+ // Get current position on the associated actors
+ vtkRenderWindowInteractor* rwi = this->GetInteractor( );
+ if( rwi == NULL )
+ return;
+
+ // Get modifiers
+ bool alt = ( rwi->GetAltKey( ) == 1 );
+ bool ctr = ( rwi->GetControlKey( ) == 1 );
+ bool sft = ( rwi->GetShiftKey( ) == 1 );
+
+ if( !alt && !ctr && !sft )
+ this->StartDolly( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+OnRightButtonUp( )
+{
+ this->ActiveButton = Self::ButtonID_None;
+
+ // Get current position on the associated actors
+ vtkRenderWindowInteractor* rwi = this->GetInteractor( );
+ if( rwi == NULL )
+ return;
+
+ // Get modifiers
+ bool alt = ( rwi->GetAltKey( ) == 1 );
+ bool ctr = ( rwi->GetControlKey( ) == 1 );
+ bool sft = ( rwi->GetShiftKey( ) == 1 );
+
+ switch( this->State )
+ {
+ case VTKIS_DOLLY:
+ this->EndDolly( );
+ break;
+ default:
+ break;
+ } // hctiws
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+Dolly( )
+{
+ if( this->CurrentRenderer == NULL )
+ return;
+
+ vtkRenderWindowInteractor* rwi = this->GetInteractor( );
+ double *center = this->CurrentRenderer->GetCenter( );
+ int dy = rwi->GetEventPosition( )[ 1 ] - rwi->GetLastEventPosition( )[ 1 ];
+ double dyf = this->MotionFactor * dy / center[ 1 ];
+ this->_Dolly( std::pow( 1.1, dyf ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+Pan( )
+{
+ if( this->CurrentRenderer == NULL )
+ return;
+
+ vtkRenderWindowInteractor* rwi = this->Interactor;
+ double viewFocus[ 4 ], focalDepth, viewPoint[ 3 ];
+ double newPickPoint[ 4 ], oldPickPoint[ 4 ], motionVector[ 3 ];
+
+ // Calculate the focal depth since we'll be using it a lot
+ vtkCamera* camera = this->CurrentRenderer->GetActiveCamera( );
+ camera->GetFocalPoint( viewFocus );
+ this->ComputeWorldToDisplay(
+ viewFocus[ 0 ], viewFocus[ 1 ], viewFocus[ 2 ], viewFocus
+ );
+ focalDepth = viewFocus[ 2 ];
+ this->ComputeDisplayToWorld(
+ rwi->GetEventPosition( )[ 0 ],
+ rwi->GetEventPosition( )[ 1 ],
+ focalDepth,
+ newPickPoint
+ );
+
+ // Has to recalc old mouse point since the viewport has moved,
+ // so can't move it outside the loop
+ this->ComputeDisplayToWorld(
+ rwi->GetLastEventPosition( )[ 0 ],
+ rwi->GetLastEventPosition( )[ 1 ],
+ focalDepth,
+ oldPickPoint
+ );
+
+ // Camera motion is reversed
+ motionVector[ 0 ] = oldPickPoint[ 0 ] - newPickPoint[ 0 ];
+ motionVector[ 1 ] = oldPickPoint[ 1 ] - newPickPoint[ 1 ];
+ motionVector[ 2 ] = oldPickPoint[ 2 ] - newPickPoint[ 2 ];
+
+ camera->GetFocalPoint( viewFocus );
+ camera->GetPosition( viewPoint );
+ camera->SetFocalPoint(
+ motionVector[ 0 ] + viewFocus[ 0 ],
+ motionVector[ 1 ] + viewFocus[ 1 ],
+ motionVector[ 2 ] + viewFocus[ 2 ]
+ );
+ camera->SetPosition(
+ motionVector[ 0 ] + viewPoint[ 0 ],
+ motionVector[ 1 ] + viewPoint[ 1 ],
+ motionVector[ 2 ] + viewPoint[ 2 ]
+ );
+ if( rwi->GetLightFollowCamera( ) )
+ this->CurrentRenderer->UpdateLightsGeometryToFollowCamera( );
+ rwi->Render( );
+}
+
// -------------------------------------------------------------------------
cpExtensions::Visualization::BaseInteractorStyle::
BaseInteractorStyle( )
- : Superclass( )
+ : Superclass( ),
+ MotionFactor( double( 10 ) )
{
this->LeftButtonEvent.Reset( );
this->MiddleButtonEvent.Reset( );
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+_Dolly( double factor )
+{
+ if( this->CurrentRenderer == NULL )
+ return;
+
+ vtkCamera* camera = this->CurrentRenderer->GetActiveCamera( );
+ if( camera->GetParallelProjection( ) == 0 )
+ {
+ camera->Dolly( factor );
+ if( this->AutoAdjustCameraClippingRange )
+ this->CurrentRenderer->ResetCameraClippingRange( );
+ }
+ else
+ camera->SetParallelScale( camera->GetParallelScale( ) / factor );
+ if( this->Interactor->GetLightFollowCamera( ) )
+ this->CurrentRenderer->UpdateLightsGeometryToFollowCamera( );
+ this->Interactor->Render( );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::BaseInteractorStyle::
_ProcessEvents(
s->OnLeftDoubleClick( );
else if( nc == 1 )
s->OnLeftClick( );
- s->ActiveButton = Self::ButtonID_Left;
+ s->OnLeftButtonDown( );
}
break;
case vtkCommand::LeftButtonReleaseEvent:
{
s->LeftButtonEvent.Release( );
- s->ActiveButton = Self::ButtonID_None;
+ s->OnLeftButtonUp( );
}
break;
case vtkCommand::MiddleButtonPressEvent:
s->OnMiddleDoubleClick( );
else if( nc == 1 )
s->OnMiddleClick( );
- s->ActiveButton = Self::ButtonID_Middle;
+ s->OnMiddleButtonDown( );
}
break;
case vtkCommand::MiddleButtonReleaseEvent:
{
s->MiddleButtonEvent.Release( );
- s->ActiveButton = Self::ButtonID_None;
+ s->OnMiddleButtonUp( );
}
break;
case vtkCommand::RightButtonPressEvent:
s->OnRightDoubleClick( );
else if( nc == 1 )
s->OnRightClick( );
- s->ActiveButton = Self::ButtonID_Right;
+ s->OnRightButtonDown( );
}
break;
case vtkCommand::RightButtonReleaseEvent:
{
s->RightButtonEvent.Release( );
- s->ActiveButton = Self::ButtonID_None;
+ s->OnRightButtonUp( );
}
break;
case vtkCommand::MouseWheelForwardEvent:
void DelegateTDxEvent( unsigned long event, void* calldata );
// Possible mouse motion events
- virtual void OnMouseMove( ) { }
+ virtual void OnMouseMove( );
virtual void OnMouseWheelForward( ) { }
virtual void OnMouseWheelBackward( ) { }
// Possible mouse click-related events
inline ButtonID GetButtonID( ) const
{ return( this->ActiveButton ); }
- virtual void OnLeftButtonDown( ) { }
- virtual void OnLeftButtonUp( ) { }
+
+ virtual void OnLeftButtonDown( );
+ virtual void OnLeftButtonUp( );
+ virtual void OnMiddleButtonDown( );
+ virtual void OnMiddleButtonUp( );
+ virtual void OnRightButtonDown( );
+ virtual void OnRightButtonUp( );
+
virtual void OnLeftClick( ) { }
virtual void OnLeftDoubleClick( ) { }
- virtual void OnMiddleButtonDown( ) { }
- virtual void OnMiddleButtonUp( ) { }
virtual void OnMiddleClick( ) { }
virtual void OnMiddleDoubleClick( ) { }
- virtual void OnRightButtonDown( ) { }
- virtual void OnRightButtonUp( ) { }
virtual void OnRightClick( ) { }
virtual void OnRightDoubleClick( ) { }
virtual void OnEnter( ) { }
virtual void OnLeave( ) { }
- // Unused methods
- inline void StartState( int newstate ) { }
- inline void StopState( ) { }
- inline void StartAnimate( ) { }
- inline void StopAnimate( ) { }
- inline void StartRotate( ) { }
- inline void EndRotate( ) { }
- inline void StartZoom( ) { }
- inline void EndZoom( ) { }
- inline void StartPan( ) { }
- inline void EndPan( ) { }
- inline void StartSpin( ) { }
- inline void EndSpin( ) { }
- inline void StartDolly( ) { }
- inline void EndDolly( ) { }
- inline void StartUniformScale( ) { }
- inline void EndUniformScale( ) { }
- inline void StartTimer( ) { }
- inline void EndTimer( ) { }
- inline void StartTwoPointer( ) { }
- inline void EndTwoPointer( ) { }
- inline void OnTimer( ) { }
+ virtual void Dolly( );
+ virtual void Pan( );
protected:
BaseInteractorStyle( );
virtual ~BaseInteractorStyle( );
+ virtual void _Dolly( double factor );
+
static void _ProcessEvents(
vtkObject* object,
unsigned long event,
Self& operator=( const Self& );
protected:
+ double MotionFactor;
/**
* Button events
void cpExtensions::Visualization::ImageInteractorStyle::
OnMouseMove( )
{
+ this->Superclass::OnMouseMove( );
+
// Get current position on the associated actors
vtkRenderWindowInteractor* rwi = this->GetInteractor( );
if( rwi == NULL || this->MouseMoveCommand == NULL )
return;
- double pos[ 3 ];
- if( !( this->_PickPosition( pos ) ) )
- return;
// Get modifiers
bool alt = ( rwi->GetAltKey( ) == 1 );
bool sft = ( rwi->GetShiftKey( ) == 1 );
ButtonID button = this->GetButtonID( );
+ double pos[ 3 ];
+ if( !( this->_PickPosition( pos ) ) )
+ return;
+
// Invoke possible events
this->MouseMoveCommand( this->Data, button, pos, alt, ctr, sft );
rwi->Render( );
bool sft = ( rwi->GetShiftKey( ) == 1 );
// Invoke possible events
- this->MouseClickCommand( this->Data, Self::ButtonID_Left, pos, alt, ctr, sft );
+ this->MouseClickCommand(
+ this->Data, Self::ButtonID_Left, pos, alt, ctr, sft
+ );
rwi->Render( );
}
bool sft = ( rwi->GetShiftKey( ) == 1 );
// Invoke possible events
- this->MouseDoubleClickCommand( this->Data, Self::ButtonID_Left, pos, alt, ctr, sft );
+ this->MouseDoubleClickCommand(
+ this->Data, Self::ButtonID_Left, pos, alt, ctr, sft
+ );
rwi->Render( );
}
bool sft = ( rwi->GetShiftKey( ) == 1 );
// Invoke possible events
- this->MouseClickCommand( this->Data, Self::ButtonID_Middle, pos, alt, ctr, sft );
+ this->MouseClickCommand(
+ this->Data, Self::ButtonID_Middle, pos, alt, ctr, sft
+ );
rwi->Render( );
}
bool sft = ( rwi->GetShiftKey( ) == 1 );
// Invoke possible events
- this->MouseDoubleClickCommand( this->Data, Self::ButtonID_Middle, pos, alt, ctr, sft );
+ this->MouseDoubleClickCommand(
+ this->Data, Self::ButtonID_Middle, pos, alt, ctr, sft
+ );
rwi->Render( );
}
bool sft = ( rwi->GetShiftKey( ) == 1 );
// Invoke possible events
- this->MouseClickCommand( this->Data, Self::ButtonID_Right, pos, alt, ctr, sft );
+ this->MouseClickCommand(
+ this->Data, Self::ButtonID_Right, pos, alt, ctr, sft
+ );
rwi->Render( );
}
bool sft = ( rwi->GetShiftKey( ) == 1 );
// Invoke possible events
- this->MouseDoubleClickCommand( this->Data, Self::ButtonID_Right, pos, alt, ctr, sft );
+ this->MouseDoubleClickCommand(
+ this->Data, Self::ButtonID_Right, pos, alt, ctr, sft
+ );
rwi->Render( );
}
#include <cpExtensions/Visualization/ImageSliceActors.h>
+#include <cmath>
#include <sstream>
#include <vtkAlgorithmOutput.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkStreamingDemandDrivenPipeline.h>
#include <vtkTextProperty.h>
+#include <vtkWindowLevelLookupTable.h>
// -------------------------------------------------------------------------
cpExtensions::Visualization::ImageSliceActors*
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-AddInputConnection( vtkAlgorithmOutput* aout, int axis )
+AddInputConnection( vtkAlgorithmOutput* aout, int axis, LUTType lut )
{
+ vtkImageData* data = dynamic_cast< vtkImageData* >(
+ aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+ );
+ if( data == NULL )
+ return;
+
+ vtkImageMapToColors* new_map =
+ dynamic_cast< vtkImageMapToColors* >( aout->GetProducer( ) );
+ if( new_map == NULL )
+ {
+ // Configure LUT
+ this->_ConfigureNewLUT( data, lut );
+ new_map = *( this->ImageMaps.rbegin( ) );
+ if( new_map != NULL )
+ {
+ new_map->SetInputConnection( aout );
+ new_map->Update( );
+
+ } // fi
+ }
+ else
+ this->ImageMaps.push_back( new_map );
+
+ // Create mapper and actors
vtkSmartPointer< vtkImageSliceMapper > mapper =
vtkSmartPointer< vtkImageSliceMapper >::New( );
+ if( new_map != NULL )
+ mapper->SetInputConnection( new_map->GetOutputPort( ) );
+ else
+ mapper->SetInputConnection( aout );
this->SliceMappers.push_back( mapper );
- mapper->SetInputConnection( aout );
this->_ConfigureNewInput( axis );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-AddInputData( vtkImageData* data, int axis )
+AddInputData( vtkImageData* data, int axis, LUTType lut )
{
+ // Configure LUT
+ this->_ConfigureNewLUT( data, lut );
+ vtkImageMapToColors* new_map = *( this->ImageMaps.rbegin( ) );
+ if( new_map != NULL )
+ {
+ new_map->SetInputData( data );
+ new_map->Update( );
+
+ } // fi
+
+ // Create mapper and actors
vtkSmartPointer< vtkImageSliceMapper > mapper =
vtkSmartPointer< vtkImageSliceMapper >::New( );
+ if( new_map != NULL )
+ mapper->SetInputConnection( new_map->GetOutputPort( ) );
+ else
+ mapper->SetInputData( data );
this->SliceMappers.push_back( mapper );
- mapper->SetInputData( data );
this->_ConfigureNewInput( axis );
}
this->RemoveAllItems( );
// Delete all images
+ this->ImageMaps.clear( );
this->SliceMappers.clear( );
this->ImageActors.clear( );
this->AssociatedActors.clear( );
// Reconfigure unique objects
- this->Cursor = vtkSmartPointer< vtkPolyData >::New( );
- this->CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->CursorActor = vtkSmartPointer< vtkActor >::New( );
+ this->Cursor = vtkSmartPointer< vtkPolyData >::New( );
+ this->CursorMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->CursorActor = vtkSmartPointer< vtkActor >::New( );
this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
cursor_points->InsertNextPoint( 0, 0, 0 );
cursor_points->InsertNextPoint( 0, 0, 0 );
cursor_points->InsertNextPoint( 0, 0, 0 );
+ cursor_points->InsertNextPoint( 0, 0, 0 );
+ cursor_points->InsertNextPoint( 0, 0, 0 );
+ cursor_points->InsertNextPoint( 0, 0, 0 );
+ cursor_points->InsertNextPoint( 0, 0, 0 );
cursor_lines->InsertNextCell( 2 );
cursor_lines->InsertCellPoint( 0 );
cursor_lines->InsertCellPoint( 1 );
cursor_lines->InsertNextCell( 2 );
cursor_lines->InsertCellPoint( 2 );
cursor_lines->InsertCellPoint( 3 );
+ cursor_lines->InsertNextCell( 2 );
+ cursor_lines->InsertCellPoint( 4 );
+ cursor_lines->InsertCellPoint( 5 );
+ 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 );
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-PushActorsInto( vtkRenderWindow* window )
+PushActorsInto( vtkRenderWindow* window, bool force_style )
{
vtkRenderWindowInteractor* rwi = window->GetInteractor( );
vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
// Update style
- if( rwi != NULL )
+ if( rwi != NULL && force_style )
{
if( rwi->GetInteractorStyle( ) != this->Style.GetPointer( ) )
+ {
rwi->SetInteractorStyle( this->Style );
+ } // fi
+
} // fi
if( renderer != NULL )
{
+ // 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( );
+
// Configure camera
vtkCamera* camera = renderer->GetActiveCamera( );
if( camera == NULL )
return;
// Parallel projections are better when displaying 2D images
- int axis = this->GetAxis( );
- camera->ParallelProjectionOn( );
- camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
- if( axis == 0 )
+ if( force_style )
{
- camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
- }
- else if( axis == 1 )
- {
- camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
- camera->SetViewUp ( double( 0 ), double( 0 ), double( -1 ) );
- }
- else // if( axis == 2 )
- {
- camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
- camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+ int axis = this->GetAxis( );
+ camera->ParallelProjectionOn( );
+ camera->SetFocalPoint( double( 0 ), double( 0 ), double( 0 ) );
+ if( axis == 0 )
+ {
+ camera->SetPosition( double( 1 ), double( 0 ), double( 0 ) );
+ camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+ }
+ else if( axis == 1 )
+ {
+ camera->SetPosition( double( 0 ), double( 1 ), double( 0 ) );
+ camera->SetViewUp ( double( 0 ), double( 0 ), double( -1 ) );
+ }
+ else // if( axis == 2 )
+ {
+ camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
+ camera->SetViewUp ( double( 0 ), double( 1 ), double( 0 ) );
+
+ } // fi
} // fi
renderer->ResetCamera( );
-
- // 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( );
+ rwi->Render( );
} // fi
}
void cpExtensions::Visualization::ImageSliceActors::
PopActorsFrom( vtkRenderWindow* window )
{
- /*
- unsigned int N = this->GetNumberOfImageActors( );
- for( unsigned int n = 0; n < N; ++n )
- renderer->RemoveActor( this->GetImageActor( n ) );
- renderer->RemoveActor( this->GetTextActor( ) );
- renderer->RemoveActor( this->GetPlaneActor( ) );
- renderer->Modified( );
- */
+ vtkRenderWindowInteractor* rwi = window->GetInteractor( );
+ vtkRenderer* renderer = window->GetRenderers( )->GetFirstRenderer( );
+
+ 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( );
+
+ } // fi
}
// -------------------------------------------------------------------------
points->SetPoint( 1, 0, 0, 0 );
points->SetPoint( 2, 0, 0, 0 );
points->SetPoint( 3, 0, 0, 0 );
+ points->SetPoint( 4, 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( );
if( this->SliceMappers.size( ) == 0 )
return;
+ // Get ordered axes
int a0 = this->GetAxis( );
int a1 = ( a0 + 1 ) % 3;
int a2 = ( a0 + 2 ) % 3;
+ int ma0 = a0 << 1;
+ int ma1 = a1 << 1;
+ int ma2 = a2 << 1;
double bounds[ 6 ];
- this->SliceMappers[ 0 ]->GetBounds( bounds );
+ this->SliceMappers[ 0 ]->GetInput( )->GetBounds( bounds );
+
+ double
+ p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ],
+ p4[ 3 ], p5[ 3 ], p6[ 3 ], p7[ 3 ];
- double p0[ 3 ], p1[ 3 ], p2[ 3 ], p3[ 3 ];
- p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = pos[ a0 ];
- p0[ a2 ] = p1[ a2 ] = pos[ a2 ];
- p2[ a1 ] = p3[ a1 ] = pos[ a1 ];
- p0[ a1 ] = bounds[ a1 << 1 ];
- p1[ a1 ] = bounds[ ( a1 << 1 ) + 1 ];
- p2[ a2 ] = bounds[ a2 << 1 ];
- p3[ a2 ] = bounds[ ( a2 << 1 ) + 1 ];
+ p0[ a2 ] = p1[ a2 ] = p4[ a2 ] = p5[ a2 ] = pos[ a2 ];
+ p2[ a1 ] = p3[ a1 ] = p6[ a1 ] = p7[ a1 ] = pos[ a1 ];
+ p0[ a0 ] = p1[ a0 ] = p2[ a0 ] = p3[ a0 ] = bounds[ ma0 ];
+ p4[ a0 ] = p5[ a0 ] = p6[ a0 ] = p7[ a0 ] = bounds[ ma0 + 1 ];
+ p0[ a1 ] = p4[ a1 ] = bounds[ ma1 ];
+ p1[ a1 ] = p5[ a1 ] = bounds[ ma1 + 1 ];
+ p2[ a2 ] = p6[ a2 ] = bounds[ ma2 ];
+ p3[ a2 ] = p7[ a2 ] = bounds[ ma2 + 1 ];
vtkPoints* points = this->Cursor->GetPoints( );
points->SetPoint( 0, p0 );
points->SetPoint( 1, p1 );
points->SetPoint( 2, p2 );
points->SetPoint( 3, p3 );
+ points->SetPoint( 4, p4 );
+ points->SetPoint( 5, p5 );
+ points->SetPoint( 6, p6 );
+ points->SetPoint( 7, p7 );
this->Cursor->Modified( );
this->CursorMapper->Modified( );
this->CursorActor->Modified( );
}
+// -------------------------------------------------------------------------
+vtkImageMapToColors* cpExtensions::Visualization::ImageSliceActors::
+GetImageMap( unsigned int id )
+{
+ if( id < this->ImageMaps.size( ) )
+ return( this->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( ) );
+ else
+ return( NULL );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetWindow( unsigned int id ) const
+{
+ if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+ {
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->ImageMaps[ id ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ return( lut->GetWindow( ) );
+ else
+ return( double( 0 ) );
+ }
+ else
+ return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetLevel( unsigned int id ) const
+{
+ if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+ {
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->ImageMaps[ id ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ return( lut->GetLevel( ) );
+ else
+ return( double( 0 ) );
+ }
+ else
+ return( double( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetWindow( unsigned int id, double w )
+{
+ if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+ {
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->ImageMaps[ id ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ {
+ lut->SetWindow( w );
+ lut->Build( );
+ this->ImageMaps[ id ]->Modified( );
+ this->Modified( );
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetLevel( unsigned int id, double l )
+{
+ if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+ {
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->ImageMaps[ id ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ {
+ lut->SetLevel( l );
+ lut->Build( );
+ this->ImageMaps[ id ]->Modified( );
+ this->Modified( );
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetWindowLevel( unsigned int id, double w, double l )
+{
+ if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+ {
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->ImageMaps[ id ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ {
+ lut->SetWindow( w );
+ lut->SetLevel( l );
+ lut->Build( );
+ this->ImageMaps[ id ]->Modified( );
+ this->UpdateText( w, l );
+ this->Modified( );
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+ResetWindowLevel( unsigned int id )
+{
+}
+
// -------------------------------------------------------------------------
int cpExtensions::Visualization::ImageSliceActors::
GetAxis( ) const
else if( axId == 2 ) axis = 'Z';
int slice = this->GetSliceNumber( );
- vtkImageData* image = this->SliceMappers[ 0 ]->GetInput( );
+ vtkImageData* image;
+ if( this->ImageMaps[ 0 ] != NULL )
+ image =
+ dynamic_cast< vtkImageData* >( this->ImageMaps[ 0 ]->GetInput( ) );
+ else
+ image = this->SliceMappers[ 0 ]->GetInput( );
int ijk[ 3 ];
double pcoords[ 3 ];
: Superclass( ),
Interpolate( false )
{
+ this->Clear( );
+
// Connect this view with a controller
this->Style = vtkSmartPointer< ImageInteractorStyle >::New( );
this->Style->AssociateView( this );
this->Style->SetMouseDoubleClickCommand( Self::_MouseDoubleClickCommand );
this->Style->SetMouseWheelCommand( Self::_MouseWheelCommand );
this->Style->SetKeyCommand( Self::_KeyCommand );
-
- this->Clear( );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+_ConfigureNewLUT( vtkImageData* data, LUTType lut_t )
+{
+ static const double _0 = double( 0 );
+ static const double _1 = double( 1 );
+ static const double _2 = double( 2 );
+ static const double _4 = double( 4 );
+ static const double _6 = double( 6 );
+ static const double _OPACITY = double( 0.6 );
+
+ // Configure LUT
+ vtkSmartPointer< vtkImageMapToColors > new_map( NULL );
+ if( data->GetNumberOfScalarComponents( ) == 1 )
+ {
+ double range[ 2 ];
+ data->GetScalarRange( range );
+ if( lut_t == Self::LUTType_WindowLevel )
+ {
+ vtkSmartPointer< vtkWindowLevelLookupTable > lut =
+ vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
+ lut->SetScaleToLinear( );
+ lut->SetTableRange( range );
+ lut->SetWindow( range[ 1 ] - range[ 0 ] );
+ lut->SetLevel( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) );
+ lut->Build( );
+
+ new_map = vtkSmartPointer< vtkImageMapToColors >::New( );
+ new_map->SetLookupTable( lut );
+ }
+ else if( lut_t == LUTType_Colors )
+ {
+ // Get HSV from display color
+ double r = 1, g = 0, b = 0;
+ double cmax = ( r > g )? r: g; cmax = ( b > cmax )? b: cmax;
+ double cmin = ( r < g )? r: g; cmin = ( b < cmin )? b: cmin;
+ double d = cmax - cmin;
+
+ double saturation = ( std::fabs( cmax ) > _0 )? d / cmax: _0;
+ double value = cmax;
+ double hue = _0;
+ if( d > _0 )
+ {
+ if( r == cmax )
+ hue = std::fmod( ( g - b ) / d, _6 );
+ else if( g == cmax )
+ hue = ( ( b - r ) / d ) + _2;
+ else if( b == cmax )
+ hue = ( ( r - g ) / d ) + _4;
+ hue *= _1 / _6;
+
+ } // fi
+
+ // Define new lookup table
+ vtkSmartPointer< vtkLookupTable > lut =
+ vtkSmartPointer< vtkLookupTable >::New( );
+ lut->SetScaleToLinear( );
+ lut->SetNanColor( _0, _0, _0, _0 );
+ lut->SetTableRange( range[ 0 ], range[ 1 ] );
+ lut->SetAlphaRange( _0, _OPACITY );
+ lut->SetHueRange( _0, hue );
+ lut->SetSaturationRange( _0, saturation );
+ lut->SetValueRange( _0, value );
+ lut->Build( );
+
+ new_map = vtkSmartPointer< vtkImageMapToColors >::New( );
+ new_map->SetLookupTable( lut );
+
+ } // fi
+
+ } // fi
+ this->ImageMaps.push_back( new_map );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
_ConfigureNewInput( int axis )
}
else if( btn == ImageInteractorStyle::ButtonID_Right )
{
+ if( !alt && !ctr && sft )
+ {
+ double bounds[ 6 ];
+ actors->SliceMappers[ 0 ]->GetBounds( bounds );
+
+ int a0 = actors->GetAxis( );
+ int a1 = ( a0 + 1 ) % 3;
+ int a2 = ( a0 + 2 ) % 3;
+ double dx = pos[ a1 ] - actors->StartWindowLevelPos[ a1 ];
+ double dy = pos[ a2 ] - actors->StartWindowLevelPos[ a2 ];
+ dx /= bounds[ ( a1 << 1 ) + 1 ] - bounds[ a1 << 1 ];
+ dy /= bounds[ ( a2 << 1 ) + 1 ] - bounds[ a2 << 1 ];
+
+ dx *= actors->StartWindowLevel[ 0 ];
+ dy *= actors->StartWindowLevel[ 1 ];
+ actors->SetWindowLevel(
+ 0,
+ actors->StartWindowLevel[ 0 ] + dx,
+ actors->StartWindowLevel[ 1 ] + dy
+ );
+
+ } // fi
+
} // fi
}
bool alt, bool ctr, bool sft
)
{
+ ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data );
+ if( actors == NULL )
+ return;
+
+ actors->StartWindowLevelPos[ 0 ] = pos[ 0 ];
+ actors->StartWindowLevelPos[ 1 ] = pos[ 1 ];
+ actors->StartWindowLevelPos[ 2 ] = pos[ 2 ];
+ actors->StartWindowLevel[ 0 ] = actors->GetWindow( 0 );
+ actors->StartWindowLevel[ 1 ] = actors->GetLevel( 0 );
}
// -------------------------------------------------------------------------
#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkImageActor.h>
+#include <vtkImageMapToColors.h>
#include <vtkImageSliceMapper.h>
#include <vtkPlane.h>
#include <vtkPolyData.h>
public:
vtkTypeMacro( ImageSliceActors, vtkPropCollection );
+ enum LUTType
+ {
+ LUTType_None = 0,
+ LUTType_WindowLevel,
+ LUTType_Colors
+ };
+
public:
// Creation
static ImageSliceActors* New( );
- void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
- void AddInputData( vtkImageData* data, int axis = 2 );
+ void AddInputConnection(
+ vtkAlgorithmOutput* aout,
+ int axis = 2,
+ LUTType lut = Self::LUTType_None
+ );
+ void AddInputData(
+ vtkImageData* data,
+ int axis = 2,
+ LUTType lut = Self::LUTType_None );
void Clear( );
vtkInteractorStyle* GetStyle( );
const vtkInteractorStyle* GetStyle( ) const;
- void PushActorsInto( vtkRenderWindow* window );
+ void PushActorsInto( vtkRenderWindow* window, bool force_style = true );
void PopActorsFrom( vtkRenderWindow* window );
unsigned int GetNumberOfImageActors( ) const;
vtkImageActor* GetImageActor( unsigned int id );
void ResetCursor( );
void SetCursor( double pos[ 3 ] );
+ vtkImageMapToColors* GetImageMap( unsigned int id );
+ const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
+
+ double GetWindow( unsigned int id ) const;
+ double GetLevel( unsigned int id ) const;
+ void SetWindow( unsigned int id, double w );
+ void SetLevel( unsigned int id, double l );
+ void SetWindowLevel( unsigned int id, double w, double l );
+ void ResetWindowLevel( unsigned int id );
+
int GetAxis( ) const;
int GetSliceNumber( ) const;
int GetSliceNumberMinValue( ) const;
ImageSliceActors( );
virtual ~ImageSliceActors( );
+ void _ConfigureNewLUT( vtkImageData* data, LUTType lut_t );
void _ConfigureNewInput( int axis );
// Events
vtkSmartPointer< ImageInteractorStyle > Style;
// Multiple actors
+ std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
std::vector< vtkSmartPointer< vtkImageActor > > ImageActors;
bool Interpolate;
char TextBuffer[ 1024 ];
vtkSmartPointer< vtkTextActor > TextActor;
vtkSmartPointer< vtkActor > PlaneActor;
+
+ double StartWindowLevelPos[ 3 ];
+ double StartWindowLevel[ 2 ];
};
} // ecapseman
#include <cpExtensions/Visualization/MPRActors.h>
-#include <cmath>
-
-#include <vtkAlgorithmOutput.h>
#include <vtkImageData.h>
-#include <vtkInformation.h>
-#include <vtkLookupTable.h>
-#include <vtkOutlineSource.h>
-#include <vtkProperty.h>
#include <vtkRenderer.h>
-#include <vtkWindowLevelLookupTable.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderWindow.h>
// -------------------------------------------------------------------------
cpExtensions::Visualization::MPRActors*
// -------------------------------------------------------------------------
int cpExtensions::Visualization::MPRActors::
-AddInputConnection( vtkAlgorithmOutput* aout )
+AddInputConnection(
+ vtkAlgorithmOutput* aout, ImageSliceActors::LUTType lut
+ )
{
- int N = this->ImageMaps.size( );
+ int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
if( N == 0 )
{
- this->ImageMaps.push_back(
- vtkSmartPointer< vtkImageMapToColors >::New( )
- );
- this->ImageMaps[ 0 ]->SetInputConnection( aout );
- this->SetLookupTableToWindowLevel( 0 );
- this->_Update( 0 );
- this->ResetWindowLevel( 0 );
- return( 0 );
+ this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0, lut );
+ vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
+ for( unsigned int i = 0; i < 2; ++i )
+ for( unsigned int j = 0; j < 3; ++j )
+ if( i != 0 || j != 0 )
+ this->Slices[ i ][ j ]->AddInputConnection(
+ ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j,
+ ImageSliceActors::LUTType_None
+ );
}
else
{
+ /*
// Check if the image share the same space
vtkImageData* ref_image = this->_Image( 0 );
vtkImageData* new_image =
return( N );
}
else
- return( -1 );
+ N = -1;
+ */
} // fi
+ return( N );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::MPRActors::
-AddInputData( vtkImageData* image )
+AddInputData( vtkImageData* image, ImageSliceActors::LUTType lut )
{
+ int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
+ if( N == 0 )
+ {
+ this->Slices[ 0 ][ 0 ]->AddInputData( image, 0, lut );
+ vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
+ for( unsigned int i = 0; i < 2; ++i )
+ for( unsigned int j = 0; j < 3; ++j )
+ if( i != 0 || j != 0 )
+ {
+ if( imap != NULL )
+ this->Slices[ i ][ j ]->AddInputConnection(
+ imap->GetOutputPort( ), j,
+ ImageSliceActors::LUTType_None
+ );
+ else
+ this->Slices[ i ][ j ]->AddInputData(
+ image, j,
+ ImageSliceActors::LUTType_None
+ );
+ } // fi
+ }
+ else
+ {
+ } // fi
+ return( N );
+ /*
int N = this->ImageMaps.size( );
if( N == 0 )
{
return( -1 );
} // fi
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
-PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
+PushActorsInto(
+ vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z,
+ vtkRenderWindow* w
+ )
{
- vtkRenderer* rends[] = { x, y, z };
+ this->Slices[ 0 ][ 0 ]->PushActorsInto( x, true );
+ this->Slices[ 0 ][ 1 ]->PushActorsInto( y, true );
+ this->Slices[ 0 ][ 2 ]->PushActorsInto( z, true );
+
+ vtkRenderer* wren =
+ ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
+ vtkRenderer* rends[ ] =
+ {
+ ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL,
+ ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL,
+ ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL
+ };
for( int i = 0; i < 3; ++i )
{
if( rends[ i ] != NULL )
- {
- for(
- unsigned int k = 0;
- k < this->Slices[ 0 ][ i ]->GetNumberOfImageActors( );
- ++k
- )
- rends[ i ]->AddActor( this->Slices[ 0 ][ i ]->GetImageActor( k ) );
- rends[ i ]->AddActor( this->Slices[ 0 ][ i ]->GetTextActor( ) );
for( int j = 0; j < 3; ++j )
- rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
-
- } // fi
- if( w != NULL )
+ if( i != j )
+ rends[ i ]->AddActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
+ if( wren != NULL )
{
for(
unsigned int k = 0;
k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
++k
)
- w->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
- w->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
+ wren->AddActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
+ wren->AddActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
} // fi
} // rof
- if( w != NULL )
- w->AddActor( this->ImageOutlineActor );
+ if( wren != NULL )
+ wren->AddActor( this->ImageOutlineActor );
}
// -------------------------------------------------------------------------
vtkRenderer* w
)
{
+ /*
vtkRenderer* rends[] = { x, y, z };
for( int i = 0; i < 3; ++i )
{
} // rof
if( w != NULL )
w->RemoveActor( this->ImageOutlineActor );
+ */
}
// -------------------------------------------------------------------------
+ /*
void cpExtensions::Visualization::MPRActors::
LinkInteractors( )
{
this->_Update( 1 );
this->_Update( 2 );
}
+ */
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
{
+ /*
if( i < this->ImageMaps.size( ) )
{
this->ImageMaps[ i ]->SetLookupTable( lut );
this->Modified( );
} // fi
+ */
}
// -------------------------------------------------------------------------
vtkScalarsToColors* cpExtensions::Visualization::MPRActors::
GetLookupTable( unsigned int i ) const
{
+ /*
if( i < this->ImageMaps.size( ) )
return( this->ImageMaps[ i ]->GetLookupTable( ) );
else
return( NULL );
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
SetLookupTableToWindowLevel( unsigned int i )
{
+ /*
// Check if the input has been configured
vtkImageData* image = this->_Image( i );
if( image == NULL )
lut->Build( );
this->SetLookupTable( i, lut );
+ */
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
GetMaxWindow( unsigned int i ) const
{
+ /*
// Check if the input has been configured
vtkImageData* image = this->_Image( i );
if( image == NULL )
double r[ 2 ];
image->GetScalarRange( r );
return( r[ 1 ] - r[ 0 ] );
+ */
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
GetMinLevel( unsigned int i ) const
{
+ /*
// Check if the input has been configured
vtkImageData* image = this->_Image( i );
if( image == NULL )
double r[ 2 ];
image->GetScalarRange( r );
return( r[ 0 ] );
+ */
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
GetMaxLevel( unsigned int i ) const
{
+ /*
// Check if the input has been configured
vtkImageData* image = this->_Image( i );
if( image == NULL )
double r[ 2 ];
image->GetScalarRange( r );
return( r[ 1 ] );
+ */
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
GetWindow( unsigned int i ) const
{
+ /*
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
return( lut->GetWindow( ) );
else
return( double( 0 ) );
+ */
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
GetLevel( unsigned int i ) const
{
+ /*
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
return( lut->GetLevel( ) );
else
return( double( 0 ) );
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
SetWindow( unsigned int i, const double& w )
{
+ /*
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
this->Modified( );
} // fi
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
SetLevel( unsigned int i, const double& l )
{
+ /*
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
this->Modified( );
} // fi
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
SetWindowLevel( unsigned int i, const double& w, const double& l )
{
+ /*
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
if( lut != NULL )
this->Modified( );
} // fi
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
ResetWindowLevel( unsigned int i )
{
+ /*
vtkImageData* image = this->_Image( i );
vtkWindowLevelLookupTable* lut =
dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
this->Modified( );
} // fi
+ */
}
// -------------------------------------------------------------------------
unsigned int i, const double& r, const double& g, const double& b
)
{
+ /*
static const double _0 = double( 0 );
static const double _1 = double( 1 );
static const double _2 = double( 2 );
else if( b == cmax )
hue = ( ( r - g ) / d ) + _4;
hue *= _1 / _6;
-
+
} // fi
// Define new lookup table
vtkSmartPointer< vtkLookupTable > lut =
vtkSmartPointer< vtkLookupTable >::New( );
lut->SetScaleToLinear( );
- /*
- lut->SetAboveRangeColor( _0, _0, _0, _0 );
- lut->SetBelowRangeColor( _0, _0, _0, _0 );
- */
lut->SetNanColor( _0, _0, _0, _0 );
lut->SetTableRange( range[ 0 ], range[ 1 ] );
lut->SetAlphaRange( _0, _OPACITY );
lut->Build( );
this->SetLookupTable( i, lut );
+ */
}
// -------------------------------------------------------------------------
vtkImageData* cpExtensions::Visualization::MPRActors::
_Image( unsigned int i ) const
{
+ /*
if( i < this->ImageMaps.size( ) )
{
vtkAlgorithm* algo = this->ImageMaps[ i ]->GetInputAlgorithm( );
);
}
else
- return( NULL );
+ */
+ return( NULL );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
_Update( unsigned int i )
{
+ /*
// Check if the input has been configured
vtkImageData* image = this->_Image( i );
if( image == NULL )
this->AddItem( this->ImageOutlineActor );
} // fi
+ */
}
// eof - $RCSfile$
#include <cpExtensions/cpExtensions_Export.h>
#include <cpExtensions/Visualization/ImageSliceActors.h>
+/*
#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkImageMapToColors.h>
+*/
// -------------------------------------------------------------------------
+/*
class vtkAlgorithmOutput;
class vtkImageData;
class vtkRenderer;
class vtkScalarsToColors;
+*/
// -------------------------------------------------------------------------
namespace cpExtensions
ImageSliceActors* GetSliceActors( const int& i ) const;
- int AddInputConnection( vtkAlgorithmOutput* aout );
- int AddInputData( vtkImageData* image );
+ int AddInputConnection(
+ vtkAlgorithmOutput* aout,
+ ImageSliceActors::LUTType lut = ImageSliceActors::LUTType_WindowLevel
+ );
+ int AddInputData(
+ vtkImageData* image,
+ ImageSliceActors::LUTType lut = ImageSliceActors::LUTType_WindowLevel
+ );
- void PushDataInto(
- vtkRenderer* x,
- vtkRenderer* y,
- vtkRenderer* z,
- vtkRenderer* w
+ void PushActorsInto(
+ vtkRenderWindow* x,
+ vtkRenderWindow* y,
+ vtkRenderWindow* z,
+ vtkRenderWindow* w
);
void PopDataFrom(
vtkRenderer* x,
vtkRenderer* z,
vtkRenderer* w
);
- void LinkInteractors( );
// Lookup table methods
void SetLookupTable( unsigned int i, vtkScalarsToColors* lut );
Self& operator=( const Self& );
protected:
- std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
+ // TODO: std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
vtkSmartPointer< vtkActor > ImageOutlineActor;
vtkSmartPointer< ImageSliceActors > Slices[ 2 ][ 3 ];
};
SetImage( vtkImageData* image )
{
this->m_MPRActors->AddInputData( image );
- this->m_MPRActors->PushDataInto(
- this->m_Renderers[ 0 ],
- this->m_Renderers[ 1 ],
- this->m_Renderers[ 2 ],
- this->m_Renderers[ 3 ]
+ this->m_MPRActors->PushActorsInto(
+ this->m_Windows[ 0 ],
+ this->m_Windows[ 1 ],
+ this->m_Windows[ 2 ],
+ this->m_Windows[ 3 ]
);
// First rendering
return;
// Push everything on renderers
- this->m_MPRActors->PushDataInto(
- this->m_Renderers[ 0 ],
- this->m_Renderers[ 1 ],
- this->m_Renderers[ 2 ],
- this->m_Renderers[ 3 ]
+ this->m_MPRActors->PushActorsInto(
+ this->m_Windows[ 0 ],
+ this->m_Windows[ 1 ],
+ this->m_Windows[ 2 ],
+ this->m_Windows[ 3 ]
);
// Rendering
} // rof
// Finish interactor linking
- this->m_MPRActors->LinkInteractors( );
+ // TODO: this->m_MPRActors->LinkInteractors( );
// Restart rendering
this->ResetCameras( );
inline std::string cpPlugins::BasicFilters::BinaryErodeImageFilter::
_RealGD( itk::DataObject* image )
{
- //typedef itk::Image<I, I::ImageDimension> ImageType;
- typedef itk::BinaryBallStructuringElement< I::PixelType, I::ImageDimension> StructuringElementType;
+ //typedef itk::Image<I, I::ImageDimension> ImageType;
+ typedef itk::BinaryBallStructuringElement< typename I::PixelType, I::ImageDimension> StructuringElementType;
typedef itk::BinaryErodeImageFilter< I, O, StructuringElementType > _F;
typedef typename _F::RadiusType _RT;
rad_val.Fill( this->m_Parameters.GetValueAsUint( "Radius" ) );
// Configure filter
-
+
StructuringElementType structuringElement;
structuringElement.SetRadius(rad_val);
structuringElement.CreateStructuringElement();
BinaryErodeImageFilter,
cpPluginsInterfaceImageToImageFilter
);
- cpPlugins_Id_Macro(
- cpPlugins::BasicFilters::BinaryErodeImageFilter,
- "ImageToImageFilter"
- );
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::BinaryErodeImageFilter,
+ "ImageToImageFilter"
+ );
protected:
BinaryErodeImageFilter( );