2011-06-05 14:45:39 +00:00
|
|
|
/*
|
2016-07-17 21:57:10 -04:00
|
|
|
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
2014-08-11 17:00:55 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
* Neither the name of the Universite de Sherbrooke nor the
|
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2015-03-16 19:51:22 +00:00
|
|
|
#include <QApplication>
|
2011-06-05 14:45:39 +00:00
|
|
|
#include <QtCore/QDir>
|
2013-04-30 20:16:01 +00:00
|
|
|
#include "rtabmap/utilite/UEventsManager.h"
|
2013-02-03 22:12:02 +00:00
|
|
|
#include "rtabmap/core/RtabmapThread.h"
|
2014-02-24 21:04:02 +00:00
|
|
|
#include "rtabmap/core/Rtabmap.h"
|
2011-06-05 14:45:39 +00:00
|
|
|
#include "rtabmap/gui/MainWindow.h"
|
2015-03-16 19:51:22 +00:00
|
|
|
#include <QMessageBox>
|
2013-04-30 20:16:01 +00:00
|
|
|
#include "rtabmap/utilite/UObjDeletionThread.h"
|
2016-04-10 14:52:14 -04:00
|
|
|
#include "rtabmap/utilite/UFile.h"
|
|
|
|
|
#include "rtabmap/utilite/UConversion.h"
|
2011-06-05 14:45:39 +00:00
|
|
|
#include "ObjDeletionHandler.h"
|
|
|
|
|
|
|
|
|
|
using namespace rtabmap;
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
/* Set logger type */
|
|
|
|
|
ULogger::setType(ULogger::kTypeConsole);
|
2015-09-03 09:56:25 -04:00
|
|
|
ULogger::setLevel(ULogger::kInfo);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
/* Create tasks */
|
|
|
|
|
QApplication * app = new QApplication(argc, argv);
|
2017-01-27 14:31:44 -05:00
|
|
|
app->setStyleSheet("QMessageBox { messagebox-text-interaction-flags: 5; }"); // selectable message box
|
2016-11-16 17:39:17 -05:00
|
|
|
|
|
|
|
|
ParametersMap parameters = Parameters::parseArguments(argc, argv, true);
|
2011-06-05 14:45:39 +00:00
|
|
|
MainWindow * mainWindow = new MainWindow();
|
2016-04-10 14:52:14 -04:00
|
|
|
app->installEventFilter(mainWindow); // to catch FileOpen events.
|
|
|
|
|
|
|
|
|
|
std::string database;
|
|
|
|
|
for(int i=1; i<argc; ++i)
|
|
|
|
|
{
|
|
|
|
|
std::string value = uReplaceChar(argv[i], '~', UDirectory::homeDir());
|
|
|
|
|
if(UFile::exists(value) &&
|
|
|
|
|
UFile::getExtension(value).compare("db") == 0)
|
|
|
|
|
{
|
|
|
|
|
database = value;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2015-01-30 15:30:57 -05:00
|
|
|
UINFO("Program started...");
|
|
|
|
|
|
2011-06-05 14:45:39 +00:00
|
|
|
UEventsManager::addHandler(mainWindow);
|
|
|
|
|
|
|
|
|
|
/* Start thread's task */
|
2015-01-30 15:30:57 -05:00
|
|
|
if(mainWindow->isSavedMaximized())
|
|
|
|
|
{
|
|
|
|
|
mainWindow->showMaximized();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mainWindow->show();
|
|
|
|
|
}
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2014-02-24 21:04:02 +00:00
|
|
|
RtabmapThread * rtabmap = new RtabmapThread(new Rtabmap());
|
2013-01-10 20:29:01 +00:00
|
|
|
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
|
|
|
|
|
UEventsManager::addHandler(rtabmap);
|
2016-04-10 14:52:14 -04:00
|
|
|
|
|
|
|
|
if(!database.empty())
|
|
|
|
|
{
|
2016-11-16 17:39:17 -05:00
|
|
|
mainWindow->openDatabase(database.c_str());
|
|
|
|
|
}
|
|
|
|
|
if(parameters.size())
|
|
|
|
|
{
|
|
|
|
|
mainWindow->updateParameters(parameters);
|
2016-04-10 14:52:14 -04:00
|
|
|
}
|
2011-06-09 02:56:31 +00:00
|
|
|
|
2011-06-05 14:45:39 +00:00
|
|
|
// Now wait for application to finish
|
|
|
|
|
app->connect( app, SIGNAL( lastWindowClosed() ),
|
|
|
|
|
app, SLOT( quit() ) );
|
|
|
|
|
app->exec();// MUST be called by the Main Thread
|
|
|
|
|
|
|
|
|
|
/* Remove handlers */
|
|
|
|
|
UEventsManager::removeHandler(mainWindow);
|
|
|
|
|
UEventsManager::removeHandler(rtabmap);
|
|
|
|
|
|
2015-01-30 15:30:57 -05:00
|
|
|
UINFO("Killing threads...");
|
2012-03-03 01:46:30 +00:00
|
|
|
rtabmap->join(true);
|
2011-06-05 14:45:39 +00:00
|
|
|
|
2015-01-30 15:30:57 -05:00
|
|
|
UINFO("Closing RTAB-Map...");
|
|
|
|
|
delete rtabmap;
|
2014-01-22 19:49:28 +00:00
|
|
|
delete mainWindow;
|
2011-06-05 14:45:39 +00:00
|
|
|
delete app;
|
2015-01-30 15:30:57 -05:00
|
|
|
UINFO("All done!");
|
2011-06-05 14:45:39 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|