Example #1
0
static float
PointProximity(void *p, VG_View *vv, VG_Vector *vPt)
{
	VG_Text *vt = p;
	VG_Vector v1 = VG_Pos(vt->p1);
	VG_Vector v2 = VG_Pos(vt->p2);

	/* XXX TODO */
	return VG_PointLineDistance(v1, v2, vPt);
}
Example #2
0
static void
Move(void *p, VG_Vector vCurs, VG_Vector vRel)
{
	VG_Circle *vc = p;

	vc->r = VG_Distance(VG_Pos(vc->p), vCurs);
}
Example #3
0
static void
Extent(void *p, VG_View *vv, VG_Vector *a, VG_Vector *b)
{
	VG_Circle *vc = p;
	VG_Vector vCenter = VG_Pos(vc->p);

	a->x = vCenter.x - vc->r;
	a->y = vCenter.y - vc->r;
	b->x = vCenter.x + vc->r;
	b->y = vCenter.y + vc->r;
}
Example #4
0
static void
Draw(void *p, VG_View *vv)
{
	VG_Circle *vc = p;
	VG_Vector vCenter = VG_Pos(vc->p);
	int x, y, r;

	VG_GetViewCoords(vv, vCenter, &x, &y);
	r = (int)(vc->r*vv->scale);
	AG_DrawCircle(vv, x, y, r, VG_MapColorRGB(VGNODE(vc)->color));
}
Example #5
0
static void
Extent(void *p, VG_View *vv, VG_Vector *a, VG_Vector *b)
{
	VG_Text *vt = p;
	float wText, hText;
	VG_Vector v1, v2;
	int su;

	if ((su = AG_TextCacheGet(vv->tCache, vt->text)) == -1) {
		a->x = 0.0f;
		a->y = 0.0f;
		return;
	}
	wText = (float)WSURFACE(vv,su)->w/vv->scale;
	hText = (float)WSURFACE(vv,su)->h/vv->scale;
	v1 = VG_Pos(vt->p1);
	v2 = VG_Pos(vt->p2);
	a->x = MIN(v1.x,v2.x) - wText/2.0f;
	a->y = MIN(v1.y,v2.y) - hText/2.0f;
	b->x = MAX(v1.x,v2.x) + hText/2.0f;
	b->y = MAX(v1.y,v2.y) + hText/2.0f;
}
Example #6
0
static void
RenderText(VG_Text *vt, char *sIn, VG_View *vv)
{
	char sSubst[VG_TEXT_MAX], *s;
	VG_Vector v1, v2, vMid;
	int x, y;
	int su;

	if (vt->vsObj != NULL) {
		AG_VariableSubst(vt->vsObj, sIn, sSubst, sizeof(sSubst));
		s = sSubst;
	} else {
		s = sIn;
	}

	AG_PushTextState();

	if (vt->fontFace[0] != '\0' &&
	   ((agGUI && vt->fontSize != (int)agDefaultFont->spec.size) ||
	    (agGUI && vt->fontFlags != agDefaultFont->flags))) {
		AG_TextFontLookup(vt->fontFace, vt->fontSize, vt->fontFlags);
	}
	AG_TextColor(VG_MapColorRGB(VGNODE(vt)->color));

	v1 = VG_Pos(vt->p1);
	v2 = VG_Pos(vt->p2);
	vMid.x = v1.x + (v2.x - v1.x)/2.0f;
	vMid.y = v1.y + (v2.y - v1.y)/2.0f;
	VG_GetViewCoords(vv, vMid, &x, &y);
	
	if ((su = AG_TextCacheGet(vv->tCache, s)) != -1) {
		VG_DrawSurface(vv, x, y,
		    VG_Degrees(VG_Atan2(v1.y-v2.y, v1.x-v2.x)),
		    su);
	}
	AG_PopTextState();
}
Example #7
0
static float
PointProximity(void *p, VG_View *vv, VG_Vector *vPt)
{
	VG_Circle *vc = p;
	VG_Vector vCenter = VG_Pos(vc->p);
	float theta = Atan2(vPt->y - vCenter.y,
	                    vPt->x - vCenter.x);
	VG_Vector vNear;
	float d;

	vNear.x = vCenter.x + vc->r*Cos(theta);
	vNear.y = vCenter.y + vc->r*Sin(theta);
	d = VG_Distance(*vPt, vNear);
	*vPt = vNear;
	return (d);
}
Example #8
0
static int
MouseMotion(void *p, VG_Vector vPos, VG_Vector vRel, int b)
{
	VG_TextTool *t = p;
	VG_View *vv = VGTOOL(t)->vgv;
	VG_Point *pEx;
	VG_Vector pos;
	float theta, rad;
	
	if (t->vtIns != NULL) {
		pEx = t->vtIns->p1;
		pos = VG_Pos(pEx);
		theta = VG_Atan2(vPos.y - pos.y,
		                 vPos.x - pos.x);
		rad = VG_Hypot(vPos.x - pos.x,
		               vPos.y - pos.y);
		if ((pEx = VG_NearestPoint(vv, vPos, t->vtIns->p2))) {
			VG_Status(vv, _("End baseline at Point%u"),
			    (Uint)VGNODE(pEx)->handle);
		} else {
			VG_Status(vv,
			    _("End baseline at %.2f,%.2f "
			      "(%.2f|%.2f\xc2\xb0)"),
			    vPos.x, vPos.y, rad, VG_Degrees(theta));
		}
		VG_SetPosition(t->vtIns->p2, vPos);
	} else {
		if ((pEx = VG_NearestPoint(vv, vPos, NULL))) {
			VG_Status(vv, _("Start baseline at Point%u"),
			    (Uint)VGNODE(pEx)->handle);
		} else {
			VG_Status(vv, _("Start baseline at %.2f,%.2f"), vPos.x,
			    vPos.y);
		}
	}
	return (0);
}