graph_displayer_canvas.cc
changeset 177 40f3006fba2e
parent 174 95872af46fc4
child 180 911c6ba0e3c8
equal deleted inserted replaced
50:78d43416f94e 51:30254d7580ea
    23 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) :
    23 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) :
    24   nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
    24   nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
    25   nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
    25   nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
    26   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    26   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    27   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
    27   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
    28   iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), is_drawn(false), mytab(mainw)
    28   was_redesigned(false), is_drawn(false), mytab(mainw)
    29 {
    29 {
    30   //base event handler is move tool
    30   //base event handler is move tool
    31   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    31   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    32   actual_tool=MOVE;
    32   actual_tool=MOVE;
    33 
    33 
   302       dim2::Point<double> init(init_vector_length*rnd(),
   302       dim2::Point<double> init(init_vector_length*rnd(),
   303 			       init_vector_length*rnd());
   303 			       init_vector_length*rnd());
   304       moveNode(init.x, init.y, nodesmap[i], i);
   304       moveNode(init.x, init.y, nodesmap[i], i);
   305       was_redesigned=true;
   305       was_redesigned=true;
   306     }
   306     }
   307   
   307 
       
   308   double attraction;
       
   309   double propulsation;
       
   310   int iterations;
       
   311 
       
   312   (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
   308 
   313 
   309   //iteration counter
   314   //iteration counter
   310   for(int l=0;l<iterations;l++)
   315   for(int l=0;l<iterations;l++)
   311     {
   316     {
   312       Graph::NodeMap<double> x(mytab.mapstorage.graph);
   317       Graph::NodeMap<double> x(mytab.mapstorage.graph);
   391 	  moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
   396 	  moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
   392 	}
   397 	}
   393     }
   398     }
   394 }
   399 }
   395 
   400 
   396 void GraphDisplayerCanvas::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
       
   397 {
       
   398   attraction_p=attraction;
       
   399   propulsation_p=propulsation;
       
   400   iterations_p=iterations;
       
   401 }
       
   402 
       
   403 void GraphDisplayerCanvas::set_attraction(double attraction_p)
       
   404 {
       
   405   attraction=attraction_p;
       
   406 }
       
   407 
       
   408 void GraphDisplayerCanvas::set_propulsation(double propulsation_p)
       
   409 {
       
   410   propulsation=propulsation_p;
       
   411 }
       
   412 
       
   413 void GraphDisplayerCanvas::set_iteration(int iterations_p)
       
   414 {
       
   415   iterations=iterations_p;
       
   416 }
       
   417