Skip to content

Commit

Permalink
Do not select interactive markers when mousing over them (#451)
Browse files Browse the repository at this point in the history
* Expose selection manager's "pick" method

The method is useful for getting objects in a bounding box without actually selecting them.
The last argument, single_render_pass, was not being used and so it has been removed.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Use pick method instead of select

This removes a visual bounding box (highlight) appearing over interactive markers.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
  • Loading branch information
jacobperron authored Aug 22, 2019
1 parent d873784 commit 564fa38
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
23 changes: 9 additions & 14 deletions rviz_common/include/rviz_common/interaction/selection_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ class RVIZ_COMMON_PUBLIC SelectionManager
int y2,
SelectType type) override;

/// Get all objects in a bounding box.
void pick(
rviz_rendering::RenderWindow * window,
int x1,
int y1,
int x2,
int y2,
M_Picked & results) override;

void update() override;

const M_Picked & getSelection() const override;
Expand Down Expand Up @@ -141,20 +150,6 @@ private Q_SLOTS:
void updateProperties();

private:
/**
* \return handles of all objects in the given bounding box
* \param single_render_pass only perform one rendering pass
* (point cloud selecting won't work)
*/
void pick(
rviz_rendering::RenderWindow * window,
int x1,
int y1,
int x2,
int y2,
M_Picked & results,
bool single_render_pass = false);

/// Set the list of currently selected objects.
void setSelection(const M_Picked & objs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ class RVIZ_COMMON_PUBLIC SelectionManagerIface : public QObject
virtual void select(
rviz_rendering::RenderWindow * window, int x1, int y1, int x2, int y2, SelectType type) = 0;

/// Get all objects in a bounding box.
/**
* \return handles of all objects in the given bounding box
*/
virtual void pick(
rviz_rendering::RenderWindow * window,
int x1,
int y1,
int x2,
int y2,
M_Picked & results) = 0;

virtual void update() = 0;

virtual const M_Picked & getSelection() const = 0;
Expand Down
5 changes: 2 additions & 3 deletions rviz_common/src/rviz_common/interaction/selection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ void SelectionManager::pick(
int y1,
int x2,
int y2,
M_Picked & results,
bool single_render_pass)
M_Picked & results)
{
auto handler_lock = handler_manager_->lock(std::defer_lock);
std::lock(selection_mutex_, handler_lock);
Expand Down Expand Up @@ -619,7 +618,7 @@ void SelectionManager::pick(
std::pair<M_Picked::iterator, bool> insert_result =
results.insert(std::make_pair(handle, Picked(handle)));
if (insert_result.second) {
if (handler->needsAdditionalRenderPass(1) && !single_render_pass) {
if (handler->needsAdditionalRenderPass(1)) {
need_additional.insert(handle);
need_additional_render = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,16 @@ void InteractionTool::deactivate()

void InteractionTool::updateFocus(const rviz_common::ViewportMouseEvent & event)
{
rviz_common::interaction::M_Picked results;
const auto selection_manager = context_->getSelectionManager();
// Select exactly 1 pixel
selection_manager->select(
// Pick exactly 1 pixel
selection_manager->pick(
event.panel->getRenderWindow(),
event.x,
event.y,
event.x + 1,
event.y + 1,
rviz_common::interaction::SelectionManagerIface::SelectType::Replace);

const rviz_common::interaction::M_Picked results = selection_manager->getSelection();
results);

last_selection_frame_count_ = context_->getFrameCount();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MockSelectionManager : public rviz_common::interaction::SelectionManagerIf
MOCK_METHOD5(highlight, void(rviz_rendering::RenderWindow *, int, int, int, int));
MOCK_METHOD0(removeHighlight, void());
MOCK_METHOD6(select, void(rviz_rendering::RenderWindow *, int, int, int, int, SelectType));
MOCK_METHOD6(pick, void(rviz_rendering::RenderWindow *, int, int, int, int, M_Picked &));

MOCK_METHOD0(update, void());
MOCK_CONST_METHOD0(getSelection, const M_Picked & ());
Expand Down

0 comments on commit 564fa38

Please sign in to comment.