Skip to content

Commit

Permalink
Merge pull request #321 from AdenKoperczak/location_markers_part2
Browse files Browse the repository at this point in the history
Location Markers Part 2
  • Loading branch information
dpaulat authored Jan 12, 2025
2 parents db95a11 + 736fd43 commit 60b4833
Show file tree
Hide file tree
Showing 37 changed files with 1,233 additions and 217 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ Checks:
- '-misc-include-cleaner'
- '-misc-non-private-member-variables-in-classes'
- '-modernize-use-trailing-return-type'
- '-bugprone-easily-swappable-parameters'
- '-modernize-return-braced-init-list'
FormatStyle: 'file'
1 change: 1 addition & 0 deletions scwx-qt/res/icons/font-awesome-6/briefcase-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scwx-qt/res/icons/font-awesome-6/building-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scwx-qt/res/icons/font-awesome-6/caravan-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scwx-qt/res/icons/font-awesome-6/house-solid-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions scwx-qt/res/icons/font-awesome-6/location-pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scwx-qt/res/icons/font-awesome-6/star-solid-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scwx-qt/res/icons/font-awesome-6/tent-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scwx-qt/res/textures/images/location-marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion scwx-qt/scwx-qt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ set(HDR_TYPES source/scwx/qt/types/alert_types.hpp
source/scwx/qt/types/layer_types.hpp
source/scwx/qt/types/location_types.hpp
source/scwx/qt/types/map_types.hpp
source/scwx/qt/types/media_types.hpp
source/scwx/qt/types/marker_types.hpp
source/scwx/qt/types/media_types.hpp
source/scwx/qt/types/qt_types.hpp
source/scwx/qt/types/radar_product_record.hpp
source/scwx/qt/types/text_event_key.hpp
Expand Down Expand Up @@ -255,6 +255,7 @@ set(HDR_UI source/scwx/qt/ui/about_dialog.hpp
source/scwx/qt/ui/county_dialog.hpp
source/scwx/qt/ui/download_dialog.hpp
source/scwx/qt/ui/edit_line_dialog.hpp
source/scwx/qt/ui/edit_marker_dialog.hpp
source/scwx/qt/ui/flow_layout.hpp
source/scwx/qt/ui/gps_info_dialog.hpp
source/scwx/qt/ui/hotkey_edit.hpp
Expand Down Expand Up @@ -285,6 +286,7 @@ set(SRC_UI source/scwx/qt/ui/about_dialog.cpp
source/scwx/qt/ui/county_dialog.cpp
source/scwx/qt/ui/download_dialog.cpp
source/scwx/qt/ui/edit_line_dialog.cpp
source/scwx/qt/ui/edit_marker_dialog.cpp
source/scwx/qt/ui/flow_layout.cpp
source/scwx/qt/ui/gps_info_dialog.cpp
source/scwx/qt/ui/hotkey_edit.cpp
Expand Down Expand Up @@ -314,6 +316,7 @@ set(UI_UI source/scwx/qt/ui/about_dialog.ui
source/scwx/qt/ui/collapsible_group.ui
source/scwx/qt/ui/county_dialog.ui
source/scwx/qt/ui/edit_line_dialog.ui
source/scwx/qt/ui/edit_marker_dialog.ui
source/scwx/qt/ui/gps_info_dialog.ui
source/scwx/qt/ui/imgui_debug_dialog.ui
source/scwx/qt/ui/layer_dialog.ui
Expand Down Expand Up @@ -357,6 +360,7 @@ set(HDR_UTIL source/scwx/qt/util/color.hpp
source/scwx/qt/util/network.hpp
source/scwx/qt/util/streams.hpp
source/scwx/qt/util/texture_atlas.hpp
source/scwx/qt/util/q_color_modulate.hpp
source/scwx/qt/util/q_file_buffer.hpp
source/scwx/qt/util/q_file_input_stream.hpp
source/scwx/qt/util/time.hpp
Expand All @@ -369,6 +373,7 @@ set(SRC_UTIL source/scwx/qt/util/color.cpp
source/scwx/qt/util/maplibre.cpp
source/scwx/qt/util/network.cpp
source/scwx/qt/util/texture_atlas.cpp
source/scwx/qt/util/q_color_modulate.cpp
source/scwx/qt/util/q_file_buffer.cpp
source/scwx/qt/util/q_file_input_stream.cpp
source/scwx/qt/util/time.cpp
Expand Down
9 changes: 9 additions & 0 deletions scwx-qt/scwx-qt.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<file>res/icons/font-awesome-6/angles-up-solid.svg</file>
<file>res/icons/font-awesome-6/backward-step-solid.svg</file>
<file>res/icons/font-awesome-6/book-solid.svg</file>
<file>res/icons/font-awesome-6/briefcase-solid.svg</file>
<file>res/icons/font-awesome-6/building-columns-solid.svg</file>
<file>res/icons/font-awesome-6/building-solid.svg</file>
<file>res/icons/font-awesome-6/caravan-solid.svg</file>
<file>res/icons/font-awesome-6/copy-regular.svg</file>
<file>res/icons/font-awesome-6/discord.svg</file>
<file>res/icons/font-awesome-6/earth-americas-solid.svg</file>
Expand All @@ -40,8 +44,11 @@
<file>res/icons/font-awesome-6/gears-solid.svg</file>
<file>res/icons/font-awesome-6/github.svg</file>
<file>res/icons/font-awesome-6/house-solid.svg</file>
<file>res/icons/font-awesome-6/house-solid-white.svg</file>
<file>res/icons/font-awesome-6/keyboard-regular.svg</file>
<file>res/icons/font-awesome-6/layer-group-solid.svg</file>
<file>res/icons/font-awesome-6/location-crosshairs-solid.svg</file>
<file>res/icons/font-awesome-6/location-pin.svg</file>
<file>res/icons/font-awesome-6/palette-solid.svg</file>
<file>res/icons/font-awesome-6/pause-solid.svg</file>
<file>res/icons/font-awesome-6/play-solid.svg</file>
Expand All @@ -53,7 +60,9 @@
<file>res/icons/font-awesome-6/square-minus-regular.svg</file>
<file>res/icons/font-awesome-6/square-plus-regular.svg</file>
<file>res/icons/font-awesome-6/star-solid.svg</file>
<file>res/icons/font-awesome-6/star-solid-white.svg</file>
<file>res/icons/font-awesome-6/stop-solid.svg</file>
<file>res/icons/font-awesome-6/tent-solid.svg</file>
<file>res/icons/font-awesome-6/volume-high-solid.svg</file>
<file>res/palettes/wct/CC.pal</file>
<file>res/palettes/wct/Default16.pal</file>
Expand Down
23 changes: 19 additions & 4 deletions scwx-qt/source/scwx/qt/gl/draw/geo_icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static constexpr std::size_t kIntegersPerVertex_ = 4;
static constexpr std::size_t kIntegerBufferLength_ =
kNumTriangles * kVerticesPerTriangle * kIntegersPerVertex_;

struct GeoIconDrawItem
struct GeoIconDrawItem : types::EventHandler
{
units::length::nautical_miles<double> threshold_ {};
std::chrono::sys_time<std::chrono::seconds> startTime_ {};
Expand Down Expand Up @@ -691,7 +691,7 @@ void GeoIcons::Impl::UpdateSingleBuffer(
hoverIcons.end(),
[&di](auto& entry) { return entry.di_ == di; });

if (di->visible_ && !di->hoverText_.empty())
if (di->visible_ && (!di->hoverText_.empty() || di->event_ != nullptr))
{
const units::angle::radians<double> radians = angle;

Expand Down Expand Up @@ -903,7 +903,7 @@ bool GeoIcons::RunMousePicking(
const QPointF& mouseGlobalPos,
const glm::vec2& mouseCoords,
const common::Coordinate& /* mouseGeoCoords */,
std::shared_ptr<types::EventHandler>& /* eventHandler */)
std::shared_ptr<types::EventHandler>& eventHandler)
{
std::unique_lock lock {p->iconMutex_};

Expand Down Expand Up @@ -993,12 +993,27 @@ bool GeoIcons::RunMousePicking(
if (it != p->currentHoverIcons_.crend())
{
itemPicked = true;
util::tooltip::Show(it->di_->hoverText_, mouseGlobalPos);
if (!it->di_->hoverText_.empty())
{
// Show tooltip
util::tooltip::Show(it->di_->hoverText_, mouseGlobalPos);
}
if (it->di_->event_ != nullptr)
{
eventHandler = it->di_;
}
}

return itemPicked;
}

void GeoIcons::RegisterEventHandler(
const std::shared_ptr<GeoIconDrawItem>& di,
const std::function<void(QEvent*)>& eventHandler)
{
di->event_ = eventHandler;
}

} // namespace draw
} // namespace gl
} // namespace qt
Expand Down
10 changes: 10 additions & 0 deletions scwx-qt/source/scwx/qt/gl/draw/geo_icons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ class GeoIcons : public DrawItem
*/
void FinishIcons();

/**
* Registers an event handler for an icon.
*
* @param [in] di Icon draw item
* @param [in] eventHandler Event handler function
*/
static void
RegisterEventHandler(const std::shared_ptr<GeoIconDrawItem>& di,
const std::function<void(QEvent*)>& eventHandler);

private:
class Impl;

Expand Down
Loading

0 comments on commit 60b4833

Please sign in to comment.