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