#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