1 #include <cpExtensions/Config.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/QT/SimpleMPRWidget.h>
6 #include <cpExtensions/QT/ImageWidget.h>
7 #include <cpPlugins/Interface/Workspace.h>
9 #include <QApplication>
11 #include <QMainWindow>
12 #include <QHBoxLayout>
14 #include <vtkImageData.h>
16 #endif // cpExtensions_QT4
18 //----------------------------------------------------------------------------
19 int main( int argc, char* argv[] )
21 #ifdef cpExtensions_QT4
22 typedef cpPlugins::Interface::Plugins _TPlugins;
23 typedef cpPlugins::Interface::Workspace _TWorkspace;
28 std::cerr << "Usage: " << argv[ 0 ] << " image_file(s)" << std::endl;
34 _TPlugins::Pointer plugins = _TPlugins::New( );
37 plugins->LoadEnvironments( );
38 plugins->GuessPlugins( );
40 catch( std::exception& err )
42 std::cerr << "Error caught: " << err.what( ) << std::endl;
48 _TWorkspace::Pointer ws = _TWorkspace::New( );
49 ws->PrintExecutionOn( );
52 auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
53 auto params = reader->GetParameters( );
54 for( int i = 1; i < argc; ++i )
55 params->AddToOpenFileNameList( "FileNames", argv[ i ] );
62 catch( std::exception& err )
64 std::cerr << "Error caugth: " << err.what( ) << std::endl;
70 auto image = reader->GetOutputData< vtkImageData >( "Output" );
71 auto dim = image->GetDataDimension( );
77 QApplication app( argc, argv );
79 wnd.setGeometry( 0, 0, 1024, 768 );
85 auto view = new cpExtensions::QT::ImageWidget( &wnd );
86 view->SetImage( image, 2, "image" );
91 auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
92 view->SetImage( image, "image" );
97 // Start application and show data
98 wnd.setCentralWidget( wdg );
100 return( app.exec( ) );
105 std::cerr << "Unmanaged dimension." << std::endl;
111 #else // cpExtensions_QT4
113 #endif // cpExtensions_QT4