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 <charles.c.ellison@erdc.dren.mil>
Co-authored-by: matlabbe <matlabbe@gmail.com>
This commit is contained in:
Charles Ellison
2024-09-21 20:36:06 -05:00
committed by GitHub
parent 379e11bd66
commit 21abdddbff
5 changed files with 56 additions and 28 deletions

View File

@@ -52,6 +52,7 @@ class QGraphicsView;
class QLabel; class QLabel;
class QToolButton; class QToolButton;
class QDialog; class QDialog;
class QSpinBox;
namespace rtabmap namespace rtabmap
{ {
@@ -161,7 +162,7 @@ private:
void updateIds(); void updateIds();
void update(int value, void update(int value,
QLabel * labelIndex, QSpinBox * spinBoxIndex,
QLabel * labelParents, QLabel * labelParents,
QLabel * labelChildren, QLabel * labelChildren,
QLabel * weight, QLabel * weight,

View File

@@ -175,7 +175,7 @@ public Q_SLOTS:
protected: protected:
virtual void wheelEvent ( QWheelEvent * event ); virtual void wheelEvent ( QWheelEvent * event );
virtual void mouseMoveEvent(QMouseEvent * event); virtual void mouseMoveEvent(QMouseEvent * event);
virtual void mouseDoubleClickEvent(QMouseEvent * event); virtual void mousePressEvent(QMouseEvent * event);
virtual void contextMenuEvent(QContextMenuEvent * event); virtual void contextMenuEvent(QContextMenuEvent * event);
private: private:

View File

@@ -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_B, SIGNAL(valueChanged(int)), this, SLOT(sliderBValueChanged(int)));
connect(ui_->horizontalSlider_A, SIGNAL(sliderMoved(int)), this, SLOT(sliderAMoved(int))); connect(ui_->horizontalSlider_A, SIGNAL(sliderMoved(int)), this, SLOT(sliderAMoved(int)));
connect(ui_->horizontalSlider_B, SIGNAL(sliderMoved(int)), this, SLOT(sliderBMoved(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_priorA, SIGNAL(clicked(bool)), this, SLOT(editConstraint()));
connect(ui_->toolButton_edit_priorB, 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())); connect(ui_->toolButton_remove_priorA, SIGNAL(clicked(bool)), this, SLOT(rejectConstraint()));
@@ -1156,6 +1161,11 @@ bool DatabaseViewer::closeDatabase()
sliderAValueChanged(0); sliderAValueChanged(0);
sliderBValueChanged(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_->clear();
constraintsViewer_->refreshView(); constraintsViewer_->refreshView();
@@ -2120,6 +2130,13 @@ void DatabaseViewer::updateIds()
if(ids_.size()) 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_A->setMinimum(0);
ui_->horizontalSlider_B->setMinimum(0); ui_->horizontalSlider_B->setMinimum(0);
ui_->horizontalSlider_A->setMaximum(ids_.size()-1); ui_->horizontalSlider_A->setMaximum(ids_.size()-1);
@@ -2135,6 +2152,10 @@ void DatabaseViewer::updateIds()
{ {
ui_->horizontalSlider_A->setEnabled(false); ui_->horizontalSlider_A->setEnabled(false);
ui_->horizontalSlider_B->setEnabled(false); ui_->horizontalSlider_B->setEnabled(false);
ui_->spinBox_indexA->setEnabled(false);
ui_->spinBox_indexB->setEnabled(false);
ui_->label_idA->setText("NaN"); ui_->label_idA->setText("NaN");
ui_->label_idB->setText("NaN"); ui_->label_idB->setText("NaN");
} }
@@ -4583,7 +4604,7 @@ void DatabaseViewer::graphLinkSelected(int from, int to)
void DatabaseViewer::sliderAValueChanged(int value) void DatabaseViewer::sliderAValueChanged(int value)
{ {
this->update(value, this->update(value,
ui_->label_indexA, ui_->spinBox_indexA,
ui_->label_parentsA, ui_->label_parentsA,
ui_->label_childrenA, ui_->label_childrenA,
ui_->label_weightA, ui_->label_weightA,
@@ -4610,7 +4631,7 @@ void DatabaseViewer::sliderAValueChanged(int value)
void DatabaseViewer::sliderBValueChanged(int value) void DatabaseViewer::sliderBValueChanged(int value)
{ {
this->update(value, this->update(value,
ui_->label_indexB, ui_->spinBox_indexB,
ui_->label_parentsB, ui_->label_parentsB,
ui_->label_childrenB, ui_->label_childrenB,
ui_->label_weightB, ui_->label_weightB,
@@ -4635,7 +4656,7 @@ void DatabaseViewer::sliderBValueChanged(int value)
} }
void DatabaseViewer::update(int value, void DatabaseViewer::update(int value,
QLabel * labelIndex, QSpinBox * spinBoxIndex,
QLabel * labelParents, QLabel * labelParents,
QLabel * labelChildren, QLabel * labelChildren,
QLabel * weight, QLabel * weight,
@@ -4661,7 +4682,9 @@ void DatabaseViewer::update(int value,
lastSliderIndexBrowsed_ = value; lastSliderIndexBrowsed_ = value;
UTimer timer; UTimer timer;
labelIndex->setText(QString::number(value)); spinBoxIndex->blockSignals(true);
spinBoxIndex->setValue(value);
spinBoxIndex->blockSignals(false);
labelParents->clear(); labelParents->clear();
labelChildren->clear(); labelChildren->clear();
weight->clear(); weight->clear();
@@ -5982,7 +6005,9 @@ void DatabaseViewer::updateWordsMatching(const std::vector<int> & inliers)
void DatabaseViewer::sliderAMoved(int value) 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()) if(value>=0 && value < ids_.size())
{ {
ui_->label_idA->setText(QString::number(ids_.at(value))); ui_->label_idA->setText(QString::number(ids_.at(value)));
@@ -5995,7 +6020,9 @@ void DatabaseViewer::sliderAMoved(int value)
void DatabaseViewer::sliderBMoved(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()) if(value>=0 && value < ids_.size())
{ {
ui_->label_idB->setText(QString::number(ids_.at(value))); ui_->label_idB->setText(QString::number(ids_.at(value)));
@@ -6308,7 +6335,7 @@ void DatabaseViewer::updateConstraintView(
ui_->horizontalSlider_B->blockSignals(false); ui_->horizontalSlider_B->blockSignals(false);
if(link.from()>0) if(link.from()>0)
this->update(idToIndex_.value(link.from()), this->update(idToIndex_.value(link.from()),
ui_->label_indexA, ui_->spinBox_indexA,
ui_->label_parentsA, ui_->label_parentsA,
ui_->label_childrenA, ui_->label_childrenA,
ui_->label_weightA, ui_->label_weightA,
@@ -6333,7 +6360,7 @@ void DatabaseViewer::updateConstraintView(
if(link.to()>0) if(link.to()>0)
{ {
this->update(idToIndex_.value(link.to()), this->update(idToIndex_.value(link.to()),
ui_->label_indexB, ui_->spinBox_indexB,
ui_->label_parentsB, ui_->label_parentsB,
ui_->label_childrenB, ui_->label_childrenB,
ui_->label_weightB, ui_->label_weightB,

View File

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

View File

@@ -61,7 +61,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>417</width> <width>419</width>
<height>389</height> <height>389</height>
</rect> </rect>
</property> </property>
@@ -392,7 +392,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>416</width> <width>418</width>
<height>389</height> <height>389</height>
</rect> </rect>
</property> </property>
@@ -745,9 +745,9 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="label_indexA"> <widget class="QSpinBox" name="spinBox_indexA">
<property name="text"> <property name="frame">
<string>indexA</string> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@@ -810,9 +810,9 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="label_indexB"> <widget class="QSpinBox" name="spinBox_indexB">
<property name="text"> <property name="frame">
<string>indexB</string> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@@ -1641,7 +1641,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>318</width> <width>314</width>
<height>188</height> <height>188</height>
</rect> </rect>
</property> </property>
@@ -1797,8 +1797,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>518</width> <width>276</width>
<height>1007</height> <height>1201</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -2458,8 +2458,8 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-42</y> <y>0</y>
<width>298</width> <width>294</width>
<height>272</height> <height>272</height>
</rect> </rect>
</property> </property>
@@ -2633,8 +2633,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>432</width> <width>181</width>
<height>196</height> <height>485</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">