コード例 #1
0
ファイル: cols.c プロジェクト: fr1tz/nadir
void
colresize(Column *c, Rectangle r)
{
	int i;
	Rectangle r1, r2;
	Window *w;

	clearmouse();
	textresize(&c->tag, r, TRUE);
	draw(screen, c->tag.scrollr, tagcols[TEXT], nil, ZP);
	c->r = r;

	r1 = r;
	for(i=0; i<c->nw; i++){
		w = c->w[i];
		w->maxlines = 0;
		if(i == c->nw-1)
			r1.max.y = r.max.y;
		else
			r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
		r1.max.y = max(r1.max.y, r1.min.y + Border+font->height);
		r2 = r1;
		r2.max.y = r2.min.y+Border;
		draw(screen, r2, display->black, nil, ZP);
		r1.min.y = r2.max.y;
		r1.min.y = winresize(w, r1, FALSE, i==c->nw-1);
	}
}
コード例 #2
0
ファイル: text.c プロジェクト: 00001/plan9port
int
textresize(Text *t, Rectangle r, int keepextra)
{
	int odx;

	if(Dy(r) <= 0)
		r.max.y = r.min.y;
	else if(!keepextra)
		r.max.y -= Dy(r)%t->fr.font->height;
	odx = Dx(t->all);
	t->all = r;
	t->scrollr = r;
	t->scrollr.max.x = r.min.x+Scrollwid;
	t->lastsr = nullrect;
	r.min.x += Scrollwid+Scrollgap;
	frclear(&t->fr, 0);
	textredraw(t, r, t->fr.font, t->fr.b, odx);
	if(keepextra && t->fr.r.max.y < t->all.max.y && !t->fr.noredraw){
		/* draw background in bottom fringe of window */
		r.min.x -= Scrollgap;
		r.min.y = t->fr.r.max.y;
		r.max.y = t->all.max.y;
		draw(screen, r, t->fr.cols[BACK], nil, ZP);
	}
	return t->all.max.y;
}
コード例 #3
0
ファイル: screenlock.c プロジェクト: CoryXie/nix-os
void
grabmouse(void*)
{
	int fd, x, y;
	char ibuf[256], obuf[256];

	if(debug)
		return;
	fd = open("/dev/mouse", ORDWR);
	if(fd < 0)
		error("can't open /dev/mouse: %r");

	snprint(obuf, sizeof obuf, "m %d %d",
		screen->r.min.x + Dx(screen->r)/2,
		screen->r.min.y + Dy(screen->r)/2);
	while(read(fd, ibuf, sizeof ibuf) > 0){
		ibuf[12] = 0;
		ibuf[24] = 0;
		x = atoi(ibuf+1);
		y = atoi(ibuf+13);
		if(x != screen->r.min.x + Dx(screen->r)/2 ||
		   y != screen->r.min.y + Dy(screen->r)/2){
			fprint(fd, "%s", obuf);
			doblank = 1;
		}
	}
}
コード例 #4
0
ファイル: cols.c プロジェクト: dalmonian/harvey
void
colresize(Column *c, Rectangle r)
{
	int i;
	Rectangle r1, r2;
	Window *w;

	clearmouse();
	r1 = r;
	r1.max.y = r1.min.y + c->tag.font->height;
	textresize(&c->tag, r1);
	draw(screen, c->tag.scrollr, colbutton, nil, colbutton->r.min);
	r1.min.y = r1.max.y;
	r1.max.y += Border;
	draw(screen, r1, display->black, nil, ZP);
	r1.max.y = r.max.y;
	for(i=0; i<c->nw; i++){
		w = c->w[i];
		w->maxlines = 0;
		if(i == c->nw-1)
			r1.max.y = r.max.y;
		else
			r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
		r2 = r1;
		r2.max.y = r2.min.y+Border;
		draw(screen, r2, display->black, nil, ZP);
		r1.min.y = r2.max.y;
		r1.min.y = winresize(w, r1, FALSE);
	}
	c->r = r;
}
コード例 #5
0
ファイル: glendy.c プロジェクト: grobe0ba/plan9front
Point 
pix2board(int x, int y)
{
	float d, rx, ry, yh;
	int ny, nx;

	/* XXX: float→int causes small rounding errors */

	d = (float)(Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) -20: Dx(screen->r)-20;
	rx = d/(float)SzX;
	rx = rx/2.0;
	ry =d/(float)SzY;
	ry = ry/2.0;

	yh = ry/3.73205082;

	/* reverse board2pix() */
	ny = (int)(((float)y - ry)/(2*ry - ((y>2*ry)?yh:0.0)) + 0.5); /* ny = (y - ry)/(2ry-yh) */
	nx = (int)(((float)x - rx - (ny%2?rx:0.0))/(rx*2.0) + 0.5); /* nx = (x - rx - rx)/2rx */
	
	if (nx >= SzX)
		nx = SzX-1;
	if (ny >=SzY)
		ny = SzY-1;

	return Pt(nx, ny);
}
コード例 #6
0
ファイル: view.c プロジェクト: dancrossnyc/harvey
void
showpage(int page, Menu *m)
{
	if(doc->fwdonly)
		m->lasthit = 0;	/* this page */
	else
		m->lasthit = reverse ? doc->npage-1-page : page;

	esetcursor(&reading);
	delayfreeimage(nil);
	im = cachedpage(doc, angle, page);
	if(im == nil)
		wexits(0);
	if(resizing)
		resize(Dx(im->r), Dy(im->r));

	esetcursor(nil);
	if(showbottom){
		ul.y = screen->r.max.y - Dy(im->r);
		showbottom = 0;
	}

	redraw(screen);
	flushimage(display, 1);
}
コード例 #7
0
ファイル: win.c プロジェクト: grobe0ba/plan9front
void
resize(void)
{
	Rectangle old, r;
	int dxo, dyo, dxn, dyn;
	Win *w;
	
	old = screen->r;
	dxo = Dx(old);
	dyo = Dy(old);
	if(getwindow(display, Refnone) < 0)
		sysfatal("resize failed: %r");
	dxn = Dx(screen->r);
	dyn = Dy(screen->r);
	freescreen(scr);
	scr = allocscreen(screen, display->white, 0);
	if(scr == nil)
		sysfatal("allocscreen: %r");
	for(w = wlist.next; w != &wlist; w = w->next){
		r = rectsubpt(w->entire, old.min);
		r.min.x = muldiv(r.min.x, dxn, dxo);
		r.max.x = muldiv(r.max.x, dxn, dxo);
		r.min.y = muldiv(r.min.y, dyn, dyo);
		r.max.y = muldiv(r.max.y, dyn, dyo);
		w->entire = rectaddpt(r, screen->r.min);
		w->inner = insetrect(w->entire, BORDSIZ);
		freeimage(w->im);
		w->im = allocwindow(scr, w->entire, Refbackup, 0);
		if(w->im == nil)
			sysfatal("allocwindow: %r");
		draw(w->im, w->inner, w->tab->cols[BACK], nil, ZP);
		border(w->im, w->entire, BORDSIZ, w->tab->cols[w == actw ? BORD : DISB], ZP);
		w->tab->draw(w);
	}
}
コード例 #8
0
ファイル: stack.c プロジェクト: kaffepanna/wmii
void
stack_info(Frame *f, Frame **firstp, Frame **lastp, int *dyp, int *nframep) {
    Frame *ft, *first, *last;
    int dy, nframe;

    nframe = 0;
    dy = 0;
    first = f;
    last = f;

    for(ft=f; ft && ft->collapsed; ft=ft->anext)
        ;
    if(ft && ft != f) {
        f = ft;
        dy += Dy(f->colr);
    }
    for(ft=f; ft && !ft->collapsed; ft=ft->aprev) {
        first = ft;
        nframe++;
        dy += Dy(ft->colr);
    }
    for(ft=f->anext; ft && !ft->collapsed; ft=ft->anext) {
        if(first == nil)
            first = ft;
        last = ft;
        nframe++;
        dy += Dy(ft->colr);
    }
    if(nframep) *nframep = nframe;
    if(firstp) *firstp = first;
    if(lastp) *lastp = last;
    if(dyp) *dyp = dy;
}
コード例 #9
0
ファイル: crect.c プロジェクト: 8l/inferno
void
tkcvsrectdraw(Image *img, TkCitem *i, TkEnv *pe)
{
	int lw, rw;
	TkEnv *e;
	TkCrect *r;
	Rectangle d, rr;
	Point tr, bl;
	Image *pen;

	USED(pe);

	d.min = i->p.drawpt[0];
	d.max = i->p.drawpt[1];

	e = i->env;
	r = TKobj(TkCrect, i);

	pen = nil;
	if((e->set & (1<<TkCfill)))
		pen = tkgc(e, TkCfill);

	if(pen != nil)
		draw(img, d, pen, r->stipple, d.min);

	tr.x = d.max.x;
	tr.y = d.min.y;
	bl.x = d.min.x;
	bl.y = d.max.y;

	rw = (TKF2I(r->width) + 1)/2;
	if(rw <= 0)
		return;
	lw = (TKF2I(r->width))/2;

	pen = tkgc(e, TkCforegnd);
	if(pen != nil) {
		/* horizontal lines first */
		rr.min.x = d.min.x - lw;
		rr.max.x = d.max.x + rw;
		rr.min.y = d.min.y - lw;
		rr.max.y = d.min.y + rw;
		draw(img, rr, pen, nil, rr.min);
		rr.min.y += Dy(d);
		rr.max.y += Dy(d);
		draw(img, rr, pen, nil, rr.min);
		/* now the vertical */
		/* horizontal lines first */
		rr.min.x = d.min.x - lw;
		rr.max.x = d.min.x + rw;
		rr.min.y = d.min.y + rw;
		rr.max.y = d.max.y - lw;
		draw(img, rr, pen, nil, rr.min);
		rr.min.x += Dx(d);
		rr.max.x += Dx(d);
		draw(img, rr, pen, nil, rr.min);
	}
}
コード例 #10
0
ファイル: view.c プロジェクト: dancrossnyc/harvey
/*
 * A draw operation that touches only the area contained in bot but not in top.
 * mp and sp get aligned with bot.min.
 */
