mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:30:05 +00:00
Add layer wrapper and generic layer
This commit is contained in:
parent
9ff6eabd2a
commit
a010cc55c3
12 changed files with 187 additions and 40 deletions
|
|
@ -65,12 +65,16 @@ set(SRC_MANAGER source/scwx/qt/manager/radar_product_manager.cpp
|
|||
source/scwx/qt/manager/resource_manager.cpp
|
||||
source/scwx/qt/manager/settings_manager.cpp)
|
||||
set(HDR_MAP source/scwx/qt/map/color_table_layer.hpp
|
||||
source/scwx/qt/map/generic_layer.hpp
|
||||
source/scwx/qt/map/layer_wrapper.hpp
|
||||
source/scwx/qt/map/map_widget.hpp
|
||||
source/scwx/qt/map/overlay_layer.hpp
|
||||
source/scwx/qt/map/radar_product_layer.hpp
|
||||
source/scwx/qt/map/radar_range_layer.hpp
|
||||
source/scwx/qt/map/triangle_layer.hpp)
|
||||
set(SRC_MAP source/scwx/qt/map/color_table_layer.cpp
|
||||
source/scwx/qt/map/generic_layer.cpp
|
||||
source/scwx/qt/map/layer_wrapper.cpp
|
||||
source/scwx/qt/map/map_widget.cpp
|
||||
source/scwx/qt/map/overlay_layer.cpp
|
||||
source/scwx/qt/map/radar_product_layer.cpp
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ ColorTableLayer::ColorTableLayer(
|
|||
}
|
||||
ColorTableLayer::~ColorTableLayer() = default;
|
||||
|
||||
void ColorTableLayer::initialize()
|
||||
void ColorTableLayer::Initialize()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()";
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ void ColorTableLayer::initialize()
|
|||
[=]() { p->colorTableNeedsUpdate_ = true; });
|
||||
}
|
||||
|
||||
void ColorTableLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ void ColorTableLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
SCWX_GL_CHECK_ERROR();
|
||||
}
|
||||
|
||||
void ColorTableLayer::deinitialize()
|
||||
void ColorTableLayer::Deinitialize()
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/gl/gl.hpp>
|
||||
#include <scwx/qt/map/generic_layer.hpp>
|
||||
#include <scwx/qt/view/radar_product_view.hpp>
|
||||
|
||||
#include <QMapboxGL>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -14,19 +13,17 @@ namespace map
|
|||
|
||||
class ColorTableLayerImpl;
|
||||
|
||||
class ColorTableLayer : public QObject, public QMapbox::CustomLayerHostInterface
|
||||
class ColorTableLayer : public GenericLayer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ColorTableLayer(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl);
|
||||
~ColorTableLayer();
|
||||
|
||||
void initialize() override final;
|
||||
void render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void deinitialize() override final;
|
||||
void Initialize() override final;
|
||||
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void Deinitialize() override final;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ColorTableLayerImpl> p;
|
||||
|
|
|
|||
23
scwx-qt/source/scwx/qt/map/generic_layer.cpp
Normal file
23
scwx-qt/source/scwx/qt/map/generic_layer.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <scwx/qt/map/generic_layer.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace map
|
||||
{
|
||||
|
||||
class GenericLayerImpl
|
||||
{
|
||||
public:
|
||||
explicit GenericLayerImpl() {}
|
||||
|
||||
~GenericLayerImpl() {}
|
||||
};
|
||||
|
||||
GenericLayer::GenericLayer() : p(std::make_unique<GenericLayerImpl>()) {}
|
||||
GenericLayer::~GenericLayer() = default;
|
||||
|
||||
} // namespace map
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
35
scwx-qt/source/scwx/qt/map/generic_layer.hpp
Normal file
35
scwx-qt/source/scwx/qt/map/generic_layer.hpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMapboxGL>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace map
|
||||
{
|
||||
|
||||
class GenericLayerImpl;
|
||||
|
||||
class GenericLayer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GenericLayer();
|
||||
~GenericLayer();
|
||||
|
||||
virtual void Initialize() = 0;
|
||||
virtual void Render(const QMapbox::CustomLayerRenderParameters&) = 0;
|
||||
virtual void Deinitialize() = 0;
|
||||
|
||||
private:
|
||||
std::unique_ptr<GenericLayerImpl> p;
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
49
scwx-qt/source/scwx/qt/map/layer_wrapper.cpp
Normal file
49
scwx-qt/source/scwx/qt/map/layer_wrapper.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include <scwx/qt/map/layer_wrapper.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace map
|
||||
{
|
||||
|
||||
class LayerWrapperImpl
|
||||
{
|
||||
public:
|
||||
explicit LayerWrapperImpl(std::shared_ptr<GenericLayer> layer) :
|
||||
layer_ {layer}
|
||||
{
|
||||
}
|
||||
|
||||
~LayerWrapperImpl() {}
|
||||
|
||||
std::shared_ptr<GenericLayer> layer_;
|
||||
};
|
||||
|
||||
LayerWrapper::LayerWrapper(std::shared_ptr<GenericLayer> layer) :
|
||||
p(std::make_unique<LayerWrapperImpl>(layer))
|
||||
{
|
||||
}
|
||||
LayerWrapper::~LayerWrapper() = default;
|
||||
|
||||
LayerWrapper::LayerWrapper(LayerWrapper&&) noexcept = default;
|
||||
LayerWrapper& LayerWrapper::operator=(LayerWrapper&&) noexcept = default;
|
||||
|
||||
void LayerWrapper::initialize()
|
||||
{
|
||||
p->layer_->Initialize();
|
||||
}
|
||||
|
||||
void LayerWrapper::render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
{
|
||||
p->layer_->Render(params);
|
||||
}
|
||||
|
||||
void LayerWrapper::deinitialize()
|
||||
{
|
||||
p->layer_->Deinitialize();
|
||||
}
|
||||
|
||||
} // namespace map
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
36
scwx-qt/source/scwx/qt/map/layer_wrapper.hpp
Normal file
36
scwx-qt/source/scwx/qt/map/layer_wrapper.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/map/generic_layer.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace map
|
||||
{
|
||||
|
||||
class LayerWrapperImpl;
|
||||
|
||||
class LayerWrapper : public QMapbox::CustomLayerHostInterface
|
||||
{
|
||||
public:
|
||||
explicit LayerWrapper(std::shared_ptr<GenericLayer> layer);
|
||||
~LayerWrapper();
|
||||
|
||||
LayerWrapper(const LayerWrapper&) = delete;
|
||||
LayerWrapper& operator=(const LayerWrapper&) = delete;
|
||||
|
||||
LayerWrapper(LayerWrapper&&) noexcept;
|
||||
LayerWrapper& operator=(LayerWrapper&&) noexcept;
|
||||
|
||||
void initialize() override final;
|
||||
void render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void deinitialize() override final;
|
||||
|
||||
private:
|
||||
std::unique_ptr<LayerWrapperImpl> p;
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/map/color_table_layer.hpp>
|
||||
#include <scwx/qt/map/layer_wrapper.hpp>
|
||||
#include <scwx/qt/map/overlay_layer.hpp>
|
||||
#include <scwx/qt/map/radar_product_layer.hpp>
|
||||
#include <scwx/qt/map/radar_range_layer.hpp>
|
||||
|
|
@ -57,6 +58,7 @@ public:
|
|||
radarProductLayer_ {nullptr},
|
||||
radarProductView_ {nullptr},
|
||||
overlayLayer_ {nullptr},
|
||||
colorTableLayer_ {nullptr},
|
||||
isActive_ {false},
|
||||
lastPos_(),
|
||||
currentStyleIndex_ {0},
|
||||
|
|
@ -82,8 +84,10 @@ public:
|
|||
|
||||
std::shared_ptr<common::ColorTable> colorTable_;
|
||||
std::shared_ptr<view::RadarProductView> radarProductView_;
|
||||
std::shared_ptr<RadarProductLayer> radarProductLayer_;
|
||||
std::shared_ptr<OverlayLayer> overlayLayer_;
|
||||
|
||||
std::shared_ptr<RadarProductLayer> radarProductLayer_;
|
||||
std::shared_ptr<OverlayLayer> overlayLayer_;
|
||||
std::shared_ptr<ColorTableLayer> colorTableLayer_;
|
||||
|
||||
bool isActive_;
|
||||
QPointF lastPos_;
|
||||
|
|
@ -236,13 +240,20 @@ void MapWidget::AddLayers()
|
|||
p->map_->removeLayer("colorTable");
|
||||
}
|
||||
|
||||
p->radarProductLayer_ =
|
||||
std::make_shared<RadarProductLayer>(p->radarProductView_, p->gl_);
|
||||
p->overlayLayer_ =
|
||||
std::make_shared<OverlayLayer>(p->radarProductView_, p->gl_);
|
||||
p->colorTableLayer_ =
|
||||
std::make_shared<ColorTableLayer>(p->radarProductView_, p->gl_);
|
||||
|
||||
// QMapboxGL::addCustomLayer will take ownership of the QScopedPointer
|
||||
QScopedPointer<QMapbox::CustomLayerHostInterface> pHost(
|
||||
new RadarProductLayer(p->radarProductView_, p->gl_));
|
||||
new LayerWrapper(p->radarProductLayer_));
|
||||
QScopedPointer<QMapbox::CustomLayerHostInterface> pOverlayHost(
|
||||
new OverlayLayer(p->radarProductView_, p->gl_));
|
||||
new LayerWrapper(p->overlayLayer_));
|
||||
QScopedPointer<QMapbox::CustomLayerHostInterface> pColorTableHost(
|
||||
new ColorTableLayer(p->radarProductView_, p->gl_));
|
||||
new LayerWrapper(p->colorTableLayer_));
|
||||
|
||||
QString before = "ferry";
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ OverlayLayer::OverlayLayer(
|
|||
}
|
||||
OverlayLayer::~OverlayLayer() = default;
|
||||
|
||||
void OverlayLayer::initialize()
|
||||
void OverlayLayer::Initialize()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()";
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ void OverlayLayer::initialize()
|
|||
&OverlayLayer::UpdateSweepTimeNextFrame);
|
||||
}
|
||||
|
||||
void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params)
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
SCWX_GL_CHECK_ERROR();
|
||||
}
|
||||
|
||||
void OverlayLayer::deinitialize()
|
||||
void OverlayLayer::Deinitialize()
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/gl/gl.hpp>
|
||||
#include <scwx/qt/map/generic_layer.hpp>
|
||||
#include <scwx/qt/view/radar_product_view.hpp>
|
||||
|
||||
#include <QMapboxGL>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -14,19 +13,17 @@ namespace map
|
|||
|
||||
class OverlayLayerImpl;
|
||||
|
||||
class OverlayLayer : public QObject, public QMapbox::CustomLayerHostInterface
|
||||
class OverlayLayer : public GenericLayer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OverlayLayer(
|
||||
std::shared_ptr<view::RadarProductView> radarProductView,
|
||||
gl::OpenGLFunctions& gl);
|
||||
~OverlayLayer();
|
||||
|
||||
void initialize() override final;
|
||||
void render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void deinitialize() override final;
|
||||
void Initialize() override final;
|
||||
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void Deinitialize() override final;
|
||||
|
||||
public slots:
|
||||
void UpdateSweepTimeNextFrame();
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ RadarProductLayer::RadarProductLayer(
|
|||
}
|
||||
RadarProductLayer::~RadarProductLayer() = default;
|
||||
|
||||
void RadarProductLayer::initialize()
|
||||
void RadarProductLayer::Initialize()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()";
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ void RadarProductLayer::UpdateSweep()
|
|||
p->numVertices_ = vertices.size() / 2;
|
||||
}
|
||||
|
||||
void RadarProductLayer::render(
|
||||
void RadarProductLayer::Render(
|
||||
const QMapbox::CustomLayerRenderParameters& params)
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
|
@ -295,7 +295,7 @@ void RadarProductLayer::render(
|
|||
gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_);
|
||||
}
|
||||
|
||||
void RadarProductLayer::deinitialize()
|
||||
void RadarProductLayer::Deinitialize()
|
||||
{
|
||||
gl::OpenGLFunctions& gl = p->gl_;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/gl/gl.hpp>
|
||||
#include <scwx/qt/map/generic_layer.hpp>
|
||||
#include <scwx/qt/view/radar_product_view.hpp>
|
||||
|
||||
#include <QMapboxGL>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -14,21 +13,17 @@ namespace map
|
|||
|
||||
class RadarProductLayerImpl;
|
||||
|
||||
class RadarProductLayer :
|
||||
public QObject,
|
||||
public QMapbox::CustomLayerHostInterface
|
||||
class RadarProductLayer : public GenericLayer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
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 Initialize() override final;
|
||||
void Render(const QMapbox::CustomLayerRenderParameters&) override final;
|
||||
void Deinitialize() override final;
|
||||
|
||||
private:
|
||||
void UpdateColorTable();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue