FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gnuplot-old/src/plot2d.c at Release_4_4_3 · 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
/
plot2d.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
2627 lines (2305 loc) · 82.8 KB
Breadcrumbs
gnuplot-old
/
src
/
plot2d.c
Copy path
File metadata and controls
2627 lines (2305 loc) · 82.8 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: plot2d.c,v 1.193.2.18 2010/10/22 04:38:28 sfeam Exp $"
); }
#endif
/* GNUPLOT - plot2d.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.
]*/
#include
"gp_types.h"
#include
"plot2d.h"
#include
"alloc.h"
#include
"axis.h"
#include
"binary.h"
#include
"command.h"
#include
"datafile.h"
#include
"eval.h"
#include
"fit.h"
#include
"graphics.h"
#include
"interpol.h"
#include
"misc.h"
#include
"parse.h"
#include
"setshow.h"
#include
"tables.h"
#include
"tabulate.h"
#include
"term_api.h"
#include
"util.h"
#include
"variable.h"
/* For locale handling */
#ifndef
_Windows
# include
"help.h"
#endif
/* minimum size of points[] in curve_points */
#define
MIN_CRV_POINTS
100
/* static prototypes */
static
struct
curve_points
*
cp_alloc
__PROTO
((
int
num
));
static
int
get_data
__PROTO
((
struct
curve_points
*
));
static
void
store2d_point
__PROTO
((
struct
curve_points
*
,
int
i
,
double
x
,
double
y
,
double
xlow
,
double
xhigh
,
double
ylow
,
double
yhigh
,
double
width
));
static
void
eval_plots
__PROTO
((
void
));
static
void
parametric_fixup
__PROTO
((
struct
curve_points
*
start_plot
,
int
*
plot_num
));
static
void
box_range_fiddling
__PROTO
((
struct
curve_points
*
plot
));
static
void
histogram_range_fiddling
__PROTO
((
struct
curve_points
*
plot
));
/* internal and external variables */
/* the curves/surfaces of the plot */
struct
curve_points
*
first_plot
=
NULL
;
static
struct
udft_entry
plot_func
;
/* box width (automatic) */
double
boxwidth
=
-1.0
;
/* whether box width is absolute (default) or relative */
TBOOLEAN
boxwidth_is_absolute
=
TRUE;
static
double
histogram_rightmost
=
0.0
;
/* Highest x-coord of histogram so far */
static
char
*
histogram_title
=
NULL
;
/* Subtitle for this histogram */
static
struct
coordinate
GPHUGE
*
stackheight
=
NULL
;
/* Scratch space for y autoscale */
static
int
stack_count
=
0
;
/* counter for stackheight */
/* function implementations */
/* HBB 20000508: moved cp_alloc() &friends to the main module using them, and
* made cp_alloc 'static'.
*/
/*
* cp_alloc() allocates a curve_points structure that can hold 'num'
* points. Initialize all fields to NULL.
*/
static
struct
curve_points
*
cp_alloc
(
int
num
)
{
struct
curve_points
*
cp
;
struct
lp_style_type
default_lp_properties
=
DEFAULT_LP_STYLE_TYPE
;
cp
=
(
struct
curve_points
*
)
gp_alloc
(
sizeof
(
struct
curve_points
),
"curve"
);
memset
(
cp
,
0
,
sizeof
(
struct
curve_points
));
cp
->
p_max
=
(
num
>=
0
?
num
:
0
);
if
(
num
>
0
)
cp
->
points
=
(
struct
coordinate
GPHUGE
*
)
gp_alloc
(
num
*
sizeof
(
struct
coordinate
),
"curve points"
);
/* Initialize various fields */
cp
->
lp_properties
=
default_lp_properties
;
default_arrow_style
(
&
(
cp
->
arrow_properties
));
cp
->
fill_properties
=
default_fillstyle
;
return
(
cp
);
}
/*
* cp_extend() reallocates a curve_points structure to hold "num"
* points. This will either expand or shrink the storage.
*/
void
cp_extend
(
struct
curve_points
*
cp
,
int
num
)
{
#if
defined(
DOS16
)
||
defined(
WIN16
)
/* Make sure we do not allocate more than 64k points in msdos since
* indexing is done with 16-bit int
* Leave some bytes for malloc maintainance.
*/
if
(
num
>
32700
)
int_error
(
NO_CARET
,
"Array index must be less than 32k in msdos"
);
#endif
/* MSDOS */
if
(
num
==
cp
->
p_max
)
return
;
if
(
num
>
0
) {
if
(
cp
->
points
==
NULL
) {
cp
->
points
=
gp_alloc
(
num
*
sizeof
(
cp
->
points
[
0
]),
"curve points"
);
}
else
{
cp
->
points
=
gp_realloc
(
cp
->
points
,
num
*
sizeof
(
cp
->
points
[
0
]),
"expanding curve points"
);
}
cp
->
p_max
=
num
;
}
else
{
if
(
cp
->
points
!=
NULL
)
free
(
cp
->
points
);
cp
->
points
=
NULL
;
cp
->
p_max
=
0
;
}
}
/*
* cp_free() releases any memory which was previously malloc()'d to hold
* curve points (and recursively down the linked list).
*/
/* HBB 20000506: instead of risking stack havoc by recursion, operate
* iteratively */
void
cp_free
(
struct
curve_points
*
cp
)
{
while
(
cp
) {
struct
curve_points
*
next
=
cp
->
next
;
if
(
cp
->
title
)
free
(
cp
->
title
);
if
(
cp
->
points
)
free
(
cp
->
points
);
if
(
cp
->
labels
) {
free_labels
(
cp
->
labels
);
cp
->
labels
=
(
struct
text_label
*
)
NULL
;
}
free
(
cp
);
cp
=
next
;
}
}
/*
* In the parametric case we can say plot [a= -4:4] [-2:2] [-1:1] sin(a),a**2
* while in the non-parametric case we would say only plot [b= -2:2] [-1:1]
* sin(b)
*/
void
plotrequest
()
{
int
dummy_token
=
-1
;
int
t_axis
;
if
(!
term
)
/* unknown */
int_error
(
c_token
,
"use 'set term' to set terminal type first"
);
is_3d_plot
=
FALSE;
/* Deactivate if 'set view map' is still running after the previous 'splot': */
splot_map_deactivate
();
if
(
parametric
&&
strcmp
(
set_dummy_var
[
0
],
"u"
)
==
0
)
strcpy
(
set_dummy_var
[
0
],
"t"
);
/* initialise the arrays from the 'set' scalars */
AXIS_INIT2D
(
FIRST_X_AXIS
,
0
);
AXIS_INIT2D
(
FIRST_Y_AXIS
,
1
);
AXIS_INIT2D
(
SECOND_X_AXIS
,
0
);
AXIS_INIT2D
(
SECOND_Y_AXIS
,
1
);
AXIS_INIT2D
(
T_AXIS
,
0
);
AXIS_INIT2D
(
R_AXIS
,
1
);
AXIS_INIT2D
(
COLOR_AXIS
,
1
);
t_axis
=
(
parametric
||
polar
) ?
T_AXIS
:
FIRST_X_AXIS
;
PARSE_NAMED_RANGE
(
t_axis
,
dummy_token
);
if
(
parametric
||
polar
)
/* set optional x ranges */
PARSE_RANGE
(
FIRST_X_AXIS
);
/* possible reversal of x range *does* matter, even in parametric
* or polar mode */
CHECK_REVERSE
(
FIRST_X_AXIS
);
PARSE_RANGE
(
FIRST_Y_AXIS
);
CHECK_REVERSE
(
FIRST_Y_AXIS
);
PARSE_RANGE
(
SECOND_X_AXIS
);
CHECK_REVERSE
(
SECOND_X_AXIS
);
PARSE_RANGE
(
SECOND_Y_AXIS
);
CHECK_REVERSE
(
SECOND_Y_AXIS
);
/* Clear out any tick labels read from data files in previous plot */
for
(
t_axis
=
0
;
t_axis
<
AXIS_ARRAY_SIZE
;
t_axis
++
) {
struct
ticdef
*
ticdef
=
&
axis_array
[
t_axis
].
ticdef
;
if
(
ticdef
->
def
.
user
)
ticdef
->
def
.
user
=
prune_dataticks
(
ticdef
->
def
.
user
);
if
(!
ticdef
->
def
.
user
&&
ticdef
->
type
==
TIC_USER
)
ticdef
->
type
=
TIC_COMPUTED
;
}
/* use the default dummy variable unless changed */
if
(
dummy_token
>=
0
)
copy_str
(
c_dummy_var
[
0
],
dummy_token
,
MAX_ID_LEN
);
else
(
void
)
strcpy
(
c_dummy_var
[
0
],
set_dummy_var
[
0
]);
eval_plots
();
}
#ifdef
VOLATILE_REFRESH
/* Helper function for refresh command. Reexamine each data point and update the
* flags for INRANGE/OUTRANGE/UNDEFINED based on the current limits for that axis.
* Normally the axis limits are already known at this point. But if the user has
* forced "set autoscale" since the previous plot or refresh, we need to reset the
* axis limits and try to approximate the full auto-scaling behaviour.
*/
void
refresh_bounds
(
struct
curve_points
*
first_plot
,
int
nplots
)
{
struct
curve_points
*
this_plot
=
first_plot
;
int
iplot
;
/* plot index */
for
(
iplot
=
0
;
iplot
<
nplots
;
iplot
++
,
this_plot
=
this_plot
->
next
) {
int
i
;
/* point index */
struct
axis
*
x_axis
=
&
axis_array
[
this_plot
->
x_axis
];
struct
axis
*
y_axis
=
&
axis_array
[
this_plot
->
y_axis
];
/* IMAGE clipping is done elsewhere, so we don't need INRANGE/OUTRANGE
* checks.
*/
if
(
this_plot
->
plot_style
==
IMAGE
||
this_plot
->
plot_style
==
RGBIMAGE
) {
if
(
x_axis
->
set_autoscale
)
plot_image_or_update_axes
(
this_plot
,TRUE);
continue
;
}
for
(
i
=
0
;
i
<
this_plot
->
p_count
;
i
++
) {
struct
coordinate
GPHUGE
*
point
=
&
this_plot
->
points
[
i
];
if
(
point
->
type
==
UNDEFINED
)
continue
;
else
point
->
type
=
INRANGE
;
/* If the state has been set to autoscale since the last plot,
* mark everything INRANGE and re-evaluate the axis limits now.
* Otherwise test INRANGE/OUTRANGE against previous axis limits.
*/
if
(!
this_plot
->
noautoscale
&&
(
x_axis
->
set_autoscale
&
(
AUTOSCALE_MIN
|
AUTOSCALE_MAX
))) {
if
(
point
->
x
>
x_axis
->
max
)
x_axis
->
max
=
point
->
x
;
if
(
point
->
x
<
x_axis
->
min
)
x_axis
->
min
=
point
->
x
;
}
else
if
(!
inrange
(
point
->
x
,
x_axis
->
min
,
x_axis
->
max
)) {
point
->
type
=
OUTRANGE
;
continue
;
}
if
(!
this_plot
->
noautoscale
&&
(
y_axis
->
set_autoscale
&
(
AUTOSCALE_MIN
|
AUTOSCALE_MAX
))) {
if
(
point
->
y
>
y_axis
->
max
)
y_axis
->
max
=
point
->
y
;
if
(
point
->
y
<
y_axis
->
min
)
y_axis
->
min
=
point
->
y
;
}
else
if
(!
inrange
(
point
->
y
,
y_axis
->
min
,
y_axis
->
max
)) {
point
->
type
=
OUTRANGE
;
continue
;
}
}
}
}
#endif
/* A quick note about boxes style. For boxwidth auto, we cannot
* calculate widths yet, since it may be sorted, etc. But if
* width is set, we must do it now, before logs of xmin/xmax
* are taken.
* We store -1 in point->z as a marker to mean width needs to be
* calculated, or 0 to mean that xmin/xmax are set correctly
*/
/* current_plot->token is after datafile spec, for error reporting
* it will later be moved passed title/with/linetype/pointtype
*/
static
int
get_data
(
struct
curve_points
*
current_plot
)
{
int
i
/* num. points ! */
,
j
;
int
ngood
;
int
max_cols
,
min_cols
;
/* allowed range of column numbers */
double
v
[
MAXDATACOLS
];
int
storetoken
=
current_plot
->
token
;
struct
coordinate
GPHUGE
*
cp
;
TBOOLEAN
variable_color
=
FALSE;
double
variable_color_value
;
if
((
current_plot
->
lp_properties
.
pm3d_color
.
type
==
TC_RGB
)
&&
(
current_plot
->
lp_properties
.
pm3d_color
.
value
<
0
))
variable_color
=
TRUE;
if
(
current_plot
->
lp_properties
.
pm3d_color
.
type
==
TC_Z
)
variable_color
=
TRUE;
if
(
current_plot
->
lp_properties
.
l_type
==
LT_COLORFROMCOLUMN
)
variable_color
=
TRUE;
/* eval_plots has already opened file */
/* HBB 2000504: For most 2D plot styles the 'z' coordinate is unused.
* Set it to NO_AXIS to account for that. For styles that use
* the z coordinate as a real coordinate (i.e. not a width or
* 'delta' component, change the setting inside the switch: */
current_plot
->
z_axis
=
NO_AXIS
;
/* HBB NEW 20060427: if there's only one, explicit using column,
* it's y data. df_axis[] has to reflect that, so df_readline()
* will expect time/date input. */
if
(
df_no_use_specs
==
1
)
df_axis
[
0
]
=
df_axis
[
1
];
switch
(
current_plot
->
plot_style
) {
/* set maximum columns to scan */
case
XYERRORLINES
:
case
XYERRORBARS
:
case
BOXXYERROR
:
min_cols
=
4
;
max_cols
=
7
;
/* HBB FIXME 20060427: what's 7th? */
if
(
df_no_use_specs
>=
6
) {
/* HBB 20060427: signal 3rd and 4th column are absolute x
* data --- needed so time/date parsing works */
df_axis
[
2
]
=
df_axis
[
3
]
=
df_axis
[
0
];
/* and 5th and 6th are absolute y data */
df_axis
[
4
]
=
df_axis
[
5
]
=
df_axis
[
1
];
}
break
;
case
FINANCEBARS
:
/* HBB 20000504: use 'z' coordinate for y-axis quantity */
current_plot
->
z_axis
=
current_plot
->
y_axis
;
min_cols
=
max_cols
=
5
;
/* HBB 20060427: signal 3rd and 4th column are absolute y data
* --- needed so time/date parsing works */
df_axis
[
2
]
=
df_axis
[
3
]
=
df_axis
[
4
]
=
df_axis
[
1
];
break
;
case
CANDLESTICKS
:
current_plot
->
z_axis
=
current_plot
->
y_axis
;
min_cols
=
5
;
max_cols
=
6
;
df_axis
[
2
]
=
df_axis
[
3
]
=
df_axis
[
4
]
=
df_axis
[
1
];
break
;
case
BOXERROR
:
min_cols
=
3
;
/* HBB 20040520: fixed, was 4 */
max_cols
=
5
;
/* There are four(!) possible cases: */
/* 3 cols --> (x,y,dy), auto dx */
/* 4 cols, boxwidth==-2 --> (x,y,ylow,yhigh), auto dx */
/* 4 cols, boxwidth!=-2 --> (x,y,dy,dx) */
/* 5 cols --> (x,y,ylow,yhigh,dx) */
if
((
df_no_use_specs
==
4
&&
boxwidth
==
-2
)
||
df_no_use_specs
==
5
)
/* HBB 20060427: signal 3rd and 4th column are absolute y
* data --- needed so time/date parsing works */
df_axis
[
2
]
=
df_axis
[
3
]
=
df_axis
[
1
];
break
;
case
VECTOR
:
/* x, y, dx, dy, variable_color */
min_cols
=
4
;
max_cols
=
5
;
break
;
case
XERRORLINES
:
case
XERRORBARS
:
min_cols
=
3
;
max_cols
=
4
;
if
(
df_no_use_specs
==
4
)
/* HBB 20060427: signal 3rd and 4th column are absolute x
* data --- needed so time/date parsing works */
df_axis
[
2
]
=
df_axis
[
3
]
=
df_axis
[
0
];
break
;
case
YERRORLINES
:
case
YERRORBARS
:
min_cols
=
3
;
max_cols
=
4
;
if
(
df_no_use_specs
==
4
)
/* HBB 20060427: signal 3rd and 4th column are absolute y
* data --- needed so time/date parsing works */
df_axis
[
2
]
=
df_axis
[
3
]
=
df_axis
[
1
];
break
;
case
HISTOGRAMS
:
min_cols
=
1
;
max_cols
=
3
;
break
;
case
BOXES
:
min_cols
=
1
;
max_cols
=
4
;
break
;
case
FILLEDCURVES
:
min_cols
=
1
;
max_cols
=
3
;
df_axis
[
2
]
=
df_axis
[
1
];
/* Both curves use same y axis */
break
;
case
IMPULSES
:
/* 2 + possible variable color */
case
LINES
:
case
DOTS
:
min_cols
=
1
;
max_cols
=
3
;
break
;
case
LABELPOINTS
:
/* 3 column data: X Y Label */
/* 4th column allows rgb variable */
min_cols
=
3
;
max_cols
=
4
;
expect_string
(
3
);
break
;
case
IMAGE
:
min_cols
=
3
;
max_cols
=
3
;
break
;
case
RGBIMAGE
:
min_cols
=
5
;
max_cols
=
6
;
break
;
case
RGBA_IMAGE
:
min_cols
=
6
;
max_cols
=
6
;
break
;
#ifdef
EAM_OBJECTS
case
CIRCLES
:
/* 3 + possible variable color */
min_cols
=
2
;
max_cols
=
4
;
break
;
#endif
case
POINTSTYLE
:
case
LINESPOINTS
:
/* Allow 3rd column because of 'pointsize variable' */
/* Allow 4th column because of 'lc rgb variable' */
min_cols
=
1
;
max_cols
=
4
;
break
;
default
:
min_cols
=
1
;
max_cols
=
2
;
break
;
}
if
(
current_plot
->
plot_smooth
==
SMOOTH_ACSPLINES
) {
max_cols
=
3
;
current_plot
->
z_axis
=
FIRST_Z_AXIS
;
df_axis
[
2
]
=
FIRST_Z_AXIS
;
}
if
(
df_no_use_specs
>
max_cols
)
int_error
(
NO_CARET
,
"Too many using specs for this style"
);
if
(
df_no_use_specs
>
0
&&
df_no_use_specs
<
min_cols
)
int_error
(
NO_CARET
,
"Not enough columns for this style"
);
i
=
0
;
ngood
=
0
;
/* If the user has set an explicit locale for numeric input, apply it */
/* here so that it affects data fields read from the input file. */
set_numeric_locale
();
while
((
j
=
df_readline
(
v
,
max_cols
))
!=
DF_EOF
) {
/* j <= max_cols */
if
(
i
>=
current_plot
->
p_max
) {
/* overflow about to occur. Extend size of points[]
* array. Double the size, and add 1000 points, to avoid
* needlessly small steps. */
cp_extend
(
current_plot
,
i
+
i
+
1000
);
}
if
(
j
>
0
) {
ngood
++
;
/* Allow for optional columns. Currently only used for a few styles, */
/* but could be extended to a more general mechanism. */
variable_color_value
=
0
;
if
(
variable_color
) {
static
char
*
errmsg
=
"Not enough columns for variable color"
;
switch
(
current_plot
->
plot_style
) {
case
VECTOR
:
if
(
j
<
5
)
int_error
(
NO_CARET
,
errmsg
);
case
CIRCLES
:
if
(
j
<
4
)
int_error
(
NO_CARET
,
errmsg
);
case
BOXES
:
if
(
j
<
3
)
int_error
(
NO_CARET
,
errmsg
);
variable_color_value
=
v
[
--
j
];
default
:
break
;
}
}
}
switch
(
j
) {
default
:
{
df_close
();
int_error
(
c_token
,
"internal error : df_readline returned %d : datafile line %d"
,
j
,
df_line_number
);
}
case
DF_MISSING
:
/* Plot type specific handling of missing points goes here. */
if
(
current_plot
->
plot_style
==
HISTOGRAMS
) {
current_plot
->
points
[
i
].
type
=
UNDEFINED
;
i
++
;
continue
;
}
/* Jun 2006 - Return to behavior of 3.7 and current docs:
* do not interrupt plotted line because of missing data
*/
FPRINTF
((
stderr
,
"Missing datum %d\n"
,
i
));
continue
;
case
DF_UNDEFINED
:
/* NaN or bad result from extended using expression */
current_plot
->
points
[
i
].
type
=
UNDEFINED
;
i
++
;
continue
;
case
DF_FIRST_BLANK
:
/* The binary input routines generate DF_FIRST_BLANK at the end
* of scan lines, so that the data may be used for the isometric
* splots. Rather than turning that off inside the binary
* reading routine based upon the plot mode, DF_FIRST_BLANK is
* ignored for certain plot types requiring 3D coordinates in
* MODE_PLOT.
*/
if
(
current_plot
->
plot_style
==
IMAGE
||
current_plot
->
plot_style
==
RGBIMAGE
||
current_plot
->
plot_style
==
RGBA_IMAGE
)
continue
;
/* break in data, make next point undefined */
/* FIXME: We really should distinguish between a blank */
/* line and an undefined value on a non-blank line. */
current_plot
->
points
[
i
].
type
=
UNDEFINED
;
i
++
;
continue
;
case
DF_SECOND_BLANK
:
/* second blank line. We dont do anything
* (we did everything when we got FIRST one)
*/
continue
;
case
DF_FOUND_KEY_TITLE
:
df_set_key_title
(
current_plot
);
continue
;
case
DF_KEY_TITLE_MISSING
:
fprintf
(
stderr
,
"get_data: key title not found in requested column\n"
);
continue
;
case
0
:
/* not blank line, but df_readline couldn't parse it */
{
df_close
();
int_error
(
current_plot
->
token
,
"Bad data on line %d"
,
df_line_number
);
}
case
1
:
{
/* only one number */
/* x is index, assign number to y */
v
[
1
]
=
v
[
0
];
v
[
0
]
=
df_datum
;
/* nobreak */
}
case
2
:
H_ERR_BARS
:
if
(
current_plot
->
plot_style
==
HISTOGRAMS
) {
if
(
histogram_opts
.
type
==
HT_ERRORBARS
) {
/* The code is a tangle, but we can get here with j = 1, 2, or 3 */
if
(
j
==
1
)
int_error
(
c_token
,
"Not enough columns in using specification"
);
else
if
(
j
==
2
) {
v
[
3
]
=
v
[
0
]
+
v
[
1
];
v
[
2
]
=
v
[
0
]
-
v
[
1
];
}
else
{
v
[
3
]
=
v
[
2
];
v
[
2
]
=
v
[
1
];
}
v
[
1
]
=
v
[
0
];
v
[
0
]
=
df_datum
;
}
else
if
(
j
>=
2
)
int_error
(
c_token
,
"Too many columns in using specification"
);
else
v
[
2
]
=
v
[
3
]
=
v
[
1
];
if
(
histogram_opts
.
type
==
HT_STACKED_IN_TOWERS
) {
histogram_rightmost
=
current_plot
->
histogram_sequence
+
current_plot
->
histogram
->
start
;
current_plot
->
histogram
->
end
=
histogram_rightmost
;
}
else
if
(
v
[
0
]
+
current_plot
->
histogram
->
start
>
histogram_rightmost
) {
histogram_rightmost
=
v
[
0
]
+
current_plot
->
histogram
->
start
;
current_plot
->
histogram
->
end
=
histogram_rightmost
;
}
/* Histogram boxwidths are always absolute */
if
(
boxwidth
>
0
)
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
boxwidth
/
2
,
v
[
0
]
+
boxwidth
/
2
,
v
[
2
],
v
[
3
],
0.0
);
else
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
0.5
,
v
[
0
]
+
0.5
,
v
[
2
],
v
[
3
],
0.0
);
/* x, y */
/* ylow and yhigh are same as y */
}
else
if
( (
current_plot
->
plot_style
==
BOXES
)
&&
boxwidth
>
0
&&
boxwidth_is_absolute
) {
/* calculate width now */
if
(
axis_array
[
current_plot
->
x_axis
].
log
) {
double
base
=
axis_array
[
current_plot
->
x_axis
].
base
;
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
*
pow
(
base
,
-
boxwidth
/
2.
),
v
[
0
]
*
pow
(
base
,
boxwidth
/
2.
),
v
[
1
],
variable_color_value
,
0.0
);
}
else
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
boxwidth
/
2
,
v
[
0
]
+
boxwidth
/
2
,
v
[
1
],
variable_color_value
,
0.0
);
#ifdef
EAM_OBJECTS
}
else
if
(
current_plot
->
plot_style
==
CIRCLES
) {
/* x, y, default radius, full circle */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
+
1.
,
v
[
0
],
0.
,
variable_color_value
,
360.
);
#endif
}
else
{
if
(
current_plot
->
plot_style
==
CANDLESTICKS
||
current_plot
->
plot_style
==
FINANCEBARS
) {
int_warn
(
storetoken
,
"This plot style does not work with 1 or 2 cols. Setting to points"
);
current_plot
->
plot_style
=
POINTSTYLE
;
}
/* xlow and xhigh are same as x */
/* auto width if boxes, else ignored */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
variable_color_value
,
-1.0
);
}
break
;
case
3
:
/* x, y, ydelta OR x, y, xdelta OR x, y, width */
if
(
current_plot
->
plot_smooth
==
SMOOTH_ACSPLINES
)
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
1
],
v
[
2
]);
else
switch
(
current_plot
->
plot_style
) {
case
HISTOGRAMS
:
if
(
histogram_opts
.
type
==
HT_ERRORBARS
)
goto
H_ERR_BARS
;
else
/* fall through */
default
:
int_warn
(
storetoken
,
"This plot style does not work with 3 cols. Setting to yerrorbars"
);
current_plot
->
plot_style
=
YERRORBARS
;
/* fall through */
case
FILLEDCURVES
:
current_plot
->
filledcurves_options
.
closeto
=
FILLEDCURVES_BETWEEN
;
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
2
],
-1.0
);
break
;
case
YERRORLINES
:
case
YERRORBARS
:
case
BOXERROR
:
/* x, y, dy */
/* auto width if boxes, else ignored */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
]
-
v
[
2
],
v
[
1
]
+
v
[
2
],
-1.0
);
break
;
case
XERRORLINES
:
case
XERRORBARS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
v
[
2
],
v
[
0
]
+
v
[
2
],
v
[
1
],
v
[
1
],
0.0
);
break
;
case
BOXES
:
/* calculate xmin and xmax here, so that logs are taken if if necessary */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
v
[
2
] /
2
,
v
[
0
]
+
v
[
2
] /
2
,
v
[
1
],
variable_color_value
,
0.0
);
break
;
case
LABELPOINTS
:
/* Load the coords just as we would have for a point plot */
store2d_point
(
current_plot
,
i
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
1
],
-1.0
);
/* Allocate and fill in a text_label structure to match it */
store_label
(
current_plot
->
labels
,
&
(
current_plot
->
points
[
i
]),
i
,
df_tokens
[
2
],
0.0
);
i
++
;
break
;
case
IMAGE
:
/* x_center y_center color_value */
store2d_point
(
current_plot
,
i
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
1
],
v
[
2
]);
cp
=
&
(
current_plot
->
points
[
i
]);
COLOR_STORE_WITH_LOG_AND_UPDATE_RANGE
(
cp
->
CRD_COLOR
,
v
[
2
],
cp
->
type
,
COLOR_AXIS
,
current_plot
->
noautoscale
,
NOOP
,
cp
->
CRD_COLOR
=
v
[
2
]);
i
++
;
break
;
case
POINTSTYLE
:
/* x, y, variable point size or variable color */
case
LINESPOINTS
:
case
IMPULSES
:
case
LINES
:
case
DOTS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
2
],
v
[
2
]);
break
;
#ifdef
EAM_OBJECTS
case
CIRCLES
:
/* x, y, radius */
/* by default a full circle is drawn */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
v
[
2
],
v
[
0
]
+
v
[
2
],
0.
,
variable_color_value
,
360.
);
break
;
#endif
}
/*inner switch */
break
;
case
4
:
/* x, y, ylow, yhigh OR
* x, y, xlow, xhigh OR
* x, y, xdelta, ydelta OR
* x, y, ydelta, width
*/
switch
(
current_plot
->
plot_style
) {
default
:
int_warn
(
storetoken
,
"This plot style does not work with 4 cols. Setting to yerrorbars"
);
current_plot
->
plot_style
=
YERRORBARS
;
/* fall through */
case
YERRORLINES
:
case
YERRORBARS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
2
],
v
[
3
],
-1.0
);
break
;
case
BOXXYERROR
:
/* x, y, dx, dy */
case
XYERRORLINES
:
case
XYERRORBARS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
v
[
2
],
v
[
0
]
+
v
[
2
],
v
[
1
]
-
v
[
3
],
v
[
1
]
+
v
[
3
],
0.0
);
break
;
case
BOXES
:
/* x, y, xmin, xmax */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
2
],
v
[
3
],
v
[
1
],
variable_color_value
,
0.0
);
break
;
case
XERRORLINES
:
case
XERRORBARS
:
/* x, y, xmin, xmax */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
2
],
v
[
3
],
v
[
1
],
v
[
1
],
0.0
);
break
;
case
BOXERROR
:
if
(
boxwidth
==
-2
)
/* x,y, ylow, yhigh --- width automatic */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
2
],
v
[
3
],
-1.0
);
else
/* x, y, dy, width */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
v
[
3
] /
2
,
v
[
0
]
+
v
[
3
] /
2
,
v
[
1
]
-
v
[
2
],
v
[
1
]
+
v
[
2
],
0.0
);
break
;
case
VECTOR
:
/* x,y,dx,dy */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
]
+
v
[
2
],
v
[
1
],
v
[
1
]
+
v
[
3
],
variable_color_value
);
break
;
case
POINTSTYLE
:
/* x, y, variable point size and variable color */
case
LINESPOINTS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
3
],
v
[
2
]);
break
;
case
LABELPOINTS
:
/* Load the coords just as we would have for a point plot */
store2d_point
(
current_plot
,
i
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
1
],
-1.0
);
/* Allocate and fill in a text_label structure to match it */
store_label
(
current_plot
->
labels
,
&
(
current_plot
->
points
[
i
]),
i
,
df_tokens
[
2
],
v
[
3
]);
i
++
;
break
;
}
/*inner switch */
break
;
case
5
:
{
/* x, y, ylow, yhigh, width or x open low high close */
switch
(
current_plot
->
plot_style
) {
default
:
int_warn
(
storetoken
,
"Unrecognized 5 column plot style; resetting to boxerrorbars"
);
current_plot
->
plot_style
=
BOXERROR
;
/*fall through */
case
BOXERROR
:
/* x, y, ylow, yhigh, width */
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
]
-
v
[
4
] /
2
,
v
[
0
]
+
v
[
4
] /
2
,
v
[
2
],
v
[
3
],
0.0
);
break
;
case
FINANCEBARS
:
/* x yopen ylow yhigh yclose */
case
CANDLESTICKS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
2
],
v
[
3
],
v
[
4
]);
break
;
case
RGBIMAGE
:
/* x_center y_center r_value g_value b_value (rgb) */
goto
images
;
}
break
;
}
case
7
:
/* same as six columns. Width ignored */
/* eh ? - fall through */
case
6
:
/* x, y, xlow, xhigh, ylow, yhigh */
switch
(
current_plot
->
plot_style
) {
default
:
int_warn
(
storetoken
,
"This plot style not work with 6 cols. Setting to xyerrorbars"
);
current_plot
->
plot_style
=
XYERRORBARS
;
/*fall through */
case
XYERRORLINES
:
case
XYERRORBARS
:
case
BOXXYERROR
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
2
],
v
[
3
],
v
[
4
],
v
[
5
],
0.0
);
break
;
case
CANDLESTICKS
:
store2d_point
(
current_plot
,
i
++
,
v
[
0
],
v
[
1
],
v
[
5
]
>
0
?
v
[
0
]
-
v
[
5
]/
2.
:
v
[
0
],
v
[
0
],
v
[
2
],
v
[
3
],
v
[
4
]);
break
;
images
:
case
RGBA_IMAGE
:
/* x_cent y_cent red green blue alpha */
case
RGBIMAGE
:
/* x_cent y_cent red green blue */
store2d_point
(
current_plot
,
i
,
v
[
0
],
v
[
1
],
v
[
0
],
v
[
0
],
v
[
1
],
v
[
1
],
v
[
2
]);
/* We will autoscale the RGB components to a total range [0:255]
* so we don't need to do any fancy scaling here.
*/
cp
=
&
(
current_plot
->
points
[
i
]);
cp
->
CRD_R
=
v
[
2
];
cp
->
CRD_G
=
v
[
3
];
cp
->
CRD_B
=
v
[
4
];
cp
->
CRD_A
=
v
[
5
];
/* Alpha channel */
i
++
;
break
;
}
}
/*switch */
}
/*while */
/* This removes extra point caused by blank lines after data. */
if
(
current_plot
->
points
[
i
-
1
].
type
==
UNDEFINED
)
i
--
;
current_plot
->
p_count
=
i
;
cp_extend
(
current_plot
,
i
);
/* shrink to fit */
df_close
();
/* We are finished reading user input; return to C locale for internal use */
reset_numeric_locale
();
return
ngood
;
/* 0 indicates an 'empty' file */
}
/* called by get_data for each point */
static
void
store2d_point
(
struct
curve_points
*
current_plot
,
int
i
,
/* point number */
double
x
,
double
y
,
double
xlow
,
double
xhigh
,
double
ylow
,
double
yhigh
,
double
width
)
/* BOXES widths: -1 -> autocalc, 0 -> use xlow/xhigh */
{
struct
coordinate
GPHUGE
*
cp
=
&
(
current_plot
->
points
[
i
]);
coord_type
dummy_type
=
INRANGE
;
/* sometimes we dont care about outranging */
/* jev -- pass data values thru user-defined function */
/* div -- y is dummy variable 2 - copy value there */
if
(
ydata_func
.
at
) {
struct
value
val
;
(
void
)
Gcomplex
(
&
ydata_func
.
dummy_values
[
0
],
y
,
0.0
);
ydata_func
.
dummy_values
[
2
]
=
ydata_func
.
dummy_values
[
0
];
evaluate_at
(
ydata_func
.
at
,
&
val
);
y
=
undefined
?
0.0
:
real
(
&
val
);
/* EAM FIXME - filtering ylow and yhigh is nonsense for many plot styles */
(
void
)
Gcomplex
(
&
ydata_func
.
dummy_values
[
0
],
ylow
,
0.0
);
ydata_func
.
dummy_values
[
2
]
=
ydata_func
.
dummy_values
[
0
];
evaluate_at
(
ydata_func
.
at
,
&
val
);
ylow
=
undefined
?
0
:
real
(
&
val
);
(
void
)
Gcomplex
(
&
ydata_func
.
dummy_values
[
0
],
yhigh
,
0.0
);
ydata_func
.
dummy_values
[
2
]
=
ydata_func
.
dummy_values
[
0
];
evaluate_at
(
ydata_func
.
at
,
&
val
);
yhigh
=
undefined
?
0
:
real
(
&
val
);
}
dummy_type
=
cp
->
type
=
INRANGE
;
if
(
polar
) {
double
newx
,
newy
;
if
(!(
axis_array
[
R_AXIS
].
autoscale
&
AUTOSCALE_MAX
)
&&
y
>
axis_array
[
R_AXIS
].
max
) {
cp
->
type
=
OUTRANGE
;
}
if
(!(
axis_array
[
R_AXIS
].
autoscale
&
AUTOSCALE_MIN
)) {
/* we store internally as if plotting r(t)-rmin */
y
-=
axis_array
[
R_AXIS
].
min
;
}
newx
=
y
*
cos
(
x
*
ang2rad
);
newy
=
y
*
sin
(
x
*
ang2rad
);
y
=
newy
;
x
=
newx
;
if
(!(
axis_array
[
R_AXIS
].
autoscale
&
AUTOSCALE_MAX
)
&&
yhigh
>
axis_array
[
R_AXIS
].
max
) {
cp
->
type
=
OUTRANGE
;
}
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL