From aa64bd55225b94914c3008c9f1ecc97ccdaf83f4 Mon Sep 17 00:00:00 2001 From: Thibault Soucarre <thibault.soucarre@inria.fr> Date: Mon, 25 Aug 2014 13:05:57 +0000 Subject: [PATCH] Correct container texts when using node selection --- src/interface/Node_select.cpp | 172 ++++++++++++++++---------------- src/render/Render_alternate.cpp | 143 +++++++++++++------------- src/render/Render_alternate.hpp | 3 + src/render/Render_opengl.cpp | 9 +- src/trace/EntityValue.hpp | 3 + 5 files changed, 173 insertions(+), 157 deletions(-) diff --git a/src/interface/Node_select.cpp b/src/interface/Node_select.cpp index bac7725d..9405d38e 100644 --- a/src/interface/Node_select.cpp +++ b/src/interface/Node_select.cpp @@ -6,13 +6,13 @@ ** use, modify and/or redistribute the software under the terms of the ** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following ** URL: "http://www.cecill.info". -** +** ** As a counterpart to the access to the source code and rights to copy, ** modify and redistribute granted by the license, users are provided ** only with a limited warranty and the software's author, the holder of ** the economic rights, and the successive licensors have only limited ** liability. -** +** ** In this respect, the user's attention is drawn to the risks associated ** with loading, using, modifying and/or developing or reproducing the ** software by the user in light of its specific status of free software, @@ -23,7 +23,7 @@ ** their requirements in conditions enabling the security of their ** systems and/or data to be ensured and, more generally, to use and ** operate it in the same conditions as regards security. -** +** ** The fact that you are presently reading this means that you have had ** knowledge of the CeCILL-A license and that you accept its terms. ** @@ -37,7 +37,7 @@ ** - MARCOUEILLE Jule ** - NOISETTE Pascal ** - REDONDY Arthur -** - VUCHENER Clément +** - VUCHENER Clément ** */ #include <iostream> @@ -91,14 +91,14 @@ Node_select::~Node_select() { } void Node_select::set_initial_container_names(){ - + const Container::Vector *root_containers = _trace->get_root_containers(); if(root_containers->empty()) { *Message::get_instance() << tr("No containers in this trace").toStdString() << Message::ende; return; } - _nodes_original->clear(); + _nodes_original->clear(); // Add the root container names QList<QTreeWidgetItem *> items; QFlags<Qt::ItemFlag> flg; @@ -108,30 +108,30 @@ void Node_select::set_initial_container_names(){ string name = (*it)->get_name().to_string(); QStringList temp(QString::fromStdString(name)); QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)0, temp); - current_node->setData(0,Qt::UserRole,qVariantFromValue(*it));//store the pointer to the container in the Data field + current_node->setData(0,Qt::UserRole,qVariantFromValue(*it));//store the pointer to the container in the Data field items.append(current_node); - + // Recursivity to add the children names set_container_names_rec(current_node, (*it), flg, false); } _nodes_original->insertTopLevelItems(0, items); - + _nodes_original->expandAll(); - + } void Node_select::set_displayed_container_names(){ - + const Container::Vector *root_containers = _trace->get_view_root_containers(); if(root_containers->empty())root_containers = _trace->get_root_containers(); - + if(root_containers->empty()) { *Message::get_instance() << tr("No containers in this trace").toStdString() << Message::ende; return; } - + _displayed_containers.clear(); _nodes_displayed->clear(); // Add the root container names @@ -144,19 +144,19 @@ void Node_select::set_displayed_container_names(){ QStringList temp(QString::fromStdString(name)); QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)0, temp); - current_node->setFlags(flg); + current_node->setFlags(flg); current_node->setCheckState(0,Qt::Checked); current_node->setData(0,Qt::UserRole,qVariantFromValue(*it));//store the pointer to the container in the Data field items.append(current_node); - + // Recursivity to add the children names set_container_names_rec(current_node, (*it), flg, true); } _nodes_displayed->insertTopLevelItems(0, items); - + _nodes_displayed->expandAll(); - + } @@ -164,9 +164,9 @@ void Node_select::set_displayed_container_names(){ void Node_select::set_container_names_rec(QTreeWidgetItem *current_node, Container *current_container, QFlags<Qt::ItemFlag> flg, bool load_view) { - + const Container::Vector *children; - + if(load_view==true)children = current_container->get_view_children(); if(load_view==false || children->empty())children = current_container->get_children(); //QFlags<Qt::ItemFlag> flg= Qt::ItemIsDragEnabled; @@ -178,16 +178,16 @@ void Node_select::set_container_names_rec(QTreeWidgetItem *current_node, Contain string name = (*it)->get_name().to_string(); QStringList temp(QString::fromStdString(name)); QTreeWidgetItem *node = new QTreeWidgetItem(current_node, temp); - - node->setFlags(flg); + + node->setFlags(flg); node->setData(0,Qt::UserRole, qVariantFromValue(*it));//store the pointer to the container in the Data field - if(flg & Qt::ItemIsUserCheckable)node->setCheckState(0,Qt::Checked); + if(flg & Qt::ItemIsUserCheckable)node->setCheckState(0,Qt::Checked); set_container_names_rec(node ,(*it), flg, load_view); } } Trace* Node_select::get_trace() { - return _trace; + return _trace; } void Node_select::set_trace(Trace *trace) { @@ -203,15 +203,15 @@ void Stats_window::set_selected_nodes(string kind_of_state){ list<StateType *>::const_iterator itstat; list<StateType *>::const_iterator endstat; const ContainerType *kind_of_container = NULL; - + states_types_list = _trace->get_state_types(); endstat = states_types_list->end(); for (itstat = states_types_list->begin(); itstat != endstat; itstat++){ if ((*itstat)->get_name().to_string() == kind_of_state){ - kind_of_container = (*itstat)->get_container_type(); - continue; + kind_of_container = (*itstat)->get_container_type(); + continue; } } @@ -225,10 +225,10 @@ void Stats_window::set_selected_nodes(string kind_of_state){ QTreeWidgetItemIterator it(_nodes_selected); while (*it) { if ((*it)->checkState(0) == Qt::Checked){ - Container *cont = _trace->search_container((*it)->text(0).toStdString()); + Container *cont = _trace->search_container((*it)->text(0).toStdString()); //cout << ((ContainerType *)cont->get_type())->get_name().to_string() << " " << ((ContainerType *)kind_of_container)->get_name().to_string() << endl; - if (cont->get_type() == kind_of_container) - _selected_containers.push_back(cont); + if (cont->get_type() == kind_of_container) + _selected_containers.push_back(cont); } it ++; } @@ -247,33 +247,33 @@ void Stats_window::set_selected_nodes(string kind_of_state){ //resets to initial containers, _displayed_containers.clear(); QList<QTreeWidgetItem *> items; - QTreeWidgetItemIterator it(_nodes_original);//browse only top containers + QTreeWidgetItemIterator it(_nodes_original);//browse only top containers while (*it) { if((*it)->parent()==NULL){//we only want parent nodes _displayed_containers.push_back(((*it)->data(0,Qt::UserRole)).value<Container*>()); reassign_children_rec(*it, 0); } ++it; - + } - + _nodes_displayed->clear(); //can we load that from _nodes_original instead ? set_displayed_container_names(); Element_pos zoom[2]={Info::Render::_x_min, Info::Render::_x_max}; - Info::Render::_x_min_visible = 0.0; - Info::Render::_x_max_visible = 0.0; - _trace->set_view_root_containers(_displayed_containers); - //_trace->set_selected_container(_trace->get_root_containers()); + Info::Render::_x_min_visible = 0.0; + Info::Render::_x_max_visible = 0.0; + _trace->set_view_root_containers(_displayed_containers); + //_trace->set_selected_container(_trace->get_root_containers()); _console->get_console()->launch_action(Core:: _STATE_CLEAN_RENDER_AREA); #if defined(USE_ITC) && defined(BOOST_SERIALIZE) - _trace->updateTrace(new Interval(zoom[0], zoom[1])); - #endif + _trace->updateTrace(new Interval(zoom[0], zoom[1])); + #endif _console->get_console()->draw_trace(_console->get_filename(),Core::_DRAW_OPENGL); - _console->get_console()->launch_action(Core:: _STATE_ZOOM_IN_AN_INTERVAL, &zoom); + _console->get_console()->launch_action(Core:: _STATE_ZOOM_IN_AN_INTERVAL, &zoom); _console->get_console()->launch_action(Core:: _STATE_RENDER_UPDATE); - - + + } @@ -297,11 +297,11 @@ void Node_select::on_load_button_clicked(){ } } - _trace->load_config_from_xml(filename); // we set the view_trace, but not our representation, we have to parse it again + _trace->load_config_from_xml(filename); // we set the view_trace, but not our representation, we have to parse it again + + set_displayed_container_names(); + - set_displayed_container_names(); - - } @@ -309,21 +309,21 @@ void Node_select::on_display_button_clicked(){ //take the new list and apply it to the trace // if not checked, remove container // if position has changed, set to the new position - + //we need to be recursive again, and to avoid problems with similar names - - - /* - //this only works to select containers, we cannot order them by this way - _displayed_containers.clear(); - QTreeWidgetItemIterator it(_nodes_displayed, QTreeWidgetItemIterator::Checked); + + + /* + //this only works to select containers, we cannot order them by this way + _displayed_containers.clear(); + QTreeWidgetItemIterator it(_nodes_displayed, QTreeWidgetItemIterator::Checked); while (*it) { _displayed_containers.push_back(((*it)->data(0,Qt::UserRole)).value<Container*>()); ++it; } _trace->set_selected_container(&_displayed_containers);*/ - //use _view_root containers and _view_children in order not to modify the actual structure and limit modifications to do in drawtrace + //use _view_root containers and _view_children in order not to modify the actual structure and limit modifications to do in drawtrace _displayed_containers.clear(); build_displayed_nodes(_displayed_containers); _trace->set_view_root_containers(_displayed_containers); @@ -339,8 +339,8 @@ void Node_select::on_display_button_clicked(){ _console->get_console()->launch_action(Core:: _STATE_ZOOM_IN_AN_INTERVAL, &it); _console->get_console()->launch_action(Core:: _STATE_RENDER_UPDATE); } - - + + void Node_select::build_displayed_nodes( std::list<Container *>& displayed_containers){ QTreeWidgetItemIterator it(_nodes_displayed, QTreeWidgetItemIterator::Checked);//browse only top containers while (*it) { @@ -362,12 +362,12 @@ void Node_select::reassign_children_rec(QTreeWidgetItem* item, QFlags<Qt::Check item->data(0,Qt::UserRole).value<Container*>()->add_view_child(item->child(i)->data(0,Qt::UserRole).value<Container*>()); reassign_children_rec(item->child(i), flg); } - + } - + } - - + + void Node_select::set_filename(string filename){ _file_viewed = filename; } @@ -375,7 +375,7 @@ void Node_select::set_filename(string filename){ void Node_select::on_export_button_clicked(){ //export the trees to a XML file, in order to allow easy reusing - + const QString path_by_default = QString(_file_viewed.substr(0, _file_viewed.find_last_of('.')).c_str()) + ".xml"; QString filename = QFileDialog::getSaveFileName(this, tr("Export File"), @@ -392,14 +392,14 @@ void Node_select::on_export_button_clicked(){ filename += ".xml"; } } - + QDomDocument doc( "Subset " ); QDomElement root = doc.createElement( "nodes" ); doc.appendChild( root ); - + //go through all elements of _nodes_displayed - QTreeWidgetItemIterator it(_nodes_displayed);//browse only top containers - + QTreeWidgetItemIterator it(_nodes_displayed);//browse only top containers + while (*it) { if((*it)->parent()==NULL){//we only want parent nodes @@ -410,22 +410,22 @@ void Node_select::on_export_button_clicked(){ root.appendChild( rootElement ); } ++it; - + } - + QFile file( filename ); if( !file.open( QIODevice::WriteOnly) ){ *Message::get_instance() << tr("Error while opening the file").toStdString() << Message::ende; return ; } - + QTextStream ts( &file ); ts << doc.toString(); file.close(); - - - + + + } @@ -447,13 +447,13 @@ void Node_select::export_children_rec(QTreeWidgetItem* item, QDomElement& parent element.setAttribute( "name", QString(item->child(i)->data(0,Qt::UserRole).value<Container*>()->get_name().to_string().c_str()) ); parent.appendChild( element ); export_children_rec(item->child(i), element, doc); - + } - + } - + } - + void Node_select::close_window(){ hide(); @@ -470,43 +470,43 @@ void Node_select::keyPressEvent(QKeyEvent *) { _ui_stats_area->translate_x(--_x_translated); x_scroll->setSliderPosition(_x_translated); } - break; + break; case Qt::Key_Right: // Key 'right' pressed. if(_x_translated < 99) { _ui_stats_area->translate_x(++_x_translated); x_scroll->setSliderPosition(_x_translated); } - break; + break; case Qt::Key_Up: - // Key 'up' pressed. + // Key 'up' pressed. if(_y_translated > 0) { _ui_stats_area->translate_y(--_y_translated); y_scroll->setSliderPosition(_y_translated); } - break; + break; case Qt::Key_Down: - // Key 'down' pressed. + // Key 'down' pressed. if(_y_translated < 99) { _ui_stats_area->translate_y(++_y_translated); y_scroll->setSliderPosition(_y_translated); } - break; + break; case Qt::Key_PageUp: - // Key 'Page Up' pressed. + // Key 'Page Up' pressed. _ui_stats_area->translate_y(0); y_scroll->setSliderPosition(0); break; case Qt::Key_PageDown: - // Key 'Page Down' pressed. + // Key 'Page Down' pressed. _ui_stats_area->translate_y(100); y_scroll->setSliderPosition(100); break; default: - break; + break; } - + event->accept();*/ } /* @@ -514,7 +514,7 @@ void Stats_window::init() { // We set the names of the containers for the tree widget _nodes_selected->clear(); set_container_names(); - + // We init the times _start_time = Info::Render::_x_min_visible; _end_time = Info::Render::_x_max_visible; @@ -542,7 +542,7 @@ void Stats_window::set_arguments(std::map<std::string , QVariant *>) { } void Stats_window::execute() { - on_reload_button_clicked(); + on_reload_button_clicked(); } string Stats_window::get_name() { diff --git a/src/render/Render_alternate.cpp b/src/render/Render_alternate.cpp index ef2c361c..0d88bffc 100644 --- a/src/render/Render_alternate.cpp +++ b/src/render/Render_alternate.cpp @@ -99,6 +99,9 @@ static bool _draw_counter; Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat& format) : Hook_event(this, core, parent, format), _containers(GL_QUADS), /*_states(GL_QUADS),*/ _events(GL_POINTS), _events2(GL_LINES), _arrows(GL_LINE), _arrows2(GL_TRIANGLES), _counters(GL_LINE), _ruler(GL_QUADS), _modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)), _container_height(_DRAWING_CONTAINER_HEIGHT_DEFAULT){ + _texts.clear(); + _variable_texts.clear(); + _links.clear(); } @@ -347,10 +350,10 @@ void Render_alternate::paintGL(){ const std::map<long int, Variable_text_>::const_iterator it_end=_variable_texts.end(); for(;it!=it_end;it++){ - renderText ( render_to_screen_x(trace_to_render_x(vertical_line))+3, + 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); + arial_font); } @@ -474,90 +477,92 @@ bool Render_alternate::build(){ bool Render_alternate::unbuild(){ + /********************** * * Init OpenGL features * **********************/ - /* enable some OpenGL features*/ - // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - // glEnable(GL_TEXTURE_2D); - - // glEnable(GL_BLEND);/* enable blending for the alpha color */ - // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // glColor3d(1.0, 1.0, 1.0);/* init color to white */ + /*enable some OpenGL features*/ + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glEnable(GL_TEXTURE_2D); - // /***************************** - // * - // * Init render area attributes - // * - // *****************************/ + glEnable(GL_BLEND);/* enable blending for the alpha color */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // _state = DRAWING_STATE_WAITING;/* change the drawing state */ + glColor3d(1.0, 1.0, 1.0);/* init color to white */ - // _wait_angle=0.0f;/* begin with 0 rad angle */ - // _wait_angle_y=0.0f;/* begin with 0 rad angle */ - // /* init measurement attributes */ - // Info::Container::x_max = 0; - // Info::Container::y_max = 0; - // Info::Container::x_min = 0; - // Info::Container::y_min = 0; - - // // Info::Render::_ui_render_min_value->setText(""); - // // Info::Render::_ui_render_max_value->setText(""); - - // Info::Entity::x_max = 0; - // Info::Entity::x_min = 0; - // // _state_x_max = 0; - // _state_y_max = 0; - // // _state_x_min = 0; - // _state_y_min = 0; + /***************************** + * + * Init render area attributes + * + *****************************/ + + _state = DRAWING_STATE_WAITING;/* change the drawing state */ + + //_wait_angle=0.0f;/* begin with 0 rad angle */ + //_wait_angle_y=0.0f;/* begin with 0 rad angle */ + + /* init measurement attributes */ + /*Info::Container::x_max = 0; + Info::Container::y_max = 0; + Info::Container::x_min = 0; + Info::Container::y_min = 0;*/ + + // Info::Render::_ui_render_min_value->setText(""); + // Info::Render::_ui_render_max_value->setText(""); + + //Info::Entity::x_max = 0; + //Info::Entity::x_min = 0; + // _state_x_max = 0; + //_state_y_max = 0; + // _state_x_min = 0; + //_state_y_min = 0; + + /* clear lists to store container texts */ + _text_pos.clear(); + _text_value.clear(); + clear_text(); + + //_arrows.clear(); + //_circles.clear(); + //_texts.clear(); + + /*for (unsigned int i=0 ; + i<_vbos.size() ; + i++){ + delete _vbos[i]; + } + _vbos.clear();*/ - // /* clear lists to store container texts */ - // _text_pos.clear(); - // _text_value.clear(); + /* clear the event vector */ + // _events.clear(); + /* clear the arrow vector */ // _arrows.clear(); - // _circles.clear(); - // _texts.clear(); - - // for (unsigned int i=0 ; - // i<_vbos.size() ; - // i++){ - // delete _vbos[i]; - // } - // _vbos.clear(); - - // /* clear the event vector */ - // // _events.clear(); - - // /* clear the arrow vector */ - // // _arrows.clear(); - // /* empty the selection stack */ - // while(false == _previous_selection.empty()) - // _previous_selection.pop(); + /* empty the selection stack */ + while(false == _previous_selection.empty()) + _previous_selection.pop(); - // if (NULL == _render_instance) - // return true; + if (NULL == _render_instance) + return true; - // /* Now, timer is set */ - // if (_wait_timer == NULL){ - // _wait_angle = 0.0f; + /* Now, timer is set */ + // if (_wait_timer == NULL){ + // _wait_angle = 0.0f; - // /* _wait_timer = new QTimer(this); - // connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL())); - // _wait_timer->start(_wait_spf);*/ - // } + /* _wait_timer = new QTimer(this); + connect(_wait_timer, SIGNAL(timeout()), _render_instance, SLOT(updateGL())); + _wait_timer->start(_wait_spf);*/ + //} - // return true;//_render_instance->display_unbuild(); + return true;//_render_instance->display_unbuild(); } @@ -645,7 +650,7 @@ void Render_alternate::draw_text(const Element_pos x, const Element_pos y, const if (_draw_ruler) return;/* do not draw text for ruler */ Container_text_ buf; buf.x = x; - buf.y = render_to_trace_y(y);// + offset_y; //render_to_trace_y(y);/* Cancel previous transformation. */ + buf.y = render_to_trace_y(y);/* Cancel previous transformation. */ buf.value = s; buf.size = size; _texts.push_back(buf); @@ -943,3 +948,7 @@ Element_pos Render_alternate::get_vertical_line(){ return vertical_line; } +void Render_alternate::clear_text (){ + _texts.clear(); + _variable_texts.clear(); +} diff --git a/src/render/Render_alternate.hpp b/src/render/Render_alternate.hpp index d95a5cc0..7c1c3d38 100644 --- a/src/render/Render_alternate.hpp +++ b/src/render/Render_alternate.hpp @@ -543,6 +543,9 @@ public slots: */ void update_vertical_line(); + /*! Function that only delete the text of the screen */ + void clear_text (); + }; diff --git a/src/render/Render_opengl.cpp b/src/render/Render_opengl.cpp index 7c7b4440..08799762 100644 --- a/src/render/Render_opengl.cpp +++ b/src/render/Render_opengl.cpp @@ -399,9 +399,9 @@ void Render_opengl::paintGL(){ if (it==it_end || render_to_screen_y(trace_to_render_y(_texts[i].y)) - render_to_screen_y(trace_to_render_y((*it).second))> height ){ const QString text_elided = metric.elidedText(_texts[i].value.c_str(), Qt::ElideRight, _x_scale_container_state*Info::Screen::width/(Info::Trace::depth+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); + 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; @@ -872,7 +872,8 @@ void Render_opengl::start_draw_states(){ glNewList(_list_states, GL_COMPILE);/* open the list */ } -void Render_opengl::draw_state(const Element_pos, const Element_pos, const Element_pos, const Element_pos, const Element_col, const EntityValue* ){ +void Render_opengl::draw_state(const Element_pos x, const Element_pos y, const Element_pos z, const Element_pos w, const Element_pos h, const EntityValue* value){ + draw_quad(x, y, z, w, h); } void Render_opengl::end_draw_states(){ diff --git a/src/trace/EntityValue.hpp b/src/trace/EntityValue.hpp index e5230e45..428df8fc 100644 --- a/src/trace/EntityValue.hpp +++ b/src/trace/EntityValue.hpp @@ -56,6 +56,9 @@ private: Name _name; EntityType *_type; std::map<std::string, Value *> _opt; + //Element_col _r; + //Element_col _g; + //Element_col _b; public: /*! -- GitLab