Cleanup gui

Fixed crash when a new location (B merged with previous location A through rehearsal) and then loop on a location already merged with the location A (which is not anymore in WM)
Updated rejected hypothesis tag

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@299 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2011-07-23 03:55:05 +00:00
parent 9fe16dd504
commit 649153e1df
9 changed files with 156 additions and 201 deletions

View File

@@ -101,13 +101,13 @@ private slots:
void clearTheCache();
void saveFigures();
void loadFigures();
void selectScreenCaptureFormat(bool checked);
void updateElapsedTime();
void processStats(const rtabmap::Statistics & stat);
void applyAllPrefSettings();
void applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags);
void applyPrefSettings(const rtabmap::ParametersMap & parameters);
void processRtabmapEventInit(int status, const QString & info);
void updateItemsShown();
void changeImgRateSetting();
void changeTimeLimitSetting();
void captureScreen();
@@ -157,6 +157,7 @@ private:
QActionGroup * _selectSourceGrp;
QString _graphSavingFileName;
QString _autoScreenCaptureFormat;
};
}

View File

@@ -24,7 +24,9 @@
#include <QtGui/QMenu>
#include <QtGui/QFileDialog>
#include <QtCore/QDir>
#include <QtGui/QAction>
#include "utilite/ULogger.h"
#include "KeypointItem.h"
namespace rtabmap {
@@ -37,6 +39,15 @@ ImageView::ImageView(QWidget * parent) :
this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
this->setScene(new QGraphicsScene(this));
connect(this->scene(), SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(updateZoom()));
_menu = new QMenu(tr(""), this);
_showImage = _menu->addAction(tr("Show image"));
_showImage->setCheckable(true);
_showImage->setChecked(true);
_showFeatures = _menu->addAction(tr("Show features"));
_showFeatures->setCheckable(true);
_showFeatures->setChecked(true);
_saveImage = _menu->addAction(tr("Save picture..."));
}
ImageView::~ImageView() {
@@ -49,12 +60,20 @@ void ImageView::resetZoom()
this->setDragMode(QGraphicsView::NoDrag);
}
bool ImageView::isImageShown()
{
return _showImage->isChecked();
}
bool ImageView::isFeaturesShown()
{
return _showFeatures->isChecked();
}
void ImageView::contextMenuEvent(QContextMenuEvent * e)
{
QMenu menu(tr(""), this);
QAction * saveImage = menu.addAction(tr("Save picture..."));
if(menu.exec(e->globalPos()) == saveImage)
QAction * action = _menu->exec(e->globalPos());
if(action == _saveImage)
{
QString text;
#ifdef QT_SVG_LIB
@@ -71,6 +90,26 @@ void ImageView::contextMenuEvent(QContextMenuEvent * e)
img.save(text);
}
}
else if(action == _showFeatures || action == _showImage)
{
this->updateItemsShown();
}
}
void ImageView::updateItemsShown()
{
QList<QGraphicsItem*> items = this->scene()->items();
for(int i=0; i<items.size(); ++i)
{
if(qgraphicsitem_cast<KeypointItem*>(items.at(i)))
{
items.at(i)->setVisible(_showFeatures->isChecked());
}
else if(qgraphicsitem_cast<QGraphicsPixmapItem*>(items.at(i)))
{
items.at(i)->setVisible(_showImage->isChecked());
}
}
}
void ImageView::updateZoom()

View File

@@ -23,6 +23,9 @@
#include <QtGui/QGraphicsView>
#include <QtCore/QRectF>
class QAction;
class QMenu;
namespace rtabmap {
class ImageView : public QGraphicsView {
@@ -35,6 +38,9 @@ public:
void resetZoom();
bool isImageShown();
bool isFeaturesShown();
protected:
virtual void contextMenuEvent(QContextMenuEvent * e);
virtual void wheelEvent(QWheelEvent * e);
@@ -42,10 +48,18 @@ protected:
private slots:
void updateZoom();
private:
void updateItemsShown();
private:
int _zoom;
int _minZoom;
QString _savedFileName;
QMenu * _menu;
QAction * _showImage;
QAction * _showFeatures;
QAction * _saveImage;
};
}

View File

@@ -50,6 +50,7 @@
#include <QtCore/QStringList>
#include <QtCore/QProcess>
#include <QtGui/QSplashScreen>
#include <QtGui/QInputDialog>
#define LOG_FILE_NAME "LogRtabmap.txt"
#define SHARE_SHOW_LOG_FILE "share/rtabmap/showlogs.m"
@@ -75,7 +76,8 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_oneSecondTimer(0),
_elapsedTime(0),
_posteriorCurve(0),
_likelihoodCurve(0)
_likelihoodCurve(0),
_autoScreenCaptureFormat("png")
{
ULOGGER_DEBUG("");
@@ -166,6 +168,8 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_ui->menuShow_view->addAction(_ui->dockWidget_likelihood->toggleViewAction());
_ui->menuShow_view->addAction(_ui->dockWidget_statsV2->toggleViewAction());
_ui->menuShow_view->addAction(_ui->dockWidget_console->toggleViewAction());
_ui->menuShow_view->addAction(_ui->toolBar->toggleViewAction());
_ui->toolBar->setWindowTitle(tr("Control toolbar"));
QAction * a = _ui->menuShow_view->addAction("Status");
a->setCheckable(false);
connect(a, SIGNAL(triggered(bool)), _initProgressDialog, SLOT(show()));
@@ -183,6 +187,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
connect(_ui->actionGenerate_map, SIGNAL(triggered()), this , SLOT(generateMap()));
connect(_ui->actionDelete_memory, SIGNAL(triggered()), this , SLOT(deleteMemory()));
connect(_ui->menuEdit, SIGNAL(aboutToShow()), this, SLOT(updateEditMenu()));
connect(_ui->actionAuto_screen_capture, SIGNAL(triggered(bool)), this, SLOT(selectScreenCaptureFormat(bool)));
#if defined(Q_WS_MAC) or defined(Q_WS_WIN)
connect(_ui->actionOpen_working_directory, SIGNAL(triggered()), SLOT(openWorkingDirectory()));
@@ -219,10 +224,6 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
connect(_ui->doubleSpinBox_stats_timeLimit, SIGNAL(editingFinished()), this, SLOT(changeTimeLimitSetting()));
connect(this, SIGNAL(imgRateChanged(double)), _preferencesDialog, SLOT(setImgRate(double)));
connect(this, SIGNAL(timeLimitChanged(double)), _preferencesDialog, SLOT(setTimeLimit(double)));
connect(_ui->checkBox_showFeatures, SIGNAL(toggled(bool)), this, SLOT(updateItemsShown()));
connect(_ui->checkBox_showFeaturesLoop, SIGNAL(toggled(bool)), this, SLOT(updateItemsShown()));
connect(_ui->checkBox_showImage, SIGNAL(toggled(bool)), this, SLOT(updateItemsShown()));
connect(_ui->checkBox_showImageLoop, SIGNAL(toggled(bool)), this, SLOT(updateItemsShown()));
// Statistics from the detector
qRegisterMetaType<rtabmap::Statistics>("rtabmap::Statistics");
@@ -410,7 +411,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
}
QRectF sceneRect = img.rect();
refPixmap = QPixmap::fromImage(img);
_ui->imageView_source->scene()->addPixmap(refPixmap)->setVisible(this->_ui->checkBox_showImage->isChecked());
_ui->imageView_source->scene()->addPixmap(refPixmap)->setVisible(this->_ui->imageView_source->isImageShown());
_ui->imageView_source->setSceneRect(sceneRect);
_ui->imageView_loopClosure->setSceneRect(sceneRect);
}
@@ -439,6 +440,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
}
ULOGGER_DEBUG("");
int rejectedHyp = bool(uValue(stat.data(), Statistics::kLoopRejectedHypothesis(), 0.0f));
float highestHypothesisValue = uValue(stat.data(), Statistics::kLoopHighest_hypothesis_value(), 0.0f);
if(highestHypothesisId > 0)
{
bool show = true;
@@ -452,7 +454,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
}
_ui->label_matchId->setText(QString("Match ID = %1").arg(stat.loopClosureId()));
}
else if(rejectedHyp)
else if(rejectedHyp && highestHypothesisValue >= _preferencesDialog->getLoopThr())
{
show = _preferencesDialog->imageRejectedShown() || _preferencesDialog->imageHighestHypShown();;
if(show)
@@ -493,7 +495,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
if(!lcImg.isNull())
{
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(lcImg))->setVisible(this->_ui->checkBox_showImageLoop->isChecked());
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(lcImg))->setVisible(this->_ui->imageView_loopClosure->isImageShown());
}
if(highestHypothesisIsSaved)
{
@@ -744,7 +746,7 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
// GREEN = NEW
item = new KeypointItem(r.pt.x-radius, r.pt.y-radius, radius*2, info, QColor(0, 255, 0, alpha));
}
item->setVisible(this->_ui->checkBox_showFeatures->isChecked());
item->setVisible(this->_ui->imageView_source->isFeaturesShown());
this->_ui->imageView_source->scene()->addItem(item);
item->setZValue(1);
}
@@ -786,7 +788,7 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
// GREEN = NEW
item = new KeypointItem(r.pt.x-radius, r.pt.y-radius, radius*2, info, QColor(0, 255, 0, alpha));
}
item->setVisible(this->_ui->checkBox_showFeaturesLoop->isChecked());
item->setVisible(this->_ui->imageView_loopClosure->isFeaturesShown());
this->_ui->imageView_loopClosure->scene()->addItem(item);
item->setZValue(1);
}
@@ -802,35 +804,6 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
}
}
void MainWindow::updateItemsShown()
{
QList<QGraphicsItem*> items = _ui->imageView_source->scene()->items();
for(int i=0; i<items.size(); ++i)
{
if(qgraphicsitem_cast<KeypointItem*>(items.at(i)))
{
items.at(i)->setVisible(_ui->checkBox_showFeatures->isChecked());
}
else if(qgraphicsitem_cast<QGraphicsPixmapItem*>(items.at(i)))
{
items.at(i)->setVisible(_ui->checkBox_showImage->isChecked());
}
}
items = _ui->imageView_loopClosure->scene()->items();
for(int i=0; i<items.size(); ++i)
{
if(qgraphicsitem_cast<KeypointItem*>(items.at(i)))
{
items.at(i)->setVisible(_ui->checkBox_showFeaturesLoop->isChecked());
}
else if(qgraphicsitem_cast<QGraphicsPixmapItem*>(items.at(i)))
{
items.at(i)->setVisible(_ui->checkBox_showImageLoop->isChecked());
}
}
}
void MainWindow::resizeEvent(QResizeEvent* anEvent)
{
_ui->imageView_source->fitInView(_ui->imageView_source->sceneRect(), Qt::KeepAspectRatio);
@@ -888,7 +861,7 @@ void MainWindow::captureScreen()
dir.mkdir(targetDir);
}
targetDir += "/";
QString name = QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".png";
QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".") + _autoScreenCaptureFormat;
_ui->statusbar->clearMessage();
QPixmap figure = QPixmap::grabWidget(this);
figure.save(targetDir + name);
@@ -1251,6 +1224,24 @@ void MainWindow::loadFigures()
}
void MainWindow::selectScreenCaptureFormat(bool checked)
{
if(checked)
{
QStringList items;
items << QString("png") << QString("jpg");
bool ok;
QString item = QInputDialog::getItem(this, tr("Select format"), tr("Format:"), items, 0, false, &ok);
if(ok && !item.isEmpty())
{
_autoScreenCaptureFormat = item;
}
this->captureScreen();
}
}
//END ACTIONS
// STATES
// Must be called by the GUI thread, use signal StateChanged()
void MainWindow::changeState(MainWindow::State newState)

