Commit 5598d54f authored by Kevin Coulomb's avatar Kevin Coulomb
Browse files

Bug corrected

parent f0a6bc50
......@@ -216,17 +216,23 @@ void Container::fill_stat( Statistic * stat, Interval I){
if(this->get_children()->empty()) {
browse_stat_link(this,stat,I);
}
Node<StateChange> * prev = NULL;
Node<StateChange> * sauv = NULL;
Node<StateChange> ** prev = &sauv;
Node<StateChange> * node = this->get_states()->get_root();
double tmp;
browse_stat_state(node,stat,I,prev);
// To add the first partial state of the interval
if(prev &&
prev->get_element() &&
prev->get_element()->get_right_state()){
if(prev->get_element()->get_right_state()->get_end_time() >
if(sauv &&
sauv->get_element() &&
sauv->get_element()->get_right_state()){
if(sauv->get_element()->get_right_state()->get_end_time() >
I._left){
stat->add_state(node->get_element()->get_right_state()->get_value(),
prev->get_element()->get_right_state()->get_end_time()-I._left);
if( sauv->get_element()->get_right_state()->get_end_time() > I._right)
tmp = I._right - I._left;
else
tmp = sauv->get_element()->get_right_state()->get_end_time() - I._left;
stat->add_state(sauv->get_element()->get_right_state()->get_value(),tmp);
}
}
......@@ -234,7 +240,7 @@ void Container::fill_stat( Statistic * stat, Interval I){
}
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, Node<StateChange>* prev){
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, Node<StateChange>** prev){
if( ! node ||
! node->get_element())
......@@ -267,20 +273,20 @@ void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I,
}
}
else{
// Else node is before the interval
if(node->get_right_child()){
if( ! prev ){
prev = node;
}
else if(node->get_element()->get_right_state()){
if(node->get_element()->get_right_state()->get_start_time() >=
prev->get_element()->get_right_state()->get_start_time()){
prev = node;
}
else{ // Else node is before the interval
if( !(*prev) ){
*prev = node;
}
if(node->get_element()->get_right_state()){
if(node->get_element()->get_right_state()->get_start_time() >=
(*prev)->get_element()->get_right_state()->get_start_time()){
*prev = node;
}
}
if(node->get_right_child()){
browse_stat_state(node->get_right_child(),stats,I,prev);
}
}
}
......
......@@ -282,7 +282,7 @@ public:
* \param bool : A boolean used to remember if the first element has been displayed or not
* \param prev : To save the previous state before the interval to be able to count it in the statistic
*/
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, Node<StateChange> * prev);
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, Node<StateChange> ** prev);
/*!
* \fn fill_stat(Container * cont, Statistic * stat, Interval I)
* \brief Fill the stat element with the corresponding data to be displayed
......
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