diff --git a/src/interface/render_area.cpp b/src/interface/render_area.cpp index 75ff0058258a48eea2d3f582f3893d49e352bc98..c767faead02e199c3fb08124bf9de61764c8aae7 100644 --- a/src/interface/render_area.cpp +++ b/src/interface/render_area.cpp @@ -72,6 +72,7 @@ Render_area::Render_area(QWidget *parent) _state_translate = 0;/* temporary, for states translation */ //_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_arrow = -2.0f;/* closer to camera than containers or states (MUST be negative)*/ _z_state= -3.0f; @@ -271,6 +272,9 @@ void Render_area::paintGL(){ glPopMatrix(); //glCallList(_list_counters); + + draw_stored_arrows(_arrows);/* draw arrows without display lists */ + draw_stored_events(_events);/* draw events without display lists */ break; @@ -379,6 +383,8 @@ bool Render_area::unbuild(){ glEnable(GL_BLEND);/* enable blending for the alpha color */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor3d(1.0, 1.0, 1.0);/* init color to white */ + return true; } diff --git a/src/interface/render_area.hpp b/src/interface/render_area.hpp index 0f034f2e74999e6c226354cc62a026829b6840c1..ffb9ffef3406f99fbb7f69eb05dfab1c881f69a1 100644 --- a/src/interface/render_area.hpp +++ b/src/interface/render_area.hpp @@ -26,6 +26,14 @@ struct Event_{ 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. @@ -43,6 +51,7 @@ class Render_area : public QGLWidget, public Render std::list _text_pos; std::list _text_value; std::vector _events; + std::vector _arrows; /*********************************** @@ -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_stored_arrows(std::vector &arrows); + void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height); void draw_stored_events(std::vector &events); 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(); @@ -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){ + 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 &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; - /* 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); - glScalef(2, 2, 0);/* should be set */ + glTranslated(end_time, end_height, _z_arrow); + 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) */ - else - glRotatef(90,0, 0, 1);/* vertical alignment */ + }/* end if (start_time != end_time) */ + else + glRotatef(90,0, 0, 1);/* vertical alignment */ - // 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();*/ + 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(); - glPopMatrix(); + glPopMatrix(); - glPushMatrix(); + glPushMatrix(); - glTranslated(0, 0, _z_arrow); - glLineWidth(2.5f); - 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); + glTranslated(0, 0, _z_arrow); + glLineWidth(2.5f); + glBegin(GL_LINES); + { + glColor3d(1.0, 0.7, 0.7);glVertex2d(start_time, start_height); + glColor3d(0.9, 0.6, 0.6);glVertex2d(end_time, end_height); } - glEnd(); - glLineWidth(1.0f);/* 1 is the default value */ - - glPopMatrix(); + glEnd(); + glLineWidth(1.0f);/* 1 is the default value */ + glPopMatrix(); + } } - inline void Render_area::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){ Event_ buf;