Commit a75f53a2 authored by Thibault Soucarre's avatar Thibault Soucarre

add events

parent b0133cf7
......@@ -354,18 +354,11 @@ public:
/* For SVG */
Element_pos radius;/* the circle radius */
drawing_instance->set_color(r, g, b);
time = trace_to_render_x(time - Info::Render::_x_min_visible);
height = trace_to_render_y(height);
container_height = container_height*coeff_trace_render_y();
radius = .5f;
drawing_instance->draw_circle(time, height, _z_event, radius);
drawing_instance->draw_line(time, height,
time, height+container_height, _z_event);
/* For OpenGL */
drawing_instance->draw_event(time, height, container_height);
......
......@@ -72,6 +72,7 @@
#include "render/vbo.hpp"
#include <iostream>
#define PI 3.14159265
#define NB_STEPS 20
using namespace std;
......@@ -79,10 +80,11 @@ using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
static bool _draw_container;
static bool _draw_state;
static bool _draw_states;
static bool _draw_ruler;
static bool _draw_arrow;
static bool _draw_event;
static bool _draw_counter;
//const int Render_alternate::DRAWING_TIMER_DEFAULT = 10;
/***********************************
......@@ -96,7 +98,7 @@ static bool _draw_event;
**********************************/
Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat& format)
: Hook_event(this, core, parent, format), _containers(GL_QUADS), _states(GL_QUADS), _events(GL_POLYGON), _arrows(GL_LINE), _counters(GL_LINE), _ruler(GL_QUADS), _shader("vertexshader.vertexshader", "fragmentshader.fragmentshader"), _modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)){
: Hook_event(this, core, parent, format), _containers(GL_QUADS), _states(GL_QUADS), _circles(GL_POLYGON), _arrows(GL_LINE), _counters(GL_LINE), _ruler(GL_QUADS), _shader("vertexshader.vertexshader", "fragmentshader.fragmentshader"), _modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)){
setAutoFillBackground(false);
......@@ -232,24 +234,47 @@ void Render_alternate::paintGL(){
_arrows.unlock();
_modelview = tmp;*/
int n = _links.size()/4;
for(int i=0; i<n ; i++){
_arrows.lock();
//save current modelview
tmp = _modelview;
//change matrix
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate , _z_arrow));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1.0));
_modelview = glm::translate(_modelview, glm::vec3(_links[4*i+2], _links[4*i+3], 0));
_modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
_modelview = glm::scale(_modelview, glm::vec3(_links[4*i+1], _links[4*i+1/10], 1));
//draw the arrow
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glDrawArrays(GL_LINES, 0,6);
_arrows.unlock();
//restore matrix
_modelview = tmp;
if(false == Info::Render::_no_arrows){
for(int i=0; i<n ; i++){
_arrows.lock();
//save current modelview
tmp = _modelview;
//change matrix
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate , _z_arrow));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1.0));
_modelview = glm::translate(_modelview, glm::vec3(_links[4*i+2], _links[4*i+3], 0));
_modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
_modelview = glm::scale(_modelview, glm::vec3(_links[4*i+1], _links[4*i+1/10], 1));
//draw the arrow
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glDrawArrays(GL_LINES, 0,6);
_arrows.unlock();
//restore matrix
_modelview = tmp;
}
}
/*drawing events*/
if(false == Info::Render::_no_events){
n = _events.size()/3;
for(int i=0; i<n ; i++){
_modelview = glm::translate(_modelview, glm::vec3(_default_entity_x_translate - _x_state_translate, _ruler_y + _ruler_height - _y_state_translate , _z_event));
_modelview = glm::scale(_modelview, glm::vec3(_x_state_scale, _y_state_scale, 1.0));
_modelview = glm::translate(_modelview, glm::vec3(_events[3*i], _events[3*i+1], _z_event));
_modelview = glm::scale(_modelview, glm::vec3(1/_x_state_scale, Info::Screen::width/(_y_state_scale*Info::Screen::height), 1.0));
_circles.lock();
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glDrawArrays(GL_POLYGON, 0, NB_STEPS);
_modelview = glm::scale(_modelview, glm::vec3(1.0, _events[3*i+2]*_y_state_scale*Info::Screen::height/Info::Screen::width, 1.0));
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
glLineWidth(3.0);
glDrawArrays(GL_LINES, NB_STEPS, 2);
glLineWidth(1.0);
_circles.unlock();
_modelview = tmp;
}
}
/*draw selection if necessary*/
......@@ -1004,24 +1029,32 @@ void Render_alternate::start_draw_events(){
}
void Render_alternate::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
/*Event_ buf;
const Element_pos offset_x = -_default_entity_x_translate;
const Element_pos offset_y = -_ruler_y - _ruler_height;
buf.time = time + offset_x;
buf.height = height + offset_y;
buf.container_height = container_height + offset_y;
buf.red = _red;
buf.green = _green;
buf.blue = _blue;
_circles.push_back(buf);*/
_events.push_back(time + offset_x);
_events.push_back(height + offset_y);
_events.push_back(container_height);
}
void Render_alternate::end_draw_events(){
//As for arrows, we use the same coordinates for every events we draw. Position is changed using modelview matrix
set_color(1.0, 1.0, 1.0);
const float angle = 0;
const float delta_angle = 2 * PI / NB_STEPS;
const float radius = 0.5;
for(int j = 0 ; j < NB_STEPS ; j ++){
_circles.add(radius*cos(angle + j*delta_angle), radius*sin(angle + j*delta_angle), _r, _g, _b);
}
_circles.add(0, 0, _r, _g, _b);
_circles.add(0, 0.5, _r, _g, _b);
//_circles.add(cos_table[j]/_x_state_scale, (sin_table[j]*Info::Screen::width)/(_y_state_scale*Info::Screen::height), _r, _g, _b);
// cos_table2[2*j]= cos_table[j]/_x_state_scale;
// sin_table2[2*j+1]= (sin_table[j]*Info::Screen::width)/(_y_state_scale*Info::Screen::height);
_circles.config();
_draw_event = false;
_events.config();
cout << "end_draw_events" << endl;
}
......
......@@ -88,12 +88,13 @@ private:
Element_col _r;
Element_col _g;
Element_col _b;
bool _draw_container;
bool _draw_states;
bool _draw_arrow;
bool _draw_event;
bool _draw_counter;
//bool _draw_container;
//bool _draw_states;
//bool _draw_arrow;
//bool _draw_event;
//bool _draw_counter;
std::vector<Element_pos> _links;
std::vector<Element_pos> _events;
glm::mat4 _modelview;
glm::mat4 _projection;
protected:
......@@ -130,7 +131,7 @@ protected:
//std::vector<Event_> _circles;
Vbo _containers;
Vbo _states;
Vbo _events;
Vbo _circles;
Vbo _arrows;
Vbo _counters;
Vbo _ruler;
......
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