-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
147 lines (125 loc) · 4.38 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//##########################################################################
//# #
//# CLOUDCOMPARE #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
//# #
//##########################################################################
#include <ccIncludeGL.h>
//Qt
#include <qapplication.h>
#include <qsplashscreen>
#include <qpixmap>
#include <qmessagebox.h>
#include <qlocale.h>
#include<qtimer.h>
#include<qdatetime.h>
//qCC_db
#include <ccTimer.h>
#include <ccNormalVectors.h>
#include <ccColorScalesManager.h>
//qCC_io
#include <FileIOFilter.h>
#include "mainwindow.h"
#include "ccCommandLineParser.h"
//! QApplication wrapper
class qccApplication : public QApplication
{
public:
qccApplication( int &argc, char **argv )
: QApplication( argc, argv ){
setOrganizationName("CASIA");
setApplicationName("IGITLandscapeViewer");
}
};
int main(int argc, char *argv[]){
//fronts setting
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForTr(codec);
QTextCodec::setCodecForLocale(QTextCodec::codecForLocale());
QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
//QT initialiation5
qccApplication app(argc, argv);
app.addLibraryPath("./imageformats");
//Force 'Chinese' local so as to get a consistent behavior everywhere
QLocale::setDefault(QLocale::Chinese);
//splash screen
QSplashScreen* splash = 0;
QTime splashStartTime;
bool commandLine = (argc>1 && argv[1][0]=='-');
if(!commandLine){
//has openGL??
if(!QGLFormat::hasOpenGL()){
QMessageBox::critical(0, "Error", "This application needs OpenGL to run!");
return EXIT_FAILURE;
}
// splash screen
splashStartTime.start();
QPixmap pixmap(QString::fromUtf8("./images/imLogoV2Qt.png"));
splash = new QSplashScreen(pixmap,Qt::WindowStaysOnTopHint);
splash->show();
QApplication::processEvents();
}
//global structures initialization
ccTimer::Init();
FileIOFilter::InitInternalFilters(); //load all known I/O filters (plugins will come later!)
ccNormalVectors::GetUniqueInstance(); //force pre-computed normals array initialization
ccColorScalesManager::GetUniqueInstance(); //force pre-computed color tables initialization
int result = 0;
if (commandLine){
//command line processing (no GUI)
result = ccCommandLineParser::Parse(argc,argv);
}
else{
//main window init.
MainWindow* mainWindow = MainWindow::TheInstance();
if (!mainWindow){
QMessageBox::critical(0, "Error", "Failed to initialize the main application window?!");
return EXIT_FAILURE;
}
mainWindow->show();
QApplication::processEvents();
}
if(argc >1){
if(splash){
splash->close();
}
//any additional argument is assumed to be a filename --> we try to load it/them
QStringList filenames;
for (int i=1; i<argc; ++i){
filenames << QString(argv[i]);
}
//mainWindow->addToDB(filenames);
}
if(splash){
//we want the splash screen to be visible a minimum amount of time (1000 ms.)
while (splashStartTime.elapsed() < 1000){
splash->raise();
QApplication::processEvents(); //to let the system breath!
}
splash->close();
QApplication::processEvents();
delete splash;
splash = 0;
}
//let's rock!
try {
result = app.exec();
}
catch(...){
QMessageBox::warning(0, "CC crashed!","Hum, it seems that CC has crashed... Sorry about that :)");
}
//release global structures
////MainWindow::DestroyInstance();
////FileIOFilter::UnregisterAll();
return result;
}