Namespace cleanup

This commit is contained in:
Dan Paulat 2021-08-08 08:24:40 -05:00
parent c22db501b3
commit 5a97d99a34
20 changed files with 88 additions and 46 deletions

View file

@ -52,8 +52,11 @@ set(HDR_MAIN source/scwx/qt/main/main_window.hpp)
set(SRC_MAIN source/scwx/qt/main/main.cpp
source/scwx/qt/main/main_window.cpp)
set(UI_MAIN source/scwx/qt/main/main_window.ui)
set(HDR_GL source/scwx/qt/gl/text_shader.hpp)
set(SRC_GL source/scwx/qt/gl/text_shader.cpp)
set(HDR_GL source/scwx/qt/gl/gl.hpp
source/scwx/qt/gl/shader_program.hpp
source/scwx/qt/gl/text_shader.hpp)
set(SRC_GL source/scwx/qt/gl/shader_program.cpp
source/scwx/qt/gl/text_shader.cpp)
set(HDR_MANAGER source/scwx/qt/manager/radar_manager.hpp)
set(SRC_MANAGER source/scwx/qt/manager/radar_manager.cpp)
set(HDR_MAP source/scwx/qt/map/map_widget.hpp
@ -65,12 +68,9 @@ set(SRC_MAP source/scwx/qt/map/map_widget.cpp
source/scwx/qt/map/radar_range_layer.cpp
source/scwx/qt/map/triangle_layer.cpp)
set(HDR_UTIL source/scwx/qt/util/font.hpp
source/scwx/qt/util/font_buffer.hpp
source/scwx/qt/util/gl.hpp
source/scwx/qt/util/shader_program.hpp)
source/scwx/qt/util/font_buffer.hpp)
set(SRC_UTIL source/scwx/qt/util/font.cpp
source/scwx/qt/util/font_buffer.cpp
source/scwx/qt/util/shader_program.cpp)
source/scwx/qt/util/font_buffer.cpp)
set(HDR_VIEW source/scwx/qt/view/radar_view.hpp)
set(SRC_VIEW source/scwx/qt/view/radar_view.cpp)
@ -85,6 +85,8 @@ set(TS_FILES ts/scwx_en_US.ts)
set(PROJECT_SOURCES ${HDR_MAIN}
${SRC_MAIN}
${HDR_GL}
${SRC_GL}
${HDR_MANAGER}
${SRC_MANAGER}
${UI_MAIN}
@ -100,6 +102,8 @@ set(PROJECT_SOURCES ${HDR_MAIN}
source_group("Header Files\\main" FILES ${HDR_MAIN})
source_group("Source Files\\main" FILES ${SRC_MAIN})
source_group("Header Files\\gl" FILES ${HDR_GL})
source_group("Source Files\\gl" FILES ${SRC_GL})
source_group("Header Files\\manager" FILES ${HDR_MANAGER})
source_group("Source Files\\manager" FILES ${SRC_MANAGER})
source_group("UI Files\\main" FILES ${UI_MAIN})

View file

@ -16,8 +16,11 @@ namespace scwx
{
namespace qt
{
namespace gl
{
using OpenGLFunctions = QOpenGLFunctions_3_3_Core;
}
} // namespace qt
} // namespace scwx

View file

@ -1,4 +1,4 @@
#include <scwx/qt/util/shader_program.hpp>
#include <scwx/qt/gl/shader_program.hpp>
#include <QFile>
@ -8,8 +8,10 @@ namespace scwx
{
namespace qt
{
namespace gl
{
static const std::string logPrefix_ = "[scwx::qt::util::shader_program] ";
static const std::string logPrefix_ = "[scwx::qt::gl::shader_program] ";
static constexpr GLsizei INFO_LOG_BUF_SIZE = 512;
@ -173,5 +175,6 @@ void ShaderProgram::Use() const
p->gl_.glUseProgram(p->id_);
}
} // namespace gl
} // namespace qt
} // namespace scwx

View file

@ -1,6 +1,6 @@
#pragma once
#include <scwx/qt/util/gl.hpp>
#include <scwx/qt/gl/gl.hpp>
#ifdef _WIN32
# include <Windows.h>
@ -13,6 +13,8 @@ namespace scwx
{
namespace qt
{
namespace gl
{
class ShaderProgramImpl;
@ -38,5 +40,6 @@ private:
std::unique_ptr<ShaderProgramImpl> p;
};
} // namespace gl
} // namespace qt
} // namespace scwx

