Commit 3fec3731 authored by Augustin Degomme's avatar Augustin Degomme
Browse files

add possibility to switch the order of displayed containers by dragging and...

add possibility to switch the order of displayed containers by dragging and dropping them directly in the visualization window. (the father of both containers have to be the same)
parent 8dedd9e8
......@@ -481,6 +481,7 @@ bool Core::draw_trace(const string & filename, const int format) {
}
delete parser;
parser=NULL;
}
else if ( _file_opened != filename) {/* just check if execution is normal */
*Message::get_instance() << "Try to use file: " << filename << " instead of a previous parsed file: " << _file_opened << Message::ende;
......@@ -892,14 +893,15 @@ void Core::launch_action(int state, void* arg) {
case _STATE_RELEASE_RENDER_AREA:{
if(parser!=NULL ){
/*if(parser!=NULL ){
parser->set_canceled();
//locks the mutex and automatically unlocks it when going out of scope
QMutexLocker locker(_mutex);
emit build_finished(false);
emit close_windows();
_closed->wait(_mutex);
}
while(parser!=NULL)
_closed->wait(_mutex,100);
}*/
if (_render_opengl->unbuild()==false)
message << "Close file : an error occured with trace releasing." << Message::ende;
......@@ -1024,6 +1026,102 @@ void Core::launch_action(int state, void* arg) {
_render_opengl->show_minimap();
break;
case _STATE_SWITCH_CONTAINERS:
{
Element_pos yr = ((Element_pos*)arg)[0];
Element_pos yr2 = ((Element_pos*)arg)[1];
const Container* container=NULL;
const Container* container2=NULL;
const Container::Vector *root_containers = _trace->get_view_root_containers();
if(root_containers->empty())root_containers= _trace->get_root_containers();
if (!root_containers->empty()){
for (Container::VectorIt i = root_containers->begin();
i != root_containers->end();
i++)
if ((container = buf.search_container_by_position(*i, yr)))
break;
for (Container::VectorIt i = root_containers->begin();
i != root_containers->end();
i++)
if ((container2 = buf.search_container_by_position(*i, yr2)))
break;
}
// If the clic is out
if (!container)
return;
if (!container2)
return;
//we found the two children containers, we have to know the depth
Element_pos xr = ((Element_pos*)arg)[2] * (_trace->get_depth()+1);
if(xr<0)return;
for(int i=0; i < (_trace->get_depth() - xr); i++){
container= container->get_parent();
container2=container2->get_parent();
}
//we cannot switch when containers' parents are not the same
if((container->get_parent()!=container2->get_parent()))return;
if(container==container2)
return;
Container* parent= const_cast<Container*>(container->get_parent());
//printf("we ask to switch %s and %s \n", container->get_name().to_string().c_str(), container2->get_name().to_string().c_str());
const std::list<Container*>* children=NULL;
if(parent==NULL){//we switch top level containers
children = _trace->get_view_root_containers();
if(children->empty()) children = _trace->get_root_containers();
}else{
children = new std::list<Container*>(*parent->get_view_children());
if(children->empty()) children = parent->get_children();
}
std::list<Container*>::const_iterator it= children->begin();
const std::list<Container*>::const_iterator it_end= children->end();
if(parent!=NULL){
parent->clear_view_children();
for(; it!=it_end; it++){
if((*it)==container) parent->add_view_child(const_cast<Container*>(container2));
else if((*it)==container2) parent->add_view_child(const_cast<Container*>(container));
else parent->add_view_child(*it);
}
}else{//for root containers we have to build a new list and fill it
std::list<Container*>* new_list= new std::list<Container*> ();
for(; it!=it_end; it++){
if((*it)==container){
new_list->push_back(const_cast<Container*>(container2));
}
else if((*it)==container2) new_list->push_back(const_cast<Container*>(container));
else new_list->push_back(*it);
}
_trace->set_view_root_containers(*new_list);
}
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;
launch_action(Core:: _STATE_CLEAN_RENDER_AREA);
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
_trace->updateTrace(new Interval(zoom[0], zoom[1]));
#endif
draw_trace(get_filename(),Core::_DRAW_OPENGL);
launch_action(Core:: _STATE_ZOOM_IN_AN_INTERVAL, &zoom);
launch_action(Core:: _STATE_RENDER_UPDATE);
break;
}
case _DRAW_OPENGL_PARTIAL:
{
//_main_window->get_node_select()->set_trace(_trace);
......
......@@ -228,6 +228,8 @@ public:
static const int _STATE_SPLITTING=27;
static const int _LOAD_DATA = 28;
static const int _STATE_SWITCH_CONTAINERS = 29;
/*!
* \brief Launch an action according to the argument state value.
* \param state An integer corresponding to a kind of action which must be executed.
......
......@@ -308,9 +308,9 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){
void Hook_event::mouseMoveEvent(QMouseEvent * event){
if (!_mouse_pressed) return;
if (_mouse_pressed_inside_container)
_new_mouse_x = Info::Screen::width;
else
//if (_mouse_pressed_inside_container)
// _new_mouse_x = Info::Screen::width;
//else
_new_mouse_x = event->x();
if (_mouse_pressed_inside_ruler)
......@@ -352,9 +352,18 @@ void Hook_event::mouseReleaseEvent(QMouseEvent * event){
_mouse_pressed=false;
event->accept();/* accept the event */
}else if (_mouse_pressed_inside_container){
Element_pos y1 = render_to_trace_y(screen_to_render_y(_mouse_y));
Element_pos x1 = screen_to_render_x(_new_mouse_x) / (_x_scale_container_state*Info::Render::width);
Element_pos y2 = render_to_trace_y(screen_to_render_y(_new_mouse_y));
Element_pos buf[3]={y1,y2, x1};
_core->launch_action(_core->_STATE_SWITCH_CONTAINERS, &buf);
_mouse_pressed=false;
_mouse_pressed_inside_container=false;
}else{
if (_new_mouse_x < _mouse_x){
invert_buf_x = _mouse_x;
_mouse_x = _new_mouse_x;
......
......@@ -306,7 +306,7 @@ void Render_opengl::paintGL(){
{
glTranslated(0.0, 0.0, 100.0);/* not accurate */
if (_mouse_pressed && (Info::Render::_key_ctrl == false)){
if (_mouse_pressed && (Info::Render::_key_ctrl == false) && !_mouse_pressed_inside_container){
glTranslated(0.0, 0.0, _z_container_under);
......
Supports Markdown
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