Geo icons updates for rendering

This commit is contained in:
Dan Paulat 2023-11-23 08:19:43 -06:00
parent 18f500fe5f
commit ad4c402404
2 changed files with 64 additions and 41 deletions

View file

@ -70,8 +70,7 @@ struct GeoIconDrawItem
std::chrono::sys_time<std::chrono::seconds> startTime_ {}; std::chrono::sys_time<std::chrono::seconds> startTime_ {};
std::chrono::sys_time<std::chrono::seconds> endTime_ {}; std::chrono::sys_time<std::chrono::seconds> endTime_ {};
bool visible_ {}; boost::gil::rgba8_pixel_t modulate_ {255, 255, 255, 255};
boost::gil::rgba8_pixel_t modulate_ {};
double latitude_ {}; double latitude_ {};
double longitude_ {}; double longitude_ {};
double x_ {}; double x_ {};
@ -118,6 +117,7 @@ public:
std::shared_ptr<GlContext> context_; std::shared_ptr<GlContext> context_;
bool visible_ {true};
bool dirty_ {false}; bool dirty_ {false};
bool thresholded_ {false}; bool thresholded_ {false};
@ -273,6 +273,11 @@ void GeoIcons::Initialize()
void GeoIcons::Render(const QMapLibreGL::CustomLayerRenderParameters& params, void GeoIcons::Render(const QMapLibreGL::CustomLayerRenderParameters& params,
bool textureAtlasChanged) bool textureAtlasChanged)
{ {
if (!p->visible_)
{
return;
}
std::unique_lock lock {p->iconMutex_}; std::unique_lock lock {p->iconMutex_};
if (!p->currentIconList_.empty()) if (!p->currentIconList_.empty())
@ -380,6 +385,11 @@ void IconInfo::UpdateTextureInfo()
scaledHeight_ = iconHeight_ * yFactor; scaledHeight_ = iconHeight_ * yFactor;
} }
void GeoIcons::SetVisible(bool visible)
{
p->visible_ = visible;
}
void GeoIcons::StartIconSheets() void GeoIcons::StartIconSheets()
{ {
// Clear the new buffer // Clear the new buffer
@ -454,6 +464,18 @@ void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
di->y_ = yOffset; di->y_ = yOffset;
} }
void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& 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<GeoIconDrawItem>& di, void GeoIcons::SetIconAngle(const std::shared_ptr<GeoIconDrawItem>& di,
units::angle::degrees<double> angle) units::angle::degrees<double> angle)
{ {
@ -472,12 +494,6 @@ void GeoIcons::SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di,
di->hoverText_ = text; di->hoverText_ = text;
} }
void GeoIcons::SetIconVisible(const std::shared_ptr<GeoIconDrawItem>& di,
bool visible)
{
di->visible_ = visible;
}
void GeoIcons::FinishIcons() void GeoIcons::FinishIcons()
{ {
// Update buffers // Update buffers
@ -512,12 +528,6 @@ void GeoIcons::Impl::UpdateBuffers()
for (auto& di : newIconList_) for (auto& di : newIconList_)
{ {
// Skip hidden icons
if (!di->visible_)
{
continue;
}
auto it = currentIconSheets_.find(di->iconSheet_); auto it = currentIconSheets_.find(di->iconSheet_);
if (it == currentIconSheets_.cend()) if (it == currentIconSheets_.cend())
{ {

View file

@ -42,6 +42,13 @@ public:
const QPointF& mouseGlobalPos, const QPointF& mouseGlobalPos,
const glm::vec2& mouseCoords) override; 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. * Resets and prepares the draw item for adding a new set of icon sheets.
*/ */
@ -91,7 +98,7 @@ public:
* @param [in] iconSheet The name of the icon sheet in the texture atlas * @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 * @param [in] iconIndex The zero-based index of the icon in the icon sheet
*/ */
void SetIconTexture(const std::shared_ptr<GeoIconDrawItem>& di, static void SetIconTexture(const std::shared_ptr<GeoIconDrawItem>& di,
const std::string& iconSheet, const std::string& iconSheet,
std::size_t iconIndex); std::size_t iconIndex);
@ -99,24 +106,39 @@ public:
* Sets the location of a geo icon. * Sets the location of a geo icon.
* *
* @param [in] di Geo icon draw item * @param [in] di Geo icon draw item
* @param [in] latitude The latitude of the geo icon. * @param [in] latitude The latitude of the geo icon in degrees.
* @param [in] longitude The longitude of the geo icon. * @param [in] longitude The longitude of the geo icon in degrees.
* @param [in] xOffset The x-offset of the geo icon. Default is 0. * @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. Default is 0. * @param [in] yOffset The y-offset of the geo icon in pixels. Default is 0.
*/ */
void SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di, static void SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
units::angle::degrees<double> latitude, units::angle::degrees<double> latitude,
units::angle::degrees<double> longitude, units::angle::degrees<double> longitude,
double xOffset = 0.0, double xOffset = 0.0,
double yOffset = 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<GeoIconDrawItem>& di,
double latitude,
double longitude,
double xOffset = 0.0,
double yOffset = 0.0);
/** /**
* Sets the angle of a geo icon. * Sets the angle of a geo icon.
* *
* @param [in] di Geo icon draw item * @param [in] di Geo icon draw item
* @param [in] angle Angle in degrees * @param [in] angle Angle in degrees
*/ */
void SetIconAngle(const std::shared_ptr<GeoIconDrawItem>& di, static void SetIconAngle(const std::shared_ptr<GeoIconDrawItem>& di,
units::angle::degrees<double> angle); units::angle::degrees<double> angle);
/** /**
@ -125,7 +147,7 @@ public:
* @param [in] di Geo icon draw item * @param [in] di Geo icon draw item
* @param [in] modulate Modulate color * @param [in] modulate Modulate color
*/ */
void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di, static void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate); boost::gil::rgba8_pixel_t modulate);
/** /**
@ -134,18 +156,9 @@ public:
* @param [in] di Geo icon draw item * @param [in] di Geo icon draw item
* @param [in] text Hover text * @param [in] text Hover text
*/ */
void SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di, static void SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di,
const std::string& text); 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<GeoIconDrawItem>& di,
bool visible);
/** /**
* Finalizes the draw item after adding new icons. * Finalizes the draw item after adding new icons.
*/ */