Privacy
An open-source, flexible 3D physical simulation framework
main.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2011, 2012 DFKI GmbH Robotics Innovation Center
3
*
4
* This file is part of the MARS simulation framework.
5
*
6
* MARS is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License
8
* as published by the Free Software Foundation, either version 3
9
* of the License, or (at your option) any later version.
10
*
11
* MARS is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with MARS. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
#include "
MARS.h
"
22
#include "
MyApp.h
"
23
24
#include <signal.h>
25
#include <cstdio>
26
//#include "HandleFileNames.h"
27
//#include <QPlastiqueStyle>
28
29
30
#include <stdexcept>
31
32
33
void
qtExitHandler
(
int
sig) {
34
mars::app::exit_main
(sig);
35
#ifndef NO_GUI
36
if
(qApp) qApp->quit();
37
#endif
38
}
39
40
void
ignoreSignal
(
int
sig) {
41
(void)(sig);
42
}
43
48
int
main
(
int
argc,
char
*argv[]) {
49
50
// Q_INIT_RESOURCE(resources);
51
#ifndef WIN32
52
signal(SIGQUIT,
qtExitHandler
);
53
signal(SIGPIPE,
qtExitHandler
);
54
//signal(SIGKILL, qtExitHandler);
55
signal(SIGUSR1,
ignoreSignal
);
56
#else
57
signal(SIGFPE,
qtExitHandler
);
58
signal(SIGILL,
qtExitHandler
);
59
signal(SIGSEGV,
qtExitHandler
);
60
signal(SIGBREAK,
qtExitHandler
);
61
#endif
62
signal(SIGABRT,
qtExitHandler
);
63
signal(SIGTERM,
qtExitHandler
);
64
signal(SIGINT,
qtExitHandler
);
65
66
67
mars::app::MARS
*simulation =
new
mars::app::MARS
();
68
simulation->
readArguments
(argc, argv);
69
70
mars::app::MyApp
*app=NULL;
71
if
(simulation->
needQApp
) {
72
new
mars::app::MyApp
(argc, argv);
73
//app->setStyle(new QPlastiqueStyle);
74
}
75
76
// for osx relase build:
77
/*
78
QDir dir(QApplication::applicationDirPath());
79
dir.cdUp();
80
dir.cd("PlugIns");
81
QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
82
*/
83
84
//app->setWindowIcon(QIcon(QString::fromStdString(Pathes::getGuiPath()) + "images/mars_icon.ico"));
85
86
simulation->
start
(argc, argv);
87
88
int
state;
89
if
(simulation->
needQApp
) state = app->exec();
90
else
state = simulation->
runWoQApp
();
91
92
delete
simulation;
93
fprintf(stderr,
"\n################################\n"
);
94
fprintf(stderr,
"## everything closed fine ^-^ ##\n"
);
95
fprintf(stderr,
"################################\n\n"
);
96
return
state;
97
}
mars::app::MARS::start
void start(int argc, char **argv, bool startThread=true, bool handleLibraryLoading=true)
Definition:
MARS.cpp:177
mars::app::MyApp
This function provides a clean exit of the simulation in case of a kill-signal.
Definition:
MyApp.h:58
qtExitHandler
void qtExitHandler(int sig)
Definition:
main.cpp:33
mars::app::exit_main
void exit_main(int signal)
Definition:
MARS.cpp:62
mars::app::MARS::runWoQApp
int runWoQApp()
Definition:
MARS.cpp:362
mars::app::MARS::readArguments
void readArguments(int argc, char **argv)
Definition:
MARS.cpp:285
mars::app::MARS::needQApp
bool needQApp
Definition:
MARS.h:80
mars::app::MARS
Definition:
MARS.h:63
MARS.h
MyApp.h
ignoreSignal
void ignoreSignal(int sig)
Definition:
main.cpp:40
main
int main(int argc, char *argv[])
The main function, that starts the GUI and init the physical environment.
Definition:
main.cpp:48
app
src
main.cpp
Generated on Fri May 25 2018 11:46:19 by
1.8.13