# HG changeset patch # User ladanyi # Date 1125059854 0 # Node ID 6eb2f0f3bab9bbc92214f19dc30f33f307c3622b # Parent e40c41eae31f6cfe3ef03f0a47b9dbab039cb5a5 Display the node's coordinates while moving it. diff -r e40c41eae31f -r 6eb2f0f3bab9 gui/graph_displayer_canvas-event.cc --- a/gui/graph_displayer_canvas-event.cc Fri Aug 26 11:37:41 2005 +0000 +++ b/gui/graph_displayer_canvas-event.cc Fri Aug 26 12:37:34 2005 +0000 @@ -86,6 +86,7 @@ bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e) { + static Gnome::Canvas::Text *coord_text = 0; switch(e->type) { case GDK_BUTTON_PRESS: @@ -112,6 +113,11 @@ } break; case GDK_BUTTON_RELEASE: + if (coord_text) + { + delete coord_text; + coord_text = 0; + } isbutton=0; active_item=NULL; active_node=INVALID; @@ -121,7 +127,7 @@ if(active_node!=INVALID) { mapstorage.modified = true; - mapstorage.coords.set(active_node, xy(clicked_x, clicked_y)); + //new coordinates will be the old values, //because the item will be moved to the //new coordinate therefore the new movement @@ -138,10 +144,42 @@ active_item->move(dx, dy); nodetextmap[active_node]->move(dx, dy); + // the new coordinates of the centre of the node + double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x); + double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y); + clicked_x=new_x; clicked_y=new_y; + // write back the new coordinates to the coords map + mapstorage.coords.set(active_node, xy(coord_x, coord_y)); + // reposition the coordinates text + std::ostringstream ostr; + ostr << "(" << + mapstorage.coords[active_node].x << ", " << + mapstorage.coords[active_node].y << ")"; + if (coord_text) + { + coord_text->property_text().set_value(ostr.str()); + coord_text->property_x().set_value(mapstorage.coords[active_node].x + + node_property_defaults[N_RADIUS] + 40); + coord_text->property_y().set_value(mapstorage.coords[active_node].y + + node_property_defaults[N_RADIUS] - 40); + } + else + { + coord_text = new Gnome::Canvas::Text( + displayed_graph, + mapstorage.coords[active_node].x + + node_property_defaults[N_RADIUS] + 40, + mapstorage.coords[active_node].y + + node_property_defaults[N_RADIUS] - 40, + ostr.str()); + coord_text->property_fill_color().set_value("black"); + } + + //all the edges connected to the moved point has to be redrawn for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei) { Gnome::Canvas::Points coos;