ladanyi@1606: #include "graph_displayer_canvas.h" ladanyi@1606: #include "broken_edge.h" alpar@1632: #include hegyi@1512: hegyi@1512: alpar@1643: int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node) hegyi@1512: { hegyi@1525: Graph::NodeMap * actual_map; hegyi@1599: double min, max; hegyi@1525: if(mapname=="Default") hegyi@1525: { hegyi@1599: min=node_property_defaults[N_RADIUS]; hegyi@1599: max=node_property_defaults[N_RADIUS]; ladanyi@1606: actual_map=new Graph::NodeMap(mapstorage.graph,node_property_defaults[N_RADIUS]); hegyi@1525: } hegyi@1525: else hegyi@1525: { hegyi@1599: min=mapstorage.minOfNodeMap(mapname); hegyi@1599: max=mapstorage.maxOfNodeMap(mapname); hegyi@1525: actual_map=(mapstorage.nodemap_storage)[mapname]; hegyi@1525: } hegyi@1525: hegyi@1512: if(node==INVALID) hegyi@1512: { ladanyi@1606: for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) hegyi@1512: { hegyi@1614: double v=fabs((*actual_map)[i]); hegyi@1599: int w; hegyi@1599: if(min==max) hegyi@1599: { hegyi@1599: w=(int)(node_property_defaults[N_RADIUS]); hegyi@1599: } hegyi@1599: else hegyi@1599: { hegyi@1599: w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS)); hegyi@1599: } hegyi@1512: if(w>=0) hegyi@1512: { hegyi@1512: double x1, y1, x2, y2; hegyi@1525: x1=nodesmap[i]->property_x1().get_value(); hegyi@1525: x2=nodesmap[i]->property_x2().get_value(); hegyi@1525: y1=nodesmap[i]->property_y1().get_value(); hegyi@1525: y2=nodesmap[i]->property_y2().get_value(); hegyi@1512: nodesmap[i]->property_x1().set_value((x1+x2)/2-w); hegyi@1512: nodesmap[i]->property_x2().set_value((x1+x2)/2+w); hegyi@1512: nodesmap[i]->property_y1().set_value((y1+y2)/2-w); hegyi@1512: nodesmap[i]->property_y2().set_value((y1+y2)/2+w); hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1525: //I think only new nodes use this case hegyi@1525: // int w=(int)(*actual_map)[node]; hegyi@1525: int w=(int)(node_property_defaults[N_RADIUS]); hegyi@1512: if(w>=0) hegyi@1512: { hegyi@1512: double x1, y1, x2, y2; hegyi@1525: x1=nodesmap[node]->property_x1().get_value(); hegyi@1525: x2=nodesmap[node]->property_x2().get_value(); hegyi@1525: y1=nodesmap[node]->property_y1().get_value(); hegyi@1525: y2=nodesmap[node]->property_y2().get_value(); hegyi@1512: nodesmap[node]->property_x1().set_value((x1+x2)/2-w); hegyi@1512: nodesmap[node]->property_x2().set_value((x1+x2)/2+w); hegyi@1512: nodesmap[node]->property_y1().set_value((y1+y2)/2-w); hegyi@1512: nodesmap[node]->property_y2().set_value((y1+y2)/2+w); hegyi@1512: } hegyi@1512: } hegyi@1512: return 0; hegyi@1512: }; hegyi@1512: alpar@1643: int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node) hegyi@1512: { hegyi@1512: hegyi@1512: //function maps the range of the maximum and hegyi@1512: //the minimum of the nodemap to the range of hegyi@1512: //green in RGB hegyi@1512: hegyi@1525: Graph::NodeMap * actual_map; hegyi@1525: if(mapname=="Default") hegyi@1525: { ladanyi@1606: actual_map=new Graph::NodeMap(mapstorage.graph,node_property_defaults[N_COLOR]); hegyi@1525: } hegyi@1525: else hegyi@1525: { hegyi@1525: actual_map=(mapstorage.nodemap_storage)[mapname]; hegyi@1525: } hegyi@1525: hegyi@1525: double max, min; hegyi@1525: hegyi@1525: if(mapname!="Default") hegyi@1525: { hegyi@1525: max=mapstorage.maxOfNodeMap(mapname); hegyi@1525: min=mapstorage.minOfNodeMap(mapname); hegyi@1525: } hegyi@1525: else hegyi@1525: { hegyi@1525: max=node_property_defaults[N_COLOR]; hegyi@1525: min=node_property_defaults[N_COLOR]; hegyi@1525: } hegyi@1525: hegyi@1525: hegyi@1512: if(node==INVALID) hegyi@1512: { hegyi@1512: ladanyi@1606: for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) hegyi@1512: { hegyi@1512: Gdk::Color color; hegyi@1525: hegyi@1525: double w=(*actual_map)[i]; hegyi@1525: hegyi@1512: if(max!=min) hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 0, 100); hegyi@1512: } hegyi@1512: hegyi@1512: nodesmap[i]->property_fill_color_gdk().set_value(color); hegyi@1512: } hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1512: Gdk::Color color; hegyi@1525: hegyi@1525: double w=(*actual_map)[node]; hegyi@1525: hegyi@1512: if(max!=min) hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 0, 100); hegyi@1512: } hegyi@1512: hegyi@1512: nodesmap[node]->property_fill_color_gdk().set_value(color); hegyi@1512: } hegyi@1512: return 0; hegyi@1512: }; hegyi@1512: alpar@1643: int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node) hegyi@1512: { hegyi@1512: hegyi@1512: //the number in the map will be written on the node hegyi@1512: //EXCEPT when the name of the map is Text, because hegyi@1512: //in that case empty string will be written, because hegyi@1512: //that is the deleter map hegyi@1525: hegyi@1581: Graph::NodeMap * actual_map=NULL; hegyi@1579: if(mapname!="Default") hegyi@1525: { hegyi@1525: actual_map=(mapstorage.nodemap_storage)[mapname]; hegyi@1525: } hegyi@1512: hegyi@1512: if(node==INVALID) hegyi@1512: { ladanyi@1606: for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) hegyi@1512: { hegyi@1525: if(mapname!="Default") hegyi@1512: { hegyi@1579: nodemap_to_edit=mapname; hegyi@1525: double number=(*actual_map)[i]; hegyi@1596: hegyi@1596: std::ostringstream ostr; hegyi@1596: ostr << number; hegyi@1596: hegyi@1596: nodetextmap[i]->property_text().set_value(ostr.str()); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1579: nodemap_to_edit=""; hegyi@1512: nodetextmap[i]->property_text().set_value(""); hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1525: if(mapname!="Default") hegyi@1512: { hegyi@1525: double number=(*actual_map)[node]; hegyi@1596: hegyi@1596: std::ostringstream ostr; hegyi@1596: ostr << number; hegyi@1596: hegyi@1596: nodetextmap[node]->property_text().set_value(ostr.str()); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1512: nodetextmap[node]->property_text().set_value(""); hegyi@1512: } hegyi@1512: } hegyi@1512: return 0; hegyi@1512: };