Commit 721e9f11 authored by Olivier Lagrasse's avatar Olivier Lagrasse

commit pour debuggage

parent ca96b837
......@@ -18,9 +18,9 @@ DIR_TRACE = trace/src
all:
@(cd $(DIR_TRACE) && make)
@(cd $(DIR_INTERFACE) && make)
@(cd $(DIR_PARSER) && make)
@(cd $(DIR_TRACE) && make)
@echo " "
@echo "Compilation completed! File created in 'bin' folder."
@echo " "
......
......@@ -21,6 +21,7 @@ using namespace std;
Render_area::Render_area(QWidget *parent)
: QGLWidget(parent){
_parent = (Interface_graphic*)parent;
if (_parent==NULL){
......@@ -328,14 +329,18 @@ GLuint Render_area::draw_wait() {
GLuint Render_area::draw_trace(){//Trace trace)
GLuint object;
GLuint list_containers;
GLuint list_states;
stack<EntityList> stack_states;
list_containers = glGenLists(1);/* create the list */
if (list_containers==0){
object = glGenLists(1);/* create the list */
if (object == 0){
_parent->warning("Error when creating list");
}
glNewList(object, GL_COMPILE);/* open the list */
glNewList(list_containers, GL_COMPILE);/* open the list */
{
/*** Drawing containers ***/
......@@ -348,25 +353,25 @@ GLuint Render_area::draw_trace(){//Trace trace)
stack<Element_count> position_stack;
stack<Element_pos> height_stack;
Element_pos x;
Element_pos y;
Element_pos y_buf;/* buffer for the y position */
Element_pos height_buf;/* buffer for the container height */
Container* container;
list<Container *> trace_container;
const Container* container;
const list<Container *> *trace_container = _trace->get_root_containers();
list<Container *>::iterator it;
bool isAnotherContainer = true;/* use to stop the loop */
trace_container = _trace->get_root_containers();
position_stack.push(0);
height_stack.push(0);
container = get_container(trace_container, 0);
if (container->get_children().size() <= 1)
if (number_of_children(container) <= 1)
x = _container_width;
else
x = _container_height;
......@@ -388,12 +393,8 @@ GLuint Render_area::draw_trace(){//Trace trace)
position_stack.top() ++;/* add a child */
position_stack.push(0);/* prepare for the next child */
cerr << endl << "EXPLORER "; container->disp();
container = get_container(container->get_children(), buf_pos);
cerr << "EXPLORE NEW CHILD ";container->disp();
if (1 >= number_of_children(container))/* Check the child count of the child container */
x += _container_width+_container_h_space;/* if there is just one child, container can be draw horizontally */
else
......@@ -410,14 +411,13 @@ GLuint Render_area::draw_trace(){//Trace trace)
y_buf = _container_height+_container_v_space;
height_stack.push(y_buf);
y += y_buf;
/* Then, we store the list of entity */
stack_states.push(container->get_states());
}
draw_container(x, y, _container_width, _container_height);
cerr << "DRAW HORIZ " << x << " " << y <<" : "<<_container_width << " " << _container_height;
container->disp();
x -= (_container_width + _container_h_space);
}
......@@ -425,20 +425,19 @@ GLuint Render_area::draw_trace(){//Trace trace)
height_buf = 0;
for (unsigned int i = 0 ; i < number_of_children(container) ; i ++){
for (int i = 0 ; i < number_of_children(container) ; i ++){
height_buf += height_stack.top();
height_stack.pop();
}
height_stack.push(height_buf);/* push the sum of child heights */
height_buf -= _container_v_space;
draw_container(x, y, _container_height, height_buf);/* Vertically, it is drawn as higher as it has children */
cerr << "DRAW VERT " << x << " " << y <<" : "<<_container_height << " " << height_buf;
container->disp();
x -= (_container_height + _container_h_space);
......@@ -453,13 +452,13 @@ GLuint Render_area::draw_trace(){//Trace trace)
position_stack.pop();
if (container->get_parent()->get_parent() != NULL){
cerr << "REACH HIS FATHER ";container->disp();
container = get_container( container->get_parent()->get_parent()->get_children(), position_stack.top()-1);/* '-1' because we continu with the same container, not the following */
cerr << "IS -> ";container->disp();
}
else{
cerr << "REACH ROOT ";container->disp();
container = container->get_parent();//get_container(_trace->get_root_containers(), 0);
}
position_stack.push(buf);
......@@ -475,18 +474,59 @@ GLuint Render_area::draw_trace(){//Trace trace)
}
glEndList();/* close the list */
glNewList(list_states, GL_COMPILE);/* open the list */
{
EntityList buf_list;
State* buf_entity;
Element_count i;/* for the level (y axis) of the states */
while (stack_states.empty()==false){
for ( buf_list = stack_states.top(), i=0 ; buf_list.has_next()==true ; buf_list.next(), i++ ) {
buf_entity = (State*)buf_list.get_current_entity();
draw_state(buf_entity->get_start_time().get_value(), buf_entity->get_end_time().get_value(), i, 1.0, 1.0, 0.0);
}
stack_states.pop();
}
}
glEndList();/* close the list */
/* The two lists are merged */
glNewList(object, GL_COMPILE);/* open the list */
{
glCallList(list_containers);
glCallList(list_states);
}
glEndList();/* close the list */
return object;
}
inline Element_count Render_area::number_of_children(Container* c) {
return c->get_children().size();
}
inline Element_count Render_area::number_of_children(const Container* c){
return c->get_children()->size();
}
inline Element_count Render_area::return_last_visited_child(stack<Element_count> &s) {
if (s.empty() == true){
inline Element_count Render_area::return_last_visited_child(stack<Element_count> const &s){
if (s.empty()==true){
_parent->error("The render area position stack is empty.");
return -1;
}
......@@ -495,16 +535,18 @@ inline Element_count Render_area::return_last_visited_child(stack<Element_count>
}
Container* Render_area::get_container(list <Container*> list_container, int pos) const {
list<Container *>::iterator it;
int i=0;
Container* Render_area::get_container(const list <Container*>* list_container, const int pos) const{
list<Container *>::const_iterator it;
int i=0;
for (it = list_container.begin() ; i < pos ; it++, i++ ){ }
for (it=list_container->begin() ; i<pos; it++, i++ ){ }
return *it;
}
void Render_area::draw_container(Element_pos x, Element_pos y, Element_pos w, Element_pos h) const {
void Render_area::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) const{
static float j=0.1;
glPushMatrix();
......@@ -527,10 +569,24 @@ void Render_area::draw_container(Element_pos x, Element_pos y, Element_pos w, El
}
void Render_area::draw_state(const Date start, const Date end, const Level level) const{
void Render_area::draw_state(const Element_pos start, const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b) const{
glPushMatrix();
glTranslatef(20, 40, 0);
glScalef(20, 20, 20);
Element_pos base = level*(_state_height+_state_v_space);
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(r, g, b);glVertex2d(start, base);
glColor3d(r, g, b);glVertex2d(start, base + _state_height);
glColor3d(r, g, b);glVertex2d(start+end, base + _state_height);
glColor3d(r, g, b);glVertex2d(start+end, base);
}
glEnd();
glPopMatrix();
}
......@@ -8,12 +8,12 @@
typedef long Element_count ;
typedef double Element_pos;
typedef double Element_col;
class Render_area;
typedef double Level;
typedef double Date;
#include "resource.hpp"
......@@ -197,13 +197,38 @@ class Render_area : public QGLWidget
*/
static const float DRAWING_CONTAINER_V_SPACE_DEFAULT = 0.2f;
/*!
* \brief The default height for states.
*/
static const float DRAWING_STATE_HEIGHT_DEFAULT = 1.0f;
/*!
* \brief The default width for states.
*/
static const float DRAWING_STATE_WIDTH_DEFAULT = 2.0f;
/*!
* \brief The default horizontal space between states.
*/
static const float DRAWING_STATE_H_SPACE_DEFAULT = 0.2f;
/*!
* \brief The default vertical space between states.
*/
static const float DRAWING_STATE_V_SPACE_DEFAULT = 0.2f;
/*!
* \brief Geometrical informations about the trace shape.
*/
double _container_width;
double _container_height;
double _container_h_space;
double _container_v_space;
double _container_v_space;
double _state_width;
double _state_height;
double _state_h_space;
double _state_v_space;
/***********************************
......@@ -217,16 +242,16 @@ class Render_area : public QGLWidget
GLuint draw_trace();
inline Element_count number_of_children(Container* c);
inline Element_count number_of_children(const Container* c);
inline Element_count return_last_visited_child(std::stack<Element_count> &s);
inline Element_count return_last_visited_child(std::stack<Element_count> const &s);
/*!
* \brief Return the pos container of the list
*/
Container* get_container(std::list <Container*> list_container, int pos) const;
Container* get_container(const std::list <Container*> *list_container, const int pos) const;
/*!
......@@ -236,15 +261,18 @@ class Render_area : public QGLWidget
* \param w the width of the container
* \param h the height of the container
*/
void draw_container(Element_pos x, Element_pos y, Element_pos w, Element_pos h) const;
void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) const;
/*!
* \brief Draw a state of the trace.
* \param r the red color rate of the state.
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
* \param start the beginning time of the state.
* \param end the ending time of the state.
* \param level refer to the container which state belongs to.
*/
void draw_state(const Date start, const Date end, const Level level) const;
void draw_state(const Element_pos start , const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b) const;
......
......@@ -60,9 +60,14 @@ class Render_area;
class Trace;
class Container;
class EntityList;
class State;
#include "interface/tests/test_trace.hpp"
//include "interface/tests/test_trace.hpp"
#include "trace/src/Trace.hpp"
#include "interface/src/interface.hpp"
#include "interface/src/interface_console.hpp"
......@@ -84,8 +89,9 @@ class Container;
class Container;
#include "trace/src/Trace.hpp"
#include "trace/src/Container.hpp"
*/
......
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