示例#1
0
void Vertices::f_getExtent (
    float& l, float& b, float& cx, float& cy, float& tol, Graphic* gs
) {
    float bx0, by0, bx1, by1, tcx, tcy, dummy1, dummy2;
	
    if (extentCached()) {
	getCachedExtent(bx0, by0, tcx, tcy, tol);
	bx1 = 2*tcx - bx0;
	by1 = 2*tcy - by0;

    } else {
	bx0 = bx1 = x()[0]; by0 = by1 = y()[0];

	for (int i = 1; i < count(); ++i) {
	    bx0 = min(bx0, float(x()[i]));
	    by0 = min(by0, float(y()[i]));
	    bx1 = max(bx1, float(x()[i]));
	    by1 = max(by1, float(y()[i]));
	}
	tcx = (bx0 + bx1) / 2;
	tcy = (by0 + by1) / 2;
	tol = 0;
	cacheExtent(bx0, by0, tcx, tcy, tol);
    }
    transformRect(bx0, by0, bx1, by1, l, b, dummy1, dummy2, gs);
    transform(tcx, tcy, cx, cy, gs);
}
示例#2
0
void BSplineSelection::getExtent (float& l, float& b, float& cx, float& cy,
float& tol, Graphic* gs) {
    Extent e;
    if (extentCached()) {
	getCachedExtent(e.left, e.bottom, e.cx, e.cy, e.tol);
    } else {
	FullGraphic gstmp;
	concatGSGraphic(ifillbspline, this, gs, &gstmp);
	getExtentGraphic(
            ifillbspline, e.left, e.bottom, e.cx, e.cy, e.tol, &gstmp
        );
	Extent te;
	concatGSGraphic(bspline, this, gs, &gstmp);
	getExtentGraphic(
            bspline, te.left, te.bottom, te.cx, te.cy, te.tol, &gstmp
        );
	e.Merge(te);
	cacheExtent(e.left, e.bottom, e.cx, e.cy, e.tol);
    }
    float right = 2*e.cx - e.left;
    float top = 2*e.cy - e.bottom;
    float dummy = 0;
    transformRect(e.left, e.bottom, right, top, l, b, dummy, dummy, gs);
    transform(e.cx, e.cy, cx, cy, gs);
    tol = MergeArrowHeadTol(e.tol, gs);
}
示例#3
0
void Vertices::s_getExtent (
    float& l, float& b, float& cx, float& cy, float& tol, Graphic* gs
) {
    float bx0, by0, bx1, by1, tcx, tcy, width, dummy1, dummy2;

    if (extentCached()) {
	getCachedExtent(bx0, by0, tcx, tcy, tol);
	bx1 = 2*tcx - bx0;
	by1 = 2*tcy - by0;

    } else {
	width = float(gs->GetBrush()->Width());
	tol = (width > 1) ? width/2 : 0;
	bx0 = bx1 = x() ? x()[0] : 0.0; 
	by0 = by1 = y() ? y()[0] : 0.0;

	for (int i = 1; i < count(); ++i) {
	    bx0 = min(bx0, float(x()[i]));
	    by0 = min(by0, float(y()[i]));
	    bx1 = max(bx1, float(x()[i]));
	    by1 = max(by1, float(y()[i]));
	}
	tcx = (bx0 + bx1) / 2;
	tcy = (by0 + by1) / 2;
	cacheExtent(bx0, by0, tcx, tcy, tol);
    }
    transformRect(bx0, by0, bx1, by1, l, b, dummy1, dummy2, gs);
    transform(tcx, tcy, cx, cy, gs);
}
示例#4
0
void UpdatedWidget::update(double dx, double dy)
{
    setGeometry(transformRect(m_initRect, dx, dy));
    resizeBackground(dx, dy);
    QList<Button*> ls = this->findChildren<Button*>();
    foreach (Button* w, ls) {
        w->update(dx, dy);
    }
示例#5
0
cv::Rect adjustRect(std::vector<cv::Point>& poly, cv::Rect cur, cv::Rect seed)
{
    std::vector<cv::Rect> vrect;
    cv::Rect rect;

    // try to expand the rect
    vrect=transformRect(cur, seed, cur.width+seed.width, cur.height+seed.height);
    rect=selectBestRect(poly, vrect, cur);
    if(cur!=rect) return rect;

    // failed to expand, then try to translate it!
    vrect=transformRect(cur, cv::Rect(0,0,1,1), cur.width, cur.height);
    rect=selectBestRect(poly, vrect, cur);

    if(cur!=rect) return rect;
    else return cur;
}
示例#6
0
void BitmapGraphic::CalcExtent (
    int w, int h,
    float& l, float& b, float& cx, float& cy, float& tol, Graphic* gs
) {
    transformRect(0, 0, float(w)/2, float(h)/2, l, b, cx, cy, gs);
    PSBrush* br = gs->GetBrush();
    float width = (br == nil) ? 0 : float(br->Width());
    tol = (width > 1) ? width/2 : 0;
}
示例#7
0
void PadGraphic::getExtent (
    float& l, float& b, float& cx, float& cy, float& tol, Graphic* gs
) {
    float fr, ft;

    transformRect(float(_l), float(_b), float(_r), float(_t), l, b, fr, ft,gs);
    cx = (l + fr)/2;
    cy = (b + ft)/2;
    tol = 0;
}
示例#8
0
void RasterRect::getExtent (
    float& x0, float& y0, float& cx, float& cy, float& tol, Graphic* gs
) {
    if (gs->GetTransformer() == nil) {
	x0 = y0 = 0;
	cx = _raster->Width() / 2;
	cy = _raster->Height() / 2;
    } else {
	transformRect(0,0,_raster->Width(),_raster->Height(),x0,y0,cx,cy,gs);
	cx = (cx + x0)/2;
	cy = (cy + y0)/2;
    }
    tol = 0;
}
示例#9
0
文件: picture.cpp 项目: PNCG/neuron
void Picture::getExtent (
    float& l, float& b, float& cx, float& cy, float& tol, Graphic* gs
) {
    Extent e;
    float right, top, dummy1, dummy2;

    if (extentCached()) {
	getCachedExtent(e._left, e._bottom, e._cx, e._cy, e._tol);

    } else {
	if (IsEmpty()) {
	    l = b = cx = cy = tol = 0.0;
	    return;

	} else {
            Iterator i;
            FullGraphic gstemp;
            Transformer ttemp;
            Extent te;
    
            gstemp.SetTransformer(&ttemp);
            First(i);
	    Graphic* gr = GetGraphic(i);
	    concatGSGraphic(gr, gr, gs, &gstemp);
            concatTransformerGraphic(gr, nil, gr->GetTransformer(), &ttemp);
	    getExtentGraphic(gr, e._left,e._bottom,e._cx,e._cy,e._tol,&gstemp);

            for (Next(i); !Done(i); Next(i)) {
		gr = GetGraphic(i);
		concatGSGraphic(gr, gr, gs, &gstemp);
                concatTransformerGraphic(gr,nil, gr->GetTransformer(), &ttemp);
		getExtentGraphic(
                    gr, te._left, te._bottom, te._cx, te._cy, te._tol, &gstemp
                );
		e.Merge(te);
	    }
	    cacheExtent(e._left, e._bottom, e._cx, e._cy, e._tol);
            gstemp.SetTransformer(nil); // to avoid deleting ttemp explicitly
	}
    }
    right = 2*e._cx - e._left;
    top = 2*e._cy - e._bottom;
    transformRect(e._left, e._bottom, right, top, l, b, dummy1, dummy2, gs);
    transform(e._cx, e._cy, cx, cy, gs);
    tol = e._tol;
}
示例#10
0
void UStencil::getExtent (
    float& x0, float& y0, float& cx, float& cy, float& tol, Graphic* gs
) {
    Bitmap* bitmap = (_mask == nil) ? _image : _mask;
    float w = float(bitmap->Width());
    float h = float(bitmap->Height());

    if (gs->GetTransformer() == nil) {
	x0 = y0 = 0;
	cx = w/2;
	cy = h/2;
    } else {
	transformRect(0, 0, w, h, x0, y0, cx, cy, gs);
	cx = (cx + x0)/2;
	cy = (cy + y0)/2;
    }
    tol = 0;
}
示例#11
0
void TextGraphic::getExtent (
    float& x0, float& y0, float& cx, float& cy, float& tol, Graphic* gs
) {
    PSFont* f = gs->GetFont();
    Coord l, b, r, t;

    CalcBox(l, b, r, t, f);
    if (gs->GetTransformer() == nil) {
	x0 = l;
	y0 = b;
	cx = float(l + r) / 2;
	cy = float(b + t) / 2;
    } else {
        transformRect(l, b, r, t, x0, y0, cx, cy, gs);
	cx = (cx + x0)/2;
	cy = (cy + y0)/2;
    }
    tol = 0;
}
示例#12
0
void ULabel::getExtent (
    float& x0, float& y0, float& cx, float& cy, float& tol, Graphic* gs
) {
    PSFont* f = gs->GetFont();
    float width = f->Width(_string);
    float height = f->Height();

    if (gs->GetTransformer() == nil) {
	x0 = 0;
	y0 = 0;
	cx = width / 2;
	cy = height / 2;
    } else {
        transformRect(0, 0, width, height, x0, y0, cx, cy, gs);
	cx = (cx + x0)/2;
	cy = (cy + y0)/2;
    }
    tol = 0;
}
示例#13
0
void DiploMenuRescaling::setup(){
	const Rect midpoint = {1920/2, 1080/2, 0, 0};
	/* Note: The (x,y) coordinate depends from resolution.
	 * This given default values was evaluated for 1920x1080.
	 * => x,y should be used as offsets to get 
	 *    resolution independend changes. 
	 * */
	const Rect default_leftTop = {0x1C7, 0x0AE, 0x102, 0x1F9};
	const Rect default_leftBottom = {0x1C7, 0x2A7, 0x102, 0x0E8};
	const Rect default_rightTop = {0x4B6, 0x0AE, 0x102, 0x1F9};
	const Rect default_rightBottom = {0x4B6, 0x2A7, 0x102, 0x0E8};

	const Rect default_midHeadline = {0x2CF, 0x0AE, 0x1E1, 0x2B};
	const Rect default_midCenter = {0x2CF, 0x0D9, 0x1E1, 0x1CE};
	//const Rect default_midLeaderhead = {0x2CF, 0x0D9, 0x1C4, 0x161};
	const Rect default_midBottom = {0x2CF, 0x2A7, 0x1E1, 0xE8};

	transformRect( factorHeight, factorHeight, midpoint, 
			default_leftTop, leftTop);
	transformRect( factorHeight, factorHeight, midpoint, 
			default_leftBottom, leftBottom);
	transformRect( factorHeight, factorHeight, midpoint, 
			default_rightTop, rightTop);
	transformRect( factorHeight, factorHeight, midpoint, 
			default_rightBottom, rightBottom);

	transformRect( factorHeight, factorHeight, midpoint, 
			default_midHeadline, midHeadline);
	transformRect( factorHeight, factorHeight, midpoint, 
			default_midCenter, midCenter);
	transformRect( factorHeight, factorHeight, midpoint, 
			default_midBottom, midBottom);

	//Apply extra width change of left and right slide
	leftTop.x -= extraWidthSides;
	leftTop.w += extraWidthSides;
	leftBottom.x -= extraWidthSides;
	leftBottom.w += extraWidthSides;
	rightTop.w += extraWidthSides;
	rightBottom.w += extraWidthSides;
}