diff --git a/interface/src/render_svg.cpp b/interface/src/render_svg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3e89d94a6e36784b63f6200022dcbea9af62bb6 --- /dev/null +++ b/interface/src/render_svg.cpp @@ -0,0 +1,57 @@ +#include "render_svg.hpp" + + + + void Svg::rectangle() + { + sprintf(_conteneur,"<rect title='container' width='%ld' height='%ld' x='%ld' y='%ld' fill='rgb(%d,%d,%d)' />",_w, _h, _x,_y,_r,_g,_b); + afficher(_conteneur); + } + + void Svg::afficher(char* s) + { + printf(s); + } + + void Svg::init() + { + char * entete = "<?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'>\n\t<style type='text/css' id='stylecss' >\n\t\trect:hover\n\t\t\t{\n\t\t\t\tfill:#8fbbd0;\n\t\t\t}\n\t</style>\n\t<desc>Rectangles</desc>\n"; + afficher(entete); + + } + + void Svg::end() + { + char* end_of_document = "</svg>"; + afficher(end_of_document); + } + + void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) + { + _r=47; + _g=54; + _b=153; + _w=(unsigned long)w; + _h=(unsigned long)h; + _x=(unsigned long)x; + _y=(unsigned long)y; + rectangle(); + + + } + + 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)100; + _x=(unsigned long)start; + _y=(unsigned long)50; + rectangle(); + + + } diff --git a/interface/src/render_svg.hpp b/interface/src/render_svg.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b47a0ae966d104c61dfd1d424c772547c717e8a1 --- /dev/null +++ b/interface/src/render_svg.hpp @@ -0,0 +1,56 @@ +#ifndef RENDER_SGV +#define RENDER_SVG + +#include <stdio.h> + +typedef long Element_count ; +typedef double Element_pos; +typedef double Element_col; + + +class Svg{ + + + private: + + char _conteneur[2048]; + unsigned char _r,_g,_b; + unsigned long _x,_y,_w,_h; + + void afficher(char*s); + void rectangle(); + + public: + /*! + * \brief SVG header buiding + */ + void init(); + + /*! + * \brief SVG bottom file buiding + */ + void end(); + + + /*! + * \brief Draw a container according to the parameters + * \param x the x position of the container + * \param y the y position of the container + * \param w the width of the container + * \param h the height of the container + */ + void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) ; + + /*! + * \brief Draw a state of the trace. + * \param r the red color rate of the state. + * \param g the green color rate of the state. + * \param b the blue color rate of the state. + * \param start the beginning time of the state. + * \param end the ending time of the state. + * \param level refer to the container which state belongs to. + */ + void 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) ; + }; + +#endif// RENDER_SGV diff --git a/interface/tests/makefile b/interface/tests/makefile new file mode 100644 index 0000000000000000000000000000000000000000..4b11b4e7dce95f67d75402365997dd4cc8af2bfe --- /dev/null +++ b/interface/tests/makefile @@ -0,0 +1,8 @@ +test_svg.o: test_svg.cpp + g++ -c -g -Wall test_svg.cpp -o test_svg.o + +render_svg.o: ../src/render_svg.cpp ../src/render_svg.hpp + g++ -c -g -Wall ../src/render_svg.cpp -o render_svg.o + +test_svg: test_svg.o render_svg.o + g++ -g -Wall render_svg.o test_svg.o -o test_svg \ No newline at end of file diff --git a/interface/tests/test_svg.cpp b/interface/tests/test_svg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d73412cfb4a323a61ed5578dd1cef7d0f966d320 --- /dev/null +++ b/interface/tests/test_svg.cpp @@ -0,0 +1,17 @@ +#include <iostream> +#include "../src/render_svg.hpp" +using namespace std; + +int main() +{ + + + Svg s; + s.init(); + s.draw_container(0,100,100,100); + s.draw_state(0 , 150, 0, 50,50,50); + s.draw_state(400, 750, 0, 0xff,0xcc,33); + s.end(); + + return 0; +}