Added menu actions "Save settings..." and "Load settings..."
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@198 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
7a3080cd43
commit
3eda414d91
@ -38,9 +38,10 @@
|
|||||||
#include "utilite/UDirectory.h"
|
#include "utilite/UDirectory.h"
|
||||||
|
|
||||||
// Camera ownership transferred
|
// Camera ownership transferred
|
||||||
MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
MainWindow::MainWindow(Camera * camera, const QString & settings, QWidget * parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
camera_(camera),
|
camera_(camera),
|
||||||
|
settings_(settings),
|
||||||
likelihoodCurve_(0),
|
likelihoodCurve_(0),
|
||||||
lowestRefreshRate_(99),
|
lowestRefreshRate_(99),
|
||||||
objectsModified_(false)
|
objectsModified_(false)
|
||||||
@ -67,9 +68,14 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
|||||||
ui_->dockWidget_plot->setVisible(false);
|
ui_->dockWidget_plot->setVisible(false);
|
||||||
ui_->widget_controls->setVisible(false);
|
ui_->widget_controls->setVisible(false);
|
||||||
|
|
||||||
|
if(settings_.isEmpty())
|
||||||
|
{
|
||||||
|
settings_ = Settings::iniDefaultPath();
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray geometry;
|
QByteArray geometry;
|
||||||
QByteArray state;
|
QByteArray state;
|
||||||
Settings::loadSettings(Settings::iniDefaultPath(), &geometry, &state);
|
Settings::loadSettings(settings_, &geometry, &state);
|
||||||
this->restoreGeometry(geometry);
|
this->restoreGeometry(geometry);
|
||||||
this->restoreState(state);
|
this->restoreState(state);
|
||||||
|
|
||||||
@ -121,6 +127,8 @@ connect(ui_->toolBox, SIGNAL(parametersChanged(const QStringList &)), this, SLOT
|
|||||||
connect(ui_->actionAbout, SIGNAL(triggered()), aboutDialog_ , SLOT(exec()));
|
connect(ui_->actionAbout, SIGNAL(triggered()), aboutDialog_ , SLOT(exec()));
|
||||||
connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
|
connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
|
||||||
connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));
|
connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));
|
||||||
|
connect(ui_->actionSave_settings, SIGNAL(triggered()), this, SLOT(saveSettings()));
|
||||||
|
connect(ui_->actionLoad_settings, SIGNAL(triggered()), this, SLOT(loadSettings()));
|
||||||
|
|
||||||
connect(ui_->pushButton_play, SIGNAL(clicked()), this, SLOT(startProcessing()));
|
connect(ui_->pushButton_play, SIGNAL(clicked()), this, SLOT(startProcessing()));
|
||||||
connect(ui_->pushButton_stop, SIGNAL(clicked()), this, SLOT(stopProcessing()));
|
connect(ui_->pushButton_stop, SIGNAL(clicked()), this, SLOT(stopProcessing()));
|
||||||
@ -182,7 +190,7 @@ void MainWindow::closeEvent(QCloseEvent * event)
|
|||||||
}
|
}
|
||||||
if(quit)
|
if(quit)
|
||||||
{
|
{
|
||||||
Settings::saveSettings(Settings::iniDefaultPath(), this->saveGeometry(), this->saveState());
|
Settings::saveSettings(settings_, this->saveGeometry(), this->saveState());
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -201,6 +209,65 @@ void MainWindow::setSourceImageText(const QString & text)
|
|||||||
ui_->imageView_source->setTextLabel(text);
|
ui_->imageView_source->setTextLabel(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::loadSettings()
|
||||||
|
{
|
||||||
|
QString path = QFileDialog::getOpenFileName(this, tr("Load settings..."), Settings::workingDirectory(), "*.ini");
|
||||||
|
if(!path.isEmpty())
|
||||||
|
{
|
||||||
|
if(QFileInfo(path).suffix().compare("ini") != 0)
|
||||||
|
{
|
||||||
|
path.append(".ini");
|
||||||
|
}
|
||||||
|
loadSettings(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MainWindow::saveSettings()
|
||||||
|
{
|
||||||
|
QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), Settings::workingDirectory(), "*.ini");
|
||||||
|
if(!path.isEmpty())
|
||||||
|
{
|
||||||
|
if(QFileInfo(path).suffix().compare("ini") != 0)
|
||||||
|
{
|
||||||
|
path.append(".ini");
|
||||||
|
}
|
||||||
|
saveSettings(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWindow::loadSettings(const QString & path)
|
||||||
|
{
|
||||||
|
if(!path.isEmpty() && QFileInfo(path).suffix().compare("ini") == 0)
|
||||||
|
{
|
||||||
|
QByteArray geometry;
|
||||||
|
QByteArray state;
|
||||||
|
Settings::loadSettings(path, &geometry, &state);
|
||||||
|
this->restoreGeometry(geometry);
|
||||||
|
this->restoreState(state);
|
||||||
|
|
||||||
|
//update parameters tool box
|
||||||
|
const ParametersMap & parameters = Settings::getParameters();
|
||||||
|
for(ParametersMap::const_iterator iter = parameters.begin(); iter!= parameters.constEnd(); ++iter)
|
||||||
|
{
|
||||||
|
ui_->toolBox->updateParameter(iter.key());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
printf("Path \"%s\" not valid (should be *.ini)\n", path.toStdString().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWindow::saveSettings(const QString & path)
|
||||||
|
{
|
||||||
|
if(!path.isEmpty() && QFileInfo(path).suffix().compare("ini") == 0)
|
||||||
|
{
|
||||||
|
Settings::saveSettings(path, this->saveGeometry(), this->saveState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
printf("Path \"%s\" not valid (should be *.ini)\n", path.toStdString().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int MainWindow::loadObjects(const QString & dirPath)
|
int MainWindow::loadObjects(const QString & dirPath)
|
||||||
{
|
{
|
||||||
int loadedObjects = 0;
|
int loadedObjects = 0;
|
||||||
|
|||||||
@ -33,9 +33,12 @@ class MainWindow : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(Camera * camera = 0, QWidget * parent = 0);
|
MainWindow(Camera * camera = 0, const QString & settings = "", QWidget * parent = 0);
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
|
bool loadSettings(const QString & path);
|
||||||
|
bool saveSettings(const QString & path);
|
||||||
|
|
||||||
int loadObjects(const QString & dirPath);
|
int loadObjects(const QString & dirPath);
|
||||||
void saveObjects(const QString & dirPath);
|
void saveObjects(const QString & dirPath);
|
||||||
|
|
||||||
@ -51,6 +54,8 @@ public slots:
|
|||||||
void pauseProcessing();
|
void pauseProcessing();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void loadSettings();
|
||||||
|
void saveSettings();
|
||||||
void loadObjects();
|
void loadObjects();
|
||||||
bool saveObjects();
|
bool saveObjects();
|
||||||
void addObjectFromScene();
|
void addObjectFromScene();
|
||||||
@ -80,6 +85,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
Ui_mainWindow * ui_;
|
Ui_mainWindow * ui_;
|
||||||
Camera * camera_;
|
Camera * camera_;
|
||||||
|
QString settings_;
|
||||||
rtabmap::PdfPlotCurve * likelihoodCurve_;
|
rtabmap::PdfPlotCurve * likelihoodCurve_;
|
||||||
AboutDialog * aboutDialog_;
|
AboutDialog * aboutDialog_;
|
||||||
QList<ObjWidget*> objects_;
|
QList<ObjWidget*> objects_;
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>825</width>
|
<width>826</width>
|
||||||
<height>441</height>
|
<height>448</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -108,7 +108,7 @@
|
|||||||
<widget class="QWidget" name="widget_controls" native="true">
|
<widget class="QWidget" name="widget_controls" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>-1</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -202,8 +202,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>825</width>
|
<width>826</width>
|
||||||
<height>22</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -213,6 +213,9 @@
|
|||||||
<addaction name="actionLoad_objects"/>
|
<addaction name="actionLoad_objects"/>
|
||||||
<addaction name="actionSave_objects"/>
|
<addaction name="actionSave_objects"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionLoad_settings"/>
|
||||||
|
<addaction name="actionSave_settings"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuEdit">
|
<widget class="QMenu" name="menuEdit">
|
||||||
@ -474,8 +477,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>348</width>
|
<width>360</width>
|
||||||
<height>114</height>
|
<height>120</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -533,7 +536,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>198</width>
|
<width>198</width>
|
||||||
<height>314</height>
|
<height>318</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
||||||
@ -696,6 +699,16 @@
|
|||||||
<string>Camera from directory of images...</string>
|
<string>Camera from directory of images...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSave_settings">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save settings...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionLoad_settings">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load settings...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user