[Lemon-commits] [lemon_svn] hegyi: r1992 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:49:20 CET 2006
Author: hegyi
Date: Thu Jun 23 19:56:24 2005
New Revision: 1992
Modified:
hugo/trunk/gui/graph_displayer_canvas.cc
hugo/trunk/gui/mapstorage.cc
hugo/trunk/gui/mapstorage.h
Log:
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?)
Modified: hugo/trunk/gui/graph_displayer_canvas.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas.cc Thu Jun 23 19:56:24 2005
@@ -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;j<strl;j++)
- {
- if(j!=length)
- {
- int digit=(int)(number/maxpos);
- str[j]=(digit+'0');
- number-=digit*maxpos;
- number*=10;
- }
- }
+ for(int j=0;j<strl;j++)
+ {
+ if(j!=length)
+ {
+ int digit=(int)(number/maxpos);
+ str[j]=(digit+'0');
+ number-=digit*maxpos;
+ number*=10;
+ }
+ }
- edgetextmap[i]->property_text().set_value(str);
- }
- else
- {
- edgetextmap[i]->property_text().set_value("");
+ edgetextmap[i]->property_text().set_value(str);
+ }
+ 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;
Modified: hugo/trunk/gui/mapstorage.cc
==============================================================================
--- hugo/trunk/gui/mapstorage.cc (original)
+++ hugo/trunk/gui/mapstorage.cc Thu Jun 23 19:56:24 2005
@@ -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<double> * >::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<PROPERTY_NUM;i++)
+// {
+// (default_edgemaps[i])[e]=property_defaults[i];
+// }
+}
Modified: hugo/trunk/gui/mapstorage.h
==============================================================================
--- hugo/trunk/gui/mapstorage.h (original)
+++ hugo/trunk/gui/mapstorage.h Thu Jun 23 19:56:24 2005
@@ -80,6 +80,12 @@
///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
std::map< std::string,Graph::EdgeMap<double> * >::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
More information about the Lemon-commits
mailing list