Back to index

tetex-bin  3.0
paths.h
Go to the documentation of this file.
00001 /* $XConsortium: paths.h,v 1.2 91/10/10 11:18:50 rws Exp $ */
00002 /* Copyright International Business Machines, Corp. 1991
00003  * All Rights Reserved
00004  * Copyright Lexmark International, Inc. 1991
00005  * All Rights Reserved
00006  *
00007  * License to use, copy, modify, and distribute this software and its
00008  * documentation for any purpose and without fee is hereby granted,
00009  * provided that the above copyright notice appear in all copies and that
00010  * both that copyright notice and this permission notice appear in
00011  * supporting documentation, and that the name of IBM or Lexmark not be
00012  * used in advertising or publicity pertaining to distribution of the
00013  * software without specific, written prior permission.
00014  *
00015  * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
00016  * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
00018  * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE
00019  * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE
00021  * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
00022  * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL
00023  * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
00024  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00025  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00026  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
00027  * THIS SOFTWARE.
00028  */
00029 /*SHARED*/
00030 
00031 #include "types.h"
00032 
00033 #define   Loc(S,x,y)                   t1_Loc(S,(DOUBLE)x,(DOUBLE)y)
00034 #define   ILoc(S,x,y)                  t1_ILoc(S,x,y)
00035 #define   Line(P)                      t1_Line(P)
00036 #define   Join(p1,p2)                  t1_Join(p1,p2)
00037 #define   ClosePath(p)                 t1_ClosePath(p,0)
00038 #define   CloseLastSubPath(p)          t1_ClosePath(p,1)
00039 #define   Conic(B,C,s)                 t1_Conic(B,C,(DOUBLE)s)
00040 #define   RoundConic(M,C,r)            t1_RoundConic(M,C,(DOUBLE)r)
00041 #define   ArcP3(S,P2,P3)               t1_ArcP3(S,P2,P3)
00042 #define   ArcCA(S,C,d)                 t1_ArcCA(S,C,(DOUBLE)d)
00043 #define   Bezier(B,C,D)                t1_Bezier(B,C,D)
00044 #define   Hint(S,r,w,o,h,a,d,l)        t1_Hint(S,r,w,o,h,a,d,l)
00045 #define   Reverse(p)                   t1_Reverse(p)
00046 #define   ReverseSubPaths(p)           t1_ReverseSubPaths(p)
00047 #define   AddLoc(p1,p2)                t1_Join(p1,p2)
00048 #define   SubLoc(p1,p2)                t1_SubLoc(p1,p2)
00049 #define   DropSegment(p)               t1_DropSegment(p)
00050 #define   HeadSegment(p)               t1_HeadSegment(p)
00051 #define   QueryLoc(P,S,x,y)            t1_QueryLoc(P,S,x,y)
00052 #define   QueryPath(p,t,B,C,D,r)       t1_QueryPath(p,t,B,C,D,r)
00053 #define   QueryBounds(p,S,x1,y1,x2,y2)  t1_QueryBounds(p,S,x1,y1,x2,y2)
00054  
00055  
00056 struct segment *t1_Loc();     /* create a location object (or "move" segment) */
00057 struct segment *t1_ILoc();    /* integer argument version of same             */
00058 struct segment *t1_Line();    /* straight line path segment                   */
00059 struct segment *t1_Join();    /* join two paths or regions together           */
00060 struct segment *t1_ClosePath();  /* close a path or path set                  */
00061 struct conicsegment *t1_Conic();  /* conic curve path segment                 */
00062 struct conicsegment *t1_RoundConic();  /* ditto, specified another way        */
00063 struct conicsegment *t1_ArcP3(); /* circular path segment with three points   */
00064 struct conicsegment *t1_ArcCA(); /* ditto, with center point and angle        */
00065 struct beziersegment *t1_Bezier();  /* Bezier third order curve path segment  */
00066 struct hintsegment *t1_Hint();  /* produce a font 'hint' path segment         */
00067 struct segment *t1_Reverse(); /* reverse the complete order of paths          */
00068 struct segment *t1_ReverseSubPaths();  /* reverse only sub-paths; moves unchanged */
00069 struct segment *t1_SubLoc();  /* subtract two location objects                */
00070 struct segment *t1_DropSegment();  /* Drop the first segment in a path        */
00071 struct segment *t1_HeadSegment();  /* return the first segment in a path      */
00072 void t1_QueryLoc();           /* Query location; return its (x,y)             */
00073 void t1_QueryPath();          /* Query segment at head of a path              */
00074 void t1_QueryBounds();        /* Query the bounding box of a path             */
00075  
00076 /*END SHARED*/
00077 /*SHARED*/
00078  
00079 #define   CopyPath(p)             t1_CopyPath(p)
00080 #define   KillPath(p)             t1_KillPath(p)
00081 #define   PathTransform(p,m)      t1_PathXform(p,m)
00082 #define   PathDelta(p,pt)         t1_PathDelta(p,pt)
00083 #define   BoundingBox(h,w)        t1_BoundingBox(h,w)
00084 #define   PathSegment(t,x,y)      t1_PathSegment(t,(fractpel)x,(fractpel)y)
00085 #define   JoinSegment(b,t,x,y,a)  t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a)
00086 #define   Hypoteneuse(dx,dy)      t1_Hypoteneuse(dx,dy)
00087 #define   BoxPath(S,h,w)          t1_BoxPath(S,h,w)
00088  
00089 struct segment *t1_CopyPath(); /* duplicate a path                            */
00090 void t1_KillPath();           /* destroy a path                               */
00091 struct segment *t1_PathXform();  /* transform a path arbitrarily              */
00092 void t1_PathDelta();          /* calculate the ending point of a path         */
00093 struct segment *t1_PathSegment(); /* produce a MOVE or LINE segment           */
00094 struct segment *t1_JoinSegment(); /* join a MOVE or LINE segment to a path    */
00095 DOUBLE t1_Hypoteneuse();      /* returns the length of a line                 */
00096 struct segment *t1_BoxPath();   /* returns a rectangular path                 */
00097  
00098 /*END SHARED*/
00099 /*SHARED*/
00100  
00101 #define    ConsumePath(p)    MAKECONSUME(p,KillPath(p))
00102 #define    UniquePath(p)     MAKEUNIQUE(p,CopyPath(p))
00103  
00104 /*END SHARED*/
00105 /*SHARED*/
00106  
00107 struct segment {
00108        XOBJ_COMMON     /* xobject common data define 3-26-91 PNM             */
00109        unsigned char size;   /* size of the structure                        */
00110        unsigned char context;  /* index to device context                    */
00111        struct segment *link; /* pointer to next structure in linked list     */
00112        struct segment *last; /* pointer to last structure in list            */
00113        struct fractpoint dest; /* relative ending location of path segment   */
00114 } ;
00115  
00116 #define   ISCLOSED(flag)   ((flag)&0x80)  /* subpath is closed               */
00117 #define   LASTCLOSED(flag) ((flag)&0x40)  /* last segment in closed subpath  */
00118  
00119 /*
00120 NOTE: The ISCLOSED flag is set on the MOVETYPE segment before the
00121 subpath proper; the LASTCLOSED flag is set on the last segment (LINETYPE)
00122 in the subpath
00123  
00124 We define the ISPATHANCHOR predicate to test that a path handle
00125 passed by the user is valid:
00126 */
00127  
00128 #define   ISPATHANCHOR(p)  (ISPATHTYPE(p->type)&&p->last!=NULL)
00129  
00130 /*
00131 For performance reasons, a user's "location" object is identical to
00132 a path whose only segment is a move segment.  We define a predicate
00133 to test for this case.  See also :hdref refid=location..
00134 */
00135  
00136 #define   ISLOCATION(p)    ((p)->type == MOVETYPE && (p)->link == NULL)
00137  
00138 /*END SHARED*/
00139 /*SHARED*/
00140  
00141 struct conicsegment {
00142        XOBJ_COMMON          /* xobject common data define 3-26-91 PNM        */
00143                             /* type = CONICTYPE                             */
00144        unsigned char size;   /* as with any 'segment' type                   */
00145        unsigned char context;  /* as with any 'segment' type                 */
00146        struct segment *link; /* as with any 'segment' type                   */
00147        struct segment *last; /* as with any 'segment' type                   */
00148        struct fractpoint dest;  /* Ending point (C point)                    */
00149        struct fractpoint M;  /* "midpoint" of conic explained above          */
00150        float roundness;      /* explained above                              */
00151 } ;
00152 /*END SHARED*/
00153 /*SHARED*/
00154  
00155 struct beziersegment {
00156        XOBJ_COMMON           /* xobject common data define 3-26-91 PNM       */
00157                           /* type = BEZIERTYPE                       */
00158        unsigned char size;   /* as with any 'segment' type                   */
00159        unsigned char context;  /* as with any 'segment' type                 */
00160        struct segment *link; /* as with any 'segment' type                   */
00161        struct segment *last; /* as with any 'segment' type                   */
00162        struct fractpoint dest;  /* ending point (D)                          */
00163        struct fractpoint B;  /* control point B                              */
00164        struct fractpoint C;  /* control point C                              */
00165 } ;
00166  
00167 /*END SHARED*/
00168 /*SHARED*/
00169  
00170 struct hintsegment {
00171        XOBJ_COMMON            /* xobject common data define 3-26-91 PNM      */
00172                               /* type = HINTTYPE                    */
00173        unsigned char size;   /* size of the structure                        */
00174        unsigned char context;  /* device context                             */
00175        struct segment *link; /* pointer to next structure in linked list     */
00176        struct segment *last; /* pointer to last structure in list            */
00177        struct fractpoint dest; /* ALWAYS 0,0                                 */
00178        struct fractpoint ref;
00179        struct fractpoint width;
00180        char orientation;
00181        char hinttype;
00182        char adjusttype;
00183        char direction;
00184        int label;
00185 } ;
00186  
00187 /*END SHARED*/
00188 /*SHARED*/
00189  
00190 /*
00191 CONCAT links the 'p2' path chain on the end of the 'p1' chain.  (This macro
00192 is also used by the STROKES module.)
00193 */
00194 #define  CONCAT(p1, p2)  { \
00195        p1->last->link = p2;     /* link p2 on end of p1                      */ \
00196        p1->last = p2->last;    /* last of new is last of p2                  */ \
00197        p2->last = NULL; }    /* only first segment has non-NULL "last"       */
00198  
00199 /*END SHARED*/