Esempio n. 1
0
/**
 * Draw the enlarged schema. This methods can only
 * be called after the block have been placed
 */
void decorateSchema::draw(device& dev)
{
    assert(placed());

    fSchema->draw(dev);
#if 0
    // draw enlarge input wires
    for (unsigned int i=0; i<inputs(); i++) {
        point p = inputPoint(i);
        point q = fSchema->inputPoint(i);
        dev.trait(p.x, p.y, q.x, q.y);
    }

    // draw enlarge output wires
    for (unsigned int i=0; i<outputs(); i++) {
        point p = outputPoint(i);
        point q = fSchema->outputPoint(i);
        dev.trait(p.x, p.y, q.x, q.y);
    }
#endif
    // define the coordinates of the frame
    double tw = (2+fText.size())*dLetter*0.75;
    double x0 = x() + fMargin/2;				// left
    double y0 = y() + fMargin/2;				// top
    double x1 = x() + width() - fMargin/2;		// right
    double y1 = y() + height() - fMargin/2;		// bottom
    //double tl = x0 + 2*dWire;					// left of text zone
    double tl = x() + fMargin;					// left of text zone
    double tr = min(tl+tw, x1);					// right of text zone

    // draw the surronding frame
    dev.dasharray(x0, y0, x0, y1);				// left line
    dev.dasharray(x0, y1, x1, y1);				// bottom line
    dev.dasharray(x1, y1, x1, y0);				// right line
    dev.dasharray(x0, y0, tl, y0);				// top segment before text
    dev.dasharray(tr, y0, x1, y0);				// top segment after text

    // draw the label
    dev.label(tl, y0, fText.c_str());	//
}
Esempio n. 2
0
void seqSchema::drawInternalWires(device& dev)
{
	assert (fSchema1->outputs() == fSchema2->inputs());

	const int 	N 	= fSchema1->outputs();
	double 		dx 	= 0;
	double		mx 	= 0;
	int			dir	=-1;

	if (orientation() == kLeftRight) {
		// draw left right cables
		for (int i=0; i<N; i++) {
			point src = fSchema1->outputPoint(i);
			point dst = fSchema2->inputPoint(i);

            int d = direction(src,dst);
            if (d != dir) {
                // compute attributes of new direction
                switch (d) {
                    case kUpDir 	: mx = 0; dx = dWire; break;
                    case kDownDir	: mx = fHorzGap; dx = -dWire; break;
                    default			: mx = 0; dx = 0; break;
                }
                dir = d;
            } else {
                // move in same direction
                mx = mx +dx;
            }
            if (src.y == dst.y) {
                // draw straight cable
                dev.trait(src.x, src.y, dst.x, dst.y);
            } else {
                // draw zizag cable
                dev.trait(src.x, src.y, src.x+mx, src.y);
                dev.trait(src.x+mx, src.y, src.x+mx, dst.y);
                dev.trait(src.x+mx, dst.y, dst.x, dst.y);
            }

        }
	} else {
		// draw right left cables
		for (int i=0; i<N; i++) {
			point src = fSchema1->outputPoint(i);
			point dst = fSchema2->inputPoint(i);

            int d = direction(src,dst);
            if (d != dir) {
                // compute attributes of new direction
                switch (d) {
                    case kUpDir 	: mx = -fHorzGap; dx = dWire; break;
                    case kDownDir	: mx = 0; dx = -dWire; break;
                    default			: mx = 0; dx = 0; break;
                }
                dir = d;
            } else {
                // move in same direction
                mx = mx +dx;
            }
            if (src.y == dst.y) {
                // draw straight cable
                dev.trait(src.x, src.y, dst.x, dst.y);
            } else {
                // draw zizag cable
                dev.trait(src.x, src.y, src.x+mx, src.y);
                dev.trait(src.x+mx, src.y, src.x+mx, dst.y);
                dev.trait(src.x+mx, dst.y, dst.x, dst.y);
            }

        }
	}
}