static void
gendrawdiff(Image *dst, Rectangle bot, Rectangle top,
	Image *src, Point sp, Image *mask, Point mp, int op)
{
	Rectangle r;
	Point origin;
	Point delta;

	USED(op);

	if(Dx(bot)*Dy(bot) == 0)
		return;

	/* no points in bot - top */
	if(rectinrect(bot, top))
		return;

	/* bot - top ≡ bot */
	if(Dx(top)*Dy(top)==0 || rectXrect(bot, top)==0){
		gendrawop(dst, bot, src, sp, mask, mp, op);
		return;
	}

	origin = bot.min;
	/* split bot into rectangles that don't intersect top */
	/* left side */
	if(bot.min.x < top.min.x){
		r = Rect(bot.min.x, bot.min.y, top.min.x, bot.max.y);
		delta = subpt(r.min, origin);
		gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
		bot.min.x = top.min.x;
	}

	/* right side */
	if(bot.max.x > top.max.x){
		r = Rect(top.max.x, bot.min.y, bot.max.x, bot.max.y);
		delta = subpt(r.min, origin);
		gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
		bot.max.x = top.max.x;
	}

	/* top */
	if(bot.min.y < top.min.y){
		r = Rect(bot.min.x, bot.min.y, bot.max.x, top.min.y);
		delta = subpt(r.min, origin);
		gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
		bot.min.y = top.min.y;
	}

	/* bottom */
	if(bot.max.y > top.max.y){
		r = Rect(bot.min.x, top.max.y, bot.max.x, bot.max.y);
		delta = subpt(r.min, origin);
		gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
		bot.max.y = top.max.y;
	}
}
コード例 #11
0
ファイル: catclock.c プロジェクト: aahud/harvey
void
redraw(Image *screen)
{
	Rectangle r = Rect(0,0,Dx(screen->r), Dy(screen->r));
	catoffs.x=(Dx(r)-CATWID)/2;
	catoffs.y=(Dy(r)-CATHGT)/2;
	if(!ptinrect(catoffs, r)) fprint(2, "catclock: window too small, resize!\n");
	xredraw=1;
}
コード例 #12
0
ファイル: vgamga4xx.c プロジェクト: 99years/plan9
static int
mga4xxscroll(VGAscr *scr, Rectangle dr, Rectangle sr)
{
	uchar * mga;
	int pitch;
 	int width, height;
	ulong start, end, sgn;
	Point sp, dp;
 
	if(scr->mmio == 0)
		return 0;
	mga = (uchar*)scr->mmio;

	assert(Dx(sr) == Dx(dr) && Dy(sr) == Dy(dr));

	sp = sr.min;
	dp = dr.min;
	if(eqpt(sp, dp))
		return 1;

	pitch = Dx(scr->gscreen->r);
	width = Dx(sr);
	height = Dy(sr);
	sgn = 0;

	if(dp.y > sp.y && dp.y < sp.y + height){
		sp.y += height - 1;
		dp.y += height - 1;
		sgn |= SGN_UP;
	}

	width--;
	start = end = sp.x + (sp.y * pitch);

	if(dp.x > sp.x && dp.x < sp.x + width){
		start += width;
		sgn |= SGN_LEFT;
	}
	else
		end += width;

	mga_fifo(mga, 8);
	mgawrite32(mga, DWGCTL, 0);
	mgawrite32(mga, SGN, sgn);
	mgawrite32(mga, AR5, sgn & SGN_UP ? -pitch : pitch);
	mgawrite32(mga, AR0, end);
	mgawrite32(mga, AR3, start);
	mgawrite32(mga, FXBNDRY, ((dp.x + width) << 16) | dp.x);
	mgawrite32(mga, YDSTLEN, (dp.y << 16) | height);
	mgawrite32(mga, DWGCTL + GO, DWG_BITBLT | DWG_SHIFTZERO | DWG_BFCOL | DWG_REPLACE);

	while(mgaread32(mga, STATUS) & 0x00010000)
		;

	return 1;
}
コード例 #13
0
ファイル: column.c プロジェクト: heilage-nsk/configs
static int
column_surplus(Area *a) {
	Frame *f;
	int surplus;

	surplus = Dy(a->r);
	for(f=a->frame; f; f=f->anext)
		surplus -= Dy(f->r);
	return surplus;
}
コード例 #14
0
ファイル: unloadimage.c プロジェクト: grobe0ba/plan9front
int
unloadimage(Image *i, Rectangle r, uchar *data, int ndata)
{
    int bpl, n, chunk, dx, dy;
    uchar *a, *start;
    Display *d;

    if(!rectinrect(r, i->r)) {
        werrstr("unloadimage: bad rectangle");
        return -1;
    }
    bpl = bytesperline(r, i->depth);
    if(ndata < bpl*Dy(r)) {
        werrstr("unloadimage: buffer too small");
        return -1;
    }
    start = data;
    d = i->display;
    chunk = d->bufsize;
    flushimage(d, 0);	/* make sure subsequent flush is for us only */
    while(r.min.y < r.max.y) {
        dx = Dx(r);
        dy = chunk/bpl;
        if(dy <= 0) {
            dy = 1;
            dx = ((chunk*dx)/bpl) & ~7;
            n = bytesperline(Rect(r.min.x, r.min.y, r.min.x+dx, r.min.y+dy), i->depth);
            if(unloadimage(i, Rect(r.min.x+dx, r.min.y, r.max.x, r.min.y+dy), data+n, bpl-n) < 0)
                return -1;
        } else {
            if(dy > Dy(r))
                dy = Dy(r);
            n = bpl*dy;
        }
        a = bufimage(d, 1+4+4*4);
        if(a == nil) {
            werrstr("unloadimage: %r");
            return -1;
        }
        a[0] = 'r';
        BPLONG(a+1, i->id);
        BPLONG(a+5, r.min.x);
        BPLONG(a+9, r.min.y);
        BPLONG(a+13, r.min.x+dx);
        BPLONG(a+17, r.min.y+dy);
        if(flushimage(d, 0) < 0)
            return -1;
        if(read(d->fd, data, n) < 0)
            return -1;
        data += bpl*dy;
        r.min.y += dy;
    }
    return data - start;
}
コード例 #15
0
ファイル: glendy.c プロジェクト: grobe0ba/plan9front
void
resize(void)
{
	int fd, size = (Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) + 20 : Dx(screen->r)+20; 

	fd = open("/dev/wctl", OWRITE);
	if(fd >= 0){
		fprint(fd, "resize -dx %d -dy %d", size, size);
		close(fd);
	}

}
コード例 #16
0
ファイル: bar.c プロジェクト: heilage-nsk/configs
void
bar_sety(WMScreen *s, int y) {
	Rectangle *r;
	int dy;

	r = &s->brect;

	dy = Dy(*r);
	r->min.y = y;
	r->max.y = y + dy;
	if(Dy(*r))
		reshapewin(s->barwin, *r);
}
コード例 #17
0
ファイル: group.c プロジェクト: 99years/plan9
static void
boxboxresize(Group *g, Rectangle r)
{
	int rows, cols, ht, wid, i, hpad, wpad;
	Rectangle rr;

	if(debug) fprint(2, "boxboxresize %q %R (%d×%d) min/max %R separation %d\n", g->name, r, Dx(r), Dy(r), g->size, g->separation);
	ht = 0;
	for(i=0; i<g->nkids; i++){
		if (g->kids[i]->size.min.y > ht)
			ht = g->kids[i]->size.min.y;
	}
	if (ht == 0)
		ctlerror("boxboxresize: height");
	rows = Dy(r) / (ht+g->separation);
	hpad = (Dy(r) % (ht+g->separation)) / g->nkids;
	cols = (g->nkids+rows-1)/rows;
	wid = Dx(r) / cols - g->separation;
	for(i=0; i<g->nkids; i++){
		if (g->kids[i]->size.max.x < wid)
			wid = g->kids[i]->size.max.x;
	}
	for(i=0; i<g->nkids; i++){
		if (g->kids[i]->size.min.x > wid)
			wid = g->kids[i]->size.min.x;
	}
	if (wid > Dx(r) / cols)
		ctlerror("can't fit controls in boxbox");
	wpad = (Dx(r) % (wid+g->separation)) / g->nkids;
	rr = rectaddpt(Rect(0,0,wid, ht), addpt(r.min, Pt(g->separation/2, g->separation/2)));
	if(debug) fprint(2, "boxboxresize rows %d, cols %d, wid %d, ht %d, wpad %d, hpad %d\n", rows, cols, wid, ht, wpad, hpad);
	for(i=0; i<g->nkids; i++){
		if(debug) fprint(2, "	%d %q: %R (%d×%d)\n", i, g->kids[i]->name, rr, Dx(rr), Dy(rr));
		_ctlprint(g->kids[i], "rect %R",
			rectaddpt(rr, Pt((wpad+wid+g->separation)*(i/rows), (hpad+ht+g->separation)*(i%rows))));
	}
	g->nseparators = rows + cols - 2;
	g->separators = realloc(g->separators, g->nseparators*sizeof(Rectangle));
	rr = r;
	rr.max.y = rr.min.y + g->separation+hpad;
	for (i = 1; i < rows; i++){
		g->separators[i-1] = rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation-hpad));
		if(debug) fprint(2, "row separation %d [%d]: %R\n", i, i-1, rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation)));
	}
	rr = r;
	rr.max.x = rr.min.x + g->separation+wpad;
	for (i = 1; i < cols; i++){
		g->separators[i+rows-2] = rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation-wpad, 0));
		if(debug) fprint(2, "col separation %d [%d]: %R\n", i, i+rows-2, rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation, 0)));
	}
}
コード例 #18
0
ファイル: kbmap.c プロジェクト: aahud/harvey
void
geometry(void)
{
	int i, rows;
	Rectangle r;

	rows = (Dy(screen->r)-2*MARGIN+PAD)/(font->height+PAD);

	r = Rect(0,0,(Dx(screen->r)-2*MARGIN), font->height);
	for(i=0; i<nmap; i++)
		map[i].r = rectaddpt(rectaddpt(r, Pt(MARGIN+(PAD+Dx(r))*(i/rows),
					MARGIN+(PAD+Dy(r))*(i%rows))), screen->r.min);

}
コード例 #19
0
ファイル: util.c プロジェクト: carriercomm/plan9-gpl
/*
 * Heuristic city.
 */
