-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathset.c
More file actions
6603 lines (6047 loc) · 174 KB
/
set.c
File metadata and controls
6603 lines (6047 loc) · 174 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef lint
static char *RCSid() { return RCSid("$Id: set.c,v 1.571 2017-09-29 19:23:37 sfeam Exp $"); }
#endif
/* GNUPLOT - set.c */
/*[
* Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the complete modified source code. Modifications are to
* be distributed as patches to the released version. Permission to
* distribute binaries produced by compiling modified sources is granted,
* provided you
* 1. distribute the corresponding source modifications from the
* released version in the form of a patch file along with the binaries,
* 2. add special version identification to distinguish your version
* in addition to the base release version number,
* 3. provide your name and address as the primary contact for the
* support of your modified version, and
* 4. retain our contact information in regard to use of the base
* software.
* Permission to distribute the released version of the source code along
* with corresponding source modifications in the form of a patch file is
* granted with same provisions 2 through 4 for binary distributions.
*
* This software is provided "as is" without express or implied warranty
* to the extent permitted by applicable law.
]*/
/*
* 19 September 1992 Lawrence Crowl ([email protected])
* Added user-specified bases for log scaling.
*/
#include "setshow.h"
#include "alloc.h"
#include "axis.h"
#include "command.h"
#include "contour.h"
#include "datafile.h"
#include "datablock.h"
#include "fit.h"
#include "gp_hist.h"
#include "gp_time.h"
#include "hidden3d.h"
#include "jitter.h"
#include "misc.h"
#include "plot.h"
#include "plot2d.h"
#include "plot3d.h"
#include "tables.h"
#include "tabulate.h"
#include "term_api.h"
#include "util.h"
#include "variable.h"
#include "pm3d.h"
#include "getcolor.h"
#include <ctype.h>
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
static palette_color_mode pm3d_last_set_palette_mode = SMPAL_COLOR_MODE_NONE;
static void set_angles __PROTO((void));
static void set_arrow __PROTO((void));
static int assign_arrow_tag __PROTO((void));
static void set_autoscale __PROTO((void));
static void set_bars __PROTO((void));
static void set_border __PROTO((void));
static void set_boxplot __PROTO((void));
static void set_boxwidth __PROTO((void));
static void set_clabel __PROTO((void));
static void set_clip __PROTO((void));
static void set_cntrparam __PROTO((void));
static void set_cntrlabel __PROTO((void));
static void set_contour __PROTO((void));
static void set_dashtype __PROTO((void));
static void set_dgrid3d __PROTO((void));
static void set_decimalsign __PROTO((void));
static void set_degreesign __PROTO((char *));
static void set_dummy __PROTO((void));
static void set_encoding __PROTO((void));
static void set_fit __PROTO((void));
static void set_grid __PROTO((void));
static void set_hidden3d __PROTO((void));
static void set_history __PROTO((void));
static void set_isosamples __PROTO((void));
static void set_key __PROTO((void));
static void set_label __PROTO((void));
static int assign_label_tag __PROTO((void));
static void set_loadpath __PROTO((void));
static void set_fontpath __PROTO((void));
static void set_locale __PROTO((void));
static void set_logscale __PROTO((void));
static void set_mapping __PROTO((void));
static void set_margin __PROTO((t_position *));
static void set_minus_sign __PROTO((void));
static void set_micro __PROTO((void));
static void set_missing __PROTO((void));
static void set_separator __PROTO((char **));
static void set_datafile_commentschars __PROTO((void));
static void set_monochrome __PROTO((void));
#ifdef USE_MOUSE
static void set_mouse __PROTO((void));
#endif
static void set_offsets __PROTO((void));
static void set_origin __PROTO((void));
static void set_output __PROTO((void));
static void set_parametric __PROTO((void));
static void set_pm3d __PROTO((void));
static void set_palette __PROTO((void));
static void set_colorbox __PROTO((void));
static void set_pointsize __PROTO((void));
static void set_pointintervalbox __PROTO((void));
static void set_polar __PROTO((void));
static void set_print __PROTO((void));
#ifdef EAM_OBJECTS
static void set_object __PROTO((void));
static void set_obj __PROTO((int, int));
#endif
static void set_psdir __PROTO((void));
static void set_rgbmax __PROTO((void));
static void set_samples __PROTO((void));
static void set_size __PROTO((void));
static void set_style __PROTO((void));
static void set_surface __PROTO((void));
static void set_table __PROTO((void));
static void set_terminal __PROTO((void));
static void set_termoptions __PROTO((void));
static void set_theta __PROTO((void));
static void set_tics __PROTO((void));
static void set_ticscale __PROTO((void));
static void set_timefmt __PROTO((void));
static void set_timestamp __PROTO((void));
static void set_view __PROTO((void));
static void set_zero __PROTO((void));
static void set_timedata __PROTO((struct axis *));
static void set_range __PROTO((struct axis *));
static void set_paxis __PROTO((void));
static void set_raxis __PROTO((void));
static void set_xyplane __PROTO((void));
static void set_ticslevel __PROTO((void));
static void set_zeroaxis __PROTO((AXIS_INDEX));
static void set_allzeroaxis __PROTO((void));
/******** Local functions ********/
static void set_xyzlabel __PROTO((text_label * label));
static void load_tics __PROTO((struct axis * axis));
static void load_tic_user __PROTO((struct axis * axis));
static void load_tic_series __PROTO((struct axis * axis));
static void set_linestyle __PROTO((struct linestyle_def **head, lp_class destination_class));
static void set_arrowstyle __PROTO((void));
static int assign_arrowstyle_tag __PROTO((void));
static int set_tic_prop __PROTO((struct axis *));
static void set_mttics __PROTO((struct axis *this_axis));
static void check_palette_grayscale __PROTO((void));
static int set_palette_defined __PROTO((void));
static void set_palette_file __PROTO((void));
static void set_palette_function __PROTO((void));
static void parse_histogramstyle __PROTO((histogram_style *hs,
t_histogram_type def_type, int def_gap));
static void set_style_parallel __PROTO((void));
static void parse_lighting_options __PROTO((void));
static const char *encoding_micro __PROTO((void));
static const char *encoding_minus __PROTO((void));
static const struct position default_position
= {first_axes, first_axes, first_axes, 0., 0., 0.};
static const struct position default_offset
= {character, character, character, 0., 0., 0.};
static lp_style_type default_hypertext_point_style
= {1, LT_BLACK, 4, DASHTYPE_SOLID, 0, 0, 1.0, PTSZ_DEFAULT, DEFAULT_P_CHAR, {TC_RGB, 0x000000, 0.0}, DEFAULT_DASHPATTERN};
/******** The 'set' command ********/
void
set_command()
{
c_token++;
/* Mild form of backwards compatibility */
/* Allow "set no{foo}" rather than "unset foo" */
if (gp_input_line[token[c_token].start_index] == 'n' &&
gp_input_line[token[c_token].start_index+1] == 'o' &&
gp_input_line[token[c_token].start_index+2] != 'n') {
if (interactive)
int_warn(c_token, "deprecated syntax, use \"unset\"");
token[c_token].start_index += 2;
token[c_token].length -= 2;
c_token--;
unset_command();
} else {
int save_token = c_token;
set_iterator = check_for_iteration();
if (empty_iteration(set_iterator)) {
/* Skip iteration [i=start:end] where start > end */
while (!END_OF_COMMAND) c_token++;
set_iterator = cleanup_iteration(set_iterator);
return;
}
if (forever_iteration(set_iterator)) {
set_iterator = cleanup_iteration(set_iterator);
int_error(save_token, "unbounded iteration");
}
save_token = c_token;
ITERATE:
switch(lookup_table(&set_tbl[0],c_token)) {
case S_ANGLES:
set_angles();
break;
case S_ARROW:
set_arrow();
break;
case S_AUTOSCALE:
set_autoscale();
break;
case S_BARS:
set_bars();
break;
case S_BORDER:
set_border();
break;
case S_BOXWIDTH:
set_boxwidth();
break;
case S_CLABEL:
set_clabel();
break;
case S_CLIP:
set_clip();
break;
case S_COLOR:
unset_monochrome();
c_token++;
break;
case S_COLORSEQUENCE:
set_colorsequence(0);
break;
case S_CNTRPARAM:
set_cntrparam();
break;
case S_CNTRLABEL:
set_cntrlabel();
break;
case S_CONTOUR:
set_contour();
break;
case S_DASHTYPE:
set_dashtype();
break;
case S_DGRID3D:
set_dgrid3d();
break;
case S_DEBUG:
/* Developer-only option (not in user documentation) */
/* Does nothing in normal use */
c_token++;
debug = int_expression();
break;
case S_DECIMALSIGN:
set_decimalsign();
break;
case S_DUMMY:
set_dummy();
break;
case S_ENCODING:
set_encoding();
break;
case S_FIT:
set_fit();
break;
case S_FONTPATH:
set_fontpath();
break;
case S_FORMAT:
set_format();
break;
case S_GRID:
set_grid();
break;
case S_HIDDEN3D:
set_hidden3d();
break;
case S_HISTORYSIZE: /* Deprecated in favor of "set history size" */
case S_HISTORY:
set_history();
break;
case S_ISOSAMPLES:
set_isosamples();
break;
case S_JITTER:
set_jitter();
break;
case S_KEY:
set_key();
break;
case S_LINESTYLE:
set_linestyle(&first_linestyle, LP_STYLE);
break;
case S_LINETYPE:
if (equals(c_token+1,"cycle")) {
c_token += 2;
linetype_recycle_count = int_expression();
} else
set_linestyle(&first_perm_linestyle, LP_TYPE);
break;
case S_LABEL:
set_label();
break;
case S_LINK:
case S_NONLINEAR:
link_command();
break;
case S_LOADPATH:
set_loadpath();
break;
case S_LOCALE:
set_locale();
break;
case S_LOGSCALE:
set_logscale();
break;
case S_MACROS:
/* Aug 2013 - macros are always enabled */
c_token++;
break;
case S_MAPPING:
set_mapping();
break;
case S_MARGIN:
/* Jan 2015: CHANGE to order <left>,<right>,<bottom>,<top> */
set_margin(&lmargin);
if (!equals(c_token,","))
break;
set_margin(&rmargin);
if (!equals(c_token,","))
break;
set_margin(&bmargin);
if (!equals(c_token,","))
break;
set_margin(&tmargin);
break;
case S_BMARGIN:
set_margin(&bmargin);
break;
case S_LMARGIN:
set_margin(&lmargin);
break;
case S_RMARGIN:
set_margin(&rmargin);
break;
case S_TMARGIN:
set_margin(&tmargin);
break;
case S_MICRO:
set_micro();
break;
case S_MINUS_SIGN:
set_minus_sign();
break;
case S_DATAFILE:
if (almost_equals(++c_token,"miss$ing"))
set_missing();
else if (almost_equals(c_token,"sep$arators"))
set_separator(&df_separators);
else if (almost_equals(c_token,"com$mentschars"))
set_datafile_commentschars();
else if (almost_equals(c_token,"bin$ary"))
df_set_datafile_binary();
else if (almost_equals(c_token,"fort$ran")) {
df_fortran_constants = TRUE;
c_token++;
} else if (almost_equals(c_token,"nofort$ran")) {
df_fortran_constants = FALSE;
c_token++;
} else if (almost_equals(c_token,"fpe_trap")) {
df_nofpe_trap = FALSE;
c_token++;
} else if (almost_equals(c_token,"nofpe_trap")) {
df_nofpe_trap = TRUE;
c_token++;
} else
int_error(c_token,"expecting datafile modifier");
break;
#ifdef USE_MOUSE
case S_MOUSE:
set_mouse();
break;
#endif
case S_MONOCHROME:
set_monochrome();
break;
case S_MULTIPLOT:
term_start_multiplot();
break;
case S_OFFSETS:
set_offsets();
break;
case S_ORIGIN:
set_origin();
break;
case SET_OUTPUT:
set_output();
break;
case S_PARAMETRIC:
set_parametric();
break;
case S_PM3D:
set_pm3d();
break;
case S_PALETTE:
set_palette();
break;
case S_COLORBOX:
set_colorbox();
break;
case S_POINTINTERVALBOX:
set_pointintervalbox();
break;
case S_POINTSIZE:
set_pointsize();
break;
case S_POLAR:
set_polar();
break;
case S_PRINT:
set_print();
break;
case S_PSDIR:
set_psdir();
break;
#ifdef EAM_OBJECTS
case S_OBJECT:
set_object();
break;
#endif
case S_SAMPLES:
set_samples();
break;
case S_RGBMAX:
set_rgbmax();
break;
case S_SIZE:
set_size();
break;
case S_STYLE:
set_style();
break;
case S_SURFACE:
set_surface();
break;
case S_TABLE:
set_table();
break;
case S_TERMINAL:
set_terminal();
break;
case S_TERMOPTIONS:
set_termoptions();
break;
case S_THETA:
set_theta();
break;
case S_TICS:
set_tics();
break;
case S_TICSCALE:
set_ticscale();
break;
case S_TIMEFMT:
set_timefmt();
break;
case S_TIMESTAMP:
set_timestamp();
break;
case S_TITLE:
set_xyzlabel(&title);
title.rotate = 0.0;
break;
case S_VIEW:
set_view();
break;
case S_ZERO:
set_zero();
break;
case S_MXTICS:
case S_NOMXTICS:
case S_XTICS:
case S_NOXTICS:
case S_XDTICS:
case S_NOXDTICS:
case S_XMTICS:
case S_NOXMTICS:
set_tic_prop(&axis_array[FIRST_X_AXIS]);
break;
case S_MYTICS:
case S_NOMYTICS:
case S_YTICS:
case S_NOYTICS:
case S_YDTICS:
case S_NOYDTICS:
case S_YMTICS:
case S_NOYMTICS:
set_tic_prop(&axis_array[FIRST_Y_AXIS]);
break;
case S_MX2TICS:
case S_NOMX2TICS:
case S_X2TICS:
case S_NOX2TICS:
case S_X2DTICS:
case S_NOX2DTICS:
case S_X2MTICS:
case S_NOX2MTICS:
set_tic_prop(&axis_array[SECOND_X_AXIS]);
break;
case S_MY2TICS:
case S_NOMY2TICS:
case S_Y2TICS:
case S_NOY2TICS:
case S_Y2DTICS:
case S_NOY2DTICS:
case S_Y2MTICS:
case S_NOY2MTICS:
set_tic_prop(&axis_array[SECOND_Y_AXIS]);
break;
case S_MZTICS:
case S_NOMZTICS:
case S_ZTICS:
case S_NOZTICS:
case S_ZDTICS:
case S_NOZDTICS:
case S_ZMTICS:
case S_NOZMTICS:
set_tic_prop(&axis_array[FIRST_Z_AXIS]);
break;
case S_MCBTICS:
case S_NOMCBTICS:
case S_CBTICS:
case S_NOCBTICS:
case S_CBDTICS:
case S_NOCBDTICS:
case S_CBMTICS:
case S_NOCBMTICS:
set_tic_prop(&axis_array[COLOR_AXIS]);
break;
case S_RTICS:
case S_MRTICS:
set_tic_prop(&axis_array[POLAR_AXIS]);
break;
case S_TTICS:
set_tic_prop(&THETA_AXIS);
break;
case S_MTTICS:
set_mttics(&THETA_AXIS);
break;
case S_XDATA:
set_timedata(&axis_array[FIRST_X_AXIS]);
axis_array[T_AXIS].datatype
= axis_array[U_AXIS].datatype
= axis_array[FIRST_X_AXIS].datatype;
break;
case S_YDATA:
set_timedata(&axis_array[FIRST_Y_AXIS]);
axis_array[V_AXIS].datatype
= axis_array[FIRST_X_AXIS].datatype;
break;
case S_ZDATA:
set_timedata(&axis_array[FIRST_Z_AXIS]);
break;
case S_CBDATA:
set_timedata(&axis_array[COLOR_AXIS]);
break;
case S_X2DATA:
set_timedata(&axis_array[SECOND_X_AXIS]);
break;
case S_Y2DATA:
set_timedata(&axis_array[SECOND_Y_AXIS]);
break;
case S_XLABEL:
set_xyzlabel(&axis_array[FIRST_X_AXIS].label);
break;
case S_YLABEL:
set_xyzlabel(&axis_array[FIRST_Y_AXIS].label);
break;
case S_ZLABEL:
set_xyzlabel(&axis_array[FIRST_Z_AXIS].label);
break;
case S_CBLABEL:
set_xyzlabel(&axis_array[COLOR_AXIS].label);
break;
case S_RLABEL:
set_xyzlabel(&axis_array[POLAR_AXIS].label);
break;
case S_X2LABEL:
set_xyzlabel(&axis_array[SECOND_X_AXIS].label);
break;
case S_Y2LABEL:
set_xyzlabel(&axis_array[SECOND_Y_AXIS].label);
break;
case S_XRANGE:
set_range(&axis_array[FIRST_X_AXIS]);
break;
case S_X2RANGE:
set_range(&axis_array[SECOND_X_AXIS]);
break;
case S_YRANGE:
set_range(&axis_array[FIRST_Y_AXIS]);
break;
case S_Y2RANGE:
set_range(&axis_array[SECOND_Y_AXIS]);
break;
case S_ZRANGE:
set_range(&axis_array[FIRST_Z_AXIS]);
break;
case S_CBRANGE:
set_range(&axis_array[COLOR_AXIS]);
break;
case S_RRANGE:
set_range(&axis_array[POLAR_AXIS]);
if (polar)
rrange_to_xy();
break;
case S_TRANGE:
set_range(&axis_array[T_AXIS]);
break;
case S_URANGE:
set_range(&axis_array[U_AXIS]);
break;
case S_VRANGE:
set_range(&axis_array[V_AXIS]);
break;
case S_PAXIS:
set_paxis();
break;
case S_RAXIS:
set_raxis();
break;
case S_XZEROAXIS:
set_zeroaxis(FIRST_X_AXIS);
break;
case S_YZEROAXIS:
set_zeroaxis(FIRST_Y_AXIS);
break;
case S_ZZEROAXIS:
set_zeroaxis(FIRST_Z_AXIS);
break;
case S_X2ZEROAXIS:
set_zeroaxis(SECOND_X_AXIS);
break;
case S_Y2ZEROAXIS:
set_zeroaxis(SECOND_Y_AXIS);
break;
case S_ZEROAXIS:
set_allzeroaxis();
break;
case S_XYPLANE:
set_xyplane();
break;
case S_TICSLEVEL:
set_ticslevel();
break;
default:
int_error(c_token, "unrecognized option - see 'help set'.");
break;
}
if (next_iteration(set_iterator)) {
c_token = save_token;
goto ITERATE;
}
}
update_gpval_variables(0);
set_iterator = cleanup_iteration(set_iterator);
}
/* process 'set angles' command */
static void
set_angles()
{
c_token++;
if (END_OF_COMMAND) {
/* assuming same as defaults */
ang2rad = 1;
} else if (almost_equals(c_token, "r$adians")) {
c_token++;
ang2rad = 1;
} else if (almost_equals(c_token, "d$egrees")) {
c_token++;
ang2rad = DEG2RAD;
} else
int_error(c_token, "expecting 'radians' or 'degrees'");
if (polar && axis_array[T_AXIS].set_autoscale) {
/* set trange if in polar mode and no explicit range */
axis_array[T_AXIS].set_min = 0;
axis_array[T_AXIS].set_max = 2 * M_PI / ang2rad;
}
}
/* process a 'set arrow' command */
/* set arrow {tag} {from x,y} {to x,y} {{no}head} ... */
/* allow any order of options - pm 25.11.2001 */
static void
set_arrow()
{
struct arrow_def *this_arrow = NULL;
struct arrow_def *new_arrow = NULL;
struct arrow_def *prev_arrow = NULL;
TBOOLEAN duplication = FALSE;
TBOOLEAN set_start = FALSE;
TBOOLEAN set_end = FALSE;
int save_token;
int tag;
c_token++;
/* get tag */
if (almost_equals(c_token, "back$head") || equals(c_token, "front")
|| equals(c_token, "from") || equals(c_token, "at")
|| equals(c_token, "to") || equals(c_token, "rto")
|| equals(c_token, "size")
|| equals(c_token, "filled") || equals(c_token, "empty")
|| equals(c_token, "as") || equals(c_token, "arrowstyle")
|| almost_equals(c_token, "head$s") || equals(c_token, "nohead")
|| almost_equals(c_token, "nobo$rder")) {
tag = assign_arrow_tag();
} else
tag = int_expression();
if (tag <= 0)
int_error(c_token, "tag must be > 0");
/* OK! add arrow */
if (first_arrow != NULL) { /* skip to last arrow */
for (this_arrow = first_arrow; this_arrow != NULL;
prev_arrow = this_arrow, this_arrow = this_arrow->next)
/* is this the arrow we want? */
if (tag <= this_arrow->tag)
break;
}
if (this_arrow == NULL || tag != this_arrow->tag) {
new_arrow = gp_alloc(sizeof(struct arrow_def), "arrow");
if (prev_arrow == NULL)
first_arrow = new_arrow;
else
prev_arrow->next = new_arrow;
new_arrow->tag = tag;
new_arrow->next = this_arrow;
this_arrow = new_arrow;
this_arrow->start = default_position;
this_arrow->end = default_position;
this_arrow->angle = 0.0;
this_arrow->type = arrow_end_undefined;
default_arrow_style(&(new_arrow->arrow_properties));
}
while (!END_OF_COMMAND) {
/* get start position */
if (equals(c_token, "from") || equals(c_token,"at")) {
if (set_start) { duplication = TRUE; break; }
c_token++;
if (END_OF_COMMAND)
int_error(c_token, "start coordinates expected");
/* get coordinates */
get_position(&this_arrow->start);
set_start = TRUE;
continue;
}
/* get end or relative end position */
if (equals(c_token, "to") || equals(c_token,"rto")) {
if (set_end) { duplication = TRUE; break; }
if (equals(c_token,"rto"))
this_arrow->type = arrow_end_relative;
else
this_arrow->type = arrow_end_absolute;
c_token++;
if (END_OF_COMMAND)
int_error(c_token, "end coordinates expected");
/* get coordinates */
get_position(&this_arrow->end);
set_end = TRUE;
continue;
}
/* get end position specified as length + orientation angle */
if (almost_equals(c_token, "len$gth")) {
if (set_end) { duplication = TRUE; break; }
this_arrow->type = arrow_end_oriented;
c_token++;
get_position_default(&this_arrow->end, first_axes, 1);
set_end = TRUE;
continue;
}
if (almost_equals(c_token,"ang$le")) {
c_token++;
this_arrow->angle = real_expression();
continue;
}
/* Allow interspersed style commands */
save_token = c_token;
arrow_parse(&this_arrow->arrow_properties, TRUE);
if (save_token != c_token)
continue;
if (!END_OF_COMMAND)
int_error(c_token, "wrong argument in set arrow");
} /* while (!END_OF_COMMAND) */
if (duplication)
int_error(c_token, "duplicate or contradictory arguments");
}
/* assign a new arrow tag
* arrows are kept sorted by tag number, so this is easy
* returns the lowest unassigned tag number
*/
static int
assign_arrow_tag()
{
struct arrow_def *this_arrow;
int last = 0; /* previous tag value */
for (this_arrow = first_arrow; this_arrow != NULL;
this_arrow = this_arrow->next)
if (this_arrow->tag == last + 1)
last++;
else
break;
return (last + 1);
}
/* helper routine for 'set autoscale' on a single axis */
static TBOOLEAN
set_autoscale_axis(struct axis *this)
{
char keyword[16];
char *name = (char *) &(axis_name(this->index)[0]);
if (equals(c_token, name)) {
this->set_autoscale = AUTOSCALE_BOTH;
this->min_constraint = CONSTRAINT_NONE;
this->max_constraint = CONSTRAINT_NONE;
++c_token;
return TRUE;
}
sprintf(keyword, "%smi$n", name);
if (almost_equals(c_token, keyword)) {
this->set_autoscale |= AUTOSCALE_MIN;
this->min_constraint = CONSTRAINT_NONE;
++c_token;
return TRUE;
}
sprintf(keyword, "%sma$x", name);
if (almost_equals(c_token, keyword)) {
this->set_autoscale |= AUTOSCALE_MAX;
this->max_constraint = CONSTRAINT_NONE;
++c_token;
return TRUE;
}
sprintf(keyword, "%sfix", name);
if (equals(c_token, keyword)) {
this->set_autoscale |= AUTOSCALE_FIXMIN | AUTOSCALE_FIXMAX;
++c_token;
return TRUE;
}
sprintf(keyword, "%sfixmi$n", name);
if (almost_equals(c_token, keyword)) {
this->set_autoscale |= AUTOSCALE_FIXMIN;
++c_token;
return TRUE;
}
sprintf(keyword, "%sfixma$x", name);
if (almost_equals(c_token, keyword)) {
this->set_autoscale |= AUTOSCALE_FIXMAX;
++c_token;
return TRUE;
}
return FALSE;
}
/* process 'set autoscale' command */
static void
set_autoscale()
{
int axis;
c_token++;
if (END_OF_COMMAND) {
for (axis=0; axis<AXIS_ARRAY_SIZE; axis++)
axis_array[axis].set_autoscale = AUTOSCALE_BOTH;
for (axis=0; axis<num_parallel_axes; axis++)
parallel_axis[axis].set_autoscale = AUTOSCALE_BOTH;
return;
} else if (equals(c_token, "xy") || equals(c_token, "yx")) {
axis_array[FIRST_X_AXIS].set_autoscale =
axis_array[FIRST_Y_AXIS].set_autoscale = AUTOSCALE_BOTH;
axis_array[FIRST_X_AXIS].min_constraint =
axis_array[FIRST_X_AXIS].max_constraint =
axis_array[FIRST_Y_AXIS].min_constraint =
axis_array[FIRST_Y_AXIS].max_constraint = CONSTRAINT_NONE;
c_token++;
return;
} else if (equals(c_token, "fix") || almost_equals(c_token, "noext$end")) {
for (axis=0; axis<AXIS_ARRAY_SIZE; axis++)
axis_array[axis].set_autoscale |= AUTOSCALE_FIXMIN | AUTOSCALE_FIXMAX;
for (axis=0; axis<num_parallel_axes; axis++)
parallel_axis[axis].set_autoscale |= AUTOSCALE_FIXMIN | AUTOSCALE_FIXMAX;
c_token++;
return;
} else if (almost_equals(c_token, "ke$epfix")) {
for (axis=0; axis<AXIS_ARRAY_SIZE; axis++)
axis_array[axis].set_autoscale |= AUTOSCALE_BOTH;
for (axis=0; axis<num_parallel_axes; axis++)
parallel_axis[axis].set_autoscale |= AUTOSCALE_BOTH;
c_token++;
return;
}
if (set_autoscale_axis(&axis_array[FIRST_X_AXIS])) return;
if (set_autoscale_axis(&axis_array[FIRST_Y_AXIS])) return;
if (set_autoscale_axis(&axis_array[FIRST_Z_AXIS])) return;
if (set_autoscale_axis(&axis_array[SECOND_X_AXIS])) return;
if (set_autoscale_axis(&axis_array[SECOND_Y_AXIS])) return;
if (set_autoscale_axis(&axis_array[COLOR_AXIS])) return;
if (set_autoscale_axis(&axis_array[POLAR_AXIS])) return;
/* FIXME: Do these commands make any sense? */
if (set_autoscale_axis(&axis_array[T_AXIS])) return;
if (set_autoscale_axis(&axis_array[U_AXIS])) return;
if (set_autoscale_axis(&axis_array[V_AXIS])) return;
/* come here only if nothing found: */
int_error(c_token, "Invalid range");
}
/* process 'set bars' command */
static void
set_bars()
{
int save_token;
c_token++;
if (END_OF_COMMAND)
reset_bars();
while (!END_OF_COMMAND) {
if (equals(c_token,"default")) {
reset_bars();
++c_token;
return;
}
/* Jul 2015 - allow a separate line type for error bars */
save_token = c_token;
lp_parse(&bar_lp, LP_ADHOC, FALSE);
if (c_token != save_token) {
bar_lp.flags = LP_ERRORBAR_SET;
continue;
}
if (almost_equals(c_token,"s$mall")) {