]> Creatis software - clitk.git/blob - vv/vv.cxx
XVI IO
[clitk.git] / vv / vv.cxx
1 /*=========================================================================
2
3  Program:   vv
4  Language:  C++
5  Author :   Pierre Seroul (pierre.seroul@gmail.com)
6
7 Copyright (C) 2008
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 =========================================================================*/
24
25 #include <utility>
26 #include <cassert>
27 #include <QApplication>
28 #include <QPixmap>
29 #include <QSplashScreen>
30 #include <QTimer>
31 #include <QDesktopWidget>
32
33 #include "clitkIO.h"
34 #include "vvMainWindow.h"
35 #include "vvConstants.h"
36
37 //------------------------------------------------------------------------------
38 int main( int argc, char** argv )
39 {
40 #ifdef _WIN32
41     HWND hWnd = GetConsoleWindow();
42     ShowWindow( hWnd, SW_HIDE );
43 #endif
44
45     CLITK_INIT;
46
47     QApplication app( argc, argv );
48     Q_INIT_RESOURCE(vvIcons);
49     //QPixmap pixmap(":/splashscreen.PNG");
50     QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
51     /*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));*/
52     //  splash->show();
53     QTimer::singleShot(2000, splash, SLOT(close()));
54     while (!splash->isHidden())
55         app.processEvents();
56
57     vvMainWindow window;
58
59     //Try to give the window a sensible default size
60     int width=QApplication::desktop()->width()*0.8;
61     int height=QApplication::desktop()->height()*0.9;
62     if (width> 1.5*height)
63         width=1.5*height;
64     window.resize(width,height);
65
66     window.show();
67
68     std::vector<std::string> filenames;
69     std::vector<std::pair<int ,std::string> > overlays;
70     std::vector<std::pair<int ,std::string> > vector_fields;
71     if (argc >1)
72     {
73         for (int i = 1; i < argc; i++)
74         {
75             std::string temp = argv[i];
76             if (temp=="--vf")
77             {
78                 assert(filenames.size()>=1);
79                 vector_fields.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
80                 i++; //skip vf name
81             }
82             else if (temp=="--overlay")
83             {
84                 assert(filenames.size()>=1);
85                 overlays.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
86                 i++; //skip overlay name
87             }
88             else
89                 filenames.push_back(temp);
90         }
91         window.LoadImages(filenames,IMAGE);
92         for (std::vector<std::pair<int ,std::string> >::iterator i=overlays.begin();
93              i!=overlays.end();i++)
94           window.AddOverlayImage((*i).first,(*i).second.c_str());
95         for (std::vector<std::pair<int ,std::string> >::iterator i=vector_fields.begin();
96              i!=vector_fields.end();i++)
97           window.AddField((*i).second.c_str(), (*i).first);
98         
99     }
100
101     return app.exec();
102 }