mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:10:06 +00:00
Change tick display for past vs. forecast data
This commit is contained in:
parent
900267b16f
commit
7de1b1d57d
3 changed files with 86 additions and 13 deletions
|
|
@ -50,6 +50,10 @@ struct LinkedVectorDrawItem
|
||||||
float width_ {5.0f};
|
float width_ {5.0f};
|
||||||
bool visible_ {true};
|
bool visible_ {true};
|
||||||
std::string hoverText_ {};
|
std::string hoverText_ {};
|
||||||
|
|
||||||
|
bool ticksEnabled_ {false};
|
||||||
|
units::length::nautical_miles<double> tickRadius_ {1.0};
|
||||||
|
units::length::nautical_miles<double> tickRadiusIncrement_ {0.0};
|
||||||
};
|
};
|
||||||
|
|
||||||
class LinkedVectors::Impl
|
class LinkedVectors::Impl
|
||||||
|
|
@ -69,10 +73,6 @@ public:
|
||||||
|
|
||||||
std::vector<std::shared_ptr<LinkedVectorDrawItem>> vectorList_ {};
|
std::vector<std::shared_ptr<LinkedVectorDrawItem>> vectorList_ {};
|
||||||
std::shared_ptr<GeoLines> geoLines_;
|
std::shared_ptr<GeoLines> geoLines_;
|
||||||
|
|
||||||
bool ticksEnabled_ {false};
|
|
||||||
units::length::nautical_miles<double> tickRadius_ {1.0};
|
|
||||||
units::length::nautical_miles<double> tickRadiusIncrement_ {1.0};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LinkedVectors::LinkedVectors(std::shared_ptr<GlContext> context) :
|
LinkedVectors::LinkedVectors(std::shared_ptr<GlContext> context) :
|
||||||
|
|
@ -176,6 +176,26 @@ void LinkedVectors::SetVectorHoverText(
|
||||||
di->hoverText_ = text;
|
di->hoverText_ = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinkedVectors::SetVectorTicksEnabled(
|
||||||
|
const std::shared_ptr<LinkedVectorDrawItem>& di, bool enabled)
|
||||||
|
{
|
||||||
|
di->ticksEnabled_ = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinkedVectors::SetVectorTickRadius(
|
||||||
|
const std::shared_ptr<LinkedVectorDrawItem>& di,
|
||||||
|
units::length::meters<double> radius)
|
||||||
|
{
|
||||||
|
di->tickRadius_ = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinkedVectors::SetVectorTickRadiusIncrement(
|
||||||
|
const std::shared_ptr<LinkedVectorDrawItem>& di,
|
||||||
|
units::length::meters<double> radiusIncrement)
|
||||||
|
{
|
||||||
|
di->tickRadiusIncrement_ = radiusIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
void LinkedVectors::FinishVectors()
|
void LinkedVectors::FinishVectors()
|
||||||
{
|
{
|
||||||
// Generate borders
|
// Generate borders
|
||||||
|
|
@ -183,7 +203,7 @@ void LinkedVectors::FinishVectors()
|
||||||
{
|
{
|
||||||
for (auto& di : p->vectorList_)
|
for (auto& di : p->vectorList_)
|
||||||
{
|
{
|
||||||
auto tickRadius = p->tickRadius_;
|
auto tickRadius = di->tickRadius_;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < di->coordinates_.size() - 1; ++i)
|
for (std::size_t i = 0; i < di->coordinates_.size() - 1; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -207,7 +227,7 @@ void LinkedVectors::FinishVectors()
|
||||||
|
|
||||||
di->borderDrawItems_.emplace_back(std::move(borderLine));
|
di->borderDrawItems_.emplace_back(std::move(borderLine));
|
||||||
|
|
||||||
if (p->ticksEnabled_)
|
if (di->ticksEnabled_)
|
||||||
{
|
{
|
||||||
auto angle = util::GeographicLib::GetAngle(
|
auto angle = util::GeographicLib::GetAngle(
|
||||||
latitude1, longitude1, latitude2, longitude2);
|
latitude1, longitude1, latitude2, longitude2);
|
||||||
|
|
@ -234,7 +254,7 @@ void LinkedVectors::FinishVectors()
|
||||||
GeoLines::SetLineVisible(tickBorderLine, di->visible_);
|
GeoLines::SetLineVisible(tickBorderLine, di->visible_);
|
||||||
GeoLines::SetLineHoverText(tickBorderLine, di->hoverText_);
|
GeoLines::SetLineHoverText(tickBorderLine, di->hoverText_);
|
||||||
|
|
||||||
tickRadius += p->tickRadiusIncrement_;
|
tickRadius += di->tickRadiusIncrement_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,7 +263,7 @@ void LinkedVectors::FinishVectors()
|
||||||
// Generate geo lines
|
// Generate geo lines
|
||||||
for (auto& di : p->vectorList_)
|
for (auto& di : p->vectorList_)
|
||||||
{
|
{
|
||||||
auto tickRadius = p->tickRadius_;
|
auto tickRadius = di->tickRadius_;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < di->coordinates_.size() - 1; ++i)
|
for (std::size_t i = 0; i < di->coordinates_.size() - 1; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -272,7 +292,7 @@ void LinkedVectors::FinishVectors()
|
||||||
|
|
||||||
di->lineDrawItems_.emplace_back(std::move(geoLine));
|
di->lineDrawItems_.emplace_back(std::move(geoLine));
|
||||||
|
|
||||||
if (p->ticksEnabled_)
|
if (di->ticksEnabled_)
|
||||||
{
|
{
|
||||||
auto angle = util::GeographicLib::GetAngle(
|
auto angle = util::GeographicLib::GetAngle(
|
||||||
latitude1, longitude1, latitude2, longitude2);
|
latitude1, longitude1, latitude2, longitude2);
|
||||||
|
|
@ -304,7 +324,7 @@ void LinkedVectors::FinishVectors()
|
||||||
GeoLines::SetLineHoverText(tickGeoLine, di->hoverText_);
|
GeoLines::SetLineHoverText(tickGeoLine, di->hoverText_);
|
||||||
}
|
}
|
||||||
|
|
||||||
tickRadius += p->tickRadiusIncrement_;
|
tickRadius += di->tickRadiusIncrement_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <scwx/qt/gl/draw/draw_item.hpp>
|
#include <scwx/qt/gl/draw/draw_item.hpp>
|
||||||
|
|
||||||
#include <boost/gil.hpp>
|
#include <boost/gil.hpp>
|
||||||
|
#include <units/length.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -131,6 +132,36 @@ public:
|
||||||
SetVectorHoverText(const std::shared_ptr<LinkedVectorDrawItem>& di,
|
SetVectorHoverText(const std::shared_ptr<LinkedVectorDrawItem>& di,
|
||||||
const std::string& text);
|
const std::string& text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the presence of ticks on the linked vector.
|
||||||
|
*
|
||||||
|
* @param [in] di Linked vector draw item
|
||||||
|
* @param [in] enabled Ticks enabled
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
SetVectorTicksEnabled(const std::shared_ptr<LinkedVectorDrawItem>& di,
|
||||||
|
bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the tick radius of the linked vector.
|
||||||
|
*
|
||||||
|
* @param [in] di Linked vector draw item
|
||||||
|
* @param [in] radius Length of the tick extending beyond the linked vector
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
SetVectorTickRadius(const std::shared_ptr<LinkedVectorDrawItem>& di,
|
||||||
|
units::length::meters<double> radius);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the tick radius increment of the linked vector.
|
||||||
|
*
|
||||||
|
* @param [in] di Linked vector draw item
|
||||||
|
* @param [in] radiusIncrement Length increment of each tick beyond the first
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
SetVectorTickRadiusIncrement(const std::shared_ptr<LinkedVectorDrawItem>& di,
|
||||||
|
units::length::meters<double> radiusIncrement);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalizes the draw item after adding new linked vectors.
|
* Finalizes the draw item after adding new linked vectors.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public:
|
||||||
const common::Coordinate& center,
|
const common::Coordinate& center,
|
||||||
const std::string& hoverText,
|
const std::string& hoverText,
|
||||||
boost::gil::rgba32f_pixel_t color,
|
boost::gil::rgba32f_pixel_t color,
|
||||||
|
bool tickRadiusIncrement,
|
||||||
std::shared_ptr<gl::draw::LinkedVectors>& linkedVectors);
|
std::shared_ptr<gl::draw::LinkedVectors>& linkedVectors);
|
||||||
static void HandleScitDataPacket(
|
static void HandleScitDataPacket(
|
||||||
const std::shared_ptr<wsr88d::rpg::Packet>& packet,
|
const std::shared_ptr<wsr88d::rpg::Packet>& packet,
|
||||||
|
|
@ -220,10 +221,12 @@ void OverlayProductLayer::Impl::HandleScitDataPacket(
|
||||||
if (scitDataPacket != nullptr)
|
if (scitDataPacket != nullptr)
|
||||||
{
|
{
|
||||||
boost::gil::rgba32f_pixel_t color {1.0f, 1.0f, 1.0f, 1.0f};
|
boost::gil::rgba32f_pixel_t color {1.0f, 1.0f, 1.0f, 1.0f};
|
||||||
|
bool tickRadiusIncrement = true;
|
||||||
if (scitDataPacket->packet_code() ==
|
if (scitDataPacket->packet_code() ==
|
||||||
static_cast<std::uint16_t>(wsr88d::rpg::PacketCode::ScitPastData))
|
static_cast<std::uint16_t>(wsr88d::rpg::PacketCode::ScitPastData))
|
||||||
{
|
{
|
||||||
color = {0.5f, 0.5f, 0.5f, 1.0f};
|
color = {0.5f, 0.5f, 0.5f, 1.0f};
|
||||||
|
tickRadiusIncrement = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& subpacket : scitDataPacket->packet_list())
|
for (auto& subpacket : scitDataPacket->packet_list())
|
||||||
|
|
@ -232,8 +235,12 @@ void OverlayProductLayer::Impl::HandleScitDataPacket(
|
||||||
{
|
{
|
||||||
case static_cast<std::uint16_t>(
|
case static_cast<std::uint16_t>(
|
||||||
wsr88d::rpg::PacketCode::LinkedVectorNoValue):
|
wsr88d::rpg::PacketCode::LinkedVectorNoValue):
|
||||||
HandleLinkedVectorPacket(
|
HandleLinkedVectorPacket(subpacket,
|
||||||
subpacket, center, stormId, color, linkedVectors);
|
center,
|
||||||
|
stormId,
|
||||||
|
color,
|
||||||
|
tickRadiusIncrement,
|
||||||
|
linkedVectors);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -254,6 +261,7 @@ void OverlayProductLayer::Impl::HandleLinkedVectorPacket(
|
||||||
const common::Coordinate& center,
|
const common::Coordinate& center,
|
||||||
const std::string& hoverText,
|
const std::string& hoverText,
|
||||||
boost::gil::rgba32f_pixel_t color,
|
boost::gil::rgba32f_pixel_t color,
|
||||||
|
bool tickRadiusIncrement,
|
||||||
std::shared_ptr<gl::draw::LinkedVectors>& linkedVectors)
|
std::shared_ptr<gl::draw::LinkedVectors>& linkedVectors)
|
||||||
{
|
{
|
||||||
auto linkedVectorPacket =
|
auto linkedVectorPacket =
|
||||||
|
|
@ -265,6 +273,20 @@ void OverlayProductLayer::Impl::HandleLinkedVectorPacket(
|
||||||
gl::draw::LinkedVectors::SetVectorWidth(di, 1.0f);
|
gl::draw::LinkedVectors::SetVectorWidth(di, 1.0f);
|
||||||
gl::draw::LinkedVectors::SetVectorModulate(di, color);
|
gl::draw::LinkedVectors::SetVectorModulate(di, color);
|
||||||
gl::draw::LinkedVectors::SetVectorHoverText(di, hoverText);
|
gl::draw::LinkedVectors::SetVectorHoverText(di, hoverText);
|
||||||
|
gl::draw::LinkedVectors::SetVectorTicksEnabled(di, true);
|
||||||
|
gl::draw::LinkedVectors::SetVectorTickRadius(
|
||||||
|
di, units::length::nautical_miles<double> {1.0});
|
||||||
|
|
||||||
|
if (tickRadiusIncrement)
|
||||||
|
{
|
||||||
|
gl::draw::LinkedVectors::SetVectorTickRadiusIncrement(
|
||||||
|
di, units::length::nautical_miles<double> {1.0});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gl::draw::LinkedVectors::SetVectorTickRadiusIncrement(
|
||||||
|
di, units::length::nautical_miles<double> {0.0});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue