1.1 --- a/graph_displayer_canvas-event.cc Thu Jul 28 14:31:32 2005 +0000
1.2 +++ b/graph_displayer_canvas-event.cc Thu Jul 28 15:54:00 2005 +0000
1.3 @@ -216,7 +216,7 @@
1.4
1.5 //draw the new node in red at the clicked place
1.6 case GDK_2BUTTON_PRESS:
1.7 - std::cout << "double click" << std::endl;
1.8 + //std::cout << "double click" << std::endl;
1.9 break;
1.10 case GDK_BUTTON_PRESS:
1.11 isbutton=1;
1.12 @@ -381,7 +381,7 @@
1.13 else
1.14 {
1.15 target_node=INVALID;
1.16 - std::cout << "Loop edge is not yet implemented!" << std::endl;
1.17 + std::cerr << "Loop edge is not yet implemented!" << std::endl;
1.18 }
1.19 }
1.20 //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore.
1.21 @@ -527,189 +527,225 @@
1.22
1.23 bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e)
1.24 {
1.25 - switch(e->type)
1.26 + if(actual_tool==EDGE_MAP_EDIT)
1.27 {
1.28 - case GDK_KEY_PRESS:
1.29 - //for Escape or Enter hide the displayed widget
1.30 - {
1.31 - nodeMapEditEventHandler(e);
1.32 - break;
1.33 - }
1.34 - case GDK_BUTTON_PRESS:
1.35 - //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge.
1.36 - {
1.37 - //find the activated item
1.38 - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.39 - active_item=(get_item_at(clicked_x, clicked_y));
1.40 + switch(e->type)
1.41 + {
1.42 + case GDK_KEY_PRESS:
1.43 + //for Escape or Enter hide the displayed widget
1.44 + {
1.45 + nodeMapEditEventHandler(e);
1.46 + break;
1.47 + }
1.48 + case GDK_BUTTON_PRESS:
1.49 + //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge.
1.50 + {
1.51 + //for determine, whether it was an edge
1.52 + Graph::EdgeIt clicked_edge=INVALID;
1.53
1.54 - //determine, whether it was an edge
1.55 - Graph::EdgeIt clicked_edge=INVALID;
1.56 - for (EdgeIt i(g); i!=INVALID; ++i)
1.57 - {
1.58 - if(edgesmap[i]==active_item)
1.59 + //find the activated item between texts
1.60 + active_item=(get_item_at(e->button.x, e->button.y));
1.61 + for (EdgeIt i(g); i!=INVALID; ++i)
1.62 {
1.63 - clicked_edge=i;
1.64 + if(edgetextmap[i]==active_item)
1.65 + {
1.66 + clicked_edge=i;
1.67 + }
1.68 }
1.69 - }
1.70 - //if it was really an edge...
1.71 - if(clicked_edge!=INVALID)
1.72 - {
1.73 - //If there is already edited edge, it has to be saved first
1.74 - if(entrywidget.is_visible())
1.75 +
1.76 + //if it was not between texts, search for it between edges
1.77 + if(clicked_edge==INVALID)
1.78 {
1.79 + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.80 + active_item=(get_item_at(clicked_x, clicked_y));
1.81 +
1.82 + for (EdgeIt i(g); i!=INVALID; ++i)
1.83 + {
1.84 + //at the same time only one can be active
1.85 + if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item))
1.86 + {
1.87 + clicked_edge=i;
1.88 + }
1.89 + }
1.90 + }
1.91 + //if it was really an edge...
1.92 + if(clicked_edge!=INVALID)
1.93 + {
1.94 + //If there is already edited edge, it has to be saved first
1.95 + if(entrywidget.is_visible())
1.96 + {
1.97 + GdkEvent * generated=new GdkEvent();
1.98 + generated->type=GDK_KEY_PRESS;
1.99 + ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;
1.100 + entryWidgetChangeHandler(generated);
1.101 + }
1.102 + //If the previous value could be saved, we can go further, otherwise not
1.103 + if(!entrywidget.is_visible())
1.104 + {
1.105 + //and there is activated map
1.106 + if(edgetextmap[clicked_edge]->property_text().get_value()!="")
1.107 + {
1.108 + //activate the general variable for it
1.109 + active_edge=clicked_edge;
1.110 + //delete visible widget if there is
1.111 + if(canvasentrywidget)
1.112 + {
1.113 + delete(canvasentrywidget);
1.114 + }
1.115 +
1.116 + //initialize the entry
1.117 + entrywidget.show();
1.118 +
1.119 + //fill in the correct value
1.120 + entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value());
1.121 +
1.122 + //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc
1.123 + xy<double> entry_coos;
1.124 + entry_coos.x=(edgetextmap[active_edge])->property_x().get_value();
1.125 + entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2;
1.126 + entry_coos.y=(edgetextmap[active_edge])->property_y().get_value();
1.127 + entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2;
1.128 + canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
1.129 + canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4);
1.130 + canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);
1.131 + }
1.132 + }
1.133 + }
1.134 + //if it was not an edge...
1.135 + else
1.136 + {
1.137 + //In this case the click did not happen on an edge
1.138 + //if there is visible entry we save the value in it
1.139 + //we pretend like an Enter was presse din the Entry widget
1.140 GdkEvent * generated=new GdkEvent();
1.141 generated->type=GDK_KEY_PRESS;
1.142 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;
1.143 entryWidgetChangeHandler(generated);
1.144 }
1.145 - //If the previous value could be saved, we can go further, otherwise not
1.146 - if(!entrywidget.is_visible())
1.147 - {
1.148 - //and there is activated map
1.149 - if(edgetextmap[clicked_edge]->property_text().get_value()!="")
1.150 - {
1.151 - //activate the general variable for it
1.152 - active_edge=clicked_edge;
1.153 - //delete visible widget if there is
1.154 - if(canvasentrywidget)
1.155 - {
1.156 - delete(canvasentrywidget);
1.157 - }
1.158 -
1.159 - //initialize the entry
1.160 - entrywidget.show();
1.161 -
1.162 - //fill in the correct value
1.163 - entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value());
1.164 -
1.165 - //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc
1.166 - xy<double> entry_coos;
1.167 - entry_coos.x=(edgetextmap[active_edge])->property_x().get_value();
1.168 - entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2;
1.169 - entry_coos.y=(edgetextmap[active_edge])->property_y().get_value();
1.170 - entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2;
1.171 - canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
1.172 - canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4);
1.173 - canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);
1.174 - }
1.175 - }
1.176 + break;
1.177 }
1.178 - //if it was not an edge...
1.179 - else
1.180 - {
1.181 - //In this case the click did not happen on an edge
1.182 - //if there is visible entry we save the value in it
1.183 - //we pretend like an Enter was presse din the Entry widget
1.184 - GdkEvent * generated=new GdkEvent();
1.185 - generated->type=GDK_KEY_PRESS;
1.186 - ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;
1.187 - entryWidgetChangeHandler(generated);
1.188 - }
1.189 - break;
1.190 - }
1.191 - default:
1.192 - break;
1.193 + default:
1.194 + break;
1.195 + }
1.196 }
1.197 return false;
1.198 }
1.199
1.200 bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e)
1.201 {
1.202 - switch(e->type)
1.203 + if(actual_tool==NODE_MAP_EDIT)
1.204 {
1.205 - case GDK_KEY_PRESS:
1.206 - //for Escape or Enter hide the displayed widget
1.207 - {
1.208 - switch(((GdkEventKey*)e)->keyval)
1.209 + switch(e->type)
1.210 + {
1.211 + case GDK_KEY_PRESS:
1.212 + //for Escape or Enter hide the displayed widget
1.213 {
1.214 - case GDK_Escape:
1.215 - entrywidget.hide();
1.216 - break;
1.217 - case GDK_Return:
1.218 - case GDK_KP_Enter:
1.219 - entrywidget.hide();
1.220 - break;
1.221 - default:
1.222 + switch(((GdkEventKey*)e)->keyval)
1.223 + {
1.224 + case GDK_Escape:
1.225 + entrywidget.hide();
1.226 + break;
1.227 + case GDK_Return:
1.228 + case GDK_KP_Enter:
1.229 + entrywidget.hide();
1.230 + break;
1.231 + default:
1.232 + break;
1.233 + }
1.234 +
1.235 break;
1.236 }
1.237 -
1.238 - break;
1.239 - }
1.240 - case GDK_BUTTON_PRESS:
1.241 - //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge.
1.242 - {
1.243 - //find the activated item
1.244 - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.245 - active_item=(get_item_at(clicked_x, clicked_y));
1.246 + case GDK_BUTTON_PRESS:
1.247 + //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge.
1.248 + {
1.249 + //for determine, whether it was a node
1.250 + Graph::NodeIt clicked_node=INVALID;
1.251
1.252 - //determine, whether it was a node
1.253 - Graph::NodeIt clicked_node=INVALID;
1.254 - for (NodeIt i(g); i!=INVALID; ++i)
1.255 - {
1.256 - if(nodesmap[i]==active_item)
1.257 + //find the activated item between texts
1.258 + active_item=(get_item_at(e->button.x, e->button.y));
1.259 + for (NodeIt i(g); i!=INVALID; ++i)
1.260 {
1.261 - clicked_node=i;
1.262 + //at the same time only one can be active
1.263 + if(nodetextmap[i]==active_item)
1.264 + {
1.265 + clicked_node=i;
1.266 + }
1.267 }
1.268 - }
1.269
1.270 - //if it was really an edge...
1.271 - if(clicked_node!=INVALID)
1.272 - {
1.273 - //If there is already edited edge, it has to be saved first
1.274 - if(entrywidget.is_visible())
1.275 + //if there was not, search for it between nodes
1.276 + if(clicked_node==INVALID)
1.277 {
1.278 + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.279 + active_item=(get_item_at(clicked_x, clicked_y));
1.280 +
1.281 + for (NodeIt i(g); i!=INVALID; ++i)
1.282 + {
1.283 + //at the same time only one can be active
1.284 + if(nodesmap[i]==active_item)
1.285 + {
1.286 + clicked_node=i;
1.287 + }
1.288 + }
1.289 + }
1.290 + //if it was really an edge...
1.291 + if(clicked_node!=INVALID)
1.292 + {
1.293 + //If there is already edited edge, it has to be saved first
1.294 + if(entrywidget.is_visible())
1.295 + {
1.296 + GdkEvent * generated=new GdkEvent();
1.297 + generated->type=GDK_KEY_PRESS;
1.298 + ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;
1.299 + entryWidgetChangeHandler(generated);
1.300 + }
1.301 + //If the previous value could be saved, we can go further, otherwise not
1.302 + if(!entrywidget.is_visible())
1.303 + {
1.304 + //and there is activated map
1.305 + if(nodetextmap[clicked_node]->property_text().get_value()!="")
1.306 + {
1.307 + //activate the general variable for it
1.308 + active_node=clicked_node;
1.309 + //delete visible widget if there is
1.310 + if(canvasentrywidget)
1.311 + {
1.312 + delete(canvasentrywidget);
1.313 + }
1.314 +
1.315 + //initialize the entry
1.316 + entrywidget.show();
1.317 +
1.318 + //fill in the correct value
1.319 + entrywidget.set_text(nodetextmap[active_node]->property_text().get_value());
1.320 +
1.321 + //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc
1.322 + xy<double> entry_coos;
1.323 + entry_coos.x=(nodetextmap[active_node])->property_x().get_value();
1.324 + entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2;
1.325 + entry_coos.y=(nodetextmap[active_node])->property_y().get_value();
1.326 + entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2;
1.327 + canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
1.328 + canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*4);
1.329 + canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5);
1.330 + }
1.331 + }
1.332 + }
1.333 + //if it was not an edge...
1.334 + else
1.335 + {
1.336 + //In this case the click did not happen on an edge
1.337 + //if there is visible entry we save the value in it
1.338 + //we pretend like an Enter was presse din the Entry widget
1.339 GdkEvent * generated=new GdkEvent();
1.340 generated->type=GDK_KEY_PRESS;
1.341 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;
1.342 entryWidgetChangeHandler(generated);
1.343 }
1.344 - //If the previous value could be saved, we can go further, otherwise not
1.345 - if(!entrywidget.is_visible())
1.346 - {
1.347 - //and there is activated map
1.348 - if(nodetextmap[clicked_node]->property_text().get_value()!="")
1.349 - {
1.350 - //activate the general variable for it
1.351 - active_node=clicked_node;
1.352 - //delete visible widget if there is
1.353 - if(canvasentrywidget)
1.354 - {
1.355 - delete(canvasentrywidget);
1.356 - }
1.357 -
1.358 - //initialize the entry
1.359 - entrywidget.show();
1.360 -
1.361 - //fill in the correct value
1.362 - entrywidget.set_text(nodetextmap[active_node]->property_text().get_value());
1.363 -
1.364 - //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc
1.365 - xy<double> entry_coos;
1.366 - entry_coos.x=(nodetextmap[active_node])->property_x().get_value();
1.367 - entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2;
1.368 - entry_coos.y=(nodetextmap[active_node])->property_y().get_value();
1.369 - entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2;
1.370 - canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
1.371 - canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*1.5);
1.372 - canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5);
1.373 - }
1.374 - }
1.375 + break;
1.376 }
1.377 - //if it was not an edge...
1.378 - else
1.379 - {
1.380 - //In this case the click did not happen on an edge
1.381 - //if there is visible entry we save the value in it
1.382 - //we pretend like an Enter was presse din the Entry widget
1.383 - GdkEvent * generated=new GdkEvent();
1.384 - generated->type=GDK_KEY_PRESS;
1.385 - ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;
1.386 - entryWidgetChangeHandler(generated);
1.387 - }
1.388 - break;
1.389 - }
1.390 - default:
1.391 - break;
1.392 + default:
1.393 + break;
1.394 + }
1.395 }
1.396 return false;
1.397 }
1.398 @@ -782,7 +818,7 @@
1.399 //the text in the entry was not correct for a double
1.400 else
1.401 {
1.402 - std::cout << "ERROR: only handling of double values is implemented yet!" << std::endl;
1.403 + std::cerr << "ERROR: only handling of double values is implemented yet!" << std::endl;
1.404 }
1.405
1.406 break;
1.407 @@ -829,7 +865,7 @@
1.408 {
1.409 if(forming_edge!=INVALID)
1.410 {
1.411 - std::cout << "ERROR!!!! Valid edge found!" << std::endl;
1.412 + std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
1.413 }
1.414 else
1.415 {
1.416 @@ -850,7 +886,7 @@
1.417 }
1.418 else
1.419 {
1.420 - std::cout << "ERROR!!!! Invalid edge found!" << std::endl;
1.421 + std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
1.422 }
1.423 }
1.424