1.1 --- a/gui/graph_displayer_canvas-edge.cc Fri Jun 24 08:44:54 2005 +0000
1.2 +++ b/gui/graph_displayer_canvas-edge.cc Fri Jun 24 18:16:12 2005 +0000
1.3 @@ -3,49 +3,82 @@
1.4 #include <math.h>
1.5
1.6
1.7 -int GraphDisplayerCanvas::changeLineWidth (std::string mapname)
1.8 +int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge)
1.9 {
1.10 - for (EdgeIt i(g); i!=INVALID; ++i)
1.11 + if(edge==INVALID)
1.12 {
1.13 - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
1.14 + for (EdgeIt i(g); i!=INVALID; ++i)
1.15 + {
1.16 + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
1.17 + if(w>=0)
1.18 + {
1.19 + edgesmap[i]->property_width_pixels().set_value(w);
1.20 + }
1.21 + }
1.22 + }
1.23 + else
1.24 + {
1.25 + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge];
1.26 if(w>=0)
1.27 {
1.28 - edgesmap[i]->property_width_pixels().set_value(w);
1.29 + edgesmap[edge]->property_width_pixels().set_value(w);
1.30 }
1.31 }
1.32 return 0;
1.33 };
1.34
1.35 -int GraphDisplayerCanvas::changeColor (std::string mapname)
1.36 +int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge)
1.37 {
1.38
1.39 //function maps the range of the maximum and
1.40 //the minimum of the nodemap to the range of
1.41 //green in RGB
1.42 + if(edge==INVALID)
1.43 + {
1.44
1.45 - for (EdgeIt i(g); i!=INVALID; ++i)
1.46 - {
1.47 - double w=(*(mapstorage.edgemap_storage)[mapname])[i];
1.48 - double max=mapstorage.maxOfEdgeMap(mapname);
1.49 - double min=mapstorage.minOfEdgeMap(mapname);
1.50 + for (EdgeIt i(g); i!=INVALID; ++i)
1.51 + {
1.52 + double w=(*(mapstorage.edgemap_storage)[mapname])[i];
1.53 + double max=mapstorage.maxOfEdgeMap(mapname);
1.54 + double min=mapstorage.minOfEdgeMap(mapname);
1.55
1.56 - //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
1.57 - Gdk::Color color;
1.58 - if(max!=min)
1.59 + //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
1.60 + Gdk::Color color;
1.61 + if(max!=min)
1.62 + {
1.63 + color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
1.64 + }
1.65 + else
1.66 + {
1.67 + color.set_rgb_p (0, 100, 0);
1.68 + }
1.69 +
1.70 + edgesmap[i]->property_fill_color_gdk().set_value(color);
1.71 + }
1.72 + }
1.73 + else
1.74 {
1.75 - color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
1.76 + double w=(*(mapstorage.edgemap_storage)[mapname])[edge];
1.77 + double max=mapstorage.maxOfEdgeMap(mapname);
1.78 + double min=mapstorage.minOfEdgeMap(mapname);
1.79 +
1.80 + //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
1.81 + Gdk::Color color;
1.82 + if(max!=min)
1.83 + {
1.84 + color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
1.85 + }
1.86 + else
1.87 + {
1.88 + color.set_rgb_p (0, 100, 0);
1.89 + }
1.90 +
1.91 + edgesmap[edge]->property_fill_color_gdk().set_value(color);
1.92 }
1.93 - else
1.94 - {
1.95 - color.set_rgb_p (0, 100, 0);
1.96 - }
1.97 -
1.98 - edgesmap[i]->property_fill_color_gdk().set_value(color);
1.99 - }
1.100 return 0;
1.101 };
1.102
1.103 -int GraphDisplayerCanvas::changeText (std::string mapname)
1.104 +int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge)
1.105 {
1.106
1.107 //the number in the map will be written on the edge
1.108 @@ -54,11 +87,50 @@
1.109 //that is the deleter map
1.110 //\todo isn't it a bit woodcutter?
1.111
1.112 - for (EdgeIt i(g); i!=INVALID; ++i)
1.113 + if(edge==INVALID)
1.114 {
1.115 - if(mapname!="Text")
1.116 + for (EdgeIt i(g); i!=INVALID; ++i)
1.117 {
1.118 - double number=(*(mapstorage.edgemap_storage)[mapname])[i];
1.119 + if(mapname!=edge_property_strings[E_TEXT])
1.120 + {
1.121 + double number=(*(mapstorage.edgemap_storage)[mapname])[i];
1.122 + int length=1;
1.123 + //if number is smaller than one, length would be negative, or invalid
1.124 + if(number>=1)
1.125 + {
1.126 + length=(int)(floor(log(number)/log(10)))+1;
1.127 + }
1.128 + int maxpos=(int)(pow(10,length-1));
1.129 + int strl=length+1+RANGE;
1.130 + char * str=new char[strl];
1.131 + str[length]='.';
1.132 + str[strl]='\0';
1.133 +
1.134 + for(int j=0;j<strl;j++)
1.135 + {
1.136 + if(j!=length)
1.137 + {
1.138 + int digit=(int)(number/maxpos);
1.139 + str[j]=(digit+'0');
1.140 + number-=digit*maxpos;
1.141 + number*=10;
1.142 + }
1.143 + }
1.144 +
1.145 + edgetextmap[i]->property_text().set_value(str);
1.146 + }
1.147 + else
1.148 + {
1.149 + edgetextmap[i]->property_text().set_value("");
1.150 + }
1.151 + }
1.152 +
1.153 + }
1.154 + else
1.155 + {
1.156 + if(mapname!=edge_property_strings[E_TEXT])
1.157 + {
1.158 + double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
1.159 int length=1;
1.160 //if number is smaller than one, length would be negative, or invalid
1.161 if(number>=1)
1.162 @@ -82,12 +154,15 @@
1.163 }
1.164 }
1.165
1.166 - edgetextmap[i]->property_text().set_value(str);
1.167 + edgetextmap[edge]->property_text().set_value(str);
1.168 }
1.169 else
1.170 {
1.171 - edgetextmap[i]->property_text().set_value("");
1.172 + edgetextmap[edge]->property_text().set_value("");
1.173 }
1.174 +
1.175 }
1.176 +
1.177 return 0;
1.178 +
1.179 };