graph_displayer_canvas-event.cc
changeset 155 74065e83844d
parent 151 72f1c33f89d4
child 160 14a76109b561
equal deleted inserted replaced
42:1cf24b73380a 43:1daa8aabaf9f
   167         }
   167         }
   168 
   168 
   169 	//all the edges connected to the moved point has to be redrawn
   169 	//all the edges connected to the moved point has to be redrawn
   170         for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
   170         for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
   171         {
   171         {
       
   172           XY arrow_pos;
       
   173 
       
   174           if (mytab.mapstorage.graph.source(ei) == mytab.mapstorage.graph.target(ei))
       
   175           {
       
   176             arrow_pos = mytab.mapstorage.arrow_pos[ei] + XY(dx, dy);
       
   177           }
       
   178           else
       
   179           {
   172             XY moved_node_1(coord_x - dx, coord_y - dy);
   180             XY moved_node_1(coord_x - dx, coord_y - dy);
   173             XY moved_node_2(coord_x, coord_y);
   181             XY moved_node_2(coord_x, coord_y);
   174             Node target = mytab.mapstorage.graph.target(ei);
   182             Node target = mytab.mapstorage.graph.target(ei);
   175             XY fix_node(mytab.mapstorage.coords[target].x,
   183             XY fix_node(mytab.mapstorage.coords[target].x,
   176                         mytab.mapstorage.coords[target].y);
   184                 mytab.mapstorage.coords[target].y);
   177             XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
   185             XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
   178 
   186 
   179             XY arrow_pos;
   187             arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   180 	    arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   188           }
   181 
   189 
   182             mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
   190           mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
   183             edgesmap[ei]->draw();
   191           edgesmap[ei]->draw();
   184 
   192 
   185 	    //reposition of edgetext
   193           //reposition of edgetext
   186 	    XY text_pos=mytab.mapstorage.arrow_pos[ei];
   194           XY text_pos=mytab.mapstorage.arrow_pos[ei];
   187 	    text_pos+=(XY(10,10));
   195           text_pos+=(XY(10,10));
   188 	    edgetextmap[ei]->property_x().set_value(text_pos.x);
   196           edgetextmap[ei]->property_x().set_value(text_pos.x);
   189 	    edgetextmap[ei]->property_y().set_value(text_pos.y);
   197           edgetextmap[ei]->property_y().set_value(text_pos.y);
   190         }
   198         }
   191 
   199 
   192         for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
   200         for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
   193         {
   201         {
       
   202           if (mytab.mapstorage.graph.source(ei) != mytab.mapstorage.graph.target(ei))
       
   203           {
   194             XY moved_node_1(coord_x - dx, coord_y - dy);
   204             XY moved_node_1(coord_x - dx, coord_y - dy);
   195             XY moved_node_2(coord_x, coord_y);
   205             XY moved_node_2(coord_x, coord_y);
   196             Node source = mytab.mapstorage.graph.source(ei);
   206             Node source = mytab.mapstorage.graph.source(ei);
   197             XY fix_node(mytab.mapstorage.coords[source].x,
   207             XY fix_node(mytab.mapstorage.coords[source].x,
   198                         mytab.mapstorage.coords[source].y);
   208                 mytab.mapstorage.coords[source].y);
   199             XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
   209             XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
   200 
   210 
   201             XY arrow_pos;
   211             XY arrow_pos;
   202 	    arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   212             arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   203 
   213 
   204             mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
   214             mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
   205             edgesmap[ei]->draw();
   215             edgesmap[ei]->draw();
   206 
   216 
   207 	    //reposition of edgetext
   217             //reposition of edgetext
   208 	    XY text_pos=mytab.mapstorage.arrow_pos[ei];
   218             XY text_pos=mytab.mapstorage.arrow_pos[ei];
   209 	    text_pos+=(XY(10,10));
   219             text_pos+=(XY(10,10));
   210 	    edgetextmap[ei]->property_x().set_value(text_pos.x);
   220             edgetextmap[ei]->property_x().set_value(text_pos.x);
   211 	    edgetextmap[ei]->property_y().set_value(text_pos.y);
   221             edgetextmap[ei]->property_y().set_value(text_pos.y);
       
   222           }
   212         }
   223         }
   213       }
   224       }
   214     default: break;
   225     default: break;
   215   }
   226   }
   216 
   227 
   524       //or was it an edge?
   535       //or was it an edge?
   525       if(active_node==INVALID)
   536       if(active_node==INVALID)
   526 	{
   537 	{
   527 	  for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   538 	  for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   528 	    {
   539 	    {
   529 	      if(edgesmap[i]==active_item)
   540 	      if(edgesmap[i]->getLine()==active_item)
   530 		{
   541 		{
   531 		  active_edge=i;
   542 		  active_edge=i;
   532 		}
   543 		}
   533 	    }
   544 	    }
   534 	}
   545 	}