1 #include <cpExtensions/Config.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/QT/ImageWidget.h>
6 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
7 #include <cpPlugins/Interface/Workspace.h>
9 #include <QApplication>
11 #include <QMainWindow>
12 #include <QHBoxLayout>
14 #include <vtkImageData.h>
15 #include <vtkPolyData.h>
18 #include <vtkImageTracerWidget.h>
19 #include <vtkSplineWidget.h>
20 #include <vtkSmartPointer.h>
21 #include <vtkGlyphSource2D.h>
25 #endif // cpExtensions_QT4
27 //----------------------------------------------------------------------------
28 int main( int argc, char* argv[] )
30 #ifdef cpExtensions_QT4
35 std::cerr << "Usage: " << argv[ 0 ] << " image_file(s)" << std::endl;
41 cpPlugins::Interface::Plugins::Pointer interface =
42 cpPlugins::Interface::Plugins::New( );
45 interface->LoadEnvironments( );
46 interface->GuessPlugins( );
48 catch( std::exception& err )
50 std::cerr << "Error caught: " << err.what( ) << std::endl;
56 typedef cpPlugins::Interface::Workspace _TWorkspace;
57 _TWorkspace::Pointer ws = _TWorkspace::New( );
58 ws->PrintExecutionOn( );
61 auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
62 auto widget = ws->CreateFilter( "Widgets", "SplineWidget", "spline" );
63 ws->Connect( "reader", "spline", "Output", "Input" );
64 auto params = reader->GetParameters( );
65 for( int i = 1; i < argc; ++i )
66 params->AddToOpenFileNameList( "FileNames", argv[ i ] );
73 catch( std::exception& err )
75 std::cerr << "Error caugth: " << err.what( ) << std::endl;
81 QApplication app( argc, argv );
83 wnd.setGeometry( 0, 0, 1024, 768 );
84 cpExtensions::QT::ImageWidget view( &wnd );
86 reader->GetOutputData< vtkImageData >( "Output" ), 2, "image"
88 widget->AddInteractor( view.GetInteractor( ) );
91 // Start application and show data
92 wnd.setCentralWidget( &view );
97 widget->GetOutputData< vtkPolyData >( "Output" )->Print( std::cout );
99 #else // cpExtensions_QT4
101 #endif // cpExtensions_QT4