Changeset 28:fa28f1071bd6 in glemon-0.x for graph_displayer_canvas-edge.cc
- Timestamp:
- 06/24/05 20:16:12 (19 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@1996
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas-edge.cc
r27 r28 4 4 5 5 6 int GraphDisplayerCanvas::change LineWidth (std::string mapname)6 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge) 7 7 { 8 for (EdgeIt i(g); i!=INVALID; ++i)8 if(edge==INVALID) 9 9 { 10 int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; 10 for (EdgeIt i(g); i!=INVALID; ++i) 11 { 12 int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; 13 if(w>=0) 14 { 15 edgesmap[i]->property_width_pixels().set_value(w); 16 } 17 } 18 } 19 else 20 { 21 int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge]; 11 22 if(w>=0) 12 23 { 13 edgesmap[ i]->property_width_pixels().set_value(w);24 edgesmap[edge]->property_width_pixels().set_value(w); 14 25 } 15 26 } … … 17 28 }; 18 29 19 int GraphDisplayerCanvas::change Color (std::string mapname)30 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge) 20 31 { 21 32 … … 23 34 //the minimum of the nodemap to the range of 24 35 //green in RGB 36 if(edge==INVALID) 37 { 25 38 26 for (EdgeIt i(g); i!=INVALID; ++i)27 28 29 30 39 for (EdgeIt i(g); i!=INVALID; ++i) 40 { 41 double w=(*(mapstorage.edgemap_storage)[mapname])[i]; 42 double max=mapstorage.maxOfEdgeMap(mapname); 43 double min=mapstorage.minOfEdgeMap(mapname); 31 44 32 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl; 33 Gdk::Color color; 34 if(max!=min) 45 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl; 46 Gdk::Color color; 47 if(max!=min) 48 { 49 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 50 } 51 else 52 { 53 color.set_rgb_p (0, 100, 0); 54 } 55 56 edgesmap[i]->property_fill_color_gdk().set_value(color); 57 } 58 } 59 else 35 60 { 36 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 61 double w=(*(mapstorage.edgemap_storage)[mapname])[edge]; 62 double max=mapstorage.maxOfEdgeMap(mapname); 63 double min=mapstorage.minOfEdgeMap(mapname); 64 65 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl; 66 Gdk::Color color; 67 if(max!=min) 68 { 69 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 70 } 71 else 72 { 73 color.set_rgb_p (0, 100, 0); 74 } 75 76 edgesmap[edge]->property_fill_color_gdk().set_value(color); 37 77 } 38 else39 {40 color.set_rgb_p (0, 100, 0);41 }42 43 edgesmap[i]->property_fill_color_gdk().set_value(color);44 }45 78 return 0; 46 79 }; 47 80 48 int GraphDisplayerCanvas::change Text (std::string mapname)81 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge) 49 82 { 50 83 … … 55 88 //\todo isn't it a bit woodcutter? 56 89 57 for (EdgeIt i(g); i!=INVALID; ++i)90 if(edge==INVALID) 58 91 { 59 if(mapname!="Text")92 for (EdgeIt i(g); i!=INVALID; ++i) 60 93 { 61 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 94 if(mapname!=edge_property_strings[E_TEXT]) 95 { 96 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 97 int length=1; 98 //if number is smaller than one, length would be negative, or invalid 99 if(number>=1) 100 { 101 length=(int)(floor(log(number)/log(10)))+1; 102 } 103 int maxpos=(int)(pow(10,length-1)); 104 int strl=length+1+RANGE; 105 char * str=new char[strl]; 106 str[length]='.'; 107 str[strl]='\0'; 108 109 for(int j=0;j<strl;j++) 110 { 111 if(j!=length) 112 { 113 int digit=(int)(number/maxpos); 114 str[j]=(digit+'0'); 115 number-=digit*maxpos; 116 number*=10; 117 } 118 } 119 120 edgetextmap[i]->property_text().set_value(str); 121 } 122 else 123 { 124 edgetextmap[i]->property_text().set_value(""); 125 } 126 } 127 128 } 129 else 130 { 131 if(mapname!=edge_property_strings[E_TEXT]) 132 { 133 double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; 62 134 int length=1; 63 135 //if number is smaller than one, length would be negative, or invalid … … 83 155 } 84 156 85 edgetextmap[ i]->property_text().set_value(str);157 edgetextmap[edge]->property_text().set_value(str); 86 158 } 87 159 else 88 160 { 89 edgetextmap[ i]->property_text().set_value("");161 edgetextmap[edge]->property_text().set_value(""); 90 162 } 163 91 164 } 165 92 166 return 0; 167 93 168 };
Note: See TracChangeset
for help on using the changeset viewer.