All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
main.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of TerraView - A Free and Open Source GIS Application.
4 
5  TerraView is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraView is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib Code Editor. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@dpi.inpe.br>.
18  */
19 
20 /*!
21  \file terraview/main.cpp
22 
23  \brief It contains the main routine of TerraView.
24 */
25 
26 // TerraView
27 #include "TerraView.h"
28 #include "TerraViewConfig.h"
29 
30 // TerraLib
32 
33 // STL
34 #include <cstdlib>
35 #include <exception>
36 
37 // Qt
38 #include <QtCore/QResource>
39 #include <QtGui/QApplication>
40 #include <QtGui/QSplashScreen>
41 #include <QtGui/QMessageBox>
42 
43 #include <locale>
44 
45 int main(int argc, char** argv)
46 {
47  QApplication app(argc, argv);
48 
49  setlocale(LC_ALL,"C");// This force to use "." as decimal separator.
50 
51  //QResource::registerResource(TERRAVIEW_RESOURCE_FILE);
52 
53  int waitVal = EXIT_FAILURE;
54 
55  try
56  {
57  const char* te_env = getenv("TERRALIB_DIR");
58 
59  if(te_env == 0)
60  {
61  QMessageBox::critical(0, QObject::tr("Execution Failure"), QObject::tr("Environment variable \"TERRALIB_DIR\" not found.\nTry to set it before run the application."));
62  throw std::exception();
63  }
64 
65  std::string splash_pix(te_env);
66  splash_pix += "/resources/images/png/terraview-splashscreen.png";
67 
68  QPixmap pixmap(splash_pix.c_str());
69 
70  QSplashScreen* splash(new QSplashScreen(pixmap/*, Qt::WindowStaysOnTopHint*/));
71 
72  splash->setAttribute(Qt::WA_DeleteOnClose, true);
73 
74  splash->setStyleSheet("QWidget { font-size: 12px; font-weight: bold }");
75 
76  te::qt::af::SplashScreenManager::getInstance().set(splash, Qt::AlignBottom | Qt::AlignHCenter, Qt::white);
77 
78  splash->show();
79 
80  TerraView tview;
81 
82  std::string appPath = qApp->applicationDirPath().toStdString();
83 
84  tview.init(appPath+"/config.xml");
85 
86  splash->finish(&tview);
87 
88  tview.showMaximized();
89 
90  tview.resetState();
91 
92  waitVal = app.exec();
93  }
94  catch(const std::exception& /*e*/)
95  {
96  return EXIT_FAILURE;
97  }
98  catch(...)
99  {
100  return EXIT_FAILURE;
101  }
102 
103  return waitVal;
104 }
105 
A singleton for holding he application splash screen.
int main(int argc, char *argv[])
Definition: main.cpp:24
void init()
Definition: TerraView.cpp:52
static SplashScreenManager & getInstance()
It returns a reference to the singleton instance.
The main class of TerraView.
Definition: TerraView.h:54
The main class of TerraView.