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());
} }
+75 -32
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,12 +1730,30 @@ void PreferencesDialog::selectSourceImage(Src src)
src = kSrcUsbDevice; src = kSrcUsbDevice;
} }
} }
else
if(!fromPrefDialog)
{ {
// from user if(ckecked)
_ui->groupBox_sourceImage->setChecked(true); {
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);
}
}
} }
_ui->groupBox_sourceImage->setChecked(false);
}
if(ckecked)
{
if(src == kSrcImages) if(src == kSrcImages)
{ {
QString path = QFileDialog::getExistingDirectory(this, QString(), _ui->source_images_lineEdit_path->text()); QString path = QFileDialog::getExistingDirectory(this, QString(), _ui->source_images_lineEdit_path->text());
@@ -1765,6 +1770,7 @@ void PreferencesDialog::selectSourceImage(Src src)
_ui->source_images_lineEdit_path->setText(path); _ui->source_images_lineEdit_path->setText(path);
_ui->source_images_spinBox_startPos->setValue(1); _ui->source_images_spinBox_startPos->setValue(1);
_ui->source_images_refreshDir->setChecked(false); _ui->source_images_refreshDir->setChecked(false);
_ui->groupBox_sourceImage->setChecked(true);
} }
else else
{ {
@@ -1782,17 +1788,27 @@ void PreferencesDialog::selectSourceImage(Src src)
{ {
_ui->source_comboBox_image_type->setCurrentIndex(2); _ui->source_comboBox_image_type->setCurrentIndex(2);
_ui->source_video_lineEdit_path->setText(path); _ui->source_video_lineEdit_path->setText(path);
_ui->groupBox_sourceImage->setChecked(true);
} }
} }
else // kSrcUsbDevice else // kSrcUsbDevice
{ {
_ui->source_comboBox_image_type->setCurrentIndex(0); _ui->source_comboBox_image_type->setCurrentIndex(0);
_ui->groupBox_sourceImage->setChecked(true);
}
} }
if(!fromPrefDialog && _obsoletePanels) 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,10 +1820,17 @@ void PreferencesDialog::selectSourceImage(Src src)
} }
} }
void PreferencesDialog::selectSourceDatabase(bool user) void PreferencesDialog::selectSourceDatabase(bool user, bool ckecked)
{ {
ULOGGER_DEBUG(""); ULOGGER_DEBUG("");
if(user)
{
_ui->groupBox_sourceDatabase->setChecked(false);
}
if(ckecked)
{
QString dir = _ui->source_database_lineEdit_path->text(); QString dir = _ui->source_database_lineEdit_path->text();
if(dir.isEmpty()) if(dir.isEmpty())
{ {
@@ -1819,20 +1842,24 @@ void PreferencesDialog::selectSourceDatabase(bool user)
{ {
int r = QMessageBox::question(this, tr("Odometry in database..."), tr("Use odometry saved in database (if some saved)?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); 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)
{
// from user
_ui->groupBox_sourceDatabase->setChecked(true); _ui->groupBox_sourceDatabase->setChecked(true);
}
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes); _ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
_ui->source_database_lineEdit_path->setText(path); _ui->source_database_lineEdit_path->setText(path);
_ui->source_spinBox_databaseStartPos->setValue(0); _ui->source_spinBox_databaseStartPos->setValue(0);
}
}
if(user && _obsoletePanels) if(_ui->groupBox_sourceDatabase->isChecked())
{ {
_ui->groupBox_sourceImage->setChecked(false); _ui->groupBox_sourceImage->setChecked(false);
_ui->groupBox_sourceOpenni->setChecked(false); _ui->groupBox_sourceOpenni->setChecked(false);
}
if(user)
{
// Even if there is no change, MainWindow should be notified
makeObsoleteSourcePanel();
if(validateForm()) if(validateForm())
{ {
this->writeSettings(); this->writeSettings();
@@ -1843,12 +1870,13 @@ void PreferencesDialog::selectSourceDatabase(bool user)
} }
} }
} }
}
void PreferencesDialog::selectSourceRGBD(Src src) void PreferencesDialog::selectSourceRGBD(Src src, bool ckecked)
{ {
ULOGGER_DEBUG(""); ULOGGER_DEBUG("");
if(ckecked)
{
if(!_ui->general_checkBox_activateRGBD->isChecked()) if(!_ui->general_checkBox_activateRGBD->isChecked())
{ {
int button = QMessageBox::information(this, int button = QMessageBox::information(this,
@@ -1861,15 +1889,16 @@ void PreferencesDialog::selectSourceRGBD(Src src)
_ui->general_checkBox_activateRGBD->setChecked(true); _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,9 +1922,13 @@ void PreferencesDialog::selectSourceRGBD(Src src)
this->resetCalibration(); this->resetCalibration();
} }
} }
}
if(validateForm()) if(validateForm())
{ {
// Even if there is no change, MainWindow should be notified
makeObsoleteSourcePanel();
this->writeSettings(); this->writeSettings();
} }
else else
@@ -1903,7 +1936,6 @@ void PreferencesDialog::selectSourceRGBD(Src src)
this->readSettingsBegin(); this->readSettingsBegin();
} }
} }
}
void PreferencesDialog::openDatabaseViewer() void PreferencesDialog::openDatabaseViewer()
{ {
@@ -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
{ {