Commit a3ee1d8c authored by Johnny Jazeix's avatar Johnny Jazeix

Statistics fixed for viewing and exporting.

parent 7bda0d0d
......@@ -156,7 +156,7 @@ void Render_stats_opengl::paintGL(){
qglColor(QColor(0, 0, 0)); // We put the text in black
for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end() ; it_txt ++, it_pos ++) {
buf_x = *it_pos + _translated_x;
buf_x = *it_pos - _translated_x;
it_pos ++;
buf_y = *it_pos - _translated_y;
......
......@@ -90,19 +90,19 @@ void Render_stats_svg::fill_file(){
/* Draw rect */
for (it_rect = _rect_pos.begin() ; it_rect!=_rect_pos.end() ; it_rect ++) {
Element_pos x = *it_rect;
const Element_pos &x = *it_rect;
it_rect ++;
Element_pos y = *it_rect;
const Element_pos &y = *it_rect;
it_rect ++;
Element_pos w = *it_rect;
const Element_pos &w = *it_rect;
it_rect ++;
Element_pos h = *it_rect;
const Element_pos &h = *it_rect;
it_rect ++;
Element_pos r = *it_rect;
const Element_pos &r = *it_rect;
it_rect ++;
Element_pos g = *it_rect;
const Element_pos &g = *it_rect;
it_rect ++;
Element_pos b = *it_rect;
const Element_pos &b = *it_rect;
_svg_file << "<rect width=\"" << w
<< "\" height=\"" << h
......@@ -115,13 +115,13 @@ void Render_stats_svg::fill_file(){
/* Draw lines */
for (it_line=_line_pos.begin() ; it_line!=_line_pos.end() ; it_line ++) {
Element_pos x = *it_line;
const Element_pos &x = *it_line;
it_line ++;
Element_pos y = *it_line;
const Element_pos &y = *it_line;
it_line ++;
Element_pos size_x = *it_line;
const Element_pos &size_x = *it_line;
it_line ++;
Element_pos size_y = *it_line;
const Element_pos &size_y = *it_line;
_svg_file << "<line x1=\"" << x
<< "\" y1=\"" << height-(y-_y_min)
......@@ -138,7 +138,7 @@ void Render_stats_svg::fill_file(){
buf_txt = *it_txt;
_svg_file << "<text x=\"" << buf_x
<<"\" y=\"" << height-(buf_y-_y_min)
<<"\" y=\"" << buf_y-_y_min+20
<< "\">" << buf_txt
<< "</text>\n";
}/* end for(...) */
......
......@@ -78,7 +78,7 @@ public:
_x_axis_length = _MAX_WIDTH_AXIS_DEFAULT;
_y_axis_length = _MAX_HEIGHT_AXIS_DEFAULT;
this->_pos_x_container_name = _POS_X_CONTAINER_NAME;
this->_pos_y_container_name = _HEIGHT_FOR_ONE_CONTAINER_DEFAULT - 10;
this->_pos_y_container_name = 10;
_nb_variables_already_print = 0;
_start_x = _START_HISTOGRAM_X_DEFAULT;
_start_y = 20.;
......@@ -148,11 +148,11 @@ public:
// Draw the container name
container_name = this->_containers_to_print[container_id]->get_name().to_string();
draw_object->draw_text(this->_pos_x_container_name,
this->_pos_y_container_name + pos_y - 30,
this->_pos_y_container_name + 30 - pos_y,
container_name);
// Draw the variable name
draw_object->draw_text(this->_pos_x_container_name,
this->_pos_y_container_name + pos_y - 50,
this->_pos_y_container_name + 50 - pos_y,
var->get_type()->get_name().to_string());
// Draw the axis
......@@ -163,19 +163,19 @@ public:
// Draw the legend axis
// Time unit
draw_object->draw_text(pos_x+_x_axis_length+10. ,
pos_y,
draw_object->draw_text(pos_x+_x_axis_length+10.,
_HEIGHT_FOR_ONE_CONTAINER_DEFAULT-pos_y,
"time unit");
// Variable unit
if(var->get_extra_fields()->find(std::string("unit")) != var->get_extra_fields()->end()) {
const String *var_unit = (const String *)var->get_extra_fields()->find(std::string("unit"))->second;
draw_object->draw_text(pos_x,
pos_y+_y_axis_length+10. ,
_HEIGHT_FOR_ONE_CONTAINER_DEFAULT-(pos_y+_y_axis_length+10.) ,
"("+var_unit->to_string()+")");
}
else {
draw_object->draw_text(pos_x,
pos_y+_y_axis_length+10. ,
_HEIGHT_FOR_ONE_CONTAINER_DEFAULT-(pos_y+_y_axis_length+10.) ,
"no unit");
}
......@@ -188,14 +188,14 @@ public:
for(int i = 0 ; i <= nb_values ; i ++) {
// x value -> time
draw_object->draw_text(pos_x+i*_x_axis_length/nb_values,
pos_y-15. ,
_HEIGHT_FOR_ONE_CONTAINER_DEFAULT-(pos_y-15.) ,
QString::number(duration*(double)i/(double)nb_values+this->_start_time, 'f', 3).toStdString());
draw_object->draw_vertical_line(pos_x+i*_x_axis_length/nb_values,
pos_y-5,
5);
// y value -> counter
draw_object->draw_text(pos_x-30. ,
pos_y+i*_y_axis_length/nb_values,
_HEIGHT_FOR_ONE_CONTAINER_DEFAULT-(pos_y+i*_y_axis_length/nb_values),
QString::number((max_value-min_value)*i/(double)nb_values+min_value, 'f', 1).toStdString());
draw_object->draw_horizontal_line(pos_x-5,
pos_y+i*_y_axis_length/nb_values,
......@@ -205,7 +205,7 @@ public:
else {
// Only one in the middle
draw_object->draw_text(pos_x-30. ,
pos_y+_y_axis_length/2,
_HEIGHT_FOR_ONE_CONTAINER_DEFAULT-(pos_y+_y_axis_length/2),
QString::number(max_value, 'f', 1).toStdString());
draw_object->draw_horizontal_line(pos_x-5,
pos_y+_y_axis_length/2,
......
......@@ -130,14 +130,14 @@ public:
_starty + _WIDTH_HISTOGRAM_DEFAULT - 2.5,
5.);
draw_object->draw_text(_startx + i*_graph_width/100 - 10.,
_starty + _WIDTH_HISTOGRAM_DEFAULT + 15.,
this->_size_for_one_container-(_starty + _WIDTH_HISTOGRAM_DEFAULT + 15.),
QString::number(i, 'd', 1).toStdString()+"%");
// Dra Down Scale
// Draw Down Scale
draw_object->draw_vertical_line(_startx + i*_graph_width/100.,
_starty - (nbcont-1)*_WIDTH_HISTOGRAM_DEFAULT - 2.5,
5.);
draw_object->draw_text(_startx + i*_graph_width/100 - 10.,
_starty - (nbcont-1)*_WIDTH_HISTOGRAM_DEFAULT - 15.,
this->_size_for_one_container-(_starty - (nbcont-1)*_WIDTH_HISTOGRAM_DEFAULT - 15.),
QString::number(i, 'd', 1).toStdString()+"%");
}
......@@ -178,7 +178,7 @@ public:
// Draw the container name
ctname = this->_containers_to_print[container_id]->get_name().to_string();
draw_object->draw_text(_POS_X_CONTAINER_NAME,
pos_y + _WIDTH_HISTOGRAM_DEFAULT / 2. - 5.,
this->_size_for_one_container-(pos_y + _WIDTH_HISTOGRAM_DEFAULT / 2. - 5.),
ctname);
// Draw the stats
......@@ -208,7 +208,8 @@ public:
red, green, blue);
if ( width > 30. )
draw_object->draw_text(pos_x + width / 2 - 10., pos_y + _WIDTH_HISTOGRAM_DEFAULT / 2. - 5.,
draw_object->draw_text(pos_x + width / 2 - 10.,
this->_size_for_one_container-(pos_y + _WIDTH_HISTOGRAM_DEFAULT / 2. - 5.),
QString::number(percent*100., 'f', 1).toStdString()+"%");
pos_x += width;
......@@ -241,7 +242,9 @@ public:
it ++, decalage ++) {
std::string name = (*it)->get_name().to_string();
draw_object->draw_text(pos_x+w+_POS_X_LEGEND_DEFAULT, pos_y, name);
draw_object->draw_text(pos_x+w+_POS_X_LEGEND_DEFAULT,
this->_size_for_one_container-pos_y,
name);
if((*it)->get_extra_fields()->find(std::string("Color")) != (*it)->get_extra_fields()->end())
{
......
......@@ -108,9 +108,9 @@ public:
virtual void draw_container_name(T* draw_object, const int container_id) const {
// Get the position for the i-th container name
Element_pos pos_x = this->_pos_x_container_name;
Element_pos pos_y = this->_pos_y_container_name - this->_size_for_one_container * container_id;
std::string name = this->_containers_to_print[container_id]->get_name().to_string();
const Element_pos pos_x = this->_pos_x_container_name;
const Element_pos pos_y = this->_size_for_one_container*(container_id+1)-this->_pos_y_container_name;
const std::string name = this->_containers_to_print[container_id]->get_name().to_string();
draw_object->draw_text(pos_x, pos_y, name);
......@@ -135,7 +135,11 @@ public:
const double max_percentage = get_max_percentage(temp_states);
// Draw axes
draw_object->draw_axis(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT*(this->_states[container_id].size()+1), this->_percentage_height_default*100);
draw_object->draw_text(pos_x-30, pos_y+this->_percentage_height_default*100-5, QString::number(max_percentage*100., 'g', 3).toStdString()+"%");
draw_object->draw_text(pos_x-35,
this->_size_for_one_container-(pos_y+this->_percentage_height_default*100-5),
QString::number(max_percentage*100., 'g', 3).toStdString()+"%");
draw_object->draw_horizontal_line(pos_x, pos_y+this->_percentage_height_default*100, _WIDTH_HISTOGRAM_DEFAULT*(this->_states[container_id].size()+1));
......@@ -159,7 +163,9 @@ public:
}
// We print the percentage above
draw_object->draw_text(pos_x, pos_y+height/max_percentage+1, QString::number(length/(this->_end_time-this->_start_time)*100., 'f', 1).toStdString()+"%");
draw_object->draw_text(pos_x,
this->_size_for_one_container-(pos_y+height/max_percentage+1),
QString::number(length/(this->_end_time-this->_start_time)*100., 'f', 1).toStdString()+"%");
//std::cout << "State : " << name << " for " << (*it).second->_total_length*100./(this->_end_time-this->_start_time)<< "% between " << this->_start_time << " sec and " << this->_end_time << " sec" << std::endl;
......@@ -182,7 +188,7 @@ public:
*/
virtual void draw_legend(T* draw_object, const int container_id) {
Element_pos pos_x = _POS_X_CONTAINER_NAME + _POS_X_LEGEND_DEFAULT;
Element_pos pos_y = -this->_size_for_one_container * (container_id) + _POS_Y_LEGEND_DEFAULT;
Element_pos pos_y = this->_size_for_one_container * (container_id+1) - _POS_Y_LEGEND_DEFAULT;
const double w = this->_width_for_rect_legend;
const double h = this->_height_for_rect_legend;
......@@ -197,7 +203,7 @@ public:
if((*it).first->get_extra_fields()->find(std::string("Color")) != (*it).first->get_extra_fields()->end()) {
const Color *color = (const Color *)(*it).first->get_extra_fields()->find(std::string("Color"))->second;
draw_object->draw_rect(pos_x, pos_y, w, h, color->get_red(), color->get_green(), color->get_blue());
draw_object->draw_rect(pos_x, this->_size_for_one_container-pos_y, w, h, color->get_red(), color->get_green(), color->get_blue());
}
else {
draw_object->draw_rect(pos_x, pos_y, w, h, 0.7, 0.7, 0.75);
......@@ -206,10 +212,10 @@ public:
switch(decalage%3) {
case 2:
pos_x += 100;
pos_y += 40;
pos_y -= 40;
break;
default:
pos_y -= 20;
pos_y += 20;
break;
}
}
......
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