diff --git a/CMakeLists.txt b/CMakeLists.txt index d2503bcf..b6b207fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/app/src/main.cpp b/app/src/main.cpp index 9305a1b7..0f65b76f 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -33,6 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "rtabmap/gui/MainWindow.h" #include #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; istart(); // 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() ), diff --git a/cmake_modules/MacOSXBundleInfo.plist.in b/cmake_modules/MacOSXBundleInfo.plist.in new file mode 100644 index 00000000..7d5f67f8 --- /dev/null +++ b/cmake_modules/MacOSXBundleInfo.plist.in @@ -0,0 +1,56 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + LSRequiresCarbon + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + + +CFBundleDocumentTypes + + + CFBundleTypeExtensions + + db + + + + CFBundleTypeName + RTAB-Map Database + CFBundleTypeRole + Editor + LSIsAppleDefaultForType + Yes + + + + + diff --git a/guilib/include/rtabmap/gui/MainWindow.h b/guilib/include/rtabmap/gui/MainWindow.h index 6aa6928e..affe36d5 100644 --- a/guilib/include/rtabmap/gui/MainWindow.h +++ b/guilib/include/rtabmap/gui/MainWindow.h @@ -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); diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index 5c53c3ec..7191773c 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -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()