]> Creatis software - clitk.git/blob - vv/vv.cxx
some small correction
[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   CLITK_INIT;
34
35   QApplication app( argc, argv );
36   Q_INIT_RESOURCE(vvIcons);
37   //QPixmap pixmap(":/splashscreen.PNG");
38   QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
39   /*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));*/
40   //  splash->show();
41   QTimer::singleShot(2000, splash, SLOT(close()));
42   while (!splash->isHidden())
43     app.processEvents();
44
45   vvMainWindow window;
46
47   //Try to give the window a sensible default size
48   int width=QApplication::desktop()->width()*0.8;
49   int height=QApplication::desktop()->height()*0.9;
50   if (width> 1.5*height)
51     width=1.5*height;
52   window.resize(width,height);
53
54   window.show();
55
56   std::vector<std::string> filenames;
57   std::vector<std::pair<int ,std::string> > overlays;
58   std::vector<std::pair<int ,std::string> > rois;
59   std::vector<std::pair<int ,std::string> > vector_fields;
60   if (argc >1) {
61     for (int i = 1; i < argc; i++) {
62       std::string temp = argv[i];
63       if (temp=="--vf") {
64         assert(filenames.size()>=1);
65         vector_fields.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
66         i++; //skip vf name
67       } 
68       else {
69         if (temp=="--overlay") {
70           assert(filenames.size()>=1);
71           overlays.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
72           i++; //skip overlay name
73         } 
74         else {
75           if (temp=="--roi") {
76             assert(filenames.size()>=1);
77             rois.push_back(std::make_pair(filenames.size()-1,argv[i+1]));
78             i++; //skip overlay name
79           } 
80           else {
81             filenames.push_back(temp);
82           }
83         }
84       }
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     for (std::vector<std::pair<int ,std::string> >::iterator i=rois.begin();
94          i!=rois.end(); i++) {
95       DD((*i).second.c_str());
96       DD((*i).first);
97       // window.AddROI((*i).second.c_str(), (*i).first);
98     }
99
100   }
101
102   return app.exec();
103 }