mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 05:50:05 +00:00
Added a basic location marker manager.
This commit is contained in:
parent
84233868d6
commit
19415cd0a1
16 changed files with 806 additions and 44 deletions
|
|
@ -18,39 +18,56 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
|||
class MarkerLayer::Impl
|
||||
{
|
||||
public:
|
||||
explicit Impl(std::shared_ptr<MapContext> context) :
|
||||
geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}
|
||||
explicit Impl(MarkerLayer* self, std::shared_ptr<MapContext> context) :
|
||||
self_ {self}, geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}
|
||||
{
|
||||
ConnectSignals();
|
||||
}
|
||||
~Impl() {}
|
||||
|
||||
void ReloadMarkers();
|
||||
void ConnectSignals();
|
||||
|
||||
MarkerLayer* self_;
|
||||
const std::string& markerIconName_ {
|
||||
types::GetTextureName(types::ImageTexture::Cursor17)};
|
||||
|
||||
std::shared_ptr<gl::draw::GeoIcons> geoIcons_;
|
||||
};
|
||||
|
||||
void MarkerLayer::Impl::ConnectSignals()
|
||||
{
|
||||
auto markerManager = manager::MarkerManager::Instance();
|
||||
|
||||
QObject::connect(markerManager.get(),
|
||||
&manager::MarkerManager::MarkersUpdated,
|
||||
self_,
|
||||
[this]()
|
||||
{
|
||||
this->ReloadMarkers();
|
||||
});
|
||||
}
|
||||
|
||||
void MarkerLayer::Impl::ReloadMarkers()
|
||||
{
|
||||
logger_->debug("ReloadMarkers()");
|
||||
auto markerManager = manager::MarkerManager::Instance();
|
||||
|
||||
geoIcons_->StartIcons();
|
||||
|
||||
for (size_t i = 0; i < markerManager->marker_count(); i++)
|
||||
{
|
||||
types::MarkerInfo marker = markerManager->get_marker(i);
|
||||
const types::MarkerInfo& marker = markerManager->get_marker(i);
|
||||
std::shared_ptr<gl::draw::GeoIconDrawItem> icon = geoIcons_->AddIcon();
|
||||
geoIcons_->SetIconTexture(icon, markerIconName_, 0);
|
||||
geoIcons_->SetIconLocation(icon, marker.latitude_, marker.longitude_);
|
||||
geoIcons_->SetIconLocation(icon, marker.latitude, marker.longitude);
|
||||
}
|
||||
|
||||
geoIcons_->FinishIcons();
|
||||
}
|
||||
|
||||
MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) :
|
||||
DrawLayer(context), p(std::make_unique<MarkerLayer::Impl>(context))
|
||||
DrawLayer(context), p(std::make_unique<MarkerLayer::Impl>(this, context))
|
||||
{
|
||||
AddDrawItem(p->geoIcons_);
|
||||
}
|
||||
|
|
@ -65,6 +82,8 @@ void MarkerLayer::Initialize()
|
|||
p->geoIcons_->StartIconSheets();
|
||||
p->geoIcons_->AddIconSheet(p->markerIconName_);
|
||||
p->geoIcons_->FinishIconSheets();
|
||||
|
||||
p->ReloadMarkers();
|
||||
}
|
||||
|
||||
void MarkerLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
||||
|
|
@ -72,9 +91,6 @@ void MarkerLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
|||
// auto markerManager = manager::MarkerManager::Instance();
|
||||
gl::OpenGLFunctions& gl = context()->gl();
|
||||
|
||||
// TODO. do not redo this every time
|
||||
p->ReloadMarkers();
|
||||
|
||||
DrawLayer::Render(params);
|
||||
|
||||
SCWX_GL_CHECK_ERROR();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue