hegyi@28: #include hegyi@28: #include hegyi@28: #include hegyi@28: hegyi@28: hegyi@28: int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Graph::Node node) hegyi@28: { hegyi@31: Graph::NodeMap * actual_map; hegyi@31: if(mapname=="Default") hegyi@31: { hegyi@31: actual_map=new Graph::NodeMap(g,node_property_defaults[N_RADIUS]); hegyi@31: } hegyi@31: else hegyi@31: { hegyi@31: actual_map=(mapstorage.nodemap_storage)[mapname]; hegyi@31: } hegyi@31: hegyi@28: if(node==INVALID) hegyi@28: { hegyi@28: for (NodeIt i(g); i!=INVALID; ++i) hegyi@28: { hegyi@31: int w=(int)(*actual_map)[i]; hegyi@28: if(w>=0) hegyi@28: { hegyi@28: double x1, y1, x2, y2; hegyi@31: x1=nodesmap[i]->property_x1().get_value(); hegyi@31: x2=nodesmap[i]->property_x2().get_value(); hegyi@31: y1=nodesmap[i]->property_y1().get_value(); hegyi@31: y2=nodesmap[i]->property_y2().get_value(); hegyi@28: nodesmap[i]->property_x1().set_value((x1+x2)/2-w); hegyi@28: nodesmap[i]->property_x2().set_value((x1+x2)/2+w); hegyi@28: nodesmap[i]->property_y1().set_value((y1+y2)/2-w); hegyi@28: nodesmap[i]->property_y2().set_value((y1+y2)/2+w); hegyi@28: } hegyi@28: } hegyi@28: } hegyi@28: else hegyi@28: { hegyi@31: //I think only new nodes use this case hegyi@31: // int w=(int)(*actual_map)[node]; hegyi@31: int w=(int)(node_property_defaults[N_RADIUS]); hegyi@28: if(w>=0) hegyi@28: { hegyi@28: double x1, y1, x2, y2; hegyi@31: x1=nodesmap[node]->property_x1().get_value(); hegyi@31: x2=nodesmap[node]->property_x2().get_value(); hegyi@31: y1=nodesmap[node]->property_y1().get_value(); hegyi@31: y2=nodesmap[node]->property_y2().get_value(); hegyi@28: nodesmap[node]->property_x1().set_value((x1+x2)/2-w); hegyi@28: nodesmap[node]->property_x2().set_value((x1+x2)/2+w); hegyi@28: nodesmap[node]->property_y1().set_value((y1+y2)/2-w); hegyi@28: nodesmap[node]->property_y2().set_value((y1+y2)/2+w); hegyi@28: } hegyi@28: } hegyi@28: return 0; hegyi@28: }; hegyi@28: hegyi@28: int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Graph::Node node) hegyi@28: { hegyi@28: hegyi@28: //function maps the range of the maximum and hegyi@28: //the minimum of the nodemap to the range of hegyi@28: //green in RGB hegyi@28: hegyi@31: Graph::NodeMap * actual_map; hegyi@31: if(mapname=="Default") hegyi@31: { hegyi@31: actual_map=new Graph::NodeMap(g,node_property_defaults[N_COLOR]); hegyi@31: } hegyi@31: else hegyi@31: { hegyi@31: actual_map=(mapstorage.nodemap_storage)[mapname]; hegyi@31: } hegyi@31: hegyi@31: double max, min; hegyi@31: hegyi@31: if(mapname!="Default") hegyi@31: { hegyi@31: max=mapstorage.maxOfNodeMap(mapname); hegyi@31: min=mapstorage.minOfNodeMap(mapname); hegyi@31: } hegyi@31: else hegyi@31: { hegyi@31: max=node_property_defaults[N_COLOR]; hegyi@31: min=node_property_defaults[N_COLOR]; hegyi@31: } hegyi@31: hegyi@31: hegyi@28: if(node==INVALID) hegyi@28: { hegyi@28: hegyi@28: for (NodeIt i(g); i!=INVALID; ++i) hegyi@28: { hegyi@28: Gdk::Color color; hegyi@31: hegyi@31: double w=(*actual_map)[i]; hegyi@31: hegyi@28: if(max!=min) hegyi@28: { hegyi@28: color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); hegyi@28: } hegyi@28: else hegyi@28: { hegyi@28: color.set_rgb_p (0, 0, 100); hegyi@28: } hegyi@28: hegyi@28: nodesmap[i]->property_fill_color_gdk().set_value(color); hegyi@28: } hegyi@28: } hegyi@28: else hegyi@28: { hegyi@28: Gdk::Color color; hegyi@31: hegyi@31: double w=(*actual_map)[node]; hegyi@31: hegyi@28: if(max!=min) hegyi@28: { hegyi@28: color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); hegyi@28: } hegyi@28: else hegyi@28: { hegyi@28: color.set_rgb_p (0, 0, 100); hegyi@28: } hegyi@28: hegyi@28: nodesmap[node]->property_fill_color_gdk().set_value(color); hegyi@28: } hegyi@28: return 0; hegyi@28: }; hegyi@28: hegyi@28: int GraphDisplayerCanvas::changeNodeText (std::string mapname, Graph::Node node) hegyi@28: { hegyi@28: hegyi@28: //the number in the map will be written on the node hegyi@28: //EXCEPT when the name of the map is Text, because hegyi@28: //in that case empty string will be written, because hegyi@28: //that is the deleter map hegyi@31: hegyi@36: Graph::NodeMap * actual_map=NULL; hegyi@35: if(mapname!="Default") hegyi@31: { hegyi@31: actual_map=(mapstorage.nodemap_storage)[mapname]; hegyi@31: } hegyi@28: hegyi@28: if(node==INVALID) hegyi@28: { hegyi@28: for (NodeIt i(g); i!=INVALID; ++i) hegyi@28: { hegyi@31: if(mapname!="Default") hegyi@28: { hegyi@35: nodemap_to_edit=mapname; hegyi@31: double number=(*actual_map)[i]; hegyi@28: int length=1; hegyi@28: //if number is smaller than one, length would be negative, or invalid hegyi@28: if(number>=1) hegyi@28: { hegyi@28: length=(int)(floor(log(number)/log(10)))+1; hegyi@28: } hegyi@28: int maxpos=(int)(pow(10,length-1)); hegyi@28: int strl=length+1+RANGE; hegyi@28: char * str=new char[strl]; hegyi@28: str[length]='.'; hegyi@28: str[strl]='\0'; hegyi@28: hegyi@28: for(int j=0;jproperty_text().set_value(""); hegyi@28: } hegyi@28: } hegyi@28: } hegyi@28: else hegyi@28: { hegyi@31: if(mapname!="Default") hegyi@28: { hegyi@31: double number=(*actual_map)[node]; hegyi@28: int length=1; hegyi@28: //if number is smaller than one, length would be negative, or invalid hegyi@28: if(number>=1) hegyi@28: { hegyi@28: length=(int)(floor(log(number)/log(10)))+1; hegyi@28: } hegyi@28: int maxpos=(int)(pow(10,length-1)); hegyi@28: int strl=length+1+RANGE; hegyi@28: char * str=new char[strl]; hegyi@28: str[length]='.'; hegyi@28: str[strl]='\0'; hegyi@28: hegyi@28: for(int j=0;jALMOST_ONE) hegyi@36: { hegyi@36: number=round(number); hegyi@36: } hegyi@28: int digit=(int)(number/maxpos); hegyi@28: str[j]=(digit+'0'); hegyi@28: number-=digit*maxpos; hegyi@28: number*=10; hegyi@28: } hegyi@28: } hegyi@28: hegyi@28: nodetextmap[node]->property_text().set_value(str); hegyi@28: } hegyi@28: else hegyi@28: { hegyi@28: nodetextmap[node]->property_text().set_value(""); hegyi@28: } hegyi@28: } hegyi@28: return 0; hegyi@28: };