FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gnuplot-old/src/set.c at axis_branch_base · gnuplot/gnuplot-old · GitHub
gnuplot
gnuplot-old
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gnuplot-old
/
src
/
set.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
3308 lines (2994 loc) · 81.7 KB
Breadcrumbs
gnuplot-old
/
src
/
set.c
Copy path
File metadata and controls
3308 lines (2994 loc) · 81.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.35.2.7 2000/10/24 18:58:12 broeker Exp $"
); }
#endif
/* GNUPLOT - set.c */
/*[
* Copyright 1986 - 1993, 1998 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 (crowl@cs.orst.edu)
* 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
"gp_time.h"
#include
"hidden3d.h"
#include
"misc.h"
#include
"parse.h"
#include
"plot.h"
#include
"plot2d.h"
#include
"plot3d.h"
#include
"tables.h"
#include
"term_api.h"
#include
"util.h"
#include
"variable.h"
#ifdef
USE_MOUSE
# include
"mouse.h"
#endif
#include
<ctype.h>
/* for isdigit() */
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_boxwidth
__PROTO
((
void
));
static
void
set_clabel
__PROTO
((
void
));
static
void
set_clip
__PROTO
((
void
));
static
void
set_cntrparam
__PROTO
((
void
));
static
void
set_contour
__PROTO
((
void
));
static
void
set_dgrid3d
__PROTO
((
void
));
static
void
set_dummy
__PROTO
((
void
));
static
void
set_encoding
__PROTO
((
void
));
static
void
set_format
__PROTO
((
void
));
static
void
set_grid
__PROTO
((
void
));
static
void
set_hidden3d
__PROTO
((
void
));
#if
defined(
HAVE_LIBREADLINE
)
&&
defined(
GNUPLOT_HISTORY
)
static
void
set_historysize
__PROTO
((
void
));
#endif
static
void
set_isosamples
__PROTO
((
void
));
static
void
set_key
__PROTO
((
void
));
static
void
set_keytitle
__PROTO
((
void
));
static
void
set_label
__PROTO
((
void
));
static
int
assign_label_tag
__PROTO
((
void
));
static
void
set_loadpath
__PROTO
((
void
));
static
void
set_locale
__PROTO
((
void
));
static
void
set_logscale
__PROTO
((
void
));
static
void
set_mapping
__PROTO
((
void
));
static
void
set_bmargin
__PROTO
((
void
));
static
void
set_lmargin
__PROTO
((
void
));
static
void
set_rmargin
__PROTO
((
void
));
static
void
set_tmargin
__PROTO
((
void
));
static
void
set_missing
__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_pointsize
__PROTO
((
void
));
static
void
set_polar
__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_terminal
__PROTO
((
void
));
static
void
set_termoptions
__PROTO
((
void
));
static
void
set_tics
__PROTO
((
void
));
static
void
set_ticscale
__PROTO
((
void
));
static
void
set_ticslevel
__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
((
AXIS_INDEX
));
static
void
set_range
__PROTO
((
AXIS_INDEX
));
static
void
set_zeroaxis
__PROTO
((
AXIS_INDEX
));
static
void
set_allzeroaxis
__PROTO
((
void
));
/******** Local functions ********/
static
void
get_position
__PROTO
((
struct
position
*
pos
));
static
void
get_position_type
__PROTO
((
enum
position_type
*
type
,
int
*
axes
));
static
void
set_xyzlabel
__PROTO
((
label_struct
*
label
));
static
void
load_tics
__PROTO
((
AXIS_INDEX
axis
));
static
void
load_tic_user
__PROTO
((
AXIS_INDEX
axis
));
static
void
free_marklist
__PROTO
((
struct
ticmark
*
list
));
static
void
load_tic_series
__PROTO
((
AXIS_INDEX
axis
));
static
void
load_offsets
__PROTO
((
double
*
a
,
double
*
b
,
double
*
c
,
double
*
d
));
static
void
set_linestyle
__PROTO
((
void
));
static
int
assign_linestyle_tag
__PROTO
((
void
));
static
int
looks_like_numeric
__PROTO
((
char
*
));
static
void
reset_lp_properties
__PROTO
((
struct
lp_style_type
*
arg
));
static
int
set_tic_prop
__PROTO
((
AXIS_INDEX
));
static
char
*
fill_numbers_into_string
__PROTO
((
char
*
pattern
));
/* Backwards compatibility ... */
static
void
set_nolinestyle
__PROTO
((
void
));
/******** The 'set' command ********/
void
set_command
()
{
static
char
GPFAR
setmess
[]
=
"valid set options: [] = choose one, {} means optional\n\n\
\t'angles', 'arrow', 'autoscale', 'bars', 'border', 'boxwidth',\n\
\t'clabel', 'clip', 'cntrparam', 'contour', 'data style', 'dgrid3d',\n\
\t'dummy', 'encoding', 'format', 'function style', 'grid',\n\
\t'hidden3d', 'historysize', 'isosamples', 'key', 'label', 'linestyle',\n\
\t'locale', 'logscale', '[blrt]margin', 'mapping', 'missing', 'mouse',\n\
\t'multiplot', 'offsets', 'origin', 'output', 'parametric', 'pointsize',\n\
\t'polar', '[rtuv]range', 'samples', 'size', 'surface', 'terminal',\n\
\t'tics', 'ticscale', 'ticslevel', 'timestamp', 'timefmt',\n\
\t'title', 'view', '[xyz]{2}data', '[xyz]{2}label', '[xyz]{2}range',\n\
\t'{no}{m}[xyz]{2}tics', '[xyz]{2}[md]tics', '{[xyz]{2}}zeroaxis', 'zero'"
;
c_token
++
;
#ifdef
BACKWARDS_COMPATIBLE
/* retain backwards compatibility to the old syntax for now
* Oh, such ugliness ...
*/
if
(
almost_equals
(
c_token
,
"da$ta"
)) {
if
(
interactive
)
int_warn
(
c_token
,
"deprecated syntax, use \"set style data\""
);
if
(!
almost_equals
(
++
c_token
,
"s$tyle"
))
int_error
(
c_token
,
"expecting keyword 'style'"
);
else
data_style
=
get_style
();
}
else
if
(
almost_equals
(
c_token
,
"fu$nction"
)) {
if
(
interactive
)
int_warn
(
c_token
,
"deprecated syntax, use \"set style function\""
);
if
(!
almost_equals
(
++
c_token
,
"s$tyle"
))
int_error
(
c_token
,
"expecting keyword 'style'"
);
else
func_style
=
get_style
();
}
else
if
(
almost_equals
(
c_token
,
"li$nestyle"
)
||
equals
(
c_token
,
"ls"
)) {
if
(
interactive
)
int_warn
(
c_token
,
"deprecated syntax, use \"set style line\""
);
c_token
++
;
set_linestyle
();
}
else
if
(
almost_equals
(
c_token
,
"noli$nestyle"
)
||
equals
(
c_token
,
"nols"
)) {
c_token
++
;
set_nolinestyle
();
}
else
if
(
input_line
[
token
[
c_token
].
start_index
]
==
'n'
&&
input_line
[
token
[
c_token
].
start_index
+
1
]
==
'o'
) {
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
{
#endif
/* BACKWARDS_COMPATIBLE */
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_CNTRPARAM
:
set_cntrparam
();
break
;
case
S_CONTOUR
:
set_contour
();
break
;
case
S_DGRID3D
:
set_dgrid3d
();
break
;
case
S_DUMMY
:
set_dummy
();
break
;
case
S_ENCODING
:
set_encoding
();
break
;
case
S_FORMAT
:
set_format
();
break
;
case
S_GRID
:
set_grid
();
break
;
case
S_HIDDEN3D
:
set_hidden3d
();
break
;
#if
defined(
HAVE_LIBREADLINE
)
&&
defined(
GNUPLOT_HISTORY
)
case
S_HISTORYSIZE
:
set_historysize
();
break
;
#endif
case
S_ISOSAMPLES
:
set_isosamples
();
break
;
case
S_KEY
:
set_key
();
break
;
case
S_KEYTITLE
:
set_keytitle
();
break
;
case
S_LABEL
:
set_label
();
break
;
case
S_LOADPATH
:
set_loadpath
();
break
;
case
S_LOCALE
:
set_locale
();
break
;
case
S_LOGSCALE
:
set_logscale
();
break
;
case
S_MAPPING
:
set_mapping
();
break
;
case
S_BMARGIN
:
set_bmargin
();
break
;
case
S_LMARGIN
:
set_lmargin
();
break
;
case
S_RMARGIN
:
set_rmargin
();
break
;
case
S_TMARGIN
:
set_tmargin
();
break
;
case
S_MISSING
:
set_missing
();
break
;
#ifdef
USE_MOUSE
case
S_MOUSE
:
set_mouse
();
break
;
#endif
case
S_MULTIPLOT
:
term_start_multiplot
();
break
;
case
S_OFFSETS
:
set_offsets
();
break
;
case
S_ORIGIN
:
set_origin
();
break
;
case
S_OUTPUT
:
set_output
();
break
;
case
S_PARAMETRIC
:
set_parametric
();
break
;
case
S_POINTSIZE
:
set_pointsize
();
break
;
case
S_POLAR
:
set_polar
();
break
;
case
S_SAMPLES
:
set_samples
();
break
;
case
S_SIZE
:
set_size
();
break
;
case
S_STYLE
:
set_style
();
break
;
case
S_SURFACE
:
set_surface
();
break
;
case
S_TERMINAL
:
set_terminal
();
break
;
case
S_TERMOPTIONS
:
set_termoptions
();
break
;
case
S_TICS
:
set_tics
();
break
;
case
S_TICSCALE
:
set_ticscale
();
break
;
case
S_TICSLEVEL
:
set_ticslevel
();
break
;
case
S_TIMEFMT
:
set_timefmt
();
break
;
case
S_TIMESTAMP
:
set_timestamp
();
break
;
case
S_TITLE
:
set_xyzlabel
(
&
title
);
break
;
case
S_VIEW
:
set_view
();
break
;
case
S_ZERO
:
set_zero
();
break
;
/* FIXME */
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
(
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
(
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
(
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
(
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
(
FIRST_Z_AXIS
);
break
;
case
S_XDATA
:
set_timedata
(
FIRST_X_AXIS
);
/* HBB 20000506: the old cod this this, too, although it
* serves no useful purpose, AFAICS */
set_timedata
(
T_AXIS
);
set_timedata
(
U_AXIS
);
break
;
case
S_YDATA
:
set_timedata
(
FIRST_Y_AXIS
);
/* dito */
set_timedata
(
V_AXIS
);
break
;
case
S_ZDATA
:
set_timedata
(
FIRST_Z_AXIS
);
break
;
case
S_X2DATA
:
set_timedata
(
SECOND_X_AXIS
);
break
;
case
S_Y2DATA
:
set_timedata
(
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_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
(
FIRST_X_AXIS
);
break
;
case
S_X2RANGE
:
set_range
(
SECOND_X_AXIS
);
break
;
case
S_YRANGE
:
set_range
(
FIRST_Y_AXIS
);
break
;
case
S_Y2RANGE
:
set_range
(
SECOND_Y_AXIS
);
break
;
case
S_ZRANGE
:
set_range
(
FIRST_Z_AXIS
);
break
;
case
S_RRANGE
:
set_range
(
R_AXIS
);
break
;
case
S_TRANGE
:
set_range
(
T_AXIS
);
break
;
case
S_URANGE
:
set_range
(
U_AXIS
);
break
;
case
S_VRANGE
:
set_range
(
V_AXIS
);
break
;
case
S_XZEROAXIS
:
set_zeroaxis
(
FIRST_X_AXIS
);
break
;
case
S_YZEROAXIS
:
set_zeroaxis
(
FIRST_Y_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
;
default
:
int_error
(
c_token
,
setmess
);
break
;
}
#ifdef
BACKWARDS_COMPATIBLE
}
#endif
}
/* 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} */
static
void
set_arrow
()
{
struct
value
a
;
struct
arrow_def
*
this_arrow
=
NULL
;
struct
arrow_def
*
new_arrow
=
NULL
;
struct
arrow_def
*
prev_arrow
=
NULL
;
struct
position
spos
,
epos
,
headsize
;
struct
lp_style_type
loc_lp
;
int
tag
;
TBOOLEAN
set_start
,
set_end
,
head
=
1
;
TBOOLEAN
set_line
=
0
,
set_headsize
=
0
,
set_layer
=
0
;
TBOOLEAN
relative
=
0
;
int
layer
=
0
;
headsize
.
x
=
0
;
/* length being zero means the default head size */
c_token
++
;
/* Init struct lp_style_type loc_lp */
reset_lp_properties
(
&
loc_lp
);
/* get tag */
if
(!
END_OF_COMMAND
&&
!
equals
(
c_token
,
"from"
)
&&
!
equals
(
c_token
,
"to"
)
&&
!
equals
(
c_token
,
"rto"
)
) {
/* must be a tag expression! */
tag
=
(
int
)
real
(
const_express
(
&
a
));
if
(
tag
<=
0
)
int_error
(
c_token
,
"tag must be > zero"
);
}
else
tag
=
assign_arrow_tag
();
/* default next tag */
/* HBB 20001018: removed code here that accepted 'first' or
* 'second' keywords. The resulting variables 'axes' and
* 'set_axes' effected nothing, anyway --> deleted them, too. */
/* get start position */
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"from"
)) {
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"start coordinates expected"
);
/* get coordinates */
get_position
(
&
spos
);
set_start
=
TRUE;
}
else
{
spos
.
x
=
spos
.
y
=
spos
.
z
=
0
;
spos
.
scalex
=
spos
.
scaley
=
spos
.
scalez
=
first_axes
;
set_start
=
FALSE;
}
/* get end position */
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"to"
)) {
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"end coordinates expected"
);
/* get coordinates */
get_position
(
&
epos
);
set_end
=
TRUE;
}
else
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"rto"
)) {
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"end coordinates expected"
);
/* get coordinates */
get_position
(
&
epos
);
set_end
=
TRUE;
relative
=
1
;
}
else
{
epos
.
x
=
epos
.
y
=
epos
.
z
=
0
;
epos
.
scalex
=
epos
.
scaley
=
epos
.
scalez
=
first_axes
;
set_end
=
FALSE;
}
/* get start position - what the heck, either order is ok */
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"from"
)) {
if
(
set_start
)
int_error
(
c_token
,
"only one 'from' is allowed"
);
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"start coordinates expected"
);
/* get coordinates */
get_position
(
&
spos
);
set_start
=
TRUE;
}
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"nohead"
)) {
c_token
++
;
head
=
0
;
}
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"head"
)) {
c_token
++
;
head
=
1
;
}
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"heads"
)) {
c_token
++
;
head
=
2
;
}
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"size"
)) {
headsize
.
scalex
=
headsize
.
scaley
=
headsize
.
scalez
=
first_axes
;
/* only scalex used; scaley is angle of the head in [deg] */
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"head size expected"
);
get_position
(
&
headsize
);
set_headsize
=
TRUE;
}
set_layer
=
FALSE;
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"back"
)) {
c_token
++
;
layer
=
0
;
set_layer
=
TRUE;
}
if
(!
END_OF_COMMAND
&&
equals
(
c_token
,
"front"
)) {
c_token
++
;
layer
=
1
;
set_layer
=
TRUE;
}
set_line
=
1
;
/* pick up a line spec - allow ls, but no point. */
lp_parse
(
&
loc_lp
,
1
,
0
,
0
,
0
);
loc_lp
.
pointflag
=
0
;
/* standard value for arrows, don't use points */
if
(!
END_OF_COMMAND
)
int_error
(
c_token
,
"extraneous or out-of-order arguments in set arrow"
);
/* 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
) {
/* changing the arrow */
if
(
set_start
) {
this_arrow
->
start
=
spos
;
}
if
(
set_end
) {
this_arrow
->
end
=
epos
;
this_arrow
->
relative
=
relative
;
}
this_arrow
->
head
=
head
;
if
(
set_layer
) {
this_arrow
->
layer
=
layer
;
}
if
(
set_headsize
) {
this_arrow
->
headsize
=
headsize
;
}
if
(
set_line
) {
this_arrow
->
lp_properties
=
loc_lp
;
}
}
else
{
/* adding the arrow */
new_arrow
=
(
struct
arrow_def
*
)
gp_alloc
(
sizeof
(
struct
arrow_def
),
"arrow"
);
if
(
prev_arrow
!=
NULL
)
prev_arrow
->
next
=
new_arrow
;
/* add it to end of list */
else
first_arrow
=
new_arrow
;
/* make it start of list */
new_arrow
->
tag
=
tag
;
new_arrow
->
next
=
this_arrow
;
new_arrow
->
start
=
spos
;
new_arrow
->
end
=
epos
;
new_arrow
->
head
=
head
;
new_arrow
->
headsize
=
headsize
;
new_arrow
->
layer
=
layer
;
new_arrow
->
relative
=
relative
;
new_arrow
->
lp_properties
=
loc_lp
;
}
}
/* 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
);
}
/* process 'set autoscale' command */
static
void
set_autoscale
()
{
char
min_string
[
20
],
max_string
[
20
];
c_token
++
;
if
(
END_OF_COMMAND
) {
INIT_AXIS_ARRAY
(
set_autoscale
,
DTRUE
);
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
=
DTRUE
;
c_token
++
;
return
;
}
/* save on replication with a macro */
#define
PROCESS_AUTO_LETTER
(
axis
) \
do { \
if (equals(c_token, axis_defaults[axis].name)) { \
axis_array[axis].set_autoscale = DTRUE; \
++c_token; \
return; \
} \
sprintf(min_string, "%smi$n", axis_defaults[axis].name); \
if (almost_equals(c_token, min_string)) { \
axis_array[axis].set_autoscale |= 1; \
++c_token; \
return; \
} \
sprintf(max_string, "%sma$x", axis_defaults[axis].name); \
if (almost_equals(c_token, max_string)) { \
axis_array[axis].set_autoscale |= 2; \
++c_token; \
return; \
} \
} while(0)
PROCESS_AUTO_LETTER
(
R_AXIS
);
PROCESS_AUTO_LETTER
(
T_AXIS
);
PROCESS_AUTO_LETTER
(
U_AXIS
);
PROCESS_AUTO_LETTER
(
V_AXIS
);
PROCESS_AUTO_LETTER
(
FIRST_X_AXIS
);
PROCESS_AUTO_LETTER
(
FIRST_Y_AXIS
);
PROCESS_AUTO_LETTER
(
FIRST_Z_AXIS
);
PROCESS_AUTO_LETTER
(
SECOND_X_AXIS
);
PROCESS_AUTO_LETTER
(
SECOND_Y_AXIS
);
/* came here only if nothing found: */
int_error
(
c_token
,
"Invalid range"
);
}
/* process 'set bars' command */
static
void
set_bars
()
{
struct
value
a
;
c_token
++
;
if
(
END_OF_COMMAND
) {
bar_size
=
1.0
;
}
else
if
(
almost_equals
(
c_token
,
"s$mall"
)) {
bar_size
=
0.0
;
++
c_token
;
}
else
if
(
almost_equals
(
c_token
,
"l$arge"
)) {
bar_size
=
1.0
;
++
c_token
;
}
else
{
bar_size
=
real
(
const_express
(
&
a
));
}
}
/* process 'set border' command */
static
void
set_border
()
{
struct
value
a
;
c_token
++
;
if
(
END_OF_COMMAND
){
draw_border
=
31
;
}
else
{
draw_border
=
(
int
)
real
(
const_express
(
&
a
));
}
/* HBB 980609: add linestyle handling for 'set border...' */
/* For now, you have to give a border bitpattern to be able to specify
* a linestyle. Sorry for this, but the gnuplot parser really is too messy
* for any other solution, currently */
/* not for long, I hope. Lars */
if
(
END_OF_COMMAND
) {
set_lp_properties
(
&
border_lp
,
0
,
-2
,
0
,
1.0
,
1.0
);
}
else
{
lp_parse
(
&
border_lp
,
1
,
0
,
-2
,
0
);
}
}
/* process 'set boxwidth' command */
static
void
set_boxwidth
()
{
struct
value
a
;
c_token
++
;
if
(
END_OF_COMMAND
)
boxwidth
=
-1.0
;
else
{
/* if((boxwidth = real(const_express(&a))) != -2.0) */
/* boxwidth = magnitude(const_express(&a));*/
boxwidth
=
real
(
const_express
(
&
a
));
}
}
/* process 'set clabel' command */
static
void
set_clabel
()
{
c_token
++
;
label_contours
=
TRUE;
if
(
isstring
(
c_token
))
quote_str
(
contour_format
,
c_token
++
,
30
);
}
/* process 'set clip' command */
static
void
set_clip
()
{
c_token
++
;
if
(
END_OF_COMMAND
)
/* assuming same as points */
clip_points
=
TRUE;
else
if
(
almost_equals
(
c_token
,
"p$oints"
))
clip_points
=
TRUE;
else
if
(
almost_equals
(
c_token
,
"o$ne"
))
clip_lines1
=
TRUE;
else
if
(
almost_equals
(
c_token
,
"t$wo"
))
clip_lines2
=
TRUE;
else
int_error
(
c_token
,
"expecting 'points', 'one', or 'two'"
);
c_token
++
;
}
/* process 'set cntrparam' command */
static
void
set_cntrparam
()
{
struct
value
a
;
c_token
++
;
if
(
END_OF_COMMAND
) {
/* assuming same as defaults */
contour_pts
=
DEFAULT_NUM_APPROX_PTS
;
contour_kind
=
CONTOUR_KIND_LINEAR
;
contour_order
=
DEFAULT_CONTOUR_ORDER
;
contour_levels
=
DEFAULT_CONTOUR_LEVELS
;
contour_levels_kind
=
LEVELS_AUTO
;
}
else
if
(
almost_equals
(
c_token
,
"p$oints"
)) {
c_token
++
;
contour_pts
=
(
int
)
real
(
const_express
(
&
a
));
}
else
if
(
almost_equals
(
c_token
,
"li$near"
)) {
c_token
++
;
contour_kind
=
CONTOUR_KIND_LINEAR
;
}
else
if
(
almost_equals
(
c_token
,
"c$ubicspline"
)) {
c_token
++
;
contour_kind
=
CONTOUR_KIND_CUBIC_SPL
;
}
else
if
(
almost_equals
(
c_token
,
"b$spline"
)) {
c_token
++
;
contour_kind
=
CONTOUR_KIND_BSPLINE
;
}
else
if
(
almost_equals
(
c_token
,
"le$vels"
)) {
c_token
++
;
init_dynarray
(
&
dyn_contour_levels_list
,
sizeof
(
double
),
5
,
10
);
/* RKC: I have modified the next two:
* to use commas to separate list elements as in xtics
* so that incremental lists start,incr[,end]as in "
*/
if
(
almost_equals
(
c_token
,
"di$screte"
)) {
contour_levels_kind
=
LEVELS_DISCRETE
;
c_token
++
;
if
(
END_OF_COMMAND
)
int_error
(
c_token
,
"expecting discrete level"
);
else
*
(
double
*
)
nextfrom_dynarray
(
&
dyn_contour_levels_list
)
=
real
(
const_express
(
&
a
));
while
(!
END_OF_COMMAND
) {
if
(!
equals
(
c_token
,
","
))
int_error
(
c_token
,
"expecting comma to separate discrete levels"
);
c_token
++
;
*
(
double
*
)
nextfrom_dynarray
(
&
dyn_contour_levels_list
)
=
real
(
const_express
(
&
a
));
}
contour_levels
=
dyn_contour_levels_list
.
end
;
}
else
if
(
almost_equals
(
c_token
,
"in$cremental"
)) {
int
i
=
0
;
/* local counter */
contour_levels_kind
=
LEVELS_INCREMENTAL
;
c_token
++
;
contour_levels_list
[
i
++
]
=
real
(
const_express
(
&
a
));
if
(!
equals
(
c_token
,
","
))
int_error
(
c_token
,
"expecting comma to separate start,incr levels"
);
c_token
++
;
if
((
contour_levels_list
[
i
++
]
=
real
(
const_express
(
&
a
)))
==
0
)
int_error
(
c_token
,
"increment cannot be 0"
);
if
(!
END_OF_COMMAND
) {
if
(!
equals
(
c_token
,
","
))
int_error
(
c_token
,
"expecting comma to separate incr,stop levels"
);
c_token
++
;
/* need to round up, since 10,10,50 is 5 levels, not four,
* but 10,10,49 is four
*/
dyn_contour_levels_list
.
end
=
i
;
contour_levels
=
(
int
) ( (
real
(
const_express
(
&
a
))
-
contour_levels_list
[
0
])/
contour_levels_list
[
1
]
+
1.0
);
}
}
else
if
(
almost_equals
(
c_token
,
"au$to"
)) {
contour_levels_kind
=
LEVELS_AUTO
;
c_token
++
;
if
(!
END_OF_COMMAND
)
contour_levels
=
(
int
)
real
(
const_express
(
&
a
));
}
else
{
if
(
contour_levels_kind
==
LEVELS_DISCRETE
)
int_error
(
c_token
,
"Levels type is discrete, ignoring new number of contour levels"
);
contour_levels
=
(
int
)
real
(
const_express
(
&
a
));
}
}
else
if
(
almost_equals
(
c_token
,
"o$rder"
)) {
int
order
;
c_token
++
;
order
=
(
int
)
real
(
const_express
(
&
a
));
if
(
order
<
2
||
order
>
MAX_BSPLINE_ORDER
)
int_error
(
c_token
,
"bspline order must be in [2..10] range."
);
contour_order
=
order
;
}
else
int_error
(
c_token
,
"expecting 'linear', 'cubicspline', 'bspline', 'points', 'levels' or 'order'"
);
}
/* process 'set contour' command */
static
void
set_contour
()
{
c_token
++
;
if
(
END_OF_COMMAND
)
/* assuming same as points */
draw_contour
=
CONTOUR_BASE
;
else
{
if
(
almost_equals
(
c_token
,
"ba$se"
))
draw_contour
=
CONTOUR_BASE
;
else
if
(
almost_equals
(
c_token
,
"s$urface"
))
draw_contour
=
CONTOUR_SRF
;
else
if
(
almost_equals
(
c_token
,
"bo$th"
))
draw_contour
=
CONTOUR_BOTH
;
else
int_error
(
c_token
,
"expecting 'base', 'surface', or 'both'"
);
c_token
++
;
}
}
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL