1 /* This file is part of the GNU plotutils package.  Copyright (C) 1995,
2    1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
3 
4    The GNU plotutils package is free software.  You may redistribute it
5    and/or modify it under the terms of the GNU General Public License as
6    published by the Free Software foundation; either version 2, or (at your
7    option) any later version.
8 
9    The GNU plotutils package is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with the GNU plotutils package; see the file COPYING.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17    Boston, MA 02110-1301, USA. */
18 
19 /* Initialization for the first drawing state on the stack of drawing
20    states maintained by any Plotter.  Its components include drawing
21    attributes, and the state of any uncompleted path object.  (At
22    initialization, there is none.) */
23 
24 /* This is copied to the first state on the stack, in g_savestate.c.  The
25    four fields, `font_name', `font_type', `typeface_index', and
26    `font_index' are special: they are filled in at that time, since they
27    are Plotter-dependent.  So the values for them below (respectively
28    "HersheySerif", PL_F_HERSHEY, 0, and 1) are really dummies. */
29 
30 /* Two other fields (font size and line width in user coordinates) play an
31    important role at later times, e.g. a bad font size resets the font size
32    to the default.  For that reason, those variables are filled in when
33    space() or fsetmatrix() is called (see g_concat.c).  They are computed
34    using the two quantities PL_DEFAULT_FONT_SIZE_AS_FRACTION_OF_DISPLAY_SIZE
35    and PL_DEFAULT_LINE_WIDTH_AS_FRACTION_OF_DISPLAY_SIZE (defined in
36    extern.h). */
37 
38 #include "sys-defines.h"
39 #include "extern.h"
40 
41 /* save keystrokes */
42 #define DFSAFODS PL_DEFAULT_FONT_SIZE_AS_FRACTION_OF_DISPLAY_SIZE
43 #define DLWAFODS PL_DEFAULT_LINE_WIDTH_AS_FRACTION_OF_DISPLAY_SIZE
44 
45 const plDrawState _default_drawstate = {
46 
47 /***************** DEVICE-INDEPENDENT PART **************************/
48 
49 /* graphics cursor position */
50   {0.0, 0.0},			/* cursor position, in user coordinates */
51 
52 /* affine transformation from user coordinates to normalized device
53    coordinates, and affine transformation to actual device coordinates
54    (derived from it) */
55   {
56     {1.0, 0.0, 0.0, 1.0, 0.0, 0.0}, /* user->NDC transformation matrix */
57     {1.0, 0.0, 0.0, 1.0, 0.0, 0.0}, /* user->device transformation [dummy] */
58     true,			/* transf. scaling is uniform? [dummy] */
59     true,			/* transf. preserves axis dirs? [dummy] */
60     true			/* transf. doesn't reflect? [dummy] */
61   },
62 
63 /* the compound path being drawn, if any */
64   (plPath *)NULL,		/* simple path being drawn */
65   (plPath **)NULL,		/* previously drawn simple paths */
66   0,				/* number of previously drawn simple paths */
67   {0.0, 0.0},			/* starting point (used by closepath()) */
68 
69 /* modal drawing attributes */
70   /* 1. path-related attributes */
71   "even-odd",			/* fill mode ["even-odd" / "nonzero-winding"]*/
72   PL_FILL_ODD_WINDING,		/* fill type, one of PL_FILL_*, det'd by mode */
73   "solid",			/* line mode [must be valid] */
74   PL_L_SOLID,			/* line type, one of L_*, det'd by line mode */
75   true,				/* if not set, paths are "disconnected" */
76   "butt",			/* cap mode [must be valid] */
77   PL_CAP_BUTT,			/* cap type, one of PL_CAP_*, det'd by cap mode */
78   "miter",			/* join mode [must be valid] */
79   PL_JOIN_MITER,	        /* join type, one of PL_JOIN_*, det'd by mode */
80   PL_DEFAULT_MITER_LIMIT,		/* miter limit for line joins */
81   DLWAFODS,			/* line width in user coors [set by space()] */
82   true,				/* line width is (Plotter-specific) default? */
83   1.0,				/* line width in device coordinates ["] */
84   1,				/* line width, quantized to integer ["] */
85   (double *)NULL,		/* array of dash on/off lengths */
86   0,				/* length of same */
87   0.0,				/* offset distance into dash array (`phase') */
88   false,			/* dash array should override line mode? */
89   1,				/* pen type (0 = none, 1 = present) */
90   0,				/* fill type (0 = none, 1 = present,...) */
91   1,				/* orientation of circles etc.(1=c'clockwise)*/
92   /* 2. text-related attributes */
93   "HersheySerif",		/* font name [dummy, see g_openpl.c] */
94   DFSAFODS,			/* font size in user coordinates [dummy] */
95   true,				/* font size is (Plotter-specific) default? */
96   0.0,				/* degrees counterclockwise, for labels */
97   "HersheySerif",		/* true font name [dummy] */
98   0.0,				/* true font size in user coordinates (") */
99   0.0,				/* font ascent in user coordinates (") */
100   0.0,				/* font descent in user coordinates (") */
101   0.0,				/* font capital height in user coors (") */
102   PL_F_HERSHEY,			/* font type [dummy] */
103   0,				/* typeface index (in fontdb.h typeface table; this is Hershey Serif typeface) [dummy] */
104   1,				/* font index (within typeface; this is Roman variant of Hershey Serif typeface) [dummy] */
105   true,				/* true means an ISO-Latin-1 font ["] */
106   /* 3. color attributes (fgcolor and fillcolor are path-related; fgcolor
107      affects other primitives too) */
108   {0, 0, 0},			/* fg color, i.e., pen color (= black) */
109   {0, 0, 0},			/* base fill color (= black) */
110   {0, 0, 0},			/* true fill color (= black) */
111   {65535, 65535, 65535},	/* background color for display (= white) */
112   false,			/* no actual background color? */
113 
114 /* Default values for certain modal attributes, used when an out-of-range
115    value is requested. (These two are special because unlike all others,
116    they're set by the initial call to space() or fsetmatrix(), which also
117    sets the line width and font size fields above. Incidentally, space()
118    and setmatrix() also invoke linewidth().) */
119   0.0,				/* default line width in user coordinates */
120   0.0,				/* default font size in user coordinates */
121 
122 /****************** DEVICE-DEPENDENT PART ***************************/
123 
124 /* elements specific to the HP-GL drawing state [DUMMY] */
125   0.001,			/* pen width (frac of diag dist betw P1,P2) */
126 /* elements specific to the Fig drawing state [DUMMIES] */
127   16,				/* font size in fig's idea of points */
128   -1,				/* fig's fill level (-1 = transparent) */
129   FIG_C_BLACK,			/* fig's fg color (0=black) */
130   FIG_C_BLACK,			/* fig's fill color */
131 /* elements specific to the PS drawing state [DUMMIES] */
132   0.0,				/* RGB for PS fg color (floats) */
133   0.0,
134   0.0,
135   1.0,				/* RGB for PS fill color (floats) */
136   1.0,
137   1.0,
138   0,				/* idraw fg color (0=black, 9=white) */
139   9,				/* idraw bg color (0=black, 9=white) */
140   0,				/* shading (0=fg, 4=bg), if not transparent */
141 /* elements specific to the GIF drawing state [all save last 3 are DUMMIES] */
142   {0, 0, 0},			/* 24-bit RGB of pixel for drawing (= black) */
143   {0, 0, 0},			/* 24-bit RGB of pixel for filling (= black) */
144   {255, 255, 255},		/* 24-bit RGB of pixel for erasing (= white) */
145   (unsigned char)0,		/* drawing color index [dummy] */
146   (unsigned char)0,		/* filling color index [dummy] */
147   (unsigned char)0,		/* erasing color index [dummy] */
148   false,			/* drawing color index is genuine? */
149   false,			/* filling color index is genuine? */
150   false,			/* erasing color index is genuine? */
151 #ifndef X_DISPLAY_MISSING
152 /* elements spec. to X11, X11 Drawable drawingstates [nearly all: DUMMY] */
153   14,				/* font pixel size */
154   (XFontStruct *)NULL,		/* font structure (used in x_alab_X.c) */
155   (const unsigned char *)NULL,	/* label (hint to font retrieval routine) */
156   (GC)NULL,			/* graphics context, for drawing */
157   (GC)NULL,			/* graphics context, for filling */
158   (GC)NULL,			/* graphics context, for erasing */
159   {0, 0, 0},			/* pen color stored in GC (= black) */
160   {0, 0, 0},			/* fill color stored in GC (= black) */
161   {65535, 65535, 65535},	/* bg color stored in GC (= white) */
162   (unsigned long)0,		/* drawing pixel [dummy] */
163   (unsigned long)0,		/* filling pixel [dummy] */
164   (unsigned long)0,		/* erasing pixel [dummy] */
165   false,			/* drawing pixel is genuine? */
166   false,			/* filling pixel is genuine? */
167   false,			/* erasing pixel is genuine? */
168   LineSolid,			/* line style stored in drawing GC */
169   CapButt,			/* cap style stored in drawing GC */
170   JoinMiter,			/* join style stored in drawing GC */
171   0,				/* line width stored in drawing GC */
172   (char *)NULL,			/* dash list stored in drawing GC */
173   0,				/* length of dash list stored in drawing GC */
174   0,				/* offset into dash sequence, in drawing GC */
175   EvenOddRule,			/* fill rule stored in filling GC */
176 #endif /* X_DISPLAY_MISSING */
177 
178 /* pointer to previous drawing state */
179   (plDrawState *)NULL		/* pointer to previous state [must be null] */
180 };
181