PLplot
5.15.0
Toggle main menu visibility
Loading...
Searching...
No Matches
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
27
static
struct
line
28
{
29
PLINT
nels
;
30
PLINT
mark
[4];
31
PLINT
space
[4];
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
}
105
};
106
107
// Fill pattern defaults
108
109
#define NPATTERNS 8
110
static
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
}
188
};
189
190
// Set defining parameters for pattern fill
191
192
static
void
193
spat
(
const
PLINT
inc[],
const
PLINT
del[],
PLINT
nlin );
194
195
//--------------------------------------------------------------------------
196
// void plschr()
197
//
198
// Set character height.
199
//--------------------------------------------------------------------------
200
201
void
202
c_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 )
210
plP_state
(
PLSTATE_CHR
);
211
}
212
213
//--------------------------------------------------------------------------
214
// void plsmin()
215
//
216
// Set up lengths of minor tick marks.
217
//--------------------------------------------------------------------------
218
219
void
220
c_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
234
void
235
c_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
249
void
250
c_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 )
258
plP_state
(
PLSTATE_SYM
);
259
}
260
261
//--------------------------------------------------------------------------
262
// void pllsty()
263
//
264
// Set line style.
265
//--------------------------------------------------------------------------
266
267
void
268
c_pllsty
(
PLINT
lin )
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
292
void
293
c_plpat
(
PLINT
nlin,
PLINT_VECTOR
inc,
PLINT_VECTOR
del )
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
326
void
327
c_plpsty
(
PLINT
patt )
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
358
static
void
359
spat
(
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 )
371
plP_state
(
PLSTATE_FILL
);
372
}
plP_state
void plP_state(PLINT op)
Definition
plcore.c:256
plabort
void plabort(PLCHAR_VECTOR errormsg)
Definition
plctrl.c:1894
plplotP.h
PLSTATE_FILL
#define PLSTATE_FILL
Definition
plplotP.h:365
PLSTATE_CHR
#define PLSTATE_CHR
Definition
plplotP.h:368
PLSTATE_SYM
#define PLSTATE_SYM
Definition
plplotP.h:369
PLFLT
float PLFLT
Definition
plplot.h:163
PLINT_VECTOR
const PLINT * PLINT_VECTOR
Definition
plplot.h:241
plstyl
#define plstyl
Definition
plplot.h:846
PLINT
int PLINT
Definition
plplot.h:181
c_plsmin
void c_plsmin(PLFLT def, PLFLT scale)
Definition
plsdef.c:220
c_pllsty
void c_pllsty(PLINT lin)
Definition
plsdef.c:268
c_plssym
void c_plssym(PLFLT def, PLFLT scale)
Definition
plsdef.c:250
c_plpsty
void c_plpsty(PLINT patt)
Definition
plsdef.c:327
c_plpat
void c_plpat(PLINT nlin, PLINT_VECTOR inc, PLINT_VECTOR del)
Definition
plsdef.c:293
c_plschr
void c_plschr(PLFLT def, PLFLT scale)
Definition
plsdef.c:202
NPATTERNS
#define NPATTERNS
Definition
plsdef.c:109
spat
static void spat(const PLINT inc[], const PLINT del[], PLINT nlin)
Definition
plsdef.c:359
c_plsmaj
void c_plsmaj(PLFLT def, PLFLT scale)
Definition
plsdef.c:235
line
Definition
plsdef.c:28
line::nels
PLINT nels
Definition
plsdef.c:29
line::mark
PLINT mark[4]
Definition
plsdef.c:30
line::space
PLINT space[4]
Definition
plsdef.c:31
pattern
Definition
plsdef.c:111
pattern::nlines
PLINT nlines
Definition
plsdef.c:112
pattern::inc
PLINT inc[2]
Definition
plsdef.c:113
pattern::del
PLINT del[2]
Definition
plsdef.c:114
src
plsdef.c
Generated on
for PLplot by
1.17.0