]> Creatis software - clitk.git/blob - vv/vv.cxx
removed headers
[clitk.git] / vv / vv.cxx
1 #include <utility>
2 #include <cassert>
3 #include <QApplication>
4 #include <QPixmap>
5 #include <QSplashScreen>
6 #include <QTimer>
7 #include <QDesktopWidget>
8
9 #include "clitkIO.h"
10 #include "vvMainWindow.h"
11 #include "vvConstants.h"
12
13 //------------------------------------------------------------------------------
14 int main( int argc, char** argv )
15 {
16 #ifdef _WIN32
17     HWND hWnd = GetConsoleWindow();
18     ShowWindow( hWnd, SW_HIDE );
19 #endif
20
21     CLITK_INIT;
22
23     QApplication app( argc, argv );
24     Q_INIT_RESOURCE(vvIcons);
25     //QPixmap pixmap(":/splashscreen.PNG");
26     QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
27     /*splash->showMessage("VV 1.0 developped by Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr and CREATIS-LRMN http://www.creatis.insa-lyon.fr",(Qt::AlignRight | Qt::AlignBottom));*/
28     //  splash->show();
29     QTimer::singleShot(2000, splash, SLOT(close()));
30     while (!splash->isHidden())
31         app.processEvents();
32
33     vvMainWindow window;
34
35     //Try to give the window a sensible default size
36     int width=QApplication::desktop()->width()*0.8;
37     int height=QApplication::desktop()->height()*0.9;
38     if (width> 1.5*height)
39         width=1.5*height;
40     window.resize(width,height);
41
42     window.show();
43
44     std::vector<std::string> filenames;
45     std::vector<std::pair<int ,std::string> > overlays;
46     std::vector<std::pair<int ,std::string> > vector_fields;
47     if (argc >1)
48     {
49         for (int i = 1; i < argc; i++)
50         {
51             std::string temp = argv[i];
52             if (temp=="--vf")
53             {
54                 assert(filenames.size()>=1);
55                 vector_fields.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
56                 i++; //skip vf name
57             }
58             else if (temp=="--overlay")
59             {
60                 assert(filenames.size()>=1);
61                 overlays.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
62                 i++; //skip overlay name
63             }
64             else
65                 filenames.push_back(temp);
66         }
67         window.LoadImages(filenames,IMAGE);
68         for (std::vector<std::pair<int ,std::string> >::iterator i=overlays.begin();
69              i!=overlays.end();i++)
70           window.AddOverlayImage((*i).first,(*i).second.c_str());
71         for (std::vector<std::pair<int ,std::string> >::iterator i=vector_fields.begin();
72              i!=vector_fields.end();i++)
73           window.AddField((*i).second.c_str(), (*i).first);
74         
75     }
76
77     return app.exec();
78 }