From 21abdddbff66ee878860f271fcad16e7c637383f Mon Sep 17 00:00:00 2001 From: Charles Ellison <65311534+Nosille@users.noreply.github.com> Date: Sat, 21 Sep 2024 20:36:06 -0500 Subject: [PATCH] Clicking Nodes\Links brings them up in viewer (#1344) * Clicking Nodes\Links brings them up in viewer * Removed duplicated feature, kept spin box and single click node event. Removed unrelated border option crashing. --------- Co-authored-by: Chuck Ellison Co-authored-by: matlabbe --- guilib/include/rtabmap/gui/DatabaseViewer.h | 3 +- guilib/include/rtabmap/gui/GraphViewer.h | 2 +- guilib/src/DatabaseViewer.cpp | 43 +++++++++++++++++---- guilib/src/GraphViewer.cpp | 6 +-- guilib/src/ui/DatabaseViewer.ui | 30 +++++++------- 5 files changed, 56 insertions(+), 28 deletions(-) diff --git a/guilib/include/rtabmap/gui/DatabaseViewer.h b/guilib/include/rtabmap/gui/DatabaseViewer.h index f33a97622d..cb5e2029ca 100644 --- a/guilib/include/rtabmap/gui/DatabaseViewer.h +++ b/guilib/include/rtabmap/gui/DatabaseViewer.h @@ -52,6 +52,7 @@ class QGraphicsView; class QLabel; class QToolButton; class QDialog; +class QSpinBox; namespace rtabmap { @@ -161,7 +162,7 @@ private Q_SLOTS: void updateIds(); void update(int value, - QLabel * labelIndex, + QSpinBox * spinBoxIndex, QLabel * labelParents, QLabel * labelChildren, QLabel * weight, diff --git a/guilib/include/rtabmap/gui/GraphViewer.h b/guilib/include/rtabmap/gui/GraphViewer.h index 9e8996a582..945788d6e6 100644 --- a/guilib/include/rtabmap/gui/GraphViewer.h +++ b/guilib/include/rtabmap/gui/GraphViewer.h @@ -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: diff --git a/guilib/src/DatabaseViewer.cpp b/guilib/src/DatabaseViewer.cpp index 9d6dbb96a8..29b50a5f79 100644 --- a/guilib/src/DatabaseViewer.cpp +++ b/guilib/src/DatabaseViewer.cpp @@ -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())); @@ -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(); @@ -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); @@ -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"); } @@ -4583,7 +4604,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, @@ -4610,7 +4631,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, @@ -4635,7 +4656,7 @@ void DatabaseViewer::sliderBValueChanged(int value) } void DatabaseViewer::update(int value, - QLabel * labelIndex, + QSpinBox * spinBoxIndex, QLabel * labelParents, QLabel * labelChildren, QLabel * weight, @@ -4661,7 +4682,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(); @@ -5982,7 +6005,9 @@ void DatabaseViewer::updateWordsMatching(const std::vector & 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))); @@ -5995,7 +6020,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))); @@ -6308,7 +6335,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, @@ -6333,7 +6360,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, diff --git a/guilib/src/GraphViewer.cpp b/guilib/src/GraphViewer.cpp index bbd6618775..a237fc70f2 100644 --- a/guilib/src/GraphViewer.cpp +++ b/guilib/src/GraphViewer.cpp @@ -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) @@ -1826,12 +1826,12 @@ void GraphViewer::mouseDoubleClickEvent(QMouseEvent * event) } else { - QGraphicsView::mouseDoubleClickEvent(event); + QGraphicsView::mousePressEvent(event); } } else { - QGraphicsView::mouseDoubleClickEvent(event); + QGraphicsView::mousePressEvent(event); } } diff --git a/guilib/src/ui/DatabaseViewer.ui b/guilib/src/ui/DatabaseViewer.ui index aef27723fa..c968958d23 100644 --- a/guilib/src/ui/DatabaseViewer.ui +++ b/guilib/src/ui/DatabaseViewer.ui @@ -61,7 +61,7 @@ 0 0 - 417 + 419 389 @@ -392,7 +392,7 @@ 0 0 - 416 + 418 389 @@ -745,9 +745,9 @@ - - - indexA + + + false @@ -810,9 +810,9 @@ - - - indexB + + + false @@ -1641,7 +1641,7 @@ 0 0 - 318 + 314 188 @@ -1797,8 +1797,8 @@ 0 0 - 518 - 1007 + 276 + 1201 @@ -2458,8 +2458,8 @@ 0 - -42 - 298 + 0 + 294 272 @@ -2633,8 +2633,8 @@ 0 0 - 432 - 196 + 181 + 485