fixed checked/unchecked actions of menu "Select Source..."

This commit is contained in:
Mathieu Labbe
2015-01-12 16:53:18 -05:00
parent 74d6f9c83d
commit cd3bd2948e
4 changed files with 165 additions and 143 deletions
+1 -1
View File
@@ -200,7 +200,7 @@ private:
void createAndAddScanToMap(int nodeId, const Transform & pose, int mapId); void createAndAddScanToMap(int nodeId, const Transform & pose, int mapId);
void drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords, const std::multimap<int, cv::KeyPoint> & loopWords); void drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords, const std::multimap<int, cv::KeyPoint> & loopWords);
void setupMainLayout(bool vertical); void setupMainLayout(bool vertical);
void updateSelectSourceImageMenu(int type); void updateSelectSourceImageMenu(bool used, PreferencesDialog::Src src);
void updateSelectSourceDatabase(bool used); void updateSelectSourceDatabase(bool used);
void updateSelectSourceRGBDMenu(bool used, PreferencesDialog::Src src); void updateSelectSourceRGBDMenu(bool used, PreferencesDialog::Src src);
@@ -158,7 +158,7 @@ public:
bool isSourceImageUsed() const; bool isSourceImageUsed() const;
bool isSourceDatabaseUsed() const; bool isSourceDatabaseUsed() const;
bool isSourceOpenniUsed() const; bool isSourceOpenniUsed() const;
int getSourceImageType() const; PreferencesDialog::Src getSourceImageType() const;
QString getSourceImageTypeStr() const; QString getSourceImageTypeStr() const;
int getSourceWidth() const; int getSourceWidth() const;
int getSourceHeight() const; int getSourceHeight() const;
@@ -211,9 +211,9 @@ public slots:
void setHardThr(int value); void setHardThr(int value);
void setTimeLimit(float value); void setTimeLimit(float value);
void setSLAMMode(bool enabled); void setSLAMMode(bool enabled);
void selectSourceImage(Src src = kSrcUndef); void selectSourceImage(Src src = kSrcUndef, bool checked = true);
void selectSourceDatabase(bool user = false); void selectSourceDatabase(bool user = false, bool checked = true);
void selectSourceRGBD(Src src = kSrcUndef); void selectSourceRGBD(Src src = kSrcUndef, bool checked = true);
private slots: private slots:
void closeDialog ( QAbstractButton * button ); void closeDialog ( QAbstractButton * button );
+15 -36
View File
@@ -305,7 +305,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
#endif #endif
//Settings menu //Settings menu
this->updateSelectSourceImageMenu(_preferencesDialog->getSourceImageType()); this->updateSelectSourceImageMenu(_preferencesDialog->isSourceImageUsed(), _preferencesDialog->getSourceImageType());
connect(_ui->actionImageFiles, SIGNAL(triggered()), this, SLOT(selectImages())); connect(_ui->actionImageFiles, SIGNAL(triggered()), this, SLOT(selectImages()));
connect(_ui->actionVideo, SIGNAL(triggered()), this, SLOT(selectVideo())); connect(_ui->actionVideo, SIGNAL(triggered()), this, SLOT(selectVideo()));
connect(_ui->actionUsbCamera, SIGNAL(triggered()), this, SLOT(selectStream())); connect(_ui->actionUsbCamera, SIGNAL(triggered()), this, SLOT(selectStream()));
@@ -1725,7 +1725,7 @@ void MainWindow::applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags)
{ {
// Camera settings... // Camera settings...
_ui->doubleSpinBox_stats_imgRate->setValue(_preferencesDialog->getGeneralInputRate()); _ui->doubleSpinBox_stats_imgRate->setValue(_preferencesDialog->getGeneralInputRate());
this->updateSelectSourceImageMenu(_preferencesDialog->getSourceImageType()); this->updateSelectSourceImageMenu(_preferencesDialog->isSourceImageUsed(), _preferencesDialog->getSourceImageType());
this->updateSelectSourceDatabase(_preferencesDialog->isSourceDatabaseUsed()); this->updateSelectSourceDatabase(_preferencesDialog->isSourceDatabaseUsed());
this->updateSelectSourceRGBDMenu(_preferencesDialog->isSourceOpenniUsed(), _preferencesDialog->getSourceRGBD()); this->updateSelectSourceRGBDMenu(_preferencesDialog->isSourceOpenniUsed(), _preferencesDialog->getSourceRGBD());
QString src; QString src;
@@ -2012,32 +2012,11 @@ void MainWindow::resizeEvent(QResizeEvent* anEvent)
_ui->imageView_odometry->resetZoom(); _ui->imageView_odometry->resetZoom();
} }
void MainWindow::updateSelectSourceImageMenu(int type) void MainWindow::updateSelectSourceImageMenu(bool used, PreferencesDialog::Src src)
{ {
if(_preferencesDialog->isSourceImageUsed()) _ui->actionUsbCamera->setChecked(used && src == PreferencesDialog::kSrcUsbDevice);
{ _ui->actionImageFiles->setChecked(used && src == PreferencesDialog::kSrcImages);
switch(type) _ui->actionVideo->setChecked(used && src == PreferencesDialog::kSrcVideo);
{
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);
}
} }
void MainWindow::updateSelectSourceDatabase(bool used) void MainWindow::updateSelectSourceDatabase(bool used)
@@ -3205,47 +3184,47 @@ void MainWindow::updateEditMenu()
void MainWindow::selectImages() void MainWindow::selectImages()
{ {
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcImages); _preferencesDialog->selectSourceImage(PreferencesDialog::kSrcImages, _ui->actionImageFiles->isChecked());
} }
void MainWindow::selectVideo() void MainWindow::selectVideo()
{ {
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcVideo); _preferencesDialog->selectSourceImage(PreferencesDialog::kSrcVideo, _ui->actionVideo->isChecked());
} }
void MainWindow::selectStream() void MainWindow::selectStream()
{ {
_preferencesDialog->selectSourceImage(PreferencesDialog::kSrcUsbDevice); _preferencesDialog->selectSourceImage(PreferencesDialog::kSrcUsbDevice, _ui->actionUsbCamera->isChecked());
} }
void MainWindow::selectDatabase() void MainWindow::selectDatabase()
{ {
_preferencesDialog->selectSourceDatabase(true); _preferencesDialog->selectSourceDatabase(true, _ui->actionDatabase->isChecked());
} }
void MainWindow::selectOpenni() void MainWindow::selectOpenni()
{ {
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_PCL); _preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_PCL, _ui->actionOpenNI_PCL->isChecked());
} }
void MainWindow::selectFreenect() void MainWindow::selectFreenect()
{ {
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcFreenect); _preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcFreenect, _ui->actionFreenect->isChecked());
} }
void MainWindow::selectOpenniCv() void MainWindow::selectOpenniCv()
{ {
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV); _preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV, _ui->actionOpenNI_CV->isChecked());
} }
void MainWindow::selectOpenniCvAsus() void MainWindow::selectOpenniCvAsus()
{ {
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV_ASUS); _preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI_CV_ASUS, _ui->actionOpenNI_CV_ASUS->isChecked());
} }
void MainWindow::selectOpenni2() void MainWindow::selectOpenni2()
{ {
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI2); _preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI2, _ui->actionOpenNI2->isChecked());
} }
+145 -102
View File
@@ -1708,23 +1708,10 @@ QString PreferencesDialog::loadCustomConfig(const QString & section, const QStri
return value; return value;
} }
void PreferencesDialog::selectSourceImage(Src src) void PreferencesDialog::selectSourceImage(Src src, bool ckecked)
{ {
ULOGGER_DEBUG(""); 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 fromPrefDialog = false;
//bool modified = false; //bool modified = false;
if(src == kSrcUndef) if(src == kSrcUndef)
@@ -1743,56 +1730,85 @@ void PreferencesDialog::selectSourceImage(Src src)
src = kSrcUsbDevice; 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()); if(ckecked)
QDir dir(path);
if(!path.isEmpty() && dir.exists())
{ {
QStringList filters; if(_ui->general_checkBox_activateRGBD->isChecked())
filters << "*.jpg" << "*.ppm" << "*.bmp" << "*.png" << "*.pnm" << "*.tiff";
dir.setNameFilters(filters);
QFileInfoList files = dir.entryInfoList();
if(!files.empty())
{ {
_ui->source_comboBox_image_type->setCurrentIndex(1); int button = QMessageBox::information(this,
_ui->source_images_lineEdit_path->setText(path); tr("Desactivate RGB-D SLAM?"),
_ui->source_images_spinBox_startPos->setValue(1); tr("You've selected source input as images only and RGB-D SLAM mode is activated. "
_ui->source_images_refreshDir->setChecked(false); "RGB-D SLAM cannot work with images only so do you want to desactivate it?"),
} QMessageBox::Yes | QMessageBox::No);
else if(button & QMessageBox::Yes)
{ {
QMessageBox::information(this, _ui->general_checkBox_activateRGBD->setChecked(false);
tr("RTAB-Map"), }
tr("Images must be one of these formats: ") + filters.join(" "));
} }
} }
}
else if(src == kSrcVideo) _ui->groupBox_sourceImage->setChecked(false);
{
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);
} }
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_sourceDatabase->setChecked(false);
_ui->groupBox_sourceOpenni->setChecked(false); _ui->groupBox_sourceOpenni->setChecked(false);
}
if(!fromPrefDialog)
{
// Even if there is no change, MainWindow should be notified
makeObsoleteSourcePanel();
if(validateForm()) if(validateForm())
{ {
this->writeSettings(); 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(""); ULOGGER_DEBUG("");
QString dir = _ui->source_database_lineEdit_path->text(); if(user)
if(dir.isEmpty())
{ {
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(ckecked)
if(!path.isEmpty() && file.exists())
{ {
int r = QMessageBox::question(this, tr("Odometry in database..."), tr("Use odometry saved in database (if some saved)?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QString dir = _ui->source_database_lineEdit_path->text();
if(dir.isEmpty())
if(user)
{ {
// from user dir = getWorkingDirectory();
_ui->groupBox_sourceDatabase->setChecked(true);
} }
QString path = QFileDialog::getOpenFileName(this, tr("Select file"), dir, tr("RTAB-Map database files (*.db)"));
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes); QFile file(path);
_ui->source_database_lineEdit_path->setText(path); if(!path.isEmpty() && file.exists())
_ui->source_spinBox_databaseStartPos->setValue(0);
if(user && _obsoletePanels)
{ {
_ui->groupBox_sourceImage->setChecked(false); 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_sourceOpenni->setChecked(false);
if(validateForm()) _ui->groupBox_sourceDatabase->setChecked(true);
{ _ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
this->writeSettings(); _ui->source_database_lineEdit_path->setText(path);
} _ui->source_spinBox_databaseStartPos->setValue(0);
else }
{ }
this->readSettingsBegin();
} 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(""); ULOGGER_DEBUG("");
if(!_ui->general_checkBox_activateRGBD->isChecked()) if(ckecked)
{ {
int button = QMessageBox::information(this, if(!_ui->general_checkBox_activateRGBD->isChecked())
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); 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_opennipcl->setChecked(src == kSrcOpenNI_PCL);
_ui->radioButton_freenect->setChecked(src == kSrcFreenect); _ui->radioButton_freenect->setChecked(src == kSrcFreenect);
_ui->radioButton_opennicv->setChecked(src == kSrcOpenNI_CV); _ui->radioButton_opennicv->setChecked(src == kSrcOpenNI_CV);
_ui->radioButton_opennicvasus->setChecked(src == kSrcOpenNI_CV_ASUS); _ui->radioButton_opennicvasus->setChecked(src == kSrcOpenNI_CV_ASUS);
_ui->radioButton_openni2->setChecked(src == kSrcOpenNI2); _ui->radioButton_openni2->setChecked(src == kSrcOpenNI2);
if(_obsoletePanels) if(_ui->groupBox_sourceOpenni->isChecked())
{ {
_ui->groupBox_sourceImage->setChecked(false); _ui->groupBox_sourceImage->setChecked(false);
_ui->groupBox_sourceDatabase->setChecked(false); _ui->groupBox_sourceDatabase->setChecked(false);
@@ -1893,15 +1922,18 @@ void PreferencesDialog::selectSourceRGBD(Src src)
this->resetCalibration(); this->resetCalibration();
} }
} }
}
if(validateForm()) if(validateForm())
{ {
this->writeSettings(); // Even if there is no change, MainWindow should be notified
} makeObsoleteSourcePanel();
else
{ this->writeSettings();
this->readSettingsBegin(); }
} 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 QString PreferencesDialog::getSourceImageTypeStr() const
{ {