Commit 8df75422 authored by Johnny Jazeix's avatar Johnny Jazeix

Débuggage pour mac.

parent 5627e8b5
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
using namespace std; using namespace std;
int TokenSource::_cursor = 0; int TokenSource::_cursor = 0;
#ifndef WIN32
off_t TokenSource::_filesize = 1; #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
#else
std::ifstream TokenSource::_file; std::ifstream TokenSource::_file;
#else
off_t TokenSource::_filesize = 1;
#endif #endif
TokenSource::TokenSource(){ TokenSource::TokenSource(){
...@@ -22,7 +23,7 @@ TokenSource::TokenSource(const char *filename){ ...@@ -22,7 +23,7 @@ TokenSource::TokenSource(const char *filename){
} }
TokenSource::~TokenSource(){ TokenSource::~TokenSource(){
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
_file.close(); _file.close();
#else #else
if (munmap(_buffer, _filesize) == -1){ if (munmap(_buffer, _filesize) == -1){
...@@ -37,7 +38,7 @@ void TokenSource::open(const char *filename){ ...@@ -37,7 +38,7 @@ void TokenSource::open(const char *filename){
_is_eof = false; _is_eof = false;
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
_file.open(filename, ios::in); _file.open(filename, ios::in);
fill_buffer(); fill_buffer();
#else #else
...@@ -62,7 +63,7 @@ void TokenSource::open(const char *filename){ ...@@ -62,7 +63,7 @@ void TokenSource::open(const char *filename){
#endif #endif
} }
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
bool TokenSource::fill_buffer() { bool TokenSource::fill_buffer() {
if (_file.eof()) { if (_file.eof()) {
return false; return false;
...@@ -78,7 +79,7 @@ bool TokenSource::fill_buffer() { ...@@ -78,7 +79,7 @@ bool TokenSource::fill_buffer() {
bool TokenSource::go_to_next_token() { bool TokenSource::go_to_next_token() {
while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t') { while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t') {
_cursor ++; _cursor ++;
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
if (_cursor >= _buffer_size) { if (_cursor >= _buffer_size) {
if (!fill_buffer()) { if (!fill_buffer()) {
return true; return true;
...@@ -96,7 +97,7 @@ bool TokenSource::go_to_next_token() { ...@@ -96,7 +97,7 @@ bool TokenSource::go_to_next_token() {
void TokenSource::build_composite_token() { void TokenSource::build_composite_token() {
_cursor ++; _cursor ++;
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
if (_cursor == _buffer_size) { if (_cursor == _buffer_size) {
if (!fill_buffer()) { if (!fill_buffer()) {
Error::set_and_print(Error::_FSTAT, Error::_WARNING); Error::set_and_print(Error::_FSTAT, Error::_WARNING);
...@@ -136,7 +137,7 @@ void TokenSource::build_simple_token() { ...@@ -136,7 +137,7 @@ void TokenSource::build_simple_token() {
} }
bool TokenSource::ensure_capacity() { bool TokenSource::ensure_capacity() {
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
if (_cursor >= _buffer_size) { if (_cursor >= _buffer_size) {
if (!fill_buffer()) { if (!fill_buffer()) {
_is_eof = true; _is_eof = true;
...@@ -203,7 +204,7 @@ std::string *TokenSource::read_token() { ...@@ -203,7 +204,7 @@ std::string *TokenSource::read_token() {
int TokenSource::get_size_loaded() { int TokenSource::get_size_loaded() {
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
if (_file == NULL) if (_file == NULL)
return 1; return 1;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "../message/Errors.hpp" #include "../message/Errors.hpp"
#ifdef WIN32 // They do not have mmap #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES) // They do not have mmap
#define BUFFER_SIZE 2048 #define BUFFER_SIZE 2048
#define WORD_SIZE 64 #define WORD_SIZE 64
#include <fstream> #include <fstream>
...@@ -32,7 +32,7 @@ class TokenSource{ ...@@ -32,7 +32,7 @@ class TokenSource{
private: private:
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
char _buffer[BUFFER_SIZE]; char _buffer[BUFFER_SIZE];
#else #else
char* _buffer; char* _buffer;
...@@ -43,7 +43,7 @@ private: ...@@ -43,7 +43,7 @@ private:
bool _is_eof; bool _is_eof;
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
int _buffer_size; int _buffer_size;
static std::ifstream _file; static std::ifstream _file;
#else #else
...@@ -52,7 +52,7 @@ private: ...@@ -52,7 +52,7 @@ private:
#endif #endif
#ifdef WIN32 #if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
bool fill_buffer(); bool fill_buffer();
#endif #endif
......
...@@ -10,6 +10,7 @@ Element_pos Svg::_wide_factor = 200.; ...@@ -10,6 +10,7 @@ Element_pos Svg::_wide_factor = 200.;
Element_pos Svg::_height_factor = 20.; Element_pos Svg::_height_factor = 20.;
double Svg::_epsilon = 0.1; double Svg::_epsilon = 0.1;
double Svg::_scale_frequency = 50.; double Svg::_scale_frequency = 50.;
const double Svg::_MARGINSTATE = 0.5;
void Svg::init(const char *path){ void Svg::init(const char *path){
...@@ -134,8 +135,8 @@ void Svg::display_time_scale() { ...@@ -134,8 +135,8 @@ void Svg::display_time_scale() {
_total_width = _total_time; _total_width = _total_time;
Element_pos w = _total_width*_wide_factor; Element_pos w = _total_width*_wide_factor;
Element_pos h = (MARGINTOP*1.0)/2; Element_pos h = (_MARGINTOP*1.0)/2;
Element_pos x = _container_width_max + MARGINSTATE; Element_pos x = _container_width_max + _MARGINSTATE;
Element_pos y = 0; Element_pos y = 0;
Element_col r = 255; Element_col r = 255;
...@@ -164,7 +165,7 @@ void Svg::display_time_scale() { ...@@ -164,7 +165,7 @@ void Svg::display_time_scale() {
for(Element_pos i = _start_interval_time ; i < _total_time ; i+=inc) { for(Element_pos i = _start_interval_time ; i < _total_time ; i+=inc) {
x = i*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor; x = i*_wide_factor + _container_width_max + _MARGINSTATE -_start_interval_time*_wide_factor;
_time_scale << "<text x='" << x <<"' y='" << y + h << "'>|"; _time_scale << "<text x='" << x <<"' y='" << y + h << "'>|";
_time_scale << i; _time_scale << i;
......
...@@ -9,18 +9,10 @@ ...@@ -9,18 +9,10 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include "render.hpp" #include "render.hpp"
#include "resource.hpp" #include "resource.hpp"
/*! /*!
* \brief This class provides a SVG display ,it inherited from the Render interface. * \brief This class provides a SVG display ,it inherited from the Render interface.
*/ */
...@@ -51,7 +43,7 @@ private: ...@@ -51,7 +43,7 @@ private:
/*! /*!
* \brief State of the chronogramme drawer automaton * \brief State of the chronogramme drawer automaton
* the automaton can be INIT, WAIT_FOR_POINT and WAIT_NEW_CHRONO * the automaton can be _INIT, _WAIT_FOR_POINT and _WAIT_NEW_CHRONO
*/ */
int _chronogramme_state; int _chronogramme_state;
...@@ -115,38 +107,38 @@ public: ...@@ -115,38 +107,38 @@ public:
/*! /*!
* \brief Distance between two container * \brief Distance between two container
*/ */
static const double MARGIN = 10.; static const int _MARGIN = 10;
/*! /*!
* \brief Spike size * \brief Spike size
*/ */
static const double ARROWSIZE = 2.; static const int _ARROWSIZE = 2;
/*! /*!
* \brief Distance between two states * \brief Distance between two states
*/ */
static const double MARGINSTATE = 0.5; static const double _MARGINSTATE;
/*! /*!
* \brief offset between the top and the picture due to the scale * \brief offset between the top and the picture due to the scale
*/ */
static const double MARGINTOP = 20.; static const int _MARGINTOP = 20;
/*! /*!
* \brief a State of chronogramme drawer automaton * \brief a State of chronogramme drawer automaton
*/ */
static const double WAIT_NEW_CHRONO = 0.; static const int _WAIT_NEW_CHRONO = 0;
/*! /*!
* \brief a State of chronogramme drawer automaton * \brief a State of chronogramme drawer automaton
*/ */
static const double INIT = 1.; static const int _INIT = 1;
/*! /*!
* \brief a State of chronogramme drawer automaton * \brief a State of chronogramme drawer automaton
*/ */
static const double WAIT_FOR_POINT = 2.; static const int _WAIT_FOR_POINT = 2;
/*! /*!
...@@ -378,9 +370,9 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c ...@@ -378,9 +370,9 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c
Element_pos xprime,yprime; Element_pos xprime,yprime;
/*positions are translated to MARGINTOP : the upper region reserved for scale*/ /*positions are translated to _MARGINTOP : the upper region reserved for scale*/
/*heights are grown by _height_factor : conversion from time in ms to pixel*/ /*heights are grown by _height_factor : conversion from time in ms to pixel*/
yprime = _height_factor*y + MARGINTOP; yprime = _height_factor*y + _MARGINTOP;
xprime = _height_factor*x; xprime = _height_factor*x;
_thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> "; _thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> ";
...@@ -408,7 +400,7 @@ inline void Svg::end_draw_states(){ ...@@ -408,7 +400,7 @@ inline void Svg::end_draw_states(){
*******************/ *******************/
inline void Svg::start_draw_counter(){ inline void Svg::start_draw_counter(){
_chronogramme_state = INIT; _chronogramme_state = _INIT;
} }
...@@ -418,32 +410,32 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ ...@@ -418,32 +410,32 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
/*widths are widen by _wide_factor : conversion from time in ms to pixel*/ /*widths are widen by _wide_factor : conversion from time in ms to pixel*/
/*heights are grown by _height_factor : conversion from time in ms to pixel*/ /*heights are grown by _height_factor : conversion from time in ms to pixel*/
/*positions are translated to _container_width_max : the left region occupied by containers*/ /*positions are translated to _container_width_max : the left region occupied by containers*/
/*positions are translated to MARGINTOP : the upper region reserved for scale*/ /*positions are translated to _MARGINTOP : the upper region reserved for scale*/
/*whenever a time selection is set : positions are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ /*whenever a time selection is set : positions are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/
Element_pos xprime = x*_wide_factor + _container_width_max ; Element_pos xprime = x*_wide_factor + _container_width_max;
Element_pos yprime = y* _height_factor + MARGINTOP; Element_pos yprime = y* _height_factor + _MARGINTOP;
Element_pos switchvalue = _container_width_max; Element_pos switchvalue = _container_width_max;
if (_chronogramme_state == INIT) { if (_chronogramme_state == _INIT) {
if (xprime == switchvalue) { if (xprime == switchvalue) {
_chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor << " " << yprime; _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor << " " << yprime;
_chronogramme_state=WAIT_FOR_POINT; _chronogramme_state=_WAIT_FOR_POINT;
} }
else else
std::cerr<<"draw_counter not initialised"; std::cerr<<"draw_counter not initialised";
} }
else if (_chronogramme_state == WAIT_FOR_POINT) { else if (_chronogramme_state == _WAIT_FOR_POINT) {
if (xprime == switchvalue) { if (xprime == switchvalue) {
_chronogramme << "'/>"; _chronogramme << "'/>";
_svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size()); _svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size());
_chronogramme.str(""); _chronogramme.str("");
_chronogramme_state=WAIT_NEW_CHRONO; _chronogramme_state=_WAIT_NEW_CHRONO;
} }
else { else {
if (_end_interval_time && x > _end_interval_time) if (_end_interval_time && x > _end_interval_time)
...@@ -460,10 +452,10 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ ...@@ -460,10 +452,10 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
} }
else if (_chronogramme_state==WAIT_NEW_CHRONO) { else if (_chronogramme_state==_WAIT_NEW_CHRONO) {
if (xprime==switchvalue) { if (xprime==switchvalue) {
_chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor<< " " << yprime; _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor<< " " << yprime;
_chronogramme_state=WAIT_FOR_POINT; _chronogramme_state=_WAIT_FOR_POINT;
} }
else else
std::cerr<<"draw_counter not initialised"; std::cerr<<"draw_counter not initialised";
...@@ -475,7 +467,7 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ ...@@ -475,7 +467,7 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
} }
inline void Svg::end_draw_counter() { inline void Svg::end_draw_counter() {
if (_chronogramme_state!=WAIT_NEW_CHRONO && _chronogramme_state!=INIT) if (_chronogramme_state!=_WAIT_NEW_CHRONO && _chronogramme_state!=_INIT)
std::cerr<<"draw_counter not un-initialised"; std::cerr<<"draw_counter not un-initialised";
} }
...@@ -583,21 +575,21 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_ ...@@ -583,21 +575,21 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
/*width are widen by _wide_factor : conversion from time in ms to pixel*/ /*width are widen by _wide_factor : conversion from time in ms to pixel*/
/*heights are grown by _height_factor : conversion from time in ms to pixel*/ /*heights are grown by _height_factor : conversion from time in ms to pixel*/
/*positions are translated to _container_width_max : the left region occupied by containers*/ /*positions are translated to _container_width_max : the left region occupied by containers*/
/*positions are translated to MARGINTOP : the upper region reserved for scale*/ /*positions are translated to _MARGINTOP : the upper region reserved for scale*/
/*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ /*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/
Element_pos x1=start_timeprime*_wide_factor + _container_width_max -_start_interval_time*_wide_factor ; Element_pos x1=start_timeprime*_wide_factor + _container_width_max -_start_interval_time*_wide_factor ;
Element_pos y1=start_heightprime* _height_factor + MARGINTOP; Element_pos y1=start_heightprime* _height_factor + _MARGINTOP;
Element_pos x2=end_timeprime*_wide_factor+ _container_width_max -_start_interval_time*_wide_factor; Element_pos x2=end_timeprime*_wide_factor+ _container_width_max -_start_interval_time*_wide_factor;
Element_pos y2=end_heightprime* _height_factor + MARGINTOP; Element_pos y2=end_heightprime* _height_factor + _MARGINTOP;
/*an arrow :*/ /*an arrow :*/
Svg::line("arrow",x1 ,y1 ,x2,y2); Svg::line("arrow",x1 ,y1 ,x2,y2);
if (!trunc) if (!trunc)
Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2); Svg::triangle("arrow",x2 ,y2+_ARROWSIZE,x2 ,y2-_ARROWSIZE,x2+_ARROWSIZE,y2);
} }
...@@ -616,10 +608,10 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const ...@@ -616,10 +608,10 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
} }
/*parameters are grown : conversion from time in ms to pixel*/ /*parameters are grown : conversion from time in ms to pixel*/
/*positions are translated to MARGINTOP : the upper region reserved for scale*/ /*positions are translated to _MARGINTOP : the upper region reserved for scale*/
wprime = _height_factor*w; wprime = _height_factor*w;
hprime = _height_factor*h; hprime = _height_factor*h;
yprime = _height_factor*y + MARGINTOP; yprime = _height_factor*y + _MARGINTOP;
xprime = _height_factor*x; xprime = _height_factor*x;
...@@ -628,7 +620,7 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const ...@@ -628,7 +620,7 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
_container_width_max = std::max(wprime+xprime+ MARGIN,_container_width_max); _container_width_max = std::max(wprime+xprime+ _MARGIN,_container_width_max);
_container_height_min = std::min(hprime,_container_height_min); _container_height_min = std::min(hprime,_container_height_min);
} }
...@@ -677,15 +669,15 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con ...@@ -677,15 +669,15 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
/*states are widen by _wide_factor : conversion from time in ms to pixel*/ /*states are widen by _wide_factor : conversion from time in ms to pixel*/
/*states are grown by _height_factor : conversion from time in ms to pixel*/ /*states are grown by _height_factor : conversion from time in ms to pixel*/
/*states are translated to _container_width_max : the left region occupied by containers*/ /*states are translated to _container_width_max : the left region occupied by containers*/
/*states are translated to MARGINSTATE : the margin between two container*/ /*states are translated to _MARGINSTATE : the margin between two container*/
/*states are translated to MARGINTOP : the upper region reserved for scale*/ /*states are translated to _MARGINTOP : the upper region reserved for scale*/
/*states height is not the specified parameter : container_height_min replaces height which enable the state to have an uniform size */ /*states height is not the specified parameter : container_height_min replaces height which enable the state to have an uniform size */
/*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ /*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/
w = endprime*_wide_factor-startprime*_wide_factor; w = endprime*_wide_factor-startprime*_wide_factor;
h = _container_height_min; h = _container_height_min;
x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor; x = (startprime )*_wide_factor + _container_width_max + _MARGINSTATE -_start_interval_time*_wide_factor;
y = level* _height_factor + MARGINTOP; y = level* _height_factor + _MARGINTOP;
if(w < _epsilon){ if(w < _epsilon){
...@@ -719,7 +711,7 @@ inline void Svg::draw_event(const Element_pos time, const Element_pos height, c ...@@ -719,7 +711,7 @@ inline void Svg::draw_event(const Element_pos time, const Element_pos height, c
_total_time = std::max( _total_time,time); _total_time = std::max( _total_time,time);
Svg::rectangle("event",MARGINSTATE,_container_height_min, time + _container_width_max -_start_interval_time*_wide_factor, height + MARGINTOP, 0x17, 0x60, 0xe7); Svg::rectangle("event",_MARGINSTATE,_container_height_min, time + _container_width_max -_start_interval_time*_wide_factor, height + _MARGINTOP, 0x17, 0x60, 0xe7);
} }
......
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