GUI: Core parameters should be explicitly saved

This commit is contained in:
Mathieu Labbe
2015-02-13 16:50:32 -05:00
parent ad05c5902a
commit 2f4acb9581
4 changed files with 50 additions and 41 deletions

View File

@@ -364,6 +364,11 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
qRegisterMetaType<rtabmap::ParametersMap>("rtabmap::ParametersMap");
connect(_preferencesDialog, SIGNAL(settingsChanged(rtabmap::ParametersMap)), this, SLOT(applyPrefSettings(rtabmap::ParametersMap)));
// config GUI modified
connect(_preferencesDialog, SIGNAL(settingsChanged(PreferencesDialog::PANEL_FLAGS)), this, SLOT(configGUIModified()));
if(prefDialog == 0)
{
connect(_preferencesDialog, SIGNAL(settingsChanged(rtabmap::ParametersMap)), this, SLOT(configGUIModified()));
}
connect(_ui->imageView_source, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_ui->imageView_loopClosure, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_ui->imageView_odometry, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
@@ -492,7 +497,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
{
QMessageBox::Button b=QMessageBox::question(this,
tr("RTAB-Map"),
tr("There are unsaved GUI changes. Save them?"),
tr("There are unsaved changes. Save them?"),
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard);
if(b == QMessageBox::Save)
{
@@ -2252,6 +2257,7 @@ void MainWindow::saveConfigGUI()
_preferencesDialog->saveWidgetState(_exportDialog);
_preferencesDialog->saveWidgetState(_postProcessingDialog);
_preferencesDialog->saveWidgetState(_ui->graphicsView_graphView);
_preferencesDialog->saveSettings();
this->setWindowModified(false);
}

View File

@@ -545,6 +545,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
}
PreferencesDialog::~PreferencesDialog() {
// remove tmp ini file
QFile::remove(getTmpIniFilePath());
delete _ui;
}
@@ -558,11 +560,16 @@ void PreferencesDialog::init()
}
this->readSettings();
this->writeSettings();// This will create the ini file if not exist
this->writeSettings(getTmpIniFilePath());
_initialized = true;
}
void PreferencesDialog::saveSettings()
{
writeSettings();
}
void PreferencesDialog::setupTreeView()
{
if(_indexModel)
@@ -753,6 +760,8 @@ void PreferencesDialog::closeEvent(QCloseEvent *event)
UDEBUG("");
_parameters.clear();
_obsoletePanels = kPanelDummy;
this->readGuiSettings(getTmpIniFilePath());
this->readCameraSettings(getTmpIniFilePath());
event->accept();
}
@@ -766,6 +775,8 @@ void PreferencesDialog::closeDialog ( QAbstractButton * button )
case QDialogButtonBox::RejectRole:
_parameters.clear();
_obsoletePanels = kPanelDummy;
this->readGuiSettings(getTmpIniFilePath());
this->readCameraSettings(getTmpIniFilePath());
this->reject();
break;
@@ -775,7 +786,7 @@ void PreferencesDialog::closeDialog ( QAbstractButton * button )
{
if(validateForm())
{
writeSettings();
writeSettings(getTmpIniFilePath());
this->accept();
}
}
@@ -799,7 +810,7 @@ void PreferencesDialog::resetApply ( QAbstractButton * button )
updateBasicParameter();// make that changes without editing finished signal are updated.
if(validateForm())
{
writeSettings();
writeSettings(getTmpIniFilePath());
}
break;
@@ -995,6 +1006,11 @@ QString PreferencesDialog::getIniFilePath() const
return privatePath + "/rtabmap.ini";
}
QString PreferencesDialog::getTmpIniFilePath() const
{
return getIniFilePath()+".tmp";
}
void PreferencesDialog::loadConfigFrom()
{
QString path = QFileDialog::getOpenFileName(this, tr("Load settings..."), this->getWorkingDirectory(), "*.ini");
@@ -1246,7 +1262,9 @@ bool PreferencesDialog::saveConfigTo()
QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+QDir::separator()+"config.ini", "*.ini");
if(!path.isEmpty())
{
this->writeSettings(path);
writeGuiSettings(path);
writeCameraSettings(path);
writeCoreSettings(path);
return true;
}
return false;
@@ -1288,7 +1306,7 @@ void PreferencesDialog::writeSettings(const QString & filePath)
_obsoletePanels = kPanelDummy;
}
void PreferencesDialog::writeGuiSettings(const QString & filePath)
void PreferencesDialog::writeGuiSettings(const QString & filePath) const
{
QString path = getIniFilePath();
if(!filePath.isEmpty())
@@ -1346,7 +1364,7 @@ void PreferencesDialog::writeGuiSettings(const QString & filePath)
settings.endGroup(); // rtabmap
}
void PreferencesDialog::writeCameraSettings(const QString & filePath)
void PreferencesDialog::writeCameraSettings(const QString & filePath) const
{
QString path = getIniFilePath();
if(!filePath.isEmpty())
@@ -1404,7 +1422,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath)
settings.endGroup();
}
void PreferencesDialog::writeCoreSettings(const QString & filePath)
void PreferencesDialog::writeCoreSettings(const QString & filePath) const
{
QString path = getIniFilePath();
if(!filePath.isEmpty())
@@ -1611,7 +1629,7 @@ void PreferencesDialog::readSettingsEnd()
{
QApplication::processEvents();
this->readSettings();
this->readSettings(getTmpIniFilePath());
_progressDialog->setValue(1);
if(this->isVisible())
@@ -2026,7 +2044,7 @@ void PreferencesDialog::selectSourceImage(Src src, bool ckecked)
if(validateForm())
{
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{
@@ -2077,7 +2095,7 @@ void PreferencesDialog::selectSourceDatabase(bool user, bool ckecked)
if(validateForm())
{
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{
@@ -2144,7 +2162,7 @@ void PreferencesDialog::selectSourceRGBD(Src src, bool ckecked)
// Even if there is no change, MainWindow should be notified
makeObsoleteSourcePanel();
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{
@@ -3210,24 +3228,6 @@ bool PreferencesDialog::isSLAMMode() const
}
/*** SETTERS ***/
void PreferencesDialog::setHardThr(int value)
{
double dValue = double(value)/100;
ULOGGER_DEBUG("PreferencesDialog::setHardThr(%f)", dValue);
if(_ui->general_doubleSpinBox_hardThr->value() != dValue)
{
_ui->general_doubleSpinBox_hardThr->setValue(dValue);
if(validateForm())
{
this->writeSettings();
}
else
{
this->readSettingsBegin();
}
}
}
void PreferencesDialog::setInputRate(double value)
{
ULOGGER_DEBUG("imgRate=%2.2f", value);
@@ -3236,7 +3236,7 @@ void PreferencesDialog::setInputRate(double value)
_ui->general_doubleSpinBox_imgRate->setValue(value);
if(validateForm())
{
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{
@@ -3253,7 +3253,7 @@ void PreferencesDialog::setDetectionRate(double value)
_ui->general_doubleSpinBox_detectionRate->setValue(value);
if(validateForm())
{
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{
@@ -3270,7 +3270,7 @@ void PreferencesDialog::setTimeLimit(float value)
_ui->general_doubleSpinBox_timeThr->setValue(value);
if(validateForm())
{
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{
@@ -3287,7 +3287,7 @@ void PreferencesDialog::setSLAMMode(bool enabled)
_ui->general_checkBox_SLAM_mode->setChecked(enabled);
if(validateForm())
{
this->writeSettings();
this->writeSettings(getTmpIniFilePath());
}
else
{

View File

@@ -37,6 +37,8 @@
<addaction name="actionNew_database"/>
<addaction name="actionOpen_database"/>
<addaction name="separator"/>
<addaction name="actionSave_GUI_config"/>
<addaction name="separator"/>
<addaction name="actionSave_point_cloud"/>
<addaction name="actionExport_2D_scans_ply_pcd"/>
<addaction name="actionExport_2D_Grid_map_bmp_png"/>
@@ -178,7 +180,6 @@
<addaction name="action360p"/>
<addaction name="action240p"/>
</widget>
<addaction name="actionSave_GUI_config"/>
<addaction name="menuShow_view"/>
<addaction name="menuFigures"/>
<addaction name="actionScreenshot"/>
@@ -1119,7 +1120,7 @@
</action>
<action name="actionSave_GUI_config">
<property name="text">
<string>Save GUI config</string>
<string>Save config</string>
</property>
</action>
</widget>