Refactoring Radar{Layer,Manager,View} to RadarProduct{Layer,Manager,View}

This commit is contained in:
Dan Paulat 2021-10-30 22:56:05 -05:00
parent 6373728242
commit 5214f866d4
12 changed files with 160 additions and 138 deletions

View file

@ -31,7 +31,7 @@
</packagedElement> </packagedElement>
<packagedElement xmi:type="uml:Package" xmi:id="_knPeIAKhEeyIXMJVZXHk6Q" name="qt"> <packagedElement xmi:type="uml:Package" xmi:id="_knPeIAKhEeyIXMJVZXHk6Q" name="qt">
<packagedElement xmi:type="uml:Package" xmi:id="_md5dwAKhEeyIXMJVZXHk6Q" name="manager"> <packagedElement xmi:type="uml:Package" xmi:id="_md5dwAKhEeyIXMJVZXHk6Q" name="manager">
<packagedElement xmi:type="uml:Class" xmi:id="_UwnjsAKhEeyIXMJVZXHk6Q" name="RadarManager"> <packagedElement xmi:type="uml:Class" xmi:id="_UwnjsAKhEeyIXMJVZXHk6Q" name="RadarProductManager">
<ownedOperation xmi:type="uml:Operation" xmi:id="_6sXFoC9YEeyWgvKLGfX-VA" name="coordinates"> <ownedOperation xmi:type="uml:Operation" xmi:id="_6sXFoC9YEeyWgvKLGfX-VA" name="coordinates">
<ownedParameter xmi:type="uml:Parameter" xmi:id="_CXovQC9ZEeyWgvKLGfX-VA" type="_NOlLAC9WEeyWaqg4hauF0A"/> <ownedParameter xmi:type="uml:Parameter" xmi:id="_CXovQC9ZEeyWgvKLGfX-VA" type="_NOlLAC9WEeyWaqg4hauF0A"/>
<ownedParameter xmi:type="uml:Parameter" xmi:id="_Xk9LIC9lEeyWgvKLGfX-VA" direction="return"> <ownedParameter xmi:type="uml:Parameter" xmi:id="_Xk9LIC9lEeyWgvKLGfX-VA" direction="return">
@ -49,7 +49,7 @@
</packagedElement> </packagedElement>
</packagedElement> </packagedElement>
<packagedElement xmi:type="uml:Package" xmi:id="_oVSdMAKhEeyIXMJVZXHk6Q" name="view"> <packagedElement xmi:type="uml:Package" xmi:id="_oVSdMAKhEeyIXMJVZXHk6Q" name="view">
<packagedElement xmi:type="uml:Class" xmi:id="_Yt2OQAKhEeyIXMJVZXHk6Q" name="RadarView"> <packagedElement xmi:type="uml:Class" xmi:id="_Yt2OQAKhEeyIXMJVZXHk6Q" name="RadarProductView">
<ownedOperation xmi:type="uml:Operation" xmi:id="_Ra89oC9-EeyWgvKLGfX-VA" name="RadarView"> <ownedOperation xmi:type="uml:Operation" xmi:id="_Ra89oC9-EeyWgvKLGfX-VA" name="RadarView">
<ownedParameter xmi:type="uml:Parameter" xmi:id="_fn3IQC9-EeyWgvKLGfX-VA" type="_UwnjsAKhEeyIXMJVZXHk6Q"/> <ownedParameter xmi:type="uml:Parameter" xmi:id="_fn3IQC9-EeyWgvKLGfX-VA" type="_UwnjsAKhEeyIXMJVZXHk6Q"/>
<ownedParameter xmi:type="uml:Parameter" xmi:id="_rTMG8C9-EeyWgvKLGfX-VA"> <ownedParameter xmi:type="uml:Parameter" xmi:id="_rTMG8C9-EeyWgvKLGfX-VA">
@ -105,7 +105,7 @@
</packagedElement> </packagedElement>
</packagedElement> </packagedElement>
<packagedElement xmi:type="uml:Package" xmi:id="_qBoqQAKhEeyIXMJVZXHk6Q" name="map"> <packagedElement xmi:type="uml:Package" xmi:id="_qBoqQAKhEeyIXMJVZXHk6Q" name="map">
<packagedElement xmi:type="uml:Class" xmi:id="_a0ejkAKhEeyIXMJVZXHk6Q" name="RadarLayer"> <packagedElement xmi:type="uml:Class" xmi:id="_a0ejkAKhEeyIXMJVZXHk6Q" name="RadarProductLayer">
<ownedOperation xmi:type="uml:Operation" xmi:id="_X9HDIALIEeyIXMJVZXHk6Q" name="initialize"/> <ownedOperation xmi:type="uml:Operation" xmi:id="_X9HDIALIEeyIXMJVZXHk6Q" name="initialize"/>
<ownedOperation xmi:type="uml:Operation" xmi:id="_Y0k2oALIEeyIXMJVZXHk6Q" name="render"> <ownedOperation xmi:type="uml:Operation" xmi:id="_Y0k2oALIEeyIXMJVZXHk6Q" name="render">
<ownedParameter xmi:type="uml:Parameter" xmi:id="_yX_UkALKEeyIXMJVZXHk6Q" direction="inout"> <ownedParameter xmi:type="uml:Parameter" xmi:id="_yX_UkALKEeyIXMJVZXHk6Q" direction="inout">

