Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking Nodes\Links brings them up in viewer #1344

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion guilib/include/rtabmap/gui/DatabaseViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class QGraphicsView;
class QLabel;
class QToolButton;
class QDialog;
class QSpinBox;

namespace rtabmap
{
Expand Down Expand Up @@ -161,7 +162,7 @@ private Q_SLOTS:

void updateIds();
void update(int value,
QLabel * labelIndex,
QSpinBox * spinBoxIndex,
QLabel * labelParents,
QLabel * labelChildren,
QLabel * weight,
Expand Down
2 changes: 1 addition & 1 deletion guilib/include/rtabmap/gui/GraphViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public Q_SLOTS:
protected:
virtual void wheelEvent ( QWheelEvent * event );
virtual void mouseMoveEvent(QMouseEvent * event);
virtual void mouseDoubleClickEvent(QMouseEvent * event);
virtual void mousePressEvent(QMouseEvent * event);
virtual void contextMenuEvent(QContextMenuEvent * event);

private:
Expand Down
43 changes: 35 additions & 8 deletions guilib/src/DatabaseViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ DatabaseViewer::DatabaseViewer(const QString & ini, QWidget * parent) :
connect(ui_->horizontalSlider_B, SIGNAL(valueChanged(int)), this, SLOT(sliderBValueChanged(int)));
connect(ui_->horizontalSlider_A, SIGNAL(sliderMoved(int)), this, SLOT(sliderAMoved(int)));
connect(ui_->horizontalSlider_B, SIGNAL(sliderMoved(int)), this, SLOT(sliderBMoved(int)));
ui_->spinBox_indexA->setEnabled(false);
ui_->spinBox_indexB->setEnabled(false);
connect(ui_->spinBox_indexA, SIGNAL(valueChanged(int)), this, SLOT(sliderAValueChanged(int)));
connect(ui_->spinBox_indexB, SIGNAL(valueChanged(int)), this, SLOT(sliderBValueChanged(int)));

connect(ui_->toolButton_edit_priorA, SIGNAL(clicked(bool)), this, SLOT(editConstraint()));
connect(ui_->toolButton_edit_priorB, SIGNAL(clicked(bool)), this, SLOT(editConstraint()));
connect(ui_->toolButton_remove_priorA, SIGNAL(clicked(bool)), this, SLOT(rejectConstraint()));
Expand Down Expand Up @@ -1156,6 +1161,11 @@ bool DatabaseViewer::closeDatabase()
sliderAValueChanged(0);
sliderBValueChanged(0);

ui_->spinBox_indexA->setEnabled(false);
ui_->spinBox_indexA->setMaximum(0);
ui_->spinBox_indexB->setEnabled(false);
ui_->spinBox_indexB->setMaximum(0);

constraintsViewer_->clear();
constraintsViewer_->refreshView();

Expand Down Expand Up @@ -2120,6 +2130,13 @@ void DatabaseViewer::updateIds()

if(ids_.size())
{
ui_->spinBox_indexA->setMinimum(0);
ui_->spinBox_indexB->setMinimum(0);
ui_->spinBox_indexA->setMaximum(ids_.size()-1);
ui_->spinBox_indexB->setMaximum(ids_.size()-1);
ui_->spinBox_indexA->setEnabled(true);
ui_->spinBox_indexB->setEnabled(true);

ui_->horizontalSlider_A->setMinimum(0);
ui_->horizontalSlider_B->setMinimum(0);
ui_->horizontalSlider_A->setMaximum(ids_.size()-1);
Expand All @@ -2135,6 +2152,10 @@ void DatabaseViewer::updateIds()
{
ui_->horizontalSlider_A->setEnabled(false);
ui_->horizontalSlider_B->setEnabled(false);

ui_->spinBox_indexA->setEnabled(false);
ui_->spinBox_indexB->setEnabled(false);

ui_->label_idA->setText("NaN");
ui_->label_idB->setText("NaN");
}
Expand Down Expand Up @@ -4593,7 +4614,7 @@ void DatabaseViewer::graphLinkSelected(int from, int to)
void DatabaseViewer::sliderAValueChanged(int value)
{
this->update(value,
ui_->label_indexA,
ui_->spinBox_indexA,
ui_->label_parentsA,
ui_->label_childrenA,
ui_->label_weightA,
Expand All @@ -4620,7 +4641,7 @@ void DatabaseViewer::sliderAValueChanged(int value)
void DatabaseViewer::sliderBValueChanged(int value)
{
this->update(value,
ui_->label_indexB,
ui_->spinBox_indexB,
ui_->label_parentsB,
ui_->label_childrenB,
ui_->label_weightB,
Expand All @@ -4645,7 +4666,7 @@ void DatabaseViewer::sliderBValueChanged(int value)
}

void DatabaseViewer::update(int value,
QLabel * labelIndex,
QSpinBox * spinBoxIndex,
QLabel * labelParents,
QLabel * labelChildren,
QLabel * weight,
Expand All @@ -4671,7 +4692,9 @@ void DatabaseViewer::update(int value,
lastSliderIndexBrowsed_ = value;

UTimer timer;
labelIndex->setText(QString::number(value));
spinBoxIndex->blockSignals(true);
spinBoxIndex->setValue(value);
spinBoxIndex->blockSignals(false);
labelParents->clear();
labelChildren->clear();
weight->clear();
Expand Down Expand Up @@ -5992,7 +6015,9 @@ void DatabaseViewer::updateWordsMatching(const std::vector<int> & inliers)

void DatabaseViewer::sliderAMoved(int value)
{
ui_->label_indexA->setText(QString::number(value));
ui_->spinBox_indexA->blockSignals(true);
ui_->spinBox_indexA->setValue(value);
ui_->spinBox_indexA->blockSignals(false);
if(value>=0 && value < ids_.size())
{
ui_->label_idA->setText(QString::number(ids_.at(value)));
Expand All @@ -6005,7 +6030,9 @@ void DatabaseViewer::sliderAMoved(int value)

void DatabaseViewer::sliderBMoved(int value)
{
ui_->label_indexB->setText(QString::number(value));
ui_->spinBox_indexB->blockSignals(true);
ui_->spinBox_indexB->setValue(value);
ui_->spinBox_indexB->blockSignals(false);
if(value>=0 && value < ids_.size())
{
ui_->label_idB->setText(QString::number(ids_.at(value)));
Expand Down Expand Up @@ -6349,7 +6376,7 @@ void DatabaseViewer::updateConstraintView(
ui_->horizontalSlider_B->blockSignals(false);
if(link.from()>0)
this->update(idToIndex_.value(link.from()),
ui_->label_indexA,
ui_->spinBox_indexA,
ui_->label_parentsA,
ui_->label_childrenA,
ui_->label_weightA,
Expand All @@ -6374,7 +6401,7 @@ void DatabaseViewer::updateConstraintView(
if(link.to()>0)
{
this->update(idToIndex_.value(link.to()),
ui_->label_indexB,
ui_->spinBox_indexB,
ui_->label_parentsB,
ui_->label_childrenB,
ui_->label_weightB,
Expand Down
6 changes: 3 additions & 3 deletions guilib/src/GraphViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ void GraphViewer::mouseMoveEvent(QMouseEvent * event)
QGraphicsView::mouseMoveEvent(event);
}

void GraphViewer::mouseDoubleClickEvent(QMouseEvent * event)
void GraphViewer::mousePressEvent(QMouseEvent * event)
{
QGraphicsItem *item = this->scene()->itemAt(mapToScene(event->pos()), QTransform());
if(item)
Expand All @@ -1826,12 +1826,12 @@ void GraphViewer::mouseDoubleClickEvent(QMouseEvent * event)
}
else
{
QGraphicsView::mouseDoubleClickEvent(event);
QGraphicsView::mousePressEvent(event);
}
}
else
{
QGraphicsView::mouseDoubleClickEvent(event);
QGraphicsView::mousePressEvent(event);
}
}

Expand Down
30 changes: 15 additions & 15 deletions guilib/src/ui/DatabaseViewer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>417</width>
<width>419</width>
<height>389</height>
</rect>
</property>
Expand Down Expand Up @@ -392,7 +392,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<width>418</width>
<height>389</height>
</rect>
</property>
Expand Down Expand Up @@ -745,9 +745,9 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_indexA">
<property name="text">
<string>indexA</string>
<widget class="QSpinBox" name="spinBox_indexA">
<property name="frame">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -810,9 +810,9 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_indexB">
<property name="text">
<string>indexB</string>
<widget class="QSpinBox" name="spinBox_indexB">
<property name="frame">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1641,7 +1641,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<width>314</width>
<height>188</height>
</rect>
</property>
Expand Down Expand Up @@ -1797,8 +1797,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>1007</height>
<width>276</width>
<height>1201</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -2458,8 +2458,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-42</y>
<width>298</width>
<y>0</y>
<width>294</width>
<height>272</height>
</rect>
</property>
Expand Down Expand Up @@ -2633,8 +2633,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>196</height>
<width>181</width>
<height>485</height>
</rect>
</property>
<attribute name="label">
Expand Down
Loading