Hover over time for additional product information

This commit is contained in:
Dan Paulat 2023-11-19 07:56:52 -06:00
parent c2918daebf
commit 1e7df9f236
6 changed files with 107 additions and 6 deletions

View file

@ -44,9 +44,7 @@ class OverlayLayerImpl
public:
explicit OverlayLayerImpl(std::shared_ptr<MapContext> context) :
activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)},
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)},
sweepTimeString_ {},
sweepTimeNeedsUpdate_ {true}
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)}
{
}
~OverlayLayerImpl() = default;
@ -54,8 +52,9 @@ public:
std::shared_ptr<gl::draw::Rectangle> activeBoxOuter_;
std::shared_ptr<gl::draw::Rectangle> activeBoxInner_;
std::string sweepTimeString_;
bool sweepTimeNeedsUpdate_;
std::string sweepTimeString_ {};
bool sweepTimeNeedsUpdate_ {true};
bool sweepTimePicked_ {false};
};
OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) :
@ -96,6 +95,8 @@ void OverlayLayer::Render(
context()->set_render_parameters(params);
p->sweepTimePicked_ = false;
if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr)
{
const scwx::util::time_zone* currentZone;
@ -154,7 +155,38 @@ void OverlayLayer::Render(
nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_AlwaysAutoResize);
ImGui::TextUnformatted(p->sweepTimeString_.c_str());
if (ImGui::IsWindowHovered())
{
// Show a detailed product description when the sweep time is hovered
p->sweepTimePicked_ = true;
auto fields = radarProductView->GetDescriptionFields();
if (fields.empty())
{
ImGui::TextUnformatted(p->sweepTimeString_.c_str());
}
else
{
if (ImGui::BeginTable("Description Fields", 2))
{
for (auto& field : fields)
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextUnformatted(field.first.c_str());
ImGui::TableNextColumn();
ImGui::TextUnformatted(field.second.c_str());
}
ImGui::EndTable();
}
}
}
else
{
ImGui::TextUnformatted(p->sweepTimeString_.c_str());
}
ImGui::End();
}
@ -178,6 +210,16 @@ void OverlayLayer::Deinitialize()
}
}
bool OverlayLayer::RunMousePicking(
const QMapLibreGL::CustomLayerRenderParameters& /* params */,
const QPointF& /* mouseLocalPos */,
const QPointF& /* mouseGlobalPos */,
const glm::vec2& /* mouseCoords */)
{
// If sweep time was picked, don't process additional items
return p->sweepTimePicked_;
}
void OverlayLayer::UpdateSweepTimeNextFrame()
{
p->sweepTimeNeedsUpdate_ = true;

View file

@ -21,6 +21,11 @@ public:
void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final;
void Deinitialize() override final;
bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params,
const QPointF& mouseLocalPos,
const QPointF& mouseGlobalPos,
const glm::vec2& mouseCoords) override final;
public slots:
void UpdateSweepTimeNextFrame();

View file

@ -9,6 +9,10 @@
#include <boost/range/irange.hpp>
#include <boost/timer/timer.hpp>
#if !defined(_MSC_VER)
# include <date/date.h>
#endif
namespace scwx
{
namespace qt
@ -153,6 +157,44 @@ void Level3ProductView::SelectProduct(const std::string& productName)
p->product_ = productName;
}
std::vector<std::pair<std::string, std::string>>
Level3ProductView::GetDescriptionFields() const
{
std::vector<std::pair<std::string, std::string>> description {};
if (p->graphicMessage_ != nullptr)
{
const scwx::util::time_zone* currentZone;
#if defined(_MSC_VER)
currentZone = std::chrono::current_zone();
#else
currentZone = date::current_zone();
#endif
auto descriptionBlock = p->graphicMessage_->description_block();
if (descriptionBlock != nullptr)
{
auto volumeTime = scwx::util::TimePoint(
descriptionBlock->volume_scan_date(),
descriptionBlock->volume_scan_start_time() * 1000);
auto productTime = scwx::util::TimePoint(
descriptionBlock->generation_date_of_product(),
descriptionBlock->generation_time_of_product() * 1000);
description.emplace_back(
"Volume Time",
scwx::util::TimeString(volumeTime, currentZone, false));
description.emplace_back(
"Product Time",
scwx::util::TimeString(productTime, currentZone, false));
}
}
return description;
}
void Level3ProductView::LoadColorTable(
std::shared_ptr<common::ColorTable> colorTable)
{

View file

@ -38,6 +38,9 @@ public:
void SelectProduct(const std::string& productName) override;
std::vector<std::pair<std::string, std::string>>
GetDescriptionFields() const override;
protected:
std::shared_ptr<wsr88d::rpg::GraphicProductMessage>
graphic_product_message() const;

View file

@ -144,6 +144,12 @@ RadarProductView::GetCfpMomentData() const
return std::tie(data, dataSize, componentSize);
}
std::vector<std::pair<std::string, std::string>>
RadarProductView::GetDescriptionFields() const
{
return {};
}
std::chrono::system_clock::time_point RadarProductView::GetSelectedTime() const
{
return p->selectedTime_;

View file

@ -66,6 +66,9 @@ public:
GetCfpMomentData() const;
std::chrono::system_clock::time_point GetSelectedTime() const;
virtual std::vector<std::pair<std::string, std::string>>
GetDescriptionFields() const;
protected:
virtual boost::asio::thread_pool& thread_pool() = 0;