# HG changeset patch # User hegyi # Date 1119549384 0 # Node ID b0c76a4d58017c47aedeb8f20b86ca050ae0189f # Parent c45a34eaa118c4235f56ff9ff6df4da734200603 A bug, explored by Alpar is corrected, but with value-checking, and not with correct values. (There is some problem with map values of new items! Maybe refreshemnt is the responsible thing?) diff -r c45a34eaa118 -r b0c76a4d5801 graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Fri Jun 17 17:08:45 2005 +0000 +++ b/graph_displayer_canvas.cc Thu Jun 23 17:56:24 2005 +0000 @@ -95,10 +95,13 @@ int GraphDisplayerCanvas::changeLineWidth (std::string mapname) { for (EdgeIt i(g); i!=INVALID; ++i) - { - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; - edgesmap[i]->property_width_pixels().set_value(w); - } + { + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; + if(w>=0) + { + edgesmap[i]->property_width_pixels().set_value(w); + } + } return 0; }; @@ -141,35 +144,40 @@ //\todo isn't it a bit woodcutter? for (EdgeIt i(g); i!=INVALID; ++i) - { - if(mapname!="Text") { - double number=(*(mapstorage.edgemap_storage)[mapname])[i]; - int length=(int)(floor(log(number)/log(10)))+1; - int maxpos=(int)(pow(10,length-1)); - int strl=length+1+RANGE; - char * str=new char[strl]; - str[length]='.'; - str[strl]='\0'; + if(mapname!="Text") + { + double number=(*(mapstorage.edgemap_storage)[mapname])[i]; + int length=1; + //if number is smaller than one, length would be negative, or invalid + if(number>=1) + { + length=(int)(floor(log(number)/log(10)))+1; + } + int maxpos=(int)(pow(10,length-1)); + int strl=length+1+RANGE; + char * str=new char[strl]; + str[length]='.'; + str[strl]='\0'; - for(int j=0;jproperty_text().set_value(str); + edgetextmap[i]->property_text().set_value(str); + } + else + { + edgetextmap[i]->property_text().set_value(""); + } } - else - { - edgetextmap[i]->property_text().set_value(""); - } - } return 0; }; @@ -475,6 +483,9 @@ active_node=NodeIt(g,g.addNode()); + //initiating values corresponding to new node in maps + + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20); @@ -516,7 +527,7 @@ switch(e->type) { case GDK_BUTTON_PRESS: - //in edge creatino right button has special meaning + //in edge creation right button has special meaning if(e->button.button!=3) { //there is not yet selected node @@ -569,6 +580,9 @@ //creating new edge active_edge=EdgeIt(g,g.addEdge(active_node, target_node)); + + //initiating values corresponding to new edge in maps + mapstorage.init_maps_for_edge(active_edge); //calculating coordinates of new edge Gnome::Canvas::Points coos; diff -r c45a34eaa118 -r b0c76a4d5801 mapstorage.cc --- a/mapstorage.cc Fri Jun 17 17:08:45 2005 +0000 +++ b/mapstorage.cc Thu Jun 23 17:56:24 2005 +0000 @@ -86,3 +86,21 @@ return min; } +void MapStorage::init_maps_for_edge(Graph::Edge e) +{ + e=e; +// beragad, aztan csovez +// std::map< std::string,Graph::EdgeMap * >::iterator ems_it; +// for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++) +// { +// std::cout << "szevasz\n"; +// (*((*ems_it).second))[e]=0; +// } +// std::cout << std::endl; + +// g_closure_invoke... +// for(int i=0;i * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();}; + + ///This function sets a default base value for the newly created node + void init_maps_for_node(NodeIt); + + ///This function sets a default base value for the newly created node + void init_maps_for_edge(Graph::Edge); }; #endif //MAPSTORAGE_H