graph_displayer_canvas.cc
changeset 166 302d75b08b27
parent 160 14a76109b561
child 167 30a7be486475
equal deleted inserted replaced
45:3b4a78735e58 46:7b26bf746bfa
     4 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) :
     4 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) :
     5   nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
     5   nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
     6   nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
     6   nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
     7   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
     7   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
     8   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
     8   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
     9   iterations(20), attraction(0.05), propulsation(40000), mytab(mainw)
     9   iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), mytab(mainw)
    10 {
    10 {
    11   //base event handler is move tool
    11   //base event handler is move tool
    12   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    12   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    13   actual_tool=MOVE;
    13   actual_tool=MOVE;
    14 
    14 
   253   radius_p=radius_size;
   253   radius_p=radius_size;
   254 }
   254 }
   255 
   255 
   256 void GraphDisplayerCanvas::reDesignGraph()
   256 void GraphDisplayerCanvas::reDesignGraph()
   257 {
   257 {
   258   double min_dist=40;
   258   double min_dist=20;
       
   259   double init_vector_length=25;
       
   260 
       
   261   if(!was_redesigned)
       
   262     {
       
   263       NodeIt i((mytab.mapstorage).graph);
       
   264       double r=random();
       
   265       dim2::Point<double> init(init_vector_length*sin(r),init_vector_length*cos(r));
       
   266       moveNode(init.x, init.y, nodesmap[i], i);
       
   267       was_redesigned=true;
       
   268     }
       
   269   
   259 
   270 
   260   //iteration counter
   271   //iteration counter
   261   for(int l=0;l<iterations;l++)
   272   for(int l=0;l<iterations;l++)
   262     {
   273     {
   263       Graph::NodeMap<double> x(mytab.mapstorage.graph);
   274       Graph::NodeMap<double> x(mytab.mapstorage.graph);