]> Creatis software - creaMaracasVisu.git/blob - appli/QtVTKViewer/qtvtkviewer.cxx
76778d49b1f9ff32253aa41941de821fba1a601e
[creaMaracasVisu.git] / appli / QtVTKViewer / qtvtkviewer.cxx
1
2 //----------------------------------------------------------------------
3 //              File:                   ann_sample.cpp
4 //              Programmer:             Sunil Arya and David Mount
5 //              Last modified:  03/04/98 (Release 0.1)
6 //              Description:    Sample program for ANN
7 //----------------------------------------------------------------------
8 // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and
9 // David Mount.  All Rights Reserved.
10 //
11 // This software and related documentation is part of the Approximate
12 // Nearest Neighbor Library (ANN).  This software is provided under
13 // the provisions of the Lesser GNU Public License (LGPL).  See the
14 // file ../ReadMe.txt for further information.
15 //
16 // The University of Maryland (U.M.) and the authors make no
17 // representations about the suitability or fitness of this software for
18 // any purpose.  It is provided "as is" without express or implied
19 // warranty.
20 //----------------------------------------------------------------------
21
22 #include "qtvtkviewerwidget.h"
23 #include <QMainWindow>
24 #include <QApplication>
25
26
27
28
29 #include "iostream"
30
31
32 #include "OpenImageDialog.h"
33
34 using namespace std;
35 using namespace creaMaracasVisuKernel;
36
37
38 int main(int argc, char **argv)
39 {
40
41
42
43
44
45
46
47     vtkImageData* img = 0;
48
49     if (argc < 2){
50
51         OpenImageDialog open(true);
52         img = open.getImageData();
53
54         if(img == 0){
55             std::cout << "ERROR: Image filename missing. usage qtvtkviewer <image filename>"
56                       << std::endl ;
57             return EXIT_FAILURE;
58          }
59     }else{
60         std::string inputFilename = argv[1];
61
62         vtkMetaImageReader* reader = vtkMetaImageReader::New();
63         reader->SetFileName(inputFilename.c_str());
64         reader->Update();
65         img = reader->GetOutput();
66
67     }
68
69
70     QApplication app(argc, argv);
71
72
73     QMainWindow* mainwindow = new QMainWindow();
74
75     QtVTKViewerWidget *viewer = new QtVTKViewerWidget(mainwindow);
76
77     mainwindow-> setCentralWidget(viewer);
78
79
80     mainwindow->show();
81
82     viewer->setImage(img);
83     //viewer->SetLookupTable((vtkLookupTable*)colortransfer);
84
85
86
87
88     return app.exec();
89 }
90