Commit 03e92a41 authored by Pascal Noisette's avatar Pascal Noisette

retour ligne

parent d68ea3f4
......@@ -42,7 +42,7 @@ void Svg::init(const char *path){
<< "\t\t\t}\n"
<< "\t\tpath\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:green;stroke:black;stroke-width:1\n"
<< "\t\t\t\tfill:none;stroke:green;stroke-width:1\n"
<< "\t\t\t}\n"
<< "\t</style>\n"
<< "\t<desc>Rectangles</desc>\n";
......
......@@ -11,15 +11,14 @@
#define MARGIN 10 //distance between two object
#define ARROWSIZE 4 //spike size
#define WAIT_NEW_CHRONO 0
#define INIT 1
#define WAIT_FOR_POINT 2
#include "render.hpp"
#include "resource.hpp"
/*typedef unsigned long Element_count ;
typedef double Element_pos;
typedef unsigned char Element_col;
*/
class Svg : public Render{
......@@ -27,11 +26,12 @@ class Svg : public Render{
private:
std::ostringstream _buffer;
std::ostringstream _chronogramme;
int _chronogramme_state;
std::ofstream _svg_file;
inline void print();
inline void rectangle(const char* name,unsigned long w, unsigned long h,unsigned long x1,unsigned long y1, unsigned int r, unsigned int g, unsigned int b );
inline void line(const char* name, long unsigned int x1, long unsigned int y1, long unsigned int x2, long unsigned int y2);
inline void triangle(const char* name,unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3);
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);
inline void triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3);
public:
/*!
* \brief SVG header buiding
......@@ -111,6 +111,7 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c
}
inline void Svg::start_draw_containers(){
}
inline void Svg::end_draw_containers(){
......@@ -128,12 +129,59 @@ inline void Svg::end_draw_states(){
*******************/
inline void Svg::start_draw_counter(){
_chronogramme_state=INIT;
}
inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
if (_chronogramme_state==INIT)
{
if (x==0)
{
_chronogramme << "\n<path d='M0 "<< y;
_chronogramme_state=WAIT_FOR_POINT;
}
else
std::cerr<<"draw_counter not initialised";
}
else if (_chronogramme_state==WAIT_FOR_POINT)
{
if (x==0)
{
_chronogramme << "'/>";
_svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size());
_chronogramme.str("");
_chronogramme_state=WAIT_NEW_CHRONO;
}
else
{
_chronogramme << " L" << x << " " << y;
}
}
else if (_chronogramme_state==WAIT_NEW_CHRONO)
{
if (x==0)
{
_chronogramme << "\n<path d='M0 "<< y;
_chronogramme_state=WAIT_FOR_POINT;
}
else
std::cerr<<"draw_counter not initialised";
}
}
inline void Svg::end_draw_counter(){
if (_chronogramme_state!=WAIT_NEW_CHRONO)
std::cerr<<"draw_counter not un-initialised";
}
......@@ -141,13 +189,13 @@ inline void Svg::end_draw(){
Svg::end();
}
void Svg::rectangle(const char* name,unsigned long w, unsigned long h,unsigned long x1,unsigned long y1, unsigned int r, unsigned int g, unsigned int b ){
void Svg::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 ){
_buffer << "\n<rect title='"<<name<<"' width='" << w
<<"' height='"<< h
<<"' x='" << x1
<<"' y='" << y1
<<"' fill='rgb("<<r<<","<<g<<","<<b
<<")'/>" << std::endl;
<<")'/>";
print();
}
......@@ -155,12 +203,12 @@ void Svg::rectangle(const char* name,unsigned long w, unsigned long h,unsigned l
void Svg::triangle(const char* name,unsigned long x1,unsigned long y1,unsigned long x2,unsigned long y2, unsigned long x3,unsigned long y3){
void Svg::triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3){
_buffer << "\n<polyline title='"<<name<<"' class='triangle' points='"
<< x1 << "," << y1
<< " " << x2 << "," << y2
<< " " << x3 << "," << y3
<<"' />" << std::endl;
<<"' />";
print();
}
......@@ -173,7 +221,7 @@ void Svg::print(){
inline void Svg::line(const char* name, long unsigned int x1, long unsigned int y1, long unsigned int x2, long unsigned int y2){
inline void Svg::line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2){
_buffer << "\n<line title='"<<name<<"' x1='" << x1
<<"' y1='" << y1
<<"' x2='" << x2
......
......@@ -13,9 +13,9 @@ int main()
s.draw_container(0,LEVEL*2,50,100);
s.draw_container(0,LEVEL*3,50,100);
s.draw_state(100, 750, 1,NULL, 0xff,0xcc,33);
s.draw_state(100, 750.87, 1,NULL, 0xff,0xcc,33);
s.draw_state(400, 750, 2,NULL, 0xff,0xcc,33);
s.draw_state(70, 300, 3,NULL, 0xff,0xcc,33);
s.draw_state(70.756, 300, 3,NULL, 0xff,0xcc,33);
s.draw_arrow(100,700,LEVEL*1,LEVEL*3);
s.draw_arrow(200,400,LEVEL*2,LEVEL*2);
......
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