Mentions légales du service

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

makefile test svg

parent 54bb59b0
No related branches found
No related tags found
No related merge requests found
...@@ -2,46 +2,8 @@ ...@@ -2,46 +2,8 @@
using namespace std; using namespace std;
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(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(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){ void Svg::init(const char *path){
_svg_file.open(path , ofstream::out | ofstream::trunc); _svg_file.open(path , std::ofstream::out | std::ofstream::trunc);
if (_svg_file.is_open()==false){ if (_svg_file.is_open()==false){
std::cerr<<"unable to open file"; std::cerr<<"unable to open file";
} }
...@@ -73,16 +35,3 @@ void Svg::end(){ ...@@ -73,16 +35,3 @@ void Svg::end(){
_buffer.flush(); _buffer.flush();
_svg_file.close(); _svg_file.close();
} }
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){
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_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b){
rectangle(end-start,LEVEL - MARGIN, start,level*LEVEL,r , g, b);
}
...@@ -29,7 +29,7 @@ private: ...@@ -29,7 +29,7 @@ private:
std::ofstream _svg_file; std::ofstream _svg_file;
inline void print(); 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 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 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 triangle(unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3);
public: public:
/*! /*!
...@@ -80,6 +80,7 @@ public: ...@@ -80,6 +80,7 @@ public:
void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height); void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height);
void end_draw(); void end_draw();
}; };
...@@ -114,11 +115,70 @@ inline void Svg::start_draw_states(){ ...@@ -114,11 +115,70 @@ inline void Svg::start_draw_states(){
inline void Svg::end_draw_states(){ inline void Svg::end_draw_states(){
} }
inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
}
inline void Svg::end_draw(){ 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
<<"' height='"<< h
<<"' x='" << x1
<<"' y='" << y1
<<"' fill='rgb("<<r<<","<<g<<","<<b
<<")'/>";
print();
}
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();
}
}
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
<<"' y1='" << y1
<<"' x2='" << x2
<<"' y2='" << y2
<<"' />";
print();
}
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
}
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);
}
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);
}
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);
}
#endif // RENDER_SVG #endif // RENDER_SVG
test_svg.o : test_svg.cpp
render_svg.o: ../../src/interface/render_svg.cpp ../../src/interface/render_svg.hpp
g++ -g -c -Wall ../../src/interface/render_svg.cpp -o render_svg.o
test_svg : render_svg.o test_svg.o
g++ -g -o test_svg render_svg.o test_svg.o
\ No newline at end of file
#include "../src/render_svg.hpp" #include "../../src/interface/render_svg.hpp"
using namespace std; using namespace std;
int main() int main()
...@@ -13,9 +13,9 @@ int main() ...@@ -13,9 +13,9 @@ int main()
s.draw_container(0,LEVEL*2,50,100); s.draw_container(0,LEVEL*2,50,100);
s.draw_container(0,LEVEL*3,50,100); s.draw_container(0,LEVEL*3,50,100);
s.draw_state(100, 750, 1, 0xff,0xcc,33); s.draw_state(100, 750, 1,NULL, 0xff,0xcc,33);
s.draw_state(400, 750, 2, 0xff,0xcc,33); s.draw_state(400, 750, 2,NULL, 0xff,0xcc,33);
s.draw_state(70, 300, 3, 0xff,0xcc,33); s.draw_state(70, 300, 3,NULL, 0xff,0xcc,33);
s.draw_arrow(100,700,LEVEL*1,LEVEL*3); s.draw_arrow(100,700,LEVEL*1,LEVEL*3);
s.draw_arrow(200,400,LEVEL*2,LEVEL*2); s.draw_arrow(200,400,LEVEL*2,LEVEL*2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment