Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 48ca7f55 authored by Olivier Lagrasse's avatar Olivier Lagrasse
Browse files

- Mise en page FAQ dans manuel utilisateur.

- Correction bug d'alignement entre etats et conteneurs.
- Ajout fichiers source pour les vbo.
- Ajout debut test vbo.
- Fusion dans interface console de draw trace pour l'OpenGL et le SVG.
- Quand on ferme un trace, on ne peut plus l'exporter.
parent 6010f256
Branches
Tags
No related merge requests found
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
*/ */
#include "interface_console.hpp" #include "interface_console.hpp"
using namespace std; using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): " #define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
...@@ -23,9 +26,6 @@ using namespace std; ...@@ -23,9 +26,6 @@ using namespace std;
Interface_console::Interface_console(int argc, char ** argv){ Interface_console::Interface_console(int argc, char ** argv){
int state; int state;
bool useGUI;/* if window interface can be displayed */ bool useGUI;/* if window interface can be displayed */
QString current_path; QString current_path;
...@@ -33,6 +33,7 @@ Interface_console::Interface_console(int argc, char ** argv){ ...@@ -33,6 +33,7 @@ Interface_console::Interface_console(int argc, char ** argv){
app = new QApplication(argc, argv);/* create the Qt application */ app = new QApplication(argc, argv);/* create the Qt application */
current_path = QDir::currentPath(); current_path = QDir::currentPath();
_run_env[0] = new char[current_path.length()+1]; _run_env[0] = new char[current_path.length()+1];
if (!strcpy(_run_env[0], current_path.toStdString().c_str())) { if (!strcpy(_run_env[0], current_path.toStdString().c_str())) {
cerr << "Error : in " << __FILE__ << " at line " << __LINE__ << "." << endl; cerr << "Error : in " << __FILE__ << " at line " << __LINE__ << "." << endl;
cerr << "Reason : Copy of the current path directory failed." << endl; cerr << "Reason : Copy of the current path directory failed." << endl;
...@@ -44,8 +45,8 @@ Interface_console::Interface_console(int argc, char ** argv){ ...@@ -44,8 +45,8 @@ Interface_console::Interface_console(int argc, char ** argv){
Message::set_interface(this);/* define which interface will receive messages */ Message::set_interface(this);/* define which interface will receive messages */
useGUI = true; useGUI = true;
// argc = 1;
glutInit(&argc, argv);/* use for OpenGL text */
/* Qt uses the default system encoding for QString (used when opening a file) */ /* Qt uses the default system encoding for QString (used when opening a file) */
QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale()); QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
...@@ -68,7 +69,6 @@ Interface_console::Interface_console(int argc, char ** argv){ ...@@ -68,7 +69,6 @@ Interface_console::Interface_console(int argc, char ** argv){
} }
...@@ -92,59 +92,66 @@ Interface_console::~Interface_console(){ ...@@ -92,59 +92,66 @@ Interface_console::~Interface_console(){
* *
**********************************/ **********************************/
bool Interface_console::draw_trace(const string & filename, const int format){
bool Interface_console::draw_trace(const string & filename){//, Render_opengl* render_area){
if (_render_opengl==NULL){
message << "Error, no render area bound to the main window" << Message::ende;
return false;
}
Trace trace; Trace trace;
ParserPaje parser; ParserPaje parser;
DrawTrace<Render_opengl> drawing;
QApplication::setOverrideCursor(Qt::WaitCursor);
try{
parser.parse(filename, trace);
}
catch (const string &error){
//message << "unable to parse " << filename << ende;
*Message::get_instance() << "Reason : " << error << Message::ende;
return false;
}
drawing.build(_render_opengl, &trace); QApplication::setOverrideCursor(Qt::WaitCursor);
_render_opengl->build();
_render_opengl->updateGL();
QApplication::restoreOverrideCursor();
return true;
}
switch(format){
/*******************
* OpenGL render
*******************/
case _DRAW_OPENGL:
{
DrawTrace<Render_opengl> drawing_ogl;
try{
parser.parse(filename, trace);
}
catch (const string &error){
*Message::get_instance() << "Reason : " << error << Message::ende;
return false;
}
drawing_ogl.build(_render_opengl, &trace);
_render_opengl->build();
_render_opengl->updateGL();
}
bool Interface_console::draw_trace(const string & filename, Svg* svg){ _file_opened = filename;/* store filename for a future export */
Trace trace; break;
ParserPaje parser; /*******************
DrawTrace<Svg> drawing; * SVG render
*******************/
QApplication::setOverrideCursor(Qt::WaitCursor); case _DRAW_SVG:
try{ {
parser.parse(filename, trace); Svg svg;
} svg.init(_path_to_export.c_str());
catch (const string &error){ DrawTrace<Svg> drawing_svg;
//message << "unable to parse " << filename << ende;
*Message::get_instance() << "Reason : " << error << Message::ende; try{
parser.parse(filename, trace);
}
catch (const string &error){
*Message::get_instance() << "Reason : " << error << Message::ende;
return false;
}
drawing_svg.build(&svg, &trace);
svg.end();
}
break;
/*******************
* Error
*******************/
default:
*Message::get_instance() << "No kind of render recognized" << Message::ende;
return false; return false;
} }
drawing.build(svg, &trace);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
...@@ -226,74 +233,6 @@ int Interface_console::get_state(int argc, char** argv){ ...@@ -226,74 +233,6 @@ int Interface_console::get_state(int argc, char** argv){
} }
return state; return state;
////////////////////////////////////////////////////////////////
// switch(argc){
// case 1: /* just the name of the program, launch the window interface */
// return _STATE_LAUNCH_GRAPHICAL_INTERFACE;
// case 2: /* There is one argument */
// if (strncmp(argv[1], "-h", 2) == 0){
// /* display the help message */
// return _STATE_DISPLAY_HELP;
// }
// else{
// /* should be a path of a file */
// _file_opened = argv[1];/* store the path of the file */
// return _STATE_OPEN_FILE;
// }
// case 3: // open a file
// if (strncmp(argv[1], "-f", 2) == 0 || strncmp(argv[1], "-a", 2) == 0){
// /* should be a path of a file */
// _file_opened = argv[2];/* store the path of the file */
// return _STATE_OPEN_FILE;
// }
// else{
// return _STATE_DISPLAY_HELP;
// }
// case 4: // open a file in an interval
// if(strncmp(argv[2], "-t", 2) == 0){
// _file_opened = argv[1];/* store the path of the file */
// extract_times(argv[3]);
// return _STATE_OPEN_FILE_IN_AN_INTERVAL;
// }
// else{
// return _STATE_DISPLAY_HELP;
// }
// case 5: // export a file
// if (strncmp(argv[1], "-f", 2) == 0){
// /* should be a path of a file */
// _file_opened = argv[2];/* store the path of the file */
// if(strncmp(argv[3], "-e", 2) == 0){
// _path_to_export = argv[4];
// }
// else{
// return _STATE_DISPLAY_HELP;
// }
// return _STATE_EXPORT_FILE;
// }
// else{
// return _STATE_DISPLAY_HELP;
// }
// case 7: // export a piece of trace
// if (strncmp(argv[1], "-f", 2) == 0 && strncmp(argv[3], "-e", 2) == 0 && strncmp(argv[5], "-t", 2) == 0) {
// /* should be a path of a file */
// _file_opened = argv[2];/* store the path of the file */
// _path_to_export = argv[4];
// extract_times(argv[6]);
// return _STATE_EXPORT_FILE_IN_INTERVAL;
// }
// else{
// return _STATE_DISPLAY_HELP;
// }
// default:
// break;
// }
// return _STATE_UNKNOWN;
} }
void Interface_console::extract_times(const char *name){ void Interface_console::extract_times(const char *name){
...@@ -328,7 +267,6 @@ void Interface_console::launch_action(int state, void* arg){ ...@@ -328,7 +267,6 @@ void Interface_console::launch_action(int state, void* arg){
case _STATE_DISPLAY_HELP : case _STATE_DISPLAY_HELP :
display_help(); display_help();
exit(EXIT_SUCCESS);
break; break;
case _STATE_LAUNCH_GRAPHICAL_INTERFACE : case _STATE_LAUNCH_GRAPHICAL_INTERFACE :
...@@ -341,7 +279,7 @@ void Interface_console::launch_action(int state, void* arg){ ...@@ -341,7 +279,7 @@ void Interface_console::launch_action(int state, void* arg){
break; break;
case _STATE_OPEN_FILE: case _STATE_OPEN_FILE:
information(string("Opening the file: ")+string(_file_opened)); information(string("Opening the file: ")+_file_opened);
_main_window = new Interface_graphic(this);/* launch the window interface and open a file */ _main_window = new Interface_graphic(this);/* launch the window interface and open a file */
Message::set_interface(_main_window);/* define which interface will receive messages */ Message::set_interface(_main_window);/* define which interface will receive messages */
_render_opengl = new Render_opengl(_main_window); _render_opengl = new Render_opengl(_main_window);
...@@ -349,23 +287,25 @@ void Interface_console::launch_action(int state, void* arg){ ...@@ -349,23 +287,25 @@ void Interface_console::launch_action(int state, void* arg){
_main_window->opening_file(_file_opened);/* Must be called after binding the render area to the main window */ _main_window->opening_file(_file_opened);/* Must be called after binding the render area to the main window */
if(false==draw_trace(_file_opened)) if(false==draw_trace(_file_opened, _DRAW_OPENGL))
message << "Draw trace failed" << Message::ende; message << "Draw trace failed" << Message::ende;
break; break;
case _STATE_EXPORT_FILE: case _STATE_EXPORT_FILE:
if (true == _file_opened.empty()){
*Message::get_instance() << "Please to previously open a trace." << Message::endw;
return;
}
*Message::get_instance() << "export of " << _file_opened << " to " << _path_to_export << Message::endi; *Message::get_instance() << "export of " << _file_opened << " to " << _path_to_export << Message::endi;
///// Do the export ///// ///// Do the export /////
{ {
Svg svg; draw_trace(_file_opened, _DRAW_SVG);
svg.init(_path_to_export);
draw_trace(_file_opened, &svg);
svg.end();
} }
///////////////////////// /////////////////////////
exit(EXIT_SUCCESS);
break; break;
case _STATE_EXPORT_FILE_IN_INTERVAL: case _STATE_EXPORT_FILE_IN_INTERVAL:
...@@ -385,7 +325,7 @@ void Interface_console::launch_action(int state, void* arg){ ...@@ -385,7 +325,7 @@ void Interface_console::launch_action(int state, void* arg){
///// Do the export ///// ///// Do the export /////
///////////////////////// /////////////////////////
exit(EXIT_SUCCESS);
break; break;
case _STATE_OPEN_FILE_IN_AN_INTERVAL: case _STATE_OPEN_FILE_IN_AN_INTERVAL:
...@@ -402,13 +342,13 @@ void Interface_console::launch_action(int state, void* arg){ ...@@ -402,13 +342,13 @@ void Interface_console::launch_action(int state, void* arg){
else{ else{
cout << "the end of the trace."; cout << "the end of the trace.";
} }
exit(EXIT_SUCCESS);
break; break;
case _STATE_RELEASE_RENDER_AREA: case _STATE_RELEASE_RENDER_AREA:
if (_render_opengl->unbuild()==false) if (_render_opengl->unbuild()==false)
message << "Close file : an error occured with trace releasing." << Message::ende; message << "Close file : an error occured with trace releasing." << Message::ende;
_file_opened.clear();
_render_opengl->updateGL(); _render_opengl->updateGL();
break; break;
...@@ -427,7 +367,7 @@ void Interface_console::launch_action(int state, void* arg){ ...@@ -427,7 +367,7 @@ void Interface_console::launch_action(int state, void* arg){
default:/* like _STATE_UNKNOWN */ default:/* like _STATE_UNKNOWN */
display_help(); display_help();
warning(string("Cannot determine the arguments past. Please check the correct syntax.")); warning(string("Cannot determine the arguments past. Please check the correct syntax."));
exit(EXIT_SUCCESS);
} }
} }
...@@ -477,6 +417,10 @@ const string Interface_console::get_filename() const{ ...@@ -477,6 +417,10 @@ const string Interface_console::get_filename() const{
return _file_opened; return _file_opened;
} }
void Interface_console::set_path_to_export(const string& path){
_path_to_export = path;
}
char const* const* Interface_console::get_runenv() const{ char const* const* Interface_console::get_runenv() const{
return _run_env; return _run_env;
} }
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
class Interface_console; class Interface_console;
#include <QtGui>
#include <QApplication>
#include "interface.hpp" #include "interface.hpp"
#include "interface_graphic.hpp" #include "interface_graphic.hpp"
#include "../render/render_opengl.hpp" #include "../render/render_opengl.hpp"
...@@ -95,6 +94,16 @@ public: ...@@ -95,6 +94,16 @@ public:
*\brief A state which corresponds to release the OpenGL render area (display the wait screen). *\brief A state which corresponds to release the OpenGL render area (display the wait screen).
*/ */
static const int _STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE = 9; static const int _STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE = 9;
/*!
*\brief Informs that a trace has to be parsed and diplayed in the main window.
*/
static const int _DRAW_OPENGL = 10;
/*!
*\brief Informs that a trace has to be exported in svg format.
*/
static const int _DRAW_SVG = 11;
/*! /*!
*\brief A state which corresponds to display the ViTE window. *\brief A state which corresponds to display the ViTE window.
...@@ -154,12 +163,12 @@ protected: ...@@ -154,12 +163,12 @@ protected:
/*! /*!
*\brief If a file must be opened, this attributes contains its path. *\brief If a file must be opened, this attributes contains its path.
*/ */
char* _file_opened; std::string _file_opened;
/*! /*!
*\brief If a file must be exported, this attributes contains its path. *\brief If a file must be exported, this attributes contains its path.
*/ */
char* _path_to_export; std::string _path_to_export;
/*! /*!
*\brief The time where we start to watch the trace. *\brief The time where we start to watch the trace.
...@@ -233,22 +242,11 @@ protected: ...@@ -233,22 +242,11 @@ protected:
/*! /*!
* \brief This function launch trace drawing. * \brief This function launch trace drawing.
* \param filename Path of the trace file. * \param filename Path of the trace file.
* \param render_area Pointer to the render area. * \param format Format of the render output between: Interface_console::_DRAW_OPENGL and Interface_console::_DRAW_SVG.
* *
* \return true if no errors occurs. * \return true if no errors occurs.
*/ */
bool draw_trace(const std::string & filename);//, Render_opengl* render_area); bool draw_trace(const std::string & filename, const int format);
/*!
* \brief This function launch SVG drawing.
* \param filename Path of the trace file.
* \param svg Pointer to the svg instance.
*
* \return true if no errors occurs.
*/
bool draw_trace(const std::string & filename, Svg* svg);
/*! /*!
* \brief This function launch Qt event loop. * \brief This function launch Qt event loop.
...@@ -262,6 +260,13 @@ protected: ...@@ -262,6 +260,13 @@ protected:
*/ */
const std::string get_filename() const; const std::string get_filename() const;
/*!
* \brief Set the name of the output file for SVG export.
* \param path Path of the output file.
*
*/
void set_path_to_export(const std::string& path);
/*! /*!
* \brief Get the _run_env matrix. * \brief Get the _run_env matrix.
* *
......
...@@ -211,7 +211,7 @@ void Interface_graphic::on_open_triggered(){ ...@@ -211,7 +211,7 @@ void Interface_graphic::on_open_triggered(){
else{ else{
opening_file(filename.toStdString()); opening_file(filename.toStdString());
if(false==_core->draw_trace(filename.toStdString())) if(false==_core->draw_trace(filename.toStdString(), Interface_console::_DRAW_OPENGL))
error("Draw trace failed"); error("Draw trace failed");
}/* end else of if (_is_rendering_trace == true) */ }/* end else of if (_is_rendering_trace == true) */
...@@ -230,17 +230,10 @@ void Interface_graphic::on_export_file_triggered(){ ...@@ -230,17 +230,10 @@ void Interface_graphic::on_export_file_triggered(){
if (!filename.isEmpty()){ if (!filename.isEmpty()){
information(string("Exporting trace to ")+filename.toStdString()); information(string("Exporting trace to ")+filename.toStdString());
{
Svg svg; _core->set_path_to_export(filename.toStdString());
// _core->draw_trace(_trace_path, Interface_console::_DRAW_SVG);
_core->launch_action(Interface_console::_STATE_EXPORT_FILE);
svg.init(filename.toStdString().c_str());
_core->draw_trace(_trace_path, &svg);
}
} }
else else
error("No file specified for exportation"); error("No file specified for exportation");
......
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
class Interface_graphic; class Interface_graphic;
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include "../ui_main_window.h"/* the main window graphical interface */ #include "../ui_main_window.h"/* the main window graphical interface */
#include "interface.hpp" #include "interface.hpp"
......
...@@ -5,19 +5,35 @@ ...@@ -5,19 +5,35 @@
#ifndef RESOURCE_HPP #ifndef INTERFACE_RESOURCE_HPP
#define RESOURCE_HPP #define INTERFACE_RESOURCE_HPP
#include "../main_resource.hpp" #include "../main_resource.hpp"
/*
*
* WARNING : Take care that GL/glew.h MUST be included before others OpenGL includes (like GL/glut.h or QGLWidget).
*
*/
#include <GL/glew.h>/* For OpenGL VBO and shaders */
#include <GL/glut.h>/* For OpenGL text rendering */
#include <QtGui>
#include <QApplication>
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include <cmath> #include <cmath>
#include <stack> #include <stack>
#include <list> #include <list>
/* For OpenGL text rendering */
#include <GL/glut.h>
...@@ -66,9 +82,5 @@ ...@@ -66,9 +82,5 @@
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
} }
/* Define the unity of time */
typedef double Times;
#endif #endif
...@@ -8,15 +8,19 @@ ...@@ -8,15 +8,19 @@
* \brief The main launcher. * \brief The main launcher.
*/ */
#include <QApplication>
#include "interface/interface_console.hpp" #include "interface/interface_console.hpp"
/*! /*!
*\brief The main function of ViTE. *\brief The main function of ViTE.
*/ */
int main(int argc, char **argv) { int main(int argc, char **argv) {
Q_INIT_RESOURCE(vite); Q_INIT_RESOURCE(vite);
glutInit(&argc, argv);
Interface_console console(argc, argv); Interface_console console(argc, argv);
return console.run(); return console.run();
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */ #include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
/*! /*!
* \brief unity for count elements such as number of states or events... NOT USED YET * \brief unity for count elements such as number of states or events... NOT USED YET
*/ */
...@@ -26,6 +30,10 @@ typedef double Element_pos; ...@@ -26,6 +30,10 @@ typedef double Element_pos;
*/ */
typedef double Element_col; typedef double Element_col;
/* Define the unity of time */
typedef double Times;
/* Message management */ /* Message management */
......
...@@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &out, Message::end_information_t) { ...@@ -59,7 +59,7 @@ std::ostream &operator<<(std::ostream &out, Message::end_information_t) {
Interface *interface = Message::get_interface(); Interface *interface = Message::get_interface();
if (interface) { if (interface) {
interface->warning(message->str()); interface->information(message->str());
message->str(""); // flush the stream message->str(""); // flush the stream
} else { } else {
std::cerr << "Warning: no interface designed to display messages." << std::endl; std::cerr << "Warning: no interface designed to display messages." << std::endl;
......
...@@ -25,6 +25,18 @@ using namespace std; ...@@ -25,6 +25,18 @@ using namespace std;
Render_opengl::Render_opengl(QWidget *parent) Render_opengl::Render_opengl(QWidget *parent)
: QGLWidget(parent){ : QGLWidget(parent){
GLenum glew_code;
if (!QGLFormat::hasOpenGL()){
QMessageBox::information(0, "ViTE: Fatal OpenGL error","This system does not support OpenGL.");
}
_state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */ _state = DRAWING_STATE_WAINTING;/* At the beginning, no trace is drawing */
/* init the wait animation */ /* init the wait animation */
...@@ -101,6 +113,19 @@ Render_opengl::Render_opengl(QWidget *parent) ...@@ -101,6 +113,19 @@ Render_opengl::Render_opengl(QWidget *parent)
setMouseTracking (true);/* to catch mouse events */ setMouseTracking (true);/* to catch mouse events */
updateGL(); updateGL();
glew_code = glewInit();/* use for VBO and shaders */
if(GLEW_OK != glew_code){
message << "Cannot initialize GLEW: " << glewGetErrorString(glew_code) << Message::ende;
}
/*Check if VBO is supported */
if (GL_FALSE == glewIsSupported("GL_ARB_vertex_buffer_object")){
message << "VBO OpenGL extension is not supported by your graphic card." << Message::ende;
}
} }
...@@ -136,6 +161,8 @@ void Render_opengl::initializeGL(){ ...@@ -136,6 +161,8 @@ void Render_opengl::initializeGL(){
glClearStencil(0); glClearStencil(0);
_wait_list = draw_wait(); _wait_list = draw_wait();
} }
void Render_opengl::resizeGL(int width, int height){ void Render_opengl::resizeGL(int width, int height){
...@@ -297,7 +324,7 @@ void Render_opengl::paintGL(){ ...@@ -297,7 +324,7 @@ void Render_opengl::paintGL(){
const char letter = buf_txt.c_str()[i]; const char letter = buf_txt.c_str()[i];
length += glutBitmapWidth(GLUT_BITMAP_HELVETICA_10, letter); length += glutBitmapWidth(GLUT_BITMAP_HELVETICA_10, letter);
if(length > size_of_container){ if(length > size_of_container){
cout << "break" << endl;
break; break;
} }
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, letter); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, letter);
...@@ -311,7 +338,7 @@ void Render_opengl::paintGL(){ ...@@ -311,7 +338,7 @@ void Render_opengl::paintGL(){
glTranslated( _default_entity_x_translate - _state_translate , 0.0f, _z_state); glTranslated( _default_entity_x_translate - _state_translate , 0.0f, _z_state);
glScalef(_state_scale*(_render_width/_state_x_max), (_render_height-_rule_height)/_state_y_max, 0.0f); glScalef(_state_scale*(_render_width/_state_x_max), (_render_height-_rule_height)/_container_y_max, 0.0f);
...@@ -746,6 +773,144 @@ void Render_opengl::create_rule(){ ...@@ -746,6 +773,144 @@ void Render_opengl::create_rule(){
} }
*/ */
} }
// void Render_opengl::create_rule(){
// ostringstream buf_txt;
// Element_pos rule_width;
// Element_pos entity_width;
// Element_pos graduation_distance;
// Element_pos x_min;
// Element_pos start_delay;
// Element_pos coeff;
// Element_pos buf_number;
// Element_pos graduation_distance_per_5;
// int units;
// int ten_units;
// Element_pos buf_g_d;
// units = 0;//3;
// ten_units = 1;//1000;
// coeff = (_state_x_max - _state_x_min)/_render_width;/* from [0;100] to [_state_x_min;_state_x_max], used to obtain correct coordinate texts */
// entity_width = _render_width*_state_scale;/* the render width from a given scale */
// graduation_distance = entity_width/ceil(entity_width/_rule_distance);/* distance between two graduations calculated from a desire distance */
// x_min = _default_entity_x_translate-_state_translate;/* received the first integer inside render width */
// start_delay = x_min - graduation_distance*floor(x_min/graduation_distance);/* delaying rule start at 0.0 x coordinate to fit with graduation distance */
// graduation_distance_per_5 = graduation_distance/5.0;
// rule_width = (_render_width*_state_scale+x_min)/_rule_distance;
// /* Calculate the rule unit (cm, mm, um, nm, ...) */
// buf_g_d = _state_x_max/((double)_state_scale);
// /* cerr << buf_g_d << endl;
// while( (buf_g_d > 0.0) && (buf_g_d <= 1.0) ){
// buf_g_d *= 10.0;
// units ++;
// ten_units *= 10;
// }*/
// /* Draw the rule top line */
// glColor3d(1.0, 1.0, 1.0);
// glBegin(GL_LINES);
// {
// glVertex3d(max(x_min, 0.0), _rule_y, _z_rule);
// glVertex3d(entity_width+x_min, _rule_y, _z_rule);
// }
// glEnd();
// if ( (x_min<0.0) && ((entity_width+x_min)>graduation_distance)){/* we are not viewing the beginning of the trace (i.e. the 0.0 coordinate) but we still viewing the trace (not after the end) */
// /* draw previous small graduations */
// for (char k=1 ; k<5 ; k++){
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(start_delay-k*graduation_distance_per_5, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(start_delay-k*graduation_distance_per_5, _rule_y+_rule_height/3.0, _z_rule);
// }
// glEnd();
// }
// }
// /* Draw spaced graduation of _rule_distance */
// for (Element_pos i=max(x_min, start_delay) ; i<=min(entity_width+x_min, _render_width) ; i+=graduation_distance){
// if (i != min(entity_width+x_min, _render_width) ){/* prepare small graduations between the current and the next main graduation */
// /* draw small graduations */
// for (char k=1 ; k<5 ; k++){
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(i+k*graduation_distance_per_5, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(i+k*graduation_distance_per_5, _rule_y+_rule_height/3.0, _z_rule);
// }
// glEnd();
// }
// }
// /* Draw the main graduation line */
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(i, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(i, _rule_y+_rule_height, _z_rule);
// }
// glEnd();
// /* Draw the graduation text */
// glColor3d(1.0, 1.0, 1.0);
// glRasterPos2f(i, _rule_y+_rule_height);
// buf_number = (i - x_min)*coeff/_state_scale;
// /* trunc numbers */
// buf_number = floor(buf_number*ten_units);
// buf_txt << buf_number;
// for(unsigned int j=0;j<buf_txt.str().length();j++){
// glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]);
// }
// buf_txt.str("");/* flush the buffer */
// }
// /* Draw the ended graduation line */
// glBegin(GL_LINES);
// {
// glColor3d(1.0, 1.0, 1.0);glVertex3d(rule_width*_rule_distance, _rule_y, _z_rule);
// glColor3d(1.0, 0.6, 0.6);glVertex3d(rule_width*_rule_distance, _rule_y+_rule_height, _z_rule);
// }
// glEnd();
// /* Indicate the unit */
// glColor3d(1.0, 1.0, 1.0);
// glRasterPos2f(0, _rule_y+_rule_height);
// buf_txt << "10^-" << units;
// for(unsigned int j=0;j<buf_txt.str().length();j++){
// glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]);
// }
// }
void Render_opengl::set_total_width(Element_pos w){} void Render_opengl::set_total_width(Element_pos w){}
......
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
#define RENDER_OPENGL_HPP #define RENDER_OPENGL_HPP
class Render_opengl;
#include <QtGui>
#include <QGLWidget>/* for the OpenGL Widget */
class Render_opengl;
#include "render.hpp" #include "render.hpp"
#include "resource.hpp" #include "resource.hpp"
/*! /*!
* \brief Structure used to store event information. * \brief Structure used to store event information.
*/ */
...@@ -40,19 +42,19 @@ struct Event_{ ...@@ -40,19 +42,19 @@ struct Event_{
*/ */
struct Arrow_{ struct Arrow_{
/*! /*!
* \brief time when the arrow starts * \brief time when the arrow starts.
*/ */
Element_pos start_time; Element_pos start_time;
/*! /*!
* \brief time when the arrow ends * \brief time when the arrow ends.
*/ */
Element_pos end_time; Element_pos end_time;
/*! /*!
* \brief ? * \brief The start height of the arrow.
*/ */
Element_pos start_height; Element_pos start_height;
/*! /*!
* \brief ? * \brief The end height of the arrow.
*/ */
Element_pos end_height; Element_pos end_height;
}; };
......
...@@ -5,55 +5,13 @@ ...@@ -5,55 +5,13 @@
#ifndef RESOURCE_HPP #ifndef RENDER_RESOURCE_HPP
#define RESOURCE_HPP #define RENDER_RESOURCE_HPP
#include "../main_resource.hpp"
#include <cmath>
#include <stack>
#include <list>
/* For OpenGL text rendering */
#include <GL/glut.h>
/*!
* \brief PI with a precision of 8.
*/
#define PI 3.14159265
/* Now, two checkers are defined (the first for integer return value, the other #include "../main_resource.hpp"
for pointer return value). Their body can be empty to enhance program speed.
To pass multi arguments for m, use "<<" between each arguments.
*/
/*!
* \brief Checks if a function return -1 as a value.
*
* This macro is used with C functions to check them if an error occurs. Thus, it display the file, the line and some informations (with m variable) of the error than exit the program.
*/
#define CKF(f, m) if((f)==-1) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
/*!
* \brief Checks if a function return NULL as a value.
*
* This macro is used with C functions to check them if an error occurs. Thus, it display the file, the line and some informations (with m variable) of the error than exit the program.
*/
#define CKFP(f, m) if((f)==NULL) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
/* Define the unity of time */
typedef double Times;
......
/*!
*\file vbo.cpp
*/
#include "vbo.hpp"
using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
/***********************************
*
*
*
* Constructor and destructor.
*
*
*
**********************************/
Vbo::Vbo(){
/* init class attributes */
_cur = 0;
/* init OpenGL */
// glGenBuffers(1, &_id);/* create the buffer an put its value to _id */
// glBindBuffer(GL_ARRAY_BUFFER, _id);/* select our vbo */
// glBufferData(GL_ARRAY_BUFFER, _size, NULL, GL_STATIC_DRAW);/* allocate memory space inside graphic card */
// glBindBuffer(GL_ARRAY_BUFFER, 0);/* deselect our vbo */
}
Vbo::~Vbo(){
//glDeleteBuffers(1, &_id);/* release the buffer and free its memory inside graphic card */
}
/*!
*\file vbo.hpp
*/
#ifndef VBO_HPP
#define VBO_HPP
class Vbo;
#include "resource.hpp"
/*!
* \brief Manage the Vertex Buffer Object.
*/
class Vbo{
protected:
/*!
* \brief The vbo instance identity.
*/
GLuint _id;
/*!
* \brief The size of the vbo buffer. (10 000 verteces)
*/
static const int _size = 100;
/*!
* \brief Define the position indicator inside the VBO buffer. Must be lesser than _size !
*/
int _cur;
public:
/***********************************
*
* Constructor and destructor.
*
**********************************/
/*!
* \brief The default constructor.
*/
Vbo();
/*!
* \brief The destructor.
*/
virtual ~Vbo();
/***********************************
*
* Buffer filling.
*
**********************************/
/*!
* \brief Used to inform that data have been successfully added to graphic card.
*/
static const int VBO_OK = 0;
/*!
* \brief Used to inform that the buffer is full and another VBO must be create.
*/
static const int VBO_OUT_OF_MEMORY = 1;
/*!
* \brief Used to inform that an unidentified error occurs.
*/
static const int VBO_UNDEFINED_ERROR = 2;
/*!
* \brief Fill the vertex buffer object.
* \return The state of the buffer.
*
* This function is called for each vertex, so it is an inline function. It can return several number :
* <ul>
* <li><b>VBO_OK</b>: data have been added to graphic card. No error.
* <li><b>VBO_OUT_OF_MEMORY</b>: buffer is full. Another VBO must be create.
* <li><b>VBO_UNDEFINED_ERROR</b>: an error occurs but has not been identified.
* </ul>
*/
virtual int fill_buffer() = 0;
/***********************************
*
* Buffer display.
*
**********************************/
/*!
* \brief Display the VBO list inside the OpenGL area.
*/
virtual void display_buffer() = 0;
};
#endif
...@@ -7,7 +7,7 @@ OBJECTS_DIR=../bin ...@@ -7,7 +7,7 @@ OBJECTS_DIR=../bin
DESTDIR=../bin DESTDIR=../bin
CONFIG+=uitools debug CONFIG+=uitools debug
QT+=opengl QT+=opengl
LIBS += -lglut LIBS += -lglut -lGLEW
TEMPLATE = app TEMPLATE = app
TARGET = vite TARGET = vite
DEPENDPATH += . interface message parser trace trace/values DEPENDPATH += . interface message parser trace trace/values
...@@ -17,13 +17,18 @@ INCLUDEPATH += . interface message trace trace/values parser ...@@ -17,13 +17,18 @@ INCLUDEPATH += . interface message trace trace/values parser
HEADERS += message/Message.hpp \ HEADERS += message/Message.hpp \
message/Errors.hpp \ message/Errors.hpp \
main_resource.hpp \ main_resource.hpp \
# Interface headers
interface/interface.hpp \ interface/interface.hpp \
interface/interface_console.hpp \ interface/interface_console.hpp \
interface/interface_graphic.hpp \ interface/interface_graphic.hpp \
interface/resource.hpp \
# Render headers
render/render.hpp \ render/render.hpp \
render/render_opengl.hpp \ render/render_opengl.hpp \
render/render_svg.hpp \ render/render_svg.hpp \
interface/resource.hpp \ render/vbo.hpp \
render/vbo_container.hpp \
# Parser headers
parser/Definition.hpp \ parser/Definition.hpp \
parser/Line.hpp \ parser/Line.hpp \
parser/Parser.hpp \ parser/Parser.hpp \
...@@ -31,6 +36,7 @@ HEADERS += message/Message.hpp \ ...@@ -31,6 +36,7 @@ HEADERS += message/Message.hpp \
parser/ParserEventDecoder.hpp \ parser/ParserEventDecoder.hpp \
parser/ParserPaje.hpp \ parser/ParserPaje.hpp \
parser/TokenSource.hpp \ parser/TokenSource.hpp \
# Data structure headers
trace/Container.hpp \ trace/Container.hpp \
trace/ContainerType.hpp \ trace/ContainerType.hpp \
trace/DrawTrace.hpp \ trace/DrawTrace.hpp \
...@@ -58,18 +64,24 @@ HEADERS += message/Message.hpp \ ...@@ -58,18 +64,24 @@ HEADERS += message/Message.hpp \
trace/values/Values.hpp trace/values/Values.hpp
FORMS += interface/info_window.ui interface/main_window.ui interface/maquette.ui FORMS += interface/info_window.ui interface/main_window.ui interface/maquette.ui
SOURCES += message/Message.cpp \ SOURCES += message/Message.cpp \
message/Errors.cpp \
main.cpp \ main.cpp \
# Interface code files
interface/interface_console.cpp \ interface/interface_console.cpp \
interface/interface_graphic.cpp \ interface/interface_graphic.cpp \
# Render code files
render/render_opengl.cpp \ render/render_opengl.cpp \
render/render_svg.cpp \ render/render_svg.cpp \
render/vbo.cpp \
render/vbo_container.cpp \
# Parser code files
parser/Definition.cpp \ parser/Definition.cpp \
message/Errors.cpp \
parser/Line.cpp \ parser/Line.cpp \
parser/ParserDefinitionDecoder.cpp \ parser/ParserDefinitionDecoder.cpp \
parser/ParserEventDecoder.cpp \ parser/ParserEventDecoder.cpp \
parser/ParserPaje.cpp \ parser/ParserPaje.cpp \
parser/TokenSource.cpp \ parser/TokenSource.cpp \
# Data structure code files
trace/Container.cpp \ trace/Container.cpp \
trace/ContainerType.cpp \ trace/ContainerType.cpp \
trace/Entity.cpp \ trace/Entity.cpp \
......
...@@ -245,7 +245,8 @@ public: ...@@ -245,7 +245,8 @@ public:
field = state->get_value()->get_extra_fields()->find(std::string("Color")); field = state->get_value()->get_extra_fields()->find(std::string("Color"));
// Search the color // Search the color
// Mind the map, may be the source of a bug // Mind the map, may be the source of a bug
if (!state->get_value()->get_extra_fields()->empty() && if (
!state->get_value()->get_extra_fields()->empty() &&
state->get_value() && state->get_value() &&
(field != extra_fields->end())) { (field != extra_fields->end())) {
/* Call the object state drawing function with the state color */ /* Call the object state drawing function with the state color */
......
CXX=g++ CXX=g++
CXXFLAGS = -Wall -g CXXFLAGS = -Wall -g
BIN_DIR = ../bin/ BIN_DIR = ../../bin/
SRC_DIR = ../src/ SRC_DIR = ../../src/message/
OBJECT_FILE_BIN = $(BIN_DIR)enderror.o $(BIN_DIR)endwarning.o $(BIN_DIR)endinformation.o $(BIN_DIR)message.o $(BIN_DIR)message_ns.o OBJECT_FILE_BIN = $(BIN_DIR)enderror.o $(BIN_DIR)endwarning.o $(BIN_DIR)endinformation.o $(BIN_DIR)message.o $(BIN_DIR)message_ns.o
OBJECT_FILE = enderror.o endwarning.o endinformation.o message.o message_ns.o OBJECT_FILE = enderror.o endwarning.o endinformation.o message.o message_ns.o
TEST_FLAGS = -DTEST_MESSAGE TEST_FLAGS = -DTEST_MESSAGE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment