Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit f6332bcc authored by Kevin Coulomb's avatar Kevin Coulomb
Browse files

Corrections of some bugs

parent 7277579c
......@@ -63,7 +63,7 @@ void Command_window::on_execute_button_clicked(){
else if(cmd == "SMALL"){
_selected_containers.clear();
start_time = "0";
end_time = QString::fromStdString(_trace->get_max_date().to_string());
end_time = QString::fromStdString(_trace->get_max_date().to_string());
}
else if(cmd == "RECT")
filter = "0";
......
......@@ -219,19 +219,20 @@ public:
}
add(container,&containers);
/*
for(list<Container*>::const_iterator it = trace->get_root_containers()->begin() ;
it != trace->get_root_containers()->end();
}
//Adding the parent containers if not added yet
else{
for(std::vector<const Container*>::iterator it = container->begin() ;
it != container->end();
it ++){
container->push_back(*it);
//TODO
if( *it && (*it)->get_parent())
if(!is_in_set((*it)->get_parent(),container))
container->push_back((*it)->get_parent());
}
// trace->get_interval_constrained()->_left = 0;
// trace->get_interval_constrained()->_right = trace->get_max_date();*/
}
// for(unsigned int i = 0 ; i < container->size() ; i++)
// std::cout << " Conteur : " << (*container)[i]->get_name().to_string() << std::endl;
interval = trace->get_interval_constrained();
draw_object->start_draw();
......@@ -394,7 +395,7 @@ public:
it++) {
link = *it;
if(link_is_in_set(link,set_container)){
if(link_is_in_set(link,set_container,interval)){
draw_link(draw_object, link->get_start_time().get_value(), link->get_end_time().get_value(),
_container_positions[link->get_source()], _container_positions[link->get_destination()]);
}
......@@ -753,20 +754,25 @@ public:
bool link_is_in_set(Link * link, std::vector<const Container *> *set_container ){
bool link_is_in_set(Link * link, std::vector<const Container *> *set_container, Interval * interval ){
const Container * src = link->get_source();
const Container * dest = link->get_destination();
for(unsigned int i = 0 ; i < set_container->size() ; i++){
if(src == (*set_container)[i]){
for(unsigned int j = 0 ; j < set_container->size() ; j++)
if(dest == (*set_container)[j])
return true;
if(
(interval->_left.get_value() < link->get_start_time().get_value() && interval->_right.get_value() > link->get_end_time().get_value()) ||
(interval->_left.get_value() < link->get_end_time().get_value() && interval->_right.get_value() > link->get_start_time().get_value()))
return true;
}
}
return false;
}
bool is_in_set(const Container * c,std::vector<const Container *>*set_container){
if(!c || !set_container)
return false;
for(unsigned int i = 0 ; i<set_container->size() ; i++ )
if(c==(*set_container)[i])
return true;
......
......@@ -90,8 +90,9 @@ public:
*/
void draw_tree(BinaryTree<E> *tree, const Interval &I){
Node<E> *node = tree->get_root();
bool b = false;
if (node)
browse_tree(I, node);
browse_tree(I, node,b);
}
/*!
......@@ -100,8 +101,8 @@ public:
* \param I : The interval we have to draw node
* \param node : The node we want to draw
*/
void browse_tree(const Interval &I, Node<E> *node);
void browse_tree(const Interval &I, Node<E> *node, bool &b);
/*!
* \fn draw_state(double starttime, double endtime, double r, double g, double b)
* \brief Draw a state
......@@ -145,7 +146,7 @@ struct DrawNode {
* \fn draw_node(DrawTree<D, E> *draw, Node<E> *node)
* \brief To draw a node of type E with a painting object of type D
*/
static void draw_node(DrawTree<D, E> *draw, Node<E> *node) { }
static void draw_node(DrawTree<D, E> *draw, Node<E> *node, bool & b, const Interval * i) { }
};
/*!
......@@ -158,7 +159,11 @@ struct DrawNode<D, Event> {
* \fn draw_node(DrawTree<D, Event> *draw, Node<Event> *node)
* \brief To draw a node of type Event with a painting object of type D
*/
static void draw_node(DrawTree<D, Event> *draw, Node<Event> *node) {
static void draw_node(DrawTree<D, Event> *draw, Node<Event> *node,bool &b, const Interval * i) {
//Just to avoid warning at the compilation, these 2 parameters are only useful in draw_node<stateChange>
b=true;
i++;
draw->draw_event(node->get_element()->get_time().get_value());
}
};
......@@ -169,30 +174,70 @@ struct DrawNode<D, Event> {
*/
template<class D>
struct DrawNode<D, StateChange> {
static void draw_node(DrawTree<D, StateChange> *draw, Node<StateChange> *node) {
if (!node->get_element()->get_right_state())
return;
map<std::string, Value *>::const_iterator field;
const State *state = node->get_element()->get_right_state();
const map<std::string, Value *> *extra_fields;
const Color *color;
extra_fields = state->get_value()->get_extra_fields();
// Search the color
if (state->get_value() &&
!state->get_value()->get_extra_fields()->empty() &&
((field = state->get_value()->get_extra_fields()->find(std::string("Color"))) != extra_fields->end())) {
/* Call the object state drawing function with the state color */
color = (const Color *)(*field).second;
draw->draw_state(state->get_start_time().get_value(), state->get_end_time().get_value(),
color->get_red(), color->get_green(), color->get_blue());
}
else {
/* Call the object state drawing function with default color */
draw->draw_state( state->get_start_time().get_value(), state->get_end_time().get_value(), 0.7, 0.7, 0.75);
}
static void draw_node(DrawTree<D, StateChange> *draw, Node<StateChange> *node, bool& b, const Interval * interval) {
// Part to display the first state
if(!b){
b = true;
// Node<StateChange> n = *node;
// n.get_element()->get_left_state()->set_left_state(interval->_left);
if(/*node &
node->get_element() &*/
node->get_element()->get_left_state()){
map<std::string, Value *>::const_iterator field;
const State *state = node->get_element()->get_left_state();
const map<std::string, Value *> *extra_fields;
const Color *color;
extra_fields = state->get_value()->get_extra_fields();
// Search the color
if (state->get_value() &&
!state->get_value()->get_extra_fields()->empty() &&
((field = state->get_value()->get_extra_fields()->find(std::string("Color"))) != extra_fields->end())) {
/* Call the object state drawing function with the state color */
color = (const Color *)(*field).second;
draw->draw_state(interval->_left.get_value(), state->get_end_time().get_value(),
color->get_red(), color->get_green(), color->get_blue());
}
else {
/* Call the object state drawing function with default color */
draw->draw_state( state->get_start_time().get_value(), state->get_end_time().get_value(), 0.7, 0.7, 0.75);
}
}
}
if (!node->get_element()->get_right_state())
return;
map<std::string, Value *>::const_iterator field;
const State *state = node->get_element()->get_right_state();
const map<std::string, Value *> *extra_fields;
const Color *color;
extra_fields = state->get_value()->get_extra_fields();
// Max is made to not display farther than the interval
double max;
if(state->get_end_time().get_value() > interval->_right.get_value())
max = interval->_right.get_value();
else
max = state->get_end_time().get_value();
// Search the color
if (state->get_value() &&
!state->get_value()->get_extra_fields()->empty() &&
((field = state->get_value()->get_extra_fields()->find(std::string("Color"))) != extra_fields->end())) {
/* Call the object state drawing function with the state color */
color = (const Color *)(*field).second;
draw->draw_state(state->get_start_time().get_value(), max,
color->get_red(), color->get_green(), color->get_blue());
}
else {
/* Call the object state drawing function with default color */
draw->draw_state( state->get_start_time().get_value(), max, 0.7, 0.7, 0.75);
}
}
};
template<class D, class E>
/*!
*\fn DrawTree<D, E>::browse_tree(const Interval &I, Node<E> * node)
......@@ -200,7 +245,7 @@ template<class D, class E>
*\param I The interval we have to display node
*\param node The node in the tree we want to display
*/
void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node, bool & b) {
if(!node)
return;
......@@ -228,10 +273,12 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
// Launching Recursively in children
if (n_children >= 1)//left
browse_tree(Interval(I._left, node->get_element()->get_time()),
node->get_left_child());
node->get_left_child(),
b);
if (n_children >= 2)//right
browse_tree(Interval(node->get_element()->get_time(), I._right),
node->get_right_child());
node->get_right_child(),
b);
// If node's left son has a conflict on it's left side
if(n_children >= 1 && node->get_left_child()->_left_interval) {
......@@ -303,11 +350,11 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
node->_left_interval = NULL;
}
}
// Making sure node has been displayed
if(!displayed) {
DrawNode<D, E>::draw_node(this, node);
DrawNode<D, E>::draw_node(this, node,b,&I);
}
} // end if has enough space
......@@ -320,13 +367,13 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
else {
// If node is after the interval
if (n_children >= 1 && node->get_element()->get_time() > I._right) {
browse_tree(I, node->get_left_child());
browse_tree(I, node->get_left_child(),b);
node->_left_interval = node->get_left_child()->_left_interval;
node->_right_interval = NULL;
}
// Else he is before
else if (n_children >= 2) {
browse_tree(I, node->get_right_child());
browse_tree(I, node->get_right_child(),b);
node->_left_interval = NULL;
node->_right_interval = node->get_right_child()->_right_interval;
}
......
......@@ -102,6 +102,12 @@ public:
*/
const EntityValue *get_value() const;
/*!
* \fn set_left_date(Date)
* \brief To set the left date
*/
void set_left_date(Date);
};
#endif
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