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