Commit 1c3ac9af authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Advancement of the statistics in histogram mode.

parent 296919ef
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<ui version="4.0" >
<class>stats_viewer</class>
<widget class="QMainWindow" name="stats_viewer">
<property name="geometry">
<widget class="QMainWindow" name="stats_viewer" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
......@@ -10,127 +9,135 @@
<height>701</height>
</rect>
</property>
<property name="windowTitle">
<property name="windowTitle" >
<string>statistics viewer</string>
</property>
<property name="windowIcon">
<iconset resource="vite.qrc">
<property name="windowIcon" >
<iconset resource="vite.qrc" >
<normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<widget class="QWidget" name="centralwidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>26</y>
<width>855</width>
<height>675</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<layout class="QGridLayout" name="gridLayout_2" >
<property name="sizeConstraint" >
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="2" column="0">
<widget class="QTreeWidget" name="_nodes_selected">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<item row="2" column="0" >
<widget class="QTreeWidget" name="_nodes_selected" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="headerHidden">
<property name="headerHidden" >
<bool>true</bool>
</property>
<column>
<property name="text">
<property name="text" >
<string>1</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<item row="0" column="1" >
<layout class="QFormLayout" name="formLayout" >
<property name="sizeConstraint" >
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="fieldGrowthPolicy">
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="_start_time_widget"/>
<item row="0" column="1" >
<widget class="QLineEdit" name="_start_time_widget" />
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>End time</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="_end_time_widget"/>
<item row="1" column="1" >
<widget class="QLineEdit" name="_end_time_widget" />
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Kind of viewing</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="_kind_of_diagram_box">
<item row="2" column="1" >
<widget class="QComboBox" name="_kind_of_diagram_box" >
<item>
<property name="text">
<string>Horizontal percentage</string>
<property name="text" >
<string>Histogram</string>
</property>
</item>
<item>
<property name="text">
<property name="text" >
<string>Chart</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Start time</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="sizeConstraint">
<item row="2" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<property name="sizeConstraint" >
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<layout class="QVBoxLayout" name="stats_area">
<property name="sizeConstraint">
<layout class="QVBoxLayout" name="stats_area" >
<property name="sizeConstraint" >
<enum>QLayout::SetDefaultConstraint</enum>
</property>
</layout>
</item>
<item>
<widget class="QScrollBar" name="y_scroll">
<property name="orientation">
<widget class="QScrollBar" name="y_scroll" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item row="3" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
......@@ -139,37 +146,40 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="export_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<widget class="QPushButton" name="export_button" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<property name="text" >
<string>Export</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item row="3" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
......@@ -178,27 +188,27 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="reload_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<widget class="QPushButton" name="reload_button" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<property name="text" >
<string>Reload</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
......@@ -208,34 +218,34 @@
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<item row="0" column="0" >
<layout class="QVBoxLayout" name="verticalLayout" >
<property name="sizeConstraint" >
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Statistics:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Uses to display diagrams about the trace&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;states. You can display it as chart or horizontal&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;bar.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Statistics:&lt;/span>&lt;/p>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;">Uses to display diagrams about&lt;/p>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;">the trace states. You can display&lt;/p>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;">it as chart or horizontal bar.&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
......@@ -245,9 +255,9 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<item row="1" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Selected node :</string>
</property>
</widget>
......@@ -256,19 +266,19 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>855</width>
<height>27</height>
<height>26</height>
</rect>
</property>
</widget>
</widget>
<resources>
<include location="vite.qrc"/>
<include location="vite.qrc" />
</resources>
<connections/>
</ui>
......@@ -35,7 +35,7 @@ void ParserDefinitionDecoder::enter_definition(Line &line){
return;
}
if(sscanf(definition_identity_string.c_str(), "%d", &definition_identity) != 1){
if(sscanf(definition_identity_string.c_str(), "%u", &definition_identity) != 1){
Error::set(Error::_EXPECT_ID_DEF, line.get_line_count(), Error::_ERROR);
return;
}
......
......@@ -37,7 +37,7 @@ void ParserPaje::parse(string filename, Trace &trace){
}
else {
// We check if we have an event identifier
if(sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1){
if(sscanf(event_identity_string.c_str(), "%u", &event_identity) != 1){
Error::set(Error::_EXPECT_ID_DEF, line.get_line_count(), Error::_WARNING);
continue;
}
......
......@@ -12,9 +12,12 @@ using namespace std;
#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): "
Render_stats_opengl::Render_stats_opengl(QWidget *parent) : QGLWidget(parent){
_translated_y = 0;
}
Render_stats_opengl::~Render_stats_opengl(){
_text_pos.clear();
_text_value.clear();
}
void Render_stats_opengl::initializeGL(){
......@@ -32,7 +35,6 @@ void Render_stats_opengl::resizeGL(int width, int height){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, _render_width, 0, _render_height, 0, -1000);
glMatrixMode(GL_MODELVIEW);
//cout << "resize: (" << width<<", "<<height<<")"<< endl;
......@@ -50,6 +52,8 @@ void Render_stats_opengl::paintGL(){
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0, _screen_width, 0, _screen_height);
glTranslated(0, _translated_y, 0);
list<Element_pos>::iterator it_pos;
list<string>::iterator it_txt;
Element_pos buf_x;
......@@ -90,3 +94,10 @@ void Render_stats_opengl::set_total_height(Element_pos h) {
_render_height = h;
//cout << "total height of the stats: " << h << endl;
}
void Render_stats_opengl::translate_y(int value) {
_translated_y = (double)value/100.0*_render_height;
//cout << _render_height << endl;
updateGL();
}
......@@ -34,6 +34,9 @@ private:
std::list<std::string> _text_value;
GLuint _rect_list;
double _translated_y;
public:
/*!
......@@ -83,6 +86,8 @@ public:
* \param y the y position of the text.
* \param value the string value of the text.
*/
void draw_horizontal_line(const Element_pos x, const Element_pos y, const Element_pos size_x);
void draw_axis(const Element_pos x, const Element_pos y, const Element_pos size_x, const Element_pos size_y);
/*!
* \brief Draw a rectangle.
......@@ -95,8 +100,8 @@ public:
* \brief Proceeds with the end of draw functions.
*/
void end_draw();
void translate_y(int value);
/*!
* \brief Set the height of the render area.
*/
......@@ -121,6 +126,16 @@ inline void Render_stats_opengl::draw_text(const Element_pos x, const Element_po
// std::cout << "text: " << value << " @ position : ("<<x<<","<<y<<")." << std::endl;
}
inline void Render_stats_opengl::draw_horizontal_line(const Element_pos x, const Element_pos y, const Element_pos size_x){
glBegin(GL_LINES);
{
glColor3ub(0, 0, 0);
glVertex2i(x, y);
glVertex2i(x+size_x, y);
}
glEnd();
}
inline void Render_stats_opengl::draw_axis(const Element_pos x, const Element_pos y, const Element_pos size_x, const Element_pos size_y){
glBegin(GL_LINES);
{
......@@ -131,16 +146,33 @@ inline void Render_stats_opengl::draw_axis(const Element_pos x, const Element_po
glVertex2i(x, y+size_y);
}
glEnd();
glBegin(GL_TRIANGLES);/* create an arrow */
{
glColor3d(0, 0, 0);
glVertex2i(x-5, y+size_y-5);
glVertex2i(x, y+size_y);
glVertex2i(x+5, y+size_y-5);
}
glEnd();
glBegin(GL_TRIANGLES);/* create an arrow */
{
glColor3d(0, 0, 0);
glVertex2i(x+size_x-5, y+5);
glVertex2i(x+size_x, y);
glVertex2i(x+size_x-5, y-5);
}
glEnd();
}
inline void Render_stats_opengl::draw_rect(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h, const Element_pos r, const Element_pos g, const Element_pos b) {
glBegin(GL_QUADS);
{
glColor3d(r, g, b); glVertex2d(x, y);
glColor3d(r, g, b); glVertex2d(x, y+h);
glColor3d(r/1.5, g/1.5, b/1.5); glVertex2d(x, y+h);
glColor3d(r, g, b); glVertex2d(x+w, y+h);
glColor3d(r, g, b); glVertex2d(x+w, y);
glColor3d(r/1.5, g/1.5, b/1.5); glVertex2d(x+w, y);
}
glEnd();
//std::cout << "rect: " << "x ="<<x<<", y = "<<y<<", w = "<<w<<", "<<h << " ("<<r<<", "<<g<<", "<<b<<") "<<std::endl;
......
......@@ -13,6 +13,7 @@
#include "../trace/Trace.hpp"
#include "../trace/tree/Interval.hpp"
#include "Statistic.hpp"
/*!
* \def _HEIGHT_FOR_ONE_CONTAINER_DEFAULT
* \brief The default height for one container's statistics.
......@@ -42,7 +43,7 @@
* \def _START_HISTOGRAM_X_DEFAULT
* \brief The default x position for origin in histogram mode.
*/
#define _START_HISTOGRAM_X_DEFAULT 100.f
#define _START_HISTOGRAM_X_DEFAULT 80.f
/*!
* \def _START_HISTOGRAM_Y_DEFAULT
......@@ -54,7 +55,19 @@
* \def _PERCENTAGE_HEIGHT_DEFAULT
* \brief The default height for 1% in histogram mode.
*/
#define _PERCENTAGE_HEIGHT_DEFAULT 5.f
#define _PERCENTAGE_HEIGHT_DEFAULT 3.f
/*!
* \def _POS_X_LEGEND_DEFAULT
* \brief The default position for the legend.
*/
#define _POS_X_LEGEND_DEFAULT 10.f
/*!
* \def _POS_Y_LEGEND_DEFAULT
* \brief The default position for the legend.
*/
#define _POS_Y_LEGEND_DEFAULT 60.f
/*!
......@@ -80,6 +93,12 @@ protected:
double _pos_x_container_name;
double _pos_y_container_name;
double _percentage_height_default;
double _width_for_rect_legend;
double _height_for_rect_legend;
public:
/*
* \brief The default constructor
......@@ -88,6 +107,12 @@ public:
_size_for_one_container = _HEIGHT_FOR_ONE_CONTAINER_DEFAULT;
_pos_x_container_name = _POS_X_CONTAINER_NAME;
_pos_y_container_name = _POS_Y_CONTAINER_NAME;
_percentage_height_default = (_size_for_one_container - _START_HISTOGRAM_Y_DEFAULT) / 100.;
/* Size for rectangles in the legend */
_width_for_rect_legend = 20.;
_height_for_rect_legend = 15.;
}
......@@ -103,14 +128,15 @@ public:
* \brief The trace building function.
* \param draw_object the kind of object which will be drawn (OpenGL, SVG...).
* \param trace the trace data.
* \param kind_of_diagram th ekind of diagram (histogram, chart...)
* \param kind_of_diagram the kind of diagram (histogram, chart...)
*/
void build(T* draw_object, std::vector<Container *> containers_to_print, std::string kind_of_diagram) {
_containers_to_print = containers_to_print;
const int number_of_containers = _containers_to_print.size();
draw_object->start_draw();
draw_object->set_total_height((number_of_containers-1)*_size_for_one_container);
for(int i = 0 ; i < number_of_containers ; i ++) {
draw_container_name(draw_object, i);
......@@ -123,11 +149,11 @@ public:
void draw_container_name(T* draw_object, const int container_id) {
// Get the position for the i-th container name
// TO DO
Element_pos pos_x = _pos_x_container_name;
Element_pos pos_y = _pos_y_container_name + _size_for_one_container * container_id;
Element_pos pos_y = _pos_y_container_name - _size_for_one_container * container_id;
std::string name = _containers_to_print[container_id]->get_name().to_string();
////
draw_object->draw_text(pos_x, pos_y, name);
}
......@@ -141,27 +167,45 @@ public:
// Printing of the trace
// Depending on the kind of diagram...
if(kind_of_diagram == "Horizontal percentage") {
if(kind_of_diagram == "Histogram") {
int pos_x = _START_HISTOGRAM_X_DEFAULT;
int pos_y = _START_HISTOGRAM_Y_DEFAULT;
int pos_y = _START_HISTOGRAM_Y_DEFAULT - container_id*_size_for_one_container;
// Draw axes
draw_object->draw_axis(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT*(_states[container_id].size()+1), _PERCENTAGE_HEIGHT_DEFAULT*101);
draw_object->draw_text(pos_x-20, pos_y+_PERCENTAGE_HEIGHT_DEFAULT*101, "1");
draw_object->draw_axis(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT*(_states[container_id].size()+1), _percentage_height_default*100);
draw_object->draw_text(pos_x-30, pos_y+_percentage_height_default*100, "1");
draw_object->draw_horizontal_line(pos_x, pos_y+_percentage_height_default*100, _WIDTH_HISTOGRAM_DEFAULT*(_states[container_id].size()+1));
// // Draw 25%, 50% and 75% for help
// for(int i = 0 ;i < 3 ; i ++){
// char temp[4] = "\0";
// sprintf(temp, "%3lf", (float)(i+1)*0.25);