1.1 --- a/gui/graph_displayer_canvas-edge.cc Mon Oct 17 10:30:59 2005 +0000
1.2 +++ b/gui/graph_displayer_canvas-edge.cc Thu Oct 20 15:50:23 2005 +0000
1.3 @@ -3,23 +3,52 @@
1.4 #include <cmath>
1.5
1.6
1.7 +int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
1.8 +{
1.9 + Graph::EdgeMap<double> * actual_map;
1.10 + double min, max;
1.11 +
1.12 + min=edge_property_defaults[E_WIDTH];
1.13 + max=edge_property_defaults[E_WIDTH];
1.14 + actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
1.15 +
1.16 + if(edge==INVALID)
1.17 + {
1.18 + for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.19 + {
1.20 + double v=fabs((*actual_map)[i]);
1.21 + int w;
1.22 + if(min==max)
1.23 + {
1.24 + w=(int)(edge_property_defaults[E_WIDTH]);
1.25 + }
1.26 + else
1.27 + {
1.28 + w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
1.29 + }
1.30 + edgesmap[i]->property_width_units().set_value(w);
1.31 + }
1.32 + }
1.33 + else
1.34 + {
1.35 + int w=(int)(*actual_map)[edge];
1.36 + if(w>=0)
1.37 + {
1.38 + edgesmap[edge]->property_width_units().set_value(w);
1.39 + }
1.40 + }
1.41 + return 0;
1.42 +}
1.43 +
1.44 +
1.45 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
1.46 {
1.47 Graph::EdgeMap<double> * actual_map;
1.48 double min, max;
1.49
1.50 - if(mapname=="Default")
1.51 - {
1.52 - min=edge_property_defaults[E_WIDTH];
1.53 - max=edge_property_defaults[E_WIDTH];
1.54 - actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
1.55 - }
1.56 - else
1.57 - {
1.58 - min=mapstorage.minOfEdgeMap(mapname);
1.59 - max=mapstorage.maxOfEdgeMap(mapname);
1.60 - actual_map=(mapstorage.edgemap_storage)[mapname];
1.61 - }
1.62 + min=mapstorage.minOfEdgeMap(mapname);
1.63 + max=mapstorage.maxOfEdgeMap(mapname);
1.64 + actual_map=(mapstorage.edgemap_storage)[mapname];
1.65
1.66 if(edge==INVALID)
1.67 {
1.68 @@ -56,27 +85,64 @@
1.69 //the minimum of the nodemap to the range of
1.70 //green in RGB
1.71 Graph::EdgeMap<double> * actual_map;
1.72 - if(mapname=="Default")
1.73 + actual_map=(mapstorage.edgemap_storage)[mapname];
1.74 +
1.75 + double max, min;
1.76 +
1.77 + max=mapstorage.maxOfEdgeMap(mapname);
1.78 + min=mapstorage.minOfEdgeMap(mapname);
1.79 +
1.80 + if(edge==INVALID)
1.81 {
1.82 - actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
1.83 + for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.84 + {
1.85 + double w=(*actual_map)[i];
1.86 +
1.87 + Gdk::Color color;
1.88 + if(max!=min)
1.89 + {
1.90 + color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
1.91 + }
1.92 + else
1.93 + {
1.94 + color.set_rgb_p (0, 100, 0);
1.95 + }
1.96 + edgesmap[i]->property_fill_color_gdk().set_value(color);
1.97 + }
1.98 }
1.99 else
1.100 {
1.101 - actual_map=(mapstorage.edgemap_storage)[mapname];
1.102 + Gdk::Color color;
1.103 +
1.104 + double w=(*actual_map)[edge];
1.105 +
1.106 + if(max!=min)
1.107 + {
1.108 + color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
1.109 + }
1.110 + else
1.111 + {
1.112 + color.set_rgb_p (0, 100, 0);
1.113 + }
1.114 +
1.115 + edgesmap[edge]->property_fill_color_gdk().set_value(color);
1.116 }
1.117 + return 0;
1.118 +};
1.119 +
1.120 +int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
1.121 +{
1.122 +
1.123 + //function maps the range of the maximum and
1.124 + //the minimum of the nodemap to the range of
1.125 + //green in RGB
1.126 + Graph::EdgeMap<double> * actual_map;
1.127 + actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
1.128
1.129 double max, min;
1.130
1.131 - if(mapname!="Default")
1.132 - {
1.133 - max=mapstorage.maxOfEdgeMap(mapname);
1.134 - min=mapstorage.minOfEdgeMap(mapname);
1.135 - }
1.136 - else
1.137 - {
1.138 - max=edge_property_defaults[E_COLOR];
1.139 - min=edge_property_defaults[E_COLOR];
1.140 - }
1.141 + max=edge_property_defaults[E_COLOR];
1.142 + min=edge_property_defaults[E_COLOR];
1.143
1.144 if(edge==INVALID)
1.145 {
1.146 @@ -127,42 +193,51 @@
1.147 {
1.148 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.149 {
1.150 - if(mapname!="Default")
1.151 - {
1.152 - edgemap_to_edit=mapname;
1.153 - double number=(*(mapstorage.edgemap_storage)[mapname])[i];
1.154 -
1.155 - std::ostringstream ostr;
1.156 - ostr << number;
1.157 -
1.158 - edgetextmap[i]->property_text().set_value(ostr.str());
1.159 - }
1.160 - else
1.161 - {
1.162 - edgemap_to_edit="";
1.163 - edgetextmap[i]->property_text().set_value("");
1.164 - }
1.165 + edgemap_to_edit=mapname;
1.166 + double number=(*(mapstorage.edgemap_storage)[mapname])[i];
1.167 +
1.168 + std::ostringstream ostr;
1.169 + ostr << number;
1.170 +
1.171 + edgetextmap[i]->property_text().set_value(ostr.str());
1.172 }
1.173
1.174 }
1.175 else
1.176 {
1.177 - if(mapname!="Default")
1.178 - {
1.179 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
1.180
1.181 std::ostringstream ostr;
1.182 ostr << number;
1.183
1.184 edgetextmap[edge]->property_text().set_value(ostr.str());
1.185 - }
1.186 - else
1.187 - {
1.188 - edgetextmap[edge]->property_text().set_value("");
1.189 - }
1.190 -
1.191 }
1.192
1.193 return 0;
1.194
1.195 };
1.196 +
1.197 +int GraphDisplayerCanvas::resetEdgeText (Edge edge)
1.198 +{
1.199 + //the number in the map will be written on the edge
1.200 + //EXCEPT when the name of the map is Default, because
1.201 + //in that case empty string will be written, because
1.202 + //that is the deleter map
1.203 +
1.204 + if(edge==INVALID)
1.205 + {
1.206 + for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
1.207 + {
1.208 + edgemap_to_edit="";
1.209 + edgetextmap[i]->property_text().set_value("");
1.210 + }
1.211 +
1.212 + }
1.213 + else
1.214 + {
1.215 + edgetextmap[edge]->property_text().set_value("");
1.216 + }
1.217 +
1.218 + return 0;
1.219 +
1.220 +};