Commit 66e8e2b8 authored by Olivier Lagrasse's avatar Olivier Lagrasse

affichage message et evenements dans render area

parent dc25fad0
src/interface/img/logo.png

11 KB | W: | H:

src/interface/img/logo.png

22.8 KB | W: | H:

src/interface/img/logo.png
src/interface/img/logo.png
src/interface/img/logo.png
src/interface/img/logo.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -319,7 +319,7 @@ void Interface_graphic::on_about_triggered(){
"It is licensed under <i>CECILL-A</i>."));*/
QMessageBox::about(_ui_main_window, tr("About ViTE"),
tr("<b>ViTE</b> version 0.1"));
tr("<b>ViTE</b> version 0.2"));
}
......
......@@ -10,6 +10,7 @@
using namespace std;
using namespace message_ns;
#define message message_ns::message << "(" << __FILE__ << " l." << __LINE__ << "): "
/***********************************
......@@ -81,7 +82,7 @@ Render_area::~Render_area(){
void Render_area::initializeGL(){
glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
glClearColor(0.5f, 0.5f, 0.55f, 1.0f);
glEnable(GL_DEPTH_TEST);
......@@ -124,8 +125,6 @@ void Render_area::paintGL(){
string buf_txt;
int j=0.6;
resizeGL(width(), height());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
......@@ -140,9 +139,11 @@ void Render_area::paintGL(){
/* turn around y axis */
_wait_angle+=0.1f;
if (_wait_angle>=360) _wait_angle=0.0f;
glPushMatrix();
glScalef(15, 15, 0);
glRotatef(-_wait_angle,0, 1, 0);
glCallList(_wait_list);
......@@ -154,9 +155,7 @@ void Render_area::paintGL(){
case DRAWING_STATE_DRAWING:/* A trace is drawn */
if (glIsList(_list_states)==GL_FALSE)
message << "ERROR LIST not exist for states." << ende;
glMatrixMode(GL_MODELVIEW);
......@@ -175,19 +174,11 @@ void Render_area::paintGL(){
cerr << "Default container position (before translation and scaling) : (x_max = " << _container_x_max << ", y_max = " << _container_y_max << ")" << endl << endl;
#endif
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(0, 0, j);glVertex2d(0, 10);
glColor3d(0, 0, j-0.1);glVertex2d(0, 5);
glColor3d(0, 0, j-0.1);glVertex2d(-5, 5);
glColor3d(0, 0, j);glVertex2d(-5, 10);
}
glEnd();
glCallList(_list_containers);
if (glIsList(_list_containers)==GL_FALSE)
message << "ERROR LIST not exist for containers." << ende;
else
glCallList(_list_containers);
glPopMatrix();
......@@ -230,9 +221,10 @@ void Render_area::paintGL(){
glTranslated(20.0f-_state_translate, 40.0f, -2.0f);
glScalef(_state_scale, 50.0f/_container_y_max, 0.0f);
glCallList(_list_states);
if (glIsList(_list_states)==GL_FALSE)
message << "ERROR LIST not exist for states." << ende;
else
glCallList(_list_states);
glPopMatrix();
......@@ -307,6 +299,7 @@ bool Render_area::build(){
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
return true;
}
......
......@@ -15,7 +15,7 @@ typedef double Level;
#include <QGLWidget>/* for the OpenGL Widget */
//#include "interface_graphic.hpp"
#include "render.hpp"
#include "resource.hpp"
......@@ -24,7 +24,7 @@ typedef double Level;
/*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
*/
class Render_area : public QGLWidget
class Render_area : public QGLWidget, public Render
{
Q_OBJECT
......@@ -107,10 +107,6 @@ class Render_area : public QGLWidget
*/
void paintGL();
// void paintEvent(QPaintEvent *event);
/***********************************
*
* The wait screen drawing.
......@@ -285,6 +281,8 @@ class Render_area : public QGLWidget
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_event(const Element_pos time, const Element_pos height, const Element_pos container_height);
void end_draw();
};
......@@ -339,11 +337,11 @@ inline void Render_area::draw_container(const Element_pos x, const Element_pos y
}
glEnd();
if (x>_container_x_max)
_container_x_max = x;
if ((x+w)>_container_x_max)
_container_x_max = x+w;
if (y>_container_y_max)
_container_y_max = y;
if ((y+h)>_container_y_max)
_container_y_max = y+h;
}
......@@ -382,8 +380,8 @@ inline void Render_area::draw_state(const Element_pos start, const Element_pos e
#ifdef DEBUG_MODE_RENDER_AREA
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
cerr << "States position (for drawing): (x = " << start << ", y = " << base << ", w = " << end-start << ", h = " << height << ") -> level:" << level << endl << endl;
std::cerr << __FILE__ << " l." << __LINE__ << ":" << std::endl;
std::cerr << "States position (for drawing): (x = " << start << ", y = " << base << ", w = " << end-start << ", h = " << height << ")" << std::endl << std::endl;
#endif
......@@ -410,6 +408,10 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
glPushMatrix();
glTranslated(end_time, end_height, _z_arrow);
glScalef(2, 2, 0);/* should be set */
if (start_time != end_time){
......@@ -418,30 +420,82 @@ inline void Render_area::draw_arrow(const Element_pos start_time, const Element_
glRotatef(angle,0, 0, 1);
}/* end if (start_time != end_time) */
glTranslated(end_time, end_height, _z_arrow);
else
glRotatef(90,0, 0, 1);/* vertical alignment */
glBegin(GL_TRIANGLES);/* create an arrow */
{
glColor3d(1.0, 1.0, 1.0);glVertex2d(0.0, 0.5);
glColor3d(0.9, 0.9, 0.9);glVertex2d(0.5, -0.5);
glColor3d(0.9, 0.9, 0.9);glVertex2d(-0.5, -0.5);
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();
glPushMatrix();
glBegin(GL_LINE);
glTranslated(0, 0, _z_arrow);
glLineWidth(2.5f);
glBegin(GL_LINES);
{
glColor3d(1.0, 1.0, 1.0);glVertex3d(start_time, start_height, _z_arrow);
glColor3d(0.9, 0.9, 0.9);glVertex3d(end_time, end_height, _z_arrow);
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);
}
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){
Element_pos radius;/* the circle radius */
Element_pos angle;
Element_pos delta_angle;
int step;
/* IMPROVEMENT: put the circle into a display list */
/* draw a circle */
radius = (container_height - height)/2.0f;
angle = PI/2.0f;
step = 20;/* 20 polygons for the circle */
if (step!=0)
delta_angle = 2*PI/step;
glColor3d(0.5, 0.8, 0.5);
glBegin(GL_POLYGON);
{
for(int i =0 ; i<step ; i++){
glVertex3d(time + cos(angle+delta_angle*i)*radius , height + sin(angle+delta_angle*i)*radius , _z_arrow);
}
}
glEnd();
/* draw line */
glLineWidth(2.5f);
glBegin(GL_LINES);
{
glColor3d(0.5, 0.8, 0.5);glVertex3d(time, height, _z_arrow);
glColor3d(0.4, 0.7, 0.4);glVertex3d(time, height+container_height, _z_arrow);
}
glEnd();
glLineWidth(1.0f);
}
inline void Render_area::end_draw(){
}
......
This diff is collapsed.
######################################################################
# Automatically generated by qmake (2.01a) Mon Feb 23 22:24:45 2009
######################################################################
TEMPLATE = app
TARGET = test
OBJECTS_DIR=../../bin
DESTDIR=../../bin
CONFIG+=uitools debug
QT+=opengl
LIBS += -lglut
DEPENDPATH += .
INCLUDEPATH += . \
../../bin
# Input
HEADERS += resource_test.hpp \
test_area.hpp \
../../src/interface/render_area.hpp \
../../src/interface/resource.hpp \
../../main_resource.hpp \
../../src/interface/interface.hpp \
../../src/message/enderror.hpp \
../../src/message/endwarning.hpp \
../../src/message/endinformation.hpp \
../../src/message/message.hpp \
../../src/message/message_ns.hpp
SOURCES += test_area.cpp \
../../src/interface/render_area.cpp \
../../src/message/enderror.cpp \
../../src/message/endwarning.cpp \
../../src/message/endinformation.cpp \
../../src/message/message.cpp \
../../src/message/message_ns.cpp
######################################################################
# Automatically generated by qmake (2.01a) Mon Feb 23 22:24:45 2009
######################################################################
TEMPLATE = app
TARGET = test
CONFIG+=uitools debug
QT+=opengl
LIBS += -lglut
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += resource_test.hpp \
test_area.hpp \
../src/render_area.hpp \
../src/resource.hpp \
../../main_resource.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Value.hpp \
../../trace/src/values/Date.hpp \
../../trace/src/values/String.hpp \
../../trace/src/values/Name.hpp \
../../trace/src/values/Integer.hpp \
../../trace/src/values/Hex.hpp \
../../trace/src/values/Double.hpp \
../../trace/src/values/Color.hpp \
../../trace/src/ContainerType.hpp \
../../trace/src/Container.hpp \
../../trace/src/State.hpp \
../../trace/src/Entity.hpp \
../../trace/src/StateType.hpp \
../../trace/src/EntityType.hpp \
../../trace/src/EntityValue.hpp \
../../trace/src/EntityList.hpp \
../../trace/src/DrawTrace.hpp \
../../parser/src/ParserPaje.hpp \
../../parser/src/ParserDefinitionDecoder.hpp \
../../parser/src/Definition.hpp \
../../parser/src/Line.hpp \
../../parser/src/TokenSource.hpp \
../../parser/src/ParserEventDecoder.hpp \
../../trace/src/values/Values.hpp \
../../parser/src/Parser.hpp \
../src/interface.hpp \
../src/interface_console.hpp \
../src/interface_graphic.hpp
SOURCES += test_area.cpp \
../src/render_area.cpp \
../../trace/src/Trace.cpp \
../../trace/src/values/Date.cpp \
../../trace/src/values/String.cpp \
../../trace/src/values/Name.cpp \
../../trace/src/values/Integer.cpp \
../../trace/src/values/Hex.cpp \
../../trace/src/values/Double.cpp \
../../trace/src/values/Color.cpp \
../../trace/src/ContainerType.cpp \
../../trace/src/Container.cpp \
../../trace/src/State.cpp \
../../trace/src/Entity.cpp \
../../trace/src/StateType.cpp \
../../trace/src/EntityType.cpp \
../../trace/src/EntityValue.cpp \
../../trace/src/EntityList.cpp \
../../parser/src/ParserPaje.cpp \
../../parser/src/ParserDefinitionDecoder.cpp \
../../parser/src/Definition.cpp \
../../parser/src/Line.cpp \
../../parser/src/TokenSource.cpp \
../../parser/src/ParserEventDecoder.cpp \
../src/interface_console.cpp \
../src/interface_graphic.cpp
......@@ -9,23 +9,79 @@
using namespace std;
class Interface_ : public Interface{
public:
void error(string s) const{
cerr << s << endl;
}
void warning(string s) const{
cerr << s << endl;
}
void information(string s) const{
cerr << s << endl;
}
};
int main(int argc, char** argv){
glutInit(&argc, argv);
QApplication app(argc, argv);
Interface_ i;
Message::set_interface_instance(&i);
// Interface_graphic* g = new Interface_graphic();
QWidget t;
t.show();
t.setGeometry(0, 0, 800, 600);
Render_area r(&t);
r.show();
r.setGeometry(0, 0, 800, 600);
cerr << "Test_trace t:" << endl;
// r.build();
// r.show();
t.show();
Element_pos a = 50;
r.draw_container_text(a, a," a, a");
r.start_draw();
{
r.start_draw_containers();
{
r.draw_container(0, 0, 30, 20);
r.draw_container(0, 22, 30, 20);
// r.draw_container(1, 60, 60, 20);
r.draw_container_text(0, 10,"Container 2");
r.draw_container_text(0, 32,"Container 1");
}
r.end_draw_containers();
r.start_draw_states();
{
r.draw_state(0, 4, 0, 20, 0.6, 0.7, 0.8);
r.draw_state(4.5, 7.98, 0, 20, 0.6, 0.7, 0.8);
r.draw_arrow(10, 10, 0, 3);
r.draw_arrow(10, -10, -15, -3);
r.draw_arrow(-150, 150, -10, 30);
r.draw_event(14, 4, 2);
r.draw_event(10, 4, 1);
r.draw_event(18, 4, 3);
r.draw_event(10, 4, 10);
}
r.end_draw_states();
}
r.end_draw();
;
r.build();
return app.exec();
}
......
......@@ -8,7 +8,7 @@
#define TEST_AREA_HPP
#include "resource_test.hpp"
#include "../src/render_area.hpp"
#include "../../src/interface/render_area.hpp"
#endif
......
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