Commit a198b35f authored by Pascal Noisette's avatar Pascal Noisette

export container ok

parent d2bd1d36
......@@ -4,6 +4,8 @@ using namespace std;
void Svg::init(const char *path){
container_width_max = 0;
container_height_min = 1280;
_svg_file.open(path , std::ofstream::out | std::ofstream::trunc);
if (_svg_file.is_open()==false){
......@@ -26,7 +28,7 @@ void Svg::init(const char *path){
_buffer << "<?xml version='1.0' encoding='utf-8' standalone='no'?>\n"
<< "<!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' width='1280' height='728' id='svg2' style='background-color:#c1e9ed;' >\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\t{\n"
......
......@@ -7,7 +7,7 @@
#include <fstream>
#define BUFFER_SIZE 10 //character number stored before flush the _buffer
#define LEVEL 110 //distance between two containers
#define LEVEL 20 //distance between two containers
#define MARGIN 10 //distance between two object
#define ARROWSIZE 4 //spike size
......@@ -15,10 +15,14 @@
#define INIT 1
#define WAIT_FOR_POINT 2
#include "render.hpp"
#include "resource.hpp"
#define max(a,b) (a>b?a:b);
#define min(a,b) (a>b?b:a);
class Svg : public Render{
......@@ -28,6 +32,9 @@ private:
std::ostringstream _chronogramme;
int _chronogramme_state;
std::ofstream _svg_file;
Element_pos container_width_max;
Element_pos container_height_min;
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 );
inline void line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2);
......@@ -134,6 +141,8 @@ inline void Svg::start_draw_counter(){
inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
std::cout<<"s.draw_counter("<<x<<","<<y<<");\n";
if (_chronogramme_state==INIT)
{
if (x==0)
......@@ -231,22 +240,45 @@ 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){
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
std::cout<<"s.draw_arrow("<<start_time<<","<<end_time<<","<<start_height<<","<< end_height<<");\n";
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
}
inline void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
Svg::rectangle("container",w, h, x, y, 0xff, 0x44, 0xcc);
Element_pos xprime,yprime,wprime,hprime;
wprime = LEVEL*w;
hprime = LEVEL*h;
yprime = LEVEL*y;
xprime = LEVEL*x;
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);
}
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("state",end-start,LEVEL - MARGIN, start,level*LEVEL,r , g, 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);
}
inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
Svg::rectangle("event",MARGIN,container_height, time, height, 0xff, 0xff, 0xff);
std::cout<<"s.draw_event("<<time<<","<< height<<","<<container_height<<");\n";
Svg::rectangle("event",MARGIN,container_height, time + container_width_max , height, 0xff, 0xff, 0xff);
}
#endif // RENDER_SVG
This diff is collapsed.
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