Changeset 1731:616bc933c2bc in lemon-0.x for gui/graph_displayer_canvas-edge.cc
- Timestamp:
- 10/20/05 17:50:23 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2258
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/graph_displayer_canvas-edge.cc
r1645 r1731 4 4 5 5 6 int GraphDisplayerCanvas:: changeEdgeWidth (std::string mapname,Edge edge)6 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge) 7 7 { 8 8 Graph::EdgeMap<double> * actual_map; 9 9 double min, max; 10 10 11 if(mapname=="Default") 12 { 13 min=edge_property_defaults[E_WIDTH]; 14 max=edge_property_defaults[E_WIDTH]; 15 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]); 16 } 17 else 18 { 19 min=mapstorage.minOfEdgeMap(mapname); 20 max=mapstorage.maxOfEdgeMap(mapname); 21 actual_map=(mapstorage.edgemap_storage)[mapname]; 22 } 23 11 min=edge_property_defaults[E_WIDTH]; 12 max=edge_property_defaults[E_WIDTH]; 13 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]); 14 24 15 if(edge==INVALID) 25 16 { … … 48 39 } 49 40 return 0; 41 } 42 43 44 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge) 45 { 46 Graph::EdgeMap<double> * actual_map; 47 double min, max; 48 49 min=mapstorage.minOfEdgeMap(mapname); 50 max=mapstorage.maxOfEdgeMap(mapname); 51 actual_map=(mapstorage.edgemap_storage)[mapname]; 52 53 if(edge==INVALID) 54 { 55 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) 56 { 57 double v=fabs((*actual_map)[i]); 58 int w; 59 if(min==max) 60 { 61 w=(int)(edge_property_defaults[E_WIDTH]); 62 } 63 else 64 { 65 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); 66 } 67 edgesmap[i]->property_width_units().set_value(w); 68 } 69 } 70 else 71 { 72 int w=(int)(*actual_map)[edge]; 73 if(w>=0) 74 { 75 edgesmap[edge]->property_width_units().set_value(w); 76 } 77 } 78 return 0; 50 79 }; 51 80 … … 57 86 //green in RGB 58 87 Graph::EdgeMap<double> * actual_map; 59 if(mapname=="Default") 60 { 61 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]); 62 } 63 else 64 { 65 actual_map=(mapstorage.edgemap_storage)[mapname]; 66 } 88 actual_map=(mapstorage.edgemap_storage)[mapname]; 67 89 68 90 double max, min; 69 91 70 if(mapname!="Default") 71 { 72 max=mapstorage.maxOfEdgeMap(mapname); 73 min=mapstorage.minOfEdgeMap(mapname); 74 } 75 else 76 { 77 max=edge_property_defaults[E_COLOR]; 78 min=edge_property_defaults[E_COLOR]; 79 } 92 max=mapstorage.maxOfEdgeMap(mapname); 93 min=mapstorage.minOfEdgeMap(mapname); 94 95 if(edge==INVALID) 96 { 97 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) 98 { 99 double w=(*actual_map)[i]; 100 101 Gdk::Color color; 102 if(max!=min) 103 { 104 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 105 } 106 else 107 { 108 color.set_rgb_p (0, 100, 0); 109 } 110 edgesmap[i]->property_fill_color_gdk().set_value(color); 111 } 112 } 113 else 114 { 115 Gdk::Color color; 116 117 double w=(*actual_map)[edge]; 118 119 if(max!=min) 120 { 121 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 122 } 123 else 124 { 125 color.set_rgb_p (0, 100, 0); 126 } 127 128 edgesmap[edge]->property_fill_color_gdk().set_value(color); 129 } 130 return 0; 131 }; 132 133 int GraphDisplayerCanvas::resetEdgeColor (Edge edge) 134 { 135 136 //function maps the range of the maximum and 137 //the minimum of the nodemap to the range of 138 //green in RGB 139 Graph::EdgeMap<double> * actual_map; 140 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]); 141 142 double max, min; 143 144 max=edge_property_defaults[E_COLOR]; 145 min=edge_property_defaults[E_COLOR]; 80 146 81 147 if(edge==INVALID) … … 128 194 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) 129 195 { 130 if(mapname!="Default") 131 { 132 edgemap_to_edit=mapname; 133 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 134 135 std::ostringstream ostr; 136 ostr << number; 137 138 edgetextmap[i]->property_text().set_value(ostr.str()); 139 } 140 else 141 { 142 edgemap_to_edit=""; 143 edgetextmap[i]->property_text().set_value(""); 144 } 145 } 146 147 } 148 else 149 { 150 if(mapname!="Default") 151 { 196 edgemap_to_edit=mapname; 197 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 198 199 std::ostringstream ostr; 200 ostr << number; 201 202 edgetextmap[i]->property_text().set_value(ostr.str()); 203 } 204 205 } 206 else 207 { 152 208 double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; 153 209 … … 156 212 157 213 edgetextmap[edge]->property_text().set_value(ostr.str()); 158 } 159 else 160 { 161 edgetextmap[edge]->property_text().set_value(""); 162 } 163 164 } 165 166 return 0; 167 168 }; 214 } 215 216 return 0; 217 218 }; 219 220 int GraphDisplayerCanvas::resetEdgeText (Edge edge) 221 { 222 //the number in the map will be written on the edge 223 //EXCEPT when the name of the map is Default, because 224 //in that case empty string will be written, because 225 //that is the deleter map 226 227 if(edge==INVALID) 228 { 229 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) 230 { 231 edgemap_to_edit=""; 232 edgetextmap[i]->property_text().set_value(""); 233 } 234 235 } 236 else 237 { 238 edgetextmap[edge]->property_text().set_value(""); 239 } 240 241 return 0; 242 243 };
Note: See TracChangeset
for help on using the changeset viewer.