View file

@ -1,6 +1,6 @@
#pragma once
#include <scwx/qt/util/shader_program.hpp>
#include <scwx/qt/gl/shader_program.hpp>
#include <scwx/qt/util/font.hpp>
#include <memory>

View file

@ -9,8 +9,8 @@ int main(int argc, char* argv[])
boost::log::core::get()->set_filter(boost::log::trivial::severity >=
boost::log::trivial::debug);
QApplication a(argc, argv);
scwx::qt::MainWindow w;
QApplication a(argc, argv);
scwx::qt::main::MainWindow w;
w.show();
return a.exec();
}

View file

@ -7,6 +7,8 @@ namespace scwx
{
namespace qt
{
namespace main
{
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
@ -17,7 +19,7 @@ MainWindow::MainWindow(QWidget* parent) :
settings.setCacheDatabasePath("/tmp/mbgl-cache.db");
settings.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
ui->centralwidget->layout()->addWidget(new MapWidget(settings));
ui->centralwidget->layout()->addWidget(new map::MapWidget(settings));
}
MainWindow::~MainWindow()
@ -25,5 +27,6 @@ MainWindow::~MainWindow()
delete ui;
}
} // namespace main
} // namespace qt
} // namespace scwx

View file

@ -13,6 +13,8 @@ namespace scwx
{
namespace qt
{
namespace main
{
class MainWindow : public QMainWindow
{
@ -26,5 +28,6 @@ private:
Ui::MainWindow* ui;
};
} // namespace main
} // namespace qt
} // namespace scwx

View file

