Ejemplo n.º 1
0
Archivo: Eyes.c Proyecto: aosm/X11
/* ARGSUSED */
static void draw_it (
     XtPointer client_data,
     XtIntervalId *id)		/* unused */
{
        EyesWidget	w = (EyesWidget)client_data;
	Window		rep_root, rep_child;
	int		rep_rootx, rep_rooty;
	unsigned int	rep_mask;
	int		dx, dy;
	TPoint		mouse;
	Display		*dpy = XtDisplay (w);
	Window		win = XtWindow (w);
	TPoint		newpupil[2];
	XPoint		xnewpupil, xpupil;

	if (XtIsRealized((Widget)w)) {
    		XQueryPointer (dpy, win, &rep_root, &rep_child,
 			&rep_rootx, &rep_rooty, &dx, &dy, &rep_mask);
		mouse.x = Tx(dx, dy, &w->eyes.t);
		mouse.y = Ty(dx, dy, &w->eyes.t);
		if (!TPointEqual (mouse, w->eyes.mouse)) {
			computePupils (mouse, newpupil);
			xpupil.x = Xx(w->eyes.pupil[0].x, w->eyes.pupil[0].y, &w->eyes.t);
			xpupil.y = Xy(w->eyes.pupil[0].x, w->eyes.pupil[0].y, &w->eyes.t);
			xnewpupil.x =  Xx(newpupil[0].x, newpupil[0].y, &w->eyes.t);
			xnewpupil.y =  Xy(newpupil[0].x, newpupil[0].y, &w->eyes.t);
			if (!XPointEqual (xpupil, xnewpupil)) {
			    if (w->eyes.pupil[0].x != -1000 || w->eyes.pupil[0].y != -1000)
				eyeBall (w, w->eyes.centerGC, 0);
			    w->eyes.pupil[0] = newpupil[0];
			    eyeBall (w, w->eyes.pupGC, 0);
			}
			xpupil.x = Xx(w->eyes.pupil[1].x, w->eyes.pupil[1].y, &w->eyes.t);
			xpupil.y = Xy(w->eyes.pupil[1].x, w->eyes.pupil[1].y, &w->eyes.t);
			xnewpupil.x =  Xx(newpupil[1].x, newpupil[1].y, &w->eyes.t);
			xnewpupil.y =  Xy(newpupil[1].x, newpupil[1].y, &w->eyes.t);
			if (!XPointEqual (xpupil, xnewpupil)) {
			    if (w->eyes.pupil[1].x != -1 || w->eyes.pupil[1].y != -1)
				eyeBall (w, w->eyes.centerGC, 1);
			    w->eyes.pupil[1] = newpupil[1];
			    eyeBall (w, w->eyes.pupGC, 1);
			}
			w->eyes.mouse = mouse;
			w->eyes.update = 0;
		} else {
			if (delays[w->eyes.update + 1] != 0)
				++w->eyes.update;
		}
	}
	w->eyes.interval_id =
		XtAppAddTimeOut(XtWidgetToApplicationContext((Widget) w),
				delays[w->eyes.update], draw_it, (XtPointer)w);
} /* draw_it */
Ejemplo n.º 2
0
static void
TFillArc(register Display * dpy, Drawable d, GC gc, Transform * t, double x, double y, double width, double height, int angle1, int angle2, XRectangle * rect)
{
	int         xx, xy, xw, xh;

	xx = Xx(x, y, t);
	xy = Xy(x, y, t);
	xw = Xwidth(width, height, t);
	xh = Xheight(width, height, t);
	if (xw < 0) {
		xx += xw;
		xw = -xw;
	}
	if (xh < 0) {
		xy += xh;
		xh = -xh;
	}
	XFillArc(dpy, d, gc, xx, xy, xw, xh, angle1, angle2);

	if (rect != NULL) {
		rect->x = xx;
		rect->y = xy;
		rect->width = xw;
		rect->height = xh;
	}
}
Ejemplo n.º 3
0
static void
drawEye(EyesWidget w, TPoint newpupil, int num)
{
    XPoint		xnewpupil, xpupil;

    xpupil.x = Xx(w->eyes.pupil[num].x, w->eyes.pupil[num].y, &w->eyes.t);
    xpupil.y = Xy(w->eyes.pupil[num].x, w->eyes.pupil[num].y, &w->eyes.t);
    xnewpupil.x = Xx(newpupil.x, newpupil.y, &w->eyes.t);
    xnewpupil.y = Xy(newpupil.x, newpupil.y, &w->eyes.t);
    if (
	!XPointEqual(xpupil, xnewpupil)) {
	TPoint oldpupil = w->eyes.pupil[num];
	w->eyes.pupil[num] = newpupil;
	eyeBall (w, TRUE, &oldpupil, num);
    }
}
Ejemplo n.º 4
0
Archivo: drawp.c Proyecto: kahrs/cda
static void
drawpin(Pin p)
{
    int r = RAD(p.drill);
    if (r == 0)
        r = 27;
    if (pinradius != r)
        Bprint(&out, "circlerad=%d\n", pinradius=r);
    Bprint(&out, "pin(%d,%d)\n", Xy(p.p));
    reftodatum(p.p);
}
Ejemplo n.º 5
0
void Blotter::find_connected_area(
    Blotter::Area& area,
    const int x,
    const int y
) {
    std::list <Xy> open; // Pixels that still have to be examined.
    open.push_back(Xy(x, y));

    const int xl = area.ground->w;
    const int yl = area.ground->h;

    while (!open.empty()) {
        Xy cur = *open.begin();
        open.erase(open.begin());

        if (getpixel(area.ground, cur.first, cur.second) != pink) {
            std::set <Xy> ::const_iterator found = area.Xy.find(cur);
            // If cur is not in the set area.Xy
            if (found == area.Xy.end()) {
                area.Xy.insert(cur);
                if (area.x_min > cur.first)  area.x_min = cur.first;
                if (area.x_max < cur.first)  area.x_max = cur.first;
                if (area.y_min > cur.second) area.y_min = cur.second;
                if (area.y_max < cur.second) area.y_max = cur.second;
                const bool u = cur.first  > 0;
                const bool d = cur.first  < xl - 1;
                const bool l = cur.second > 0;
                const bool r = cur.second < yl - 1;
                if (u     ) open.push_back(Xy(cur.first-1, cur.second  ));
                if (u && r) open.push_back(Xy(cur.first-1, cur.second+1));
                if (     r) open.push_back(Xy(cur.first,   cur.second+1));
                if (d && r) open.push_back(Xy(cur.first+1, cur.second+1));
                if (d     ) open.push_back(Xy(cur.first+1, cur.second  ));
                if (d && l) open.push_back(Xy(cur.first+1, cur.second-1));
                if (     l) open.push_back(Xy(cur.first,   cur.second-1));
                if (u && l) open.push_back(Xy(cur.first-1, cur.second-1));
            }
        }
        // Done checking a pixel.
    }
    // Done adding a complete connected area to Area& area.
}
Ejemplo n.º 6
0
Archivo: drawp.c Proyecto: kahrs/cda
static void
drawchip(Chip *c)
{
    int vert, i;
    char *name;

    if(c->flags&UNPLACED)
        return;
    if(!wfile) {
        vert = (nortext == 0) && (Dy(c->r) > Dx(c->r));
        name = chname==0 ? c->name :
               chname<0 ? (c->type->code ? c->type->code : c->typename) :
               c->type->pkgname;
        Bprint(&out, "chip(%s,%d,%d,%d,%d,%d,%d,%d)\n",
               name, Xy(c->pt), Dx(c->r), Dy(c->r),
               c->pt.x-c->r.min.x, c->pt.y-c->r.min.y, vert);
    }
Ejemplo n.º 7
0
static void
FillArc(Display *dpy, Drawable d, GC gc, Transform *t, double x, double y,
	double width, double height, int angle1, int angle2)
{
	int xx, xy, xw, xh;

	xx = Xx(x,y,t);
	xy = Xy(x,y,t);
	xw = Xwidth (width, height, t);
	xh = Xheight (width, height, t);
	if (xw < 0)
	{
		xx += xw;
		xw = -xw;
	}
	if (xh < 0)
	{
		xy += xh;
		xh = -xh;
	}
	XFillArc(dpy, d, gc, xx, xy, xw, xh, angle1, angle2);
}
Ejemplo n.º 8
0
ShZzy::ShZzy(const char* theName)
  :Sh(theName, Xy(0)),
   iAmInited(false)
{}