2015-12-28 14:18:23 +00:00
|
|
|
/*
|
|
|
|
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
|
2015-12-28 14:18:23 +00:00
|
|
|
the AUTHORS file.
|
|
|
|
*/
|
|
|
|
|
2016-02-07 18:28:45 +00:00
|
|
|
#pragma once
|
2015-12-28 14:18:23 +00:00
|
|
|
|
|
|
|
#include <QOpenGLWidget>
|
|
|
|
#include <QOpenGLFunctions>
|
|
|
|
#include <QOpenGLBuffer>
|
|
|
|
#include <QOpenGLShaderProgram>
|
2016-01-09 05:18:24 +00:00
|
|
|
#include <QOpenGLVertexArrayObject>
|
2015-12-28 14:18:23 +00:00
|
|
|
|
2016-01-12 12:55:22 +00:00
|
|
|
#include <QVector>
|
|
|
|
#include <include/functiongraph.hpp>
|
|
|
|
|
2016-01-14 10:52:05 +00:00
|
|
|
#include <chrono>
|
2016-02-28 17:34:40 +00:00
|
|
|
#include <array>
|
2016-01-14 10:52:05 +00:00
|
|
|
|
|
|
|
typedef std::chrono::steady_clock monoclock;
|
|
|
|
|
2015-12-28 14:18:23 +00:00
|
|
|
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|
|
|
{
|
2016-01-12 12:55:22 +00:00
|
|
|
Q_OBJECT
|
2015-12-28 14:18:23 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-12-28 14:18:23 +00:00
|
|
|
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();
|
2015-12-28 14:18:23 +00:00
|
|
|
|
|
|
|
public:
|
2016-02-25 00:21:13 +00:00
|
|
|
std::array<FunctionGraph, 2> m_functions;
|
2016-01-16 13:19:46 +00:00
|
|
|
|
2015-12-28 14:18:23 +00:00
|
|
|
explicit GLWidget(QWidget* parent = 0);
|
2016-01-12 12:55:22 +00:00
|
|
|
void resetMatrix();
|
2015-12-28 14:18:23 +00:00
|
|
|
};
|