From ad4c402404f70236be07cde268d2f9b615d349c5 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Thu, 23 Nov 2023 08:19:43 -0600 Subject: [PATCH] Geo icons updates for rendering --- scwx-qt/source/scwx/qt/gl/draw/geo_icons.cpp | 38 +++++++---- scwx-qt/source/scwx/qt/gl/draw/geo_icons.hpp | 67 ++++++++++++-------- 2 files changed, 64 insertions(+), 41 deletions(-) diff --git a/scwx-qt/source/scwx/qt/gl/draw/geo_icons.cpp b/scwx-qt/source/scwx/qt/gl/draw/geo_icons.cpp index 1c8f59f9..5615d3f3 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/geo_icons.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/geo_icons.cpp @@ -70,8 +70,7 @@ struct GeoIconDrawItem std::chrono::sys_time startTime_ {}; std::chrono::sys_time endTime_ {}; - bool visible_ {}; - boost::gil::rgba8_pixel_t modulate_ {}; + boost::gil::rgba8_pixel_t modulate_ {255, 255, 255, 255}; double latitude_ {}; double longitude_ {}; double x_ {}; @@ -118,6 +117,7 @@ public: std::shared_ptr context_; + bool visible_ {true}; bool dirty_ {false}; bool thresholded_ {false}; @@ -273,6 +273,11 @@ void GeoIcons::Initialize() void GeoIcons::Render(const QMapLibreGL::CustomLayerRenderParameters& params, bool textureAtlasChanged) { + if (!p->visible_) + { + return; + } + std::unique_lock lock {p->iconMutex_}; if (!p->currentIconList_.empty()) @@ -380,6 +385,11 @@ void IconInfo::UpdateTextureInfo() scaledHeight_ = iconHeight_ * yFactor; } +void GeoIcons::SetVisible(bool visible) +{ + p->visible_ = visible; +} + void GeoIcons::StartIconSheets() { // Clear the new buffer @@ -454,6 +464,18 @@ void GeoIcons::SetIconLocation(const std::shared_ptr& di, di->y_ = yOffset; } +void GeoIcons::SetIconLocation(const std::shared_ptr& di, + double latitude, + double longitude, + double xOffset, + double yOffset) +{ + di->latitude_ = latitude; + di->longitude_ = longitude; + di->x_ = xOffset; + di->y_ = yOffset; +} + void GeoIcons::SetIconAngle(const std::shared_ptr& di, units::angle::degrees angle) { @@ -472,12 +494,6 @@ void GeoIcons::SetIconHoverText(const std::shared_ptr& di, di->hoverText_ = text; } -void GeoIcons::SetIconVisible(const std::shared_ptr& di, - bool visible) -{ - di->visible_ = visible; -} - void GeoIcons::FinishIcons() { // Update buffers @@ -512,12 +528,6 @@ void GeoIcons::Impl::UpdateBuffers() for (auto& di : newIconList_) { - // Skip hidden icons - if (!di->visible_) - { - continue; - } - auto it = currentIconSheets_.find(di->iconSheet_); if (it == currentIconSheets_.cend()) { diff --git a/scwx-qt/source/scwx/qt/gl/draw/geo_icons.hpp b/scwx-qt/source/scwx/qt/gl/draw/geo_icons.hpp index 40482cc7..9d4bc9a7 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/geo_icons.hpp +++ b/scwx-qt/source/scwx/qt/gl/draw/geo_icons.hpp @@ -42,6 +42,13 @@ public: const QPointF& mouseGlobalPos, const glm::vec2& mouseCoords) override; + /** + * Sets the visibility of the geo icons. + * + * @param [in] visible Icon visibility + */ + void SetVisible(bool visible); + /** * Resets and prepares the draw item for adding a new set of icon sheets. */ @@ -91,24 +98,39 @@ public: * @param [in] iconSheet The name of the icon sheet in the texture atlas * @param [in] iconIndex The zero-based index of the icon in the icon sheet */ - void SetIconTexture(const std::shared_ptr& di, - const std::string& iconSheet, - std::size_t iconIndex); + static void SetIconTexture(const std::shared_ptr& di, + const std::string& iconSheet, + std::size_t iconIndex); /** * Sets the location of a geo icon. * * @param [in] di Geo icon draw item - * @param [in] latitude The latitude of the geo icon. - * @param [in] longitude The longitude of the geo icon. - * @param [in] xOffset The x-offset of the geo icon. Default is 0. - * @param [in] yOffset The y-offset of the geo icon. Default is 0. + * @param [in] latitude The latitude of the geo icon in degrees. + * @param [in] longitude The longitude of the geo icon in degrees. + * @param [in] xOffset The x-offset of the geo icon in pixels. Default is 0. + * @param [in] yOffset The y-offset of the geo icon in pixels. Default is 0. */ - void SetIconLocation(const std::shared_ptr& di, - units::angle::degrees latitude, - units::angle::degrees longitude, - double xOffset = 0.0, - double yOffset = 0.0); + static void SetIconLocation(const std::shared_ptr& di, + units::angle::degrees latitude, + units::angle::degrees longitude, + double xOffset = 0.0, + double yOffset = 0.0); + + /** + * Sets the location of a geo icon. + * + * @param [in] di Geo icon draw item + * @param [in] latitude The latitude of the geo icon in degrees. + * @param [in] longitude The longitude of the geo icon in degrees. + * @param [in] xOffset The x-offset of the geo icon in pixels. Default is 0. + * @param [in] yOffset The y-offset of the geo icon in pixels. Default is 0. + */ + static void SetIconLocation(const std::shared_ptr& di, + double latitude, + double longitude, + double xOffset = 0.0, + double yOffset = 0.0); /** * Sets the angle of a geo icon. @@ -116,8 +138,8 @@ public: * @param [in] di Geo icon draw item * @param [in] angle Angle in degrees */ - void SetIconAngle(const std::shared_ptr& di, - units::angle::degrees angle); + static void SetIconAngle(const std::shared_ptr& di, + units::angle::degrees angle); /** * Sets the modulate color of a geo icon. @@ -125,8 +147,8 @@ public: * @param [in] di Geo icon draw item * @param [in] modulate Modulate color */ - void SetIconModulate(const std::shared_ptr& di, - boost::gil::rgba8_pixel_t modulate); + static void SetIconModulate(const std::shared_ptr& di, + boost::gil::rgba8_pixel_t modulate); /** * Sets the hover text of a geo icon. @@ -134,17 +156,8 @@ public: * @param [in] di Geo icon draw item * @param [in] text Hover text */ - void SetIconHoverText(const std::shared_ptr& di, - const std::string& text); - - /** - * Sets the visibility of a geo icon. - * - * @param [in] di Geo icon draw item - * @param [in] visible Icon visibility - */ - void SetIconVisible(const std::shared_ptr& di, - bool visible); + static void SetIconHoverText(const std::shared_ptr& di, + const std::string& text); /** * Finalizes the draw item after adding new icons.