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

Tape Measure Plugin #456

Merged
merged 29 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7d4ab56
init plugin template
Oct 22, 2020
32236cc
some updates
Oct 28, 2020
a062e20
Add marker placement
Nov 10, 2020
af399c9
Complete functionality
Nov 10, 2020
3f7f265
Tidy up
Nov 11, 2020
8f107d6
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Nov 11, 2020
041e54b
Update docs
Nov 11, 2020
22d1c0f
Clean up
Nov 11, 2020
f0b022a
revert some changes
Nov 11, 2020
0dfec2f
Add crosshair cursor
Nov 11, 2020
38a6e4e
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Nov 11, 2020
a0f20f6
Add shortcut and new icon
Nov 11, 2020
cf77ad8
Merge branch 'jshep1/tape_measure_plugin' of https://github.com/ignit…
Nov 11, 2020
83b0a43
Updates
Nov 12, 2020
e69d95a
Add in trashcan icon
Nov 13, 2020
161e979
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Nov 16, 2020
59d5b33
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Nov 17, 2020
df26ea2
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Nov 20, 2020
a7cbc13
add in gui events
Nov 20, 2020
a31264c
Remove events from gazebo gui
Nov 20, 2020
dda9038
requested fixes
Nov 20, 2020
4d41ebe
More fixes
Nov 20, 2020
744e2db
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Nov 24, 2020
65d122a
handle key presses on cpp side
Nov 24, 2020
acaac9c
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Dec 7, 2020
d8a7404
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Dec 10, 2020
762a2d5
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Dec 14, 2020
aecce0c
update required gui version
Dec 15, 2020
2f47f18
Merge branch 'ign-gazebo3' into jshep1/tape_measure_plugin
Dec 16, 2020
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
52 changes: 52 additions & 0 deletions include/ignition/gazebo/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,58 @@ namespace events
/// \brief The path of SDF file to be previewed.
std::string filePath;
};

/// \brief Event which is called to broadcast the 3D coordinates of a user's
/// mouse hover within the scene.
class HoverToScene : public QEvent
{
/// \brief Constructor
/// \param[in] _point The point at which the mouse is hovering within the
/// scene
public: explicit HoverToScene(const math::Vector3d &_point)
: QEvent(kType), point(_point)
{
}

/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::User + 6);

/// \brief Get the point within the scene over which the user is hovering.
/// \return The 3D point
public: math::Vector3d Point() const
{
return this->point;
}

/// \brief The 3D point over which the user is hovering.
private: math::Vector3d point;
};

/// \brief Event which is called to broadcast the 3D coordinates of a user's
/// left click within the scene.
class LeftClickToScene : public QEvent
{
/// \brief Constructor
/// \param[in] _point The point which the user has left clicked within the
/// scene
public: explicit LeftClickToScene(const math::Vector3d &_point)
: QEvent(kType), point(_point)
{
}

/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::User + 7);

/// \brief Get the point within the scene that the user clicked.
/// \return The 3D point.
public: math::Vector3d Point() const
{
return this->point;
}

/// \brief The 3D point that the user clicked within the scene.
private: math::Vector3d point;
};
} // namespace events
}
} // namespace gui
Expand Down
1 change: 1 addition & 0 deletions src/gui/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ add_subdirectory(playback_scrubber)
add_subdirectory(resource_spawner)
add_subdirectory(scene3d)
add_subdirectory(shapes)
add_subdirectory(tape_measure)
add_subdirectory(transform_control)
add_subdirectory(video_recorder)
add_subdirectory(view_angle)
32 changes: 32 additions & 0 deletions src/gui/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,44 @@ Entity IgnRenderer::UniqueId()
void IgnRenderer::HandleMouseEvent()
{
std::lock_guard<std::mutex> lock(this->dataPtr->mutex);
this->BroadcastHoverPos();
this->BroadcastLeftClick();
this->HandleMouseContextMenu();
this->HandleModelPlacement();
this->HandleMouseTransformControl();
this->HandleMouseViewControl();
}

/////////////////////////////////////////////////
void IgnRenderer::BroadcastHoverPos()
{
if (this->dataPtr->hoverDirty)
{
math::Vector3d pos = this->ScreenToScene(this->dataPtr->mouseHoverPos);
chapulina marked this conversation as resolved.
Show resolved Hide resolved

gui::events::HoverToScene hoverToSceneEvent(pos);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
&hoverToSceneEvent);
}
}

/////////////////////////////////////////////////
void IgnRenderer::BroadcastLeftClick()
{
if (this->dataPtr->mouseEvent.Button() == common::MouseEvent::LEFT &&
this->dataPtr->mouseEvent.Type() == common::MouseEvent::RELEASE &&
!this->dataPtr->mouseEvent.Dragging() && this->dataPtr->mouseDirty)
{
math::Vector3d pos = this->ScreenToScene(this->dataPtr->mouseEvent.Pos());

gui::events::LeftClickToScene leftClickToSceneEvent(pos);
ignition::gui::App()->sendEvent(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>(),
&leftClickToSceneEvent);
}
}

/////////////////////////////////////////////////
void IgnRenderer::HandleMouseContextMenu()
{
Expand Down
6 changes: 6 additions & 0 deletions src/gui/plugins/scene3d/Scene3D.hh
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \brief Handle model placement requests
private: void HandleModelPlacement();

/// \brief Broadcasts the currently hovered 3d scene location.
private: void BroadcastHoverPos();

/// \brief Broadcasts a left click within the scene
private: void BroadcastLeftClick();

/// \brief Generate a unique entity id.
/// \return The unique entity id
private: Entity UniqueId();
Expand Down
6 changes: 6 additions & 0 deletions src/gui/plugins/tape_measure/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gz_add_gui_plugin(TapeMeasure
SOURCES TapeMeasure.cc
QT_HEADERS TapeMeasure.hh
PRIVATE_LINK_LIBS
${IGNITION-RENDERING_LIBRARIES}
)
Loading