Commit 83334493 authored by Pascal Noisette's avatar Pascal Noisette

svg : largeur pour confort visuel, fleche ok, state ok, probleme de state de...

svg : largeur pour confort visuel, fleche ok, state ok, probleme de state de longueur nulle, probleme de svg de 100Mo (requiert 1,5Go de ram à l'ouverture avec interprete firefox
parent a198b35f
......@@ -5,6 +5,7 @@ using namespace std;
void Svg::init(const char *path){
container_width_max = 0;
debug_counter=0;
container_height_min = 1280;
_svg_file.open(path , std::ofstream::out | std::ofstream::trunc);
......@@ -30,33 +31,48 @@ void Svg::init(const char *path){
<< "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>\n"
<< "<svg xmlns='http://www.w3.org/2000/svg' x='0' y='0' id='svg2' style='background-color:#c1e9ed;' >\n"
<< "\t<style type='text/css' id='stylecss' >\n"
<< "\t\trect:hover\n"
<< "\t\t#undef\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:#8fbbd0;\n"
<< "\t\t\t\tfill:url(#Degrade);\n"
<< "\t\t\t}\n"
<< "\t\tline\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:white;stroke:black;stroke-width:1\n"
<< "\t\t\t\tfill:#f8c71b;stroke:#f8c71b;stroke-width:1\n"
<< "\t\t\t}\n"
<< "\t\t#triangle\n"
<< "\t\tpolyline\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:black;stroke:black;stroke-width:1\n"
<< "\t\t\t\tfill:#f8c71b;stroke:#f8c71b;stroke-width:1\n"
<< "\t\t\t}\n"
<< "\t\tpath\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:none;stroke:green;stroke-width:1\n"
<< "\t\t\t}\n"
<< "\t</style>\n"
<< "\t<desc>Rectangles</desc>\n";
<< "\t<desc>Rectangles</desc>\n"
<< "<g>"
<< "<defs>"
<< "<linearGradient id='Degrade'>"
<< "<stop offset='5%' stop-color='#F60' />"
<< "<stop offset='95%' stop-color='#FF6' />"
<< "</linearGradient>"
<< "</defs>";
print();
}
void Svg::end(){
_buffer << "\n</svg>";
_svg_file.write(_buffer.str().c_str(), _buffer.str().size());
_buffer.flush();
_buffer.str("");
_thin_element_buffer << "\n</g></svg>";
_svg_file.write(_thin_element_buffer.str().c_str(), _thin_element_buffer.str().size());
_thin_element_buffer.flush();
_thin_element_buffer.str("");
_svg_file.close();
#ifdef TEST_SVG_MODE
......
......@@ -9,7 +9,9 @@
#define BUFFER_SIZE 10 //character number stored before flush the _buffer
#define LEVEL 20 //distance between two containers
#define MARGIN 10 //distance between two object
#define ARROWSIZE 4 //spike size
#define ARROWSIZE 2 //spike size
#define WIDE 20
#define MARGINSTATE 0.5
#define WAIT_NEW_CHRONO 0
#define INIT 1
......@@ -29,11 +31,13 @@ class Svg : public Render{
private:
std::ostringstream _buffer;
std::ostringstream _thin_element_buffer;
std::ostringstream _chronogramme;
int _chronogramme_state;
std::ofstream _svg_file;
Element_pos container_width_max;
Element_pos container_height_min;
int debug_counter;
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 );
......@@ -199,7 +203,7 @@ inline void Svg::end_draw(){
}
void Svg::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 ){
_buffer << "\n<rect title='"<<name<<"' width='" << w
_buffer << "\n<rect class='"<<name<<"' title='"<<name<<"' width='" << w
<<"' height='"<< h
<<"' x='" << x1
<<"' y='" << y1
......@@ -213,12 +217,12 @@ void Svg::rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1
void Svg::triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3){
_buffer << "\n<polyline title='"<<name<<"' class='triangle' points='"
_thin_element_buffer << "\n<polyline title='"<<name<<"' class='triangle' points='"
<< x1 << "," << y1
<< " " << x2 << "," << y2
<< " " << x3 << "," << y3
<<"' />";
print();
}
void Svg::print(){
......@@ -231,7 +235,7 @@ void Svg::print(){
inline void Svg::line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2){
_buffer << "\n<line title='"<<name<<"' x1='" << x1
_thin_element_buffer << "\n<line title='"<<name<<"' x1='" << x1
<<"' y1='" << y1
<<"' x2='" << x2
<<"' y2='" << y2
......@@ -243,9 +247,16 @@ 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";
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 y2=end_height*LEVEL;
Svg::line("arrow",x1 ,y1 ,x2,y2);
Svg::line("arrow",start_time+ container_width_max ,start_height,end_time+ container_width_max ,end_height);
Svg::triangle("arrow",end_time+ container_width_max ,end_height+ARROWSIZE,end_time+ container_width_max ,end_height-ARROWSIZE,end_time+ARROWSIZE+ container_width_max ,end_height);//spike
Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2);//spike
}
inline void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
......@@ -268,17 +279,30 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
inline void Svg::draw_state(const Element_pos start , const Element_pos end, const Element_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b){
std::cout<<"s.draw_state("<<start<<","<<end<<","<<level<<","<< height<<","<<r<<","<<g<<","<< b <<");\n";
Svg::rectangle("state",end-start, container_height_min, start + container_width_max ,level*LEVEL,r , g, b);
Element_pos w =end*WIDE-start*WIDE;
Element_pos h = container_height_min;
Element_pos x = (start )*WIDE+ container_width_max + MARGINSTATE;
Element_pos y = level*LEVEL;
if(w==0){
//std::cerr<<"state width is null";
return;
}
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 , g, b);
}
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";
Svg::rectangle("event",MARGIN,container_height, time + container_width_max , height, 0xff, 0xff, 0xff);
Svg::rectangle("event",MARGIN,container_height, time + container_width_max , height, 0x17, 0x60, 0xe7);
}
#endif // RENDER_SVG
This source diff could not be displayed because it is too large. You can view the blob instead.
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