Commit 9fb51a9d authored by Kevin Coulomb's avatar Kevin Coulomb

Correction pour les etats non affichachées si gris, et un peu de doc

supplémentaire
parent 7957fe85
......@@ -3,7 +3,7 @@
Container::Container(Name name, Date creation_time, ContainerType *type, Container *parent):
_name(name), _creation_time(creation_time), _destruction_time(0.0), _type(type), _parent(parent),
_n_variables(0), _event_tree(0), _state_tree(0), _n_events(0), _n_states(0) {
_n_states(0), _state_tree(0), _n_events(0), _event_tree(0), _n_variables(0) {
}
template <class T>
......
......@@ -25,9 +25,19 @@ class DrawTrace
protected:
// Interface_graphic* _window;
std::list<const Container *> _entity_containers; // Containers with states or events
std::list<const Container *> _link_containers; // Containers with links
std::list<const Container *> _variable_containers; // Containers with variables
/*!
* \brief Containers with states or events
*/
std::list<const Container *> _entity_containers;
/*!
* \brief Containers with links
*/
std::list<const Container *> _link_containers;
/*!
* \brief Containers with variables
*/
std::list<const Container *> _variable_containers;
std::map<const Container *, Element_pos, std::less<const Container *> > _container_positions;
/*!
......@@ -140,6 +150,10 @@ public:
*
**********************************/
/*
* \fn browse_container_tree(T* draw_object, Trace* trace)
* \brief Function that browses the containers of the trace argument and make them painted with a T object
*/
inline void browse_container_tree(T* draw_object, Trace* trace){
/*** Drawing containers ***/
int position = 0;
......@@ -156,6 +170,11 @@ public:
}/* end browse_container_tree */
/*
* \fn browse_container(T* draw_object, const Container *container, int position, int depth)
* \brief Recursive function that browse a container to draw it with a T painting object in position, knowing the current depth in the tree
*/
int browse_container(T* draw_object, const Container *container, int position, int depth) {
int size = 0;
......@@ -311,32 +330,7 @@ public:
draw_object->end_draw_counter();
}
/*!
* \brief Draw a state
* \param draw_object Object that contains the drawing methods
* \param starttime Time when the state begins
* \param endtime Time when the state ends
* \param position Line where the state is drawn
* \param r Red value of the state color
* \param g Green value of the state color
* \param b Blue value of the state color
*/
/* inline void draw_state(T *draw_object, double starttime, double endtime, int position, double r, double g, double b) {
Element_pos y = position*(_container_height+_container_v_space) + _container_v_space/2;
draw_object->draw_state(starttime, endtime, y, _state_height, r, g, b);
}*/
/*!
* \brief Draw an event
* \param draw_object Object that contains the drawing methods
* \param time Time of the event
* \param position Line where the event is drawn
*/
/*inline void draw_event(T *draw_object, double time, int position) {
Element_pos y = position*(_container_height+_container_v_space) + _container_v_space/2;
draw_object->draw_event(time, y, _state_height);
}*/
/*!
* \brief Draw a point of a variable curve
......
/*!
*\file DrawTree.hpp
*/
#ifndef DRAWTREE_HPP
#define DRAWTREE_HPP
......@@ -6,6 +10,9 @@
#include <iostream>
template<class D, class E>
/*!
* \brief Class called to draw a binary tree of type E using a D painting object
*/
class DrawTree {
private:
D *_draw_object;
......@@ -31,7 +38,7 @@ public:
}
/*!
* \fn browse_draw_tree_root( BinaryTree * tree, Interval * I)
* \fn draw_tree( BinaryTree<E> * tree, const Interval &I)
* \brief Function called to draw on ViTE the elements of a tree
* \param tree : The tree we want to draw
* \param I : The interval we have to draw the tree
......@@ -43,7 +50,7 @@ public:
}
/*!
* \fn browse_draw_tree( Interval * I, Node * node)
* \fn browse_tree(const Interval &I, Node<E> *node)
* \brief Function called to draw on ViTE a node
* \param I : The interval we have to draw node
* \param node : The node we want to draw
......@@ -75,27 +82,46 @@ public:
}
/*!
* \fn display_busy(Interval *I)
* \fn draw_busy(Interval *I)
* \brief Function that display a purple squarre in the interval selected
*/
inline void draw_busy(Interval *I) {
draw_state(I->_left.get_value(), I->_right.get_value(), 0.9, 0.9, 0.9);
draw_state(I->_left.get_value(), I->_right.get_value(), 0.2, 0.2, 0.2);
}
};
/*!
* \struct DrawNode
* \brief Structure to draw a node of type E with a painting object of type D
*/
template<class D, class E>
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) { }
};
/*!
* \struct DrawNode
* \brief Draw a Node<Event> with a D painting object
*/
template<class D>
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) {
draw->draw_event(node->get_element()->get_time().get_value());
}
};
/*!
* \struct DrawNode
* \brief Draw a Node<StateChange> with a D painting object
*/
template<class D>
struct DrawNode<D, StateChange> {
static void draw_node(DrawTree<D, StateChange> *draw, Node<StateChange> *node) {
......@@ -124,7 +150,7 @@ struct DrawNode<D, StateChange> {
template<class D, class E>
/*!
*\fn browse_tree(Interval * I, Node<E> * node)
*\fn DrawTree<D, E>::browse_tree(const Interval &I, Node<E> * node)
*\brief Function that browses a tree to display
*\param I : The interval we have to display node
*\param Node : The node in the tree we want to display
......@@ -151,9 +177,9 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
// If the node is in the interval
if(node->get_element()->get_time() <= I._right &&
node->get_element()->get_time() >= I._left) {
// If the node can be displayed (interval is wide enought)
if (I._right - I._left > _min_size) {
if (I._right - I._left > _min_size){
// Launching Recursively in children
if (n_children >= 1)//left
browse_tree(Interval(I._left, node->get_element()->get_time()),
......@@ -168,7 +194,7 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
node->_left_interval = new Interval(node->get_left_child()->_left_interval->_left,
node->get_left_child()->_left_interval->_right);
}
// Else no problem on the left
// Else no problem on the left (if a leaf, treated later)
else {
node->_left_interval = NULL;
}
......@@ -178,83 +204,32 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
node->get_left_child()->_right_interval &&
node->get_right_child()->_left_interval) {
// If node is too close of the problematic area by both sides
if(node->get_element()->get_time() - node->get_left_child()->_right_interval->_right < _min_size &&
node->get_right_child()->_left_interval->_left - node->get_element()->get_time() < _min_size) {
// Drawing a crowded area
draw_busy(new Interval(node->get_left_child()->_right_interval->_left,
node->get_right_child()->_left_interval->_right));
displayed = true;
if(!node->get_left_child()->_right_interval)
delete node->get_left_child()->_right_interval;
if (!node->get_left_child()->_left_interval &&
node->get_left_child()->_right_interval != node->get_right_child()->_left_interval)
delete node->get_right_child()->_left_interval;
node->get_right_child()->_left_interval = NULL;
node->get_left_child()->_right_interval = NULL;
}
// If 2 intervals present but only the left is problematic
else if(node->get_element()->get_time() - node->get_left_child()->_right_interval->_right < _min_size){
displayed = true;
draw_busy(new Interval(node->get_left_child()->_right_interval->_left,
node->get_element()->get_time()));
draw_busy(node->get_right_child()->_left_interval);
if(!node->get_left_child()->_right_interval)
delete node->get_left_child()->_right_interval;
node->get_left_child()->_right_interval = NULL;
}
// If 2 intervals present but only the right is problematic
else if(node->get_right_child()->_left_interval->_left - node->get_element()->get_time() < _min_size){
displayed = true;
draw_busy(new Interval(node->get_element()->get_time(),
node->get_right_child()->_left_interval->_right));
draw_busy(node->get_left_child()->_right_interval);
if(!node->get_right_child()->_left_interval)
delete node->get_right_child()->_left_interval;
node->get_right_child()->_left_interval = NULL;
}
else{
draw_busy(node->get_left_child()->_right_interval);
draw_busy(node->get_right_child()->_left_interval);
displayed = true;
DrawNode<D, E>::draw_node(this, node);
}
// Drawing a crowded area
draw_busy(new Interval(node->get_left_child()->_right_interval->_left,
node->get_right_child()->_left_interval->_right));
displayed = true;
delete node->get_left_child()->_right_interval;
delete node->get_right_child()->_left_interval;
node->get_right_child()->_left_interval = NULL;
node->get_left_child()->_right_interval = NULL;
}
// Else if problem possible with the left child : it's right interval
else if (n_children >= 1 && node->get_left_child()->_right_interval) {
// If node is in the problematic area
if(node->get_element()->get_time() - node->get_left_child()->_right_interval->_right < _min_size) {
displayed = true;
draw_busy(new Interval(node->get_left_child()->_right_interval->_left,
node->get_element()->get_time()));
if(!node->get_left_child()->_right_interval)
delete node->get_left_child()->_right_interval;
node->get_left_child()->_right_interval = NULL;
}
else {
draw_busy(node->get_left_child()->_right_interval);
}
draw_busy(new Interval(node->get_left_child()->_right_interval->_left,
node->get_element()->get_time()));
delete node->get_left_child()->_right_interval;
node->get_left_child()->_right_interval = NULL;
}
// Else if problem possible with the right child : it's left interval
else if (n_children >= 2 && node->get_right_child()->_left_interval) {
if(node->get_right_child()->_left_interval->_left - node->get_element()->get_time() < _min_size) {
displayed = true;
draw_busy(new Interval(node->get_element()->get_time(),
node->get_right_child()->_left_interval->_right));
if(!node->get_right_child()->_left_interval)
delete node->get_right_child()->_left_interval;
node->get_right_child()->_left_interval = NULL;
}
else {
draw_busy(node->get_right_child()->_left_interval);
}
}
else if(n_children>= 1 && !displayed){
displayed = true;
DrawNode<D, E>::draw_node(this, node);
draw_busy(new Interval(node->get_element()->get_time(),
node->get_right_child()->_left_interval->_right));
delete node->get_right_child()->_left_interval;
node->get_right_child()->_left_interval = NULL;
}
......@@ -262,18 +237,35 @@ void DrawTree<D, E>::browse_tree(const Interval &I, Node<E> *node) {
if(n_children >= 2 && node->get_right_child()->_right_interval) {
// Setting the node's right interval as busy
node->_right_interval = node->get_right_child()->_right_interval;
}
// Else no problem on the right
}
// Else no problem on the right (if a leaf, treated after)
else {
node->_right_interval = NULL;
}
// Treating the special case of a leaf
if(n_children == 0){
//If too close of the previous node
if(node->get_element()->get_time() - I._left < _min_size){
node->_left_interval= new Interval(I._left,
node->get_element()->get_time());
node->_right_interval = NULL;
}
//If too close of the following node
if(I._right - node->get_element()->get_time() < _min_size){
node->_right_interval = new Interval(node->get_element()->get_time(),
I._right);
node->_left_interval = NULL;
}
}
// Making sure node has been displayed
if(!displayed) {
DrawNode<D, E>::draw_node(this, node);
}
} // end if has enough space
else {
// Cannot display node so the busy intervals are the same and value I
node->_left_interval = new Interval(I);
......
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