Commit 7a159b0a authored by Olivier Lagrasse's avatar Olivier Lagrasse

Reorganisation du code de l'interface (remontee des appels a la trace ou au...

Reorganisation du code de l'interface (remontee des appels a la trace ou au parser dans l'interface console) - reorganisation des includes de l'interface - ajout fonction de dessin des liens - code pour la gestion des messages (non operationnel)
parent dad0285d
......@@ -4,7 +4,7 @@
# * \brief Makefile for the ViTE interface. Commands are : \
# * make all : compiles the released version.
# * make debugs : compiles with debug informations.
# * make tests : compiles the tests.
# * make mtest : compiles the tests.
# * make clean : deletes generated files.
# */
#
......@@ -50,8 +50,8 @@ plugins:
#@echo " "
tests:
cd ./tests && make all
mtest:
cd ./test && qmake-qt4 && make all
@echo " "
@echo "Compilation completed! (test)"
@echo " "
......
......@@ -45,6 +45,9 @@ Interface_console::Interface_console(int argc, char ** argv){
state = get_state(argc, argv);
launch_action(state);
}
......@@ -68,6 +71,22 @@ Interface_console::~Interface_console(){
**********************************/
bool Interface_console::draw_trace(const string & filename, Render_area* render_area){
Trace trace;
ParserPaje parser;
DrawTrace<Render_area> drawing;
parser.parse(filename, trace);
drawing.build(render_area, &trace);
return true;
}
int Interface_console::run(){
return app->exec();
......@@ -183,6 +202,7 @@ void Interface_console::extract_times(const char *name){
void Interface_console::launch_action(int state){
switch(state) {
case _STATE_DISPLAY_HELP :
......@@ -191,12 +211,13 @@ void Interface_console::launch_action(int state){
break;
case _STATE_LAUNCH_GRAPHICAL_INTERFACE :
_main_window = new Interface_graphic();/* launch the window interface */
break;
_main_window = new Interface_graphic(this);/* launch the window interface */
break;
case _STATE_OPEN_FILE:
information(string("Opening the file: ")+string(_file_opened));
_main_window = new Interface_graphic(_file_opened);/* launch the window interface and open a file */
_main_window = new Interface_graphic(this, _file_opened);/* launch the window interface and open a file */
break;
......@@ -263,7 +284,7 @@ void Interface_console::display_help(){
<< "(-f) [file path] : open the trace file and display it." << endl
<< "-a [file path] : open the trace file and display all of it." << endl
<< "[file path] -t ([time_init]):([time_end]) : open the trace file and display it in the interval. There could be no time_init or time_end."
<< " In these cases, we print the trace from the start and/or to the end." << endl
<< " In these cases, the trace will be printed from the start and/or to the end." << endl
<< "-f [path-source] -e [path-dest] : export the trace file in the svg format." << endl
<< "-f [path-source] -e [path-dest] -t ([time_init]):([time_end]) : export the trace file in the svg format in the interval given." << endl << endl;
}
......
......@@ -8,9 +8,17 @@
class Interface_console;
#include "resource.hpp"
#include <QApplication>
#include "interface.hpp"
#include "interface_graphic.hpp"
#include "render_area.hpp"
#include "../../trace/src/Trace.hpp"
#include "../../trace/src/DrawTrace.hpp"
#include "../../parser/src/ParserPaje.hpp"
#include "resource.hpp"
......@@ -36,6 +44,8 @@ protected:
*/
Interface_graphic* _main_window;
Render_area* _render_opengl;
QApplication* app;
......@@ -171,6 +181,13 @@ protected:
*
**********************************/
/*!
* \brief This function launch trace drawing.
* \param filename Path of the trace file.
*/
bool draw_trace(const std::string & filename, Render_area* render_area);
/*!
* \brief This function launch Qt event loop.
*/
......
......@@ -20,17 +20,18 @@ using namespace std;
**********************************/
Interface_graphic::Interface_graphic(QWidget *parent):QWidget(parent){
Interface_graphic::Interface_graphic(Interface_console* core, QWidget *parent):QWidget(parent){
_core = core;
_is_rendering_trace = false;
load_windows();
}
Interface_graphic::Interface_graphic(const string file_path, QWidget *parent):QWidget(parent){
Interface_graphic::Interface_graphic(Interface_console* core, const string file_path, QWidget *parent):QWidget(parent){
_core = core;
_is_rendering_trace = false;
load_windows();
......@@ -148,19 +149,13 @@ void Interface_graphic::information(const string s) const{
**********************************/
void Interface_graphic::opening_file(string const &path){
Trace trace;
ParserPaje parser;
information(string("File opened: ")+ path);
parser.parse(path, trace);
if (build(&trace)==false)
error("Open file : an error occured with wait screen releasing.");
_core->draw_trace(path, _ui_render_area);
_ui_render_area->build();
_is_rendering_trace = true;
......@@ -182,9 +177,9 @@ void Interface_graphic::opening_file(string const &path){
**********************************/
bool Interface_graphic::build(Trace* trace){
return _ui_render_area->build(trace);
}
/*bool Interface_graphic::build(Trace* trace){
return _ui_render_area->build();
}*/
......
......@@ -9,6 +9,13 @@
class Interface_graphic;
#include <QtGui>
#include <QtUiTools>/* for the run-time loading .ui file */
#include "interface.hpp"
#include "interface_console.hpp"
#include "render_area.hpp"
#include "resource.hpp"
......@@ -65,6 +72,7 @@ class Interface_graphic : public QWidget, public Interface{
QVBoxLayout* _ui_render_area_layout;
Interface_console* _core;
/***********************************
*
......@@ -134,14 +142,14 @@ public:
* \brief The default constructor
* \arg parent: the parent widget of the graphical interface. Should be ignored.
*/
Interface_graphic(QWidget *parent = 0);
Interface_graphic(Interface_console* core, QWidget *parent = 0);
/*!
* \brief The constructor which open a file
* \arg file_path: the file which be parsed then displayed.
* \arg parent: the parent widget of the graphical interface. Should be ignored.
*/
Interface_graphic(std::string file_path, QWidget *parent = 0);
Interface_graphic(Interface_console* core, std::string file_path, QWidget *parent = 0);
/*!
......@@ -205,7 +213,7 @@ public:
* \brief This function will build the trace sent by the data structure ('_trace').
* \arg trace The trace which be displayed.
*/
bool build(Trace* trace);
// bool build(Trace* trace);
......
......@@ -42,15 +42,8 @@ Render_area::Render_area(QWidget *parent)
/* init the trace drawing */
_drawing_list=0;
_container_width = DRAWING_CONTAINER_WIDTH_DEFAULT;
_container_height = DRAWING_CONTAINER_HEIGHT_DEFAULT;
_container_h_space = DRAWING_CONTAINER_H_SPACE_DEFAULT;
_container_v_space = DRAWING_CONTAINER_V_SPACE_DEFAULT;
_state_height = DRAWING_STATE_HEIGHT_DEFAULT;
_state_v_space = DRAWING_STATE_V_SPACE_DEFAULT;
_trace = NULL;
_container_x_max = 0;
_container_y_max = 0;
......@@ -63,6 +56,8 @@ Render_area::Render_area(QWidget *parent)
_state_translate = 0;/* temporary, for states translation */
_container_view_size = 50;/* temporary, for container view */
_z_arrow = 1;/* closer to camera than containers or states */
setAutoFillBackground(false);
......@@ -201,7 +196,7 @@ void Render_area::paintGL(){
glColor3d(0, 0, j-0.1);glVertex2d(-5, 5);
glColor3d(0, 0, j);glVertex2d(-5, 10);
}
glEnd();
glEnd();
......@@ -312,9 +307,7 @@ void Render_area::change_container_view(int view_size){
bool Render_area::build(Trace* trace){
_trace = trace;
bool Render_area::build(){
if (glIsList(_wait_list)==GL_TRUE){/* if the list exists */
glDeleteLists(_wait_list, 1);
......@@ -351,8 +344,6 @@ bool Render_area::build(Trace* trace){
bool Render_area::unbuild(){
_trace = NULL;
if (glIsList(_drawing_list)==GL_TRUE){/* if the list exists */
glDeleteLists(_drawing_list, 1);
_drawing_list = 0;
......@@ -476,9 +467,9 @@ GLuint Render_area::draw_wait() {
GLuint Render_area::draw_trace(){//Trace trace)
DrawTrace<Render_area> drawing;
// DrawTrace<Render_area> drawing;
drawing.build(this, _trace);
// drawing.build(this, _trace);
GLuint object; /* Must be delete */
......@@ -492,106 +483,3 @@ GLuint Render_area::draw_trace(){//Trace trace)
return object; /* Must be delete */
}
inline void Render_area::start_draw(){
/* clear lists to store container texts */
_text_pos.clear();
_text_value.clear();
}
inline void Render_area::start_draw_containers(){
_list_containers = glGenLists(1);/* create the list */
if (_list_containers==0){
_parent->warning("Error when creating list");
}
glNewList(_list_containers, GL_COMPILE);/* open the list */
}
inline void Render_area::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) {
float j=0.6;
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(0, 0, j);glVertex2d(x, y);
glColor3d(0, 0, j-0.1);glVertex2d(x, y-h);
glColor3d(0, 0, j-0.1);glVertex2d(x-w, y-h);
glColor3d(0, 0, j);glVertex2d(x-w, y);
}
glEnd();
if (x>_container_x_max)
_container_x_max = x;
if (y>_container_y_max)
_container_y_max = y;
}
inline void Render_area::draw_container_text(const Element_pos x, const Element_pos y, const string value){
_text_pos.push_back(x);
_text_pos.push_back(y);
_text_value.push_back(value);
}
inline void Render_area::end_draw_containers(){
glEndList();/* close the list */
}
inline void Render_area::start_draw_states(){
_list_states = glGenLists(1);/* create the list */
if (_list_states==0){
_parent->warning("Error when creating list");
}
glNewList(_list_states, GL_COMPILE);/* open the list */
}
inline void Render_area::draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b){
#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;
#endif
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(r, g, b);glVertex2d(start, base);
glColor3d(r, g, b);glVertex2d(start, base + height);
glColor3d(r*2, g*2, b*2);glVertex2d(end, base + height);
glColor3d(r*2, g*2, b*2);glVertex2d(end, base);
}
glEnd();
}
inline void Render_area::end_draw_states(){
glEndList();/* close the list */
}
inline void Render_area::end_draw(){
}
......@@ -11,10 +11,11 @@ class Render_area;
typedef double Level;
#include "resource.hpp"
#include <QtGui>
#include <QGLWidget>/* for the OpenGL Widget */
#include "interface_graphic.hpp"
#include "resource.hpp"
......@@ -55,10 +56,7 @@ class Render_area : public QGLWidget
*
**********************************/
/*!
* \brief The data structure attribute.
*/
Trace* _trace;
......@@ -180,51 +178,12 @@ class Render_area : public QGLWidget
*/
GLuint _drawing_list;
/*!
* \brief The default height for containers.
*/
static const float DRAWING_CONTAINER_HEIGHT_DEFAULT = 1.2f;
/*!
* \brief The default width for containers.
*/
static const float DRAWING_CONTAINER_WIDTH_DEFAULT = 2.5f;
/*!
* \brief The default horizontal space between containers.
*/
static const float DRAWING_CONTAINER_H_SPACE_DEFAULT = 0.1f;
/*!
* \brief The default vertical space between containers.
*/
static const float DRAWING_CONTAINER_V_SPACE_DEFAULT = 0.2f;
/*!
* \brief The default height for states.
*/
static const float DRAWING_STATE_HEIGHT_DEFAULT = 1.2f;
/*!
* \brief The default vertical space between states.
*/
static const float DRAWING_STATE_V_SPACE_DEFAULT = 0.2f;
Element_pos _container_x_max;
Element_pos _container_y_max;
/*!
* \brief Geometrical informations about the trace shape.
*/
double _container_width;
double _container_height;
double _container_h_space;
double _container_v_space;
double _state_height;
double _state_v_space;
double _container_x_max;
double _container_y_max;
Element_pos _z_arrow;/* z position for arrows */
/***********************************
* Trace Drawing functions and attributes.
......@@ -237,16 +196,16 @@ class Render_area : public QGLWidget
GLuint draw_trace();
inline Element_count number_of_children(const Container* c);
// inline Element_count number_of_children(const Container* c);
inline Element_count return_last_visited_child(std::stack<Element_count> const &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(const std::list <Container*> *list_container, const int pos) const;
// Container* get_container(const std::list <Container*> *list_container, const int pos) const;
int _state_scale;/* temporary */
......@@ -285,7 +244,7 @@ class Render_area : public QGLWidget
* \brief This function draws the trace.
* \arg trace the trace which be displayed.
*/
bool build(Trace* trace);
bool build();
/*!
* \brief This function releases the trace.
......@@ -297,9 +256,9 @@ class Render_area : public QGLWidget
void change_container_view(int view_size);/* temporary -> to change the size of container view */
inline void start_draw();
void start_draw();
inline void start_draw_containers();
void start_draw_containers();
/*!
* \brief Draw a container according to the parameters
......@@ -308,7 +267,7 @@ class Render_area : public QGLWidget
* \param w the width of the container
* \param h the height of the container
*/
inline void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h);
void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h);
/*!
* \brief Draw the text of a container.
......@@ -316,11 +275,11 @@ class Render_area : public QGLWidget
* \param y the y position of the text.
* \param value the string value of the text.
*/
inline void draw_container_text(const Element_pos x, const Element_pos y, const std::string value);
void draw_container_text(const Element_pos x, const Element_pos y, const std::string value);
inline void end_draw_containers();
void end_draw_containers();
inline void start_draw_states();
void start_draw_states();
/*!
* \brief Draw a state of the trace.
......@@ -332,12 +291,160 @@ class Render_area : public QGLWidget
* \param g the green color rate of the state.
* \param b the blue color rate of the state.
*/
inline void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b);
void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b);
void end_draw_states();
inline void end_draw_states();
void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height);
inline void end_draw();
void end_draw();
};
/* inline function area */
inline void Render_area::start_draw(){
/* clear lists to store container texts */
_text_pos.clear();
_text_value.clear();
}
inline void Render_area::start_draw_containers(){
_list_containers = glGenLists(1);/* create the list */
if (_list_containers==0){
// _parent->warning("Error when creating list");
}
glNewList(_list_containers, GL_COMPILE);/* open the list */
}
inline void Render_area::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) {
float j=0.6;
glBegin(GL_QUADS);/* create a quads */
{
glColor3d(0, 0, j);glVertex2d(x, y);
glColor3d(0, 0, j-0.1);glVertex2d(x, y+h);
glColor3d(0, 0, j-0.1);glVertex2d(x+w, y+h);
glColor3d(0, 0, j);glVertex2d(x+w, y);
}
glEnd();
if (x>_container_x_max)
_container_x_max = x;
if (y>_container_y_max)
_container_y_max = y;
}
inline void Render_area::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
_text_pos.push_back(x);
_text_pos.push_back(y);
_text_value.push_back(value);
}
inline void Render_area::end_draw_containers(){
glEndList();/* close the list */
}
inline void Render_area::start_draw_states(){
_list_states = glGenLists(1);/* create the list */
if (_list_states==0){
// _parent->warning("Error when creating list");
}
glNewList(_list_states, GL_COMPILE);/* open the list */
}
inline void Render_area::draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b){
#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;