PLplot 5.15.0
plsdef.c
Go to the documentation of this file.
1// Routines to set various plplot parameters, such as char height,
2// symbol size, tick length, line and fill patterns, etc.
3//
4// Copyright (C) 2004-2014 Alan W. Irwin
5//
6// This file is part of PLplot.
7//
8// PLplot is free software; you can redistribute it and/or modify
9// it under the terms of the GNU Library General Public License as published
10// by the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// PLplot is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public License
19// along with PLplot; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22
23#include "plplotP.h"
24
25// Line pattern defaults
26
27static struct line
28{
32} line[] = {
33 {
34 0, // Continuous line
35 {
36 0, 0, 0, 0
37 },
38 {
39 0, 0, 0, 0
40 }
41 },
42 {
43 1,
44 {
45 1000, 0, 0, 0
46 },
47 {
48 1000, 0, 0, 0
49 }
50 },
51 {
52 1,
53 {
54 2000, 0, 0, 0
55 },
56 {
57 2000, 0, 0, 0
58 }
59 },
60 {
61 1,
62 {
63 2000, 0, 0, 0
64 },
65 {
66 1000, 0, 0, 0
67 }
68 },
69 {
70 2,
71 {
72 2500, 1000, 0, 0
73 },
74 {
75 1000, 1000, 0, 0
76 }
77 },
78 {
79 2,
80 {
81 2000, 1000, 0, 0
82 },
83 {
84 2000, 1000, 0, 0
85 }
86 },
87 {
88 3,
89 {
90 1000, 1500, 2000, 0
91 },
92 {
93 1000, 1500, 2000, 0
94 }
95 },
96 {
97 3,
98 {
99 1000, 1500, 2000, 0
100 },
101 {
102 1000, 1000, 1000, 0
103 }
104 }
106
107// Fill pattern defaults
108
109#define NPATTERNS 8
110static struct pattern
111{
112 PLINT nlines; // Number of lines in pattern (1 or 2)
113 PLINT inc[2]; // Inclination 10 ths of degrees
114 PLINT del[2]; // Spacing for each line
115} pattern[] = {
116 {
117 1,
118 {
119 0, 0
120 },
121 {
122 2000, 0
123 }
124 },
125 {
126 1,
127 {
128 900, 0
129 },
130 {
131 2000, 0
132 }
133 },
134 {
135 1,
136 {
137 450, 0
138 },
139 {
140 2000, 0
141 }
142 },
143 {
144 1,
145 {
146 -450, 0
147 },
148 {
149 2000, 0
150 }
151 },
152 {
153 1,
154 {
155 300, 0
156 },
157 {
158 2000, 0
159 }
160 },
161 {
162 1,
163 {
164 -300, 0
165 },
166 {
167 2000, 0
168 }
169 },
170 {
171 2,
172 {
173 0, 900
174 },
175 {
176 2000, 2000
177 }
178 },
179 {
180 2,
181 {
182 450, -450
183 },
184 {
185 2000, 2000
186 }
187 }
189
190// Set defining parameters for pattern fill
191
192static void
193spat( const PLINT inc[], const PLINT del[], PLINT nlin );
194
195//--------------------------------------------------------------------------
196// void plschr()
197//
198// Set character height.
199//--------------------------------------------------------------------------
200
201void
202c_plschr( PLFLT def, PLFLT scale )
203{
204 if ( def != 0.0 )
205 plsc->chrdef = def;
206
207 plsc->chrht = scale * plsc->chrdef;
208
209 if ( plsc->level > 0 )
211}
212
213//--------------------------------------------------------------------------
214// void plsmin()
215//
216// Set up lengths of minor tick marks.
217//--------------------------------------------------------------------------
218
219void
220c_plsmin( PLFLT def, PLFLT scale )
221{
222 if ( def != 0.0 )
223 plsc->mindef = def;
224
225 plsc->minht = scale * plsc->mindef;
226}
227
228//--------------------------------------------------------------------------
229// void plsmaj()
230//
231// Set up lengths of major tick marks.
232//--------------------------------------------------------------------------
233
234void
235c_plsmaj( PLFLT def, PLFLT scale )
236{
237 if ( def != 0.0 )
238 plsc->majdef = def;
239
240 plsc->majht = scale * plsc->majdef;
241}
242
243//--------------------------------------------------------------------------
244// void plssym()
245//
246// Set symbol height.
247//--------------------------------------------------------------------------
248
249void
250c_plssym( PLFLT def, PLFLT scale )
251{
252 if ( def != 0.0 )
253 plsc->symdef = def;
254
255 plsc->symht = scale * plsc->symdef;
256
257 if ( plsc->level > 0 )
259}
260
261//--------------------------------------------------------------------------
262// void pllsty()
263//
264// Set line style.
265//--------------------------------------------------------------------------
266
267void
269{
270 if ( plsc->level < 1 )
271 {
272 plabort( "pllsty: Please call plinit first" );
273 return;
274 }
275 if ( lin < 1 || lin > 8 )
276 {
277 plabort( "pllsty: Invalid line style" );
278 return;
279 }
280
281 plsc->line_style = lin;
282 plstyl( line[lin - 1].nels,
283 &line[lin - 1].mark[0], &line[lin - 1].space[0] );
284}
285
286//--------------------------------------------------------------------------
287// void plpat()
288//
289// Set fill pattern directly.
290//--------------------------------------------------------------------------
291
292void
294{
295 PLINT i;
296
297 if ( plsc->level < 1 )
298 {
299 plabort( "plpat: Please call plinit first" );
300 return;
301 }
302 if ( nlin < 1 || nlin > 2 )
303 {
304 plabort( "plpat: Only 1 or 2 line styles allowed" );
305 return;
306 }
307 for ( i = 0; i < nlin; i++ )
308 {
309 if ( del[i] < 0 )
310 {
311 plabort( "plpat: Line spacing must be greater than 0" );
312 return;
313 }
314 }
315 plsc->patt = NPATTERNS;
316 spat( inc, del, nlin );
317}
318
319//--------------------------------------------------------------------------
320// void plpsty()
321//
322// Set fill pattern, using one of the predefined patterns.
323// A fill pattern <= 0 indicates hardware fill.
324//--------------------------------------------------------------------------
325
326void
328{
329 if ( plsc->level < 1 )
330 {
331 plabort( "plpsty: Please call plinit first" );
332 return;
333 }
334 if ( patt > NPATTERNS || patt < 0 )
335 {
336 plabort( "plpsty: Invalid pattern" );
337 return;
338 }
339 if ( patt != plsc->patt )
340 {
341 plsc->patt = patt;
342 }
343 if ( patt > 0 )
344 {
345 spat( &pattern[patt - 1].inc[0], &pattern[patt - 1].del[0],
346 pattern[patt - 1].nlines );
347 }
348 else
349 spat( NULL, NULL, 0 );
350}
351
352//--------------------------------------------------------------------------
353// void spat()
354//
355// Set defining parameters for pattern fill
356//--------------------------------------------------------------------------
357
358static void
359spat( const PLINT inc[], const PLINT del[], PLINT nlin )
360{
361 PLINT i;
362
363 plsc->nps = nlin;
364 for ( i = 0; i < nlin; i++ )
365 {
366 plsc->inclin[i] = inc[i];
367 plsc->delta[i] = del[i];
368 }
369
370 if ( plsc->level > 0 )
372}
void plP_state(PLINT op)
Definition: plcore.c:256
void plabort(PLCHAR_VECTOR errormsg)
Definition: plctrl.c:1894
#define PLSTATE_FILL
Definition: plplotP.h:365
#define PLSTATE_CHR
Definition: plplotP.h:368
#define PLSTATE_SYM
Definition: plplotP.h:369
float PLFLT
Definition: plplot.h:163
const PLINT * PLINT_VECTOR
Definition: plplot.h:241
#define plstyl
Definition: plplot.h:846
int PLINT
Definition: plplot.h:181
void c_plsmin(PLFLT def, PLFLT scale)
Definition: plsdef.c:220
void c_pllsty(PLINT lin)
Definition: plsdef.c:268
void c_plssym(PLFLT def, PLFLT scale)
Definition: plsdef.c:250
void c_plpsty(PLINT patt)
Definition: plsdef.c:327
void c_plpat(PLINT nlin, PLINT_VECTOR inc, PLINT_VECTOR del)
Definition: plsdef.c:293
void c_plschr(PLFLT def, PLFLT scale)
Definition: plsdef.c:202
#define NPATTERNS
Definition: plsdef.c:109
static void spat(const PLINT inc[], const PLINT del[], PLINT nlin)
Definition: plsdef.c:359
void c_plsmaj(PLFLT def, PLFLT scale)
Definition: plsdef.c:235
Definition: plsdef.c:28
PLINT nels
Definition: plsdef.c:29
PLINT mark[4]
Definition: plsdef.c:30
PLINT space[4]
Definition: plsdef.c:31
PLINT nlines
Definition: plsdef.c:112
PLINT inc[2]
Definition: plsdef.c:113
PLINT del[2]
Definition: plsdef.c:114