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
39
#include <vtkObject.h>
40
41
using namespace
rtabmap
;
42
43
int
main
(
int
argc,
char
*
argv
[])
44
{
45
/* Set logger type */
46
ULogger::setType
(
ULogger::kTypeConsole
);
47
ULogger::setLevel
(
ULogger::kWarning
);
48
49
#ifdef WIN32
50
CoInitialize(
nullptr
);
51
#endif
52
53
#if VTK_MAJOR_VERSION >= 8
54
vtkObject::GlobalWarningDisplayOff();
55
#endif
56
57
/* Create tasks */
58
QApplication *
app
=
new
QApplication(argc, argv);
59
app->setStyleSheet(
"QMessageBox { messagebox-text-interaction-flags: 5; }"
);
// selectable message box
60
61
ParametersMap
parameters =
Parameters::parseArguments
(argc, argv,
false
);
62
MainWindow
* mainWindow =
new
MainWindow
();
63
app->installEventFilter(mainWindow);
// to catch FileOpen events.
64
65
std::string database;
66
for
(
int
i=1; i<argc; ++i)
67
{
68
std::string value =
uReplaceChar
(argv[i],
'~'
,
UDirectory::homeDir
());
69
if
(
UFile::exists
(value) &&
70
UFile::getExtension
(value).compare(
"db"
) == 0)
71
{
72
database = value;
73
}
74
}
75
76
printf(
"Program started...\n"
);
77
78
UEventsManager::addHandler
(mainWindow);
79
80
/* Start thread's task */
81
if
(mainWindow->
isSavedMaximized
())
82
{
83
mainWindow->showMaximized();
84
}
85
else
86
{
87
mainWindow->show();
88
}
89
90
RtabmapThread
*
rtabmap
=
new
RtabmapThread
(
new
Rtabmap
());
91
rtabmap->
start
();
// start it not initialized... will be initialized by event from the gui
92
UEventsManager::addHandler
(rtabmap);
93
94
if
(!database.empty())
95
{
96
mainWindow->
openDatabase
(database.c_str(), parameters);
97
}
98
else
if
(parameters.size())
99
{
100
mainWindow->
updateParameters
(parameters);
101
}
102
103
// Now wait for application to finish
104
app->connect( app, SIGNAL( lastWindowClosed() ),
105
app, SLOT( quit() ) );
106
app->exec();
// MUST be called by the Main Thread
107
108
/* Remove handlers */
109
UEventsManager::removeHandler
(mainWindow);
110
UEventsManager::removeHandler
(rtabmap);
111
112
rtabmap->
join
(
true
);
113
114
printf(
"Closing RTAB-Map...\n"
);
115
delete
rtabmap;
116
delete
mainWindow;
117
delete
app
;
118
printf(
"All done!\n"
);
119
120
return
0;
121
}
RtabmapThread.h
UDirectory::homeDir
static std::string homeDir()
Definition:
UDirectory.cpp:355
UThread::start
void start()
Definition:
UThread.cpp:122
rtabmap::Rtabmap
Definition:
Rtabmap.h:54
rtabmap::MainWindow
Definition:
MainWindow.h:79
UEventsManager.h
Rtabmap.h
rtabmap::Parameters::parseArguments
static ParametersMap parseArguments(int argc, char *argv[], bool onlyParameters=false)
Definition:
Parameters.cpp:596
rtabmap
Definition:
CameraARCore.cpp:35
MainWindow.h
rtabmap::ParametersMap
std::map< std::string, std::string > ParametersMap
Definition:
Parameters.h:43
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:5404
ULogger::setLevel
static void setLevel(ULogger::Level level)
Definition:
ULogger.h:339
UObjDeletionThread.h
rtabmap::RtabmapThread
Definition:
RtabmapThread.h:51
rtabmap::MainWindow::isSavedMaximized
bool isSavedMaximized() const
Definition:
MainWindow.h:107
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:5261
uReplaceChar
std::string UTILITE_EXP uReplaceChar(const std::string &str, char before, char after)
Definition:
UConversion.cpp:33
app
QApplication * app
Definition:
tools/DataRecorder/main.cpp:59
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
rtabmap_oanet.argv
argv
Definition:
rtabmap_oanet.py:12
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:43
ULogger::kWarning
Definition:
ULogger.h:252
rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:29