diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index c36ac27f..c9349a9f 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -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}) diff --git a/scwx-qt/source/scwx/qt/util/gl.hpp b/scwx-qt/source/scwx/qt/gl/gl.hpp similarity index 97% rename from scwx-qt/source/scwx/qt/util/gl.hpp rename to scwx-qt/source/scwx/qt/gl/gl.hpp index 26e11ef5..225d209c 100644 --- a/scwx-qt/source/scwx/qt/util/gl.hpp +++ b/scwx-qt/source/scwx/qt/gl/gl.hpp @@ -16,8 +16,11 @@ namespace scwx { namespace qt { +namespace gl +{ using OpenGLFunctions = QOpenGLFunctions_3_3_Core; +} } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/util/shader_program.cpp b/scwx-qt/source/scwx/qt/gl/shader_program.cpp similarity index 96% rename from scwx-qt/source/scwx/qt/util/shader_program.cpp rename to scwx-qt/source/scwx/qt/gl/shader_program.cpp index a8d02ba6..f7460077 100644 --- a/scwx-qt/source/scwx/qt/util/shader_program.cpp +++ b/scwx-qt/source/scwx/qt/gl/shader_program.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -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 diff --git a/scwx-qt/source/scwx/qt/util/shader_program.hpp b/scwx-qt/source/scwx/qt/gl/shader_program.hpp similarity index 91% rename from scwx-qt/source/scwx/qt/util/shader_program.hpp rename to scwx-qt/source/scwx/qt/gl/shader_program.hpp index b05524ca..386cb627 100644 --- a/scwx-qt/source/scwx/qt/util/shader_program.hpp +++ b/scwx-qt/source/scwx/qt/gl/shader_program.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #ifdef _WIN32 # include @@ -13,6 +13,8 @@ namespace scwx { namespace qt { +namespace gl +{ class ShaderProgramImpl; @@ -38,5 +40,6 @@ private: std::unique_ptr p; }; +} // namespace gl } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/gl/text_shader.hpp b/scwx-qt/source/scwx/qt/gl/text_shader.hpp index 8f1926a8..a64f6d79 100644 --- a/scwx-qt/source/scwx/qt/gl/text_shader.hpp +++ b/scwx-qt/source/scwx/qt/gl/text_shader.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/scwx-qt/source/scwx/qt/main/main.cpp b/scwx-qt/source/scwx/qt/main/main.cpp index ba9153eb..a48fbd4c 100644 --- a/scwx-qt/source/scwx/qt/main/main.cpp +++ b/scwx-qt/source/scwx/qt/main/main.cpp @@ -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(); } diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index 5dab28f0..8e006269 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -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 diff --git a/scwx-qt/source/scwx/qt/main/main_window.hpp b/scwx-qt/source/scwx/qt/main/main_window.hpp index a89bdaaf..a31020ed 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.hpp +++ b/scwx-qt/source/scwx/qt/main/main_window.hpp @@ -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 diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index db19c703..1fa910e0 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -1,8 +1,7 @@ -#include "map_widget.hpp" - +#include +#include #include #include -#include #include #include @@ -17,6 +16,8 @@ namespace scwx { namespace qt { +namespace map +{ typedef std::pair MapStyle; @@ -46,7 +47,7 @@ public: } ~MapWidgetImpl() = default; - OpenGLFunctions gl_; + gl::OpenGLFunctions gl_; QMapboxGLSettings settings_; std::shared_ptr map_; @@ -266,5 +267,6 @@ void MapWidget::mapChanged(QMapboxGL::MapChange mapChange) } } +} // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/map_widget.hpp b/scwx-qt/source/scwx/qt/map/map_widget.hpp index 6d7f5cb5..af176e6f 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.hpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.hpp @@ -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 diff --git a/scwx-qt/source/scwx/qt/map/radar_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_layer.cpp index d8b6b098..80d1d8ac 100644 --- a/scwx-qt/source/scwx/qt/map/radar_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_layer.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include @@ -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 radarView, - OpenGLFunctions& gl) : + gl::OpenGLFunctions& gl) : radarView_(radarView), gl_(gl), shaderProgram_(gl), @@ -45,9 +47,9 @@ public: ~RadarLayerImpl() = default; std::shared_ptr radarView_; - OpenGLFunctions& gl_; + gl::OpenGLFunctions& gl_; - ShaderProgram shaderProgram_; + gl::ShaderProgram shaderProgram_; GLint uMVPMatrixLocation_; GLint uMapScreenCoordLocation_; std::array vbo_; @@ -61,7 +63,7 @@ public: }; RadarLayer::RadarLayer(std::shared_ptr radarView, - OpenGLFunctions& gl) : + gl::OpenGLFunctions& gl) : p(std::make_unique(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& colorTable = p->radarView_->color_table(); @@ -293,5 +295,6 @@ LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate) return screen; } +} // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/radar_layer.hpp b/scwx-qt/source/scwx/qt/map/radar_layer.hpp index ea2d32fe..fc7e236b 100644 --- a/scwx-qt/source/scwx/qt/map/radar_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_layer.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -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 radarView, - OpenGLFunctions& gl); + gl::OpenGLFunctions& gl); ~RadarLayer(); void initialize() override final; @@ -36,5 +38,6 @@ private: std::unique_ptr p; }; +} // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp index 2560e180..0e9aaea6 100644 --- a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp @@ -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 map, const QString& before) "rangeCircleLayer", "line-color", "rgba(128, 128, 128, 128)"); } +} // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp b/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp index e7d9f575..d33ccb68 100644 --- a/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/radar_range_layer.hpp @@ -6,11 +6,14 @@ namespace scwx { namespace qt { +namespace map +{ namespace RadarRangeLayer { void Add(std::shared_ptr map, const QString& before = QString()); }; +} // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/map/triangle_layer.cpp b/scwx-qt/source/scwx/qt/map/triangle_layer.cpp index 5b52c342..71d7cade 100644 --- a/scwx-qt/source/scwx/qt/map/triangle_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/triangle_layer.cpp @@ -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(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 diff --git a/scwx-qt/source/scwx/qt/map/triangle_layer.hpp b/scwx-qt/source/scwx/qt/map/triangle_layer.hpp index e62701c3..72e5f4db 100644 --- a/scwx-qt/source/scwx/qt/map/triangle_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/triangle_layer.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -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 p; }; +} // namespace map } // namespace qt } // namespace scwx diff --git a/scwx-qt/source/scwx/qt/util/font.cpp b/scwx-qt/source/scwx/qt/util/font.cpp index f9c24f1f..ac32106c 100644 --- a/scwx-qt/source/scwx/qt/util/font.cpp +++ b/scwx-qt/source/scwx/qt/util/font.cpp @@ -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); diff --git a/scwx-qt/source/scwx/qt/util/font.hpp b/scwx-qt/source/scwx/qt/util/font.hpp index 789135c7..dc87570a 100644 --- a/scwx-qt/source/scwx/qt/util/font.hpp +++ b/scwx-qt/source/scwx/qt/util/font.hpp @@ -1,7 +1,7 @@ #pragma once +#include #include -#include #include #include @@ -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 Create(const std::string& resource); diff --git a/scwx-qt/source/scwx/qt/util/font_buffer.cpp b/scwx-qt/source/scwx/qt/util/font_buffer.cpp index 06bd4cec..92fd0a3a 100644 --- a/scwx-qt/source/scwx/qt/util/font_buffer.cpp +++ b/scwx-qt/source/scwx/qt/util/font_buffer.cpp @@ -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 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_); diff --git a/scwx-qt/source/scwx/qt/util/font_buffer.hpp b/scwx-qt/source/scwx/qt/util/font_buffer.hpp index c794504c..db886bc6 100644 --- a/scwx-qt/source/scwx/qt/util/font_buffer.hpp +++ b/scwx-qt/source/scwx/qt/util/font_buffer.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -28,7 +28,7 @@ public: void Clear(); void Push(std::initializer_list indices, std::initializer_list vertices); - void Render(OpenGLFunctions& gl); + void Render(gl::OpenGLFunctions& gl); private: std::unique_ptr p;