From ab30228b1a57053323363674fa7f137c0329a180 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 7 Jul 2020 23:12:04 -0300 Subject: Voltage heat map implemented Voltage heat map implemented using modern OpenGL =) New external library required: -GLEW -GLFW -GLM (incorporeted at the source) Old memory leaks fixed =) --- Project/HMPlane.h | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Project/HMPlane.h (limited to 'Project/HMPlane.h') diff --git a/Project/HMPlane.h b/Project/HMPlane.h new file mode 100644 index 0000000..489523e --- /dev/null +++ b/Project/HMPlane.h @@ -0,0 +1,90 @@ +#ifndef HMPLANE_H +#define HMPLANE_H + +#include +#include +#include + +class VertexBuffer; +class IndexBuffer; +class VertexBufferLayout; +class VertexArray; + +class OpenGLUtils; +class Shader; +class Renderer; + +class OpenGLText; + +struct BufferMeshCoords +{ + float x = 0.0; + float y = 0.0; + float z = 0.0; +}; + +class HMPlane +{ +public: + HMPlane(Shader* shader, Shader* labelShader, const float& width, const float& height, const float limits[2]); + virtual ~HMPlane(); + + virtual void Draw(const Renderer& renderer, const glm::mat4& projectionViewMatrix) const; + virtual void DrawLabel(const Renderer& renderer, const glm::mat4& projectionViewMatrix, const float& x = 0.0, const float& y = 0.0) const; + + virtual void SetLabelLimits(const float& min, const float& max); + virtual float GetMaxLimit() { return m_limits[0]; } + virtual float GetMinLimit() { return m_limits[1]; } + + virtual void SetRectSlope(const wxRect2DDouble& rect, const float& angle, const float& depth); + virtual void UpdateCoords() { FillIndexBuffer(); } + virtual void Resize(const float& width, const float& height); + + virtual void SmoothPlane(const unsigned int& iterations); + virtual void Clear(); + +protected: + + void FillCoordsBuffer(); + void FillIndexBuffer(); + + void BindOpenGLBuffers(); + + void CreateLabel(); + + const float m_meshSize = 15.0f; + unsigned int m_meshTickX = 0; + unsigned int m_meshTickY = 0; + float m_width = 0.0; + float m_height = 0.0; + + std::vector< std::vector > m_coords; + std::vector m_bufferCoords; + std::vector m_indexBuffer; + + // OpenGL shader + Shader* m_shader = nullptr; + Shader* m_labelShader = nullptr; + + // Buffers + VertexBuffer* m_vb = nullptr; + VertexBufferLayout* m_layout = nullptr; + IndexBuffer* m_ib = nullptr; + VertexArray* m_va = nullptr; + + // Label + float m_vertexBufferLabel[4 * 3]; + unsigned int m_indexBufferLabel[6]; + + VertexBuffer* m_vbL = nullptr; + VertexBufferLayout* m_layoutL = nullptr; + IndexBuffer* m_ibL = nullptr; + VertexArray* m_vaL = nullptr; + + std::vector m_glTexts; + float m_limits[2] = {1.1, 0.9}; + + bool m_isClear = true; +}; + +#endif -- cgit