Commit 9aba6c07 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Beginning of the statistics repair. Stats are printed but need to fix

the text behaviour -> Changed from QPainter to QGLWidget draw text 
method so the origin point is not the same.
parent 981b7a16
......@@ -280,12 +280,12 @@ protected:
QString _run_env[2];
/*!
*\brief If a file must be opened, this attributes contains its path.
*\brief If a file must be opened, this attribute contains its path.
*/
std::string _file_opened;
/*!
*\brief If a file must be exported, this attributes contains its path.
*\brief If a file must be exported, this attribute contains its path.
*/
std::string _path_to_export;
......
......@@ -56,7 +56,7 @@ Line::Line() : _line_count(0) {
Line::Line(const Line &l) : _tokens(l._tokens), _line_count(l._line_count) {
}
Line::Line(string &string_line) {
Line::Line(const string &string_line) {
fill_line(string_line);
}
......
......@@ -77,7 +77,7 @@ public:
* \brief Constructor for the line
* \param string_line : a filename
*/
Line(std::string &string_line);
Line(const std::string &string_line);
/*!
* \brief Destructor
......
......@@ -64,12 +64,14 @@ using namespace std;
uint64_t ParserEventOTF::_cur_time = 0;
uint64_t ParserEventOTF::_min_time = 0;
uint64_t ParserEventOTF::_max_time = 0;
map <const String, Container *, String::less_than> ParserEventOTF::_containers;
ParserEventOTF::ParserEventOTF() : _handlers(OTF_HandlerArray_open()) {
}
ParserEventOTF::~ParserEventOTF() {
OTF_HandlerArray_close(_handlers);
_containers.clear();
}
void ParserEventOTF::set_handlers(Trace *t) {
......@@ -108,7 +110,15 @@ int ParserEventOTF::handler_begin_process(void *trace, uint64_t time, uint32_t p
ContainerType *process_container_type = t->search_container_type(String(process_group._name));
Container *parent_container = t->search_container(String(process_parent._name));
// if(_containers.find(container) != _containers.end()) {
// temp_container = _containers[container];
// }
// else {
// temp_container = trace.search_container(container);
// _containers[container] = temp_container;
// }
if(process_container_type == 0) {
Error::set(Error::_UNKNOWN_CONTAINER_TYPE + process_group._name, Error::_ERROR);
}
......@@ -117,6 +127,10 @@ int ParserEventOTF::handler_begin_process(void *trace, uint64_t time, uint32_t p
}
t->create_container(d, n, process_container_type, parent_container, extra_fields);
// We store the container in the map
_containers[n.to_string()] = t->search_container(n.to_string());
return OTF_RETURN_OK;
}
......@@ -129,9 +143,18 @@ int ParserEventOTF::handler_end_process (void *trace, uint64_t time, uint32_t pr
map<string, Value *> extra_fields;
Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
Container *temp_container = t->search_container(String(process._name));
Container *temp_container = NULL;
ContainerType *temp_container_type = t->search_container_type(String(process_group._name));
const String process_name = String(process._name);
if(_containers.find(process_name) != _containers.end()) {
temp_container = _containers[process_name];
}
else {
temp_container = t->search_container(process_name);
_containers[process_name] = temp_container;
}
if(temp_container_type == 0) {
Error::set(Error::_UNKNOWN_CONTAINER_TYPE + process_group._name, Error::_ERROR);
}
......@@ -149,21 +172,29 @@ int ParserEventOTF::handler_enter (void *trace, uint64_t time, uint32_t func_id,
Date d = (double)time/(double)ParserDefinitionOTF::get_ticks_per_second();
Function &temp_function = ParserDefinitionOTF::get_function_by_id(func_id);
FunctionGroup temp_function_group = ParserDefinitionOTF::get_function_group_by_id(temp_function._func_group);
const FunctionGroup temp_function_group = ParserDefinitionOTF::get_function_group_by_id(temp_function._func_group);
Process temp_proc = ParserDefinitionOTF::get_process_by_id(proc_id);
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(proc_id);
const ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(proc_id);
String function_name = String(temp_function._name);
String function_group_name = String(temp_function_group._name);
String proc_name = String(temp_proc._name);
const String function_name = String(temp_function._name);
const String function_group_name = String(temp_function_group._name);
const String proc_name = String(temp_proc._name);
Container *temp_container = t->search_container(proc_name);
Container *temp_container = NULL;
ContainerType *temp_container_type = t->search_container_type(String(process_group._name));
StateType *temp_state_type = t->search_state_type(function_group_name);
EntityValue *temp_value = NULL;
map<std::string, Value *> extra_fields;
map<string, Value *> extra_fields;
if(_containers.find(proc_name) != _containers.end()) {
temp_container = _containers[proc_name];
}
else {
temp_container = t->search_container(proc_name);
_containers[proc_name] = temp_container;
}
if(temp_state_type == 0) {
Name name_temp(temp_function_group._name, "");
t->define_state_type(name_temp, temp_container_type, extra_fields);
......@@ -175,7 +206,7 @@ int ParserEventOTF::handler_enter (void *trace, uint64_t time, uint32_t func_id,
Color *c = temp_function._color;
Name name_temp(temp_function._name, "");
map<std::string, Value *> opt;
map<string, Value *> opt;
/* Optional fields */
FileLine source_file_locator;
......@@ -234,7 +265,7 @@ int ParserEventOTF::handler_leave (void */*trace*/, uint64_t /*time*/, uint32_t
//Container *temp_container = t->search_container(String(temp_proc._name));
//EventType *temp_event_type = t->search_event_type(String(temp_function._name));
//EntityValue *temp_value = t->search_entity_value(String(temp_function._name), temp_event_type);
//map<std::string, Value *> extra_fields;
//map<string, Value *> extra_fields;
//t->set_state(d, temp_type, temp_container, temp_value, extra_fields);
//t->pop_state(d, temp_type, temp_container, extra_fields);
......@@ -249,14 +280,24 @@ int ParserEventOTF::handler_counter(void *trace, uint64_t time, uint32_t proc_id
Counter temp_counter = ParserDefinitionOTF::get_counter_by_id(counter_id);
Process temp_proc = ParserDefinitionOTF::get_process_by_id(proc_id);
CounterGroup temp_counter_group = ParserDefinitionOTF::get_counter_group_by_id(temp_counter._counter_group);
Container *temp_container = t->search_container(String(temp_proc._name));
map<std::string, Value *> extra_fields;
Container *temp_container = NULL;
map<string, Value *> extra_fields;
String counter_group_name = String(temp_counter_group._name);
VariableType *temp_variable_type = t->search_variable_type(counter_group_name);
ProcessGroup process_group = ParserDefinitionOTF::get_processgroup_by_process(proc_id);
ContainerType *temp_container_type = t->search_container_type(String(process_group._name));
const String temp_proc_name = String(temp_proc._name);
if(_containers.find(temp_proc_name) != _containers.end()) {
temp_container = _containers[temp_proc_name];
}
else {
temp_container = t->search_container(temp_proc_name);
_containers[temp_proc_name] = temp_container;
}
if(temp_variable_type == 0) {
Name name_temp(temp_counter_group._name, "");
......@@ -268,7 +309,7 @@ int ParserEventOTF::handler_counter(void *trace, uint64_t time, uint32_t proc_id
// Creation of the container if not already done with beginProcess
handler_begin_process(trace, time, proc_id);
temp_proc = ParserDefinitionOTF::get_process_by_id(proc_id);
temp_container = t->search_container(String(temp_proc._name));
temp_container = t->search_container(temp_proc_name);
}
// Check if nothing is empty
......@@ -315,8 +356,8 @@ int ParserEventOTF::handler_send_message (void *trace, uint64_t time, uint32_t s
Name name_temp = Name(name, "");
LinkType *link_type = t->search_link_type(link_type_string);
Container *source_cont = t->search_container(sender_string);
Container *ancestor_cont = t->search_container(receiver_string);
Container *source_container = NULL;
Container *ancestor_container = NULL;
ContainerType *source_type = t->search_container_type(sender_group_string);
ContainerType *destination_type = t->search_container_type(receiver_group_string);
......@@ -326,13 +367,29 @@ int ParserEventOTF::handler_send_message (void *trace, uint64_t time, uint32_t s
map<string, Value *> opt;
if(_containers.find(sender_string) != _containers.end()) {
source_container = _containers[sender_string];
}
else {
source_container = t->search_container(sender_string);
_containers[sender_string] = source_container;
}
if(_containers.find(receiver_string) != _containers.end()) {
ancestor_container = _containers[receiver_string];
}
else {
ancestor_container = t->search_container(receiver_string);
_containers[receiver_string] = ancestor_container;
}
if(ancestor_type == 0) {
// No ancestor
ancestor_type = source_type;
}
if(ancestor_cont == 0) {
if(ancestor_container == 0) {
// No ancestor
ancestor_cont = source_cont;
ancestor_container = source_container;
}
if(link_type == 0) {
......@@ -380,7 +437,7 @@ int ParserEventOTF::handler_send_message (void *trace, uint64_t time, uint32_t s
}
}
t->start_link(d, link_type, ancestor_cont, source_cont, value, name_string, opt);
t->start_link(d, link_type, ancestor_container, source_container, value, name_string, opt);
return OTF_RETURN_OK;
}
......@@ -415,8 +472,8 @@ int ParserEventOTF::handler_receive_message (void *trace, uint64_t time, uint32_
Name name_temp = Name(name, "");
LinkType *link_type = t->search_link_type(link_type_string);
Container *destination_cont = t->search_container(receiver_string);
Container *ancestor_cont = t->search_container(ancestor_string);
Container *destination_cont = NULL;
Container *ancestor_cont = NULL;
ContainerType *destination_type = t->search_container_type(receiver_group_string);
ContainerType *ancestor_type = t->search_container_type(ancestor_group_string);
......@@ -425,6 +482,23 @@ int ParserEventOTF::handler_receive_message (void *trace, uint64_t time, uint32_
map<string, Value *> opt;
if(_containers.find(receiver_string) != _containers.end()) {
destination_cont = _containers[receiver_string];
}
else {
destination_cont = t->search_container(receiver_string);
_containers[receiver_string] = destination_cont;
}
if(_containers.find(ancestor_string) != _containers.end()) {
ancestor_cont = _containers[ancestor_string];
}
else {
ancestor_cont = t->search_container(ancestor_string);
_containers[ancestor_string] = ancestor_cont;
}
if(ancestor_type == 0) {
// No ancestor
ancestor_type = destination_type;
......
......@@ -61,6 +61,8 @@ class ParserEventOTF{
private:
OTF_HandlerArray* _handlers;
static std::map <const String, Container *, String::less_than> _containers;
static uint64_t _cur_time;
static uint64_t _min_time;
static uint64_t _max_time;
......
......@@ -205,9 +205,6 @@ void Render_opengl::paintGL(){
glPushMatrix();
{
static float a = 0;
a ++;
glTranslated(0.0, Info::Render::height, 100.0);
glRotated(180.0, 1.0, 0.0, 0.0);
......@@ -933,7 +930,8 @@ void Render_opengl::draw_stored_arrows(){
set_color(1, 1, 1);
for (unsigned int i=0 ; i<_arrows.size() ; i++){
const unsigned int arrow_size = _arrows.size();
for (unsigned int i=0 ; i<arrow_size ; i++){
start_time = _arrows[i].start_time;// + _x_state_scale*_x_state_translate;
end_time = _arrows[i].end_time;// + _x_state_scale*_x_state_translate;
......@@ -997,7 +995,8 @@ void Render_opengl::draw_stored_circles(){
set_color(1, 1, 1);
for (unsigned int i=0 ; i<_circles.size() ; i++){
const unsigned int size = _circles.size();
for (unsigned int i=0 ; i<size ; i++){
glBegin(GL_POLYGON);
{
......
......@@ -44,8 +44,6 @@
*\file Render_svg.cpp
*/
//#include <iostream>
//#include <sstream>
#include <fstream>
/* -- */
#include "common/common.hpp"
......
......@@ -56,7 +56,7 @@
/* -- */
using namespace std;
Render_stats_opengl::Render_stats_opengl(QWidget *parent) : QGLWidget(parent){
Render_stats_opengl::Render_stats_opengl(QWidget *parent) : QGLWidget(parent), _stats_beginned_drawed(false) {
_translated_y = 0.;
_translated_x = 0.;
_render_height = height();
......@@ -89,7 +89,7 @@ void Render_stats_opengl::resizeGL(int width, int height){
}
void Render_stats_opengl::paintGL(){
makeCurrent();
glClearDepth(1.0);
glClearColor(1.f, 1.f, 1.f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
......@@ -101,13 +101,21 @@ void Render_stats_opengl::paintGL(){
glTranslated(-_translated_x, _translated_y, 0);
if(!_stats_beginned_drawed) {
return;
}
list<Element_pos>::const_iterator it_pos;
list<string>::const_iterator it_txt;
Element_pos buf_x;
Element_pos buf_y;
string buf_txt;
glCallList(_rect_list);
if (glIsList(_rect_list) == GL_FALSE)
printf("ERROR LIST not exist for stats\n");
else
glCallList(_rect_list);
// /* Draw container texts */
// for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end() ; it_txt ++, it_pos ++) {
......@@ -133,24 +141,33 @@ void Render_stats_opengl::paintGL(){
// }/* end for(...) */
glFlush();
QPainter painter(this);/* Should be create AFTER glFlush() */
painter.setPen(Qt::black);
painter.setFont(QFont("Arial", 10));
/* Check the errors */
GLenum glerror;
glerror = glGetError();
if(glerror != GL_NO_ERROR) {
fprintf(stderr, "Render stats openGL : the following OpengGL error occured: %s\n", gluErrorString(glerror));
}
// QPainter painter(this);/* Should be create AFTER glFlush() */
// painter.setPen(Qt::black);
// painter.setFont(QFont("Arial", 10));
const QFont &arial_font = QFont("Arial", 10);
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;
buf_x = *it_pos + _translated_x;
it_pos ++;
buf_y = *it_pos;
buf_y = *it_pos + _translated_y;
buf_txt = *it_txt;
painter.drawText(buf_x, buf_y, buf_txt.c_str());
//painter.drawText(buf_x, buf_y, buf_txt.c_str());
renderText(buf_x, buf_y, buf_txt.c_str(), arial_font);
}
painter.end();
// painter.end();
}
void Render_stats_opengl::translate_y(int value) {
......
......@@ -54,8 +54,6 @@
#include "common/common.hpp"
#include "render_stats.hpp"
class Render_stats_opengl;
/*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
*/
......@@ -80,6 +78,8 @@ private:
double _translated_x;
bool _stats_beginned_drawed;
public:
/*!
......@@ -217,7 +217,11 @@ inline void Render_stats_opengl::start_draw(){
_text_pos.clear();
_text_value.clear();
// makeCurrent();
_stats_beginned_drawed = true;
_rect_list = glGenLists(1);
if(_rect_list == 0) {
fprintf(stderr, "error while initialising _rect_list for stats\n");
}
glNewList(_rect_list, GL_COMPILE);
}
......@@ -226,8 +230,6 @@ inline void Render_stats_opengl::draw_text(const Element_pos x, const Element_po
_text_pos.push_back(x);
_text_pos.push_back(y);
_text_value.push_back(value);
// std::cout << "text: " << value << " @ position : ("<<x<<","<<y<<")." << std::endl;
}
inline void Render_stats_opengl::draw_line(const Element_pos x, const Element_pos y, const Element_pos x2, const Element_pos y2) {
......@@ -299,7 +301,6 @@ inline void Render_stats_opengl::draw_rect(const Element_pos x, const Element_po
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;
}
inline void Render_stats_opengl::end_draw(){
......
......@@ -45,7 +45,6 @@
*/
/* Global informations */
#include <iostream>
#include <fstream>
#include <string>
#include <list>
......
......@@ -151,11 +151,11 @@ public:
// We search for a color
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, _WIDTH_HISTOGRAM_DEFAULT, height/max_percentage, color->get_red(), color->get_green(), color->get_blue());
const Color *color = (const Color *)(*it).first->get_extra_fields()->find(std::string("Color"))->second;
draw_object->draw_rect(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT, height/max_percentage, color->get_red(), color->get_green(), color->get_blue());
}
else {
draw_object->draw_rect(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT, height/max_percentage, 0.7, 0.7, 0.75);
draw_object->draw_rect(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT, height/max_percentage, 0.7, 0.7, 0.75);
}
// We print the percentage above
......
......@@ -44,7 +44,6 @@
#include <map>
#include <list>
#include <stack>
#include <iostream>
/* -- */
#include "trace/values/Values.hpp"
#include "trace/EntityTypes.hpp"
......
......@@ -52,9 +52,9 @@
*/
class ContainerType {
private:
Name _name;
ContainerType *_parent;
std::list<ContainerType *> _children;
Name _name;
ContainerType *_parent;
std::list<ContainerType *> _children;
public:
/*!
......
......@@ -40,7 +40,6 @@
** - VUCHENER Clément
**
*/
#include <iostream>
#include <string>
#include <list>
#include <map>
......
......@@ -45,7 +45,6 @@
#include <map>
#include <list>
#include <vector>
#include <iostream>
#include <sstream>
#include <stack>
/* -- */
......
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