Exemple #1
0
static void 
ConsiderContext(struct xobject *obj,  /* object to be transformed            */
		double M[2][2])    /* matrix (may be changed)                */
{
       register int context = 0; /* index in contexts array                  */
 
       if (obj == NULL) return;
 
       if (ISPATHTYPE(obj->type)) {
               struct segment *path = (struct segment *) obj;
 
               context = path->context;
       }
       else if (obj->type == SPACETYPE) {
               struct XYspace *S = (struct XYspace *) obj;
 
               context = S->context;
       }
       else if (obj->type == PICTURETYPE) {

       }
       else
               context = NULLCONTEXT;
 
       if (context != NULLCONTEXT) {
               MatrixMultiply(contexts[context].inverse, M, M);
               MatrixMultiply(M, contexts[context].normal, M);
       }
}
Exemple #2
0
Fichier : paths.c Projet : aosm/X11
/*
When 'link' is NULL, we are at the last segment in the path (surprise!).
 
'last' is only non-NULL on the first segment of a path,
for all the other segments 'last' == NULL.  We test for a non-NULL
'last' (ISPATHANCHOR predicate) when we are given an alleged path
to make sure the user is not trying to pull a fast one on us.
 
A path may be a collection of disjoint paths.  Every break in the
disjoint path is represented by a MOVETYPE segment.
 
Closed paths are discussed in :hdref refid=close..
 
:h3.CopyPath() - Physically Duplicating a Path
 
This simple function illustrates moving through the path linked list.
Duplicating a segment just involves making a copy of it, except for
text, which has some auxilliary things involved.  We don't feel
competent to duplicate text in this module, so we call someone who
knows how (in the FONTS module).
*/
struct segment *
CopyPath(struct segment *p0)         /* path to duplicate                    */
{
       register struct segment *p,*n = NULL,*last = NULL,*anchor;
 
       for (p = p0, anchor = NULL; p != NULL; p = p->link) {
 
               ARGCHECK((!ISPATHTYPE(p->type) || (p != p0 && p->last != NULL)),
                       "CopyPath: invalid segment", p, NULL, (0), struct segment *);
 
               if (p->type == TEXTTYPE)
                       n = (struct segment *) CopyText(p);
               else
                       n = (struct segment *)Allocate(p->size, p, 0);
               n->last = NULL;
               if (anchor == NULL)
                       anchor = n;
               else
                       last->link = n;
               last = n;
       }
/*
At this point we have a chain of newly allocated segments hanging off
'anchor'.  We need to make sure the first segment points to the last:
*/
       if (anchor != NULL) {
               n->link = NULL;
               anchor->last = n;
       }
 
       return(anchor);
}
Exemple #3
0
struct xobject *t1_Xform(
       register struct xobject *obj,  /* object to transform                 */
       register DOUBLE M[2][2])    /* transformation matrix                  */
{
       if (obj == NULL)
               return(NULL);
 
       if (obj->type == FONTTYPE) {
               register struct font *F = (struct font *) obj;
 
               F = UniqueFont(F);
               return((struct xobject*)F);
       }
       if (obj->type == PICTURETYPE) {
/*
In the case of a picture, we choose both to update the picture's
transformation matrix and keep the handles up to date.
*/
               register struct picture *P = (struct picture *) obj;
               register struct segment *handles;  /* temporary path to transform handles */
 
               P = UniquePicture(P);
               handles = PathSegment(LINETYPE, P->origin.x, P->origin.y);
               handles = Join(handles,
                              PathSegment(LINETYPE, P->ending.x, P->ending.y) );
               handles = (struct segment *)Xform((struct xobject *) handles, M);
               P->origin = handles->dest;
               P->ending = handles->link->dest;
               KillPath(handles);
               return((struct xobject *)P);
       }
 
       if (ISPATHTYPE(obj->type)) {
               struct XYspace pseudo;  /* local temporary space              */
               PseudoSpace(&pseudo, M);
               return((struct xobject *) PathTransform((struct segment *)obj, &pseudo));
       }
 
 
       if (obj->type == SPACETYPE) {
               register struct XYspace *S = (struct XYspace *) obj;
 
/* replaced ISPERMANENT(S->flag) with S->references > 1 3-26-91 PNM */
               if (S->references > 1)
                       S = CopySpace(S);
               else
                       S->ID = NEXTID;
 
               MatrixMultiply(S->tofract.normal, M, S->tofract.normal);
               /*
               * mark inverted matrix invalid:
               */
               S->flag &= ~HASINVERSE(ON);
 
               FillOutFcns(S);
               return((struct xobject *) S);
       }
 
       return(ArgErr("Untransformable object", obj, obj));
}
Exemple #4
0
Fichier : paths.c Projet : aosm/X11
/*
:h3.KillPath() - Destroying a Path
 
Destroying a path is simply a matter of freeing each segment in the
linked list.  Again, we let the experts handle text.
*/
void 
KillPath(struct segment *p)         /* path to destroy                       */
{
       register struct segment *linkp;  /* temp register holding next segment*/
 
       /* return conditional based on reference count 3-26-91 PNM */
       if ( (--(p->references) > 1) ||
          ( (p->references == 1) && !ISPERMANENT(p->flag) ) )
           return;
 
       while (p != NULL) {
               if (!ISPATHTYPE(p->type)) {
                       ArgErr("KillPath: bad segment", p, NULL);
                       return;
               }
               linkp = p->link;
               if (p->type == TEXTTYPE)
                       KillText(p);
               else
                       Free(p);
               p = linkp;
       }
}