Commit d036d22c authored by Olivier Lagrasse's avatar Olivier Lagrasse

Affichage compteur + trace affichee a l'endroit

parent d75f106d
......@@ -40,8 +40,8 @@ Render_area::Render_area(QWidget *parent)
_counter_last_x=0;
_counter_last_y=0;
_counter_last_x=0.0;
_counter_last_y=0.0;
/* init main informations about OpenGL scene and QGLWidget size */
......@@ -72,10 +72,12 @@ Render_area::Render_area(QWidget *parent)
_state_translate = 0;/* temporary, for states translation */
/* 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_event = -3.0f;/* closer to camera than containers or states (MUST be negative)*/
_z_state= -4.0f;
_z_container = -1.0;
_z_arrow = -2.0;/* closer to camera than containers or states (MUST be negative)*/
_z_event = -3.0;/* closer to camera than containers or states (MUST be negative)*/
_z_counter = -4.0;
_z_state = -5.0;
setAutoFillBackground(false);
}
......@@ -120,7 +122,7 @@ void Render_area::initializeGL(){
void Render_area::resizeGL(int width, int height){
glViewport(0, 0, width, height);
/* update informations about widget size */
_screen_width = width;
_screen_height = height;
......@@ -135,7 +137,7 @@ void Render_area::resizeGL(int width, int height){
glOrtho(-50, 50, -50, 50, 0, 1000);
break;
case DRAWING_STATE_DRAWING:// A trace is drawn
glOrtho(0, _render_width, 0, _render_height, 0, 1000);
glOrtho(0, _render_width, 0, _render_height, 0, -1000);
break;
default:
message << "Undefined value for the drawing state attribute - Render area" << ende;
......@@ -190,93 +192,112 @@ void Render_area::paintGL(){
glMatrixMode(GL_MODELVIEW);
/* Draw containers */
glPushMatrix();
glPushMatrix();
{
static float a = 0;
a++;
glTranslated(0.0, _render_height, 100.0);
glRotated(180.0, 1.0, 0.0, 0.0);
/* Draw containers */
glPushMatrix();
/* glTranslatef(0.0f, 40.0f, -1.0f);
glScalef(10.0f/_container_x_max, 50.0f/_container_y_max, 0.0f);
*/
/* glTranslatef(0.0f, 40.0f, -1.0f);
glScalef(10.0f/_container_x_max, 50.0f/_container_y_max, 0.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);
glTranslatef(0.0f, 0.0f, _z_container);
glScalef( (_render_width/_container_x_max)*_x_scale_container_state, _render_height/_container_y_max, 0.0f);
#ifdef DEBUG_MODE_RENDER_AREA
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Default container position (before translation and scaling) : (x_max = " << _container_x_max << ", y_max = " << _container_y_max << ")" << endl << endl;
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Default container position (before translation and scaling) : (x_max = " << _container_x_max << ", y_max = " << _container_y_max << ")" << endl << endl;
#endif
if (glIsList(_list_containers)==GL_FALSE)
message << "ERROR LIST not exist for containers." << ende;
else
glCallList(_list_containers);
if (glIsList(_list_containers)==GL_FALSE)
message << "ERROR LIST not exist for containers." << ende;
else
glCallList(_list_containers);
glPopMatrix();
glPopMatrix();
/* Draw container texts */
for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end(); it_txt++, it_pos++ ){
/* Draw container texts */
for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end(); it_txt++, it_pos++ ){
buf_x = *it_pos;
it_pos++;
buf_x = *it_pos;
it_pos++;
buf_y = *it_pos;
buf_y = *it_pos;
buf_txt = *it_txt;
buf_txt = *it_txt;
glPushMatrix();
glPushMatrix();
/* glTranslatef(0.0f, 40.0f, 0.0f);
glScalef(10.0f/_container_x_max, 50.0f/_container_y_max, 0.0f);
*/
/* glTranslatef(0.0f, 40.0f, 0.0f);
glScalef(10.0f/_container_x_max, 50.0f/_container_y_max, 0.0f);
*/
glScalef( (_render_width/_container_x_max)*_x_scale_container_state, _render_height/_container_y_max, 0.0f);
glScalef( (_render_width/_container_x_max)*_x_scale_container_state, _render_height/_container_y_max, 0.0f);
glColor3d(1, 1, 1);
glRasterPos2f(buf_x,buf_y);
glColor3d(1, 1, 1);
glRasterPos2f(buf_x,buf_y);
#ifdef DEBUG_MODE_RENDER_AREA
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Container texts position: (x = " << buf_x << ", y = " << buf_y << ") -> '" << buf_txt << "'" << endl << endl;
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "Container texts position: (x = " << buf_x << ", y = " << buf_y << ") -> '" << buf_txt << "'" << endl << endl;
#endif
for(unsigned int i=0;i<buf_txt.length();i++){
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, buf_txt.c_str()[i]);
}
for(unsigned int i=0;i<buf_txt.length();i++){
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, buf_txt.c_str()[i]);
}
glPopMatrix();
}/* end for(...) */
glPopMatrix();
}/* end for(...) */
/* Draw states */
glPushMatrix();
/* Draw states */
glPushMatrix();
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);
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);
if (glIsList(_list_states)==GL_FALSE)
message << "ERROR LIST not exist for states." << ende;
else
glCallList(_list_states);
if (glIsList(_list_states)==GL_FALSE)
message << "ERROR LIST not exist for states." << ende;
else
glCallList(_list_states);
glPopMatrix();
glPopMatrix();
/* Draw counters */
glPushMatrix();
glTranslated( _render_width*_x_scale_container_state-_state_translate , 0.0f, _z_counter);
glScalef( _state_scale*(_render_width/_state_x_max), _render_height/_state_y_max, 0.0f);
if (glIsList(_list_counters)==GL_FALSE)
message << "ERROR LIST not exist for counters." << ende;
else
glCallList(_list_counters);
if (glIsList(_list_counters)==GL_FALSE)
;// message << "ERROR LIST not exist for counters." << ende;
else
glCallList(_list_counters);
glPopMatrix();
draw_stored_arrows(_arrows);/* draw arrows without display lists */
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 */
}
glPopMatrix();
break;
default:
......
......@@ -268,6 +268,11 @@ class Render_area : public QGLWidget, public Render
*/
Element_pos _z_arrow;
/*!
* z position for counters.
*/
Element_pos _z_counter;
/***********************************
* Trace Drawing functions and attributes.
......@@ -770,7 +775,7 @@ inline void Render_area::draw_counter(const Element_pos x, const Element_pos y){
static bool line_already_begun = false;
if (x <= 0.0f ){
if (x <= 0.0 ){
if (line_already_begun==true){/* it is not the first call */
glEnd();
......@@ -778,9 +783,9 @@ inline void Render_area::draw_counter(const Element_pos x, const Element_pos y){
line_already_begun = true;
glBegin(GL_LINE_STRIP);/* set of connected verteces */
glColor3d(1.0, 1.0, 1.0);glVertex2d(0.0f, y);/* draw the init point */
glColor3d(1.0, 1.0, 1.0);glVertex2d(0.0, y);/* draw the init point */
_counter_last_x = 0.0f;
_counter_last_x = 0.0;
}else{
......
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