1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-19 07:02:13 +00:00
stmbl/qt_term/include/glwidget.hpp

75 lines
1.8 KiB
C++
Raw Permalink Normal View History

/*
LICENSE
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
FEEDBACK & QUESTIONS
2016-01-12 12:55:22 +00:00
For feedback and questions about stmbl please e-mail one of the authors named in
the AUTHORS file.
*/
2016-02-07 18:28:45 +00:00
#pragma once
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLBuffer>
#include <QOpenGLShaderProgram>
2016-01-09 05:18:24 +00:00
#include <QOpenGLVertexArrayObject>
2016-01-12 12:55:22 +00:00
#include <QVector>
#include <include/functiongraph.hpp>
2016-01-14 10:52:05 +00:00
#include <chrono>
#include <array>
2016-01-14 10:52:05 +00:00
typedef std::chrono::steady_clock monoclock;
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
2016-01-12 12:55:22 +00:00
Q_OBJECT
private:
QOpenGLShaderProgram* m_shader;
2016-01-10 07:54:07 +00:00
2016-01-12 12:55:22 +00:00
QMatrix4x4 m_matrix;
2016-02-07 02:14:07 +00:00
QVector2D m_center;
float m_scale;
2016-01-10 07:54:07 +00:00
2016-01-12 12:55:22 +00:00
bool m_translating;
2016-02-07 02:14:07 +00:00
bool m_scaling;
2016-01-10 09:49:14 +00:00
2016-02-07 02:14:07 +00:00
QPoint m_translation_start;
2016-01-10 09:49:14 +00:00
2016-01-13 18:20:06 +00:00
QOpenGLBuffer m_vbo;
QOpenGLVertexArrayObject m_vao;
protected:
void initializeGL() override;
void paintGL() override;
2016-01-12 12:55:22 +00:00
void resizeGL(int w, int h) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
2016-01-17 17:08:40 +00:00
void wheelEvent(QWheelEvent* event) override;
2016-01-12 12:55:22 +00:00
void mouseReleaseEvent(QMouseEvent* event) override;
2016-01-11 20:29:06 +00:00
2016-01-14 10:52:05 +00:00
void updateMatrix();
public:
std::array<FunctionGraph, 2> m_functions;
2016-01-16 13:19:46 +00:00
explicit GLWidget(QWidget* parent = 0);
2016-01-12 12:55:22 +00:00
void resetMatrix();
};