1 #include <cpExtensions/Config.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/QT/SimpleMPRWidget.h>
6 #include <cpPlugins/Interface/Workspace.h>
8 #include <QApplication>
10 #include <QMainWindow>
11 #include <QHBoxLayout>
13 #include <vtkImageData.h>
15 #endif // cpExtensions_QT4
17 //----------------------------------------------------------------------------
18 int main( int argc, char* argv[] )
20 #ifdef cpExtensions_QT4
25 std::cerr << "Usage: " << argv[ 0 ] << " image_file(s)" << std::endl;
31 cpPlugins::Interface::Plugins::Pointer interface =
32 cpPlugins::Interface::Plugins::New( );
35 interface->LoadEnvironments( );
36 interface->GuessPlugins( );
38 catch( std::exception& err )
40 std::cerr << "Error caught: " << err.what( ) << std::endl;
46 typedef cpPlugins::Interface::Workspace _TWorkspace;
47 _TWorkspace::Pointer ws = _TWorkspace::New( );
48 ws->PrintExecutionOn( );
51 auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
52 auto params = reader->GetParameters( );
53 for( int i = 1; i < argc; ++i )
54 params->AddToOpenFileNameList( "FileNames", argv[ i ] );
61 catch( std::exception& err )
63 std::cerr << "Error caugth: " << err.what( ) << std::endl;
69 auto image = reader->GetOutputData< vtkImageData >( "Output" );
70 switch( image->GetDataDimension( ) )
80 QApplication app( argc, argv );
82 wnd.setGeometry( 0, 0, 1024, 768 );
85 cpExtensions::QT::SimpleMPRWidget view( &wnd );
86 view.SetImage( image, "image" );
88 // Start application and show data
89 wnd.setCentralWidget( &view );
92 return( app.exec( ) );
97 std::cerr << "Unmanaged dimension." << std::endl;
103 #else // cpExtensions_QT4
105 #endif // cpExtensions_QT4