Changeset 81:5ad61c33487c in glemon-0.x for graph_displayer_canvas-node.cc
- Timestamp:
- 10/20/05 17:50:23 (17 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2258
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas-node.cc
r62 r81 8 8 Graph::NodeMap<double> * actual_map; 9 9 double min, max; 10 if(mapname=="Default") 11 { 12 min=node_property_defaults[N_RADIUS]; 13 max=node_property_defaults[N_RADIUS]; 14 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]); 15 } 16 else 17 { 18 min=mapstorage.minOfNodeMap(mapname); 19 max=mapstorage.maxOfNodeMap(mapname); 20 actual_map=(mapstorage.nodemap_storage)[mapname]; 21 } 10 min=mapstorage.minOfNodeMap(mapname); 11 max=mapstorage.maxOfNodeMap(mapname); 12 actual_map=(mapstorage.nodemap_storage)[mapname]; 22 13 23 14 if(node==INVALID) … … 70 61 }; 71 62 63 int GraphDisplayerCanvas::resetNodeRadius (Node node) 64 { 65 Graph::NodeMap<double> * actual_map; 66 double min, max; 67 min=node_property_defaults[N_RADIUS]; 68 max=node_property_defaults[N_RADIUS]; 69 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]); 70 71 if(node==INVALID) 72 { 73 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) 74 { 75 double v=fabs((*actual_map)[i]); 76 int w; 77 if(min==max) 78 { 79 w=(int)(node_property_defaults[N_RADIUS]); 80 } 81 else 82 { 83 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS)); 84 } 85 if(w>=0) 86 { 87 double x1, y1, x2, y2; 88 x1=nodesmap[i]->property_x1().get_value(); 89 x2=nodesmap[i]->property_x2().get_value(); 90 y1=nodesmap[i]->property_y1().get_value(); 91 y2=nodesmap[i]->property_y2().get_value(); 92 nodesmap[i]->property_x1().set_value((x1+x2)/2-w); 93 nodesmap[i]->property_x2().set_value((x1+x2)/2+w); 94 nodesmap[i]->property_y1().set_value((y1+y2)/2-w); 95 nodesmap[i]->property_y2().set_value((y1+y2)/2+w); 96 } 97 } 98 } 99 else 100 { 101 //I think only new nodes use this case 102 // int w=(int)(*actual_map)[node]; 103 int w=(int)(node_property_defaults[N_RADIUS]); 104 if(w>=0) 105 { 106 double x1, y1, x2, y2; 107 x1=nodesmap[node]->property_x1().get_value(); 108 x2=nodesmap[node]->property_x2().get_value(); 109 y1=nodesmap[node]->property_y1().get_value(); 110 y2=nodesmap[node]->property_y2().get_value(); 111 nodesmap[node]->property_x1().set_value((x1+x2)/2-w); 112 nodesmap[node]->property_x2().set_value((x1+x2)/2+w); 113 nodesmap[node]->property_y1().set_value((y1+y2)/2-w); 114 nodesmap[node]->property_y2().set_value((y1+y2)/2+w); 115 } 116 } 117 return 0; 118 }; 119 72 120 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node) 73 121 { … … 78 126 79 127 Graph::NodeMap<double> * actual_map; 80 if(mapname=="Default") 81 { 82 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]); 83 } 84 else 85 { 86 actual_map=(mapstorage.nodemap_storage)[mapname]; 87 } 128 actual_map=(mapstorage.nodemap_storage)[mapname]; 88 129 89 130 double max, min; 90 131 91 if(mapname!="Default") 92 { 93 max=mapstorage.maxOfNodeMap(mapname); 94 min=mapstorage.minOfNodeMap(mapname); 95 } 96 else 97 { 98 max=node_property_defaults[N_COLOR]; 99 min=node_property_defaults[N_COLOR]; 100 } 101 132 max=mapstorage.maxOfNodeMap(mapname); 133 min=mapstorage.minOfNodeMap(mapname); 134 135 if(node==INVALID) 136 { 137 138 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) 139 { 140 Gdk::Color color; 141 142 double w=(*actual_map)[i]; 143 144 if(max!=min) 145 { 146 color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); 147 } 148 else 149 { 150 color.set_rgb_p (0, 0, 100); 151 } 152 153 nodesmap[i]->property_fill_color_gdk().set_value(color); 154 } 155 } 156 else 157 { 158 Gdk::Color color; 159 160 double w=(*actual_map)[node]; 161 162 if(max!=min) 163 { 164 color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); 165 } 166 else 167 { 168 color.set_rgb_p (0, 0, 100); 169 } 170 171 nodesmap[node]->property_fill_color_gdk().set_value(color); 172 } 173 return 0; 174 }; 175 176 int GraphDisplayerCanvas::resetNodeColor (Node node) 177 { 178 179 //function maps the range of the maximum and 180 //the minimum of the nodemap to the range of 181 //green in RGB 182 183 Graph::NodeMap<double> * actual_map; 184 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]); 185 186 double max, min; 187 188 max=node_property_defaults[N_COLOR]; 189 min=node_property_defaults[N_COLOR]; 102 190 103 191 if(node==INVALID) … … 151 239 152 240 Graph::NodeMap<double> * actual_map=NULL; 153 if(mapname!="Default") 154 { 155 actual_map=(mapstorage.nodemap_storage)[mapname]; 156 } 157 158 if(node==INVALID) 159 { 160 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) 161 { 162 if(mapname!="Default") 163 { 164 nodemap_to_edit=mapname; 165 double number=(*actual_map)[i]; 166 167 std::ostringstream ostr; 168 ostr << number; 169 170 nodetextmap[i]->property_text().set_value(ostr.str()); 171 } 172 else 173 { 174 nodemap_to_edit=""; 175 nodetextmap[i]->property_text().set_value(""); 176 } 177 } 178 } 179 else 180 { 181 if(mapname!="Default") 182 { 183 double number=(*actual_map)[node]; 241 actual_map=(mapstorage.nodemap_storage)[mapname]; 242 243 if(node==INVALID) 244 { 245 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) 246 { 247 nodemap_to_edit=mapname; 248 double number=(*actual_map)[i]; 184 249 185 250 std::ostringstream ostr; 186 251 ostr << number; 187 252 188 nodetextmap[node]->property_text().set_value(ostr.str()); 189 } 190 else 191 { 192 nodetextmap[node]->property_text().set_value(""); 193 } 194 } 195 return 0; 196 }; 253 nodetextmap[i]->property_text().set_value(ostr.str()); 254 } 255 } 256 else 257 { 258 double number=(*actual_map)[node]; 259 260 std::ostringstream ostr; 261 ostr << number; 262 263 nodetextmap[node]->property_text().set_value(ostr.str()); 264 } 265 return 0; 266 }; 267 268 int GraphDisplayerCanvas::resetNodeText (Node node) 269 { 270 271 //the number in the map will be written on the node 272 //EXCEPT when the name of the map is Text, because 273 //in that case empty string will be written, because 274 //that is the deleter map 275 276 if(node==INVALID) 277 { 278 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) 279 { 280 nodemap_to_edit=""; 281 nodetextmap[i]->property_text().set_value(""); 282 } 283 } 284 else 285 { 286 nodetextmap[node]->property_text().set_value(""); 287 } 288 return 0; 289 };
Note: See TracChangeset
for help on using the changeset viewer.