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

View file

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