Commit 11507c6d authored by Pascal Noisette's avatar Pascal Noisette

statistiques

parent 56a074de
/*!
* \brief This class provides to renderer, some statistics toward the input trace.
*/
#include "resource.hpp"
class StatInfo{
public:
Element_pos total_width;
Times total_time;
/*unused :*/
Element_count element_number;
Element_pos minimum_width;
Element_pos minimum_heigth;
Element_pos maximum_width;
Element_pos maximum_heigth;
};
......@@ -116,7 +116,18 @@ class Render
* \brief Called when all draws are finished.
*/
virtual void end_draw() = 0;
/*!
* \brief Set Statistics and Informations about input trace
*/
virtual void set_total_width(Element_pos w) = 0;
/*!
* \brief Set Statistics and Informations about input trace
*/
virtual void set_total_time(Times t) = 0;
};
......
......@@ -698,3 +698,7 @@ void Render_area::create_rule(){
}
*/
}
void Render_area::set_total_width(Element_pos w){}
void Render_area::set_total_time(Times t){}
......@@ -539,6 +539,19 @@ class Render_area : public QGLWidget, public Render
* \brief Create the rule disaply list.
*/
void create_rule();
/*!
* \brief Set Statistics and Informations about input trace
*/
void set_total_width(Element_pos w);
/*!
* \brief Set Statistics and Informations about input trace
*/
void set_total_time(Times t);
};
......
......@@ -5,10 +5,10 @@ using namespace std;
void Svg::init(const char *path){
_container_width_max = 0;
_debug_counter=0;
_container_height_min = 1280;
_epsilon = 0.1;
_StatInfo_filled = false;
_svg_file.open(path , std::ofstream::out | std::ofstream::trunc);
if (_svg_file.is_open()==false){
......@@ -39,11 +39,11 @@ void Svg::init(const char *path){
<< "\t\t\t}\n"
<< "\t\tline\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:#f8c71b;stroke:#f8c71b;stroke-width:1\n"
<< "\t\t\t\tfill:white;stroke:#f8c71b;stroke-width:1\n"
<< "\t\t\t}\n"
<< "\t\tpolyline\n"
<< "\t\t\t{\n"
<< "\t\t\t\tfill:#f8c71b;stroke:#f8c71b;stroke-width:1\n"
<< "\t\t\t\tfill:white;stroke:#f8c71b;stroke-width:1\n"
<< "\t\t\t}\n"
<< "\t\tpath\n"
<< "\t\t\t{\n"
......@@ -103,22 +103,12 @@ void Svg::end(){
void Svg::set_accuracy(double epsilon){
_epsilon = epsilon;
}
void Svg::set_information(StatInfo &p){
_info = p;
_StatInfo_filled = true;
}
void Svg::display_time_scale()
{
if (!_StatInfo_filled)
{
std::cerr<< "no information filled : use Svg::set_information(StatInfo &p) before drawing" << endl;
return;
}
Element_pos w = _info.total_width*WIDE;
Element_pos w = _total_width*WIDE;
Element_pos h = MARGINTOP;
Element_pos x = _container_width_max + MARGINSTATE;
Element_pos y = 0;
......@@ -139,3 +129,5 @@ void Svg::set_information(StatInfo &p){
}
void Svg::set_total_width(Element_pos w){}
void Svg::set_total_time(Times t){}
......@@ -9,53 +9,50 @@
#include <sstream>
#include <fstream>
/*
*\brief Character number stored before flush the _buffer
*/
#define BUFFER_SIZE 10 //character number stored before flush the _buffer
/*
*\brief Distance between two containers
*\brief height of containers
*/
#define LEVEL 20 //distance between two containers
#define LEVEL 20
/*
*\brief Distance between two object
*\brief Distance between two container
*/
#define MARGIN 10 //distance between two object
#define MARGIN 10
/*
*\brief Spike size
*/
#define ARROWSIZE 2 //spike size
#define ARROWSIZE 2
/*
*\brief
*\brief Default width of an element
*/
#define WIDE 1000
/*
*\brief
*\brief Distance between two states
*/
#define MARGINSTATE 0.5
/*
*\brief
*\brief offset between the top and the picture due to the scale
*/
#define MARGINTOP 20
/*
*\brief
*\brief a State of chronogramme drawer automaton
*/
#define WAIT_NEW_CHRONO 0
/*
*\brief
*\brief a State of chronogramme drawer automaton
*/
#define INIT 1
/*
*\brief
*\brief a State of chronogramme drawer automaton
*/
#define WAIT_FOR_POINT 2
......@@ -63,7 +60,7 @@
#include "render.hpp"
#include "resource.hpp"
#include "StatInfo.hpp"
#define max(a,b) (a>b?a:b);
#define min(a,b) (a>b?b:a);
......@@ -76,25 +73,82 @@ class Svg : public Render{
private:
StatInfo _info;
bool _StatInfo_filled;
/*!
* \brief buffer containing the main objets to be displayed
*/
std::ostringstream _buffer;
/*!
* \brief buffer containning the smallest objet which must be display over main objet to be visible
*/
std::ostringstream _thin_element_buffer;
/*!
* \brief buffer containning each counters values
*/
std::ostringstream _chronogramme;
/*!
* \brief buffer containning the scale
*/
std::ostringstream _time_scale;
/*!
* \brief State of the chronogramme drawer automaton
* the automaton can be INIT, WAIT_FOR_POINT and WAIT_NEW_CHRONO
*/
int _chronogramme_state;
/*!
* \brief output svg file
*/
std::ofstream _svg_file;
/*!
* \brief width container sum which is the abscisse of the beginnig of the events display
*/
Element_pos _container_width_max;
/*!
* \brief minimum container height which is the height of any event
*/
Element_pos _container_height_min;
int _debug_counter;
/*!
* \brief accuracy required : an element less wide than _epsilon will not be printed
*/
double _epsilon;
/*!
* \brief Statistics and Informations about input trace
*/
Element_pos _total_width;
/*!
* \brief Statistics and Informations about input trace
*/
Times _total_time;
inline void print();
void display_time_scale();
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 );
void display_time_scale();
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 Set Statistics and Informations about input trace
*/
void set_total_width(Element_pos w);
/*!
* \brief Set Statistics and Informations about input trace
*/
void set_total_time(Element_pos x1);
/*!
* \brief SVG header buiding
*/
......@@ -105,7 +159,15 @@ public:
*/
void end();
/*!
* \brief unused
*/
void start_draw();
/*!
* \brief unused
*/
void start_draw_containers();
/*!
......@@ -117,9 +179,18 @@ public:
*/
void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) ;
/*!
* \brief Draw associated container name
*/
void draw_container_text(const Element_pos x, const Element_pos y, const std::string value);
/*!
* \brief unused
*/
void end_draw_containers();
/*!
* \brief unused
*/
void start_draw_states();
/*!
......@@ -140,16 +211,37 @@ public:
*/
void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height);
/*!
* \brief unused
*/
void end_draw_states();
/*!
* \brief not yet implemented
*/
void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height);
/*!
* \brief initialise drawer automaton
*/
void start_draw_counter();
/*!
* \brief add a point or switch chronogramme drawing
*/
void draw_counter(const Element_pos x, const Element_pos y);
/*!
* \brief close drawer automaton
*/
void end_draw_counter();
/*!
* \brief unused
*/
void end_draw();
/*!
......@@ -158,13 +250,7 @@ public:
*/
void set_accuracy(double epsilon);
/*
*\fn set_information(StatInfo &p)
*\brief Function that sets the information using the StatInfo structure
*\param A StatInfo reference that contains all the information
*/
void set_information(StatInfo &p);
};
......@@ -218,7 +304,7 @@ inline void Svg::end_draw_states(){
inline void Svg::start_draw_counter(){
_chronogramme_state=INIT;
// std::cout<<"INIT\n";
}
inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
......@@ -227,13 +313,12 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
Element_pos yprime = y*LEVEL + MARGINTOP;
Element_pos switchvalue = _container_width_max;
//std::cout<<"s.draw_counter("<<xprime<<","<<yprime<<");\n";
if (_chronogramme_state==INIT)
{
if (xprime==switchvalue)
{
// std::cout<<"WAITFORPOINT\n";
_chronogramme << "\n<path d='M"<< xprime << " " << yprime;
_chronogramme_state=WAIT_FOR_POINT;
}
......@@ -247,7 +332,7 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
if (xprime==switchvalue)
{
// std::cout<<"WAITFORNEWCHRONO\n";
_chronogramme << "'/>";
_svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size());
_chronogramme.str("");
......@@ -265,7 +350,6 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
{
if (xprime==switchvalue)
{
// std::cout<<"WAITFORPOINT\n";
_chronogramme << "\n<path d='M"<< xprime << " " << yprime;
_chronogramme_state=WAIT_FOR_POINT;
}
......@@ -312,7 +396,7 @@ void Svg::triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2
}
void Svg::print(){
// if (_buffer.str().size()>BUFFER_SIZE){
_svg_file.write(_buffer.str().c_str(), _buffer.str().size());
_buffer.str("");
}
......@@ -331,7 +415,7 @@ 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){
//std::cout<<"s.draw_arrow("<<start_time<<","<<end_time<<","<<start_height<<","<< end_height<<");\n";
Element_pos x1=(start_time )*WIDE + _container_width_max ;
Element_pos y1=start_height*LEVEL + MARGINTOP;
......@@ -354,9 +438,9 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
yprime = LEVEL*y + MARGINTOP;
xprime = LEVEL*x;
// std::cout<<"s.draw_container("<<x<<","<<y<<","<<w<<","<< h<<");\n";
Svg::rectangle("container",wprime, hprime, xprime, yprime, 0xff, 0x44, 0xcc);
Svg::rectangle("container",wprime, hprime, xprime, yprime, 0xbb, 0xbb, 0xbb);
_container_width_max = max(wprime+xprime+ MARGIN,_container_width_max);
_container_height_min = min(hprime,_container_height_min);
......@@ -375,23 +459,24 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
Element_pos y = level*LEVEL + MARGINTOP;
if(w<_epsilon){
//std::cerr<<"state width is null";
return;
}
// if( debug_counter++<1000)
// std::cout<<"s.draw_state("<<start<<","<<end<<","<<level<<","<< height<<","<<r<<","<<g<<","<< b <<");\n";
Svg::rectangle("state",w,h, x,y,r*255 , g*255, b*255);
}
inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){
// std::cout<<"s.draw_event("<<time<<","<< height<<","<<container_height<<");\n";
/*!
* \brief not yet implemented
*/
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 + _container_width_max , height + MARGINTOP, 0x17, 0x60, 0xe7);
}
#endif // RENDER_SVG
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