Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 03aa3e00 authored by Pascal Noisette's avatar Pascal Noisette
Browse files

display_time_scale() : affichera la regle de temps

parent 7e67be1e
No related branches found
No related tags found
No related merge requests found
/*!
* \brief This class provides to renderer, some statistics toward the input trace.
*/
#include "resource.hpp"
class StatInfo{
public:
Element_pos total_width;
Times total_time;
/*unused :*/
Element_count element_number;
Element_pos minimum_width;
Element_pos minimum_heigth;
Element_pos maximum_width;
Element_pos maximum_heigth;
};
...@@ -8,7 +8,7 @@ void Svg::init(const char *path){ ...@@ -8,7 +8,7 @@ void Svg::init(const char *path){
_debug_counter=0; _debug_counter=0;
_container_height_min = 1280; _container_height_min = 1280;
_epsilon = 0.1; _epsilon = 0.1;
_StatInfo_filled = false;
_svg_file.open(path , std::ofstream::out | std::ofstream::trunc); _svg_file.open(path , std::ofstream::out | std::ofstream::trunc);
if (_svg_file.is_open()==false){ if (_svg_file.is_open()==false){
...@@ -68,7 +68,8 @@ void Svg::init(const char *path){ ...@@ -68,7 +68,8 @@ void Svg::init(const char *path){
} }
void Svg::end(){ void Svg::end(){
_svg_file.write(_buffer.str().c_str(), _buffer.str().size()); _svg_file.write(_buffer.str().c_str(), _buffer.str().size());
_buffer.flush(); _buffer.flush();
_buffer.str(""); _buffer.str("");
...@@ -78,7 +79,7 @@ void Svg::end(){ ...@@ -78,7 +79,7 @@ void Svg::end(){
_chronogramme.flush(); _chronogramme.flush();
_chronogramme.str(""); _chronogramme.str("");
display_time_scale();
_thin_element_buffer << "\n</g></svg>"; _thin_element_buffer << "\n</g></svg>";
...@@ -102,3 +103,39 @@ void Svg::end(){ ...@@ -102,3 +103,39 @@ void Svg::end(){
void Svg::set_accuracy(double epsilon){ void Svg::set_accuracy(double epsilon){
_epsilon = epsilon; _epsilon = epsilon;
} }
void Svg::set_information(StatInfo &p){
_info = p;
_StatInfo_filled = true;
}
void Svg::display_time_scale()
{
if (!_StatInfo_filled)
{
std::cerr<< "no information filled : use Svg::set_information(StatInfo &p) before drawing" << endl;
return;
}
Element_pos w = _info.total_width*WIDE;
Element_pos h = MARGINTOP;
Element_pos x = _container_width_max + MARGINSTATE;
Element_pos y = 0;
Element_col r = 0;
Element_col g = 0;
Element_col b = 0;
_time_scale << "\n<rect class='scale' title='scale'"
<<"' width='" << w
<<"' height='"<< h
<<"' x='" << x
<<"' y='" << y
<<"' fill='rgb("<<r<<","<<g<<","<<b
<<")'/>";
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#define ARROWSIZE 2 //spike size #define ARROWSIZE 2 //spike size
#define WIDE 1000 #define WIDE 1000
#define MARGINSTATE 0.5 #define MARGINSTATE 0.5
#define MARGINTOP 20
#define WAIT_NEW_CHRONO 0 #define WAIT_NEW_CHRONO 0
#define INIT 1 #define INIT 1
#define WAIT_FOR_POINT 2 #define WAIT_FOR_POINT 2
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "render.hpp" #include "render.hpp"
#include "resource.hpp" #include "resource.hpp"
#include "StatInfo.hpp"
#define max(a,b) (a>b?a:b); #define max(a,b) (a>b?a:b);
#define min(a,b) (a>b?b:a); #define min(a,b) (a>b?b:a);
...@@ -33,9 +33,13 @@ class Svg : public Render{ ...@@ -33,9 +33,13 @@ class Svg : public Render{
private: private:
StatInfo _info;
bool _StatInfo_filled;
std::ostringstream _buffer; std::ostringstream _buffer;
std::ostringstream _thin_element_buffer; std::ostringstream _thin_element_buffer;
std::ostringstream _chronogramme; std::ostringstream _chronogramme;
std::ostringstream _time_scale;
int _chronogramme_state; int _chronogramme_state;
std::ofstream _svg_file; std::ofstream _svg_file;
Element_pos _container_width_max; Element_pos _container_width_max;
...@@ -44,6 +48,7 @@ private: ...@@ -44,6 +48,7 @@ private:
double _epsilon; double _epsilon;
inline void print(); inline void print();
void display_time_scale();
inline void rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1,Element_pos y1, unsigned int r, unsigned int g, unsigned int b ); inline void rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1,Element_pos y1, unsigned int r, unsigned int g, unsigned int b );
inline void line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2); inline void line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2);
inline void triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3); inline void triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3);
...@@ -104,12 +109,15 @@ public: ...@@ -104,12 +109,15 @@ public:
void end_draw_counter(); void end_draw_counter();
void end_draw(); void end_draw();
/*! /*!
* \brief Set the precision of SVG display. * \brief Set the precision of SVG display.
* \param epsilon Precision * \param epsilon Precision
*/ */
void set_accuracy(double epsilon); void set_accuracy(double epsilon);
void set_information(StatInfo &p);
}; };
...@@ -133,7 +141,7 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c ...@@ -133,7 +141,7 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c
Element_pos xprime,yprime; Element_pos xprime,yprime;
yprime = LEVEL*y; yprime = LEVEL*y + MARGINTOP;
xprime = LEVEL*x; xprime = LEVEL*x;
_thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> "; _thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> ";
...@@ -168,7 +176,7 @@ inline void Svg::start_draw_counter(){ ...@@ -168,7 +176,7 @@ inline void Svg::start_draw_counter(){
inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
Element_pos xprime = x*WIDE + _container_width_max ; Element_pos xprime = x*WIDE + _container_width_max ;
Element_pos yprime = y*LEVEL; Element_pos yprime = y*LEVEL + MARGINTOP;
Element_pos switchvalue = _container_width_max; Element_pos switchvalue = _container_width_max;
//std::cout<<"s.draw_counter("<<xprime<<","<<yprime<<");\n"; //std::cout<<"s.draw_counter("<<xprime<<","<<yprime<<");\n";
...@@ -223,7 +231,7 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ ...@@ -223,7 +231,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) if (_chronogramme_state!=WAIT_NEW_CHRONO && _chronogramme_state!=INIT)
std::cerr<<"draw_counter not un-initialised"; std::cerr<<"draw_counter not un-initialised";
} }
...@@ -278,9 +286,9 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_ ...@@ -278,9 +286,9 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
//std::cout<<"s.draw_arrow("<<start_time<<","<<end_time<<","<<start_height<<","<< end_height<<");\n"; //std::cout<<"s.draw_arrow("<<start_time<<","<<end_time<<","<<start_height<<","<< end_height<<");\n";
Element_pos x1=(start_time )*WIDE + _container_width_max ; Element_pos x1=(start_time )*WIDE + _container_width_max ;
Element_pos y1=start_height*LEVEL; Element_pos y1=start_height*LEVEL + MARGINTOP;
Element_pos x2=(end_time)*WIDE+ _container_width_max; Element_pos x2=(end_time)*WIDE+ _container_width_max;
Element_pos y2=end_height*LEVEL; Element_pos y2=end_height*LEVEL + MARGINTOP;
Svg::line("arrow",x1 ,y1 ,x2,y2); Svg::line("arrow",x1 ,y1 ,x2,y2);
...@@ -295,7 +303,7 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const ...@@ -295,7 +303,7 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
wprime = LEVEL*w; wprime = LEVEL*w;
hprime = LEVEL*h; hprime = LEVEL*h;
yprime = LEVEL*y; yprime = LEVEL*y + MARGINTOP;
xprime = LEVEL*x; xprime = LEVEL*x;
// std::cout<<"s.draw_container("<<x<<","<<y<<","<<w<<","<< h<<");\n"; // std::cout<<"s.draw_container("<<x<<","<<y<<","<<w<<","<< h<<");\n";
...@@ -316,7 +324,7 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con ...@@ -316,7 +324,7 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
Element_pos w =end*WIDE-start*WIDE; Element_pos w =end*WIDE-start*WIDE;
Element_pos h = _container_height_min; Element_pos h = _container_height_min;
Element_pos x = (start )*WIDE+ _container_width_max + MARGINSTATE; Element_pos x = (start )*WIDE+ _container_width_max + MARGINSTATE;
Element_pos y = level*LEVEL; Element_pos y = level*LEVEL + MARGINTOP;
if(w<_epsilon){ if(w<_epsilon){
//std::cerr<<"state width is null"; //std::cerr<<"state width is null";
...@@ -332,7 +340,7 @@ inline void Svg::draw_event(const Element_pos time, const Element_pos height, c ...@@ -332,7 +340,7 @@ inline void Svg::draw_event(const Element_pos time, const Element_pos height, c
// std::cout<<"s.draw_event("<<time<<","<< height<<","<<container_height<<");\n"; // std::cout<<"s.draw_event("<<time<<","<< height<<","<<container_height<<");\n";
Svg::rectangle("event",MARGIN,container_height, time + _container_width_max , height, 0x17, 0x60, 0xe7); Svg::rectangle("event",MARGIN,container_height, time + _container_width_max , height + MARGINTOP, 0x17, 0x60, 0xe7);
} }
......
...@@ -19,7 +19,7 @@ class Line{ ...@@ -19,7 +19,7 @@ class Line{
private: private:
std::vector<std::string> _tokens; std::vector<std::string> _tokens;
TokenSource _source; TokenSource::TokenSource _source;
bool _is_eof; bool _is_eof;
unsigned int _line_count; unsigned int _line_count;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment