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:
matlabbe
2016-04-10 14:52:14 -04:00
parent 72fc714cb4
commit 29dd529762
5 changed files with 116 additions and 13 deletions
+3 -2
View File
@@ -198,12 +198,13 @@ IF(WITH_FREENECT2)
ENDIF(freenect2_FOUND)
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)
IF(OpenNI2_FOUND)
MESSAGE(STATUS "Found OpenNI2: ${OpenNI2_INCLUDE_DIRS}")
ENDIF(OpenNI2_FOUND)
ENDIF(WITH_OPENNI2)
ENDIF(WITH_OPENNI2 OR OpenNI2_FOUND)
IF(WITH_DC1394)
FIND_PACKAGE(DC1394 QUIET)
+20
View File
@@ -33,6 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/gui/MainWindow.h"
#include <QMessageBox>
#include "rtabmap/utilite/UObjDeletionThread.h"
#include "rtabmap/utilite/UFile.h"
#include "rtabmap/utilite/UConversion.h"
#include "ObjDeletionHandler.h"
using namespace rtabmap;
@@ -46,6 +48,19 @@ int main(int argc, char* argv[])
/* Create tasks */
QApplication * app = new QApplication(argc, argv);
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...");
@@ -64,6 +79,11 @@ int main(int argc, char* argv[])
RtabmapThread * rtabmap = new RtabmapThread(new Rtabmap());
rtabmap->start(); // start it not initialized... will be initialized by event from the gui
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
app->connect( app, SIGNAL( lastWindowClosed() ),
+56
View File
@@ -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>
+1
View File
@@ -108,6 +108,7 @@ public:
public slots:
void processStats(const rtabmap::Statistics & stat);
void updateCacheFromDatabase(const QString & path);
void openDatabase(const QString & path);
protected:
virtual void closeEvent(QCloseEvent* event);
+36 -11
View File
@@ -2589,6 +2589,11 @@ void MainWindow::processRtabmapEventInit(int status, const QString & info)
{
_initProgressDialog->setValue(_initProgressDialog->maximumSteps());
this->changeState(MainWindow::kInitialized);
if(!_openedDatabasePath.isEmpty())
{
this->downloadAllClouds();
}
}
else if((RtabmapEventInit::Status)status == RtabmapEventInit::kClosing)
{
@@ -3152,6 +3157,10 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
this->setWindowModified(true);
}
else if(event->type() == QEvent::FileOpen )
{
openDatabase(((QFileOpenEvent*)event)->file());
}
return QWidget::eventFilter(obj, event);
}
@@ -3317,23 +3326,39 @@ void MainWindow::newDatabase()
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)"));
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();
_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()