Commit 40531fd7 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Dessin des fleches

parent 1f02df15
...@@ -72,6 +72,7 @@ Render_area::Render_area(QWidget *parent) ...@@ -72,6 +72,7 @@ Render_area::Render_area(QWidget *parent)
_state_translate = 0;/* temporary, for states translation */ _state_translate = 0;/* temporary, for states translation */
//_container_view_size = 50;/* temporary, for container view */ //_container_view_size = 50;/* temporary, for container view */
/* Camera is placed on (0,0,0) and looks to (0,0,-1) */
_z_container = -1.0f; _z_container = -1.0f;
_z_arrow = -2.0f;/* closer to camera than containers or states (MUST be negative)*/ _z_arrow = -2.0f;/* closer to camera than containers or states (MUST be negative)*/
_z_state= -3.0f; _z_state= -3.0f;
...@@ -271,6 +272,9 @@ void Render_area::paintGL(){ ...@@ -271,6 +272,9 @@ void Render_area::paintGL(){
glPopMatrix(); glPopMatrix();
//glCallList(_list_counters); //glCallList(_list_counters);
draw_stored_arrows(_arrows);/* draw arrows without display lists */
draw_stored_events(_events);/* draw events without display lists */ draw_stored_events(_events);/* draw events without display lists */
break; break;
...@@ -379,6 +383,8 @@ bool Render_area::unbuild(){ ...@@ -379,6 +383,8 @@ bool Render_area::unbuild(){
glEnable(GL_BLEND);/* enable blending for the alpha color */ glEnable(GL_BLEND);/* enable blending for the alpha color */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor3d(1.0, 1.0, 1.0);/* init color to white */
return true; return true;
} }
......
...@@ -26,6 +26,14 @@ struct Event_{ ...@@ -26,6 +26,14 @@ struct Event_{
Element_pos container_height; Element_pos container_height;
}; };
struct Arrow_{
Element_pos start_time;
Element_pos end_time;
Element_pos start_height;
Element_pos end_height;
};
/*! /*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace. * \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
...@@ -43,6 +51,7 @@ class Render_area : public QGLWidget, public Render ...@@ -43,6 +51,7 @@ class Render_area : public QGLWidget, public Render
std::list<Element_pos> _text_pos; std::list<Element_pos> _text_pos;
std::list<std::string> _text_value; std::list<std::string> _text_value;
std::vector<Event_> _events; std::vector<Event_> _events;
std::vector<Arrow_> _arrows;
/*********************************** /***********************************
...@@ -329,15 +338,17 @@ class Render_area : public QGLWidget, public Render ...@@ -329,15 +338,17 @@ class Render_area : public QGLWidget, public Render
void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height); void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height);
void draw_stored_arrows(std::vector<Arrow_> &arrows);
void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height); 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 draw_stored_events(std::vector<Event_> &events);
void start_draw_counter(); void start_draw_counter();
void draw_counter(const Element_pos x, const Element_pos y);
void end_draw_counter(); void draw_counter(const Element_pos x, const Element_pos y);
void end_draw_counter();
void end_draw(); void end_draw();
...@@ -468,58 +479,86 @@ inline void Render_area::end_draw_states(){ ...@@ -468,58 +479,86 @@ inline void Render_area::end_draw_states(){
inline void Render_area::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
Arrow_ buf;
buf.start_time = start_time;
buf.end_time = end_time;
buf.start_height = start_height;
buf.end_height = end_height;
_arrows.push_back(buf);
}
inline void Render_area::draw_stored_arrows(std::vector<Arrow_> &arrows){
Element_pos start_time, end_time, start_height, end_height;
/* Manage the event drawing size from state size and render area dimensions */
Element_pos arrow_scale_x = _state_scale*(_render_width/_state_x_max);
Element_pos arrow_scale_y = _render_height/_state_y_max;
Element_pos angle; Element_pos angle;
/* DEBUG */
// std::cerr << "Arrow draw: (" << start_time << ", " << start_height << ") to (" << end_time << ", " << end_height << ")" << std::endl;
for (long i=0 ; i<(long)arrows.size() ; i++){
start_time = arrows[i].start_time*arrow_scale_x + _render_width*_x_scale_container_state-_state_translate;
end_time = arrows[i].end_time*arrow_scale_x + _render_width*_x_scale_container_state-_state_translate;
start_height = arrows[i].start_height*arrow_scale_y;
end_height = arrows[i].end_height*arrow_scale_y;
glPushMatrix(); /* DEBUG */
// std::cerr << "Arrow draw: (" << start_time << ", " << start_height << ") to (" << end_time << ", " << end_height << ")" << std::endl;
glPushMatrix();
glTranslated(end_time, end_height, _z_arrow); glTranslated(end_time, end_height, _z_arrow);
glScalef(2, 2, 0);/* should be set */ glScalef(2, 2, 0);/* should be set */
if (start_time != end_time){ if (start_time != end_time){
angle = atan2((end_height - start_height), (end_time - start_time))*180.0f/PI;/* arc tangent */ angle = atan2((end_height - start_height), (end_time - start_time))*180.0f/PI;/* arc tangent */
glRotatef(angle,0, 0, 1); glRotatef(angle,0, 0, 1);
}/* end if (start_time != end_time) */ }/* end if (start_time != end_time) */
else else
glRotatef(90,0, 0, 1);/* vertical alignment */ glRotatef(90,0, 0, 1);/* vertical alignment */
// 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(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);
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(); glPopMatrix();
glPushMatrix(); glPushMatrix();
glTranslated(0, 0, _z_arrow); glTranslated(0, 0, _z_arrow);
glLineWidth(2.5f); glLineWidth(2.5f);
glBegin(GL_LINES); glBegin(GL_LINES);
{ {
glColor3d(1.0, 0.7, 0.7);glVertex3d(start_time, start_height, _z_arrow); glColor3d(1.0, 0.7, 0.7);glVertex2d(start_time, start_height);
glColor3d(0.9, 0.6, 0.6);glVertex3d(end_time, end_height, _z_arrow); glColor3d(0.9, 0.6, 0.6);glVertex2d(end_time, end_height);
} }
glEnd(); glEnd();
glLineWidth(1.0f);/* 1 is the default value */ glLineWidth(1.0f);/* 1 is the default value */
glPopMatrix();
glPopMatrix();
}
} }
inline void Render_area::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){ inline void Render_area::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
Event_ buf; Event_ buf;
......
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