diff -r 5adf29662354 -r 930e838ad5b6 graph_displayer_canvas-event.cc --- a/graph_displayer_canvas-event.cc Mon Sep 18 16:02:20 2006 +0000 +++ b/graph_displayer_canvas-event.cc Tue Sep 19 07:43:55 2006 +0000 @@ -27,9 +27,7 @@ createEdgeEventHandler(generated); break; } - case EDGE_MAP_EDIT: - //has to do the same thing as in the case of NODE_MAP_EDIT - case NODE_MAP_EDIT: + case MAP_EDIT: { break; } @@ -63,13 +61,9 @@ actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false); break; - case EDGE_MAP_EDIT: + case MAP_EDIT: grab_focus(); - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false); - break; - - case NODE_MAP_EDIT: - actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false); + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false); break; default: @@ -622,179 +616,163 @@ return false; } -bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e) +bool GraphDisplayerCanvas::mapEditEventHandler(GdkEvent* e) { - if(actual_tool==EDGE_MAP_EDIT) - { - switch(e->type) + if(actual_tool==MAP_EDIT) { - case GDK_BUTTON_PRESS: - { - //for determine, whether it was an edge - Edge clicked_edge=INVALID; + switch(e->type) + { + case GDK_BUTTON_PRESS: + { + //for determine, whether it was an edge + Edge clicked_edge=INVALID; + //for determine, whether it was a node + Node clicked_node=INVALID; - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); - active_item=(get_item_at(clicked_x, clicked_y)); + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + active_item=(get_item_at(clicked_x, clicked_y)); - //find the activated item between texts - for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) - { - //at the same time only one can be active - if(edgetextmap[i]==active_item) - { - clicked_edge=i; - } - } + //find the activated item between text of nodes + for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) + { + //at the same time only one can be active + if(nodetextmap[i]==active_item) + { + clicked_node=i; + } + } - //if it was not between texts, search for it between edges - if(clicked_edge==INVALID) - { - for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) - { - //at the same time only one can be active - if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item)) - { - clicked_edge=i; - } - } - } - - //if it was really an edge... - if(clicked_edge!=INVALID) - { - // the id map is not editable - if (edgemap_to_edit == "label") return 0; + //if there was not, search for it between nodes + if(clicked_node==INVALID) + { + for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) + { + //at the same time only one can be active + if(nodesmap[i]==active_item) + { + clicked_node=i; + } + } + } - //and there is activated map - if(edgetextmap[clicked_edge]->property_text().get_value()!="") - { - //activate the general variable for it - active_edge=clicked_edge; + if(clicked_node==INVALID) + { + //find the activated item between texts + for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) + { + //at the same time only one can be active + if(edgetextmap[i]==active_item) + { + clicked_edge=i; + } + } - //create a dialog - Gtk::Dialog dialog("Edit value", true); - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); - Gtk::VBox* vbox = dialog.get_vbox(); - Gtk::SpinButton spin(0.0, 4); - spin.set_increments(1.0, 10.0); - spin.set_range(-1000000.0, 1000000.0); - spin.set_numeric(true); - vbox->add(spin); - spin.show(); - switch (dialog.run()) - { - case Gtk::RESPONSE_NONE: - case Gtk::RESPONSE_CANCEL: - break; - case Gtk::RESPONSE_ACCEPT: - double new_value = spin.get_value(); - (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] = - new_value; - std::ostringstream ostr; - ostr << new_value; - edgetextmap[active_edge]->property_text().set_value( - ostr.str()); - //mapwin.updateEdge(active_edge); -// mapwin.updateEdge(Edge(INVALID)); - propertyUpdate(Edge(INVALID)); - } - } - } - break; - } - default: - break; + //if it was not between texts, search for it between edges + if(clicked_edge==INVALID) + { + for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) + { + //at the same time only one can be active + if((edgesmap[i]->getLine())==active_item) + { + clicked_edge=i; + } + } + } + } + + //if it was really a node... + if(clicked_node!=INVALID) + { + // the id map is not editable + if (nodemap_to_edit == "label") return 0; + + //and there is activated map + if(nodetextmap[clicked_node]->property_text().get_value()!="") + { + //activate the general variable for it + active_node=clicked_node; + + //create a dialog + Gtk::Dialog dialog("Edit value", true); + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); + Gtk::VBox* vbox = dialog.get_vbox(); + Gtk::SpinButton spin(0.0, 4); + spin.set_increments(1.0, 10.0); + spin.set_range(-1000000.0, 1000000.0); + spin.set_numeric(true); + spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str())); + vbox->add(spin); + spin.show(); + switch (dialog.run()) + { + case Gtk::RESPONSE_NONE: + case Gtk::RESPONSE_CANCEL: + break; + case Gtk::RESPONSE_ACCEPT: + double new_value = spin.get_value(); + (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] = + new_value; + std::ostringstream ostr; + ostr << new_value; + nodetextmap[active_node]->property_text().set_value(ostr.str()); + //mapwin.updateNode(active_node); + //mapwin.updateNode(Node(INVALID)); + propertyUpdate(Node(INVALID)); + } + } + } + else + //if it was really an edge... + if(clicked_edge!=INVALID) + { + // the id map is not editable + if (edgemap_to_edit == "label") return 0; + + //and there is activated map + if(edgetextmap[clicked_edge]->property_text().get_value()!="") + { + //activate the general variable for it + active_edge=clicked_edge; + + //create a dialog + Gtk::Dialog dialog("Edit value", true); + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); + Gtk::VBox* vbox = dialog.get_vbox(); + Gtk::SpinButton spin(0.0, 4); + spin.set_increments(1.0, 10.0); + spin.set_range(-1000000.0, 1000000.0); + spin.set_numeric(true); + spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str())); + vbox->add(spin); + spin.show(); + switch (dialog.run()) + { + case Gtk::RESPONSE_NONE: + case Gtk::RESPONSE_CANCEL: + break; + case Gtk::RESPONSE_ACCEPT: + double new_value = spin.get_value(); + (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] = + new_value; + std::ostringstream ostr; + ostr << new_value; + edgetextmap[active_edge]->property_text().set_value( + ostr.str()); + //mapwin.updateEdge(active_edge); + // mapwin.updateEdge(Edge(INVALID)); + propertyUpdate(Edge(INVALID)); + } + } + } + break; + } + default: + break; + } } - } - return false; -} - -bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e) -{ - if(actual_tool==NODE_MAP_EDIT) - { - switch(e->type) - { - case GDK_BUTTON_PRESS: - { - //for determine, whether it was a node - Node clicked_node=INVALID; - - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); - active_item=(get_item_at(clicked_x, clicked_y)); - - //find the activated item between texts - for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) - { - //at the same time only one can be active - if(nodetextmap[i]==active_item) - { - clicked_node=i; - } - } - - //if there was not, search for it between nodes - if(clicked_node==INVALID) - { - for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) - { - //at the same time only one can be active - if(nodesmap[i]==active_item) - { - clicked_node=i; - } - } - } - - //if it was really a node... - if(clicked_node!=INVALID) - { - // the id map is not editable - if (nodemap_to_edit == "label") return 0; - - //and there is activated map - if(nodetextmap[clicked_node]->property_text().get_value()!="") - { - //activate the general variable for it - active_node=clicked_node; - - //create a dialog - Gtk::Dialog dialog("Edit value", true); - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); - Gtk::VBox* vbox = dialog.get_vbox(); - Gtk::SpinButton spin(0.0, 4); - spin.set_increments(1.0, 10.0); - spin.set_range(-1000000.0, 1000000.0); - spin.set_numeric(true); - vbox->add(spin); - spin.show(); - switch (dialog.run()) - { - case Gtk::RESPONSE_NONE: - case Gtk::RESPONSE_CANCEL: - break; - case Gtk::RESPONSE_ACCEPT: - double new_value = spin.get_value(); - (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] = - new_value; - std::ostringstream ostr; - ostr << new_value; - nodetextmap[active_node]->property_text().set_value( - ostr.str()); - //mapwin.updateNode(active_node); -// mapwin.updateNode(Node(INVALID)); - propertyUpdate(Node(INVALID)); - } - } - } - break; - } - default: - break; - } - } return false; }