Commit 0b65046c authored by Olivier Lagrasse's avatar Olivier Lagrasse

Ajout texte sous OpenGL et plus sous Qt -> modification Makefile de...

Ajout texte sous OpenGL et plus sous Qt -> modification Makefile de l'interface pour integration -libglut + rotation du lapin
parent 09f680e4
......@@ -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 *
......@@ -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);
......
......@@ -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);
/***********************************
......
......@@ -17,6 +17,7 @@
{
QApplication app(argc, argv);
glutInit(&argc, argv);
Interface_console console(argc, argv);
......
......@@ -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. */
......
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