Add icon visibility method to geo icons, update only dirty icons

This commit is contained in:
Dan Paulat 2024-04-20 00:34:50 -05:00
parent fcf6ef800b
commit 9cb29c6b9a
4 changed files with 328 additions and 155 deletions

View file

@ -14,6 +14,7 @@ layout (location = 3) in vec4 aModulate;
layout (location = 4) in float aAngleDeg; layout (location = 4) in float aAngleDeg;
layout (location = 5) in int aThreshold; layout (location = 5) in int aThreshold;
layout (location = 6) in ivec2 aTimeRange; layout (location = 6) in ivec2 aTimeRange;
layout (location = 7) in int aDisplayed;
uniform mat4 uMVPMatrix; uniform mat4 uMVPMatrix;
uniform mat4 uMapMatrix; uniform mat4 uMapMatrix;

View file

@ -8,6 +8,7 @@
#include <execution> #include <execution>
#include <boost/unordered/unordered_flat_map.hpp> #include <boost/unordered/unordered_flat_map.hpp>
#include <boost/unordered/unordered_flat_set.hpp>
namespace scwx namespace scwx
{ {
@ -32,8 +33,10 @@ static constexpr std::size_t kIconBufferLength =
static constexpr std::size_t kTextureBufferLength = static constexpr std::size_t kTextureBufferLength =
kNumTriangles * kVerticesPerTriangle * kPointsPerTexCoord; kNumTriangles * kVerticesPerTriangle * kPointsPerTexCoord;
// Threshold, start time, end time // Threshold, start time, end time, displayed
static constexpr std::size_t kIntegersPerVertex_ = 3; static constexpr std::size_t kIntegersPerVertex_ = 4;
static constexpr std::size_t kIntegerBufferLength_ =
kNumTriangles * kVerticesPerTriangle * kIntegersPerVertex_;
struct GeoIconDrawItem struct GeoIconDrawItem
{ {
@ -42,6 +45,7 @@ struct GeoIconDrawItem
std::chrono::sys_time<std::chrono::seconds> endTime_ {}; std::chrono::sys_time<std::chrono::seconds> endTime_ {};
boost::gil::rgba32f_pixel_t modulate_ {1.0f, 1.0f, 1.0f, 1.0f}; boost::gil::rgba32f_pixel_t modulate_ {1.0f, 1.0f, 1.0f, 1.0f};
bool visible_ {true};
double latitude_ {}; double latitude_ {};
double longitude_ {}; double longitude_ {};
double x_ {}; double x_ {};
@ -50,6 +54,8 @@ struct GeoIconDrawItem
std::string iconSheet_ {}; std::string iconSheet_ {};
std::size_t iconIndex_ {}; std::size_t iconIndex_ {};
std::string hoverText_ {}; std::string hoverText_ {};
std::shared_ptr<types::IconInfo> iconInfo_ {};
}; };
class GeoIcons::Impl class GeoIcons::Impl
@ -82,9 +88,15 @@ public:
~Impl() {} ~Impl() {}
void UpdateBuffers(); void UpdateBuffers();
void UpdateTextureBuffer(); static void UpdateSingleBuffer(const std::shared_ptr<GeoIconDrawItem>& di,
void Update(bool textureAtlasChanged); std::size_t iconIndex,
std::vector<float>& iconBuffer,
std::vector<GLint>& integerBuffer,
std::vector<IconHoverEntry>& hoverIcons);
void UpdateTextureBuffer();
void UpdateModifiedIconBuffers();
void Update(bool textureAtlasChanged);
std::shared_ptr<GlContext> context_; std::shared_ptr<GlContext> context_;
@ -93,13 +105,16 @@ public:
bool thresholded_ {false}; bool thresholded_ {false};
bool lastTextureAtlasChanged_ {false}; bool lastTextureAtlasChanged_ {false};
boost::unordered_flat_set<std::shared_ptr<GeoIconDrawItem>> dirtyIcons_ {};
std::chrono::system_clock::time_point selectedTime_ {}; std::chrono::system_clock::time_point selectedTime_ {};
std::mutex iconMutex_; std::mutex iconMutex_;
boost::unordered_flat_map<std::string, types::IconInfo> boost::unordered_flat_map<std::string, std::shared_ptr<types::IconInfo>>
currentIconSheets_ {}; currentIconSheets_ {};
boost::unordered_flat_map<std::string, types::IconInfo> newIconSheets_ {}; boost::unordered_flat_map<std::string, std::shared_ptr<types::IconInfo>>
newIconSheets_ {};
std::vector<std::shared_ptr<GeoIconDrawItem>> currentIconList_ {}; std::vector<std::shared_ptr<GeoIconDrawItem>> currentIconList_ {};
std::vector<std::shared_ptr<GeoIconDrawItem>> newIconList_ {}; std::vector<std::shared_ptr<GeoIconDrawItem>> newIconList_ {};
@ -240,6 +255,15 @@ void GeoIcons::Initialize()
reinterpret_cast<void*>(1 * sizeof(GLint))); reinterpret_cast<void*>(1 * sizeof(GLint)));
gl.glEnableVertexAttribArray(6); gl.glEnableVertexAttribArray(6);
// aDisplayed
gl.glVertexAttribPointer(7,
1,
GL_INT,
GL_FALSE,
kIntegersPerVertex_ * sizeof(GLint),
reinterpret_cast<void*>(3 * sizeof(float)));
gl.glEnableVertexAttribArray(7);
p->dirty_ = true; p->dirty_ = true;
} }
@ -338,10 +362,11 @@ void GeoIcons::AddIconSheet(const std::string& name,
std::int32_t hotY) std::int32_t hotY)
{ {
// Populate icon sheet map // Populate icon sheet map
p->newIconSheets_.emplace(std::piecewise_construct, p->newIconSheets_.emplace(
std::tuple {name}, std::piecewise_construct,
std::forward_as_tuple(types::IconInfo { std::tuple {name},
name, iconWidth, iconHeight, hotX, hotY})); std::forward_as_tuple(std::make_shared<types::IconInfo>(
name, iconWidth, iconHeight, hotX, hotY)));
} }
void GeoIcons::FinishIconSheets() void GeoIcons::FinishIconSheets()
@ -349,7 +374,7 @@ void GeoIcons::FinishIconSheets()
// Update icon sheets // Update icon sheets
for (auto& iconSheet : p->newIconSheets_) for (auto& iconSheet : p->newIconSheets_)
{ {
iconSheet.second.UpdateTextureInfo(); iconSheet.second->UpdateTextureInfo();
} }
std::unique_lock lock {p->iconMutex_}; std::unique_lock lock {p->iconMutex_};
@ -379,12 +404,26 @@ std::shared_ptr<GeoIconDrawItem> GeoIcons::AddIcon()
return p->newIconList_.emplace_back(std::make_shared<GeoIconDrawItem>()); return p->newIconList_.emplace_back(std::make_shared<GeoIconDrawItem>());
} }
void GeoIcons::SetIconVisible(const std::shared_ptr<GeoIconDrawItem>& di,
bool visible)
{
if (di->visible_ != visible)
{
di->visible_ = visible;
p->dirtyIcons_.insert(di);
}
}
void GeoIcons::SetIconTexture(const std::shared_ptr<GeoIconDrawItem>& di, void GeoIcons::SetIconTexture(const std::shared_ptr<GeoIconDrawItem>& di,
const std::string& iconSheet, const std::string& iconSheet,
std::size_t iconIndex) std::size_t iconIndex)
{ {
di->iconSheet_ = iconSheet; if (di->iconSheet_ != iconSheet || di->iconIndex_ != iconIndex)
di->iconIndex_ = iconIndex; {
di->iconSheet_ = iconSheet;
di->iconIndex_ = iconIndex;
p->dirtyIcons_.insert(di);
}
} }
void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di, void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
@ -393,10 +432,16 @@ void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
double xOffset, double xOffset,
double yOffset) double yOffset)
{ {
di->latitude_ = latitude.value(); if (di->latitude_ != latitude.value() ||
di->longitude_ = longitude.value(); di->longitude_ != longitude.value() || di->x_ != xOffset ||
di->x_ = xOffset; di->y_ != yOffset)
di->y_ = yOffset; {
di->latitude_ = latitude.value();
di->longitude_ = longitude.value();
di->x_ = xOffset;
di->y_ = yOffset;
p->dirtyIcons_.insert(di);
}
} }
void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di, void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
@ -405,37 +450,63 @@ void GeoIcons::SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
double xOffset, double xOffset,
double yOffset) double yOffset)
{ {
di->latitude_ = latitude; if (di->latitude_ != latitude || di->longitude_ != longitude ||
di->longitude_ = longitude; di->x_ != xOffset || di->y_ != yOffset)
di->x_ = xOffset; {
di->y_ = yOffset; di->latitude_ = latitude;
di->longitude_ = longitude;
di->x_ = xOffset;
di->y_ = yOffset;
p->dirtyIcons_.insert(di);
}
} }
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)
{ {
di->angle_ = angle; if (di->angle_ != angle)
{
di->angle_ = angle;
p->dirtyIcons_.insert(di);
}
} }
void GeoIcons::SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di, void GeoIcons::SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate) boost::gil::rgba8_pixel_t modulate)
{ {
di->modulate_ = {modulate[0] / 255.0f, boost::gil::rgba32f_pixel_t newModulate = {modulate[0] / 255.0f,
modulate[1] / 255.0f, modulate[1] / 255.0f,
modulate[2] / 255.0f, modulate[2] / 255.0f,
modulate[3] / 255.0f}; modulate[3] / 255.0f};
if (di->modulate_ != newModulate)
{
di->modulate_ = {modulate[0] / 255.0f,
modulate[1] / 255.0f,
modulate[2] / 255.0f,
modulate[3] / 255.0f};
p->dirtyIcons_.insert(di);
}
} }
void GeoIcons::SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di, void GeoIcons::SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba32f_pixel_t modulate) boost::gil::rgba32f_pixel_t modulate)
{ {
di->modulate_ = modulate; if (di->modulate_ != modulate)
{
di->modulate_ = modulate;
p->dirtyIcons_.insert(di);
}
} }
void GeoIcons::SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di, void GeoIcons::SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di,
const std::string& text) const std::string& text)
{ {
di->hoverText_ = text; if (di->hoverText_ != text)
{
di->hoverText_ = text;
p->dirtyIcons_.insert(di);
}
} }
void GeoIcons::FinishIcons() void GeoIcons::FinishIcons()
@ -482,10 +553,11 @@ void GeoIcons::Impl::UpdateBuffers()
continue; continue;
} }
auto& icon = it->second; auto& icon = it->second;
di->iconInfo_ = icon;
// Validate icon // Validate icon
if (di->iconIndex_ >= icon.numIcons_) if (di->iconIndex_ >= icon->numIcons_)
{ {
// No icon found // No icon found
logger_->warn("Invalid icon index: {}", di->iconIndex_); logger_->warn("Invalid icon index: {}", di->iconIndex_);
@ -495,101 +567,162 @@ void GeoIcons::Impl::UpdateBuffers()
// Icon is valid, add to valid icon list // Icon is valid, add to valid icon list
newValidIconList_.push_back(di); newValidIconList_.push_back(di);
// Threshold value // Update icon buffer
units::length::nautical_miles<double> threshold = di->threshold_; UpdateSingleBuffer(di,
GLint thresholdValue = static_cast<GLint>(std::round(threshold.value())); newValidIconList_.size() - 1,
newIconBuffer_,
newIntegerBuffer_,
newHoverIcons_);
}
// Start and end time // All icons have been updated
GLint startTime = dirtyIcons_.clear();
static_cast<GLint>(std::chrono::duration_cast<std::chrono::minutes>( }
di->startTime_.time_since_epoch())
.count());
GLint endTime =
static_cast<GLint>(std::chrono::duration_cast<std::chrono::minutes>(
di->endTime_.time_since_epoch())
.count());
// Latitude and longitude coordinates in degrees void GeoIcons::Impl::UpdateSingleBuffer(
const float lat = static_cast<float>(di->latitude_); const std::shared_ptr<GeoIconDrawItem>& di,
const float lon = static_cast<float>(di->longitude_); std::size_t iconIndex,
std::vector<float>& iconBuffer,
std::vector<GLint>& integerBuffer,
std::vector<IconHoverEntry>& hoverIcons)
{
auto& icon = di->iconInfo_;
// Base X/Y offsets in pixels // Threshold value
const float x = static_cast<float>(di->x_); units::length::nautical_miles<double> threshold = di->threshold_;
const float y = static_cast<float>(di->y_); GLint thresholdValue = static_cast<GLint>(std::round(threshold.value()));
// Icon size // Start and end time
const float iw = static_cast<float>(icon.iconWidth_); GLint startTime =
const float ih = static_cast<float>(icon.iconHeight_); static_cast<GLint>(std::chrono::duration_cast<std::chrono::minutes>(
di->startTime_.time_since_epoch())
.count());
GLint endTime =
static_cast<GLint>(std::chrono::duration_cast<std::chrono::minutes>(
di->endTime_.time_since_epoch())
.count());
// Hot X/Y (zero-based icon center) // Latitude and longitude coordinates in degrees
const float hx = static_cast<float>(icon.hotX_); const float lat = static_cast<float>(di->latitude_);
const float hy = static_cast<float>(icon.hotY_); const float lon = static_cast<float>(di->longitude_);
// Final X/Y offsets in pixels // Base X/Y offsets in pixels
const float lx = std::roundf(x - hx); const float x = static_cast<float>(di->x_);
const float rx = std::roundf(lx + iw); const float y = static_cast<float>(di->y_);
const float ty = std::roundf(y + hy);
const float by = std::roundf(ty - ih);
// Angle in degrees // Icon size
units::angle::degrees<float> angle = di->angle_; const float iw = static_cast<float>(icon->iconWidth_);
const float a = angle.value(); const float ih = static_cast<float>(icon->iconHeight_);
// Modulate color // Hot X/Y (zero-based icon center)
const float mc0 = di->modulate_[0]; const float hx = static_cast<float>(icon->hotX_);
const float mc1 = di->modulate_[1]; const float hy = static_cast<float>(icon->hotY_);
const float mc2 = di->modulate_[2];
const float mc3 = di->modulate_[3];
newIconBuffer_.insert(newIconBuffer_.end(), // Final X/Y offsets in pixels
{ const float lx = std::roundf(x - hx);
// Icon const float rx = std::roundf(lx + iw);
lat, lon, lx, by, mc0, mc1, mc2, mc3, a, // BL const float ty = std::roundf(y + hy);
lat, lon, lx, ty, mc0, mc1, mc2, mc3, a, // TL const float by = std::roundf(ty - ih);
lat, lon, rx, by, mc0, mc1, mc2, mc3, a, // BR
lat, lon, rx, by, mc0, mc1, mc2, mc3, a, // BR
lat, lon, rx, ty, mc0, mc1, mc2, mc3, a, // TR
lat, lon, lx, ty, mc0, mc1, mc2, mc3, a // TL
});
newIntegerBuffer_.insert(newIntegerBuffer_.end(),
{thresholdValue,
startTime,
endTime,
thresholdValue,
startTime,
endTime,
thresholdValue,
startTime,
endTime,
thresholdValue,
startTime,
endTime,
thresholdValue,
startTime,
endTime,
thresholdValue,
startTime,
endTime});
if (!di->hoverText_.empty()) // Angle in degrees
units::angle::degrees<float> angle = di->angle_;
const float a = angle.value();
// Modulate color
const float mc0 = di->modulate_[0];
const float mc1 = di->modulate_[1];
const float mc2 = di->modulate_[2];
const float mc3 = di->modulate_[3];
// Visibility
const GLint v = static_cast<GLint>(di->visible_);
// Icon initialize list data
const auto iconData = {
// Icon
lat, lon, lx, by, mc0, mc1, mc2, mc3, a, // BL
lat, lon, lx, ty, mc0, mc1, mc2, mc3, a, // TL
lat, lon, rx, by, mc0, mc1, mc2, mc3, a, // BR
lat, lon, rx, by, mc0, mc1, mc2, mc3, a, // BR
lat, lon, rx, ty, mc0, mc1, mc2, mc3, a, // TR
lat, lon, lx, ty, mc0, mc1, mc2, mc3, a // TL
};
const auto integerData = {thresholdValue, startTime, endTime, v,
thresholdValue, startTime, endTime, v,
thresholdValue, startTime, endTime, v,
thresholdValue, startTime, endTime, v,
thresholdValue, startTime, endTime, v,
thresholdValue, startTime, endTime, v};
// Buffer position data
auto iconBufferPosition = iconBuffer.end();
auto iconBufferOffset = iconIndex * kIconBufferLength;
auto integerBufferPosition = integerBuffer.end();
auto integerBufferOffset = iconIndex * kIntegerBufferLength_;
if (iconBufferOffset < iconBuffer.size())
{
iconBufferPosition = iconBuffer.begin() + iconBufferOffset;
}
if (integerBufferOffset < integerBuffer.size())
{
integerBufferPosition = integerBuffer.begin() + integerBufferOffset;
}
if (iconBufferPosition == iconBuffer.cend())
{
iconBuffer.insert(iconBufferPosition, iconData);
}
else
{
std::copy(iconData.begin(), iconData.end(), iconBufferPosition);
}
if (integerBufferPosition == integerBuffer.cend())
{
integerBuffer.insert(integerBufferPosition, integerData);
}
else
{
std::copy(integerData.begin(), integerData.end(), integerBufferPosition);
}
auto hoverIt = std::find_if(hoverIcons.begin(),
hoverIcons.end(),
[&di](auto& entry) { return entry.di_ == di; });
if (di->visible_ && !di->hoverText_.empty())
{
const units::angle::radians<double> radians = angle;
const auto sc = util::maplibre::LatLongToScreenCoordinate({lat, lon});
const float cosAngle = cosf(static_cast<float>(radians.value()));
const float sinAngle = sinf(static_cast<float>(radians.value()));
const glm::mat2 rotate {cosAngle, -sinAngle, sinAngle, cosAngle};
const glm::vec2 otl = rotate * glm::vec2 {lx, ty};
const glm::vec2 otr = rotate * glm::vec2 {rx, ty};
const glm::vec2 obl = rotate * glm::vec2 {lx, by};
const glm::vec2 obr = rotate * glm::vec2 {rx, by};
if (hoverIt == hoverIcons.end())
{ {
const units::angle::radians<double> radians = angle; hoverIcons.emplace_back(IconHoverEntry {di, sc, otl, otr, obl, obr});
const auto sc = util::maplibre::LatLongToScreenCoordinate({lat, lon});
const float cosAngle = cosf(static_cast<float>(radians.value()));
const float sinAngle = sinf(static_cast<float>(radians.value()));
const glm::mat2 rotate {cosAngle, -sinAngle, sinAngle, cosAngle};
const glm::vec2 otl = rotate * glm::vec2 {lx, ty};
const glm::vec2 otr = rotate * glm::vec2 {rx, ty};
const glm::vec2 obl = rotate * glm::vec2 {lx, by};
const glm::vec2 obr = rotate * glm::vec2 {rx, by};
newHoverIcons_.emplace_back(
IconHoverEntry {di, sc, otl, otr, obl, obr});
} }
else
{
hoverIt->otl_ = otl;
hoverIt->otr_ = otr;
hoverIt->obl_ = obl;
hoverIt->obr_ = obr;
}
}
else if (hoverIt != hoverIcons.end())
{
hoverIcons.erase(hoverIt);
} }
} }
@ -627,7 +760,7 @@ void GeoIcons::Impl::UpdateTextureBuffer()
auto& icon = it->second; auto& icon = it->second;
// Validate icon // Validate icon
if (di->iconIndex_ >= icon.numIcons_) if (di->iconIndex_ >= icon->numIcons_)
{ {
// No icon found // No icon found
logger_->error("Invalid icon index: {}", di->iconIndex_); logger_->error("Invalid icon index: {}", di->iconIndex_);
@ -653,17 +786,17 @@ void GeoIcons::Impl::UpdateTextureBuffer()
} }
// Texture coordinates // Texture coordinates
const std::size_t iconRow = (di->iconIndex_) / icon.columns_; const std::size_t iconRow = (di->iconIndex_) / icon->columns_;
const std::size_t iconColumn = (di->iconIndex_) % icon.columns_; const std::size_t iconColumn = (di->iconIndex_) % icon->columns_;
const float iconX = iconColumn * icon.scaledWidth_; const float iconX = iconColumn * icon->scaledWidth_;
const float iconY = iconRow * icon.scaledHeight_; const float iconY = iconRow * icon->scaledHeight_;
const float ls = icon.texture_.sLeft_ + iconX; const float ls = icon->texture_.sLeft_ + iconX;
const float rs = ls + icon.scaledWidth_; const float rs = ls + icon->scaledWidth_;
const float tt = icon.texture_.tTop_ + iconY; const float tt = icon->texture_.tTop_ + iconY;
const float bt = tt + icon.scaledHeight_; const float bt = tt + icon->scaledHeight_;
const float r = static_cast<float>(icon.texture_.layerId_); const float r = static_cast<float>(icon->texture_.layerId_);
// clang-format off // clang-format off
textureBuffer_.insert( textureBuffer_.insert(
@ -681,17 +814,51 @@ void GeoIcons::Impl::UpdateTextureBuffer()
} }
} }
void GeoIcons::Impl::UpdateModifiedIconBuffers()
{
// Update buffers for modified icons
for (auto& di : dirtyIcons_)
{
// Find modified icon in the current list
auto it =
std::find(currentIconList_.cbegin(), currentIconList_.cend(), di);
// Ignore invalid icons
if (it == currentIconList_.cend())
{
continue;
}
auto iconIndex = std::distance(currentIconList_.cbegin(), it);
UpdateSingleBuffer(di,
iconIndex,
currentIconBuffer_,
currentIntegerBuffer_,
currentHoverIcons_);
}
// Clear list of modified icons
if (!dirtyIcons_.empty())
{
dirtyIcons_.clear();
dirty_ = true;
}
}
void GeoIcons::Impl::Update(bool textureAtlasChanged) void GeoIcons::Impl::Update(bool textureAtlasChanged)
{ {
gl::OpenGLFunctions& gl = context_->gl(); gl::OpenGLFunctions& gl = context_->gl();
UpdateModifiedIconBuffers();
// If the texture atlas has changed // If the texture atlas has changed
if (dirty_ || textureAtlasChanged || lastTextureAtlasChanged_) if (dirty_ || textureAtlasChanged || lastTextureAtlasChanged_)
{ {
// Update texture coordinates // Update texture coordinates
for (auto& iconSheet : currentIconSheets_) for (auto& iconSheet : currentIconSheets_)
{ {
iconSheet.second.UpdateTextureInfo(); iconSheet.second->UpdateTextureInfo();
} }
// Update OpenGL texture buffer data // Update OpenGL texture buffer data

View file

@ -94,6 +94,13 @@ public:
*/ */
std::shared_ptr<GeoIconDrawItem> AddIcon(); std::shared_ptr<GeoIconDrawItem> AddIcon();
/**
* @param [in] di Geo icon draw item
* @param [in] visible Visibility of the icon
*/
void SetIconVisible(const std::shared_ptr<GeoIconDrawItem>& di,
bool visible);
/** /**
* Sets the texture of a geo icon. * Sets the texture of a geo icon.
* *
@ -101,9 +108,9 @@ 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
*/ */
static void SetIconTexture(const std::shared_ptr<GeoIconDrawItem>& di, void SetIconTexture(const std::shared_ptr<GeoIconDrawItem>& di,
const std::string& iconSheet, const std::string& iconSheet,
std::size_t iconIndex); std::size_t iconIndex);
/** /**
* Sets the location of a geo icon. * Sets the location of a geo icon.
@ -114,11 +121,11 @@ public:
* @param [in] xOffset The x-offset of the geo icon in pixels. 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 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, 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. * Sets the location of a geo icon.
@ -129,11 +136,11 @@ public:
* @param [in] xOffset The x-offset of the geo icon in pixels. 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 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, void SetIconLocation(const std::shared_ptr<GeoIconDrawItem>& di,
double latitude, double latitude,
double longitude, double longitude,
double xOffset = 0.0, double xOffset = 0.0,
double yOffset = 0.0); double yOffset = 0.0);
/** /**
* Sets the angle of a geo icon. * Sets the angle of a geo icon.
@ -141,8 +148,8 @@ public:
* @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
*/ */
static void SetIconAngle(const std::shared_ptr<GeoIconDrawItem>& di, void SetIconAngle(const std::shared_ptr<GeoIconDrawItem>& di,
units::angle::degrees<double> angle); units::angle::degrees<double> angle);
/** /**
* Sets the modulate color of a geo icon. * Sets the modulate color of a geo icon.
@ -150,8 +157,8 @@ 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
*/ */
static void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di, void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba8_pixel_t modulate); boost::gil::rgba8_pixel_t modulate);
/** /**
* Sets the modulate color of a geo icon. * Sets the modulate color of a geo icon.
@ -159,8 +166,8 @@ 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
*/ */
static void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di, void SetIconModulate(const std::shared_ptr<GeoIconDrawItem>& di,
boost::gil::rgba32f_pixel_t modulate); boost::gil::rgba32f_pixel_t modulate);
/** /**
* Sets the hover text of a geo icon. * Sets the hover text of a geo icon.
@ -168,8 +175,8 @@ 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
*/ */
static void SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di, void SetIconHoverText(const std::shared_ptr<GeoIconDrawItem>& di,
const std::string& text); const std::string& text);
/** /**
* Finalizes the draw item after adding new icons. * Finalizes the draw item after adding new icons.

View file

@ -182,11 +182,10 @@ void OverlayLayer::Initialize()
p->geoIcons_->StartIcons(); p->geoIcons_->StartIcons();
p->locationIcon_ = p->geoIcons_->AddIcon(); p->locationIcon_ = p->geoIcons_->AddIcon();
gl::draw::GeoIcons::SetIconTexture( p->geoIcons_->SetIconTexture(p->locationIcon_, p->locationIconName_, 0);
p->locationIcon_, p->locationIconName_, 0); p->geoIcons_->SetIconAngle(p->locationIcon_,
gl::draw::GeoIcons::SetIconAngle(p->locationIcon_, units::angle::degrees<double> {45.0});
units::angle::degrees<double> {45.0}); p->geoIcons_->SetIconLocation(
gl::draw::GeoIcons::SetIconLocation(
p->locationIcon_, coordinate.latitude(), coordinate.longitude()); p->locationIcon_, coordinate.latitude(), coordinate.longitude());
p->geoIcons_->FinishIcons(); p->geoIcons_->FinishIcons();
@ -272,10 +271,9 @@ void OverlayLayer::Initialize()
if (position.isValid() && if (position.isValid() &&
p->currentPosition_.coordinate() != coordinate) p->currentPosition_.coordinate() != coordinate)
{ {
gl::draw::GeoIcons::SetIconLocation(p->locationIcon_, p->geoIcons_->SetIconLocation(p->locationIcon_,
coordinate.latitude(), coordinate.latitude(),
coordinate.longitude()); coordinate.longitude());
p->geoIcons_->FinishIcons();
Q_EMIT NeedsRendering(); Q_EMIT NeedsRendering();
} }
p->currentPosition_ = position; p->currentPosition_ = position;