#ifdef cpExtensions_QT4
-#include <cpExtensions/QT/SimpleMPRWidget.h>
#include <cpExtensions/QT/ImageWidget.h>
+#include <cpExtensions/Visualization/WindowLevelImageActor.h>
#include <cpPlugins/Interface/Workspace.h>
#include <QApplication>
#include <QHBoxLayout>
#include <vtkImageData.h>
+#include <vtkPolyData.h>
-
-#include <vtkImageTracerWidget.h>
-#include <vtkSmartPointer.h>
-#include <vtkGlyphSource2D.h>
-#include <vtkProp.h>
-
+/* TODO
+ #include <vtkImageTracerWidget.h>
+ #include <vtkSplineWidget.h>
+ #include <vtkSmartPointer.h>
+ #include <vtkGlyphSource2D.h>
+ #include <vtkProp.h>
+*/
#endif // cpExtensions_QT4
_TWorkspace::Pointer ws = _TWorkspace::New( );
ws->PrintExecutionOn( );
- // Configure reader
+ // Configure filters
auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
+ auto widget = ws->CreateFilter( "Widgets", "SplineWidget", "spline" );
+ ws->Connect( "reader", "spline", "Output", "Input" );
auto params = reader->GetParameters( );
for( int i = 1; i < argc; ++i )
params->AddToOpenFileNameList( "FileNames", argv[ i ] );
} // yrt
- vtkSmartPointer< vtkImageTracerWidget > itw;
-
- // Configure viewer
- auto image = reader->GetOutputData< vtkImageData >( "Output" );
- auto dim = image->GetDataDimension( );
- switch( dim )
- {
- case 2: case 3:
- {
- // Qt initialization
- QApplication app( argc, argv );
- QMainWindow wnd;
- wnd.setGeometry( 0, 0, 1024, 768 );
-
- // Create main widget
- QWidget* wdg = NULL;
- if( dim == 2 )
- {
- auto view = new cpExtensions::QT::ImageWidget( &wnd );
- view->SetImage( image, 2, "image" );
- view->SetQuadrant( 2 );
- view->SetImageOpacity( 0.5 );
- wdg = view;
-
- itw = vtkSmartPointer< vtkImageTracerWidget >::New( );
- itw->SetCaptureRadius(1.5);
- itw->GetGlyphSource()->SetColor(1, 0, 0);
- itw->GetGlyphSource()->SetScale(3.0);
- itw->GetGlyphSource()->SetRotationAngle(45.0);
- itw->GetGlyphSource()->Modified();
- itw->ProjectToPlaneOn();
- itw->SetProjectionNormalToZAxes();
- itw->SetProjectionPosition(
- (
- view->GetImageActor( )->GetBounds( )[ 4 ] +
- view->GetImageActor( )->GetBounds( )[ 5 ]
- ) / double( 2 )
- );
- itw->SetViewProp( view->GetImageActor( ) );
- itw->SetInputData( image );
- itw->SetInteractor( view->GetInteractor( ) );
- itw->PlaceWidget( );
- itw->SnapToImageOn( );
- itw->AutoCloseOn( );
-
- /* TODO
- vtkSmartPointer< vtkSplineWidget > isw =
- vtkSmartPointer< vtkSplineWidget >::New( );
- isw.SetCurrentRenderer(ren2)
- isw.SetDefaultRenderer(ren2)
- isw.SetInputConnection(extract.GetOutputPort())
- isw.SetInteractor(iren)
- bnds = imageActor2.GetBounds()
- isw.PlaceWidget(bnds[0], bnds[1], bnds[2], bnds[3], bnds[4], bnds[5])
- isw.ProjectToPlaneOn()
- isw.SetProjectionNormalToXAxes()
- isw.SetProjectionPosition(pos)
- */
-
- itw->On( );
- }
- else
- {
- auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
- view->SetImage( image, "image" );
- wdg = view;
-
- } // fi
-
- // Start application and show data
- wnd.setCentralWidget( wdg );
- wnd.show( );
- return( app.exec( ) );
- }
- break;
- default:
- {
- std::cerr << "Unmanaged dimension." << std::endl;
- return( 1 );
- }
- break;
-
- } // hctiws
+ // Qt initialization
+ QApplication app( argc, argv );
+ QMainWindow wnd;
+ wnd.setGeometry( 0, 0, 1024, 768 );
+ cpExtensions::QT::ImageWidget view( &wnd );
+ view.SetImage(
+ reader->GetOutputData< vtkImageData >( "Output" ), 2, "image"
+ );
+ widget->AddInteractor( view.GetInteractor( ) );
+ widget->Update( );
+
+ // Start application and show data
+ wnd.setCentralWidget( &view );
+ wnd.show( );
+ int r = app.exec( );
+ widget->Modified( );
+ widget->Update( );
+ widget->GetOutputData< vtkPolyData >( "Output" )->Print( std::cout );
+ return( r );
#else // cpExtensions_QT4
return( 0 );
#endif // cpExtensions_QT4
}
else
{
- /* TODO
- auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
- view->SetImage( image, "image" );
- wdg = view;
- */
+ auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
+ view->SetImage( image, "image" );
+ wdg = view;
} // fi
+#include <cpExtensions/Utility.h>
#include <cpExtensions/Interaction/ImageSliceStyle.h>
#include <cpExtensions/Visualization/CursorActors.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
#include <vtkPropCollection.h>
#include <vtkPropPicker.h>
#include <vtkRenderer.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
+#include <sstream>
+
/* TODO
#include <cpExtensions/Visualization/ImageViewerActors.h>
*/
return( new Self( ) );
}
+// -------------------------------------------------------------------------
+int cpExtensions::Interaction::ImageSliceStyle::
+GetSliceNumber( ) const
+{
+ if( this->m_WLActor.GetPointer( ) != NULL )
+ return( this->m_WLActor->GetSliceNumber( ) );
+ else
+ return( -1 );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Interaction::ImageSliceStyle::
+GetOrientation( ) const
+{
+ if( this->m_WLActor.GetPointer( ) != NULL )
+ return( this->m_WLActor->GetOrientation( ) );
+ else
+ return( -1 );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Interaction::ImageSliceStyle::
OnMouseMove( )
if( this->_PickPointOnImageActor( idx, pnt ) )
{
this->m_Cursor->SetCursor( pnt, false );
+ this->_ShowText( pnt );
if( !cursor_visible )
{
this->m_Cursor->VisibilityOn( );
+ this->m_Text->VisibilityOn( );
cursor_visible = true;
} // fi
if( cursor_visible )
{
this->m_Cursor->VisibilityOff( );
+ this->m_Text->VisibilityOff( );
cursor_visible = false;
this->Interactor->Render( );
} // fi
- this->Superclass::OnMouseMove( );
+ this->Overclass::OnMouseMove( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageSliceStyle::
+OnMouseWheelForward( )
+{
+ static int s = 0;
+ if( this->m_WLActor.GetPointer( ) == NULL )
+ return;
+ s = this->m_WLActor->GetSliceNumber( );
+ s += ( this->Interactor->GetShiftKey( ) == 1 )? 10: 1;
+ this->m_WLActor->SetSliceNumber( s );
+ s = this->m_WLActor->GetSliceNumber( );
+ this->InvokeEvent( vtkCommand::UserEvent + 2, &s );
+ this->Interactor->Render( );
+ this->OnMouseMove( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageSliceStyle::
+OnMouseWheelBackward( )
+{
+ static int s = 0;
+ if( this->m_WLActor.GetPointer( ) == NULL )
+ return;
+ s = this->m_WLActor->GetSliceNumber( );
+ s -= ( this->Interactor->GetShiftKey( ) == 1 )? 10: 1;
+ this->m_WLActor->SetSliceNumber( s );
+ s = this->m_WLActor->GetSliceNumber( );
+ this->InvokeEvent( vtkCommand::UserEvent + 2, &s );
+ this->Interactor->Render( );
+ this->OnMouseMove( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageSliceStyle::
+OnChar( )
+{
+ switch( this->Interactor->GetKeyCode( ) )
+ {
+ case 'r': case 'R':
+ {
+ this->FindPokedRenderer(
+ this->Interactor->GetEventPosition( )[ 0 ],
+ this->Interactor->GetEventPosition( )[ 1 ]
+ );
+ this->CurrentRenderer->ResetCamera( );
+ this->Interactor->Render( );
+ }
+ break;
+ default:
+ break;
+
+ } // hctiws
}
/* TODO
this->m_Cursor->VisibilityOff( );
this->m_Cursor->GetProperty( 0 )->SetColor( 1, 1, 0 );
this->m_Cursor->GetProperty( 1 )->SetColor( 1, 1, 0 );
+
+ // Prepare text
+ this->m_TextBuffer[ 0 ] = '\0';
+ this->m_Text = vtkSmartPointer< vtkTextActor >::New( );
+ this->m_Text->SetTextScaleModeToNone( );
+ auto textprop = this->m_Text->GetTextProperty( );
+ textprop->SetColor( 1, 1, 0 );
+ textprop->SetFontFamilyToCourier( );
+ textprop->SetFontSize( 12 );
+ textprop->BoldOff( );
+ textprop->ItalicOff( );
+ textprop->ShadowOff( );
+ textprop->SetJustificationToLeft( );
+ textprop->SetVerticalJustificationToBottom( );
+ auto coord = this->m_Text->GetPositionCoordinate( );
+ coord->SetCoordinateSystemToNormalizedViewport( );
+ coord->SetValue( 0.01, 0.02 );
+ this->m_Text->VisibilityOff( );
}
// -------------------------------------------------------------------------
{
}
-// -------------------------------------------------------------------------
-vtkProp* cpExtensions::Interaction::ImageSliceStyle::
-_ImageActor( int i )
-{
- if( !this->CurrentRenderer )
- return( NULL );
-
- vtkPropCollection* props = this->CurrentRenderer->GetViewProps( );
- vtkProp* prop = 0;
- vtkAssemblyPath* path;
- vtkImageSlice* imageProp = NULL;
- vtkCollectionSimpleIterator pit;
-
- for( int k = 0; k < 2; k++ )
- {
- int j = 0;
- for( props->InitTraversal( pit ); ( prop = props->GetNextProp( pit ) ); )
- {
- bool foundImageProp = false;
- for( prop->InitPathTraversal( ); ( path = prop->GetNextPath( ) ); )
- {
- vtkProp* tryProp = path->GetLastNode( )->GetViewProp( );
- if( ( imageProp = vtkImageSlice::SafeDownCast( tryProp ) ) != 0 )
- {
- if( j == i )
- {
- foundImageProp = true;
- break;
-
- } // fi
- imageProp = 0;
- j++;
-
- } // fi
-
- } // rof
- if( foundImageProp )
- break;
- } // rof
- if( i < 0 )
- i += j;
-
- } // rof
- return( imageProp );
-}
-
// -------------------------------------------------------------------------
bool cpExtensions::Interaction::ImageSliceStyle::
_PickPointOnImageActor( int idx[ 2 ], double pnt[ 3 ] )
this->m_Cursor->InitTraversal( );
while( vtkProp* prop = this->m_Cursor->GetNextProp( ) )
this->CurrentRenderer->AddViewProp( prop );
+ this->CurrentRenderer->AddViewProp( this->m_Text );
} // fi
if( this->m_WLActor.GetPointer( ) == NULL )
return( true );
}
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageSliceStyle::
+_CorrectPosition( double pos[ 3 ], int ijk[ 3 ] )
+{
+ if( this->m_WLActor.GetPointer( ) == NULL )
+ return;
+ auto image = this->m_WLActor->GetImage( );
+ if( image == NULL )
+ return;
+
+ // Approximate image index
+ double pcoords[ 3 ];
+ image->ComputeStructuredCoordinates( pos, ijk, pcoords );
+
+ // Manually correct index
+ int ext[ 6 ];
+ image->GetExtent( ext );
+ for( int i = 0; i < 3; ++i )
+ {
+ if( ijk[ i ] < ext[ i << 1 ] )
+ ijk[ i ] = ext[ i << 1 ];
+ if( ext[ ( i << 1 ) + 1 ] < ijk[ i ] )
+ ijk[ i ] = ext[ ( i << 1 ) + 1 ];
+
+ } // rof
+
+ // Get real coordinates
+ int o = this->m_WLActor->GetOrientation( );
+ ijk[ o ] = this->m_WLActor->GetSliceNumber( );
+ image->GetPoint( image->ComputePointId( ijk ), pos );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageSliceStyle::
+_ShowText( double pos[ 3 ] )
+{
+ if( this->m_WLActor.GetPointer( ) == NULL )
+ return;
+ auto image = this->m_WLActor->GetImage( );
+ if( image == NULL )
+ return;
+
+ int ijk[ 3 ];
+ this->_CorrectPosition( pos, ijk );
+ int o = this->m_WLActor->GetOrientation( );
+
+ std::stringstream buffer;
+ buffer << "Axis: " << char( 'X' + char( o ) ) << std::endl;
+ int nScl = image->GetNumberOfScalarComponents( );
+ buffer
+ << "Pixel: [" << ijk[ 0 ]
+ << "," << ijk[ 1 ]
+ << "," << ijk[ 2 ] << "] = < "
+ << image->GetScalarComponentAsFloat( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 );
+ for( int n = 1; n < nScl; ++n )
+ buffer
+ << " : "
+ << image->GetScalarComponentAsFloat( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], n );
+ buffer << " >" << std::endl;
+ buffer
+ << "Point: ("
+ << pos[ 0 ] << ", " << pos[ 1 ] << ", " << pos[ 2 ]
+ << ")";
+ cpExtensions_SPRINTF( this->m_TextBuffer, 1024, buffer.str( ).c_str( ) );
+ this->m_Text->SetInput( this->m_TextBuffer );
+ this->m_Text->VisibilityOn( );
+ this->m_Text->Modified( );
+}
+
// eof - $RCSfile$
// -------------------------------------------------------------------------
class vtkPropPicker;
+class vtkTextActor;
// -------------------------------------------------------------------------
namespace cpExtensions
public:
vtkTypeMacro( ImageSliceStyle, vtkInteractorStyleImage );
+ typedef vtkInteractorStyleImage::Superclass Overclass;
public:
static Self* New( );
+ int GetSliceNumber( ) const;
+ int GetOrientation( ) const;
+
virtual void OnMouseMove( ) cpExtensions_OVERRIDE;
+ virtual void OnMouseWheelForward( ) cpExtensions_OVERRIDE;
+ virtual void OnMouseWheelBackward( ) cpExtensions_OVERRIDE;
+ virtual void OnChar( ) cpExtensions_OVERRIDE;
+
/* TODO
cpExtensions::Visualization::ImageViewerActors* GetActors( );
// Events
virtual void OnMouseMove( ) cpExtensions_OVERRIDE;
- virtual void OnMouseWheelForward( ) cpExtensions_OVERRIDE;
- virtual void OnMouseWheelBackward( ) cpExtensions_OVERRIDE;
virtual void OnChar( ) cpExtensions_OVERRIDE;
*/
ImageSliceStyle( );
virtual ~ImageSliceStyle( );
- virtual vtkProp* _ImageActor( int i );
- virtual bool _PickPointOnImageActor( int idx[ 2 ], double pnt[ 3 ] );
+ bool _PickPointOnImageActor( int idx[ 2 ], double pnt[ 3 ] );
+ void _CorrectPosition( double pos[ 3 ], int ijk[ 3 ] );
+ void _ShowText( double pos[ 3 ] );
private:
// Purposely not implemented
protected:
vtkSmartPointer< vtkPropPicker > m_PropPicker;
- vtkSmartPointer< TWLActor > m_WLActor;
- vtkSmartPointer< TCursor > m_Cursor;
- /* TODO
- vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors > m_Actors;
- */
+ vtkSmartPointer< TWLActor > m_WLActor;
+ vtkSmartPointer< TCursor > m_Cursor;
+ vtkSmartPointer< vtkTextActor > m_Text;
+ char m_TextBuffer[ 1024 ];
};
} // ecapseman
#ifdef cpExtensions_QT4
#include <cpExtensions/Interaction/ImageSliceStyle.h>
-#include <cpExtensions/Visualization/ImageOutlineActor.h>
+#include <cpExtensions/Visualization/MeshActor.h>
+#include <cpExtensions/Visualization/OutlineSource.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
+#include <vtkCamera.h>
+#include <vtkImageData.h>
+#include <vtkProperty.h>
#include <vtkRenderer.h>
/* TODO
#include <cpExtensions/Visualization/ImageViewerActors.h>
#include <cpExtensions/Visualization/LUTImageActor.h>
- #include <vtkCamera.h>
#include <vtkImageData.h>
#include <vtkImageProperty.h>
*/
cpExtensions::QT::ImageWidget::
ImageWidget( QWidget* parent, Qt::WindowFlags f )
: Superclass( parent, f ),
- m_ImageName( "" )
+ m_ImageName( "" ),
+ m_OutlineActor( NULL )
{
this->m_Style = vtkSmartPointer< TStyle >::New( );
this->m_Style->SetCurrentRenderer( this->m_Renderer );
cpExtensions::QT::ImageWidget::
~ImageWidget( )
{
+ if( this->m_OutlineActor != NULL )
+ delete this->m_OutlineActor;
}
// -------------------------------------------------------------------------
this->m_WLActor->SetImage( image );
this->m_WLActor->SetOrientation( orientation );
- this->m_OLActor = vtkSmartPointer< TOLActor >::New( );
- this->m_OLActor->SetBounds(
- orientation,
- this->m_WLActor->GetBounds( )[ orientation ],
- this->m_WLActor->GetBounds( )
- );
+ this->m_Outline = vtkSmartPointer< TOutline >::New( );
+ this->m_Outline->SetBounds( image->GetBounds( ) );
+ this->m_Outline->Update( );
+
+ if( this->m_OutlineActor != NULL )
+ delete this->m_OutlineActor;
+ this->m_OutlineActor = new TActor( );
+ this->m_OutlineActor->SetMesh( this->m_Outline->GetOutput( ) );
+
+ double cr = double( 0 );
+ double cg = double( 0 );
+ double cb = double( 0 );
+ switch( this->m_WLActor->GetOrientation( ) )
+ {
+ case 0: cr = double( 1 ); break;
+ case 1: cg = double( 1 ); break;
+ case 2: cb = double( 1 ); break;
+ default: cr = double( 1 ); break;
+ } // hctiws
+ this->m_OutlineActor->GetActor( )->GetProperty( )->SetColor( cr, cg, cb );
this->AddViewProp( this->m_WLActor, this->m_ImageName );
- this->AddAuxViewProp( this->m_OLActor, this->m_ImageName );
+ this->AddAuxViewProp( this->m_OutlineActor->GetActor( ), this->m_ImageName );
this->ResetCamera( );
}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::ImageWidget::
+ResetCamera( )
+{
+ if( this->m_WLActor.GetPointer( ) != NULL )
+ {
+ auto image = this->m_WLActor->GetImage( );
+ if( image != NULL )
+ {
+ double bounds[ 6 ];
+ image->GetBounds( bounds );
+
+ // Compute camera properties
+ double center[ 3 ];
+ center[ 0 ] = ( bounds[ 1 ] + bounds[ 0 ] ) / double( 2 );
+ center[ 1 ] = ( bounds[ 3 ] + bounds[ 2 ] ) / double( 2 );
+ center[ 2 ] = ( bounds[ 5 ] + bounds[ 4 ] ) / double( 2 );
+
+ int ori = this->m_WLActor->GetOrientation( );
+ double pos[ 3 ] = { double( 0 ) };
+ pos[ ori ] = double( 1 );
+ pos[ 0 ] += center[ 0 ];
+ pos[ 1 ] += center[ 1 ];
+ pos[ 2 ] += center[ 2 ];
+
+ double up[ 3 ] = { double( 0 ) };
+ if( ori == 0 )
+ {
+ if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
+ }
+ else if( ori == 1 )
+ {
+ if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
+ else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
+ }
+ else if( ori == 2 )
+ {
+ if ( this->m_Quadrant == 0 ) up[ 1 ] = double( 1 );
+ else if( this->m_Quadrant == 1 ) up[ 1 ] = double( 1 );
+ else if( this->m_Quadrant == 2 ) up[ 1 ] = double( 1 );
+ else if( this->m_Quadrant == 3 ) up[ 1 ] = double( 1 );
+ pos[ 2 ] *= double( -1 );
+
+ } // fi
+
+ // Reconfigure camera and return
+ auto camera = this->m_Renderer->GetActiveCamera( );
+ camera->ParallelProjectionOn( );
+ camera->SetFocalPoint( center );
+ camera->SetPosition( pos );
+ camera->SetViewUp( up );
+ this->m_Renderer->ResetCamera( bounds );
+ }
+ else
+ this->Superclass::ResetCamera( );
+ }
+ else
+ this->Superclass::ResetCamera( );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::ImageWidget::
+TWLActor* cpExtensions::QT::ImageWidget::
+GetImageActor( )
+{
+ return( this->m_WLActor );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::QT::ImageWidget::
+TWLActor* cpExtensions::QT::ImageWidget::
+GetImageActor( ) const
+{
+ return( this->m_WLActor );
+}
+
/* TODO
// -------------------------------------------------------------------------
this->Render( );
}
-// -------------------------------------------------------------------------
-void cpExtensions::QT::ImageWidget::
-ResetCamera( )
-{
- if( this->m_ImageViewerActors.GetPointer( ) != NULL )
- {
- auto image = this->m_ImageViewerActors->GetImage( );
- if( image != NULL )
- {
- double bounds[ 6 ];
- image->GetBounds( bounds );
-
- // Compute camera properties
- double center[ 3 ];
- center[ 0 ] = ( bounds[ 1 ] + bounds[ 0 ] ) / double( 2 );
- center[ 1 ] = ( bounds[ 3 ] + bounds[ 2 ] ) / double( 2 );
- center[ 2 ] = ( bounds[ 5 ] + bounds[ 4 ] ) / double( 2 );
-
- int ori = this->m_ImageViewerActors->GetOrientation( );
- double pos[ 3 ] = { double( 0 ) };
- pos[ ori ] = double( 1 );
- pos[ 0 ] += center[ 0 ];
- pos[ 1 ] += center[ 1 ];
- pos[ 2 ] += center[ 2 ];
-
- double up[ 3 ] = { double( 0 ) };
- if( ori == 0 )
- {
- if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
- }
- else if( ori == 1 )
- {
- if ( this->m_Quadrant == 0 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 1 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 2 ) up[ 2 ] = double( 1 );
- else if( this->m_Quadrant == 3 ) up[ 2 ] = double( 1 );
- }
- else if( ori == 2 )
- {
- if ( this->m_Quadrant == 0 ) up[ 1 ] = double( 1 );
- else if( this->m_Quadrant == 1 ) up[ 1 ] = double( 1 );
- else if( this->m_Quadrant == 2 ) up[ 1 ] = double( 1 );
- else if( this->m_Quadrant == 3 ) up[ 1 ] = double( 1 );
- pos[ 2 ] *= double( -1 );
-
- } // fi
-
- // Reconfigure camera and return
- auto camera = this->m_Renderer->GetActiveCamera( );
- camera->SetFocalPoint( center );
- camera->SetPosition( pos );
- camera->SetViewUp( up );
- this->m_Renderer->ResetCamera( bounds );
- }
- else
- this->Superclass::ResetCamera( );
- }
- else
- this->Superclass::ResetCamera( );
-}
-
// -------------------------------------------------------------------------
void cpExtensions::QT::ImageWidget::
GetScalarRange( double r[ 2 ] ) const
{
namespace Visualization
{
- class ImageOutlineActor;
+ class OutlineSource;
class WindowLevelImageActor;
+ class MeshActor;
/* TODO
class ImageSliceActors;
class ImageViewerActors;
typedef ImageWidget Self;
typedef RendererWidget Superclass;
- typedef cpExtensions::Visualization::ImageOutlineActor TOLActor;
+ typedef cpExtensions::Visualization::OutlineSource TOutline;
+ typedef cpExtensions::Visualization::MeshActor TActor;
typedef cpExtensions::Visualization::WindowLevelImageActor TWLActor;
typedef cpExtensions::Interaction::ImageSliceStyle TStyle;
void SetImage(
vtkImageData* image, int orientation, const std::string& name
);
+ virtual void ResetCamera( ) cpExtensions_OVERRIDE;
+
+ TWLActor* GetImageActor( );
+ const TWLActor* GetImageActor( ) const;
/* TODO
void SetImage(
int GetOrientation( ) const;
void SetSliceNumber( int slice );
- virtual void ResetCamera( ) cpExtensions_OVERRIDE;
void GetScalarRange( double r[ 2 ] ) const;
void GetWindowLevel( double wl[ 2 ] ) const;
std::string m_ImageName;
vtkSmartPointer< TWLActor > m_WLActor;
- vtkSmartPointer< TOLActor > m_OLActor;
+ vtkSmartPointer< TOutline > m_Outline;
+ TActor* m_OutlineActor;
vtkSmartPointer< TStyle > m_Style;
#ifdef cpExtensions_QT4
#include <cpExtensions/Visualization/ImageOutlineActor.h>
-#include <cpExtensions/Visualization/MPR3DActors.h>
-#include <cpExtensions/Visualization/LUTImageActor.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
-#include <vtkActor.h>
#include <vtkImageData.h>
-#include <vtkPolyData.h>
+#include <vtkPlane.h>
+
+/* TODO
+ #include <cpExtensions/Visualization/MPR3DActors.h>
+ #include <cpExtensions/Visualization/LUTImageActor.h>
+
+ #include <vtkActor.h>
+ #include <vtkPolyData.h>
+*/
// -------------------------------------------------------------------------
cpExtensions::QT::MPR3DWidget::
: Superclass( parent, f ),
m_ImageName( "" )
{
- this->m_Actors =
- vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( );
+ /* TODO
+ this->m_Actors =
+ vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( );
+ */
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::MPR3DWidget::
+Clear( )
+{
+ this->RemoveViewProps( );
+ this->m_ImageName = "";
+}
+
// -------------------------------------------------------------------------
void cpExtensions::QT::MPR3DWidget::
SetImage( vtkImageData* image, const std::string& name )
+{
+ if( name == "" )
+ return;
+ if( this->m_ImageName != "" )
+ this->Clear( );
+ this->m_ImageName = name;
+
+ for( unsigned int o = 0; o < 3; ++o )
+ {
+ this->m_WLActors[ o ] = vtkSmartPointer< TWLActor >::New( );
+ this->m_WLActors[ o ]->SetImage( image );
+ this->m_WLActors[ o ]->SetOrientation( o );
+
+ this->m_OLActors[ o ] = vtkSmartPointer< TOLActor >::New( );
+ this->m_OLActors[ o ]->SetBounds(
+ o, image->GetBounds( )[ o << 1 ], image->GetBounds( )
+ );
+
+ this->AddViewProp( this->m_WLActors[ o ], this->m_ImageName );
+ this->AddAuxViewProp( this->m_OLActors[ o ], this->m_ImageName );
+ this->ResetCamera( );
+
+ } // rof
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::MPR3DWidget::
+TWLActor* cpExtensions::QT::MPR3DWidget::
+GetImageActor( int o )
+{
+ return( this->m_WLActors[ o % 3 ] );
+}
+
+// -------------------------------------------------------------------------
+const cpExtensions::QT::MPR3DWidget::
+TWLActor* cpExtensions::QT::MPR3DWidget::
+GetImageActor( int o ) const
+{
+ return( this->m_WLActors[ o % 3 ] );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::MPR3DWidget::
+SetSliceNumber( int orientation, int slice )
+{
+ int o = orientation % 3;
+ this->m_WLActors[ o ]->SetSliceNumber( slice );
+ this->m_OLActors[ o ]->SetBounds(
+ o,
+ this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ],
+ this->m_WLActors[ o ]->GetImage( )->GetBounds( )
+ );
+ this->Render( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::MPR3DWidget::
+SetSlicesNumbers( int x, int y, int z )
+{
+ int s[] = { x, y, z };
+ for( int o = 0; o < 3; ++o )
+ {
+ this->m_WLActors[ o ]->SetSliceNumber( s[ o ] );
+ this->m_OLActors[ o ]->SetBounds(
+ o,
+ this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ],
+ this->m_WLActors[ o ]->GetImage( )->GetBounds( )
+ );
+
+ } // rof
+ this->Render( );
+}
+
+// -------------------------------------------------------------------------
+/*
+void cpExtensions::QT::MPR3DWidget::
+SetImage( vtkImageData* image, const std::string& name )
{
if( this->m_ImageName != "" )
{
} // fi
- /* TODO
return;
auto image = dynamic_cast< vtkImageData* >( data );
{
} // fi
- */
}
// -------------------------------------------------------------------------
this->m_Actors->SetImageInterpolation( i );
this->Render( );
}
+ */
#endif // cpExtensions_QT4
// -------------------------------------------------------------------------
namespace cpExtensions
{
- namespace Visualization { class MPR3DActors; }
+ namespace Visualization
+ {
+ class ImageOutlineActor;
+ class WindowLevelImageActor;
+ }
namespace QT
{
typedef MPR3DWidget Self;
typedef cpExtensions::QT::RendererWidget Superclass;
+ typedef cpExtensions::Visualization::ImageOutlineActor TOLActor;
+ typedef cpExtensions::Visualization::WindowLevelImageActor TWLActor;
+
public:
explicit MPR3DWidget( QWidget* parent = NULL, Qt::WindowFlags f = 0 );
virtual ~MPR3DWidget( );
+ void Clear( );
void SetImage( vtkImageData* image, const std::string& name );
- void Add( vtkDataSet* data, const std::string& name );
+
+ TWLActor* GetImageActor( int o );
+ const TWLActor* GetImageActor( int o ) const;
void SetSliceNumber( int orientation, int slice );
void SetSlicesNumbers( int x, int y, int z );
- void SetScalarRange( double r[ 2 ] );
- void SetWindowLevel( double wl[ 2 ] );
- void SetImageOpacity( double o );
- void SetImageInterpolation( unsigned char i );
+ /* TODO
+ void SetImage( vtkImageData* image, const std::string& name );
+ void Add( vtkDataSet* data, const std::string& name );
+
+
+ void SetScalarRange( double r[ 2 ] );
+ void SetWindowLevel( double wl[ 2 ] );
+ void SetImageOpacity( double o );
+ void SetImageInterpolation( unsigned char i );
+ */
protected:
- vtkSmartPointer< cpExtensions::Visualization::MPR3DActors > m_Actors;
std::string m_ImageName;
+
+ vtkSmartPointer< TWLActor > m_WLActors[ 3 ];
+ vtkSmartPointer< TOLActor > m_OLActors[ 3 ];
+
+ /* TODO
+ vtkSmartPointer< cpExtensions::Visualization::MPR3DActors > m_Actors;
+ std::string m_ImageName;
+ */
};
} // ecapseman
void cpExtensions::QT::MPRInteractionCommand::
AddWidget( QWidget* w )
{
- /*
- typedef cpExtensions::QT::ImageWidget _TImageWidget;
- typedef cpExtensions::QT::MPR3DWidget _TMPR3DWidget;
+ typedef cpExtensions::QT::ImageWidget _TImageWidget;
+ typedef cpExtensions::QT::MPR3DWidget _TMPR3DWidget;
- auto img = dynamic_cast< _TImageWidget* >( w );
- auto ren = dynamic_cast< _TMPR3DWidget* >( w );
- if( img != NULL )
+ auto img = dynamic_cast< _TImageWidget* >( w );
+ auto ren = dynamic_cast< _TMPR3DWidget* >( w );
+ if( img != NULL )
this->m_ImageWidgets.insert( img );
- else if( ren != NULL )
+ else if( ren != NULL )
this->m_MPR3DWidgets.insert( ren );
- */
}
// -------------------------------------------------------------------------
void cpExtensions::QT::MPRInteractionCommand::
Execute( vtkObject* caller, unsigned long evId, void* data )
{
- /*
typedef cpExtensions::Interaction::ImageSliceStyle _TStyle;
static const unsigned long _SuperCursor = vtkCommand::UserEvent + 1;
return;
if( evId == _SuperCursor )
{
- auto ori = src->GetActors( )->GetOrientation( );
- auto img = src->GetActors( )->GetImage( );
- auto pos = reinterpret_cast< double* >( data );
- int ijk[ 3 ];
- double pcoords[ 3 ];
- img->ComputeStructuredCoordinates( pos, ijk, pcoords );
+ /* TODO
+ auto ori = src->GetActors( )->GetOrientation( );
+ auto img = src->GetActors( )->GetImage( );
+ auto pos = reinterpret_cast< double* >( data );
+ int ijk[ 3 ];
+ double pcoords[ 3 ];
+ img->ComputeStructuredCoordinates( pos, ijk, pcoords );
- for(
- auto i = this->m_ImageWidgets.begin( );
- i != this->m_ImageWidgets.end( );
- ++i
- )
- if( ( *i )->GetInteractorStyle( ) != src )
- ( *i )->SetSliceNumber( ijk[ ( *i )->GetOrientation( ) ] );
+ for(
+ auto i = this->m_ImageWidgets.begin( );
+ i != this->m_ImageWidgets.end( );
+ ++i
+ )
+ if( ( *i )->GetInteractorStyle( ) != src )
+ ( *i )->SetSliceNumber( ijk[ ( *i )->GetOrientation( ) ] );
- for(
- auto r = this->m_MPR3DWidgets.begin( );
- r != this->m_MPR3DWidgets.end( );
- ++r
- )
- ( *r )->SetSlicesNumbers( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ] );
+ for(
+ auto r = this->m_MPR3DWidgets.begin( );
+ r != this->m_MPR3DWidgets.end( );
+ ++r
+ )
+ ( *r )->SetSlicesNumbers( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ] );
+ */
}
else if( evId == _Slice )
{
- auto slice = *( reinterpret_cast< int* >( data ) );
- auto ori = src->GetActors( )->GetOrientation( );
+ int slc = src->GetSliceNumber( );
+ int ori = src->GetOrientation( );
for(
auto r = this->m_MPR3DWidgets.begin( );
r != this->m_MPR3DWidgets.end( );
++r
)
- ( *r )->SetSliceNumber( ori, slice );
-
+ ( *r )->SetSliceNumber( ori, slc );
+
} // fi
- */
}
// -------------------------------------------------------------------------
m_UI( new Ui::SimpleMPRWidget ),
m_MainImageName( "" )
{
-/*
this->m_UI->setupUi( this );
// Prepare default configuration
cmd->AddWidget( this->m_YImage );
cmd->AddWidget( this->m_ZImage );
cmd->AddWidget( this->m_3DView );
- this->m_XImage->GetInteractorStyle( )->AddObserver( ev1, cmd );
- this->m_YImage->GetInteractorStyle( )->AddObserver( ev1, cmd );
- this->m_ZImage->GetInteractorStyle( )->AddObserver( ev1, cmd );
- this->m_XImage->GetInteractorStyle( )->AddObserver( ev2, cmd );
- this->m_YImage->GetInteractorStyle( )->AddObserver( ev2, cmd );
- this->m_ZImage->GetInteractorStyle( )->AddObserver( ev2, cmd );
+ this->m_XImage->GetStyle( )->AddObserver( ev1, cmd );
+ this->m_YImage->GetStyle( )->AddObserver( ev1, cmd );
+ this->m_ZImage->GetStyle( )->AddObserver( ev1, cmd );
+ this->m_XImage->GetStyle( )->AddObserver( ev2, cmd );
+ this->m_YImage->GetStyle( )->AddObserver( ev2, cmd );
+ this->m_ZImage->GetStyle( )->AddObserver( ev2, cmd );
// Connect slots
this->connect(
this->m_UI->ConfigurationButton, SIGNAL( clicked( ) ),
this, SLOT( _ConfigurationButton( ) )
);
-*/
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageActor::
SetSliceNumber( int slice )
{
- static int mySlice;
auto image = this->m_Mapper->GetInput( );
if( image != NULL )
{
// Propagate modifications
this->Modified( );
- mySlice = slice;
- this->InvokeEvent( vtkCommand::InteractionEvent, &mySlice );
} // fi
}
--- /dev/null
+#include <cpExtensions/Visualization/OutlineSource.h>
+#include <vtkCellArray.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::OutlineSource::
+Self* cpExtensions::Visualization::OutlineSource::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::OutlineSource::
+OutlineSource( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::OutlineSource::
+~OutlineSource( )
+{
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::OutlineSource::
+RequestData(
+ vtkInformation* request,
+ vtkInformationVector** inputVector,
+ vtkInformationVector* outputVector
+ )
+{
+ int r = this->Superclass::RequestData( request, inputVector, outputVector );
+
+ // Complete polydatas to avoid bizarre rendering errors (multi-thread)
+ vtkInformation *outInfo = outputVector->GetInformationObject( 0 );
+ vtkPolyData *output = vtkPolyData::SafeDownCast(
+ outInfo->Get( vtkDataObject::DATA_OBJECT( ) )
+ );
+ output->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
+ output->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
+ if( this->GenerateFaces != 1 )
+ output->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
+ return( r );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __cpExtensions__Visualization__OutlineSource__h__
+#define __cpExtensions__Visualization__OutlineSource__h__
+
+#include <cpExtensions/Config.h>
+#include <vtkOutlineSource.h>
+
+// -------------------------------------------------------------------------
+namespace cpExtensions
+{
+ namespace Visualization
+ {
+ /**
+ */
+ class cpExtensions_EXPORT OutlineSource
+ : public vtkOutlineSource
+ {
+ public:
+ typedef OutlineSource Self;
+
+ public:
+ vtkTypeMacro( OutlineSource, vtkOutlineSource );
+
+ public:
+ static Self* New( );
+
+ protected:
+ OutlineSource( );
+ virtual ~OutlineSource( );
+
+ virtual int RequestData(
+ vtkInformation* request,
+ vtkInformationVector** inputVector,
+ vtkInformationVector* outputVector
+ ) cpExtensions_OVERRIDE;
+
+ private:
+ // Purposely not implemented
+ OutlineSource( const Self& );
+ Self& operator=( const Self& );
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __cpExtensions__Visualization__OutlineSource__h__
+
+// eof - $RCSfile$
--- /dev/null
+#include <plugins/Widgets/SplineWidget.h>
+#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Mesh.h>
+#include <cpExtensions/Visualization/WindowLevelImageActor.h>
+
+#include <vtkRenderer.h>
+#include <vtkSplineWidget.h>
+
+// -------------------------------------------------------------------------
+cpPluginsWidgets::SplineWidget::
+SplineWidget( )
+ : Superclass( ),
+ m_Configured( false )
+{
+ typedef cpPlugins::BaseObjects::DataObject _TData;
+ typedef cpPlugins::DataObjects::Mesh _TMesh;
+
+ this->_ConfigureInput< _TData >( "Input", false, false );
+ this->_ConfigureOutput< _TMesh >( "Output" );
+ this->m_Contour = vtkSmartPointer< vtkPolyData >::New( );
+ this->m_Contour->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
+ this->m_Contour->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
+ this->m_Contour->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
+ this->m_Contour->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
+ this->m_Contour->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
+ this->GetOutput( "Output" )->SetVTK( this->m_Contour );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsWidgets::SplineWidget::
+~SplineWidget( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsWidgets::SplineWidget::
+_GenerateData( )
+{
+ typedef cpExtensions::Visualization::WindowLevelImageActor _TActor;
+
+ auto image = this->GetInputData< vtkImageData >( "Input" );
+ if( image == NULL )
+ this->_Error( "Invalid input image." );
+ if( this->m_Interactors.size( ) == 0 )
+ this->_Error( "Give at least one interactor." );
+
+ auto wdg = this->_CreateVTK< vtkSplineWidget >( );
+ if( this->m_Configured )
+ {
+ wdg->GetPolyData( this->m_Contour.GetPointer( ) );
+ wdg->Off( );
+ }
+ else
+ {
+ auto iIt = this->m_Interactors.begin( );
+ vtkRenderWindowInteractor* iren = NULL;
+ vtkRenderer* ren = NULL;
+ _TActor* actor = NULL;
+ 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 a = dynamic_cast< _TActor* >( prop );
+ if( a != NULL )
+ if( a->GetImage( ) == image )
+ {
+ iren = *iIt;
+ actor = a;
+ ren = r;
+
+ } // fi
+
+ } // elihw
+
+ } // fi
+
+ } // fi
+
+ } // rof
+ if( actor == NULL || ren == NULL || iren == NULL )
+ this->_Error( "Invalid actor and/or renderer." );
+
+ // Widget configuration
+ wdg->SetCurrentRenderer( ren );
+ wdg->SetDefaultRenderer( ren );
+ wdg->SetInputData( image );
+ wdg->SetProp3D( actor );
+ wdg->SetInteractor( iren );
+ double bnds[ 6 ];
+ image->GetBounds( bnds );
+ wdg->PlaceWidget(
+ bnds[ 0 ], bnds[ 1 ],
+ bnds[ 2 ], bnds[ 3 ],
+ bnds[ 4 ], bnds[ 5 ]
+ );
+ wdg->ProjectToPlaneOn( );
+ wdg->SetProjectionNormalToZAxes( );
+ wdg->SetProjectionPosition(
+ (
+ actor->GetBounds( )[ 4 ] +
+ actor->GetBounds( )[ 5 ]
+ ) / double( 2 )
+ );
+ wdg->SetHandleSize( 0.005 );
+ wdg->SetNumberOfHandles( 3 );
+ wdg->On( );
+ this->m_Configured = true;
+
+ } // fi
+
+ /* TODO
+
+ if( this->m_Configured )
+ {
+ if( points->GetNumberOfPoints( ) == 0 )
+ {
+ std::stringstream text;
+ bool start = true;
+ for( auto w = this->m_Widgets.begin( ); w != this->m_Widgets.end( ); ++w )
+ {
+ for( auto r = ( *w )->Widgets.begin( ); r != ( *w )->Widgets.end( ); ++r )
+ {
+ auto rep =
+ dynamic_cast< vtkSeedRepresentation* >(
+ ( *r )->GetRepresentation( )
+ );
+ if( rep != NULL )
+ {
+ double pos[ 3 ];
+ for( unsigned int i = 0; i < rep->GetNumberOfSeeds( ); ++i )
+ {
+ rep->GetSeedWorldPosition( i, pos );
+ if( !start )
+ text << "#";
+ start = false;
+ text << pos[ 0 ] << " " << pos[ 1 ] << " " << pos[ 2 ];
+ points->InsertNextPoint( pos );
+
+ } // rof
+
+ } // rof
+ ( *r )->EnabledOff( );
+
+ } // rof
+
+ } // rof
+ this->m_Parameters.SetString( "Text", text.str( ) );
+
+ } // fi
+ }
+ else
+ {
+ auto init_seeds = this->m_Parameters.GetString( "Text" );
+ std::vector< std::string > tokens;
+ cpExtensions::Tokenize( tokens, init_seeds, "#" );
+ for( auto tIt = tokens.begin( ); tIt != tokens.end( ); ++tIt )
+ {
+ std::vector< std::string > coords;
+ cpExtensions::Tokenize( coords, *tIt, " \t" );
+ int dim = ( coords.size( ) < 3 )? coords.size( ): 3;
+ double pos[ 3 ];
+ for( unsigned int d = 0; d < 3; ++d )
+ {
+ pos[ d ] = double( 0 );
+ if( d < dim )
+ {
+ std::istringstream value( coords[ d ] );
+ value >> pos[ d ];
+
+ } // fi
+
+ } // rof
+ verts->InsertNextCell( 1 );
+ verts->InsertCellPoint( points->GetNumberOfPoints( ) );
+ points->InsertNextPoint( pos );
+
+ } // rof
+ this->_Configure( );
+ this->Modified( );
+ this->m_Configured = true;
+
+ } // fi
+ this->GetOutput( "Output" )->SetVTK( pdata );
+ */
+}
+
+// -------------------------------------------------------------------------
+/* TODO
+void cpPluginsWidgets::SplineWidget::
+_Configure( )
+{
+ typedef cpPlugins::DataObjects::Image _TImage;
+
+ auto image = this->GetInput< _TImage >( "Input" );
+ if( image != NULL )
+ {
+ // Update actors
+ auto vtk_image = image->GetVTK< vtkImageData >( );
+ auto iIt = this->m_Interactors.begin( );
+ for( ; iIt != this->m_Interactors.end( ); ++iIt )
+ {
+ auto ren = ( *iIt )->GetInteractorStyle( )->GetCurrentRenderer( );
+ if( ren != NULL )
+ {
+ auto props = ren->GetViewProps( );
+ if( props != NULL )
+ {
+ props->InitTraversal( );
+ while( vtkProp* prop = props->GetNextProp( ) )
+ {
+ auto actor = dynamic_cast< TImageActor* >( prop );
+ if( actor != NULL )
+ if( actor->GetImage( ) == vtk_image )
+ this->m_Props[ actor ] = *iIt;
+
+ } // elihw
+
+ } // fi
+
+ } // fi
+
+ } // rof
+
+ // Process image
+ if( this->m_Props.size( ) > 0 )
+ {
+ cpPlugins_Demangle_ImageVisualDims( image->GetITK( ), _GD0_Image );
+ else this->_Error( "Invalid input image." );
+ }
+ else
+ this->_Error( "Could not create a valid widget: no actors." );
+ }
+ else
+ this->_Error( "Could not create a valid widget: no input." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsWidgets::SplineWidget::
+_GD0_Image( _TImage* image )
+{
+ for( auto p = this->m_Props.begin( ); p != this->m_Props.end( ); ++p )
+ {
+ TWidgetData* d =
+ new TWidgetData(
+ this, dynamic_cast< TImageActor* >( p->first ), p->second
+ );
+ this->m_Widgets.push_back( d );
+
+ } // rof
+}
+
+// -------------------------------------------------------------------------
+cpPluginsWidgets::SplineWidget::TWidgetData::
+TWidgetData(
+ SplineWidget* seedWidget,
+ TImageActor* actor,
+ vtkRenderWindowInteractor* iren
+ )
+{
+ auto cb = vtkSmartPointer< SplineWidgetCallback >::New( );
+ cb->Widget = seedWidget;
+ cb->Data = this;
+ this->Command = cb;
+ actor->AddObserver( vtkCommand::InteractionEvent, cb );
+
+ auto image = actor->GetImage( );
+ int ori = actor->GetOrientation( );
+ int ext[ 6 ];
+ image->GetExtent( ext );
+ for( int i = ext[ ori << 1 ]; i <= ext[ ( ori << 1 ) + 1 ]; ++i )
+ {
+ auto placer = vtkSmartPointer< _TPlacer >::New( );
+ auto handle = vtkSmartPointer< vtkPointHandleRepresentation3D >::New( );
+ auto rep = vtkSmartPointer< vtkSeedRepresentation >::New( );
+ auto wdg = vtkSmartPointer< _TWidget >::New( );
+
+ placer->SetImageSlice( actor );
+ handle->GetProperty( )->SetColor( 1, 0, 0 );
+ handle->SetPointPlacer( placer );
+ rep->SetHandleRepresentation( handle );
+ wdg->SetRepresentation( rep );
+ wdg->SetInteractor( iren );
+ wdg->AddObserver( vtkCommand::PlacePointEvent, cb );
+ wdg->AddObserver( vtkCommand::CursorChangedEvent, cb );
+ wdg->EnabledOff( );
+
+ this->Widgets.push_back( wdg );
+ this->Placers.push_back( placer );
+ this->Handles.push_back( handle );
+ this->Representations.push_back( rep );
+
+ } // rof
+
+ this->ActualWidgetId = actor->GetSliceNumber( );
+ this->Widgets[ this->ActualWidgetId ]->EnabledOn( );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsWidgets::SplineWidget::TWidgetData::
+~TWidgetData( )
+{
+}
+*/
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __cpPluginsWidgets__SplineWidget__h__
+#define __cpPluginsWidgets__SplineWidget__h__
+
+#include <plugins/cpPluginsWidgets_Export.h>
+#include <cpPlugins/BaseObjects/Widget.h>
+
+#include <vtkSmartPointer.h>
+
+/* TODO
+ #include <cpExtensions/Interaction/SplineWidget.h>
+ #include <cpExtensions/Interaction/ImageSlicePointPlacer.h>
+ #include <cpExtensions/Visualization/WindowLevelImageActor.h>
+ #include <vtkImageSlice.h>
+ #include <vtkPointHandleRepresentation3D.h>
+ #include <vtkSeedRepresentation.h>
+ #include <map>
+*/
+
+// -------------------------------------------------------------------------
+class vtkPolyData;
+
+// -------------------------------------------------------------------------
+namespace cpPluginsWidgets
+{
+ /**
+ */
+ class cpPluginsWidgets_EXPORT SplineWidget
+ : public cpPlugins::BaseObjects::Widget
+ {
+ cpPluginsObject( SplineWidget, cpPlugins::BaseObjects::Widget, Widgets );
+
+ protected:
+ bool m_Configured;
+ vtkSmartPointer< vtkPolyData > m_Contour;
+
+ /* TODO:
+ public:
+ typedef cpExtensions::Visualization::WindowLevelImageActor TImageActor;
+
+ public:
+ struct TWidgetData
+ {
+ typedef cpExtensions::Interaction::SplineWidget _TWidget;
+ typedef cpExtensions::Interaction::ImageSlicePointPlacer _TPlacer;
+
+ std::vector< vtkSmartPointer< _TWidget > > Widgets;
+ std::vector< vtkSmartPointer< _TPlacer > > Placers;
+ std::vector< vtkSmartPointer< vtkPointHandleRepresentation3D > > Handles;
+ std::vector< vtkSmartPointer< vtkSeedRepresentation > > Representations;
+ unsigned int ActualWidgetId;
+ vtkSmartPointer< vtkCommand > Command;
+
+ TWidgetData(
+ SplineWidget* seedWidget,
+ TImageActor* actor,
+ vtkRenderWindowInteractor* iren
+ );
+ virtual ~TWidgetData( );
+ };
+
+ protected:
+ void _Configure( );
+
+ template< class _TImage >
+ inline void _GD0_Image( _TImage* image );
+
+ protected:
+ std::map< vtkProp*, vtkRenderWindowInteractor* > m_Props;
+ std::vector< TWidgetData* > m_Widgets;
+ bool m_Configured;
+ */
+ };
+
+} // ecapseman
+
+#endif // __cpPluginsWidgets__SplineWidget__h__
+
+// eof - $RCSfile$