Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b15edf5d authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Correct legend for HDiagram

parent 301638f6
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@
#include<math.h> /* for min and max functions */
/*!
* \brief unity for count elements such as number of states or events... NOT USED YET
* \brief Unity for count elements such as number of states or events... NOT USED YET
*/
typedef long Element_count ;
......@@ -25,7 +25,7 @@ typedef long Element_count ;
typedef double Element_pos;
/*!
* \brief unity for colors
* \brief Unity for colors
*/
typedef double Element_col;
......
......@@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include <map>
#include <set>
#include "../message/Message.hpp"
#include "../trace/Trace.hpp"
......@@ -29,6 +30,7 @@ protected:
double _draw_height;
double _legend_width;
double _legend_height;
std::set<const EntityValue*> _setstates;
public:
/*
......@@ -111,7 +113,7 @@ public:
for(int i = 0 ; i < nbcont ; i ++) {
draw_diagram(draw_object, i);
}
draw_legend(draw_object,
draw_legend(draw_object,
_POS_X_LEGEND_DEFAULT + _startx,
_POS_Y_LEGEND_DEFAULT + _starty - (nbcont+3)*_WIDTH_HISTOGRAM_DEFAULT);
end_draw(draw_object);
......@@ -127,7 +129,6 @@ public:
stat_temp = new Statistic();
this->_containers_to_print[container_id]->fill_stat(stat_temp, Interval(this->_start_time, this->_end_time));
temp_states = stat_temp->get_states();
this->_states.push_back(temp_states);
duration = this->_end_time - this->_start_time;
// Printing of the trace
......@@ -172,33 +173,43 @@ public:
if ( width > 30. )
draw_object->draw_text(pos_x + width / 2 - 10., pos_y + _WIDTH_HISTOGRAM_DEFAULT / 2. - 5.,
QString::number(percent*100., 'f', 1).toStdString()+"%");
pos_x += width;
this->_setstates.insert((*it).first);
}
delete stat_temp;
}
void draw_legend(T* draw_object, int pos_x, int pos_y) {
void draw_legend(T* draw_object, int pos_x, int pos_y)
{
std::set<const EntityValue *>::const_iterator it;
std::set<const EntityValue *>::const_iterator end;
const double w = this->_width_for_rect_legend;
const double h = this->_height_for_rect_legend;
/* used to print legend on 3 rows */
int decalage = 0;
for (map<const EntityValue *, stats *>::iterator it = this->_states[0].begin();
it != this->_states[0].end();
it ++, decalage ++) {
std::string name = (*it).first->get_name().to_string();
draw_object->draw_text(pos_x+w+_POS_X_LEGEND_DEFAULT, pos_y, name);
end = this->_setstates.end();
for (it = this->_setstates.begin();
it != end;
it ++, decalage ++)
{
std::string name = (*it)->get_name().to_string();
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_text(pos_x+w+_POS_X_LEGEND_DEFAULT, pos_y, name);
if((*it)->get_extra_fields()->find(std::string("Color")) != (*it)->get_extra_fields()->end())
{
const Color *color = (const Color *)(*it)->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());
}
else {
}
else
{
draw_object->draw_rect(pos_x, pos_y, w, h, 0.7, 0.7, 0.75);
}
}
switch(decalage%3) {
case 2:
......@@ -209,7 +220,7 @@ public:
pos_y -= 20;
break;
}
}
}
}
};
......
......@@ -258,12 +258,14 @@ void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I,
//Add the right state of the state change
if(node->get_element()->get_right_state())
if(node->get_element()->get_right_state()->get_end_time() < I._right){
stats->add_state(node->get_element()->get_right_state()->get_value(),node->get_element()->get_right_state()->get_duration());
{
if(node->get_element()->get_right_state()->get_end_time() < I._right){
stats->add_state(node->get_element()->get_right_state()->get_value(),node->get_element()->get_right_state()->get_duration());
}
else{
stats->add_state(node->get_element()->get_right_state()->get_value(),I._right - node->get_element()->get_right_state()->get_start_time());
stats->add_state(node->get_element()->get_right_state()->get_value(),I._right - node->get_element()->get_right_state()->get_start_time());
}
}
}
// Else if after the interval
......
......@@ -199,6 +199,10 @@ const list <Container *> *Trace::get_root_containers() const {
return &_root_containers;
}
const list <StateType *> *Trace::get_state_types() const {
return &_state_types;
}
template<class T>
static T *search_tree(String name, T *el) {
if (el->get_name() == name)
......
......@@ -44,13 +44,13 @@ using std::vector;
class Trace {
private:
Date _max_date;
list <ContainerType *> _root_container_types;
list <Container *> _root_containers;
list <StateType *> _state_types;
list <EventType *> _event_types;
list <LinkType *> _link_types;
list <VariableType *> _variable_types;
Date _max_date;
list<ContainerType *> _root_container_types;
list<Container *> _root_containers;
list<StateType *> _state_types;
list<EventType *> _event_types;
list<LinkType *> _link_types;
list<VariableType *> _variable_types;
public :
Trace();
......@@ -101,7 +101,6 @@ public :
*/
void define_state_type(Name &alias, ContainerType *container_type, map<std::string, Value *> &opt);
/*!
* \brief Define a type of variable
* \param alias Name of the type
......@@ -244,6 +243,14 @@ public :
*/
const list <Container *> *get_root_containers() const;
/*!
* \brief Define a type of state
* \param alias Name of the type
* \param container_type Type of the container for these states
* \param opt Extra fields
*/
const list <StateType*> *get_state_types() const;
/*!
* \fn search_container_type(String name) const
* \brief Search a container type by his name or alias
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment