[Lemon-commits] [lemon_svn] ladanyi: r2165 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:50:39 CET 2006
Author: ladanyi
Date: Fri Aug 26 14:37:34 2005
New Revision: 2165
Modified:
hugo/trunk/gui/graph_displayer_canvas-event.cc
Log:
Display the node's coordinates while moving it.
Modified: hugo/trunk/gui/graph_displayer_canvas-event.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-event.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas-event.cc Fri Aug 26 14:37:34 2005
@@ -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<double>(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<double>(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;
More information about the Lemon-commits
mailing list