当前位置: 首页>>代码示例>>C++>>正文


C++ device::trait方法代码示例

本文整理汇总了C++中device::trait方法的典型用法代码示例。如果您正苦于以下问题:C++ device::trait方法的具体用法?C++ device::trait怎么用?C++ device::trait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在device的用法示例。


在下文中一共展示了device::trait方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

/**
 * 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());	//
}
开发者ID:EBone,项目名称:faust-1,代码行数:44,代码来源:decorateSchema.cpp

示例2: drawInternalWires

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);
            }

        }
	}
}
开发者ID:onukore,项目名称:radium,代码行数:71,代码来源:seqSchema.cpp


注:本文中的device::trait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。