Window*
makenewwindow(Text *t)
{
	Column *c;
	Window *w, *bigw, *emptyw;
	Text *emptyb;
	int i, y, el;

	if(activecol)
		c = activecol;
	else if(seltext && seltext->col)
		c = seltext->col;
	else if(t && t->col)
		c = t->col;
	else{
		if(row.ncol==0 && rowadd(&row, nil, -1)==nil)
			error("can't make column");
		c = row.col[row.ncol-1];
	}
	activecol = c;
	if(t==nil || t->w==nil || c->nw==0)
		return coladd(c, nil, nil, -1);

	/* find biggest window and biggest blank spot */
	emptyw = c->w[0];
	bigw = emptyw;
	for(i=1; i<c->nw; i++){
		w = c->w[i];
		/* use >= to choose one near bottom of screen */
		if(w->body.maxlines >= bigw->body.maxlines)
			bigw = w;
		if(w->body.maxlines-w->body.nlines >= emptyw->body.maxlines-emptyw->body.nlines)
			emptyw = w;
	}
	emptyb = &emptyw->body;
	el = emptyb->maxlines-emptyb->nlines;
	/* if empty space is big, use it */
	if(el>15 || (el>3 && el>(bigw->body.maxlines-1)/2))
		y = emptyb->r.min.y+emptyb->nlines*font->height;
	else{
		/* if this window is in column and isn't much smaller, split it */
		if(t->col==c && Dy(t->w->r)>2*Dy(bigw->r)/3)
			bigw = t->w;
		y = (bigw->r.min.y + bigw->r.max.y)/2;
	}
	w = coladd(c, nil, nil, y);
	if(w->body.maxlines < 2)
		colgrow(w->col, w, 1);
	return w;
}
コード例 #20
0
ファイル: unloadimage.c プロジェクト: AustenConrad/plan-9
int
unloadimage(Image *i, Rectangle r, uchar *data, int ndata)
{
	int bpl, n, ntot, dy;
	uchar *a;
	Display *d;

	if(!rectinrect(r, i->r)){
		werrstr("unloadimage: bad rectangle");
		return -1;
	}
	bpl = bytesperline(r, i->depth);
	if(ndata < bpl*Dy(r)){
		werrstr("unloadimage: buffer too small");
		return -1;
	}

	d = i->display;
	flushimage(d, 0);	/* make sure subsequent flush is for us only */
	ntot = 0;
	while(r.min.y < r.max.y){
		a = bufimage(d, 1+4+4*4);
		if(a == 0){
			werrstr("unloadimage: %r");
			return -1;
		}
		dy = 8000/bpl;
		if(dy <= 0){
			werrstr("unloadimage: image too wide");
			return -1;
		}
		if(dy > Dy(r))
			dy = Dy(r);
		a[0] = 'r';
		BPLONG(a+1, i->id);
		BPLONG(a+5, r.min.x);
		BPLONG(a+9, r.min.y);
		BPLONG(a+13, r.max.x);
		BPLONG(a+17, r.min.y+dy);
		if(flushimage(d, 0) < 0)
			return -1;
		n = read(d->fd, data+ntot, ndata-ntot);
		if(n < 0)
			return n;
		ntot += n;
		r.min.y += dy;
	}
	return ntot;
}
コード例 #21
0
ファイル: image.c プロジェクト: jobovy/nemo
int sub_image (imageptr iptr, regionptr rptr, imageptr *optr)
{
  int nx,ny,nz, nx1,ny1,nz1, ix,iy,iz, ix0,iy0,iz0;
  size_t np, np1;

  nx  = Nx(iptr);
  ny  = Ny(iptr);
  nz  = Nz(iptr);
  np = nx*ny*nz;
  /* grab the bounding box */
  ix0 = BLC(rptr)[0];
  iy0 = BLC(rptr)[1];
  iz0 = BLC(rptr)[2];
  nx1 = TRC(rptr)[0] - ix0;
  ny1 = TRC(rptr)[1] - iy0;
  nz1 = TRC(rptr)[2] - iz0;
  np1 = nx1*ny1*nz1;

  *optr = (imageptr ) allocate(sizeof(image));
  dprintf (DLEV,"copy_image:Allocated image @ %d size=%d * %d * %d",*optr,nx1,ny1,nz1);
    	
  Frame(*optr) = (real *) allocate(np1*sizeof(real));	
  dprintf (DLEV,"Frame allocated @ %d ",Frame(*optr));
  Nx(*optr) = nx1;
  Ny(*optr) = ny1;
  Nz(*optr) = nz1;
  Xmin(*optr) = Xmin(iptr) + ix0*Dx(iptr);
  Ymin(*optr) = Ymin(iptr) + iy0*Dy(iptr);
  Zmin(*optr) = Zmin(iptr) + iz0*Dz(iptr);
  Dx(*optr) = Dx(iptr);
  Dy(*optr) = Dy(iptr);
  Dz(*optr) = Dz(iptr);
  Namex(*optr) = mystrcpy(Namex(iptr));
  Namey(*optr) = mystrcpy(Namey(iptr));
  Namez(*optr) = mystrcpy(Namez(iptr));
  Xref(*optr) = Xref(iptr) + ix0;
  Yref(*optr) = Yref(iptr) + iy0;
  Zref(*optr) = Zref(iptr) + iz0;
  for (iz=0; iz<nz1; iz++)
    for (iy=0; iy<ny1; iy++)
      for (ix=0; ix<nx1; ix++)
	CubeValue(*optr,ix,iy,iz) = CubeValue(iptr,ix-ix0,iy-iy0,iz-iy0);
  Storage(*optr) = matdef[idef];
  Axis(*optr) = Axis(iptr);
  set_iarray(*optr);
  
  return 1;		/* succes return code  */
}
コード例 #22
0
// constructive heuristics for orthogonal representation OR
void LongestPathCompaction::constructiveHeuristics(
	PlanRep &PG,
	OrthoRep &OR,
	const RoutingChannel<int> &rc,
	GridLayoutMapped &drawing)
{
	OGDF_ASSERT(OR.isOrientated());

	// x-coordinates of vertical segments
	CompactionConstraintGraph<int> Dx(OR, PG, odEast, rc.separation());
	Dx.insertVertexSizeArcs(PG, drawing.width(), rc);

	NodeArray<int> xDx(Dx.getGraph(), 0);
	computeCoords(Dx, xDx);

	// y-coordinates of horizontal segments
	CompactionConstraintGraph<int> Dy(OR, PG, odNorth, rc.separation());
	Dy.insertVertexSizeArcs(PG, drawing.height(), rc);

	NodeArray<int> yDy(Dy.getGraph(), 0);
	computeCoords(Dy, yDy);

	// final coordinates of vertices
	for(node v : PG.nodes) {
		drawing.x(v) = xDx[Dx.pathNodeOf(v)];
		drawing.y(v) = yDy[Dy.pathNodeOf(v)];
	}
}
コード例 #23
0
ファイル: ccdsmooth.c プロジェクト: jobovy/nemo
void nemo_main ()
{
    setparams();			/* set par's in globals */

    instr = stropen (infile, "r");
    read_image (instr,&iptr);
				/* set some global paramters */
    nx = Nx(iptr);	
    ny = Ny(iptr);
    nz = Nz(iptr);
    xmin = Xmin(iptr);
    ymin = Ymin(iptr);
    zmin = Zmin(iptr);
    dx = Dx(iptr);
    dy = Dy(iptr);
    dz = Dz(iptr);

    if(hasvalue("gauss"))
        make_gauss_beam(getparam("dir"));

    outstr = stropen (outfile,"w");
    if (hasvalue("wiener"))
      wiener();
    else
      smooth_it();
    write_image (outstr,iptr);

    strclose(instr);
    strclose(outstr);
}
コード例 #24
0
ファイル: stats.c プロジェクト: aahud/harvey
Point
datapoint(Graph *g, int x, uint64_t v, uint64_t vmax)
{
	Point p;
	double y;

	p.x = x;
	y = ((double)v)/(vmax*scale);
	if(logscale){
		/*
		 * Arrange scale to cover a factor of 1000.
		 * vmax corresponds to the 100 mark.
		 * 10*vmax is the top of the scale.
		 */
		if(y <= 0.)
			y = 0;
		else{
			y = log10(y);
			/* 1 now corresponds to the top; -2 to the bottom; rescale */
			y = (y+2.)/3.;
		}
	}
	if(y < 0x7fffffff){	/* avoid floating overflow */
		p.y = g->r.max.y - Dy(g->r)*y - Dot;
		if(p.y < g->r.min.y)
			p.y = g->r.min.y;
		if(p.y > g->r.max.y-Dot)
			p.y = g->r.max.y-Dot;
	}else
		p.y = g->r.max.y-Dot;
	return p;
}
コード例 #25
0
ファイル: ccdplot.c プロジェクト: Milkyway-at-home/nemo
nemo_main()
{
  int n = 0;
  setparams();                    /* set globals */

  instr = stropen (infile, "r");
  plinit ("***", 0.0, 20.0, 0.0, 20.0);       /* init yapp */
  while (read_image(instr,&iptr)) {   /* loop while more images found */
    dprintf(1,"Time= %g MinMax= %g %g\n",Time(iptr),MapMin(iptr),MapMax(iptr));
    nx=Nx(iptr);			
    ny=Ny(iptr);
    nz=Nz(iptr);
    if (nz > 1) error("Cannot handle 3D images [%d,%d,%d]",nx,ny,nz);
    xmin=Xmin(iptr);
    ymin=Ymin(iptr);
    dx=Dx(iptr);
    dy=Dy(iptr);
    xsize = nx * dx;
    ysize = ny * dy;
    if (n>0) {
      sleep(1);
      plframe();
    }
    plot_map();                                 /* plot the map */
    n++;
  }
  plstop();                                   /* end of yapp */
  strclose(instr);
}
コード例 #26
0
ファイル: tabs.c プロジェクト: 99years/plan9
static
int
tableheight(Table *t, int sep)
{
	Tablecell *c;
	Lay *lay;
	int i, h, toth;

	for(i=0; i<t->nrow; i++){
		h = 0;
		for(c=t->rows[i].cells; c!=nil; c=c->nextinrow){
			if(c->rowspan != 1)
				continue;
			lay = layitems(c->content, Rect(0, 0, cellwidth(t, c, sep), 0), FALSE);
			h = max(h, max(Dy(lay->r), c->hspec));
			layfree(lay);
		}
		t->rows[i].height = h;
	}
	fixrows(t, sep);
	toth = 0;
	for(i=0; i<t->nrow; i++)
		toth += t->rows[i].height;

	return toth;
}
コード例 #27
0
ファイル: gcs.c プロジェクト: deadpixi/sam
/*
 * GCs are all for same screen, and depth is either 1 or screen depth.
 * Return a GC for the depth of b, with values as specified by gcv.
 *
 * Also, set (or unset) the clip rectangle if necessary.
 * (This implementation should be improved if setting a clip rectangle is not rare).
 */
