mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
fixed checked/unchecked actions of menu "Select Source..."
This commit is contained in:
@@ -305,7 +305,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
|
||||
#endif
|
||||
|
||||
//Settings menu
|
||||
this->updateSelectSourceImageMenu(_preferencesDialog->getSourceImageType());
|
||||
this->updateSelectSourceImageMenu(_preferencesDialog->isSourceImageUsed(), _preferencesDialog->getSourceImageType());
|
||||
connect(_ui->actionImageFiles, SIGNAL(triggered()), this, SLOT(selectImages()));
|
||||
connect(_ui->actionVideo, SIGNAL(triggered()), this, SLOT(selectVideo()));
|
||||
connect(_ui->actionUsbCamera, SIGNAL(triggered()), this, SLOT(selectStream()));
|
||||
@@ -1725,7 +1725,7 @@ void MainWindow::applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags)
|
||||
{
|
||||
// Camera settings...
|
||||
_ui->doubleSpinBox_stats_imgRate->setValue(_preferencesDialog->getGeneralInputRate());
|
||||
this->updateSelectSourceImageMenu(_preferencesDialog->getSourceImageType());
|
||||
this->updateSelectSourceImageMenu(_preferencesDialog->isSourceImageUsed(), _preferencesDialog->getSourceImageType());
|
||||
this->updateSelectSourceDatabase(_preferencesDialog->isSourceDatabaseUsed());
|
||||
this->updateSelectSourceRGBDMenu(_preferencesDialog->isSourceOpenniUsed(), _preferencesDialog->getSourceRGBD());
|
||||
QString src;
|
||||
@@ -2012,32 +2012,11 @@ void MainWindow::resizeEvent(QResizeEvent* anEvent)
|
||||
_ui->imageView_odometry->resetZoom();
|
||||
}
|
||||
|
||||
void MainWindow::updateSelectSourceImageMenu(int type)
|
||||
void MainWindow::updateSelectSourceImageMenu(bool used, PreferencesDialog::Src src)
|
||||
{
|
||||
if(_preferencesDialog->isSourceImageUsed())
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
_ui->actionUsbCamera->setChecked(true);
|
||||
break;
|
||||
case 1:
|
||||
_ui->actionImageFiles->setChecked(true);
|
||||
break;
|
||||
case 2:
|
||||
_ui->actionVideo->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
UERROR("Unknown source image type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// they are exclusive actions, so check/uncheck one should disable all.
|
||||
_ui->actionUsbCamera->setChecked(true);
|
||||
_ui->actionUsbCamera->setChecked(false);
|
||||
}
|
||||
_ui->actionUsbCamera->setChecked(used && src == PreferencesDialog::kSrcUsbDevice);
|
||||
_ui->actionImageFiles->setChecked(used && src == PreferencesDialog::kSrcImages);
|
||||
_ui->actionVideo->setChecked(used && src == PreferencesDialog::kSrcVideo);
|
||||
}
|
||||
|
||||
void MainWindow::updateSelectSourceDatabase(bool used)
|
||||
@@ -3205,47 +3184,47 @@ void MainWindow::updateEditMenu()
|
||||
|
||||
void MainWindow::selectImages()
|
||||
{
|
||||
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcImages);
|
||||
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcImages, _ui->actionImageFiles->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectVideo()
|
||||
{
|
||||
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcVideo);
|
||||
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcVideo, _ui->actionVideo->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectStream()
|
||||
{
|
||||
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcUsbDevice);
|
||||
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcUsbDevice, _ui->actionUsbCamera->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectDatabase()
|
||||
{
|
||||
_preferencesDialog->selectSourceDatabase(true);
|
||||
_preferencesDialog->selectSourceDatabase(true, _ui->actionDatabase->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectOpenni()
|
||||
{
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_PCL);
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_PCL, _ui->actionOpenNI_PCL->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectFreenect()
|
||||
{
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcFreenect);
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcFreenect, _ui->actionFreenect->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectOpenniCv()
|
||||
{
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV);
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV, _ui->actionOpenNI_CV->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectOpenniCvAsus()
|
||||
{
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV_ASUS);
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV_ASUS, _ui->actionOpenNI_CV_ASUS->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::selectOpenni2()
|
||||
{
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI2);
|
||||
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI2, _ui->actionOpenNI2->isChecked());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1708,23 +1708,10 @@ QString PreferencesDialog::loadCustomConfig(const QString & section, const QStri
|
||||
return value;
|
||||
}
|
||||
|
||||
void PreferencesDialog::selectSourceImage(Src src)
|
||||
void PreferencesDialog::selectSourceImage(Src src, bool ckecked)
|
||||
{
|
||||
ULOGGER_DEBUG("");
|
||||
|
||||
if(_ui->general_checkBox_activateRGBD->isChecked())
|
||||
{
|
||||
int button = QMessageBox::information(this,
|
||||
tr("Desactivate RGB-D SLAM?"),
|
||||
tr("You've selected source input as images only and RGB-D SLAM mode is activated. "
|
||||
"RGB-D SLAM cannot work with images only so do you want to desactivate it?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if(button & QMessageBox::Yes)
|
||||
{
|
||||
_ui->general_checkBox_activateRGBD->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool fromPrefDialog = false;
|
||||
//bool modified = false;
|
||||
if(src == kSrcUndef)
|
||||
@@ -1743,56 +1730,85 @@ void PreferencesDialog::selectSourceImage(Src src)
|
||||
src = kSrcUsbDevice;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// from user
|
||||
_ui->groupBox_sourceImage->setChecked(true);
|
||||
}
|
||||
|
||||
if(src == kSrcImages)
|
||||
if(!fromPrefDialog)
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, QString(), _ui->source_images_lineEdit_path->text());
|
||||
QDir dir(path);
|
||||
if(!path.isEmpty() && dir.exists())
|
||||
if(ckecked)
|
||||
{
|
||||
QStringList filters;
|
||||
filters << "*.jpg" << "*.ppm" << "*.bmp" << "*.png" << "*.pnm" << "*.tiff";
|
||||
dir.setNameFilters(filters);
|
||||
QFileInfoList files = dir.entryInfoList();
|
||||
if(!files.empty())
|
||||
if(_ui->general_checkBox_activateRGBD->isChecked())
|
||||
{
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(1);
|
||||
_ui->source_images_lineEdit_path->setText(path);
|
||||
_ui->source_images_spinBox_startPos->setValue(1);
|
||||
_ui->source_images_refreshDir->setChecked(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this,
|
||||
tr("RTAB-Map"),
|
||||
tr("Images must be one of these formats: ") + filters.join(" "));
|
||||
int button = QMessageBox::information(this,
|
||||
tr("Desactivate RGB-D SLAM?"),
|
||||
tr("You've selected source input as images only and RGB-D SLAM mode is activated. "
|
||||
"RGB-D SLAM cannot work with images only so do you want to desactivate it?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if(button & QMessageBox::Yes)
|
||||
{
|
||||
_ui->general_checkBox_activateRGBD->setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(src == kSrcVideo)
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->source_video_lineEdit_path->text(), tr("Videos (*.avi *.mpg *.mp4)"));
|
||||
QFile file(path);
|
||||
if(!path.isEmpty() && file.exists())
|
||||
{
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(2);
|
||||
_ui->source_video_lineEdit_path->setText(path);
|
||||
}
|
||||
}
|
||||
else // kSrcUsbDevice
|
||||
{
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(0);
|
||||
|
||||
_ui->groupBox_sourceImage->setChecked(false);
|
||||
}
|
||||
|
||||
if(!fromPrefDialog && _obsoletePanels)
|
||||
if(ckecked)
|
||||
{
|
||||
if(src == kSrcImages)
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, QString(), _ui->source_images_lineEdit_path->text());
|
||||
QDir dir(path);
|
||||
if(!path.isEmpty() && dir.exists())
|
||||
{
|
||||
QStringList filters;
|
||||
filters << "*.jpg" << "*.ppm" << "*.bmp" << "*.png" << "*.pnm" << "*.tiff";
|
||||
dir.setNameFilters(filters);
|
||||
QFileInfoList files = dir.entryInfoList();
|
||||
if(!files.empty())
|
||||
{
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(1);
|
||||
_ui->source_images_lineEdit_path->setText(path);
|
||||
_ui->source_images_spinBox_startPos->setValue(1);
|
||||
_ui->source_images_refreshDir->setChecked(false);
|
||||
_ui->groupBox_sourceImage->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this,
|
||||
tr("RTAB-Map"),
|
||||
tr("Images must be one of these formats: ") + filters.join(" "));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(src == kSrcVideo)
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->source_video_lineEdit_path->text(), tr("Videos (*.avi *.mpg *.mp4)"));
|
||||
QFile file(path);
|
||||
if(!path.isEmpty() && file.exists())
|
||||
{
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(2);
|
||||
_ui->source_video_lineEdit_path->setText(path);
|
||||
_ui->groupBox_sourceImage->setChecked(true);
|
||||
}
|
||||
}
|
||||
else // kSrcUsbDevice
|
||||
{
|
||||
_ui->source_comboBox_image_type->setCurrentIndex(0);
|
||||
_ui->groupBox_sourceImage->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(_ui->groupBox_sourceImage->isChecked())
|
||||
{
|
||||
_ui->groupBox_sourceDatabase->setChecked(false);
|
||||
_ui->groupBox_sourceOpenni->setChecked(false);
|
||||
}
|
||||
|
||||
if(!fromPrefDialog)
|
||||
{
|
||||
// Even if there is no change, MainWindow should be notified
|
||||
makeObsoleteSourcePanel();
|
||||
|
||||
if(validateForm())
|
||||
{
|
||||
this->writeSettings();
|
||||
@@ -1804,72 +1820,85 @@ void PreferencesDialog::selectSourceImage(Src src)
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::selectSourceDatabase(bool user)
|
||||
void PreferencesDialog::selectSourceDatabase(bool user, bool ckecked)
|
||||
{
|
||||
ULOGGER_DEBUG("");
|
||||
|
||||
QString dir = _ui->source_database_lineEdit_path->text();
|
||||
if(dir.isEmpty())
|
||||
if(user)
|
||||
{
|
||||
dir = getWorkingDirectory();
|
||||
_ui->groupBox_sourceDatabase->setChecked(false);
|
||||
}
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select file"), dir, tr("RTAB-Map database files (*.db)"));
|
||||
QFile file(path);
|
||||
if(!path.isEmpty() && file.exists())
|
||||
|
||||
if(ckecked)
|
||||
{
|
||||
int r = QMessageBox::question(this, tr("Odometry in database..."), tr("Use odometry saved in database (if some saved)?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
|
||||
if(user)
|
||||
QString dir = _ui->source_database_lineEdit_path->text();
|
||||
if(dir.isEmpty())
|
||||
{
|
||||
// from user
|
||||
_ui->groupBox_sourceDatabase->setChecked(true);
|
||||
dir = getWorkingDirectory();
|
||||
}
|
||||
|
||||
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
|
||||
_ui->source_database_lineEdit_path->setText(path);
|
||||
_ui->source_spinBox_databaseStartPos->setValue(0);
|
||||
|
||||
if(user && _obsoletePanels)
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select file"), dir, tr("RTAB-Map database files (*.db)"));
|
||||
QFile file(path);
|
||||
if(!path.isEmpty() && file.exists())
|
||||
{
|
||||
_ui->groupBox_sourceImage->setChecked(false);
|
||||
_ui->groupBox_sourceOpenni->setChecked(false);
|
||||
if(validateForm())
|
||||
{
|
||||
this->writeSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->readSettingsBegin();
|
||||
}
|
||||
int r = QMessageBox::question(this, tr("Odometry in database..."), tr("Use odometry saved in database (if some saved)?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
|
||||
_ui->groupBox_sourceDatabase->setChecked(true);
|
||||
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
|
||||
_ui->source_database_lineEdit_path->setText(path);
|
||||
_ui->source_spinBox_databaseStartPos->setValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(_ui->groupBox_sourceDatabase->isChecked())
|
||||
{
|
||||
_ui->groupBox_sourceImage->setChecked(false);
|
||||
_ui->groupBox_sourceOpenni->setChecked(false);
|
||||
}
|
||||
|
||||
if(user)
|
||||
{
|
||||
// Even if there is no change, MainWindow should be notified
|
||||
makeObsoleteSourcePanel();
|
||||
|
||||
if(validateForm())
|
||||
{
|
||||
this->writeSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->readSettingsBegin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::selectSourceRGBD(Src src)
|
||||
void PreferencesDialog::selectSourceRGBD(Src src, bool ckecked)
|
||||
{
|
||||
ULOGGER_DEBUG("");
|
||||
|
||||
if(!_ui->general_checkBox_activateRGBD->isChecked())
|
||||
if(ckecked)
|
||||
{
|
||||
int button = QMessageBox::information(this,
|
||||
tr("Activate RGB-D SLAM?"),
|
||||
tr("You've selected RGB-D camera as source input, "
|
||||
"would you want to activate RGB-D SLAM mode?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if(button & QMessageBox::Yes)
|
||||
if(!_ui->general_checkBox_activateRGBD->isChecked())
|
||||
{
|
||||
_ui->general_checkBox_activateRGBD->setChecked(true);
|
||||
int button = QMessageBox::information(this,
|
||||
tr("Activate RGB-D SLAM?"),
|
||||
tr("You've selected RGB-D camera as source input, "
|
||||
"would you want to activate RGB-D SLAM mode?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if(button & QMessageBox::Yes)
|
||||
{
|
||||
_ui->general_checkBox_activateRGBD->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ui->groupBox_sourceOpenni->setChecked(true);
|
||||
_ui->groupBox_sourceOpenni->setChecked(ckecked);
|
||||
_ui->radioButton_opennipcl->setChecked(src == kSrcOpenNI_PCL);
|
||||
_ui->radioButton_freenect->setChecked(src == kSrcFreenect);
|
||||
_ui->radioButton_opennicv->setChecked(src == kSrcOpenNI_CV);
|
||||
_ui->radioButton_opennicvasus->setChecked(src == kSrcOpenNI_CV_ASUS);
|
||||
_ui->radioButton_openni2->setChecked(src == kSrcOpenNI2);
|
||||
|
||||
if(_obsoletePanels)
|
||||
if(_ui->groupBox_sourceOpenni->isChecked())
|
||||
{
|
||||
_ui->groupBox_sourceImage->setChecked(false);
|
||||
_ui->groupBox_sourceDatabase->setChecked(false);
|
||||
@@ -1893,15 +1922,18 @@ void PreferencesDialog::selectSourceRGBD(Src src)
|
||||
this->resetCalibration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(validateForm())
|
||||
{
|
||||
this->writeSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->readSettingsBegin();
|
||||
}
|
||||
if(validateForm())
|
||||
{
|
||||
// Even if there is no change, MainWindow should be notified
|
||||
makeObsoleteSourcePanel();
|
||||
|
||||
this->writeSettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->readSettingsBegin();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2792,9 +2824,20 @@ bool PreferencesDialog::isSourceOpenniUsed() const
|
||||
}
|
||||
|
||||
|
||||
int PreferencesDialog::getSourceImageType() const
|
||||
PreferencesDialog::Src PreferencesDialog::getSourceImageType() const
|
||||
{
|
||||
return _ui->source_comboBox_image_type->currentIndex();
|
||||
if(_ui->source_comboBox_image_type->currentIndex() == 1)
|
||||
{
|
||||
return kSrcImages;
|
||||
}
|
||||
else if(_ui->source_comboBox_image_type->currentIndex() == 2)
|
||||
{
|
||||
return kSrcVideo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kSrcUsbDevice;
|
||||
}
|
||||
}
|
||||
QString PreferencesDialog::getSourceImageTypeStr() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user