Refactor GeoLine to GeoLines, in order to support multiple segments per draw item

This commit is contained in:
Dan Paulat 2024-02-04 21:17:56 -06:00
parent b8398b4ad0
commit 9499323133
3 changed files with 27 additions and 27 deletions

View file

@ -61,7 +61,7 @@ set(SRC_GL source/scwx/qt/gl/gl_context.cpp
source/scwx/qt/gl/shader_program.cpp) source/scwx/qt/gl/shader_program.cpp)
set(HDR_GL_DRAW source/scwx/qt/gl/draw/draw_item.hpp set(HDR_GL_DRAW source/scwx/qt/gl/draw/draw_item.hpp
source/scwx/qt/gl/draw/geo_icons.hpp source/scwx/qt/gl/draw/geo_icons.hpp
source/scwx/qt/gl/draw/geo_line.hpp source/scwx/qt/gl/draw/geo_lines.hpp
source/scwx/qt/gl/draw/icons.hpp source/scwx/qt/gl/draw/icons.hpp
source/scwx/qt/gl/draw/placefile_icons.hpp source/scwx/qt/gl/draw/placefile_icons.hpp
source/scwx/qt/gl/draw/placefile_images.hpp source/scwx/qt/gl/draw/placefile_images.hpp
@ -72,7 +72,7 @@ set(HDR_GL_DRAW source/scwx/qt/gl/draw/draw_item.hpp
source/scwx/qt/gl/draw/rectangle.hpp) source/scwx/qt/gl/draw/rectangle.hpp)
set(SRC_GL_DRAW source/scwx/qt/gl/draw/draw_item.cpp set(SRC_GL_DRAW source/scwx/qt/gl/draw/draw_item.cpp
source/scwx/qt/gl/draw/geo_icons.cpp source/scwx/qt/gl/draw/geo_icons.cpp
source/scwx/qt/gl/draw/geo_line.cpp source/scwx/qt/gl/draw/geo_lines.cpp
source/scwx/qt/gl/draw/icons.cpp source/scwx/qt/gl/draw/icons.cpp
source/scwx/qt/gl/draw/placefile_icons.cpp source/scwx/qt/gl/draw/placefile_icons.cpp
source/scwx/qt/gl/draw/placefile_images.cpp source/scwx/qt/gl/draw/placefile_images.cpp

View file

@ -1,4 +1,4 @@
#include <scwx/qt/gl/draw/geo_line.hpp> #include <scwx/qt/gl/draw/geo_lines.hpp>
#include <scwx/qt/util/geographic_lib.hpp> #include <scwx/qt/util/geographic_lib.hpp>
#include <scwx/qt/util/texture_atlas.hpp> #include <scwx/qt/util/texture_atlas.hpp>
#include <scwx/common/geographic.hpp> #include <scwx/common/geographic.hpp>
@ -16,7 +16,7 @@ namespace gl
namespace draw namespace draw
{ {
static const std::string logPrefix_ = "scwx::qt::gl::draw::geo_line"; static const std::string logPrefix_ = "scwx::qt::gl::draw::geo_lines";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static constexpr size_t kNumRectangles = 1; static constexpr size_t kNumRectangles = 1;
@ -29,7 +29,7 @@ static constexpr size_t kBufferLength =
static const std::string kTextureName = "lines/default-1x7"; static const std::string kTextureName = "lines/default-1x7";
class GeoLine::Impl class GeoLines::Impl
{ {
public: public:
explicit Impl(std::shared_ptr<GlContext> context) : explicit Impl(std::shared_ptr<GlContext> context) :
@ -79,16 +79,16 @@ public:
void Update(); void Update();
}; };
GeoLine::GeoLine(std::shared_ptr<GlContext> context) : GeoLines::GeoLines(std::shared_ptr<GlContext> context) :
DrawItem(context->gl()), p(std::make_unique<Impl>(context)) DrawItem(context->gl()), p(std::make_unique<Impl>(context))
{ {
} }
GeoLine::~GeoLine() = default; GeoLines::~GeoLines() = default;
GeoLine::GeoLine(GeoLine&&) noexcept = default; GeoLines::GeoLines(GeoLines&&) noexcept = default;
GeoLine& GeoLine::operator=(GeoLine&&) noexcept = default; GeoLines& GeoLines::operator=(GeoLines&&) noexcept = default;
void GeoLine::Initialize() void GeoLines::Initialize()
{ {
gl::OpenGLFunctions& gl = p->context_->gl(); gl::OpenGLFunctions& gl = p->context_->gl();
@ -166,7 +166,7 @@ void GeoLine::Initialize()
p->dirty_ = true; p->dirty_ = true;
} }
void GeoLine::Render(const QMapLibreGL::CustomLayerRenderParameters& params) void GeoLines::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
{ {
if (p->visible_) if (p->visible_)
{ {
@ -186,7 +186,7 @@ void GeoLine::Render(const QMapLibreGL::CustomLayerRenderParameters& params)
} }
} }
void GeoLine::Deinitialize() void GeoLines::Deinitialize()
{ {
gl::OpenGLFunctions& gl = p->context_->gl(); gl::OpenGLFunctions& gl = p->context_->gl();
@ -194,10 +194,10 @@ void GeoLine::Deinitialize()
gl.glDeleteBuffers(1, &p->vbo_); gl.glDeleteBuffers(1, &p->vbo_);
} }
void GeoLine::SetPoints(float latitude1, void GeoLines::SetPoints(float latitude1,
float longitude1, float longitude1,
float latitude2, float latitude2,
float longitude2) float longitude2)
{ {
if (p->points_[0].latitude_ != latitude1 || if (p->points_[0].latitude_ != latitude1 ||
p->points_[0].longitude_ != longitude1 || p->points_[0].longitude_ != longitude1 ||
@ -221,7 +221,7 @@ void GeoLine::SetPoints(float latitude1,
} }
} }
void GeoLine::SetModulateColor(boost::gil::rgba8_pixel_t color) void GeoLines::SetModulateColor(boost::gil::rgba8_pixel_t color)
{ {
if (p->modulateColor_ != color) if (p->modulateColor_ != color)
{ {
@ -230,7 +230,7 @@ void GeoLine::SetModulateColor(boost::gil::rgba8_pixel_t color)
} }
} }
void GeoLine::SetWidth(float width) void GeoLines::SetWidth(float width)
{ {
if (p->width_ != width) if (p->width_ != width)
{ {
@ -239,12 +239,12 @@ void GeoLine::SetWidth(float width)
} }
} }
void GeoLine::SetVisible(bool visible) void GeoLines::SetVisible(bool visible)
{ {
p->visible_ = visible; p->visible_ = visible;
} }
void GeoLine::Impl::Update() void GeoLines::Impl::Update()
{ {
if (dirty_) if (dirty_)
{ {

View file

@ -14,17 +14,17 @@ namespace gl
namespace draw namespace draw
{ {
class GeoLine : public DrawItem class GeoLines : public DrawItem
{ {
public: public:
explicit GeoLine(std::shared_ptr<GlContext> context); explicit GeoLines(std::shared_ptr<GlContext> context);
~GeoLine(); ~GeoLines();
GeoLine(const GeoLine&) = delete; GeoLines(const GeoLines&) = delete;
GeoLine& operator=(const GeoLine&) = delete; GeoLines& operator=(const GeoLines&) = delete;
GeoLine(GeoLine&&) noexcept; GeoLines(GeoLines&&) noexcept;
GeoLine& operator=(GeoLine&&) noexcept; GeoLines& operator=(GeoLines&&) noexcept;
void Initialize() override; void Initialize() override;
void Render(const QMapLibreGL::CustomLayerRenderParameters& params) override; void Render(const QMapLibreGL::CustomLayerRenderParameters& params) override;