Commit 4dea3b8f authored by Olivier Lagrasse's avatar Olivier Lagrasse

correction du probleme sur les evenements

parent 03e92a41
......@@ -72,8 +72,10 @@ Render_area::Render_area(QWidget *parent)
_state_translate = 0;/* temporary, for states translation */
//_container_view_size = 50;/* temporary, for container view */
_z_arrow = 1;/* closer to camera than containers or states */
_z_container = -1.0f;
_z_arrow = -2.0f;/* closer to camera than containers or states (MUST be negative)*/
_z_state= -3.0f;
setAutoFillBackground(false);
}
......@@ -157,6 +159,7 @@ void Render_area::paintGL(){
resizeGL(width(), height());
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
......@@ -197,7 +200,7 @@ void Render_area::paintGL(){
glScalef(10.0f/_container_x_max, 50.0f/_container_y_max, 0.0f);
*/
glTranslatef(0.0f, 0.0f, -1.0f);
glTranslatef(0.0f, 0.0f, _z_container);
glScalef( (_render_width/_container_x_max)*_x_scale_container_state, _render_height/_container_y_max, 0.0f);
......@@ -256,10 +259,7 @@ void Render_area::paintGL(){
/* Draw states */
glPushMatrix();
/* glTranslated(20.0f-_state_translate, 40.0f, -2.0f);
glScalef(_state_scale, 50.0f/_container_y_max, 0.0f);*/
glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, -2.0f);
glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, _z_state);
glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_state_y_max, 0.0f);
......@@ -268,11 +268,10 @@ void Render_area::paintGL(){
else
glCallList(_list_states);
glPopMatrix();
//glCallList(_list_counters);
draw_stored_events(_events);/* draw events without display lists */
break;
default:
......
......@@ -20,6 +20,11 @@ typedef double Level;
#include "resource.hpp"
struct Event_{
Element_pos time;
Element_pos height;
Element_pos container_height;
};
/*!
......@@ -37,6 +42,7 @@ class Render_area : public QGLWidget, public Render
std::list<Element_pos> _text_pos;
std::list<std::string> _text_value;
std::vector<Event_> _events;
/***********************************
......@@ -210,14 +216,17 @@ class Render_area : public QGLWidget, public Render
Element_pos _container_x_max;
Element_pos _container_y_max;
Element_pos _event_x_max;
Element_pos _event_y_max;
Element_pos _state_x_max;
Element_pos _state_y_max;
Element_pos _x_scale_container_state;
Element_pos _z_container;/* z position for containers */
Element_pos _z_state;/* z position for states */
Element_pos _z_arrow;/* z position for arrows */
/***********************************
......@@ -322,6 +331,8 @@ class Render_area : public QGLWidget, public Render
void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height);
void draw_stored_events(std::vector<Event_> &events);
void start_draw_counter();
void draw_counter(const Element_pos x, const Element_pos y);
......@@ -329,6 +340,8 @@ class Render_area : public QGLWidget, public Render
void end_draw_counter();
void end_draw();
};
......@@ -457,6 +470,9 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
Element_pos angle;
/* DEBUG */
// std::cerr << "Arrow draw: (" << start_time << ", " << start_height << ") to (" << end_time << ", " << end_height << ")" << std::endl;
glPushMatrix();
......@@ -476,13 +492,13 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
glBegin(GL_TRIANGLES);/* create an arrow */
{
// glBegin(GL_TRIANGLES);/* create an arrow */
/* {
glColor3d(1.0, 0.7, 0.7);glVertex2d(0.5, 0.0);
glColor3d(0.9, 0.6, 0.6);glVertex2d(-0.5, -0.5);
glColor3d(0.9, 0.6, 0.6);glVertex2d(-0.5, 0.5);
}
glEnd();
glEnd();*/
glPopMatrix();
......@@ -490,12 +506,12 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
glTranslated(0, 0, _z_arrow);
glLineWidth(2.5f);
glBegin(GL_LINES);
/*glBegin(GL_LINES);
{
glColor3d(1.0, 0.7, 0.7);glVertex3d(start_time, start_height, _z_arrow);
glColor3d(0.9, 0.6, 0.6);glVertex3d(end_time, end_height, _z_arrow);
}
glEnd();
}
glEnd();*/
glLineWidth(1.0f);/* 1 is the default value */
glPopMatrix();
......@@ -506,43 +522,81 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
inline void Render_area::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
Event_ buf;
buf.time = time;
buf.height = height;
buf.container_height = container_height;
_events.push_back(buf);
if (time>_event_x_max)
_event_x_max = time;
if ((height+container_height)>_event_y_max)
_event_y_max = (height+container_height);
}
inline void Render_area::draw_stored_events(std::vector<Event_> &events){
Element_pos time, height, container_height;
/* Manage the event drawing size from state size and render area dimensions */
Element_pos event_scale_x = _state_scale*(_render_width/_state_x_max);
Element_pos event_scale_y = _render_height/_state_y_max;
Element_pos radius;/* the circle radius */
Element_pos angle;
Element_pos delta_angle;
int step;
/* IMPROVEMENT: put the circle into a display list */
for (long i=0 ; i<(long)events.size() ; i++){
/* draw a circle */
radius = (container_height - height)/2.0f;
angle = PI/2.0f;
step = 20;/* 20 polygons for the circle */
time = events[i].time*event_scale_x + _render_width*_x_scale_container_state-_state_translate;
height = events[i].height*event_scale_y;
container_height = events[i].container_height*event_scale_y;
if (step!=0)
delta_angle = 2*PI/step;
/* DEBUG */
// std::cerr << "Event draw: (" << time << ", " << height << ") with height of:" << container_height << " - " << _render_width << " : " << _render_height << std::endl;
glColor3d(0.5, 0.8, 0.5);
glBegin(GL_POLYGON);
{
for(int i =0 ; i<step ; i++){
glVertex3d(time + cos(angle+delta_angle*i)*radius , height + sin(angle+delta_angle*i)*radius , _z_arrow);
/* IMPROVEMENT: put the circle into a display list */
/* draw a circle */
radius = 2.0f;
angle = PI/2.0f;
step = 20;/* 20 polygons for the circle */
if (step!=0)
delta_angle = 2*PI/step;
glColor3d(0.5, 0.8, 0.5);
glBegin(GL_POLYGON);
{
for(int i =0 ; i<step ; i++){
glVertex3d(time + cos(angle+delta_angle*i)*radius , height + sin(angle+delta_angle*i)*radius , _z_arrow);
}
}
}
glEnd();
glEnd();
/* draw line */
glLineWidth(2.5f);
/* draw line */
glLineWidth(2.5f);
glBegin(GL_LINES);
{
glColor3d(0.5, 0.8, 0.5);glVertex3d(time, height, _z_arrow);
glColor3d(0.4, 0.7, 0.4);glVertex3d(time, height+container_height, _z_arrow);
}
glEnd();
glLineWidth(1.0f);
glBegin(GL_LINES);
{
glColor3d(0.5, 0.8, 0.5);glVertex3d(time, height, _z_arrow);
glColor3d(0.4, 0.7, 0.4);glVertex3d(time, height+container_height, _z_arrow);
}
glEnd();
glLineWidth(1.0f);
}/* and loop */
}
......
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