Commit a4deed1b authored by Pascal Noisette's avatar Pascal Noisette

No commit message

No commit message
parent aac0b3bf
......@@ -2,57 +2,46 @@
using namespace std;
void Svg::rectangle(){
_buffer << "<rect title='container' width='" << _w
<<"' height='"<< _h
<<"' x='" << _x1
<<"' y='" << _y1
<<"' fill='rgb("<<_r<<","<<_g<<","<<_b
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
<<"' height='"<< h
<<"' x='" << x1
<<"' y='" << y1
<<"' fill='rgb("<<r<<","<<g<<","<<b
<<")'/>";
print();
}
void Svg::line(){
_buffer << "<line title='line' x1='" << _x1
<<"' y1='" << _y1
<<"' x2='" << _x2
<<"' y2='" << _y2
void Svg::line(unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2){
_buffer << "<line title='line' x1='" << x1
<<"' y1='" << y1
<<"' x2='" << x2
<<"' y2='" << y2
<<"' />";
print();
}
void Svg::triangle(){
_buffer << "<polyline title='triangle' class='triangle' points='"
<< _x1 << "," << _y1
<< " " << _x2 << "," << _y2
<< " " << _x3 << "," << _y3
<<"' />";
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='"
<< x1 << "," << y1
<< " " << x2 << "," << y2
<< " " << x3 << "," << y3
<<"' />";
print();
}
void Svg::print(){
if (_buffer.str().size()>BUFFER_SIZE){
_svg_file.write(_buffer.str().c_str(), _buffer.str().size());
_buffer.flush();
}
}
void Svg::init(const char *path){
_svg_file.open(path , ofstream::out | ofstream::trunc);
if (_svg_file.is_open()==false){
std::cerr<<"unable to open file";
}
......@@ -84,49 +73,16 @@ void Svg::end(){
_buffer.flush();
_svg_file.close();
}
void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
_r=0xff;
_g=0x44;
_b=0xcc;
_w=(unsigned long)w;
_h=(unsigned long)h;
_x1=(unsigned long)x;
_y1=(unsigned long)y;
rectangle();
void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
rectangle(w, h, x, y, 0xff, 0x44, 0xcc);
}
void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){
_x1=(unsigned long)start_time;
_x2=(unsigned long)end_time;
_y1=(unsigned long)start_height;
_y2=(unsigned long)end_height;
line();
_x1=(unsigned long)end_time;
_x2=(unsigned long)end_time;
_x3=(unsigned long)end_time+ARROWSIZE;
_y1=(unsigned long)end_height+ARROWSIZE;
_y2=(unsigned long)end_height-ARROWSIZE;
_y3=(unsigned long)end_height;
triangle();//spike
line(start_time,start_height,end_time,end_height);
triangle(end_time,end_height+ARROWSIZE,end_time,end_height-ARROWSIZE,end_time+ARROWSIZE,end_height);//spike
}
void Svg::draw_state(const Element_pos start , const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b){
_r=(unsigned char)r;
_g=(unsigned char)g;
_b=(unsigned char)b;
_w=(unsigned long)(end-start);
_h=(unsigned long)LEVEL - MARGIN;
_x1=(unsigned long)start;
_y1=(unsigned long)level*LEVEL;
rectangle();
rectangle(end-start,LEVEL - MARGIN, start,level*LEVEL,r , g, b);
}
......@@ -12,7 +12,7 @@
#define ARROWSIZE 4 //spike size
typedef unsigned long Element_count ;
typedef double Element_pos;
typedef unsigned long Element_pos;
typedef unsigned char Element_col;
......@@ -21,16 +21,11 @@ class Svg{
private:
std::ostringstream _buffer;
std::string _object_class;
std::ofstream _svg_file;
unsigned int _r,_g,_b; // 0 < _r,_g,_b < 255 and displayed as int
unsigned long _w,_h;
unsigned long _x1,_y1,_x2,_y2,_x3,_y3;
inline void print();
inline void rectangle();
inline void line();
inline void triangle();
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(unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2);
inline void triangle(unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3);
public:
/*!
* \brief SVG header buiding
......
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