Update placefile view when placefiles are edited from settings

This commit is contained in:
Dan Paulat 2023-07-25 23:16:36 -05:00
parent 7c21ccaf41
commit 6dedce5089
2 changed files with 36 additions and 3 deletions

View file

@ -1,5 +1,6 @@
#include <scwx/qt/map/map_widget.hpp>
#include <scwx/qt/gl/gl.hpp>
#include <scwx/qt/manager/placefile_manager.hpp>
#include <scwx/qt/manager/radar_product_manager.hpp>
#include <scwx/qt/manager/settings_manager.hpp>
#include <scwx/qt/map/alert_layer.hpp>
@ -94,6 +95,8 @@ public:
// Set Map Provider Details
mapProvider_ = GetMapProvider(generalSettings.map_provider().GetValue());
ConnectSignals();
}
~MapWidgetImpl()
@ -115,6 +118,7 @@ public:
void AddLayer(const std::string& id,
std::shared_ptr<GenericLayer> layer,
const std::string& before = {});
void ConnectSignals();
void InitializeNewRadarProductView(const std::string& colorPalette);
void RadarProductManagerConnect();
void RadarProductManagerDisconnect();
@ -142,6 +146,8 @@ public:
std::string imGuiContextName_;
bool imGuiRendererInitialized_;
std::shared_ptr<manager::PlacefileManager> placefileManager_ {
manager::PlacefileManager::Instance()};
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
std::shared_ptr<common::ColorTable> colorTable_;
@ -188,6 +194,22 @@ MapWidget::~MapWidget()
makeCurrent();
}
void MapWidgetImpl::ConnectSignals()
{
connect(placefileManager_.get(),
&manager::PlacefileManager::PlacefileEnabled,
widget_,
[this]() { widget_->update(); });
connect(placefileManager_.get(),
&manager::PlacefileManager::PlacefileRenamed,
widget_,
[this]() { widget_->update(); });
connect(placefileManager_.get(),
&manager::PlacefileManager::PlacefileUpdated,
widget_,
[this]() { widget_->update(); });
}
common::Level3ProductCategoryMap MapWidget::GetAvailableLevel3Categories()
{
if (p->radarProductManager_ != nullptr)

View file

@ -42,6 +42,7 @@ public:
float mapScale_ {1.0f};
float halfWidth_ {};
float halfHeight_ {};
bool thresholded_ {true};
ImFont* monospaceFont_ {};
};
@ -63,8 +64,11 @@ void PlacefileLayer::Impl::RenderTextDrawItem(
const QMapLibreGL::CustomLayerRenderParameters& params,
std::shared_ptr<gr::Placefile::TextDrawItem> di)
{
auto distance = util::GeographicLib::GetDistance(
params.latitude, params.longitude, di->latitude_, di->longitude_);
auto distance =
(thresholded_) ?
util::GeographicLib::GetDistance(
params.latitude, params.longitude, di->latitude_, di->longitude_) :
0;
if (distance < di->threshold_)
{
@ -145,7 +149,11 @@ void PlacefileLayer::Render(
std::size_t fontSize = 16;
auto fontSizes =
manager::SettingsManager::general_settings().font_sizes().GetValue();
if (fontSizes.size() > 0)
if (fontSizes.size() > 1)
{
fontSize = fontSizes[1];
}
else if (fontSizes.size() > 0)
{
fontSize = fontSizes[0];
}
@ -159,6 +167,9 @@ void PlacefileLayer::Render(
// Render text
for (auto& placefile : placefileManager->GetActivePlacefiles())
{
p->thresholded_ =
placefileManager->placefile_thresholded(placefile->name());
for (auto& drawItem : placefile->GetDrawItems())
{
switch (drawItem->itemType_)