diff --git a/interface/Makefile b/interface/Makefile index 9f73d2606ab02b870b98df090771a3ab9e07e863..02dab707438194df22d57290b4ed034e8f4aefc1 100644 --- a/interface/Makefile +++ b/interface/Makefile @@ -13,7 +13,8 @@ all: - cd ./src && qmake-qt4 && make all +# cd ./src && qmake-qt4 && make all + cd ./src && make all @echo " " @echo "Compilation completed! (release)" @echo " " @@ -65,7 +66,7 @@ clean: # Must be called with option -i, otherwise an error occured in the first instructions, the followings won't be executed. wash: - cd ./src && rm *~ *.o Makefile qrc_vite.cpp core + cd ./src && rm *~ *.o qrc_vite.cpp core cd ./tests && rm *~ *.o *pro Makefile core cd ./bin && rm *.o cd ./debug && rm * diff --git a/interface/src/render_area.cpp b/interface/src/render_area.cpp index 23a5c5b7c296a3e4d4f5a5434b4269716c1516cb..754f5e10571c9e8b9a187b3365cce8f743a39968 100644 --- a/interface/src/render_area.cpp +++ b/interface/src/render_area.cpp @@ -6,6 +6,8 @@ #include "render_area.hpp" + + using namespace std; @@ -65,6 +67,8 @@ Render_area::Render_area(QWidget *parent) list_states = 0; setAutoFillBackground(false); + + } @@ -98,6 +102,9 @@ void Render_area::initializeGL(){ glClearColor(0.3f, 0.3f, 0.3f, 1.0f); glEnable(GL_DEPTH_TEST); + + glClearStencil(0); + _wait_list = draw_wait(); } @@ -110,13 +117,26 @@ void Render_area::resizeGL(int width, int height){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); - - glOrtho(0, 100, 0, 100, 0, 1000); + + + switch(_state){ + + case DRAWING_STATE_WAINTING:// A wait is drawn + glOrtho(-50, 50, -50, 50, 0, 1000); + break; + case DRAWING_STATE_DRAWING:// A trace is drawn + glOrtho(0, 100, 0, 100, 0, 1000); + break; + default: + _parent->error("Undefined value for the drawing state attribute - Render area"); + } + + glMatrixMode(GL_MODELVIEW); } -void Render_area::paintEvent(QPaintEvent *event){ +void Render_area::paintGL(){ resizeGL(width(), height()); @@ -131,34 +151,39 @@ void Render_area::paintEvent(QPaintEvent *event){ case DRAWING_STATE_WAINTING:/* A wait is drawn */ /* turn around y axis */ - // _wait_angle+=0.1f; - //if (_wait_angle>=360) _wait_angle=0.0f; - // glRotatef(-_wait_angle,0, 1, 0); - - + _wait_angle+=0.1f; + if (_wait_angle>=360) _wait_angle=0.0f; + + glPushMatrix(); - glTranslatef(50, 50, 0); - glScalef(20, 20, 0); + // glTranslatef(50, 50, 0); + glScalef(15, 15, 0); + glRotatef(-_wait_angle,0, 1, 0); + glCallList(_wait_list); + glPopMatrix(); break; case DRAWING_STATE_DRAWING:/* A trace is drawn */ - if (glIsList(list_states)==GL_FALSE) _parent->error("ERROR LIST not exist for states."); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); - glTranslatef(0, 25, 0); + glTranslatef(0, 25, -1); glScalef(10/_container_x_max, 50.0/_container_y_max, 0); + glCallList(list_containers); glPopMatrix(); @@ -170,6 +195,8 @@ void Render_area::paintEvent(QPaintEvent *event){ // glTranslatef(-_state_x_max, 100-_state_y_max, 0); // glScalef(100/(_state_x_max-_state_x_min), 100/(_state_y_max-_state_y_min), 0); // glScalef(10, 10, 0); + //glOrtho(0, 0, 20, 100, 0, 1000); + glTranslated(20, 20, 0); glCallList(list_states); @@ -193,11 +220,15 @@ void Render_area::paintEvent(QPaintEvent *event){ + + if (_state== DRAWING_STATE_DRAWING){ + + /* QPainter painter(this); QFont textFont("Helvetica [Cronyx]", 2, QFont::Bold);; - + */ list<Element_pos>::iterator it_pos; list<string>::iterator it_txt; Element_pos buf_rot; @@ -205,7 +236,7 @@ void Render_area::paintEvent(QPaintEvent *event){ Element_pos buf_y; string buf_txt; - + /* painter.setPen(Qt::SolidLine); painter.setBrush(Qt::white); @@ -214,7 +245,7 @@ void Render_area::paintEvent(QPaintEvent *event){ painter.scale(10/_container_x_max, 50.0/_container_y_max); - + */ for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end(); it_txt++, it_pos++ ){ @@ -241,7 +272,26 @@ void Render_area::paintEvent(QPaintEvent *event){ //else{ // painter.rotate(0); // painter.translate(0, -(buf_rot*height()/200) ); - painter.drawText( (buf_x*width()/100)-10 , 25+(buf_y*height()/100) , buf_txt.c_str()); + + + glPushMatrix(); + + glTranslatef(0, 25, 0); + glScalef(10/_container_x_max, 50.0/_container_y_max, 0); + + + glColor3d(1, 1, 1); + // glRotatef(90,0, 1, 0); + glRasterPos2f(buf_x,buf_y); + + for(int i=0;i<buf_txt.length();i++) + { + glutBitmapCharacter(GLUT_BITMAP_8_BY_13, buf_txt.c_str()[i]); + } + + glPopMatrix(); + + /****** painter.drawText( (buf_x*width()/100)-10 , 25+(buf_y*height()/100) , buf_txt.c_str()); ******/ //painter.drawText( (buf_x*width()/100) -10, 25+(buf_y*height()/100) -10 , buf_txt.c_str()); // } @@ -250,7 +300,7 @@ void Render_area::paintEvent(QPaintEvent *event){ }/* end for(...) */ - painter.end(); + // painter.end(); }/* end if (_state== DRAWING_STATE_DRAWING) */ } @@ -588,7 +638,7 @@ GLuint Render_area::draw_trace(){//Trace trace) _text_pos.push_back(x); _text_pos.push_back(y); _text_value.push_back(container->get_name().to_string()); - + x -= (_container_height + _container_h_space); diff --git a/interface/src/render_area.hpp b/interface/src/render_area.hpp index a1228c8bdeaa16791a61d9be6abc54d3bd2a404e..8966692948849e0666abfe45f284575ada3f3b93 100644 --- a/interface/src/render_area.hpp +++ b/interface/src/render_area.hpp @@ -109,11 +109,11 @@ class Render_area : public QGLWidget /*! * \brief Call by the system each time the render area need to be updated. - */ - // void paintGL(); + */ + void paintGL(); - void paintEvent(QPaintEvent *event); + // void paintEvent(QPaintEvent *event); /*********************************** diff --git a/main.cpp b/main.cpp index 2b54d7e961a68b3d3f814db0326418736345642a..b85b5e7994933e10b639807662de967c9cfa039f 100644 --- a/main.cpp +++ b/main.cpp @@ -17,6 +17,7 @@ { QApplication app(argc, argv); + glutInit(&argc, argv); Interface_console console(argc, argv); diff --git a/main_resource.hpp b/main_resource.hpp index b3ca49049a268f565d0136a405c572d5ce5fb2c0..246686e5c2031c8e41a124f4b7a19cfb343653bb 100644 --- a/main_resource.hpp +++ b/main_resource.hpp @@ -26,6 +26,10 @@ #include <stack> #include <list> +/* For OpenGL text rendering */ +#include <GL/glut.h> + + /* These paths corresponding to the path in the resource file ('vite.qrc' in the 'bin' folder) */ #define UI_MAIN_WINDOW_NAME ":/window/main_window.ui"/* The main window ui file. */ #define UI_INFO_WINDOW_NAME ":/window/info_window.ui"/* The info window ui file. */