Commit ae6ee410 authored by Kevin Coulomb's avatar Kevin Coulomb

Modification de la structure de donnée pour utiliser les arbres sur les

etats aussi
parent eae6c06d
......@@ -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), _n_events(0), _n_states(0) {
_n_variables(0), _event_tree(0), _state_tree(0), _n_events(0), _n_states(0) {
}
template <class T>
......@@ -20,7 +20,8 @@ Container::~Container() {
clear_list<Container>(_children);
// Delete states
clear_list<State>(_states);
// clear_list<State>(_states);
delete _state_tree;
// Delete events
delete _event_tree;
......@@ -163,8 +164,8 @@ Date Container::get_destruction_time() const {
return _destruction_time;
}
const list<State *> *Container::get_states() const {
return &_states;
BinaryTree<State> *Container::get_states() const {
return _state_tree;
}
BinaryTree<Event> *Container::get_events() const {
......@@ -195,5 +196,6 @@ void Container::finish(const Date &time) {
if (_destruction_time.get_value() == 0.0)
destroy(time);
_event_tree = new BinaryTree<Event>(_events, _n_events);
_state_tree = new BinaryTree<State>(_states,_n_states);//MODIF
}
......@@ -40,6 +40,7 @@ private:
list<Container *> _children;
unsigned int _n_states;
list<State *> _states;
BinaryTree<State> *_state_tree;//MODIF
unsigned int _n_events;
list<Event *> _events;
BinaryTree<Event> *_event_tree;
......@@ -215,7 +216,7 @@ public:
* \fn get_states() const
* \brief Get the state list
*/
const list<State *> *get_states() const;
BinaryTree<State> *get_states() const;// MODIF -> enleve * du template/ du const
/*!
* \fn get_events() const
......
......@@ -176,7 +176,7 @@ public:
_entity_containers.push_back(container);
}
// Use one line dor each variable
// Use one line for each variable
if (container->get_variable_number() > 0) {
_variable_containers.push_back(container);
size += container->get_variable_number();
......@@ -213,17 +213,15 @@ public:
*/
inline void browse_entities(T* draw_object) {
const Container *container;
const list<State *> *state_list;
State *state;
BinaryTree<State> *state_tree;//MODIF
BinaryTree<Event> *event_tree;
Event *event;
const list<Link *> *link_list;
Link *link;
const map<VariableType *, Variable *> *variable_map;
Variable *var;
const list<pair<Date, Double> > *variable_values;
const map<std::string, Value *> *extra_fields;
const Color *color;
// const map<std::string, Value *> *extra_fields;
// const Color *color;
int position;
draw_object->start_draw_states();
......@@ -233,36 +231,42 @@ public:
container = *c;
position = _container_positions[container];
state_list = container->get_states();
event_tree = container->get_events();
if (!state_list->empty() || !event_tree->empty()) {
// Browse states
for (list<State *>::const_iterator i = state_list->begin();
i != state_list->end();
i++) {
state = *i;
map<std::string, Value *>::const_iterator field;
// 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_state(draw_object, state->get_start_time().get_value(), state->get_end_time().get_value(), position,
color->get_red(), color->get_green(), color->get_blue());
}
else {
/* Call the object state drawing function with default color */
draw_state(draw_object, state->get_start_time().get_value(), state->get_end_time().get_value(), position, 0.7, 0.7, 0.75);
}
}/* end for */
state_tree = container->get_states();
event_tree = container->get_events();
if (!state_tree->empty() || !event_tree->empty()) {
// Browse states
DrawTree<T, State>(draw_object, position, 0.0,
_container_height, _container_v_space, _state_height, _state_v_space)
.draw_tree(state_tree, &Interval(Date(0.0), Date(500.0)));
/*
for (list<State *>::const_iterator i = state_list->begin();
i != state_list->end();
i++) {
state = *i;
map<std::string, Value *>::const_iterator field;
// 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_state(draw_object, state->get_start_time().get_value(), state->get_end_time().get_value(), position,
color->get_red(), color->get_green(), color->get_blue());
}
else {
/* Call the object state drawing function with default color */
/* draw_state(draw_object, state->get_start_time().get_value(), state->get_end_time().get_value(), position, 0.7, 0.7, 0.75);
}
}/* end for */
// Browse events
DrawTree<T, Event>(draw_object, position, 0.0,
_container_height, _container_v_space, _state_height, _state_v_space)
.draw_tree(event_tree, &Interval(Date(0.0), Date(500.0)));
_container_height, _container_v_space, _state_height, _state_v_space)
.draw_tree(event_tree, &Interval(Date(0.0), Date(500.0)));
/*for (list<Event *>::const_iterator i = event_list->begin();
i != event_list->end();
i++) {
......@@ -348,10 +352,10 @@ public:
* \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) {
/* 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
......
This diff is collapsed.
......@@ -25,3 +25,6 @@ const EntityValue *State::get_value() const {
return _value;
}
const Date State::get_time() const{
return _start;
}
......@@ -59,6 +59,12 @@ public:
* \return Pointer to the Entityvalue or NULL if it has no value
*/
const EntityValue *get_value() const;
/*!
* \fn get_time()
* \brief Get the time of the state
*/
const Date get_time() const;
};
#endif
......@@ -36,7 +36,7 @@ public:
// Calculate n and m as size = 2^n - 1 + m and m < 2^n
int n = 0;
int a = 1;
unsigned int a = 1;
while (size >= 2*a - 1) {
a *= 2;
n++;
......
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