Graph redesign starts with an initial kick of the first node.
authorhegyi
Mon, 16 Oct 2006 13:05:25 +0000
changeset 166302d75b08b27
parent 165 2cd447b0bd3a
child 167 30a7be486475
Graph redesign starts with an initial kick of the first node.
graph_displayer_canvas.cc
graph_displayer_canvas.h
     1.1 --- a/graph_displayer_canvas.cc	Fri Oct 13 15:31:58 2006 +0000
     1.2 +++ b/graph_displayer_canvas.cc	Mon Oct 16 13:05:25 2006 +0000
     1.3 @@ -6,7 +6,7 @@
     1.4    nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
     1.5    isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
     1.6    edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
     1.7 -  iterations(20), attraction(0.05), propulsation(40000), mytab(mainw)
     1.8 +  iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), mytab(mainw)
     1.9  {
    1.10    //base event handler is move tool
    1.11    actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    1.12 @@ -255,7 +255,18 @@
    1.13  
    1.14  void GraphDisplayerCanvas::reDesignGraph()
    1.15  {
    1.16 -  double min_dist=40;
    1.17 +  double min_dist=20;
    1.18 +  double init_vector_length=25;
    1.19 +
    1.20 +  if(!was_redesigned)
    1.21 +    {
    1.22 +      NodeIt i((mytab.mapstorage).graph);
    1.23 +      double r=random();
    1.24 +      dim2::Point<double> init(init_vector_length*sin(r),init_vector_length*cos(r));
    1.25 +      moveNode(init.x, init.y, nodesmap[i], i);
    1.26 +      was_redesigned=true;
    1.27 +    }
    1.28 +  
    1.29  
    1.30    //iteration counter
    1.31    for(int l=0;l<iterations;l++)
     2.1 --- a/graph_displayer_canvas.h	Fri Oct 13 15:31:58 2006 +0000
     2.2 +++ b/graph_displayer_canvas.h	Mon Oct 16 13:05:25 2006 +0000
     2.3 @@ -417,6 +417,13 @@
     2.4  
     2.5    ///Propulsation factor during graph design
     2.6    double propulsation;
     2.7 +
     2.8 +  ///Was redesign run on this graph already?
     2.9 +  ///
    2.10 +  ///If not, the layout will be modified randomly
    2.11 +  ///to avoid frozen layout because of wrong
    2.12 +  ///initial state
    2.13 +  bool was_redesigned;
    2.14    
    2.15  private:
    2.16