]> Creatis software - clitk.git/blob - vv/vv.cxx
remove antique RCS headers
[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 #include <utility>
25 #include <cassert>
26 #include <QApplication>
27 #include <QPixmap>
28 #include <QSplashScreen>
29 #include <QTimer>
30 #include <QDesktopWidget>
31
32 #include "clitkCommon.h"
33 #include "vvMainWindow.h"
34 #include "vvInit.h"
35
36 #include "vvConstants.h"
37
38 int main( int argc, char** argv )
39 {
40     initialize_IO();
41
42     QApplication app( argc, argv );
43     Q_INIT_RESOURCE(vvIcons);
44     //QPixmap pixmap(":/splashscreen.PNG");
45     QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
46     /*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));*/
47 //  splash->show();
48     QTimer::singleShot(2000, splash, SLOT(close()));
49     while (!splash->isHidden())
50         app.processEvents();
51
52     vvMainWindow window;
53
54     //Try to give the window a sensible default size
55     int width=QApplication::desktop()->width()*0.8;
56     int height=QApplication::desktop()->height()*0.9;
57     if (width> 1.5*height)
58         width=1.5*height;
59     window.resize(width,height);
60
61     window.show();
62
63     std::vector<std::string> filenames;
64     std::vector<std::pair<int ,std::string> > overlays;
65     std::vector<std::pair<int ,std::string> > vector_fields;
66     if (argc >1)
67     {
68         for (int i = 1; i < argc; i++)
69         {
70             std::string temp = argv[i];
71             if (temp=="--vf")
72             {
73                 assert(filenames.size()>=1);
74                 vector_fields.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
75                 i++; //skip vf name
76             }
77             else if (temp=="--overlay")
78             {
79                 assert(filenames.size()>=1);
80                 overlays.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
81                 i++; //skip overlay name
82             }
83             else
84                 filenames.push_back(temp);
85         }
86         window.LoadImages(filenames,IMAGE);
87         for (std::vector<std::pair<int ,std::string> >::iterator i=overlays.begin();
88              i!=overlays.end();i++)
89           window.AddOverlayImage((*i).first,(*i).second.c_str());
90         for (std::vector<std::pair<int ,std::string> >::iterator i=vector_fields.begin();
91              i!=vector_fields.end();i++)
92           window.AddField((*i).second.c_str(), (*i).first);
93         
94     }
95
96     return app.exec();
97 }