Commit d27503f6 authored by Johnny Jazeix's avatar Johnny Jazeix

Ajout du début de ma partie sur le rapport.

Debuggage de Vite.
parent 8df75422
......@@ -9,6 +9,9 @@
#include <string>
#include <iostream>
// For dots or commas separator in double numbers
#include <locale.h>
/*!
* \fn convert_to_double(const std::string args)
* \brief Convert the string in double
......
......@@ -122,6 +122,7 @@ public:
/*!
* \brief To show the x beginning of the trace.
*/
static const int X_TRACE_BEGINNING = 0;
/*!
......
......@@ -134,10 +134,11 @@ bool Interface_console::draw_trace(const string & filename, const int format){
//delete _progress_dialog;
*Message::get_instance() << "Reason : " << error << Message::ende;
QApplication::restoreOverrideCursor();
parser.finish();
// Wait for the end thread
while(!thread.isFinished()){
thread.exit();
}
return false;
}
//delete _progress_dialog;
......@@ -147,8 +148,9 @@ bool Interface_console::draw_trace(const string & filename, const int format){
}
}else if ( _file_opened != filename){/* just check if execution is normal */
*Message::get_instance() << "Try to use file: " << filename << " instead of a previous parsed file: " << _file_opened << Message::ende;
}
else if ( _file_opened != filename){/* just check if execution is normal */
*Message::get_instance() << "Try to use file: " << filename << " instead of a previous parsed file: " << _file_opened << Message::ende;
}
Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) );
......@@ -460,6 +462,34 @@ void Interface_console::launch_action(int state, void* arg){
break;
case _STATE_OPEN_FILE_IN_AN_INTERVAL:
launch_action(_STATE_OPEN_FILE, NULL);
break;
case _STATE_RELEASE_RENDER_AREA:
if (_render_opengl->unbuild()==false)
message << "Close file : an error occured with trace releasing." << Message::ende;
_file_opened.clear();
if (false == _is_trace_loaded){
*Message::get_instance() << "Try to release a render area whereas no file was loaded" << Message::ende;
}else{
_is_trace_loaded = false;
}
if (NULL == _trace){
*Message::get_instance() << "Try to release a render area whereas no trace is loaded" << Message::ende;
}else{
delete _trace;
_trace = NULL;
}
_render_opengl->updateGL();
break;
case _STATE_EXPORT_FILE:
if (_file_opened.empty()){
......@@ -492,49 +522,6 @@ void Interface_console::launch_action(int state, void* arg){
draw_trace(_file_opened, _DRAW_SVG);
break;
case _STATE_OPEN_FILE_IN_AN_INTERVAL:
cout << "open " << _file_opened << " between ";
if(_time_start == 0){
cout << "the beginning of the trace to ";
}
else{
cout << _time_start << " seconds to ";
}
if(_time_end != 0){
cout << _time_end << " seconds." << endl;
}
else{
cout << "the end of the trace.";
}
launch_action(_STATE_LAUNCH_GRAPHICAL_INTERFACE, NULL);
draw_trace(_file_opened, _DRAW_OPENGL);
break;
case _STATE_RELEASE_RENDER_AREA:
if (_render_opengl->unbuild()==false)
message << "Close file : an error occured with trace releasing." << Message::ende;
_file_opened.clear();
if (false == _is_trace_loaded){
*Message::get_instance() << "Try to release a render area whereas no file was loaded" << Message::ende;
}else{
_is_trace_loaded = false;
}
if (NULL == _trace){
*Message::get_instance() << "Try to release a render area whereas no trace is loaded" << Message::ende;
}else{
delete _trace;
_trace = NULL;
}
_render_opengl->updateGL();
break;
case _STATE_RENDER_AREA_CHANGE_TRANSLATE:
_render_opengl->change_translate( *((int*)arg) );
break;
......
......@@ -5,6 +5,14 @@ using namespace std;
queue<string> Error::_errors;
queue<string> Error::_warnings;
const int Error::_EVERYTHING = 0;
const int Error::_WARNING = 1;
const int Error::_ERROR = 2;
string Error::_content = "";
const string Error::_PARSE = "expected \" before end of file";
const string Error::_MMAP = "mmap error";
const string Error::_EMPTY_FILE = "empty file";
......@@ -34,8 +42,6 @@ const string Error::_UNKNOWN_LINK_TYPE = "Unknown link type: ";
const string Error::_UNKNOWN_ENTITY_TYPE = "Unknown entity type: ";
string Error::_content = "";
void Error::set(const string kind_of_error, const int priority){
Error::_content = kind_of_error;
switch(priority){
......
......@@ -32,18 +32,18 @@ public:
/*!
* \brief Define the priority _ERROR.
*/
const static int _EVERYTHING = 0;
const static int _EVERYTHING;
/*!
* \brief Define the priority _WARNING.
*/
const static int _WARNING = 1;
const static int _WARNING;
/*!
* \brief Define the priority _ERROR.
*/
const static int _ERROR = 2;
const static int _ERROR;
/*
* Kind of errors known
......
......@@ -2,6 +2,9 @@
using namespace std;
const int ParserDefinitionDecoder::_OUT_A_DEFINITION = 0;
const int ParserDefinitionDecoder::_IN_A_DEFINITION = 1;
ParserDefinitionDecoder::ParserDefinitionDecoder(){
_state = _OUT_A_DEFINITION;
}
......
......@@ -37,8 +37,8 @@ private:
std::map<unsigned int, Definition> _definitions;
int _state;
unsigned int _current_definition;
static const int _OUT_A_DEFINITION = 0;
static const int _IN_A_DEFINITION = 1;
static const int _OUT_A_DEFINITION;
static const int _IN_A_DEFINITION;
public:
/*!
......
......@@ -55,10 +55,9 @@ void ParserPaje::parse(string filename, Trace &trace){
}
}
finish();
trace.finish();
_is_finished = true;
// We print the warnings and errors
Error::print_numbers();
Error::flush_in_file("log.txt");
......@@ -84,3 +83,7 @@ void ParserPaje::reinit_cursor() {
bool ParserPaje::is_end_of_parsing() const{
return _is_finished;
}
void ParserPaje::finish() {
_is_finished = true;
}
......@@ -79,6 +79,12 @@ public:
*/
bool is_end_of_parsing() const;
/*!
* \fn finish()
* \brief set _is_finished to true
*/
void finish();
};
#endif // PARSERPAJE_HPP
......
......@@ -38,16 +38,9 @@ void TokenSource::open(const char *filename){
_is_eof = false;
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
_file.open(filename, ios::in);
fill_buffer();
#else
if ((_fd = ::open(filename, O_RDONLY)) == -1) {
throw Error::_OPEN;
}
/* Getting the file size */
struct stat buf;
if(fstat(_fd, &buf) == -1) {
if(stat(filename, &buf) == -1) {
throw Error::_FSTAT;
}
......@@ -57,6 +50,15 @@ void TokenSource::open(const char *filename){
throw Error::_EMPTY_FILE;
}
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
_file.open(filename, ios::in);
fill_buffer();
#else
if ((_fd = ::open(filename, O_RDONLY)) == -1) {
throw Error::_OPEN;
}
if ((_buffer = (char *)mmap(0, _filesize, PROT_READ, MAP_PRIVATE, _fd, 0)) == MAP_FAILED) {
throw Error::_MMAP;
}
......@@ -214,7 +216,7 @@ int TokenSource::get_size_loaded() {
if (_file.bad())
return 3;
return (_file.tellg()*100.)/_file.size();
return (_file.tellg()*100.)/_filesize;
#else
if(_filesize == 0) {
return 1;
......
......@@ -42,12 +42,13 @@ private:
static int _cursor;
bool _is_eof;
static off_t _filesize;
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
int _buffer_size;
static std::ifstream _file;
#else
static off_t _filesize;
int _fd;
#endif
......
......@@ -12,6 +12,14 @@ using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
const int Render_opengl::DRAWING_STATE_WAITING = 1;
const int Render_opengl::DRAWING_STATE_DRAWING = 2;
const int Render_opengl::_ctrl_scroll_factor = 10;
const int Render_opengl::_ctrl_zoom_factor = 3;
const int Render_opengl::DRAWING_TIMER_DEFAULT = 10;
/***********************************
*
*
......
......@@ -136,12 +136,12 @@ protected:
/*!
* \brief State when there is no file opened.
*/
static const int DRAWING_STATE_WAITING = 1;
static const int DRAWING_STATE_WAITING;
/*!
* \brief State when the application is drawing traces.
*/
static const int DRAWING_STATE_DRAWING = 2;
static const int DRAWING_STATE_DRAWING;
/*!
* \brief Contains the kind of state for the render area (drawing, waiting, etc.).
......@@ -191,12 +191,12 @@ protected:
/*!
* \brief Define the scrolling factor when CTRL key is pressed.
*/
static const int _ctrl_scroll_factor = 10;
static const int _ctrl_scroll_factor;
/*!
* \brief Define the scrolling factor when CTRL key is pressed.
*/
static const int _ctrl_zoom_factor = 3;
static const int _ctrl_zoom_factor;
/***********************************
......@@ -227,7 +227,7 @@ protected:
/*!
* \brief Time in ms between two frames for the waiting screen.
*/
static const int DRAWING_TIMER_DEFAULT = 10;
static const int DRAWING_TIMER_DEFAULT;
/*!
* \brief Wait animation seconds per frame.
......
......@@ -10,7 +10,16 @@ Element_pos Svg::_wide_factor = 200.;
Element_pos Svg::_height_factor = 20.;
double Svg::_epsilon = 0.1;
double Svg::_scale_frequency = 50.;
const double Svg::_MARGINSTATE = 0.5;
const int Svg::_MARGIN = 10;
const int Svg::_ARROWSIZE = 2;
const int Svg::_MARGINTOP = 20;
const int Svg::_WAIT_NEW_CHRONO = 0;
const int Svg::_INIT = 1;
const int Svg::_WAIT_FOR_POINT = 2;
void Svg::init(const char *path){
......
......@@ -107,12 +107,12 @@ public:
/*!
* \brief Distance between two container
*/
static const int _MARGIN = 10;
static const int _MARGIN;
/*!
* \brief Spike size
*/
static const int _ARROWSIZE = 2;
static const int _ARROWSIZE;
/*!
......@@ -123,22 +123,22 @@ public:
/*!
* \brief offset between the top and the picture due to the scale
*/
static const int _MARGINTOP = 20;
static const int _MARGINTOP;
/*!
* \brief a State of chronogramme drawer automaton
*/
static const int _WAIT_NEW_CHRONO = 0;
static const int _WAIT_NEW_CHRONO;
/*!
* \brief a State of chronogramme drawer automaton
*/
static const int _INIT = 1;
static const int _INIT;
/*!
* \brief a State of chronogramme drawer automaton
*/
static const int _WAIT_FOR_POINT = 2;
static const int _WAIT_FOR_POINT;
/*!
......
......@@ -12,6 +12,9 @@ using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
const int Vbo::VBO_OK = 0;
const int Vbo::VBO_OUT_OF_MEMORY = 1;
const int Vbo::VBO_UNDEFINED_ERROR = 2;
......
......@@ -111,17 +111,17 @@ public:
/*!
* \brief Used to inform that data have been successfully added to graphic card.
*/
static const int VBO_OK = 0;
static const int VBO_OK;
/*!
* \brief Used to inform that the buffer is full and another VBO must be create.
*/
static const int VBO_OUT_OF_MEMORY = 1;
static const int VBO_OUT_OF_MEMORY;
/*!
* \brief Used to inform that an unidentified error occurs.
*/
static const int VBO_UNDEFINED_ERROR = 2;
static const int VBO_UNDEFINED_ERROR;
/*!
* \brief Fill the vertex buffer object.
......
......@@ -17,9 +17,6 @@
#include <iomanip>
#include<iostream>
// For dots or commas separator in double numbers
#include <locale.h>
/*!
*
......
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