Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
app
src
app/src/main.cpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3
All rights reserved.
4
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
9
* Redistributions in binary form must reproduce the above copyright
10
notice, this list of conditions and the following disclaimer in the
11
documentation and/or other materials provided with the distribution.
12
* Neither the name of the Universite de Sherbrooke nor the
13
names of its contributors may be used to endorse or promote products
14
derived from this software without specific prior written permission.
15
16
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#include <QApplication>
29
#include <QtCore/QDir>
30
#include "
rtabmap/utilite/UEventsManager.h
"
31
#include "
rtabmap/core/RtabmapThread.h
"
32
#include "
rtabmap/core/Rtabmap.h
"
33
#include "
rtabmap/gui/MainWindow.h
"
34
#include <QMessageBox>
35
#include "
rtabmap/utilite/UObjDeletionThread.h
"
36
#include "
rtabmap/utilite/UFile.h
"
37
#include "
rtabmap/utilite/UConversion.h
"
38
#include "
ObjDeletionHandler.h
"
39
40
using namespace
rtabmap
;
41
42
int
main
(
int
argc,
char
* argv[])
43
{
44
/* Set logger type */
45
ULogger::setType
(
ULogger::kTypeConsole
);
46
ULogger::setLevel
(
ULogger::kInfo
);
47
48
/* Create tasks */
49
QApplication *
app
=
new
QApplication(argc, argv);
50
app->setStyleSheet(
"QMessageBox { messagebox-text-interaction-flags: 5; }"
);
// selectable message box
51
52
ParametersMap
parameters =
Parameters::parseArguments
(argc, argv,
false
);
53
MainWindow
* mainWindow =
new
MainWindow
();
54
app->installEventFilter(mainWindow);
// to catch FileOpen events.
55
56
std::string database;
57
for
(
int
i=1; i<argc; ++i)
58
{
59
std::string value =
uReplaceChar
(argv[i],
'~'
,
UDirectory::homeDir
());
60
if
(
UFile::exists
(value) &&
61
UFile::getExtension
(value).compare(
"db"
) == 0)
62
{
63
database = value;
64
break
;
65
}
66
}
67
68
UINFO
(
"Program started..."
);
69
70
UEventsManager::addHandler
(mainWindow);
71
72
/* Start thread's task */
73
if
(mainWindow->
isSavedMaximized
())
74
{
75
mainWindow->showMaximized();
76
}
77
else
78
{
79
mainWindow->show();
80
}
81
82
RtabmapThread
*
rtabmap
=
new
RtabmapThread
(
new
Rtabmap
());
83
rtabmap->
start
();
// start it not initialized... will be initialized by event from the gui
84
UEventsManager::addHandler
(rtabmap);
85
86
if
(!database.empty())
87
{
88
mainWindow->
openDatabase
(database.c_str(), parameters);
89
}
90
else
if
(parameters.size())
91
{
92
mainWindow->
updateParameters
(parameters);
93
}
94
95
// Now wait for application to finish
96
app->connect( app, SIGNAL( lastWindowClosed() ),
97
app, SLOT( quit() ) );
98
app->exec();
// MUST be called by the Main Thread
99
100
/* Remove handlers */
101
UEventsManager::removeHandler
(mainWindow);
102
UEventsManager::removeHandler
(rtabmap);
103
104
UINFO
(
"Killing threads..."
);
105
rtabmap->
join
(
true
);
106
107
UINFO
(
"Closing RTAB-Map..."
);
108
delete
rtabmap;
109
delete
mainWindow;
110
delete
app
;
111
UINFO
(
"All done!"
);
112
113
return
0;
114
}
RtabmapThread.h
UDirectory::homeDir
static std::string homeDir()
Definition:
UDirectory.cpp:355
ULogger::kInfo
Definition:
ULogger.h:252
UThread::start
void start()
Definition:
UThread.cpp:122
rtabmap::Rtabmap
Definition:
Rtabmap.h:53
rtabmap::MainWindow
Definition:
MainWindow.h:77
UEventsManager.h
Rtabmap.h
rtabmap::Parameters::parseArguments
static ParametersMap parseArguments(int argc, char *argv[], bool onlyParameters=false)
Definition:
Parameters.cpp:543
rtabmap
Definition:
CameraTango.cpp:37
MainWindow.h
rtabmap::ParametersMap
std::map< std::string, std::string > ParametersMap
Definition:
Parameters.h:41
UConversion.h
Some conversion functions.
UFile::getExtension
std::string getExtension()
Definition:
UFile.h:140
rtabmap::MainWindow::openDatabase
void openDatabase(const QString &path, const rtabmap::ParametersMap &overridedParameters=rtabmap::ParametersMap())
Definition:
MainWindow.cpp:4560
ULogger::setLevel
static void setLevel(ULogger::Level level)
Definition:
ULogger.h:339
UObjDeletionThread.h
rtabmap::RtabmapThread
Definition:
RtabmapThread.h:51
ULogger::setType
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
Definition:
ULogger.cpp:176
rtabmap::MainWindow::updateParameters
void updateParameters(const rtabmap::ParametersMap ¶meters)
Definition:
MainWindow.cpp:4424
uReplaceChar
std::string UTILITE_EXP uReplaceChar(const std::string &str, char before, char after)
Definition:
UConversion.cpp:32
rtabmap::MainWindow::isSavedMaximized
bool isSavedMaximized() const
Definition:
MainWindow.h:105
app
static RTABMapApp app
Definition:
jni_interface.cpp:34
ULogger::kTypeConsole
Definition:
ULogger.h:244
UFile.h
UFile::exists
bool exists()
Definition:
UFile.h:104
UEventsManager::addHandler
static void addHandler(UEventsHandler *handler)
Definition:
UEventsManager.cpp:28
UEventsManager::removeHandler
static void removeHandler(UEventsHandler *handler)
Definition:
UEventsManager.cpp:41
UThread::join
void join(bool killFirst=false)
Definition:
UThread.cpp:85
main
int main(int argc, char *argv[])
Definition:
app/src/main.cpp:42
UINFO
#define UINFO(...)
ObjDeletionHandler.h
rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:31