@ -1,8 +1,7 @@
#include "map_widget.hpp"
#include <scwx/qt/map/map_widget.hpp>
#include <scwx/qt/gl/gl.hpp>
#include <scwx/qt/map/radar_layer.hpp>
#include <scwx/qt/map/radar_range_layer.hpp>
#include <scwx/qt/util/gl.hpp>
#include <QApplication>
#include <QColor>
@ -17,6 +16,8 @@ namespace scwx
{
namespace qt
{
namespace map
{
typedef std::pair<std::string, std::string> MapStyle;
@ -46,7 +47,7 @@ public:
}
~MapWidgetImpl() = default;
OpenGLFunctions gl_;
gl::OpenGLFunctions gl_;
QMapboxGLSettings settings_;
std::shared_ptr<QMapboxGL> map_;
@ -266,5 +267,6 @@ void MapWidget::mapChanged(QMapboxGL::MapChange mapChange)
}
}
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -16,6 +16,8 @@ namespace scwx
{
namespace qt
{
namespace map
{
class MapWidgetImpl;
@ -49,5 +51,6 @@ private slots:
void mapChanged(QMapboxGL::MapChange);
};
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -1,5 +1,5 @@
#include <scwx/qt/map/radar_layer.hpp>
#include <scwx/qt/util/shader_program.hpp>
#include <scwx/qt/gl/shader_program.hpp>
#include <execution>
@ -15,6 +15,8 @@ namespace scwx
{
namespace qt
{
namespace map
{
static constexpr uint32_t MAX_RADIALS = 720;
static constexpr uint32_t MAX_DATA_MOMENT_GATES = 1840;
@ -28,7 +30,7 @@ class RadarLayerImpl
{
public:
explicit RadarLayerImpl(std::shared_ptr<view::RadarView> radarView,
OpenGLFunctions& gl) :
gl::OpenGLFunctions& gl) :
radarView_(radarView),
gl_(gl),
shaderProgram_(gl),
@ -45,9 +47,9 @@ public:
~RadarLayerImpl() = default;
std::shared_ptr<view::RadarView> radarView_;
OpenGLFunctions& gl_;
gl::OpenGLFunctions& gl_;
ShaderProgram shaderProgram_;
gl::ShaderProgram shaderProgram_;
GLint uMVPMatrixLocation_;
GLint uMapScreenCoordLocation_;
std::array<GLuint, 2> vbo_;
@ -61,7 +63,7 @@ public:
};
RadarLayer::RadarLayer(std::shared_ptr<view::RadarView> radarView,
OpenGLFunctions& gl) :
gl::OpenGLFunctions& gl) :
p(std::make_unique<RadarLayerImpl>(radarView, gl))
{
}
@ -71,7 +73,7 @@ void RadarLayer::initialize()
{
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "initialize()";
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
// Load and configure radar shader
p->shaderProgram_.Load(":/gl/radar.vert", ":/gl/radar.frag");
@ -121,7 +123,7 @@ void RadarLayer::UpdatePlot()
p->plotUpdated_ = false;
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
boost::timer::cpu_timer timer;
@ -182,7 +184,7 @@ void RadarLayer::UpdatePlot()
void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
{
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
if (p->colorTableUpdated_)
{
@ -223,7 +225,7 @@ void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
void RadarLayer::deinitialize()
{
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "deinitialize()";
@ -251,7 +253,7 @@ void RadarLayer::UpdateColorTable()
p->colorTableUpdated_ = false;
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
const std::vector<boost::gil::rgba8_pixel_t>& colorTable =
p->radarView_->color_table();
@ -293,5 +295,6 @@ LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate)
return screen;
}
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -1,6 +1,6 @@
#pragma once
#include <scwx/qt/util/gl.hpp>
#include <scwx/qt/gl/gl.hpp>
#include <scwx/qt/view/radar_view.hpp>
#include <QMapboxGL>
@ -9,6 +9,8 @@ namespace scwx
{
namespace qt
{
namespace map
{
class RadarLayerImpl;
@ -18,7 +20,7 @@ class RadarLayer : public QObject, public QMapbox::CustomLayerHostInterface
public:
explicit RadarLayer(std::shared_ptr<view::RadarView> radarView,
OpenGLFunctions& gl);
gl::OpenGLFunctions& gl);
~RadarLayer();
void initialize() override final;
@ -36,5 +38,6 @@ private:
std::unique_ptr<RadarLayerImpl> p;
};
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -8,6 +8,8 @@ namespace scwx
{
namespace qt
{
namespace map
{
static const std::string logPrefix_ = "[scwx::qt::map::radar_range_layer] ";
@ -56,5 +58,6 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, const QString& before)
"rangeCircleLayer", "line-color", "rgba(128, 128, 128, 128)");
}
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -6,11 +6,14 @@ namespace scwx
{
namespace qt
{
namespace map
{
namespace RadarRangeLayer
{
void Add(std::shared_ptr<QMapboxGL> map, const QString& before = QString());
};
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -6,13 +6,15 @@ namespace scwx
{
namespace qt
{
namespace map
{
static const std::string logPrefix_ = "[scwx::qt::map::triangle_layer] ";
class TriangleLayerImpl
{
public:
explicit TriangleLayerImpl(OpenGLFunctions& gl) :
explicit TriangleLayerImpl(gl::OpenGLFunctions& gl) :
gl_(gl),
shaderProgram_ {GL_INVALID_INDEX},
vbo_ {GL_INVALID_INDEX},
@ -22,14 +24,14 @@ public:
}
~TriangleLayerImpl() = default;
OpenGLFunctions& gl_;
gl::OpenGLFunctions& gl_;
GLuint shaderProgram_;
GLuint vbo_;
GLuint vao_;
};
TriangleLayer::TriangleLayer(OpenGLFunctions& gl) :
TriangleLayer::TriangleLayer(gl::OpenGLFunctions& gl) :
p(std::make_unique<TriangleLayerImpl>(gl))
{
}
@ -40,7 +42,7 @@ TriangleLayer& TriangleLayer::operator=(TriangleLayer&&) noexcept = default;
void TriangleLayer::initialize()
{
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
static const char* vertexShaderSource =
"#version 330 core\n"
@ -142,7 +144,7 @@ void TriangleLayer::initialize()
void TriangleLayer::render(const QMapbox::CustomLayerRenderParameters&)
{
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
gl.glUseProgram(p->shaderProgram_);
gl.glBindVertexArray(p->vao_);
@ -151,7 +153,7 @@ void TriangleLayer::render(const QMapbox::CustomLayerRenderParameters&)
void TriangleLayer::deinitialize()
{
OpenGLFunctions& gl = p->gl_;
gl::OpenGLFunctions& gl = p->gl_;
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "deinitialize()";
@ -164,5 +166,6 @@ void TriangleLayer::deinitialize()
p->vbo_ = GL_INVALID_INDEX;
}
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -1,6 +1,6 @@
#pragma once
#include <scwx/qt/util/gl.hpp>
#include <scwx/qt/gl/gl.hpp>
#include <QMapboxGL>
@ -8,13 +8,15 @@ namespace scwx
{
namespace qt
{
namespace map
{
class TriangleLayerImpl;
class TriangleLayer : public QMapbox::CustomLayerHostInterface
{
public:
explicit TriangleLayer(OpenGLFunctions& gl);
explicit TriangleLayer(gl::OpenGLFunctions& gl);
~TriangleLayer();
TriangleLayer(const TriangleLayer&) = delete;
@ -31,5 +33,6 @@ private:
std::unique_ptr<TriangleLayerImpl> p;
};
} // namespace map
} // namespace qt
} // namespace scwx

View file

@ -191,7 +191,7 @@ float Font::TextLength(const std::string& text, float pointSize) const
return x;
}
GLuint Font::GenerateTexture(OpenGLFunctions& gl)
GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl)
{
gl.glGenTextures(1, &p->atlas_->id);
gl.glBindTexture(GL_TEXTURE_2D, p->atlas_->id);

View file

@ -1,7 +1,7 @@
#pragma once
#include <scwx/qt/gl/gl.hpp>
#include <scwx/qt/util/font_buffer.hpp>
#include <scwx/qt/util/gl.hpp>
#include <memory>
#include <string>
@ -38,7 +38,7 @@ public:
float Kerning(char c1, char c2) const;
float TextLength(const std::string& text, float pointSize) const;
GLuint GenerateTexture(OpenGLFunctions& gl);
GLuint GenerateTexture(gl::OpenGLFunctions& gl);
static std::shared_ptr<Font> Create(const std::string& resource);

View file

@ -28,7 +28,7 @@ public:
~FontBufferImpl() {}
void RenderSetup(OpenGLFunctions& gl)
void RenderSetup(gl::OpenGLFunctions& gl)
{
// Generate and setup VAO
gl.glGenVertexArrays(1, &vaoId_);
@ -64,7 +64,7 @@ public:
gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indicesId_);
}
void Upload(OpenGLFunctions& gl)
void Upload(gl::OpenGLFunctions& gl)
{
if (verticesId_ == GL_INVALID_INDEX)
{
@ -157,7 +157,7 @@ void FontBuffer::Push(std::initializer_list<GLuint> indices,
p->vertices_.insert(p->vertices_.end(), vertices);
}
void FontBuffer::Render(OpenGLFunctions& gl)
void FontBuffer::Render(gl::OpenGLFunctions& gl)
{
std::scoped_lock lock(p->mutex_);

View file

@ -1,6 +1,6 @@
#pragma once
#include <scwx/qt/util/gl.hpp>
#include <scwx/qt/gl/gl.hpp>
#include <memory>
@ -28,7 +28,7 @@ public:
void Clear();
void Push(std::initializer_list<GLuint> indices,
std::initializer_list<GLfloat> vertices);
void Render(OpenGLFunctions& gl);
void Render(gl::OpenGLFunctions& gl);
private:
std::unique_ptr<FontBufferImpl> p;