Commit 224052b5 authored by Olivier Lagrasse's avatar Olivier Lagrasse

[Bug Fix]

- Add the Trace container depth information for the render area. Since the render area does not have access to the Trace instance, the information is given through the Info class.
parent d68bc24a
......@@ -75,6 +75,8 @@ Element_pos Info::Render::_info_accurate = 0.0;
bool Info::Render::_no_arrows = false;
bool Info::Render::_no_events = false;
int Info::Trace::depth=0;
void Info::release_all(){
Info::Container::x_min = 0;
......
......@@ -251,6 +251,16 @@ public:
static const int X_SCREEN_RIGHT_MOVE = 7;
};
/*!
* \brief Sub structure to store trace information.
*/
struct Trace{
/*!
* \brief The depth (number of stacked containers) of the data structure.
*/
static int depth;
};
};
......
......@@ -323,7 +323,7 @@ void Render_opengl::paintGL(){
const unsigned int texts_size = _texts.size();
for (unsigned int i=0 ; i<texts_size ; i++){
const QFontMetrics metric(arial_font);
const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/3.);
const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/(Info::Trace::depth+1.));
if (trace_to_render_y(_texts[i].y) + 0.5 < 9) continue;/* Do not display text if it is on the ruler area */
......
......@@ -68,6 +68,11 @@ using namespace std;
Container::Container(Name name, Date creation_time, ContainerType *type, Container *parent, map<string, Value *> &opt):
_name(name), _creation_time(creation_time), _destruction_time(0.0), _type(type), _parent(parent),
_n_states(0), _state_tree(0), _n_events(0), _event_tree(0), _n_variables(0), _extra_fields(opt) {
if (parent)
_depth = parent->_depth+1;
else
_depth=0;
}
template <class T>
......@@ -408,4 +413,11 @@ void browse_stat_link(const Container * cont, Statistic * S, Interval I){
browse_stat_link(cont->get_parent(), S, I);
}
void Container::set_depth(int depth){
_depth = depth;
}
int Container::get_depth(){
return _depth;
}
......@@ -78,7 +78,8 @@ private:
unsigned int _n_variables;
std::map<VariableType *, Variable *> _variables;
std::map<std::string, Value *> _extra_fields;
int _depth;/* The container depth within the datastructure. The _depth of seed is equal to 0 */
/*
* Temporary stores states before complete definition
*/
......@@ -324,6 +325,22 @@ public:
* \brief Fill the stat element with the corresponding data to be displayed
*/
void fill_stat(Statistic * stat, Interval I);
/*!
* \fn set_depth()
* \brief The depth of the current container.
*
* The depth argument specify the depth of the current container. It should be set by the trace instance which store the container.
*/
void set_depth(int depth);
/*!
* \fn get_depth()
* \brief Return the depth of the current container.
*/
int get_depth();
};
/*!
......@@ -341,4 +358,5 @@ void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I,
*/
void browse_stat_link(const Container * cont, Statistic * S, Interval I);
#endif
......@@ -65,6 +65,10 @@
#include "trace/Entitys.hpp"
#include "trace/Trace.hpp"
/* -- */
#include "common/common.hpp"
#include "common/Info.hpp" /* Dirty, should be remove */
#include "common/Message.hpp"
/* -- */
#include "trace/tree/Interval.hpp"
/* -- */
using namespace std;
......@@ -74,6 +78,7 @@ Trace::Trace(): _max_date(0.0) {
_selected_container = NULL;
_filter = 0;
_interval_constrained = NULL;
_depth = 0;
if(Session::get_use_palette())
_palette = Session::get_palette(Session::get_current_palette());
......@@ -161,11 +166,20 @@ void Trace::create_container(Date &time, Name &name, ContainerType *type, Contai
return;
Container *cont = new Container(name, time, type, parent, opt);
if (parent)
if (parent){
cont->set_depth(parent->get_depth()+1);
parent->add_child(cont);
else
} else {
cont->set_depth(0);
_root_containers.push_back(cont);
}
/* Update the trace depth */
if (cont->get_depth() > _depth){
_depth=cont->get_depth();
Info::Trace::depth=_depth; /* Dirty method. Should be remove */
}
if (time > _max_date)
_max_date = time;
......@@ -539,6 +553,11 @@ Date Trace::get_max_date(){
return _max_date;
}
int Trace::get_depth(){
return _depth;
}
void Trace::set_selected_container(vector<const Container *> * c) {
_selected_container = c;
}
......
......@@ -92,7 +92,12 @@ private:
* \brief zoom level
*/
double _filter;
/*!
* \brief Store the depth of the trace. (number of stacked containers).
*/
int _depth;
/*!
* \brief add all the children of parent to the list
* \param containers the list where we add the children
......@@ -365,6 +370,12 @@ public :
*/
Date get_max_date();
/*!
* \fn get_depth()
* \brief Return the depth of the trace. Trace loading MUST be completed!
*/
int get_depth();
// Set
void set_selected_container (std::vector<const Container *> *);
void set_interval_constrained(Interval *);
......
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