View File

@@ -1333,7 +1333,8 @@ void OrientableLabel::paintEvent(QPaintEvent* event)
Plot::Plot(QWidget *parent) :
QWidget(parent),
_maxVisibleItems(-1)
_maxVisibleItems(-1),
_autoScreenCaptureFormat("png")
{
this->setupUi();
this->createActions();
@@ -1451,7 +1452,7 @@ void Plot::createActions()
_aYLabelVertical->setCheckable(true);
_aYLabelVertical->setChecked(true);
_aSaveFigure = new QAction(tr("Save figure..."), this);
_aAutoScreenCapture = new QAction(tr("Auto screen capture"), this);
_aAutoScreenCapture = new QAction(tr("Auto screen capture..."), this);
_aAutoScreenCapture->setCheckable(true);
_aClearData = new QAction(tr("Clear data"), this);
@@ -1974,28 +1975,10 @@ void Plot::contextMenuEvent(QContextMenuEvent * event)
}
else if(action == _aAutoScreenCapture)
{
this->captureScreen();
/*if(_aAutoScreenCapture->isChecked())
if(_aAutoScreenCapture->isChecked())
{
bool ok;
int value = QInputDialog::getInt(this,
action->text(),
tr("Screen capture delay (ms) [min=100]:"),
_autoScreenCaptureDelay,
100,
2147483647,
100,
&ok);
if(ok)
{
_autoScreenCaptureDelay = value;
this->autoCaptureScreen();
}
else
{
_aAutoScreenCapture->setChecked(false);
}
}*/
this->selectScreenCaptureFormat();
}
}
else if(action == _aClearData)
{
@@ -2047,11 +2030,24 @@ void Plot::captureScreen()
dir.mkdir(targetDir);
}
targetDir += "/";
QString name = QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".png";
QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".") + _autoScreenCaptureFormat;
QPixmap figure = QPixmap::grabWidget(this);
figure.save(targetDir + name);
}
void Plot::selectScreenCaptureFormat()
{
QStringList items;
items << QString("png") << QString("jpg");
bool ok;
QString item = QInputDialog::getItem(this, tr("Select format"), tr("Format:"), items, 0, false, &ok);
if(ok && !item.isEmpty())
{
_autoScreenCaptureFormat = item;
}
this->captureScreen();
}
// for convenience...
ThresholdCurve * Plot::addThreshold(const QString & name, float value, Qt::Orientation orientation)
{

View File

@@ -326,7 +326,7 @@ private:
void setupUi();
void createActions();
void createMenus();
void selectScreenCaptureFormat();
private:
PlotLegend * _legend;
@@ -349,6 +349,7 @@ private:
QTime _refreshIntervalTime;
int _lowestRefreshRate;
QTime _refreshStartTime;
QString _autoScreenCaptureFormat;
QMenu * _menu;
QAction * _aShowLegend;

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>839</width>
<height>447</height>
<width>842</width>
<height>457</height>
</rect>
</property>
<property name="windowTitle">
@@ -44,21 +44,23 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_19">
<widget class="QLabel" name="label_22">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-Source-</string>
<string>Source:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_refId">
<property name="minimumSize">
@@ -71,7 +73,7 @@
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@@ -87,59 +89,6 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="checkBox_showFeatures">
<property name="text">
<string>Show features</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showImage">
<property name="text">
<string>Show image</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@@ -159,21 +108,23 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_18">
<widget class="QLabel" name="label_23">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-Loop closure detection-</string>
<string>Match:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_matchId">
<property name="minimumSize">
@@ -186,7 +137,7 @@
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@@ -202,59 +153,6 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="checkBox_showFeaturesLoop">
<property name="text">
<string>Show features</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showImageLoop">
<property name="text">
<string>Show image</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@@ -265,7 +163,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>839</width>
<width>842</width>
<height>22</height>
</rect>
</property>
@@ -821,7 +719,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Auto screen capture</string>
<string>Auto screen capture...</string>
</property>
</action>
<action name="actionDump_the_prediction_matrix">