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?)
1.1 --- a/gui/graph_displayer_canvas.cc Tue Jun 21 15:58:57 2005 +0000
1.2 +++ b/gui/graph_displayer_canvas.cc Thu Jun 23 17:56:24 2005 +0000
1.3 @@ -95,10 +95,13 @@
1.4 int GraphDisplayerCanvas::changeLineWidth (std::string mapname)
1.5 {
1.6 for (EdgeIt i(g); i!=INVALID; ++i)
1.7 - {
1.8 - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
1.9 - edgesmap[i]->property_width_pixels().set_value(w);
1.10 - }
1.11 + {
1.12 + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
1.13 + if(w>=0)
1.14 + {
1.15 + edgesmap[i]->property_width_pixels().set_value(w);
1.16 + }
1.17 + }
1.18 return 0;
1.19 };
1.20
1.21 @@ -141,35 +144,40 @@
1.22 //\todo isn't it a bit woodcutter?
1.23
1.24 for (EdgeIt i(g); i!=INVALID; ++i)
1.25 - {
1.26 - if(mapname!="Text")
1.27 {
1.28 - double number=(*(mapstorage.edgemap_storage)[mapname])[i];
1.29 - int length=(int)(floor(log(number)/log(10)))+1;
1.30 - int maxpos=(int)(pow(10,length-1));
1.31 - int strl=length+1+RANGE;
1.32 - char * str=new char[strl];
1.33 - str[length]='.';
1.34 - str[strl]='\0';
1.35 + if(mapname!="Text")
1.36 + {
1.37 + double number=(*(mapstorage.edgemap_storage)[mapname])[i];
1.38 + int length=1;
1.39 + //if number is smaller than one, length would be negative, or invalid
1.40 + if(number>=1)
1.41 + {
1.42 + length=(int)(floor(log(number)/log(10)))+1;
1.43 + }
1.44 + int maxpos=(int)(pow(10,length-1));
1.45 + int strl=length+1+RANGE;
1.46 + char * str=new char[strl];
1.47 + str[length]='.';
1.48 + str[strl]='\0';
1.49
1.50 - for(int j=0;j<strl;j++)
1.51 - {
1.52 - if(j!=length)
1.53 - {
1.54 - int digit=(int)(number/maxpos);
1.55 - str[j]=(digit+'0');
1.56 - number-=digit*maxpos;
1.57 - number*=10;
1.58 - }
1.59 - }
1.60 + for(int j=0;j<strl;j++)
1.61 + {
1.62 + if(j!=length)
1.63 + {
1.64 + int digit=(int)(number/maxpos);
1.65 + str[j]=(digit+'0');
1.66 + number-=digit*maxpos;
1.67 + number*=10;
1.68 + }
1.69 + }
1.70
1.71 - edgetextmap[i]->property_text().set_value(str);
1.72 + edgetextmap[i]->property_text().set_value(str);
1.73 + }
1.74 + else
1.75 + {
1.76 + edgetextmap[i]->property_text().set_value("");
1.77 + }
1.78 }
1.79 - else
1.80 - {
1.81 - edgetextmap[i]->property_text().set_value("");
1.82 - }
1.83 - }
1.84 return 0;
1.85 };
1.86
1.87 @@ -475,6 +483,9 @@
1.88
1.89 active_node=NodeIt(g,g.addNode());
1.90
1.91 + //initiating values corresponding to new node in maps
1.92 +
1.93 +
1.94 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
1.95
1.96 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
1.97 @@ -516,7 +527,7 @@
1.98 switch(e->type)
1.99 {
1.100 case GDK_BUTTON_PRESS:
1.101 - //in edge creatino right button has special meaning
1.102 + //in edge creation right button has special meaning
1.103 if(e->button.button!=3)
1.104 {
1.105 //there is not yet selected node
1.106 @@ -569,6 +580,9 @@
1.107
1.108 //creating new edge
1.109 active_edge=EdgeIt(g,g.addEdge(active_node, target_node));
1.110 +
1.111 + //initiating values corresponding to new edge in maps
1.112 + mapstorage.init_maps_for_edge(active_edge);
1.113
1.114 //calculating coordinates of new edge
1.115 Gnome::Canvas::Points coos;
2.1 --- a/gui/mapstorage.cc Tue Jun 21 15:58:57 2005 +0000
2.2 +++ b/gui/mapstorage.cc Thu Jun 23 17:56:24 2005 +0000
2.3 @@ -86,3 +86,21 @@
2.4 return min;
2.5 }
2.6
2.7 +void MapStorage::init_maps_for_edge(Graph::Edge e)
2.8 +{
2.9 + e=e;
2.10 +// beragad, aztan csovez
2.11 +// std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it;
2.12 +// for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++)
2.13 +// {
2.14 +// std::cout << "szevasz\n";
2.15 +// (*((*ems_it).second))[e]=0;
2.16 +// }
2.17 +// std::cout << std::endl;
2.18 +
2.19 +// g_closure_invoke...
2.20 +// for(int i=0;i<PROPERTY_NUM;i++)
2.21 +// {
2.22 +// (default_edgemaps[i])[e]=property_defaults[i];
2.23 +// }
2.24 +}
3.1 --- a/gui/mapstorage.h Tue Jun 21 15:58:57 2005 +0000
3.2 +++ b/gui/mapstorage.h Thu Jun 23 17:56:24 2005 +0000
3.3 @@ -80,6 +80,12 @@
3.4
3.5 ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
3.6 std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
3.7 +
3.8 + ///This function sets a default base value for the newly created node
3.9 + void init_maps_for_node(NodeIt);
3.10 +
3.11 + ///This function sets a default base value for the newly created node
3.12 + void init_maps_for_edge(Graph::Edge);
3.13 };
3.14
3.15 #endif //MAPSTORAGE_H