#include #include "graph.h" void _F_grchip::drawlpin (int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x+node.depth,node.y+node.width/2,2); } void _F_grchip::drawtpin (int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x+node.depth/2,node.y+node.width,2); } void _F_grchip::drawrpin (int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x,node.y+node.width/2,2); } void _F_grchip::drawbpin (int x, int y, GRAPH_MODE mode, GR_NODE &node) { drawline (x,y,node.x+node.depth/2,node.y,2); } void _F_grchip::left (int pine, GRAPH_MODE mode, GR_NODE &node) { } void _F_grchip::top (int pine, GRAPH_MODE mode, GR_NODE &node) { } void _F_grchip::right (int pin, GRAPH_MODE mode, GR_NODE &node) { } void _F_grchip::bottom (int pin, GRAPH_MODE mode, GR_NODE &node) { } void grchip (_F_grchip &c, GRAPH_MODE mode, GR_NODE &node) { #if 0 struct { int x,y; }dispo[4][100]; #endif struct { int width,depth; int max_width,max_depth; int nb; GR_NODE nodes[100]; } sides[4]; for (int i=0; i<4; i++){ int n = 0; int x = 0; int y = 0; int max_depth = 0; int max_width = 0; while (1){ GR_NODE *ptn = sides[i].nodes+n; switch (i){ case 0: c.left (n,GR_EVAL,*ptn); break; case 1: c.top (n,GR_EVAL,*ptn); break; case 2: c.right (n,GR_EVAL,*ptn); break; case 3: c.top (n,GR_EVAL,*ptn); break; } if (ptn->width == 0) break; #if 0 dispo[i][n].x = x+5; // 5 units around each item dispo[i][n].y = y+5; #endif if (i & 1){ // horizontal pins x += ptn->depth+10; if (max_width < ptn->width) max_width = ptn->width; }else{ // Vertical y += ptn->width + 10; if (max_depth < ptn->depth) max_depth = ptn->depth; } n++; } sides[i].nb = n; sides[i].width = y; sides[i].depth = x; sides[i].max_width = max_width; sides[i].max_depth = max_depth; } int depth = sides[1].depth; if (sides[3].depth > depth) depth = sides[1].depth; int width = sides[0].width; if (sides[2].width > width) width = sides[2].width; GR_NODE chip; chip.depth = depth; chip.width = width; chip.x = sides[0].max_depth + 10; chip.y = sides[1].max_width + 10; node.width = width + 10 + sides[1].max_width + 10 + sides[3].max_width; node.depth = depth + 10 + sides[0].max_depth + 10 + sides[2].max_depth; fprintf (stderr,"chip %d %d %d %d\n",chip.width,chip.depth,node.width,node.depth); for (int i=0; i<4; i++){ fprintf (stderr,"%d %d %d\n" ,sides[i].nb,sides[i].max_width,sides[i].max_depth); } if (mode == GR_DRAW){ c.drawbody (GR_DRAW,chip); for (int i=0; i<4; i++){ int x = node.x; int y = node.y; switch (i){ case 0: y = chip.y+5; break; case 1: x += sides[0].max_depth + 10 + 5; break; case 2: y = chip.y + 5; x += sides[0].max_depth +10 + depth + 10; break; case 3: x += sides[0].max_depth + 10 + 5; y += sides[1].max_width + 10 + width + 10; break; } for (int j=0; jx = x; ptn->y = y; switch (i){ case 0: c.left (j,GR_DRAW,*ptn); c.drawlpin (chip.x,y+ptn->width/2,GR_DRAW,*ptn); y += ptn->width + 10; break; case 1: c.top (j,GR_DRAW,*ptn); c.drawtpin (x+ptn->depth/2,chip.y,GR_DRAW,*ptn); x += ptn->depth + 10; break; case 2: c.right (j,GR_DRAW,*ptn); c.drawrpin (chip.x+chip.depth,y+ptn->width/2,GR_DRAW,*ptn); y += ptn->width + 10; break; case 3: c.top (j,GR_DRAW,*ptn); c.drawbpin (x+ptn->depth/2,chip.y+chip.width,GR_DRAW,*ptn); x += ptn->depth + 10; break; } } } } }