Commit e28f6ab2 authored by Pascal Noisette's avatar Pascal Noisette

No commit message

No commit message
parent e8c7e405
......@@ -47,7 +47,7 @@ void Svg::init(const char *path){
}
void Svg::end(){
_buffer << "</svg>";
_buffer << "\n</svg>";
_svg_file.write(_buffer.str().c_str(), _buffer.str().size());
_buffer.flush();
_svg_file.close();
......
......@@ -28,9 +28,9 @@ private:
std::ostringstream _buffer;
std::ofstream _svg_file;
inline void print();
inline void rectangle(unsigned long w, unsigned long h,unsigned long x1,unsigned long y1, unsigned int r, unsigned int g, unsigned int b );
inline void line( long unsigned int x1, long unsigned int y1, long unsigned int x2, long unsigned int y2);
inline void triangle(unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3);
inline void rectangle(const char* name,unsigned long w, unsigned long h,unsigned long x1,unsigned long y1, unsigned int r, unsigned int g, unsigned int b );
inline void line(const char* name, long unsigned int x1, long unsigned int y1, long unsigned int x2, long unsigned int y2);
inline void triangle(const char* name,unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3);
public:
/*!
* \brief SVG header buiding
......@@ -138,8 +138,8 @@ inline void Svg::end_draw_counter(){
inline void Svg::end_draw(){
}
void Svg::rectangle(unsigned long w, unsigned long h,unsigned long x1,unsigned long y1, unsigned int r, unsigned int g, unsigned int b ){
_buffer << "<rect title='container' width='" << w
void Svg::rectangle(const char* name,unsigned long w, unsigned long h,unsigned long x1,unsigned long y1, unsigned int r, unsigned int g, unsigned int b ){
_buffer << "\n<rect title='"<<name<<"' width='" << w
<<"' height='"<< h
<<"' x='" << x1
<<"' y='" << y1
......@@ -152,8 +152,8 @@ void Svg::rectangle(unsigned long w, unsigned long h,unsigned long x1,unsigned l
void Svg::triangle(unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3){
_buffer << "<polyline title='triangle' class='triangle' points='"
void Svg::triangle(const char* name,unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3){
_buffer << "\n<polyline title='"<<name<<"' class='triangle' points='"
<< x1 << "," << y1
<< " " << x2 << "," << y2
<< " " << x3 << "," << y3
......@@ -172,8 +172,8 @@ void Svg::print(){
inline void Svg::line( long unsigned int x1, long unsigned int y1, long unsigned int x2, long unsigned int y2){
_buffer << "<line title='line' x1='" << x1
inline void Svg::line(const char* name, long unsigned int x1, long unsigned int y1, long unsigned int x2, long unsigned int y2){
_buffer << "\n<line title='"<<name<<"' x1='" << x1
<<"' y1='" << y1
<<"' x2='" << x2
<<"' y2='" << y2
......@@ -182,22 +182,22 @@ inline void Svg::line( long unsigned int x1, long unsigned int y1, long unsigned
}
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){
Svg::line(start_time,start_height,end_time,end_height);
Svg::triangle(end_time,end_height+ARROWSIZE,end_time,end_height-ARROWSIZE,end_time+ARROWSIZE,end_height);//spike
Svg::line("arrow",start_time,start_height,end_time,end_height);
Svg::triangle("arrow",end_time,end_height+ARROWSIZE,end_time,end_height-ARROWSIZE,end_time+ARROWSIZE,end_height);//spike
}
inline void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
Svg::rectangle(w, h, x, y, 0xff, 0x44, 0xcc);
Svg::rectangle("container",w, h, x, y, 0xff, 0x44, 0xcc);
}
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){
Svg::rectangle(end-start,LEVEL - MARGIN, start,level*LEVEL,r , g, b);
Svg::rectangle("state",end-start,LEVEL - MARGIN, start,level*LEVEL,r , g, b);
}
inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
rectangle(1,container_height*LEVEL, time, container_height, 0xff, 0x44, 0xcc);
//rectangle(1,container_height*LEVEL, time, container_height, 0xff, 0x44, 0xcc);
}
#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