graph_displayer_canvas.cc
branchgui
changeset 25 c45a34eaa118
parent 21 44bb92014108
child 26 b0c76a4d5801
     1.1 --- a/graph_displayer_canvas.cc	Fri Jun 17 15:41:48 2005 +0000
     1.2 +++ b/graph_displayer_canvas.cc	Fri Jun 17 17:08:45 2005 +0000
     1.3 @@ -30,10 +30,10 @@
     1.4      
     1.5      //initializing edge-text as well, to empty string
     1.6  
     1.7 -    double x1, x2, y1, y2;
     1.8 -    edgesmap[i]->get_bounds(x1, y1, x2, y2);
     1.9 -    
    1.10 -    edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, "");
    1.11 +    xy<double> text_pos=edgesmap[i]->get_arrow_pos();
    1.12 +    text_pos+=(xy<double>(10,10));
    1.13 +
    1.14 +    edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
    1.15      edgetextmap[i]->property_fill_color().set_value("black");
    1.16    }
    1.17  
    1.18 @@ -173,6 +173,7 @@
    1.19    return 0;
    1.20  };
    1.21  
    1.22 +//Deprecated
    1.23  bool GraphDisplayerCanvas::event_handler(GdkEvent* e, Node n)
    1.24  {
    1.25    switch(e->type)
    1.26 @@ -424,10 +425,10 @@
    1.27  		edgesmap[ei]->set_points(coos,true);
    1.28  	      }
    1.29  
    1.30 -	    edgesmap[ei]->get_bounds(x1, y1, x2, y2);
    1.31 -
    1.32 -	    edgetextmap[ei]->property_x().set_value((x1+x2)/2);
    1.33 -	    edgetextmap[ei]->property_y().set_value((y1+y2)/2);
    1.34 +	    xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
    1.35 +	    text_pos+=(xy<double>(10,10));
    1.36 +	    edgetextmap[ei]->property_x().set_value(text_pos.x);
    1.37 +	    edgetextmap[ei]->property_y().set_value(text_pos.y);
    1.38          }
    1.39  
    1.40          g.firstIn(ei,active_node);
    1.41 @@ -451,10 +452,10 @@
    1.42  		edgesmap[ei]->set_points(coos,true);
    1.43  	      }
    1.44  
    1.45 -	    edgesmap[ei]->get_bounds(x1, y1, x2, y2);
    1.46 -
    1.47 -	    edgetextmap[ei]->property_x().set_value((x1+x2)/2);
    1.48 -	    edgetextmap[ei]->property_y().set_value((y1+y2)/2);
    1.49 +	    xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
    1.50 +	    text_pos+=(xy<double>(10,10));
    1.51 +	    edgetextmap[ei]->property_x().set_value(text_pos.x);
    1.52 +	    edgetextmap[ei]->property_y().set_value(text_pos.y);
    1.53          }
    1.54        }
    1.55      default: break;
    1.56 @@ -589,8 +590,10 @@
    1.57  		  active_item->raise_to_top();
    1.58  
    1.59  		  //initializing edge-text as well, to empty string
    1.60 -		  edgesmap[active_edge]->get_bounds(x1, y1, x2, y2);
    1.61 -		  edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, "");
    1.62 +		  xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos();
    1.63 +		  text_pos+=(xy<double>(10,10));
    1.64 +
    1.65 +		  edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
    1.66  		  edgetextmap[active_edge]->property_fill_color().set_value("black");
    1.67  		}
    1.68  	      //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore.
    1.69 @@ -738,3 +741,42 @@
    1.70    g.erase(edge_to_delete);
    1.71  }
    1.72  
    1.73 +void GraphDisplayerCanvas::text_reposition(xy<double> new_place)
    1.74 +{
    1.75 +  new_place+=(xy<double>(10,10));
    1.76 +  edgetextmap[active_edge]->property_x().set_value(new_place.x);
    1.77 +  edgetextmap[active_edge]->property_y().set_value(new_place.y);
    1.78 +}
    1.79 +
    1.80 +void GraphDisplayerCanvas::toggle_edge_activity(BrokenEdge* active_bre, bool on)
    1.81 +{
    1.82 +  if(on)
    1.83 +    {
    1.84 +      if(active_edge!=INVALID)
    1.85 +	{
    1.86 +	  std::cout << "ERROR!!!! Valid edge found!" << std::endl;
    1.87 +	}
    1.88 +      else
    1.89 +	{
    1.90 +	  for (EdgeIt i(g); i!=INVALID; ++i)
    1.91 +	    {
    1.92 +	      if(edgesmap[i]==active_bre)
    1.93 +		{
    1.94 +		  active_edge=i;
    1.95 +		}
    1.96 +	    }
    1.97 +	}
    1.98 +    }
    1.99 +  else
   1.100 +    {
   1.101 +      if(active_edge!=INVALID)
   1.102 +	{
   1.103 +	  active_edge=INVALID;
   1.104 +	}
   1.105 +      else
   1.106 +	{
   1.107 +	  std::cout << "ERROR!!!! Invalid edge found!" << std::endl;
   1.108 +	}
   1.109 +    }
   1.110 +
   1.111 +}