mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:10:06 +00:00
Refactoring Radar{Layer,Manager,View} to RadarProduct{Layer,Manager,View}
This commit is contained in:
parent
6373728242
commit
5214f866d4
12 changed files with 160 additions and 138 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include <scwx/qt/map/map_widget.hpp>
|
||||
#include <scwx/qt/gl/gl.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 <QApplication>
|
||||
|
|
@ -41,7 +41,7 @@ public:
|
|||
gl_(),
|
||||
settings_(settings),
|
||||
map_(),
|
||||
radarManager_ {std::make_shared<manager::RadarManager>()},
|
||||
radarProductManager_ {std::make_shared<manager::RadarProductManager>()},
|
||||
lastPos_(),
|
||||
frameDraws_(0)
|
||||
{
|
||||
|
|
@ -53,7 +53,7 @@ public:
|
|||
QMapboxGLSettings settings_;
|
||||
std::shared_ptr<QMapboxGL> map_;
|
||||
|
||||
std::shared_ptr<manager::RadarManager> radarManager_;
|
||||
std::shared_ptr<manager::RadarProductManager> radarProductManager_;
|
||||
|
||||
QPointF lastPos_;
|
||||
|
||||
|
|
@ -65,11 +65,11 @@ MapWidget::MapWidget(const QMapboxGLSettings& settings) :
|
|||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
p->radarManager_->Initialize();
|
||||
p->radarProductManager_->Initialize();
|
||||
QString ar2vFile = qgetenv("AR2V_FILE");
|
||||
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()
|
||||
{
|
||||
std::shared_ptr<view::RadarView> radarView =
|
||||
std::make_shared<view::RadarView>(p->radarManager_, p->map_);
|
||||
std::shared_ptr<view::RadarProductView> radarProductView =
|
||||
std::make_shared<view::RadarProductView>(p->radarProductManager_,
|
||||
p->map_);
|
||||
|
||||
radarView->Initialize();
|
||||
radarProductView->Initialize();
|
||||
|
||||
QString colorTableFile = qgetenv("COLOR_TABLE");
|
||||
if (!colorTableFile.isEmpty())
|
||||
{
|
||||
std::shared_ptr<common::ColorTable> colorTable =
|
||||
common::ColorTable::Load(colorTableFile.toUtf8().constData());
|
||||
radarView->LoadColorTable(colorTable);
|
||||
radarProductView->LoadColorTable(colorTable);
|
||||
}
|
||||
|
||||
// QMapboxGL::addCustomLayer will take ownership of the QScopedPointer
|
||||
QScopedPointer<QMapbox::CustomLayerHostInterface> pHost(
|
||||
new RadarLayer(radarView, p->gl_));
|
||||
new RadarProductLayer(radarProductView, p->gl_));
|
||||
QScopedPointer<QMapbox::CustomLayerHostInterface> pOverlayHost(
|
||||
new OverlayLayer(radarView, p->gl_));
|
||||
new OverlayLayer(radarProductView, p->gl_));
|
||||
|
||||
QString before = "ferry";
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,10 @@ static const std::string logPrefix_ = "[scwx::qt::map::overlay_layer] ";
|
|||
class OverlayLayerImpl
|
||||
{
|
||||
public:
|
||||
explicit OverlayLayerImpl(std::shared_ptr<view::RadarView> radarView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
radarView_(radarView),
|
||||
explicit OverlayLayerImpl(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
radarProductView_(radarProductView),
|
||||
gl_(gl),
|
||||
textShader_(gl),
|
||||
font_(util::Font::Create(":/res/fonts/din1451alt.ttf")),
|
||||
|
|
@ -48,8 +49,8 @@ public:
|
|||
}
|
||||
~OverlayLayerImpl() = default;
|
||||
|
||||
std::shared_ptr<view::RadarView> radarView_;
|
||||
gl::OpenGLFunctions& gl_;
|
||||
std::shared_ptr<view::RadarProductView> radarProductView_;
|
||||
gl::OpenGLFunctions& gl_;
|
||||
|
||||
gl::TextShader textShader_;
|
||||
std::shared_ptr<util::Font> font_;
|
||||
|
|
@ -66,9 +67,10 @@ public:
|
|||
bool plotUpdated_;
|
||||
};
|
||||
|
||||
OverlayLayer::OverlayLayer(std::shared_ptr<view::RadarView> radarView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
p(std::make_unique<OverlayLayerImpl>(radarView, gl))
|
||||
OverlayLayer::OverlayLayer(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
p(std::make_unique<OverlayLayerImpl>(radarProductView, gl))
|
||||
{
|
||||
}
|
||||
OverlayLayer::~OverlayLayer() = default;
|
||||
|
|
@ -124,8 +126,8 @@ void OverlayLayer::initialize()
|
|||
// Bottom panel color
|
||||
gl.glUniform4f(p->uColorLocation_, 0.0f, 0.0f, 0.0f, 0.75f);
|
||||
|
||||
connect(p->radarView_.get(),
|
||||
&view::RadarView::PlotUpdated,
|
||||
connect(p->radarProductView_.get(),
|
||||
&view::RadarProductView::PlotUpdated,
|
||||
this,
|
||||
&OverlayLayer::ReceivePlotUpdate);
|
||||
}
|
||||
|
|
@ -139,7 +141,8 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
if (p->plotUpdated_)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
@ -207,8 +210,8 @@ void OverlayLayer::deinitialize()
|
|||
p->vbo_ = {GL_INVALID_INDEX};
|
||||
p->texture_ = GL_INVALID_INDEX;
|
||||
|
||||
disconnect(p->radarView_.get(),
|
||||
&view::RadarView::PlotUpdated,
|
||||
disconnect(p->radarProductView_.get(),
|
||||
&view::RadarProductView::PlotUpdated,
|
||||
this,
|
||||
&OverlayLayer::ReceivePlotUpdate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/gl/gl.hpp>
|
||||
#include <scwx/qt/view/radar_view.hpp>
|
||||
#include <scwx/qt/view/radar_product_view.hpp>
|
||||
|
||||
#include <QMapboxGL>
|
||||
|
||||
|
|
@ -19,8 +19,9 @@ class OverlayLayer : public QObject, public QMapbox::CustomLayerHostInterface
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OverlayLayer(std::shared_ptr<view::RadarView> radarView,
|
||||
gl::OpenGLFunctions& gl);
|
||||
explicit OverlayLayer(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl);
|
||||
~OverlayLayer();
|
||||
|
||||
void initialize() override final;
|
||||
|
|
|
|||
|
|
@ -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 <execution>
|
||||
|
|
@ -21,17 +21,18 @@ namespace map
|
|||
static constexpr uint32_t MAX_RADIALS = 720;
|
||||
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
|
||||
LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate);
|
||||
|
||||
class RadarLayerImpl
|
||||
class RadarProductLayerImpl
|
||||
{
|
||||
public:
|
||||
explicit RadarLayerImpl(std::shared_ptr<view::RadarView> radarView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
radarView_(radarView),
|
||||
explicit RadarProductLayerImpl(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
radarProductView_(radarProductView),
|
||||
gl_(gl),
|
||||
shaderProgram_(gl),
|
||||
uMVPMatrixLocation_(GL_INVALID_INDEX),
|
||||
|
|
@ -44,10 +45,10 @@ public:
|
|||
plotUpdated_(false)
|
||||
{
|
||||
}
|
||||
~RadarLayerImpl() = default;
|
||||
~RadarProductLayerImpl() = default;
|
||||
|
||||
std::shared_ptr<view::RadarView> radarView_;
|
||||
gl::OpenGLFunctions& gl_;
|
||||
std::shared_ptr<view::RadarProductView> radarProductView_;
|
||||
gl::OpenGLFunctions& gl_;
|
||||
|
||||
gl::ShaderProgram shaderProgram_;
|
||||
GLint uMVPMatrixLocation_;
|
||||
|
|
@ -62,14 +63,15 @@ public:
|
|||
bool plotUpdated_;
|
||||
};
|
||||
|
||||
RadarLayer::RadarLayer(std::shared_ptr<view::RadarView> radarView,
|
||||
gl::OpenGLFunctions& gl) :
|
||||
p(std::make_unique<RadarLayerImpl>(radarView, gl))
|
||||
RadarProductLayer::RadarProductLayer(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& 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()";
|
||||
|
||||
|
|
@ -99,27 +101,27 @@ void RadarLayer::initialize()
|
|||
// Generate vertex buffer objects
|
||||
gl.glGenBuffers(2, p->vbo_.data());
|
||||
|
||||
// Update radar plot
|
||||
UpdatePlot();
|
||||
// Update radar sweep
|
||||
UpdateSweep();
|
||||
|
||||
// Create color table
|
||||
gl.glGenTextures(1, &p->texture_);
|
||||
UpdateColorTable();
|
||||
gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
||||
connect(p->radarView_.get(),
|
||||
&view::RadarView::ColorTableLoaded,
|
||||
connect(p->radarProductView_.get(),
|
||||
&view::RadarProductView::ColorTableLoaded,
|
||||
this,
|
||||
&RadarLayer::ReceiveColorTableUpdate);
|
||||
connect(p->radarView_.get(),
|
||||
&view::RadarView::PlotUpdated,
|
||||
&RadarProductLayer::ReceiveColorTableUpdate);
|
||||
connect(p->radarProductView_.get(),
|
||||
&view::RadarProductView::PlotUpdated,
|
||||
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;
|
||||
|
||||
|
|
@ -127,9 +129,11 @@ void RadarLayer::UpdatePlot()
|
|||
|
||||
boost::timer::cpu_timer timer;
|
||||
|
||||
const std::vector<float>& vertices = p->radarView_->vertices();
|
||||
const std::vector<uint8_t>& dataMoments8 = p->radarView_->data_moments8();
|
||||
const std::vector<uint16_t>& dataMoments16 = p->radarView_->data_moments16();
|
||||
const std::vector<float>& vertices = p->radarProductView_->vertices();
|
||||
const std::vector<uint8_t>& dataMoments8 =
|
||||
p->radarProductView_->data_moments8();
|
||||
const std::vector<uint16_t>& dataMoments16 =
|
||||
p->radarProductView_->data_moments16();
|
||||
|
||||
// Bind a vertex array object
|
||||
gl.glBindVertexArray(p->vao_);
|
||||
|
|
@ -182,7 +186,8 @@ void RadarLayer::UpdatePlot()
|
|||
p->numVertices_ = vertices.size() / 2;
|
||||
}
|
||||
|
||||
void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
void RadarProductLayer::render(
|
||||
const QMapbox::CustomLayerRenderParameters& params)
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
@ -193,13 +198,13 @@ void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
|
||||
if (p->plotUpdated_)
|
||||
{
|
||||
UpdatePlot();
|
||||
UpdateSweep();
|
||||
}
|
||||
|
||||
p->shaderProgram_.Use();
|
||||
|
||||
const float scale = p->radarView_->scale() * 2.0f * mbgl::util::tileSize /
|
||||
mbgl::util::DEGREES_MAX;
|
||||
const float scale = p->radarProductView_->scale() * 2.0f *
|
||||
mbgl::util::tileSize / mbgl::util::DEGREES_MAX;
|
||||
const float xScale = scale / params.width;
|
||||
const float yScale = scale / params.height;
|
||||
|
||||
|
|
@ -223,7 +228,7 @@ void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_);
|
||||
}
|
||||
|
||||
void RadarLayer::deinitialize()
|
||||
void RadarProductLayer::deinitialize()
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
@ -237,17 +242,17 @@ void RadarLayer::deinitialize()
|
|||
p->vbo_ = {GL_INVALID_INDEX};
|
||||
p->texture_ = GL_INVALID_INDEX;
|
||||
|
||||
disconnect(p->radarView_.get(),
|
||||
&view::RadarView::ColorTableLoaded,
|
||||
disconnect(p->radarProductView_.get(),
|
||||
&view::RadarProductView::ColorTableLoaded,
|
||||
this,
|
||||
&RadarLayer::ReceiveColorTableUpdate);
|
||||
disconnect(p->radarView_.get(),
|
||||
&view::RadarView::PlotUpdated,
|
||||
&RadarProductLayer::ReceiveColorTableUpdate);
|
||||
disconnect(p->radarProductView_.get(),
|
||||
&view::RadarProductView::PlotUpdated,
|
||||
this,
|
||||
&RadarLayer::ReceivePlotUpdate);
|
||||
&RadarProductLayer::ReceivePlotUpdate);
|
||||
}
|
||||
|
||||
void RadarLayer::UpdateColorTable()
|
||||
void RadarProductLayer::UpdateColorTable()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateColorTable()";
|
||||
|
||||
|
|
@ -256,7 +261,7 @@ void RadarLayer::UpdateColorTable()
|
|||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
const std::vector<boost::gil::rgba8_pixel_t>& colorTable =
|
||||
p->radarView_->color_table();
|
||||
p->radarProductView_->color_table();
|
||||
|
||||
gl.glActiveTexture(GL_TEXTURE0);
|
||||
gl.glBindTexture(GL_TEXTURE_1D, p->texture_);
|
||||
|
|
@ -271,12 +276,12 @@ void RadarLayer::UpdateColorTable()
|
|||
gl.glGenerateMipmap(GL_TEXTURE_1D);
|
||||
}
|
||||
|
||||
void RadarLayer::ReceiveColorTableUpdate()
|
||||
void RadarProductLayer::ReceiveColorTableUpdate()
|
||||
{
|
||||
p->colorTableUpdated_ = true;
|
||||
}
|
||||
|
||||
void RadarLayer::ReceivePlotUpdate()
|
||||
void RadarProductLayer::ReceivePlotUpdate()
|
||||
{
|
||||
p->plotUpdated_ = true;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/gl/gl.hpp>
|
||||
#include <scwx/qt/view/radar_view.hpp>
|
||||
#include <scwx/qt/view/radar_product_view.hpp>
|
||||
|
||||
#include <QMapboxGL>
|
||||
|
||||
|
|
@ -12,30 +12,33 @@ namespace qt
|
|||
namespace map
|
||||
{
|
||||
|
||||
class RadarLayerImpl;
|
||||
class RadarProductLayerImpl;
|
||||
|
||||
class RadarLayer : public QObject, public QMapbox::CustomLayerHostInterface
|
||||
class RadarProductLayer :
|
||||
public QObject,
|
||||
public QMapbox::CustomLayerHostInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RadarLayer(std::shared_ptr<view::RadarView> radarView,
|
||||
gl::OpenGLFunctions& gl);
|
||||
~RadarLayer();
|
||||
explicit RadarProductLayer(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl);
|
||||
~RadarProductLayer();
|
||||
|
||||
void initialize() override final;
|
||||
void render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void deinitialize() override final;
|
||||
|
||||
void UpdateColorTable();
|
||||
void UpdatePlot();
|
||||
void UpdateSweep();
|
||||
|
||||
public slots:
|
||||
void ReceiveColorTableUpdate();
|
||||
void ReceivePlotUpdate();
|
||||
|
||||
private:
|
||||
std::unique_ptr<RadarLayerImpl> p;
|
||||
std::unique_ptr<RadarProductLayerImpl> p;
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
Loading…
Add table
Add a link
Reference in a new issue