]> Creatis software - clitk.git/blob - vv/vv.cxx
Reformatted using new coding style
[clitk.git] / vv / vv.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #include <utility>
19 #include <cassert>
20 #include <QApplication>
21 #include <QPixmap>
22 #include <QSplashScreen>
23 #include <QTimer>
24 #include <QDesktopWidget>
25
26 #include "clitkIO.h"
27 #include "vvMainWindow.h"
28 #include "vvConstants.h"
29
30 //------------------------------------------------------------------------------
31 int main( int argc, char** argv )
32 {
33 #ifdef _WIN32
34   HWND hWnd = GetConsoleWindow();
35   ShowWindow( hWnd, SW_HIDE );
36 #endif
37
38   CLITK_INIT;
39
40   QApplication app( argc, argv );
41   Q_INIT_RESOURCE(vvIcons);
42   //QPixmap pixmap(":/splashscreen.PNG");
43   QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
44   /*splash->showMessage("VV 1.0 developped by Léon Bérard c`ancer center http://oncora1.lyon.fnclcc.fr and CREATIS-LRMN http://www.creatis.insa-lyon.fr",(Qt::AlignRight | Qt::AlignBottom));*/
45   //  splash->show();
46   QTimer::singleShot(2000, splash, SLOT(close()));
47   while (!splash->isHidden())
48     app.processEvents();
49
50   vvMainWindow window;
51
52   //Try to give the window a sensible default size
53   int width=QApplication::desktop()->width()*0.8;
54   int height=QApplication::desktop()->height()*0.9;
55   if (width> 1.5*height)
56     width=1.5*height;
57   window.resize(width,height);
58
59   window.show();
60
61   std::vector<std::string> filenames;
62   std::vector<std::pair<int ,std::string> > overlays;
63   std::vector<std::pair<int ,std::string> > vector_fields;
64   if (argc >1) {
65     for (int i = 1; i < argc; i++) {
66       std::string temp = argv[i];
67       if (temp=="--vf") {
68         assert(filenames.size()>=1);
69         vector_fields.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
70         i++; //skip vf name
71       } else if (temp=="--overlay") {
72         assert(filenames.size()>=1);
73         overlays.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
74         i++; //skip overlay name
75       } else
76         filenames.push_back(temp);
77     }
78     window.LoadImages(filenames,IMAGE);
79     for (std::vector<std::pair<int ,std::string> >::iterator i=overlays.begin();
80          i!=overlays.end(); i++)
81       window.AddOverlayImage((*i).first,(*i).second.c_str());
82     for (std::vector<std::pair<int ,std::string> >::iterator i=vector_fields.begin();
83          i!=vector_fields.end(); i++)
84       window.AddField((*i).second.c_str(), (*i).first);
85
86   }
87
88   return app.exec();
89 }