#include #include #include "graph.h" void _F_grstar::link1(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link2(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link3(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link4(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link5(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link6(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link7(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link8(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::link9(int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y,2); } void _F_grstar::item2(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item3(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item4(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item5(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item6(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item7(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item8(GRAPH_MODE, GR_NODE &) { } void _F_grstar::item9(GRAPH_MODE, GR_NODE &) { } void grstar (_F_grstar &c, GRAPH_MODE mode, GR_NODE &node) { node.width = node.height = node.depth = 0; node.margin.top = node.margin.right = node.margin.left = 0; node.margin.bottom = 0; GR_NODE tbnode[9]; GR_NODE tnode; // Object in the middle of the others double angle = 0; for (int i=0; i<2; i++){ GRAPH_MODE emode = i==0 ? GR_EVAL : GR_DRAW; tnode.x = node.x+node.depth/2-tnode.depth/2; tnode.y = node.y+node.width/2-tnode.width/2; c.center (emode,tnode); int nbitem = 0; int maxwidth = 0; int maxdepth = 0; int lenx = tnode.depth/2 + 10; int leny = tnode.width/2 + 10; for (int j=0; j<9; j++){ GR_NODE *snode = tbnode + j; double ang = angle*j; double cosin = cos(ang); double sinus = sin(ang); snode->x = (int)(tnode.x + tnode.depth/2 + cosin*lenx); snode->y = (int)(tnode.y + tnode.width/2 + sinus*leny); switch (j){ case 0: c.item1(emode,*snode); break; case 1: c.item2(emode,*snode); break; case 2: c.item3(emode,*snode); break; case 3: c.item4(emode,*snode); break; case 4: c.item5(emode,*snode); break; case 5: c.item6(emode,*snode); break; case 6: c.item7(emode,*snode); break; case 7: c.item8(emode,*snode); break; case 8: c.item9(emode,*snode); break; } if (snode->width != 0){ if (maxwidth < snode->width) maxwidth = snode->width; if (maxdepth < snode->depth) maxdepth = snode->depth; nbitem++; } } // Now, we must position the objects around the center, based // on their size and their number (nbitem) // The disposition assumes a uniform size. We pick the size // of the largest item (maximum width and maximum height) // to position every object. angle = M_PI*2/nbitem; node.width = tnode.width + 10 + 10 + maxwidth + maxwidth; node.depth = tnode.depth + 10 + 10 + maxdepth + maxdepth; fprintf (stderr,"nbitem %d %f %d %d\n",nbitem,angle,maxwidth,maxdepth); fprintf (stderr,"node %d %d\n",node.width,node.depth); if (mode == GR_EVAL){ break; }else if (emode == GR_DRAW){ for (int j=0; j