render_svg.hpp 3.3 KB
Newer Older
1
#ifndef RENDER_SVG
2
#define RENDER_SVG
3 4


Pascal Noisette's avatar
Pascal Noisette committed
5 6 7
#include <iostream>
#include <sstream>
#include <fstream>
8

Pascal Noisette's avatar
Pascal Noisette committed
9 10
#define BUFFER_SIZE 2048 //character number stored before flush the _buffer
#define LEVEL 110        //distance between two containers
Pascal Noisette's avatar
Pascal Noisette committed
11 12
#define MARGIN 10        //distance between two object
#define ARROWSIZE 4      //spike size
13 14


15 16 17 18 19 20 21 22
#include "render.hpp"
#include "resource.hpp"


/*typedef unsigned long Element_count ;
typedef double Element_pos;
typedef unsigned char Element_col;
*/
23

24
class Svg : public Render{
25 26


27
private:
28 29
    std::ostringstream _buffer;
    std::ofstream _svg_file;
Pascal Noisette's avatar
Pascal Noisette committed
30
    inline void print();
Pascal Noisette's avatar
Pascal Noisette committed
31 32 33
    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);
34 35
public:
    /*!
36 37
     * \brief SVG header buiding
     */
38
    void init(const char *path);
39

40
    /*!
41 42
     * \brief SVG bottom file buiding
     */
43
    void end();
44

45 46
    void start_draw();
    void start_draw_containers();
47

48
    /*!
49 50 51 52 53 54
     * \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
     */
55 56
    void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) ;

57 58 59 60 61
    void draw_container_text(const Element_pos x, const Element_pos y, const std::string value);

    void end_draw_containers();
    void start_draw_states();

62 63 64 65 66 67 68 69 70
    /*!
     * \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.
     */
71
    void 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) ;
Pascal Noisette's avatar
Pascal Noisette committed
72 73 74 75 76 77 78

    /*!
    * \brief Draw an arrow
    *
    */
    void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height);

79 80 81 82 83
    void end_draw_states();

    void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height);

    void end_draw();
84 85
};

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123


/***********************************
 *
 *
 *
 * Drawing function for the trace.
 *
 *
 *
 **********************************/


inline void Svg::start_draw(){
}

inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){
}

inline void Svg::start_draw_containers(){
}

inline void Svg::end_draw_containers(){
}

inline void Svg::start_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(){
}


124
#endif // RENDER_SVG