Commit 2ba2b008 authored by Pascal Noisette's avatar Pascal Noisette

-precision à 0.001

-changer avec -epsilon=double
-appel de set_acuracy

parent f7e2c900
......@@ -4,9 +4,11 @@ using namespace std;
void Svg::init(const char *path){
container_width_max = 0;
debug_counter=0;
container_height_min = 1280;
_container_width_max = 0;
_debug_counter=0;
_container_height_min = 1280;
_epsilon = 0.001;
_svg_file.open(path , std::ofstream::out | std::ofstream::trunc);
if (_svg_file.is_open()==false){
......@@ -87,4 +89,7 @@ void Svg::end(){
}
void Svg::set_accuracy(double epsilon){
_epsilon = epsilon;
}
......@@ -35,9 +35,10 @@ private:
std::ostringstream _chronogramme;
int _chronogramme_state;
std::ofstream _svg_file;
Element_pos container_width_max;
Element_pos container_height_min;
int debug_counter;
Element_pos _container_width_max;
Element_pos _container_height_min;
int _debug_counter;
double _epsilon;
inline void print();
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 );
......@@ -94,11 +95,13 @@ public:
void start_draw_counter();
void draw_counter(const Element_pos x, const Element_pos y);
void draw_counter(const Element_pos x, const Element_pos y);
void end_draw_counter();
void end_draw();
void set_accuracy(double epsilon);
};
......@@ -255,11 +258,11 @@ inline void Svg::line(const char* name, Element_pos x1, Element_pos y1, Element_
inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
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 x2=(end_time)*WIDE+ container_width_max;
Element_pos x2=(end_time)*WIDE+ _container_width_max;
Element_pos y2=end_height*LEVEL;
......@@ -278,12 +281,12 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
yprime = LEVEL*y;
xprime = LEVEL*x;
std::cout<<"s.draw_container("<<x<<","<<y<<","<<w<<","<< h<<");\n";
//std::cout<<"s.draw_container("<<x<<","<<y<<","<<w<<","<< h<<");\n";
Svg::rectangle("container",wprime, hprime, xprime, yprime, 0xff, 0x44, 0xcc);
container_width_max = max(wprime+xprime+ MARGIN,container_width_max);
container_height_min = min(hprime,container_height_min);
_container_width_max = max(wprime+xprime+ MARGIN,_container_width_max);
_container_height_min = min(hprime,_container_height_min);
}
......@@ -294,25 +297,28 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
Element_pos w =end*WIDE-start*WIDE;
Element_pos h = container_height_min;
Element_pos x = (start )*WIDE+ container_width_max + MARGINSTATE;
Element_pos h = _container_height_min;
Element_pos x = (start )*WIDE+ _container_width_max + MARGINSTATE;
Element_pos y = level*LEVEL;
if(w==0){
if(w<_epsilon){
//std::cerr<<"state width is null";
return;
}
if( debug_counter++<1000)
std::cout<<"s.draw_state("<<start<<","<<end<<","<<level<<","<< height<<","<<r<<","<<g<<","<< b <<");\n";
// if( debug_counter++<1000)
// std::cout<<"s.draw_state("<<start<<","<<end<<","<<level<<","<< height<<","<<r<<","<<g<<","<< b <<");\n";
Svg::rectangle("state",w,h, x,y,r*255 , g*255, b*255);
}
inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
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, 0x17, 0x60, 0xe7);
}
#endif // RENDER_SVG
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