GC
_getgc(Bitmap *b, uint64_t gcvm, XGCValues *pgcv)
{
    static GC gc0, gcn;
    static bool clipset = false;
    GC g;
    XRectangle xr;

    g = (b->ldepth==0)? gc0 : gcn;
    if(!g){
        g = XCreateGC(_dpy, (Drawable)b->id, gcvm, pgcv);
        if(b->ldepth==0)
            gc0 = g;
        else
            gcn = g;
    } else
        XChangeGC(_dpy, g, gcvm, pgcv);
    if(b->flag&CLIP){
        xr.x = b->clipr.min.x;
        xr.y = b->clipr.min.y;
        xr.width = Dx(b->clipr);
        xr.height = Dy(b->clipr);
        if(b->flag&SHIFT){
            xr.x -= b->r.min.x;
            xr.y -= b->r.min.y;
        }
        XSetClipRectangles(_dpy, g, 0, 0, &xr, 1, YXBanded);
        clipset = true;
    }else if(clipset){
        pgcv->clip_mask = None;
        XChangeGC(_dpy, g, GCClipMask, pgcv);
        clipset = false;
    }
    return g;
}
コード例 #28
0
ファイル: menuhit.c プロジェクト: pocket7878/sam
static void
menuscrollpaint(Rectangle scrollr, int off, int nitem, int nitemdrawn)
{
    Rectangle r;

    bitblt(&screen, scrollr.min, &screen, scrollr, 0);
    r.min.x = scrollr.min.x;
    r.max.x = scrollr.max.x;
    r.min.y = scrollr.min.y + (Dy(scrollr)*off)/nitem;
    r.max.y = scrollr.min.y + (Dy(scrollr)*(off+nitemdrawn))/nitem;
    if(r.max.y < r.min.y+2)
        r.max.y = r.min.y+2;
    border(&screen, r, 1, F, _bgpixel);
    if(darkgrey)
        texture(&screen, inset(r, 1), darkgrey, S);
}
コード例 #29
0
ファイル: page.c プロジェクト: carriercomm/legacy
static
void
renderchilds(Page *p)
{
	Rectangle r;
	Kidinfo *k;
	Page *c;
	int i, j, x, y, *w, *h;

	draw(p->b, p->all, display->white, nil, ZP);
	r = p->all;
	y = r.min.y;
	c = p->child;
	k = p->kidinfo;
	frdims(k->rows, k->nrows, Dy(r), &h);
	frdims(k->cols, k->ncols, Dx(r), &w);
	for(i=0; i<k->nrows; i++){
		x = r.min.x;
		for(j=0; j<k->ncols; j++){
			if(c->aborting)
				return;
			c->b = p->b;
			c->all = Rect(x,y,x+w[j],y+h[i]);
			c->w = p->w;
			pagerender(c);
			c = c->next;
			x += w[j];
		}
		y += h[i];
	}
	free(w);
	free(h);
}
コード例 #30
0
ファイル: canvs.c プロジェクト: 8l/inferno
void
tkcvssv(Tk *tk)
{
	TkCanvas *c;
	int top, bot, height;
	char val[Tkminitem], cmd[Tkmaxitem], *v, *e;

	c = TKobj(TkCanvas, tk);
	if(c->yscroll == nil)
		return;

	top = 0;
	bot = TKI2F(1);

	height = Dy(c->region);
	if(height != 0) {
		top = TKI2F(c->view.y)/height;
		bot = TKI2F(c->view.y+tk->act.height)/height;
	}

	v = tkfprint(val, top);
	*v++ = ' ';
	tkfprint(v, bot);
	snprint(cmd, sizeof(cmd), "%s %s", c->yscroll, val);
	e = tkexec(tk->env->top, cmd, nil);
	if ((e != nil) && (tk->name != nil))
		print("tk: yscrollcommand \"%s\": %s\n", tk->name->name, e);
}