Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 2685b928 authored by CHEVALIER Arthur's avatar CHEVALIER Arthur Committed by Mathieu Faverge

feat(tmp): Temporary commit to save work

parent 27f52052
......@@ -35,6 +35,9 @@ set (MATRIXVISUALIZER_hdrs
Windows/MatrixWindow.hpp
Windows/MatrixGLWidget.hpp
Common/QuadTree.hpp
Common/Node.hpp
)
set (MATRIXVISUALIZER_srcs
......@@ -48,6 +51,9 @@ set (MATRIXVISUALIZER_srcs
Windows/MatrixWindow.cpp
Windows/MatrixGLWidget.cpp
Common/QuadTree.cpp
Common/Node.cpp
)
QT5_WRAP_UI(MATRIXVISUALIZER_forms
......
#include "Node.hpp"
Node::Node()
{
m_children = nullptr;
}
#ifndef NODE_HPP
#define NODE_HPP
class Node
{
public:
Node();
private:
Node* m_children;
};
#endif
#include "QuadTree.hpp"
QuadTree::QuadTree()
{
}
GLfloat QuadTree::getColor(int x, int y)
{
return (float)(rand() % 100) / 100.f;
}
QuadTree* QuadTree::constructFromSymbolMatrix(symbol_matrix_t* matrix)
{
QuadTree* tree = new QuadTree();
return tree;
}
#ifndef QUADTREE_HPP
#define QUADTREE_HPP
#include <QtOpenGL/QtOpenGL>
#include "../Formats/SymbolMatrix.hpp"
#include "Node.hpp"
class QuadTree
{
public:
QuadTree();
GLfloat getColor(int x, int y);
static QuadTree* constructFromSymbolMatrix(symbol_matrix_t* matrix);
private:
Node m_root;
};
#endif
#include "MatrixGLWidget.hpp"
#include "MatrixWindow.hpp"
#define BACKGROUND_COLOR_R 0.f
#define BACKGROUND_COLOR_G 0.f
#define BACKGROUND_COLOR_B 0.f
#define NB_BLOK_BY_SIDE 256
/* Helpers */
static void drawSquare(GLfloat x, GLfloat y, GLfloat dx, GLfloat dy)
static void drawSquare(GLfloat x, GLfloat y, GLfloat dx, GLfloat dy, GLfloat r, GLfloat g, GLfloat b)
{
glBegin(GL_QUADS);
// Setup color
glColor3f(r, g, b);
// Setup square corners
glVertex2f(x, y);
glVertex2f(x + dx, y);
glVertex2f(x + dx, y - dy);
glVertex2f(x, y - dy);
glEnd();
}
static void drawEmpty()
{
glBegin(GL_TRIANGLES);
glColor3f(BACKGROUND_COLOR_R, BACKGROUND_COLOR_G, BACKGROUND_COLOR_B);
glVertex2f(0, NB_BLOK_BY_SIDE);
glVertex2f(NB_BLOK_BY_SIDE, NB_BLOK_BY_SIDE);
glVertex2f(NB_BLOK_BY_SIDE, 0);
glEnd();
}
MatrixGLWidget::MatrixGLWidget(QWidget* parent, symbol_matrix_t* matrix)
: QOpenGLWidget(parent)
, m_matrix(matrix)
{
this->setFixedSize(MATRIX_WINDOW_LENGTH, MATRIX_WINDOW_HEIGHT);
m_quadtree = QuadTree::constructFromSymbolMatrix(matrix);
symbol_matrix_deinit(matrix);
delete matrix;
}
MatrixGLWidget::~MatrixGLWidget()
{
symbol_matrix_deinit(m_matrix);
delete m_matrix;
delete m_quadtree;
}
void MatrixGLWidget::initializeGL()
{
initializeOpenGLFunctions();
glClearColor(0, 0, 0, 1);
glClearColor(BACKGROUND_COLOR_R, BACKGROUND_COLOR_G, BACKGROUND_COLOR_B, 1.f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, NB_BLOK_BY_SIDE+2, 0, NB_BLOK_BY_SIDE+2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 2, 0);
}
void MatrixGLWidget::resizeGL(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, NB_BLOK_BY_SIDE, 0, NB_BLOK_BY_SIDE, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void MatrixGLWidget::paintGL()
{
int i, j;
initializeOpenGLFunctions();
glClear(GL_COLOR_BUFFER_BIT);
for (i = 0; i < NB_BLOK_BY_SIDE; ++i)
{
for (j = 0; j < NB_BLOK_BY_SIDE; ++j)
{
drawSquare(i, j, 1, 1, m_quadtree->getColor(i, j), 0.f, 0.f);
}
}
drawEmpty();
}
void MatrixGLWidget::keyPressEvent(QKeyEvent *keyEvent)
......
#ifndef MATRIX_GL_WIDGET_HPP
#define MATRIX_GL_WIDGET_HPP
#include <QtOpenGL/QtOpenGL>
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#include <QKeyEvent>
#include "../Formats/SymbolMatrix.hpp"
#include "../Common/QuadTree.hpp"
class MatrixGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
......@@ -24,7 +26,7 @@ private:
/* Helpers */
private:
symbol_matrix_t* m_matrix;
QuadTree* m_quadtree;
};
#endif
#include "MatrixWindow.hpp"
#include <QVBoxLayout>
Matrix_window::Matrix_window(symbol_matrix_t* matrix)
{
m_gl = new MatrixGLWidget(this, matrix);
QWidget* widget = new QWidget();
QVBoxLayout* layout = new QVBoxLayout(widget);
m_gl = new MatrixGLWidget(nullptr, matrix);
m_gl->setObjectName(QStringLiteral("matrix_gl_visualizer"));
this->setCentralWidget(m_gl);
this->setFixedSize(1024, 768);
m_label = new QLabel(nullptr);
m_label->setText("Infos: ");
layout->addWidget(m_gl);
layout->addWidget(m_label);
this->setCentralWidget(widget);
}
Matrix_window::~Matrix_window()
......@@ -19,3 +29,13 @@ void Matrix_window::closeEvent(QCloseEvent* event)
// Dgueu
delete this;
}
void Matrix_window::keyPressEvent(QKeyEvent* event)
{
switch (event->key())
{
case Qt::Key_Escape:
close();
break;
}
}
......@@ -6,6 +6,11 @@
#include <QMainWindow>
#include <QCloseEvent>
#include <QKeyEvent>
#include <QLabel>
#define MATRIX_WINDOW_LENGTH 512
#define MATRIX_WINDOW_HEIGHT 512
class Matrix_window : public QMainWindow
{
......@@ -13,10 +18,13 @@ public:
Matrix_window(symbol_matrix_t* matrix);
~Matrix_window();
protected:
void closeEvent(QCloseEvent* event);
void keyPressEvent(QKeyEvent* keyEvent);
private:
MatrixGLWidget* m_gl;
QLabel* m_label;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment