Commit 50efb1db authored by Augustin Degomme's avatar Augustin Degomme
Browse files

- do not display container names which are too close one to another (when vite...

- do not display container names which are too close one to another (when vite was opened with 1000+ containers, the display of names was very slow)
- the vertical line now displays the value of all crossed variables at the selected time
parent 1e7275d2
......@@ -240,10 +240,13 @@ bool Core::draw_trace(const string & filename, const int format) {
bool killed=false;
#ifdef WITH_VBO
Render<Render_alternate> render(_render_opengl);
Render<Render_alternate>render(_render_opengl) ;
#else
Render<Render_opengl> render(_render_opengl);
Render<Render_opengl> render(_render_opengl) ;
#endif
_render=(void*)&render;
QTime time_elapsed;
ostringstream buf_txt;
......@@ -1146,6 +1149,12 @@ void Core::launch_action(int state, void* arg) {
_render_opengl->apply_zoom_on_interval(((Element_pos*)arg)[0], ((Element_pos*)arg)[1]);
break;
}
case _STATE_UPDATE_VARVALUES:{
std::map<long int, double> var_map = _trace->update_text_variable_values(((Element_pos*)arg)[0]);
buf.draw_text_variable_values(_render_opengl,&var_map,((Element_pos*)arg)[0]);
break;
}
case _LOAD_DATA:{
//case where data has to be loaded from serialized files, after a zoom in the preview
......
......@@ -230,6 +230,8 @@ public:
static const int _LOAD_DATA = 28;
static const int _STATE_SWITCH_CONTAINERS = 29;
static const int _STATE_UPDATE_VARVALUES = 30;
/*!
* \brief Launch an action according to the argument state value.
* \param state An integer corresponding to a kind of action which must be executed.
......@@ -293,6 +295,8 @@ protected:
#else
Render_opengl* _render_opengl;
#endif
void* _render;
//Render<Render_opengl>* _render_opengl;
......
......@@ -389,7 +389,8 @@ void Hook_event::mouseReleaseEvent(QMouseEvent * event){
&& ((_new_mouse_y-_mouse_y) < _minimum_distance_for_selection)){/* selection is too thin to draw a box. So, it must be a user click to display entity information */
//start the timer to catch a click or double click
_timer->start(getTimeClick());
double d =render_to_trace_x( screen_to_render_x(_mouse_x));
_core->launch_action(_core->_STATE_UPDATE_VARVALUES, &d);//update the value of the variables to display
_mouse_pressed = false;
_mouse_pressed_inside_container = false;
......
......@@ -379,6 +379,17 @@ public:
_start_new_line = true;
}
/*!
* \brief Draw a text with the value of a variable
* \param text text to draw.
* \param y y position of the point.
*
*/
inline void draw_text_value(long int id, double text, double y){
drawing_instance->draw_text_value(id,text,y);
}
/*!
* \brief Draw a point of the counter.
* \param x x position of the point.
......
......@@ -118,7 +118,7 @@ Render_opengl::Render_opengl(Core* core, QWidget *parent, const QGLFormat& forma
_arrows.clear();
_circles.clear();
_texts.clear();
_variable_texts.clear();
/* init the wait animation */
_wait_list = 0;
_wait_angle = 0.0f; /* begin with 0 rad angle */
......@@ -375,19 +375,31 @@ void Render_opengl::paintGL(){
/* Draw container text */
const unsigned int texts_size = _texts.size();
std::map<Element_pos,Element_pos> previous_by_column;
//int skipped,displayed=0;
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/(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 */
//check if ye are not too close to another container to properly display the text
std::map<Element_pos,Element_pos>::const_iterator it = previous_by_column.find(_texts[i].x);
const std::map<Element_pos,Element_pos>::const_iterator it_end = previous_by_column.end();
if (it==it_end || (trace_to_render_y(_texts[i].y) - trace_to_render_y((*it).second)>1)){
renderText ( render_to_screen_x(_texts[i].x * _x_scale_container_state/0.20),
render_to_screen_y( trace_to_render_y(_texts[i].y) + 0.5),
text_elided,
arial_font);
//push only displayed values in the map
previous_by_column[_texts[i].x]=_texts[i].y;
//displayed++;
}//else{skipped++;}
}
// printf("skipped %d displayed %d\n", skipped, displayed);
/* Draw ruler text */
......@@ -714,6 +726,22 @@ void Render_opengl::set_color(float r, float g, float b){
_blue = b;
}
void Render_opengl::draw_text_value(long int id,double text, double y){
if(y!=-1){
Variable_text_ buf;
buf.y=y;
buf.value=text;
// printf("adding %f at %f for %p\n", text, y, (void*)id);
_variable_texts[id]=buf;
}else{
//it's an update
Variable_text_ buf=_variable_texts[id];
buf.value=text;
//printf("updating %f at %f for %p\n", text, y, (void*)id);
_variable_texts[id]=buf;
}
}
void Render_opengl::draw_text(const Element_pos x, const Element_pos y, const Element_pos, const std::string s){
if (_draw_ruler) return;/* do not draw text for ruler */
if (_draw_state) message << "Fatal error! Cannot put text in state lists!" << Message::ende;
......@@ -1112,6 +1140,8 @@ void Render_opengl::draw_stored_circles(){
}
void Render_opengl::update_vertical_line(){
if (_mouse_pressed_inside_container)
set_vertical_line(0);
else
......@@ -1126,6 +1156,7 @@ Element_pos Render_opengl::get_vertical_line(){
void Render_opengl::set_vertical_line(Element_pos new_coord){
if(new_coord==vertical_line)vertical_line=0;
else vertical_line=new_coord;
}
......@@ -1145,6 +1176,18 @@ void Render_opengl::draw_vertical_line(){
glEnd();
}
glPopMatrix();
//draw texts for variables
std::map<long int, Variable_text_>::const_iterator it=_variable_texts.begin();
const std::map<long int, Variable_text_>::const_iterator it_end=_variable_texts.end();
QFont arial_font = QFont("Arial", 10);
for(;it!=it_end;it++){
renderText ( render_to_screen_x(trace_to_render_x(vertical_line))+3,
render_to_screen_y( trace_to_render_y((*it).second.y) + 0.5),
QString().setNum((*it).second.value),
arial_font);
}
}
// void Render_opengl::create_minimap(const int width, const int height){
......@@ -1247,4 +1290,5 @@ void Render_opengl::clear_arrow (){
void Render_opengl::clear_text (){
_texts.clear();
_variable_texts.clear();
}
......@@ -110,6 +110,17 @@ struct Event_{
Element_col red, green, blue;
};
/*!
* \brief Structure used to store event information.
*/
struct Variable_text_{
/*!
* \brief Coordinates and radius.
*/
Element_pos y;
Element_pos value;
};
/*!
* \brief This class redefined the OpenGL widget - QGLWidget - to display the trace.
......@@ -174,6 +185,7 @@ protected:
float _red, _green, _blue;
std::vector<Container_text_> _texts;
std::map<long int, Variable_text_> _variable_texts;
std::vector<Arrow_> _arrows;
std::vector<Event_> _circles;
......@@ -435,6 +447,13 @@ public:
*/
void start_draw_counter();
/*!
* \brief Draw a text with the value of a variable
* \param text text to draw.
* \param y y position of the point.
*/
void draw_text_value(long int id,double text, double y);
/*!
* \brief Draw a point of the counter.
* \param x x position of the point.
......
......@@ -282,6 +282,13 @@ public:
*/
void draw_circle(Element_pos x, Element_pos y, Element_pos z, Element_pos r);
/*!
* \brief Draw a text with the value of a variable
* \param text text to draw.
* \param y y position of the point.
*/
void draw_text_value(long int id, double text, double y){}
};
......
......@@ -115,6 +115,7 @@ protected:
*/
std::list<const Container *> _variable_containers;
std::map<const Container *, Element_pos, std::less<const Container *> > _container_positions;
std::map<const Variable*, Element_pos> _var_positions;
// Geometrical informations about the trace shape.
/*!
......@@ -512,7 +513,10 @@ public:
double first_value = 0.;
double second_value = 0.;
draw_object->draw_text_value((long int)var,0.0, (position+1)*(_container_height+_container_v_space) - _container_v_space/2 -
0.5*_container_height);
_var_positions[var]=position;
draw_variable_value(draw_object, 0.0, 0.0, position);
for (std::list<std::pair<Date, Double> >::const_iterator value = variable_values->begin();
value != variable_values->end();
......@@ -696,6 +700,7 @@ public:
<< "<strong>Container:</strong> " << variable->get_container()->get_name().to_string() << "<br />"
<< "<strong>Type:</strong> " << variable->get_type()->get_name().to_string() << "<br />"
<< "<strong>Value:</strong> " << variable->get_value_at(x) << "<br />"
<< "<strong>Value:</strong> " << variable->get_value_at(x) << "<br />"
<< "<strong>Min:</strong> " << variable->get_min().get_value() << "<br />"
<< "<strong>Max:</strong> " << variable->get_max().get_value() << "<br />";
print_extra_fields("Type", variable->get_type()->get_extra_fields());
......@@ -930,6 +935,18 @@ public:
}
add(container,containers);
}
}
}
template<class T>
void draw_text_variable_values(T* render, std::map<long int, double>* var_map, double date){
std::map<long int, double>::const_iterator it=var_map->begin();
const std::map<long int, double>::const_iterator it_end=var_map->end();
while(it!=it_end){
render->draw_text_value((*it).first,(*it).second, -1);
it++;
}
}
};
#endif
......@@ -1052,3 +1052,52 @@ void Trace::load_names_rec(Container *current_container, QDomElement& element) {
}
std::map<long int,double> Trace::update_text_variable_values(double date){
std::map<long int,double> values;
stack<Container *> containers;
const Container::Vector* root_containers =&_view_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
Container::VectorIt i = root_containers->begin();
Container::VectorIt const &end = root_containers->end();
const Variable* var;
for (; i != end; i++)
containers.push(*i);
while (!containers.empty()) {
Container * c = containers.top();
containers.pop();
if (c->get_variable_number() > 0){
const std::map<VariableType *, Variable *>* variable_map = c->get_variables();
for (std::map<VariableType *, Variable *>::const_iterator i = variable_map->begin();
i != variable_map->end();
i++) {
var = (*i).second;
values [(long int)var]= var->get_value_at(date);
//draw_object->draw_text_value((long int)var,var->get_value_at(date), position);
}
}
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
for (; it != it_end; it++)
containers.push(*it);
}
}
return values;
}
......@@ -473,6 +473,8 @@ public :
void load_names_rec(Container *current_container, QDomElement& element);
std::map<long int,double> update_text_variable_values(double date);
};//end class
void get_state_names_colors_list(std::map<std::string, Color *> &name_map, Node<StateChange> *node);
......
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