Changeset 70:2ee22e690853 in glemon-0.x
- Timestamp:
- 08/26/05 14:37:34 (18 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2165
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas-event.cc
r69 r70 87 87 bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e) 88 88 { 89 static Gnome::Canvas::Text *coord_text = 0; 89 90 switch(e->type) 90 91 { … … 113 114 break; 114 115 case GDK_BUTTON_RELEASE: 116 if (coord_text) 117 { 118 delete coord_text; 119 coord_text = 0; 120 } 115 121 isbutton=0; 116 122 active_item=NULL; … … 122 128 { 123 129 mapstorage.modified = true; 124 mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y)); 130 125 131 //new coordinates will be the old values, 126 132 //because the item will be moved to the … … 139 145 nodetextmap[active_node]->move(dx, dy); 140 146 147 // the new coordinates of the centre of the node 148 double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x); 149 double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y); 150 141 151 clicked_x=new_x; 142 152 clicked_y=new_y; 143 153 144 154 // write back the new coordinates to the coords map 155 mapstorage.coords.set(active_node, xy<double>(coord_x, coord_y)); 156 157 // reposition the coordinates text 158 std::ostringstream ostr; 159 ostr << "(" << 160 mapstorage.coords[active_node].x << ", " << 161 mapstorage.coords[active_node].y << ")"; 162 if (coord_text) 163 { 164 coord_text->property_text().set_value(ostr.str()); 165 coord_text->property_x().set_value(mapstorage.coords[active_node].x + 166 node_property_defaults[N_RADIUS] + 40); 167 coord_text->property_y().set_value(mapstorage.coords[active_node].y + 168 node_property_defaults[N_RADIUS] - 40); 169 } 170 else 171 { 172 coord_text = new Gnome::Canvas::Text( 173 displayed_graph, 174 mapstorage.coords[active_node].x + 175 node_property_defaults[N_RADIUS] + 40, 176 mapstorage.coords[active_node].y + 177 node_property_defaults[N_RADIUS] - 40, 178 ostr.str()); 179 coord_text->property_fill_color().set_value("black"); 180 } 181 182 //all the edges connected to the moved point has to be redrawn 145 183 for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei) 146 184 {
Note: See TracChangeset
for help on using the changeset viewer.