View file

@ -1,2 +1,2 @@
#Sat Oct 23 08:00:47 CDT 2021 #Sat Oct 30 22:49:04 CDT 2021
_label_asdf=asdf2 _label_asdf=asdf2

View file

@ -58,20 +58,20 @@ set(HDR_GL source/scwx/qt/gl/gl.hpp
source/scwx/qt/gl/text_shader.hpp) source/scwx/qt/gl/text_shader.hpp)
set(SRC_GL source/scwx/qt/gl/shader_program.cpp set(SRC_GL source/scwx/qt/gl/shader_program.cpp
source/scwx/qt/gl/text_shader.cpp) source/scwx/qt/gl/text_shader.cpp)
set(HDR_MANAGER source/scwx/qt/manager/radar_manager.hpp set(HDR_MANAGER source/scwx/qt/manager/radar_product_manager.hpp
source/scwx/qt/manager/resource_manager.hpp source/scwx/qt/manager/resource_manager.hpp
source/scwx/qt/manager/settings_manager.hpp) source/scwx/qt/manager/settings_manager.hpp)
set(SRC_MANAGER source/scwx/qt/manager/radar_manager.cpp set(SRC_MANAGER source/scwx/qt/manager/radar_product_manager.cpp
source/scwx/qt/manager/resource_manager.cpp source/scwx/qt/manager/resource_manager.cpp
source/scwx/qt/manager/settings_manager.cpp) source/scwx/qt/manager/settings_manager.cpp)
set(HDR_MAP source/scwx/qt/map/map_widget.hpp set(HDR_MAP source/scwx/qt/map/map_widget.hpp
source/scwx/qt/map/overlay_layer.hpp source/scwx/qt/map/overlay_layer.hpp
source/scwx/qt/map/radar_layer.hpp source/scwx/qt/map/radar_product_layer.hpp
source/scwx/qt/map/radar_range_layer.hpp source/scwx/qt/map/radar_range_layer.hpp
source/scwx/qt/map/triangle_layer.hpp) source/scwx/qt/map/triangle_layer.hpp)
set(SRC_MAP source/scwx/qt/map/map_widget.cpp set(SRC_MAP source/scwx/qt/map/map_widget.cpp
source/scwx/qt/map/overlay_layer.cpp source/scwx/qt/map/overlay_layer.cpp
source/scwx/qt/map/radar_layer.cpp source/scwx/qt/map/radar_product_layer.cpp
source/scwx/qt/map/radar_range_layer.cpp source/scwx/qt/map/radar_range_layer.cpp
source/scwx/qt/map/triangle_layer.cpp) source/scwx/qt/map/triangle_layer.cpp)
set(HDR_SETTINGS source/scwx/qt/settings/general_settings.hpp) set(HDR_SETTINGS source/scwx/qt/settings/general_settings.hpp)
@ -82,8 +82,8 @@ set(HDR_UTIL source/scwx/qt/util/font.hpp
set(SRC_UTIL source/scwx/qt/util/font.cpp set(SRC_UTIL source/scwx/qt/util/font.cpp
source/scwx/qt/util/font_buffer.cpp source/scwx/qt/util/font_buffer.cpp
source/scwx/qt/util/json.cpp) source/scwx/qt/util/json.cpp)
set(HDR_VIEW source/scwx/qt/view/radar_view.hpp) set(HDR_VIEW source/scwx/qt/view/radar_product_view.hpp)
set(SRC_VIEW source/scwx/qt/view/radar_view.cpp) set(SRC_VIEW source/scwx/qt/view/radar_product_view.cpp)
set(RESOURCE_FILES scwx-qt.qrc) set(RESOURCE_FILES scwx-qt.qrc)

View file

@ -1,4 +1,4 @@
#include <scwx/qt/manager/radar_manager.hpp> #include <scwx/qt/manager/radar_product_manager.hpp>
#include <scwx/common/constants.hpp> #include <scwx/common/constants.hpp>
#include <deque> #include <deque>
@ -17,7 +17,8 @@ namespace qt
namespace manager namespace manager
{ {
static const std::string logPrefix_ = "[scwx::qt::manager::radar_manager] "; static const std::string logPrefix_ =
"[scwx::qt::manager::radar_product_manager] ";
static constexpr uint32_t NUM_RADIAL_GATES_0_5_DEGREE = static constexpr uint32_t NUM_RADIAL_GATES_0_5_DEGREE =
common::MAX_0_5_DEGREE_RADIALS * common::MAX_DATA_MOMENT_GATES; common::MAX_0_5_DEGREE_RADIALS * common::MAX_DATA_MOMENT_GATES;
@ -31,11 +32,11 @@ static constexpr uint32_t NUM_COORIDNATES_1_DEGREE =
// TODO: Configure this in settings for radar loop // TODO: Configure this in settings for radar loop
static constexpr size_t MAX_LEVEL2_FILES = 6; static constexpr size_t MAX_LEVEL2_FILES = 6;
class RadarManagerImpl class RadarProductManagerImpl
{ {
public: public:
explicit RadarManagerImpl() {} explicit RadarProductManagerImpl() {}
~RadarManagerImpl() = default; ~RadarProductManagerImpl() = default;
std::vector<float> coordinates0_5Degree_; std::vector<float> coordinates0_5Degree_;
std::vector<float> coordinates1Degree_; std::vector<float> coordinates1Degree_;
@ -43,11 +44,14 @@ public:
std::deque<std::shared_ptr<wsr88d::Ar2vFile>> level2Data_; std::deque<std::shared_ptr<wsr88d::Ar2vFile>> level2Data_;
}; };
RadarManager::RadarManager() : p(std::make_unique<RadarManagerImpl>()) {} RadarProductManager::RadarProductManager() :
RadarManager::~RadarManager() = default; p(std::make_unique<RadarProductManagerImpl>())
{
}
RadarProductManager::~RadarProductManager() = default;
const std::vector<float>& const std::vector<float>&
RadarManager::coordinates(common::RadialSize radialSize) const RadarProductManager::coordinates(common::RadialSize radialSize) const
{ {
switch (radialSize) switch (radialSize)
{ {
@ -58,7 +62,7 @@ RadarManager::coordinates(common::RadialSize radialSize) const
throw std::exception("Invalid radial size"); throw std::exception("Invalid radial size");
} }
std::shared_ptr<const wsr88d::Ar2vFile> RadarManager::level2_data() const std::shared_ptr<const wsr88d::Ar2vFile> RadarProductManager::level2_data() const
{ {
std::shared_ptr<const wsr88d::Ar2vFile> level2Data = nullptr; std::shared_ptr<const wsr88d::Ar2vFile> level2Data = nullptr;
@ -70,7 +74,7 @@ std::shared_ptr<const wsr88d::Ar2vFile> RadarManager::level2_data() const
return level2Data; return level2Data;
} }
void RadarManager::Initialize() void RadarProductManager::Initialize()
{ {
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()";
@ -157,7 +161,7 @@ void RadarManager::Initialize()
<< timer.format(6, "%ws"); << timer.format(6, "%ws");
} }
void RadarManager::LoadLevel2Data(const std::string& filename) void RadarProductManager::LoadLevel2Data(const std::string& filename)
{ {
std::shared_ptr<wsr88d::Ar2vFile> ar2vFile = std::shared_ptr<wsr88d::Ar2vFile> ar2vFile =
std::make_shared<wsr88d::Ar2vFile>(); std::make_shared<wsr88d::Ar2vFile>();

View file

@ -15,15 +15,15 @@ namespace qt
namespace manager namespace manager
{ {
class RadarManagerImpl; class RadarProductManagerImpl;
class RadarManager : public QObject class RadarProductManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit RadarManager(); explicit RadarProductManager();
~RadarManager(); ~RadarProductManager();
const std::vector<float>& coordinates(common::RadialSize radialSize) const; const std::vector<float>& coordinates(common::RadialSize radialSize) const;
@ -37,7 +37,7 @@ signals:
void Level2DataLoaded(); void Level2DataLoaded();
private: private:
std::unique_ptr<RadarManagerImpl> p; std::unique_ptr<RadarProductManagerImpl> p;
}; };
} // namespace manager } // namespace manager

View file

@ -1,7 +1,7 @@
#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/map/overlay_layer.hpp> #include <scwx/qt/map/overlay_layer.hpp>
#include <scwx/qt/map/radar_layer.hpp> #include <scwx/qt/map/radar_product_layer.hpp>
#include <scwx/qt/map/radar_range_layer.hpp> #include <scwx/qt/map/radar_range_layer.hpp>
#include <QApplication> #include <QApplication>
@ -41,7 +41,7 @@ public:
gl_(), gl_(),
settings_(settings), settings_(settings),
map_(), map_(),
radarManager_ {std::make_shared<manager::RadarManager>()}, radarProductManager_ {std::make_shared<manager::RadarProductManager>()},
lastPos_(), lastPos_(),
frameDraws_(0) frameDraws_(0)
{ {
@ -53,7 +53,7 @@ public:
QMapboxGLSettings settings_; QMapboxGLSettings settings_;
std::shared_ptr<QMapboxGL> map_; std::shared_ptr<QMapboxGL> map_;
std::shared_ptr<manager::RadarManager> radarManager_; std::shared_ptr<manager::RadarProductManager> radarProductManager_;
QPointF lastPos_; QPointF lastPos_;
@ -65,11 +65,11 @@ MapWidget::MapWidget(const QMapboxGLSettings& settings) :
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
p->radarManager_->Initialize(); p->radarProductManager_->Initialize();
QString ar2vFile = qgetenv("AR2V_FILE"); QString ar2vFile = qgetenv("AR2V_FILE");
if (!ar2vFile.isEmpty()) if (!ar2vFile.isEmpty())
{ {
p->radarManager_->LoadLevel2Data(ar2vFile.toUtf8().constData()); p->radarProductManager_->LoadLevel2Data(ar2vFile.toUtf8().constData());
} }
} }
@ -103,24 +103,25 @@ void MapWidget::changeStyle()
void MapWidget::AddLayers() void MapWidget::AddLayers()
{ {
std::shared_ptr<view::RadarView> radarView = std::shared_ptr<view::RadarProductView> radarProductView =
std::make_shared<view::RadarView>(p->radarManager_, p->map_); std::make_shared<view::RadarProductView>(p->radarProductManager_,
p->map_);
radarView->Initialize(); radarProductView->Initialize();
QString colorTableFile = qgetenv("COLOR_TABLE"); QString colorTableFile = qgetenv("COLOR_TABLE");
if (!colorTableFile.isEmpty()) if (!colorTableFile.isEmpty())
{ {
std::shared_ptr<common::ColorTable> colorTable = std::shared_ptr<common::ColorTable> colorTable =
common::ColorTable::Load(colorTableFile.toUtf8().constData()); common::ColorTable::Load(colorTableFile.toUtf8().constData());
radarView->LoadColorTable(colorTable); radarProductView->LoadColorTable(colorTable);
} }
// QMapboxGL::addCustomLayer will take ownership of the QScopedPointer // QMapboxGL::addCustomLayer will take ownership of the QScopedPointer
QScopedPointer<QMapbox::CustomLayerHostInterface> pHost( QScopedPointer<QMapbox::CustomLayerHostInterface> pHost(
new RadarLayer(radarView, p->gl_)); new RadarProductLayer(radarProductView, p->gl_));
QScopedPointer<QMapbox::CustomLayerHostInterface> pOverlayHost( QScopedPointer<QMapbox::CustomLayerHostInterface> pOverlayHost(
new OverlayLayer(radarView, p->gl_)); new OverlayLayer(radarProductView, p->gl_));
QString before = "ferry"; QString before = "ferry";

View file

@ -28,9 +28,10 @@ static const std::string logPrefix_ = "[scwx::qt::map::overlay_layer] ";
class OverlayLayerImpl class OverlayLayerImpl
{ {
public: public:
explicit OverlayLayerImpl(std::shared_ptr<view::RadarView> radarView, explicit OverlayLayerImpl(
std::shared_ptr<view::RadarProductView> radarProductView,
gl::OpenGLFunctions& gl) : gl::OpenGLFunctions& gl) :
radarView_(radarView), radarProductView_(radarProductView),
gl_(gl), gl_(gl),
textShader_(gl), textShader_(gl),
font_(util::Font::Create(":/res/fonts/din1451alt.ttf")), font_(util::Font::Create(":/res/fonts/din1451alt.ttf")),
@ -48,7 +49,7 @@ public:
} }
~OverlayLayerImpl() = default; ~OverlayLayerImpl() = default;
std::shared_ptr<view::RadarView> radarView_; std::shared_ptr<view::RadarProductView> radarProductView_;
gl::OpenGLFunctions& gl_; gl::OpenGLFunctions& gl_;
gl::TextShader textShader_; gl::TextShader textShader_;
@ -66,9 +67,10 @@ public:
bool plotUpdated_; bool plotUpdated_;
}; };
OverlayLayer::OverlayLayer(std::shared_ptr<view::RadarView> radarView, OverlayLayer::OverlayLayer(
std::shared_ptr<view::RadarProductView> radarProductView,
gl::OpenGLFunctions& gl) : gl::OpenGLFunctions& gl) :
p(std::make_unique<OverlayLayerImpl>(radarView, gl)) p(std::make_unique<OverlayLayerImpl>(radarProductView, gl))
{ {
} }
OverlayLayer::~OverlayLayer() = default; OverlayLayer::~OverlayLayer() = default;
@ -124,8 +126,8 @@ void OverlayLayer::initialize()
// Bottom panel color // Bottom panel color
gl.glUniform4f(p->uColorLocation_, 0.0f, 0.0f, 0.0f, 0.75f); gl.glUniform4f(p->uColorLocation_, 0.0f, 0.0f, 0.0f, 0.75f);
connect(p->radarView_.get(), connect(p->radarProductView_.get(),
&view::RadarView::PlotUpdated, &view::RadarProductView::PlotUpdated,
this, this,
&OverlayLayer::ReceivePlotUpdate); &OverlayLayer::ReceivePlotUpdate);
} }
@ -139,7 +141,8 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
if (p->plotUpdated_) if (p->plotUpdated_)
{ {
using namespace std::chrono; using namespace std::chrono;
auto plotTime = time_point_cast<seconds>(p->radarView_->PlotTime()); auto plotTime =
time_point_cast<seconds>(p->radarProductView_->PlotTime());
if (plotTime.time_since_epoch().count() != 0) if (plotTime.time_since_epoch().count() != 0)
{ {
@ -207,8 +210,8 @@ void OverlayLayer::deinitialize()
p->vbo_ = {GL_INVALID_INDEX}; p->vbo_ = {GL_INVALID_INDEX};
p->texture_ = GL_INVALID_INDEX; p->texture_ = GL_INVALID_INDEX;
disconnect(p->radarView_.get(), disconnect(p->radarProductView_.get(),
&view::RadarView::PlotUpdated, &view::RadarProductView::PlotUpdated,
this, this,
&OverlayLayer::ReceivePlotUpdate); &OverlayLayer::ReceivePlotUpdate);
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <scwx/qt/gl/gl.hpp> #include <scwx/qt/gl/gl.hpp>
#include <scwx/qt/view/radar_view.hpp> #include <scwx/qt/view/radar_product_view.hpp>
#include <QMapboxGL> #include <QMapboxGL>
@ -19,7 +19,8 @@ class OverlayLayer : public QObject, public QMapbox::CustomLayerHostInterface
Q_OBJECT Q_OBJECT
public: public:
explicit OverlayLayer(std::shared_ptr<view::RadarView> radarView, explicit OverlayLayer(
std::shared_ptr<view::RadarProductView> radarProductView,
gl::OpenGLFunctions& gl); gl::OpenGLFunctions& gl);
~OverlayLayer(); ~OverlayLayer();

View file

@ -1,4 +1,4 @@
#include <scwx/qt/map/radar_layer.hpp> #include <scwx/qt/map/radar_product_layer.hpp>
#include <scwx/qt/gl/shader_program.hpp> #include <scwx/qt/gl/shader_program.hpp>
#include <execution> #include <execution>
@ -21,17 +21,18 @@ namespace map
static constexpr uint32_t MAX_RADIALS = 720; static constexpr uint32_t MAX_RADIALS = 720;
static constexpr uint32_t MAX_DATA_MOMENT_GATES = 1840; static constexpr uint32_t MAX_DATA_MOMENT_GATES = 1840;
static const std::string logPrefix_ = "[scwx::qt::map::radar_layer] "; static const std::string logPrefix_ = "[scwx::qt::map::radar_product_layer] ";
static glm::vec2 static glm::vec2
LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate); LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate);
class RadarLayerImpl class RadarProductLayerImpl
{ {
public: public:
explicit RadarLayerImpl(std::shared_ptr<view::RadarView> radarView, explicit RadarProductLayerImpl(
std::shared_ptr<view::RadarProductView> radarProductView,
gl::OpenGLFunctions& gl) : gl::OpenGLFunctions& gl) :
radarView_(radarView), radarProductView_(radarProductView),
gl_(gl), gl_(gl),
shaderProgram_(gl), shaderProgram_(gl),
uMVPMatrixLocation_(GL_INVALID_INDEX), uMVPMatrixLocation_(GL_INVALID_INDEX),
@ -44,9 +45,9 @@ public:
plotUpdated_(false) plotUpdated_(false)
{ {
} }
~RadarLayerImpl() = default; ~RadarProductLayerImpl() = default;
std::shared_ptr<view::RadarView> radarView_; std::shared_ptr<view::RadarProductView> radarProductView_;
gl::OpenGLFunctions& gl_; gl::OpenGLFunctions& gl_;
gl::ShaderProgram shaderProgram_; gl::ShaderProgram shaderProgram_;
@ -62,14 +63,15 @@ public:
bool plotUpdated_; bool plotUpdated_;
}; };
RadarLayer::RadarLayer(std::shared_ptr<view::RadarView> radarView, RadarProductLayer::RadarProductLayer(
std::shared_ptr<view::RadarProductView> radarProductView,
gl::OpenGLFunctions& gl) : gl::OpenGLFunctions& gl) :
p(std::make_unique<RadarLayerImpl>(radarView, gl)) p(std::make_unique<RadarProductLayerImpl>(radarProductView, gl))
{ {
} }
RadarLayer::~RadarLayer() = default; RadarProductLayer::~RadarProductLayer() = default;
void RadarLayer::initialize() void RadarProductLayer::initialize()
{ {
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()"; BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()";
@ -99,27 +101,27 @@ void RadarLayer::initialize()
// Generate vertex buffer objects // Generate vertex buffer objects
gl.glGenBuffers(2, p->vbo_.data()); gl.glGenBuffers(2, p->vbo_.data());
// Update radar plot // Update radar sweep
UpdatePlot(); UpdateSweep();
// Create color table // Create color table
gl.glGenTextures(1, &p->texture_); gl.glGenTextures(1, &p->texture_);
UpdateColorTable(); UpdateColorTable();
gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
connect(p->radarView_.get(), connect(p->radarProductView_.get(),
&view::RadarView::ColorTableLoaded, &view::RadarProductView::ColorTableLoaded,
this, this,
&RadarLayer::ReceiveColorTableUpdate); &RadarProductLayer::ReceiveColorTableUpdate);
connect(p->radarView_.get(), connect(p->radarProductView_.get(),
&view::RadarView::PlotUpdated, &view::RadarProductView::PlotUpdated,
this, this,
&RadarLayer::ReceivePlotUpdate); &RadarProductLayer::ReceivePlotUpdate);
} }
void RadarLayer::UpdatePlot() void RadarProductLayer::UpdateSweep()
{ {
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdatePlot()"; BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateSweep()";
p->plotUpdated_ = false; p->plotUpdated_ = false;
@ -127,9 +129,11 @@ void RadarLayer::UpdatePlot()
boost::timer::cpu_timer timer; boost::timer::cpu_timer timer;
const std::vector<float>& vertices = p->radarView_->vertices(); const std::vector<float>& vertices = p->radarProductView_->vertices();
const std::vector<uint8_t>& dataMoments8 = p->radarView_->data_moments8(); const std::vector<uint8_t>& dataMoments8 =
const std::vector<uint16_t>& dataMoments16 = p->radarView_->data_moments16(); p->radarProductView_->data_moments8();
const std::vector<uint16_t>& dataMoments16 =
p->radarProductView_->data_moments16();
// Bind a vertex array object // Bind a vertex array object
gl.glBindVertexArray(p->vao_); gl.glBindVertexArray(p->vao_);
@ -182,7 +186,8 @@ void RadarLayer::UpdatePlot()
p->numVertices_ = vertices.size() / 2; p->numVertices_ = vertices.size() / 2;
} }
void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params) void RadarProductLayer::render(
const QMapbox::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = p->gl_; gl::OpenGLFunctions& gl = p->gl_;
@ -193,13 +198,13 @@ void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
if (p->plotUpdated_) if (p->plotUpdated_)
{ {
UpdatePlot(); UpdateSweep();
} }
p->shaderProgram_.Use(); p->shaderProgram_.Use();
const float scale = p->radarView_->scale() * 2.0f * mbgl::util::tileSize / const float scale = p->radarProductView_->scale() * 2.0f *
mbgl::util::DEGREES_MAX; mbgl::util::tileSize / mbgl::util::DEGREES_MAX;
const float xScale = scale / params.width; const float xScale = scale / params.width;
const float yScale = scale / params.height; const float yScale = scale / params.height;
@ -223,7 +228,7 @@ void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_); gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_);
} }
void RadarLayer::deinitialize() void RadarProductLayer::deinitialize()
{ {
gl::OpenGLFunctions& gl = p->gl_; gl::OpenGLFunctions& gl = p->gl_;
@ -237,17 +242,17 @@ void RadarLayer::deinitialize()
p->vbo_ = {GL_INVALID_INDEX}; p->vbo_ = {GL_INVALID_INDEX};
p->texture_ = GL_INVALID_INDEX; p->texture_ = GL_INVALID_INDEX;
disconnect(p->radarView_.get(), disconnect(p->radarProductView_.get(),
&view::RadarView::ColorTableLoaded, &view::RadarProductView::ColorTableLoaded,
this, this,
&RadarLayer::ReceiveColorTableUpdate); &RadarProductLayer::ReceiveColorTableUpdate);
disconnect(p->radarView_.get(), disconnect(p->radarProductView_.get(),
&view::RadarView::PlotUpdated, &view::RadarProductView::PlotUpdated,
this, this,
&RadarLayer::ReceivePlotUpdate); &RadarProductLayer::ReceivePlotUpdate);
} }
void RadarLayer::UpdateColorTable() void RadarProductLayer::UpdateColorTable()
{ {
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateColorTable()"; BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateColorTable()";
@ -256,7 +261,7 @@ void RadarLayer::UpdateColorTable()
gl::OpenGLFunctions& gl = p->gl_; gl::OpenGLFunctions& gl = p->gl_;
const std::vector<boost::gil::rgba8_pixel_t>& colorTable = const std::vector<boost::gil::rgba8_pixel_t>& colorTable =
p->radarView_->color_table(); p->radarProductView_->color_table();
gl.glActiveTexture(GL_TEXTURE0); gl.glActiveTexture(GL_TEXTURE0);
gl.glBindTexture(GL_TEXTURE_1D, p->texture_); gl.glBindTexture(GL_TEXTURE_1D, p->texture_);
@ -271,12 +276,12 @@ void RadarLayer::UpdateColorTable()
gl.glGenerateMipmap(GL_TEXTURE_1D); gl.glGenerateMipmap(GL_TEXTURE_1D);
} }
void RadarLayer::ReceiveColorTableUpdate() void RadarProductLayer::ReceiveColorTableUpdate()
{ {
p->colorTableUpdated_ = true; p->colorTableUpdated_ = true;
} }
void RadarLayer::ReceivePlotUpdate() void RadarProductLayer::ReceivePlotUpdate()
{ {
p->plotUpdated_ = true; p->plotUpdated_ = true;
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <scwx/qt/gl/gl.hpp> #include <scwx/qt/gl/gl.hpp>
#include <scwx/qt/view/radar_view.hpp> #include <scwx/qt/view/radar_product_view.hpp>
#include <QMapboxGL> #include <QMapboxGL>
@ -12,30 +12,33 @@ namespace qt
namespace map namespace map
{ {
class RadarLayerImpl; class RadarProductLayerImpl;
class RadarLayer : public QObject, public QMapbox::CustomLayerHostInterface class RadarProductLayer :
public QObject,
public QMapbox::CustomLayerHostInterface
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit RadarLayer(std::shared_ptr<view::RadarView> radarView, explicit RadarProductLayer(
std::shared_ptr<view::RadarProductView> radarProductView,
gl::OpenGLFunctions& gl); gl::OpenGLFunctions& gl);
~RadarLayer(); ~RadarProductLayer();
void initialize() override final; void initialize() override final;
void render(const QMapbox::CustomLayerRenderParameters&) override final; void render(const QMapbox::CustomLayerRenderParameters&) override final;
void deinitialize() override final; void deinitialize() override final;
void UpdateColorTable(); void UpdateColorTable();
void UpdatePlot(); void UpdateSweep();
public slots: public slots:
void ReceiveColorTableUpdate(); void ReceiveColorTableUpdate();
void ReceivePlotUpdate(); void ReceivePlotUpdate();
private: private:
std::unique_ptr<RadarLayerImpl> p; std::unique_ptr<RadarProductLayerImpl> p;
}; };
} // namespace map } // namespace map

View file

@ -1,4 +1,4 @@
#include <scwx/qt/view/radar_view.hpp> #include <scwx/qt/view/radar_product_view.hpp>
#include <scwx/common/constants.hpp> #include <scwx/common/constants.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
@ -12,7 +12,7 @@ namespace qt
namespace view namespace view
{ {
static const std::string logPrefix_ = "[scwx::qt::view::radar_view] "; static const std::string logPrefix_ = "[scwx::qt::view::radar_product_view] ";
static constexpr uint32_t VERTICES_PER_BIN = 6; static constexpr uint32_t VERTICES_PER_BIN = 6;
static constexpr uint32_t VALUES_PER_VERTEX = 2; static constexpr uint32_t VALUES_PER_VERTEX = 2;
@ -20,12 +20,13 @@ static constexpr uint32_t VALUES_PER_VERTEX = 2;
static std::chrono::system_clock::time_point static std::chrono::system_clock::time_point
TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds); TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds);
class RadarViewImpl class RadarProductViewImpl
{ {
public: public:
explicit RadarViewImpl(std::shared_ptr<manager::RadarManager> radarManager, explicit RadarProductViewImpl(
std::shared_ptr<manager::RadarProductManager> radarProductManager,
std::shared_ptr<QMapboxGL> map) : std::shared_ptr<QMapboxGL> map) :
radarManager_(radarManager), radarProductManager_(radarProductManager),
map_(map), map_(map),
plotTime_(), plotTime_(),
colorTable_ {boost::gil::rgba8_pixel_t(0, 128, 0, 255), colorTable_ {boost::gil::rgba8_pixel_t(0, 128, 0, 255),
@ -33,9 +34,9 @@ public:
boost::gil::rgba8_pixel_t(255, 0, 0, 255)} boost::gil::rgba8_pixel_t(255, 0, 0, 255)}
{ {
} }
~RadarViewImpl() = default; ~RadarProductViewImpl() = default;
std::shared_ptr<manager::RadarManager> radarManager_; std::shared_ptr<manager::RadarProductManager> radarProductManager_;
std::shared_ptr<QMapboxGL> map_; std::shared_ptr<QMapboxGL> map_;
std::vector<float> vertices_; std::vector<float> vertices_;
@ -47,53 +48,56 @@ public:
std::vector<boost::gil::rgba8_pixel_t> colorTable_; std::vector<boost::gil::rgba8_pixel_t> colorTable_;
}; };
RadarView::RadarView(std::shared_ptr<manager::RadarManager> radarManager, RadarProductView::RadarProductView(
std::shared_ptr<manager::RadarProductManager> radarProductManager,
std::shared_ptr<QMapboxGL> map) : std::shared_ptr<QMapboxGL> map) :
p(std::make_unique<RadarViewImpl>(radarManager, map)) p(std::make_unique<RadarProductViewImpl>(radarProductManager, map))
{ {
connect(radarManager.get(), connect(radarProductManager.get(),
&manager::RadarManager::Level2DataLoaded, &manager::RadarProductManager::Level2DataLoaded,
this, this,
&RadarView::UpdatePlot); &RadarProductView::UpdatePlot);
} }
RadarView::~RadarView() = default; RadarProductView::~RadarProductView() = default;
double RadarView::bearing() const double RadarProductView::bearing() const
{ {
return p->map_->bearing(); return p->map_->bearing();
} }
double RadarView::scale() const double RadarProductView::scale() const
{ {
return p->map_->scale(); return p->map_->scale();
} }
const std::vector<uint8_t>& RadarView::data_moments8() const const std::vector<uint8_t>& RadarProductView::data_moments8() const
{ {
return p->dataMoments8_; return p->dataMoments8_;
} }
const std::vector<uint16_t>& RadarView::data_moments16() const const std::vector<uint16_t>& RadarProductView::data_moments16() const
{ {
return p->dataMoments16_; return p->dataMoments16_;
} }
const std::vector<float>& RadarView::vertices() const const std::vector<float>& RadarProductView::vertices() const
{ {
return p->vertices_; return p->vertices_;
} }
const std::vector<boost::gil::rgba8_pixel_t>& RadarView::color_table() const const std::vector<boost::gil::rgba8_pixel_t>&
RadarProductView::color_table() const
{ {
return p->colorTable_; return p->colorTable_;
} }
void RadarView::Initialize() void RadarProductView::Initialize()
{ {
UpdatePlot(); UpdatePlot();
} }
void RadarView::LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) void RadarProductView::LoadColorTable(
std::shared_ptr<common::ColorTable> colorTable)
{ {
// TODO: Make size, offset and scale dynamic // TODO: Make size, offset and scale dynamic
const float offset = 66.0f; const float offset = 66.0f;
@ -115,12 +119,12 @@ void RadarView::LoadColorTable(std::shared_ptr<common::ColorTable> colorTable)
emit ColorTableLoaded(); emit ColorTableLoaded();
} }
std::chrono::system_clock::time_point RadarView::PlotTime() std::chrono::system_clock::time_point RadarProductView::PlotTime()
{ {
return p->plotTime_; return p->plotTime_;
} }
void RadarView::UpdatePlot() void RadarProductView::UpdatePlot()
{ {
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdatePlot()"; BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdatePlot()";
@ -128,10 +132,10 @@ void RadarView::UpdatePlot()
// TODO: Pick this based on radar data // TODO: Pick this based on radar data
const std::vector<float>& coordinates = const std::vector<float>& coordinates =
p->radarManager_->coordinates(common::RadialSize::_0_5Degree); p->radarProductManager_->coordinates(common::RadialSize::_0_5Degree);
std::shared_ptr<const wsr88d::Ar2vFile> level2Data = std::shared_ptr<const wsr88d::Ar2vFile> level2Data =
p->radarManager_->level2_data(); p->radarProductManager_->level2_data();
if (level2Data == nullptr) if (level2Data == nullptr)
{ {
return; return;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <scwx/common/color_table.hpp> #include <scwx/common/color_table.hpp>
#include <scwx/qt/manager/radar_manager.hpp> #include <scwx/qt/manager/radar_product_manager.hpp>
#include <chrono> #include <chrono>
#include <memory> #include <memory>
@ -16,16 +16,17 @@ namespace qt
namespace view namespace view
{ {
class RadarViewImpl; class RadarProductViewImpl;
class RadarView : public QObject class RadarProductView : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit RadarView(std::shared_ptr<manager::RadarManager> radarManager, explicit RadarProductView(
std::shared_ptr<manager::RadarProductManager> radarProductManager,
std::shared_ptr<QMapboxGL> map); std::shared_ptr<QMapboxGL> map);
~RadarView(); ~RadarProductView();
double bearing() const; double bearing() const;
double scale() const; double scale() const;
@ -48,7 +49,7 @@ signals:
void PlotUpdated(); void PlotUpdated();
private: private:
std::unique_ptr<RadarViewImpl> p; std::unique_ptr<RadarProductViewImpl> p;
}; };
} // namespace view } // namespace view