mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-03 16:27:46 +08:00
Main app: Open database as argument, file association *.db on Mac OS X, automatically ask to download clouds when opening a database
This commit is contained in:
+3
-2
@@ -198,12 +198,13 @@ IF(WITH_FREENECT2)
|
|||||||
ENDIF(freenect2_FOUND)
|
ENDIF(freenect2_FOUND)
|
||||||
ENDIF(WITH_FREENECT2)
|
ENDIF(WITH_FREENECT2)
|
||||||
|
|
||||||
IF(WITH_OPENNI2)
|
# IF PCL depends on OpenNI2 (already found), ignore WITH_OPENNI2
|
||||||
|
IF(WITH_OPENNI2 OR OpenNI2_FOUND)
|
||||||
FIND_PACKAGE(OpenNI2 QUIET)
|
FIND_PACKAGE(OpenNI2 QUIET)
|
||||||
IF(OpenNI2_FOUND)
|
IF(OpenNI2_FOUND)
|
||||||
MESSAGE(STATUS "Found OpenNI2: ${OpenNI2_INCLUDE_DIRS}")
|
MESSAGE(STATUS "Found OpenNI2: ${OpenNI2_INCLUDE_DIRS}")
|
||||||
ENDIF(OpenNI2_FOUND)
|
ENDIF(OpenNI2_FOUND)
|
||||||
ENDIF(WITH_OPENNI2)
|
ENDIF(WITH_OPENNI2 OR OpenNI2_FOUND)
|
||||||
|
|
||||||
IF(WITH_DC1394)
|
IF(WITH_DC1394)
|
||||||
FIND_PACKAGE(DC1394 QUIET)
|
FIND_PACKAGE(DC1394 QUIET)
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "rtabmap/gui/MainWindow.h"
|
#include "rtabmap/gui/MainWindow.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "rtabmap/utilite/UObjDeletionThread.h"
|
#include "rtabmap/utilite/UObjDeletionThread.h"
|
||||||
|
#include "rtabmap/utilite/UFile.h"
|
||||||
|
#include "rtabmap/utilite/UConversion.h"
|
||||||
#include "ObjDeletionHandler.h"
|
#include "ObjDeletionHandler.h"
|
||||||
|
|
||||||
using namespace rtabmap;
|
using namespace rtabmap;
|
||||||
@@ -46,6 +48,19 @@ int main(int argc, char* argv[])
|
|||||||
/* Create tasks */
|
/* Create tasks */
|
||||||
QApplication * app = new QApplication(argc, argv);
|
QApplication * app = new QApplication(argc, argv);
|
||||||
MainWindow * mainWindow = new MainWindow();
|
MainWindow * mainWindow = new MainWindow();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UINFO("Program started...");
|
UINFO("Program started...");
|
||||||
|
|
||||||
@@ -65,6 +80,11 @@ int main(int argc, char* argv[])
|
|||||||
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
|
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
|
||||||
UEventsManager::addHandler(rtabmap);
|
UEventsManager::addHandler(rtabmap);
|
||||||
|
|
||||||
|
if(!database.empty())
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(mainWindow, "openDatabase", Qt::QueuedConnection, Q_ARG(QString, QString(database.c_str())));
|
||||||
|
}
|
||||||
|
|
||||||
// Now wait for application to finish
|
// Now wait for application to finish
|
||||||
app->connect( app, SIGNAL( lastWindowClosed() ),
|
app->connect( app, SIGNAL( lastWindowClosed() ),
|
||||||
app, SLOT( quit() ) );
|
app, SLOT( quit() ) );
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleLongVersionString</key>
|
||||||
|
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||||
|
<key>CSResourcesFileMapped</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSRequiresCarbon</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||||
|
|
||||||
|
<!-- File type associations -->
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>db</string>
|
||||||
|
</array>
|
||||||
|
<!-- <key>CFBundleTypeIconFile</key> -->
|
||||||
|
<!-- <string>rtabmap_db.icns</string> -->
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>RTAB-Map Database</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>LSIsAppleDefaultForType</key>
|
||||||
|
<string>Yes</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -108,6 +108,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void processStats(const rtabmap::Statistics & stat);
|
void processStats(const rtabmap::Statistics & stat);
|
||||||
void updateCacheFromDatabase(const QString & path);
|
void updateCacheFromDatabase(const QString & path);
|
||||||
|
void openDatabase(const QString & path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent* event);
|
virtual void closeEvent(QCloseEvent* event);
|
||||||
|
|||||||
+36
-11
@@ -2589,6 +2589,11 @@ void MainWindow::processRtabmapEventInit(int status, const QString & info)
|
|||||||
{
|
{
|
||||||
_initProgressDialog->setValue(_initProgressDialog->maximumSteps());
|
_initProgressDialog->setValue(_initProgressDialog->maximumSteps());
|
||||||
this->changeState(MainWindow::kInitialized);
|
this->changeState(MainWindow::kInitialized);
|
||||||
|
|
||||||
|
if(!_openedDatabasePath.isEmpty())
|
||||||
|
{
|
||||||
|
this->downloadAllClouds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if((RtabmapEventInit::Status)status == RtabmapEventInit::kClosing)
|
else if((RtabmapEventInit::Status)status == RtabmapEventInit::kClosing)
|
||||||
{
|
{
|
||||||
@@ -3152,6 +3157,10 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
|||||||
{
|
{
|
||||||
this->setWindowModified(true);
|
this->setWindowModified(true);
|
||||||
}
|
}
|
||||||
|
else if(event->type() == QEvent::FileOpen )
|
||||||
|
{
|
||||||
|
openDatabase(((QFileOpenEvent*)event)->file());
|
||||||
|
}
|
||||||
return QWidget::eventFilter(obj, event);
|
return QWidget::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3317,23 +3326,39 @@ void MainWindow::newDatabase()
|
|||||||
|
|
||||||
void MainWindow::openDatabase()
|
void MainWindow::openDatabase()
|
||||||
{
|
{
|
||||||
if(_state != MainWindow::kIdle)
|
|
||||||
{
|
|
||||||
UERROR("This method can be called only in IDLE state.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_openedDatabasePath.clear();
|
|
||||||
_newDatabasePath.clear();
|
|
||||||
_newDatabasePathOutput.clear();
|
|
||||||
_databaseUpdated = false;
|
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Open database..."), _preferencesDialog->getWorkingDirectory(), tr("RTAB-Map database files (*.db)"));
|
QString path = QFileDialog::getOpenFileName(this, tr("Open database..."), _preferencesDialog->getWorkingDirectory(), tr("RTAB-Map database files (*.db)"));
|
||||||
if(!path.isEmpty())
|
if(!path.isEmpty())
|
||||||
{
|
{
|
||||||
|
this->openDatabase(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::openDatabase(const QString & path)
|
||||||
|
{
|
||||||
|
if(_state != MainWindow::kIdle)
|
||||||
|
{
|
||||||
|
UERROR("Database can only be opened in IDLE state.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string value = path.toStdString();
|
||||||
|
if(UFile::exists(value) &&
|
||||||
|
UFile::getExtension(value).compare("db") == 0)
|
||||||
|
{
|
||||||
|
_openedDatabasePath.clear();
|
||||||
|
_newDatabasePath.clear();
|
||||||
|
_newDatabasePathOutput.clear();
|
||||||
|
_databaseUpdated = false;
|
||||||
|
|
||||||
this->clearTheCache();
|
this->clearTheCache();
|
||||||
_openedDatabasePath = path;
|
_openedDatabasePath = path;
|
||||||
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdInit, path.toStdString(), 0, _preferencesDialog->getAllParameters()));
|
this->post(new RtabmapEventCmd(RtabmapEventCmd::kCmdInit, value, 0, _preferencesDialog->getAllParameters()));
|
||||||
|
applyPrefSettings(_preferencesDialog->getAllParameters(), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UERROR("File \"%s\" not valid.", value.c_str());
|
||||||
}
|
}
|
||||||
applyPrefSettings(_preferencesDialog->getAllParameters(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::closeDatabase()
|
bool MainWindow::closeDatabase()
|
||||||
|
|||||||
Reference in New Issue
Block a user