mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 00:37:46 +08:00
GUI: Core parameters should be explicitly saved
This commit is contained in:
@@ -97,11 +97,12 @@ public:
|
|||||||
virtual QString getIniFilePath() const;
|
virtual QString getIniFilePath() const;
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
// save stuff
|
||||||
|
void saveSettings();
|
||||||
void saveWindowGeometry(const QWidget * window);
|
void saveWindowGeometry(const QWidget * window);
|
||||||
void loadWindowGeometry(QWidget * window);
|
void loadWindowGeometry(QWidget * window);
|
||||||
void saveMainWindowState(const QMainWindow * mainWindow);
|
void saveMainWindowState(const QMainWindow * mainWindow);
|
||||||
void loadMainWindowState(QMainWindow * mainWindow, bool & maximized);
|
void loadMainWindowState(QMainWindow * mainWindow, bool & maximized);
|
||||||
|
|
||||||
void saveWidgetState(const QWidget * widget);
|
void saveWidgetState(const QWidget * widget);
|
||||||
void loadWidgetState(QWidget * widget);
|
void loadWidgetState(QWidget * widget);
|
||||||
|
|
||||||
@@ -207,7 +208,6 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void setInputRate(double value);
|
void setInputRate(double value);
|
||||||
void setDetectionRate(double value);
|
void setDetectionRate(double 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, bool checked = true);
|
void selectSourceImage(Src src = kSrcUndef, bool checked = true);
|
||||||
@@ -260,9 +260,11 @@ protected:
|
|||||||
virtual bool readCoreSettings(const QString & filePath = QString());
|
virtual bool readCoreSettings(const QString & filePath = QString());
|
||||||
|
|
||||||
virtual void writeSettings(const QString & filePath = QString());
|
virtual void writeSettings(const QString & filePath = QString());
|
||||||
virtual void writeGuiSettings(const QString & filePath = QString());
|
virtual void writeGuiSettings(const QString & filePath = QString()) const;
|
||||||
virtual void writeCameraSettings(const QString & filePath = QString());
|
virtual void writeCameraSettings(const QString & filePath = QString()) const;
|
||||||
virtual void writeCoreSettings(const QString & filePath = QString());
|
virtual void writeCoreSettings(const QString & filePath = QString()) const;
|
||||||
|
|
||||||
|
QString getTmpIniFilePath() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool validateForm();
|
bool validateForm();
|
||||||
|
|||||||
@@ -364,6 +364,11 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
|
|||||||
qRegisterMetaType<rtabmap::ParametersMap>("rtabmap::ParametersMap");
|
qRegisterMetaType<rtabmap::ParametersMap>("rtabmap::ParametersMap");
|
||||||
connect(_preferencesDialog, SIGNAL(settingsChanged(rtabmap::ParametersMap)), this, SLOT(applyPrefSettings(rtabmap::ParametersMap)));
|
connect(_preferencesDialog, SIGNAL(settingsChanged(rtabmap::ParametersMap)), this, SLOT(applyPrefSettings(rtabmap::ParametersMap)));
|
||||||
// config GUI modified
|
// 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_source, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
|
||||||
connect(_ui->imageView_loopClosure, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
|
connect(_ui->imageView_loopClosure, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
|
||||||
connect(_ui->imageView_odometry, 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,
|
QMessageBox::Button b=QMessageBox::question(this,
|
||||||
tr("RTAB-Map"),
|
tr("RTAB-Map"),
|
||||||
tr("There are unsaved GUI changes. Save them?"),
|
tr("There are unsaved changes. Save them?"),
|
||||||
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard);
|
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard);
|
||||||
if(b == QMessageBox::Save)
|
if(b == QMessageBox::Save)
|
||||||
{
|
{
|
||||||
@@ -2252,6 +2257,7 @@ void MainWindow::saveConfigGUI()
|
|||||||
_preferencesDialog->saveWidgetState(_exportDialog);
|
_preferencesDialog->saveWidgetState(_exportDialog);
|
||||||
_preferencesDialog->saveWidgetState(_postProcessingDialog);
|
_preferencesDialog->saveWidgetState(_postProcessingDialog);
|
||||||
_preferencesDialog->saveWidgetState(_ui->graphicsView_graphView);
|
_preferencesDialog->saveWidgetState(_ui->graphicsView_graphView);
|
||||||
|
_preferencesDialog->saveSettings();
|
||||||
this->setWindowModified(false);
|
this->setWindowModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -545,6 +545,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreferencesDialog::~PreferencesDialog() {
|
PreferencesDialog::~PreferencesDialog() {
|
||||||
|
// remove tmp ini file
|
||||||
|
QFile::remove(getTmpIniFilePath());
|
||||||
delete _ui;
|
delete _ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,11 +560,16 @@ void PreferencesDialog::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->readSettings();
|
this->readSettings();
|
||||||
this->writeSettings();// This will create the ini file if not exist
|
this->writeSettings(getTmpIniFilePath());
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::saveSettings()
|
||||||
|
{
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void PreferencesDialog::setupTreeView()
|
void PreferencesDialog::setupTreeView()
|
||||||
{
|
{
|
||||||
if(_indexModel)
|
if(_indexModel)
|
||||||
@@ -753,6 +760,8 @@ void PreferencesDialog::closeEvent(QCloseEvent *event)
|
|||||||
UDEBUG("");
|
UDEBUG("");
|
||||||
_parameters.clear();
|
_parameters.clear();
|
||||||
_obsoletePanels = kPanelDummy;
|
_obsoletePanels = kPanelDummy;
|
||||||
|
this->readGuiSettings(getTmpIniFilePath());
|
||||||
|
this->readCameraSettings(getTmpIniFilePath());
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,6 +775,8 @@ void PreferencesDialog::closeDialog ( QAbstractButton * button )
|
|||||||
case QDialogButtonBox::RejectRole:
|
case QDialogButtonBox::RejectRole:
|
||||||
_parameters.clear();
|
_parameters.clear();
|
||||||
_obsoletePanels = kPanelDummy;
|
_obsoletePanels = kPanelDummy;
|
||||||
|
this->readGuiSettings(getTmpIniFilePath());
|
||||||
|
this->readCameraSettings(getTmpIniFilePath());
|
||||||
this->reject();
|
this->reject();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -775,7 +786,7 @@ void PreferencesDialog::closeDialog ( QAbstractButton * button )
|
|||||||
{
|
{
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
writeSettings();
|
writeSettings(getTmpIniFilePath());
|
||||||
this->accept();
|
this->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -799,7 +810,7 @@ void PreferencesDialog::resetApply ( QAbstractButton * button )
|
|||||||
updateBasicParameter();// make that changes without editing finished signal are updated.
|
updateBasicParameter();// make that changes without editing finished signal are updated.
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
writeSettings();
|
writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -995,6 +1006,11 @@ QString PreferencesDialog::getIniFilePath() const
|
|||||||
return privatePath + "/rtabmap.ini";
|
return privatePath + "/rtabmap.ini";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PreferencesDialog::getTmpIniFilePath() const
|
||||||
|
{
|
||||||
|
return getIniFilePath()+".tmp";
|
||||||
|
}
|
||||||
|
|
||||||
void PreferencesDialog::loadConfigFrom()
|
void PreferencesDialog::loadConfigFrom()
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Load settings..."), this->getWorkingDirectory(), "*.ini");
|
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");
|
QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+QDir::separator()+"config.ini", "*.ini");
|
||||||
if(!path.isEmpty())
|
if(!path.isEmpty())
|
||||||
{
|
{
|
||||||
this->writeSettings(path);
|
writeGuiSettings(path);
|
||||||
|
writeCameraSettings(path);
|
||||||
|
writeCoreSettings(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1288,7 +1306,7 @@ void PreferencesDialog::writeSettings(const QString & filePath)
|
|||||||
_obsoletePanels = kPanelDummy;
|
_obsoletePanels = kPanelDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::writeGuiSettings(const QString & filePath)
|
void PreferencesDialog::writeGuiSettings(const QString & filePath) const
|
||||||
{
|
{
|
||||||
QString path = getIniFilePath();
|
QString path = getIniFilePath();
|
||||||
if(!filePath.isEmpty())
|
if(!filePath.isEmpty())
|
||||||
@@ -1346,7 +1364,7 @@ void PreferencesDialog::writeGuiSettings(const QString & filePath)
|
|||||||
settings.endGroup(); // rtabmap
|
settings.endGroup(); // rtabmap
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::writeCameraSettings(const QString & filePath)
|
void PreferencesDialog::writeCameraSettings(const QString & filePath) const
|
||||||
{
|
{
|
||||||
QString path = getIniFilePath();
|
QString path = getIniFilePath();
|
||||||
if(!filePath.isEmpty())
|
if(!filePath.isEmpty())
|
||||||
@@ -1404,7 +1422,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath)
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::writeCoreSettings(const QString & filePath)
|
void PreferencesDialog::writeCoreSettings(const QString & filePath) const
|
||||||
{
|
{
|
||||||
QString path = getIniFilePath();
|
QString path = getIniFilePath();
|
||||||
if(!filePath.isEmpty())
|
if(!filePath.isEmpty())
|
||||||
@@ -1611,7 +1629,7 @@ void PreferencesDialog::readSettingsEnd()
|
|||||||
{
|
{
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
||||||
this->readSettings();
|
this->readSettings(getTmpIniFilePath());
|
||||||
|
|
||||||
_progressDialog->setValue(1);
|
_progressDialog->setValue(1);
|
||||||
if(this->isVisible())
|
if(this->isVisible())
|
||||||
@@ -2026,7 +2044,7 @@ void PreferencesDialog::selectSourceImage(Src src, bool ckecked)
|
|||||||
|
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2077,7 +2095,7 @@ void PreferencesDialog::selectSourceDatabase(bool user, bool ckecked)
|
|||||||
|
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2144,7 +2162,7 @@ void PreferencesDialog::selectSourceRGBD(Src src, bool ckecked)
|
|||||||
// Even if there is no change, MainWindow should be notified
|
// Even if there is no change, MainWindow should be notified
|
||||||
makeObsoleteSourcePanel();
|
makeObsoleteSourcePanel();
|
||||||
|
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3210,24 +3228,6 @@ bool PreferencesDialog::isSLAMMode() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*** SETTERS ***/
|
/*** 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)
|
void PreferencesDialog::setInputRate(double value)
|
||||||
{
|
{
|
||||||
ULOGGER_DEBUG("imgRate=%2.2f", value);
|
ULOGGER_DEBUG("imgRate=%2.2f", value);
|
||||||
@@ -3236,7 +3236,7 @@ void PreferencesDialog::setInputRate(double value)
|
|||||||
_ui->general_doubleSpinBox_imgRate->setValue(value);
|
_ui->general_doubleSpinBox_imgRate->setValue(value);
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3253,7 +3253,7 @@ void PreferencesDialog::setDetectionRate(double value)
|
|||||||
_ui->general_doubleSpinBox_detectionRate->setValue(value);
|
_ui->general_doubleSpinBox_detectionRate->setValue(value);
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3270,7 +3270,7 @@ void PreferencesDialog::setTimeLimit(float value)
|
|||||||
_ui->general_doubleSpinBox_timeThr->setValue(value);
|
_ui->general_doubleSpinBox_timeThr->setValue(value);
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3287,7 +3287,7 @@ void PreferencesDialog::setSLAMMode(bool enabled)
|
|||||||
_ui->general_checkBox_SLAM_mode->setChecked(enabled);
|
_ui->general_checkBox_SLAM_mode->setChecked(enabled);
|
||||||
if(validateForm())
|
if(validateForm())
|
||||||
{
|
{
|
||||||
this->writeSettings();
|
this->writeSettings(getTmpIniFilePath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
<addaction name="actionNew_database"/>
|
<addaction name="actionNew_database"/>
|
||||||
<addaction name="actionOpen_database"/>
|
<addaction name="actionOpen_database"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionSave_GUI_config"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionSave_point_cloud"/>
|
<addaction name="actionSave_point_cloud"/>
|
||||||
<addaction name="actionExport_2D_scans_ply_pcd"/>
|
<addaction name="actionExport_2D_scans_ply_pcd"/>
|
||||||
<addaction name="actionExport_2D_Grid_map_bmp_png"/>
|
<addaction name="actionExport_2D_Grid_map_bmp_png"/>
|
||||||
@@ -178,7 +180,6 @@
|
|||||||
<addaction name="action360p"/>
|
<addaction name="action360p"/>
|
||||||
<addaction name="action240p"/>
|
<addaction name="action240p"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionSave_GUI_config"/>
|
|
||||||
<addaction name="menuShow_view"/>
|
<addaction name="menuShow_view"/>
|
||||||
<addaction name="menuFigures"/>
|
<addaction name="menuFigures"/>
|
||||||
<addaction name="actionScreenshot"/>
|
<addaction name="actionScreenshot"/>
|
||||||
@@ -1119,7 +1120,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionSave_GUI_config">
|
<action name="actionSave_GUI_config">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save GUI config</string>
|
<string>Save config</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user