Exemple #1
0
// ---------------------------------------------------------------------
void Isigraph2::keyPressEvent(QKeyEvent *event)
{
  int key1=0;
  int key=event->key();
  if (ismodifier(key)) return;
  if ((key==Qt::Key_unknown)||((key>=Qt::Key_F1)&&(key<=Qt::Key_F35))) {
    QWidget::keyPressEvent(event);
    return;
  } else
    key1=translateqkey(key);

  // Ctrl+anything becomes (possibly) a _fkey event; others become _char
  if (!event->modifiers().testFlag(Qt::ControlModifier)) {
    char sysdata[20];
    if (key==key1)
      sprintf(sysdata , "%s", event->text().toUtf8().constData());
    else sprintf(sysdata , "%s", QString(QChar(key1)).toUtf8().constData());

    pchild->event=string("char");
    pchild->sysmodifiers=pchild->pform->getsysmodifiers(event->modifiers());
    pchild->sysdata=string(sysdata);
    pchild->pform->signalevent(pchild);
    // for ESC key, abort further processing lest we generate a second J event.
    if (key==Qt::Key_Escape) return;
  }
  QWidget::keyPressEvent(event);
}
Exemple #2
0
// ---------------------------------------------------------------------
void Form::keyPressEvent(QKeyEvent *e)
{
  int k=e->key();
  if (ismodifier(k)) return;
  if (k==Qt::Key_Escape) {
    e->ignore();
    if (closed) return;
    if (escclose) {
      if (closeok) {
        closed=true;
        close();
      } else  {
        event="close";
        fakeid="";
        form=this;
        signalevent(0);
      }
    } else {
      event="cancel";
      fakeid="";
      form=this;
      signalevent(0);
    }
  } else if (k>=Qt::Key_F1 && k<=Qt::Key_F35) {
    event="fkey";
    form=this;
    signalevent(0,e);
  } else if ((e->modifiers() & Qt::ControlModifier) &&
             ((k>=Qt::Key_A && k<=Qt::Key_Z) || (k>=Qt::Key_0 && k<=Qt::Key_9) || (k>=Qt::Key_Home && k<=Qt::Key_PageDown))) {
    event="fkey";
    form=this;
    signalevent(0,e);
  } else
    QWidget::keyPressEvent(e);
}
Exemple #3
0
extern void
ambnotify(			/* record new modifier */
	OBJECT	obj
)
{
	static int  hitlimit = 0;
	OBJREC	 *o;
	char  **amblp;

	if (obj == OVOID) {		/* starting over */
		ambset[0] = 0;
		hitlimit = 0;
		return;
	}
	o = objptr(obj);
	if (hitlimit || !ismodifier(o->otype))
		return;
	for (amblp = amblist; *amblp != NULL; amblp++)
		if (!strcmp(o->oname, *amblp)) {
			if (ambset[0] >= MAXASET) {
				error(WARNING, "too many modifiers in ambient list");
				hitlimit++;
				return;		/* should this be fatal? */
			}
			insertelem(ambset, obj);
			return;
		}
}
Exemple #4
0
int
o_default(			/* default object is non-material modifier */
	register OBJREC	*o
)
{
	register LUENT	*lup;
#ifdef DEBUG
	if (o->otype >= 0 && !ismodifier(o->otype))
		error(CONSISTENCY, "o_default handed non-modifier");
#endif
					/* find name in lookup table */
	if ((lup = lu_find(&mtab, o->oname)) == NULL)
		goto memerr;
	if (lup->key == NULL) {		/* new entry? */
		lup->key = (char *)malloc(strlen(o->oname)+1);
		if (lup->key == NULL)
			goto memerr;
		strcpy(lup->key, o->oname);
	} else if (lup->data != NULL)
		freemtl(lup->data);
	if ((lup->data = o->os) != NULL)	/* make material reference */
		((MATREC *)lup->data)->nlinks++;
	return(0);
memerr:
	error(SYSTEM, "out of memory in o_default");
	return(0);
}
Exemple #5
0
static int
nonsurfintree(OCTREE ot)		/* check tree for modifiers */
{
	OBJECT  set[MAXSET+1];
	register int  i;

	if (isempty(ot))
		return(0);
	if (istree(ot)) {
		for (i = 0; i < 8; i++)
			if (nonsurfintree(octkid(ot, i)))
				return(1);
		return(0);
	}
	objset(set, ot);
	for (i = set[0]; i > 0; i-- )
		if (ismodifier(objptr(set[i])->otype))
			return(1);
	return(0);
}
Exemple #6
0
char *
checkmesh(MESH *mp)			/* validate mesh data */
{
	static char	embuf[128];
	int		nouvbounds = 1;
	int	i;
					/* basic checks */
	if (mp == NULL)
		return("NULL mesh pointer");
	if (!mp->ldflags)
		return("unassigned mesh");
	if (mp->name == NULL)
		return("missing mesh name");
	if (mp->nref <= 0)
		return("unreferenced mesh");
					/* check boundaries */
	if (mp->ldflags & IO_BOUNDS) {
		if (mp->mcube.cusize <= FTINY)
			return("illegal octree bounds in mesh");
		nouvbounds = (mp->uvlim[1][0] - mp->uvlim[0][0] <= FTINY ||
				mp->uvlim[1][1] - mp->uvlim[0][1] <= FTINY);
	}
					/* check octree */
	if (mp->ldflags & IO_TREE) {
		if (isempty(mp->mcube.cutree))
			error(WARNING, "empty mesh octree");
	}
					/* check scene data */
	if (mp->ldflags & IO_SCENE) {
		if (!(mp->ldflags & IO_BOUNDS))
			return("unbounded scene in mesh");
		if (mp->mat0 < 0 || mp->mat0+mp->nmats > nobjects)
			return("bad mesh modifier range");
		for (i = mp->mat0+mp->nmats; i-- > mp->mat0; ) {
			int	otyp = objptr(i)->otype;
			if (!ismodifier(otyp)) {
				sprintf(embuf,
					"non-modifier in mesh (%s \"%s\")",
					ofun[otyp].funame, objptr(i)->oname);
				return(embuf);
			}
		}
		if (mp->npatches <= 0)
			error(WARNING, "no patches in mesh");
		for (i = 0; i < mp->npatches; i++) {
			MESHPATCH	*pp = &mp->patch[i];
			if (pp->nverts <= 0)
				error(WARNING, "no vertices in patch");
			else {
				if (pp->xyz == NULL)
					return("missing patch vertex list");
				if (nouvbounds && pp->uv != NULL)
					return("unreferenced uv coordinates");
			}
			if (pp->ntris > 0 && pp->tri == NULL)
				return("missing patch triangle list");
			if (pp->nj1tris > 0 && pp->j1tri == NULL)
				return("missing patch joiner triangle list");
			if (pp->nj2tris > 0 && pp->j2tri == NULL)
				return("missing patch double-joiner list");
		}
	}
	return(NULL);			/* seems OK */
}