Commit 6b098eef authored by Johnny Jazeix's avatar Johnny Jazeix

Remove of some comments. True includes for render_opengl.hpp (useful for

codeblocks and others)

Improvment of the drawDiagram (it misses only one thing when there are a 
lot of containers printed).

parent fb0f9ff2
......@@ -6,12 +6,12 @@ Definition::Definition(){
_event_name.erase();
}
Definition::Definition(std::string& eventname){
Definition::Definition(string& eventname){
_event_name = eventname;
}
void Definition::store(std::string name, std::string type){
void Definition::store(string name, string type){
Field e;
e._name = name;
......@@ -30,8 +30,7 @@ void Definition::print() const{
}
string Definition::print_string() const{
string definition ("");
definition += _event_name;
string definition = _event_name;
const unsigned int field_size = _fields.size();
for(unsigned int i = 0 ; i < field_size ; i ++){
......
......@@ -10,12 +10,9 @@ Line::Line(Line &){
}
Line::Line(string &filename){
open(filename.c_str());
open(filename.c_str());
}
Line::Line(const char *filename){
open(filename);
}
Line::~Line(){
if(!_tokens.empty()){
......@@ -24,9 +21,9 @@ Line::~Line(){
}
void Line::open(const char *filename){
_line_count = 0;
_source.open(filename);
_is_eof = false;
_line_count = 0;
_source.open(filename);
_is_eof = false;
}
void Line::print() const{
......@@ -34,7 +31,7 @@ void Line::print() const{
cout << "-" ;
for(unsigned int i = 0 ; i < token_size ; i ++)
cout << _tokens[i] << " " ;
cout << "-" <<endl ;
cout << "-" << endl;
}
bool Line::starts_with(const string &s) const{
......
......@@ -15,7 +15,7 @@
/*! \class Line Line.hpp "../parser/src/Line.hpp"
/*! \class Line Line.hpp "../source/src/parser/Line.hpp"
* \brief Line object stand for paje format syntax unit .
*/
......@@ -49,12 +49,6 @@ public:
*/
Line(std::string &filename);
/*!
* \brief Constructor for the line
* \param filename : a filename
*/
Line(const char* filename);
/*!
* \brief Destructor
* Destroy the line
......
......@@ -27,60 +27,63 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
map<std::string, Value *> extra_fields;
unsigned int i = 1;
vector<Field> fields = definition.get_fields();
unsigned int number_of_values = fields.size();
const vector<Field> fields = definition.get_fields();
const unsigned int number_of_values = fields.size();
while(i < number_of_values+1) {
string current_value;
const string current_field_name = fields[i-1]._name;
const string current_field_type = fields[i-1]._type;
if (!line.item(i, current_value)) {
Error::set(Error::_LINE_TOO_SHORT_EVENT, line.get_line_count(), Error::_WARNING);
return;
}
else if (fields[i-1]._name == "Alias") {
else if (current_field_name == "Alias") {
alias = current_value;
alias_is_initialized = true;
}
else if (fields[i-1]._name == "Name") {
else if (current_field_name == "Name") {
name = current_value;
name_is_initialized = true;
}
else if (fields[i-1]._name == "ContainerType") {
else if (current_field_name == "ContainerType") {
container_type = current_value;
}
else if (fields[i-1]._name == "SourceContainerType") {
else if (current_field_name == "SourceContainerType") {
source_container_type = current_value;
}
else if (fields[i-1]._name == "DestContainerType") {
else if (current_field_name == "DestContainerType") {
dest_container_type = current_value;
}
else if (fields[i-1]._name == "EntityType") {
else if (current_field_name == "EntityType") {
entity_type = current_value;
}
else if (fields[i-1]._name == "Time") {
else if (current_field_name == "Time") {
if(!Date::instantiate(current_value, time)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting a \"date\")", line.get_line_count(), Error::_WARNING);
return;
}
}
else if (fields[i-1]._name == "Type") {
else if (current_field_name == "Type") {
type = current_value;
}
else if (fields[i-1]._name == "Container") {
else if (current_field_name == "Container") {
container = current_value;
}
else if (fields[i-1]._name == "Value") {
if(fields[i-1]._type == "double") {
else if (current_field_name == "Value") {
if(current_field_type == "double") {
if(!Double::instantiate(current_value, value_double)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting a \"double\")", line.get_line_count(), Error::_WARNING);
return;
......@@ -91,64 +94,64 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
}
}
else if (fields[i-1]._name == "SourceContainer") {
else if (current_field_name == "SourceContainer") {
source_container = current_value;
}
else if (fields[i-1]._name == "DestContainer") {
else if (current_field_name == "DestContainer") {
dest_container = current_value;
}
else if (fields[i-1]._name == "Key") {
else if (current_field_name == "Key") {
key = current_value;
}
else {
if(fields[i-1]._type == "string") {
extra_fields[fields[i-1]._name] = new String(current_value);
if(current_field_type == "string") {
extra_fields[current_field_name] = new String(current_value);
}
else if(fields[i-1]._type == "double") {
else if(current_field_type == "double") {
Double value;
if(!Double::instantiate(current_value, value)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting a \"double\")", line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Double(value);
extra_fields[current_field_name] = new Double(value);
}
else if(fields[i-1]._type == "hex") {
else if(current_field_type == "hex") {
Hex value;
if(!Hex::instantiate(current_value, value)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting a \"hex\")", line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Hex(value);
extra_fields[current_field_name] = new Hex(value);
}
else if(fields[i-1]._type == "date") {
else if(current_field_type == "date") {
Date value;
if(!Date::instantiate(current_value, value)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting a \"date\")", line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Date(value);
extra_fields[current_field_name] = new Date(value);
}
else if(fields[i-1]._type == "int") {
else if(current_field_type == "int") {
Integer value;
if(!Integer::instantiate(current_value, value)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting an \"int\")", line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Integer(value);
extra_fields[current_field_name] = new Integer(value);
}
else if(fields[i-1]._type == "color") {
else if(current_field_type == "color") {
Color value;
if(!Color::instantiate(current_value, value)) {
Error::set(Error::_INCOMPATIBLE_VALUE_IN_EVENT + current_value + " (expecting a \"color\")", line.get_line_count(), Error::_WARNING);
return;
}
extra_fields[fields[i-1]._name] = new Color(value);
extra_fields[current_field_name] = new Color(value);
}
else {
Error::set(Error::_FIELD_TYPE_UNKNOWN + fields[i-1]._type, line.get_line_count(), Error::_WARNING);
Error::set(Error::_FIELD_TYPE_UNKNOWN + current_field_type, line.get_line_count(), Error::_WARNING);
return;
}
}
......@@ -170,7 +173,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
}
string event_name = definition.get_event_name();
const string event_name = definition.get_event_name();
if(event_name == "PajeDefineContainerType") {
ContainerType *temp_container_type = trace.search_container_type(container_type);
......
......@@ -50,12 +50,10 @@ void TokenSource::open(const char *filename){
_file.open(filename, ios::in);
// throw Error::_OPEN;
_file.seekg (0, ios::end);
TokenSource::_filesize = _file.tellg();
_file.seekg (0, ios::beg);
// throw Error::_FSTAT;
#else
struct stat buf;
......
......@@ -216,8 +216,8 @@ void Render_opengl::resizeGL(int width, int height) {
void Render_opengl::paintGL(){
list<Element_pos>::iterator it_pos;
list<string>::iterator it_txt;
list<Element_pos>::const_iterator it_pos;
list<string>::const_iterator it_txt;
Element_pos buf_x;
Element_pos buf_y;
string buf_txt;
......
This diff is collapsed.
......@@ -38,14 +38,12 @@ void Render_stats_opengl::resizeGL(int width, int height){
glMatrixMode(GL_MODELVIEW);
//cout << "resize: (" << width<<", "<<height<<")"<< endl;
}
void Render_stats_opengl::paintGL(){
makeCurrent();
glClearDepth(1.0);
glClearColor(1.f, 1.f, 1.f, 1.0f);
// glClearColor(0.5f, 0.5f, 0.55f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
......@@ -55,8 +53,8 @@ void Render_stats_opengl::paintGL(){
glTranslated(-_translated_x, _translated_y, 0);
list<Element_pos>::iterator it_pos;
list<string>::iterator it_txt;
list<Element_pos>::const_iterator it_pos;
list<string>::const_iterator it_txt;
Element_pos buf_x;
Element_pos buf_y;
string buf_txt;
......@@ -64,7 +62,6 @@ void Render_stats_opengl::paintGL(){
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 ++) {
buf_x = *it_pos;
......@@ -118,5 +115,4 @@ void Render_stats_opengl::clear(){
_text_pos.clear();
_text_value.clear();
glDeleteLists(_rect_list, 1);
paintGL();
}
......@@ -28,14 +28,7 @@ public:
*/
DrawDiagram() {
this->_size_for_one_container = _HEIGHT_FOR_ONE_CONTAINER_DEFAULT;
this->_pos_x_container_name = _POS_X_CONTAINER_NAME;
this->_pos_y_container_name = _POS_Y_CONTAINER_NAME;
this->_percentage_height_default = (this->_size_for_one_container - _START_HISTOGRAM_Y_DEFAULT) / 100.;
/* Size for rectangles in the legend */
this->_width_for_rect_legend = 20.;
this->_height_for_rect_legend = 15.;
set_geometrical_informations();
}
......@@ -189,6 +182,18 @@ public:
return value;
}
void set_geometrical_informations() {
this->_pos_x_container_name = _POS_X_CONTAINER_NAME;
this->_pos_y_container_name = this->_size_for_one_container - 30;
this->_percentage_height_default = (this->_size_for_one_container - _START_HISTOGRAM_Y_DEFAULT - 20) / 100.;
/* Size for rectangles in the legend */
this->_width_for_rect_legend = 20.;
this->_height_for_rect_legend = 15.;
this->_max_width = 0;
}
};
#endif
......@@ -26,6 +26,7 @@
* The origin is set at the north west.
*/
#define _POS_X_CONTAINER_NAME 10.0f
/*!
* \def _POS_Y_CONTAINER_NAME
* \brief The default y position for the container name.
......@@ -51,12 +52,6 @@
*/
#define _START_HISTOGRAM_Y_DEFAULT 100.f
/*!
* \def _PERCENTAGE_HEIGHT_DEFAULT
* \brief The default height for 1% in histogram mode.
*/
#define _PERCENTAGE_HEIGHT_DEFAULT 3.f
/*!
* \def _POS_X_LEGEND_DEFAULT
* \brief The default position for the legend.
......@@ -99,6 +94,7 @@ protected:
double _width_for_rect_legend;
double _height_for_rect_legend;
double _max_width;
public:
/*
......@@ -106,14 +102,7 @@ public:
*/
DrawStats() {
_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.;
set_geometrical_informations();
}
......@@ -168,6 +157,17 @@ public:
draw_object->updateGL();
}
virtual void set_geometrical_informations() {
_pos_x_container_name = _POS_X_CONTAINER_NAME;
_pos_y_container_name = _size_for_one_container - 30;
_percentage_height_default = (_size_for_one_container - _START_HISTOGRAM_Y_DEFAULT - 20) / 100.;
/* Size for rectangles in the legend */
_width_for_rect_legend = 20.;
_height_for_rect_legend = 15.;
_max_width = 0;
}
};
#endif
......@@ -149,7 +149,7 @@ void Stats_window::on_x_scroll_valueChanged(int new_value) {
void Stats_window::Reinit_scroll_bars() {
_ui_stats_area->translate_y(0);
_ui_stats_area->translate_x(0);
_ui_stats_area->translate_y(0);
x_scroll->setSliderPosition(0);
y_scroll->setSliderPosition(0);
......
......@@ -36,5 +36,5 @@ std::string Name::to_string() const {
}
bool Name::operator== (String &s) const {
return s == _name || s == _alias;
return s == _alias || s == _name;
}
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