-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathsave.c
More file actions
1841 lines (1671 loc) · 52.7 KB
/
save.c
File metadata and controls
1841 lines (1671 loc) · 52.7 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: save.c,v 1.331 2017-09-11 20:13:24 sfeam Exp $"); }
#endif
/* GNUPLOT - save.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 "save.h"
#include "command.h"
#include "contour.h"
#include "datafile.h"
#include "eval.h"
#include "fit.h"
#include "gp_time.h"
#include "graphics.h"
#include "hidden3d.h"
#include "jitter.h"
#include "misc.h"
#include "plot2d.h"
#include "plot3d.h"
#include "setshow.h"
#include "term_api.h"
#include "util.h"
#include "variable.h"
#include "pm3d.h"
#include "getcolor.h"
static void save_functions__sub __PROTO((FILE *));
static void save_variables__sub __PROTO((FILE *));
static void save_tics __PROTO((FILE *, struct axis *));
static void save_mtics __PROTO((FILE *, struct axis *));
static void save_zeroaxis __PROTO((FILE *,AXIS_INDEX));
static void save_set_all __PROTO((FILE *));
const char *coord_msg[] = {"first ", "second ", "graph ", "screen ", "character ", "polar "};
/*
* functions corresponding to the arguments of the GNUPLOT `save` command
*/
void
save_functions(FILE *fp)
{
/* I _love_ information written at the top and the end
* of a human readable ASCII file. */
show_version(fp);
save_functions__sub(fp);
fputs("# EOF\n", fp);
}
void
save_variables(FILE *fp)
{
show_version(fp);
save_variables__sub(fp);
fputs("# EOF\n", fp);
}
void
save_set(FILE *fp)
{
show_version(fp);
save_set_all(fp);
fputs("# EOF\n", fp);
}
void
save_all(FILE *fp)
{
show_version(fp);
save_set_all(fp);
save_functions__sub(fp);
save_variables__sub(fp);
if (df_filename)
fprintf(fp, "## Last datafile plotted: \"%s\"\n", df_filename);
fprintf(fp, "%s\n", replot_line);
if (wri_to_fil_last_fit_cmd(NULL)) {
fputs("## ", fp);
wri_to_fil_last_fit_cmd(fp);
putc('\n', fp);
}
fputs("# EOF\n", fp);
}
/*
* auxiliary functions
*/
static void
save_functions__sub(FILE *fp)
{
struct udft_entry *udf = first_udf;
while (udf) {
if (udf->definition) {
fprintf(fp, "%s\n", udf->definition);
}
udf = udf->next_udf;
}
}
static void
save_variables__sub(FILE *fp)
{
/* always skip pi */
struct udvt_entry *udv = first_udv->next_udv;
while (udv) {
if (udv->udv_value.type != NOTDEFINED) {
if (udv->udv_value.type == ARRAY) {
fprintf(fp,"array %s[%d] = ", udv->udv_name,
udv->udv_value.v.value_array[0].v.int_val);
save_array_content(fp, udv->udv_value.v.value_array);
} else if (strncmp(udv->udv_name,"GPVAL_",6)
&& strncmp(udv->udv_name,"MOUSE_",6)
&& strncmp(udv->udv_name,"$",1)
&& (strncmp(udv->udv_name,"ARG",3) || (strlen(udv->udv_name) != 4))
&& strncmp(udv->udv_name,"NaN",4)) {
fprintf(fp, "%s = ", udv->udv_name);
disp_value(fp, &(udv->udv_value), TRUE);
(void) putc('\n', fp);
}
}
udv = udv->next_udv;
}
}
void
save_array_content(FILE *fp, struct value *array)
{
int i;
int size = array[0].v.int_val;
fprintf(fp, "[");
for (i=1; i<=size; i++) {
if (array[i].type != NOTDEFINED)
disp_value(fp, &(array[i]), TRUE);
if (i < size)
fprintf(fp, ",");
}
fprintf(fp, "]\n");
}
/* HBB 19990823: new function 'save term'. This will be mainly useful
* for the typical 'set term post ... plot ... set term <normal term>
* sequence. It's the only 'save' function that will write the
* current term setting to a file uncommentedly. */
void
save_term(FILE *fp)
{
show_version(fp);
/* A possible gotcha: the default initialization often doesn't set
* term_options, but a 'set term <type>' without options doesn't
* reset the options to startup defaults. This may have to be
* changed on a per-terminal driver basis... */
if (term)
fprintf(fp, "set terminal %s %s\n", term->name, term_options);
else
fputs("set terminal unknown\n", fp);
/* output will still be written in commented form. Otherwise, the
* risk of overwriting files is just too high */
if (outstr)
fprintf(fp, "# set output '%s'\n", outstr);
else
fputs("# set output\n", fp);
fputs("# EOF\n", fp);
}
static void
save_justification(int just, FILE *fp)
{
switch (just) {
case RIGHT:
fputs(" right", fp);
break;
case LEFT:
fputs(" left", fp);
break;
case CENTRE:
fputs(" center", fp);
break;
}
}
static void
save_set_all(FILE *fp)
{
struct text_label *this_label;
struct arrow_def *this_arrow;
struct linestyle_def *this_linestyle;
struct arrowstyle_def *this_arrowstyle;
legend_key *key = &keyT;
int axis;
/* opinions are split as to whether we save term and outfile
* as a compromise, we output them as comments !
*/
if (term)
fprintf(fp, "# set terminal %s %s\n", term->name, term_options);
else
fputs("# set terminal unknown\n", fp);
if (outstr)
fprintf(fp, "# set output '%s'\n", outstr);
else
fputs("# set output\n", fp);
fprintf(fp, "\
%sset clip points\n\
%sset clip one\n\
%sset clip two\n",
(clip_points) ? "" : "un",
(clip_lines1) ? "" : "un",
(clip_lines2) ? "" : "un"
);
save_bars(fp);
if (draw_border) {
fprintf(fp, "set border %d %s", draw_border,
border_layer == LAYER_BEHIND ? "behind" : border_layer == LAYER_BACK ? "back" : "front");
save_linetype(fp, &border_lp, FALSE);
fprintf(fp, "\n");
} else
fputs("unset border\n", fp);
for (axis = 0; axis < NUMBER_OF_MAIN_VISIBLE_AXES; axis++) {
if (axis == SAMPLE_AXIS) continue;
if (axis == COLOR_AXIS) continue;
if (axis == POLAR_AXIS) continue;
fprintf(fp, "set %sdata %s\n", axis_name(axis),
axis_array[axis].datatype == DT_TIMEDATE ? "time" :
axis_array[axis].datatype == DT_DMS ? "geographic" :
"");
}
if (boxwidth < 0.0)
fputs("set boxwidth\n", fp);
else
fprintf(fp, "set boxwidth %g %s\n", boxwidth,
(boxwidth_is_absolute) ? "absolute" : "relative");
fprintf(fp, "set style fill ");
save_fillstyle(fp, &default_fillstyle);
#ifdef EAM_OBJECTS
/* Default rectangle style */
fprintf(fp, "set style rectangle %s fc ",
default_rectangle.layer > 0 ? "front" :
default_rectangle.layer < 0 ? "behind" : "back");
save_pm3dcolor(fp, &default_rectangle.lp_properties.pm3d_color);
fprintf(fp, " fillstyle ");
save_fillstyle(fp, &default_rectangle.fillstyle);
/* Default circle properties */
fprintf(fp, "set style circle radius ");
save_position(fp, &default_circle.o.circle.extent, 1, FALSE);
fputs(" \n", fp);
/* Default ellipse properties */
fprintf(fp, "set style ellipse size ");
save_position(fp, &default_ellipse.o.ellipse.extent, 2, FALSE);
fprintf(fp, " angle %g ", default_ellipse.o.ellipse.orientation);
fputs("units ", fp);
switch (default_ellipse.o.ellipse.type) {
case ELLIPSEAXES_XY:
fputs("xy\n", fp);
break;
case ELLIPSEAXES_XX:
fputs("xx\n", fp);
break;
case ELLIPSEAXES_YY:
fputs("yy\n", fp);
break;
}
#endif
if (dgrid3d) {
if (dgrid3d_mode == DGRID3D_QNORM) {
fprintf(fp, "set dgrid3d %d,%d, %d\n",
dgrid3d_row_fineness,
dgrid3d_col_fineness,
dgrid3d_norm_value);
} else if (dgrid3d_mode == DGRID3D_SPLINES) {
fprintf(fp, "set dgrid3d %d,%d splines\n",
dgrid3d_row_fineness, dgrid3d_col_fineness );
} else {
fprintf(fp, "set dgrid3d %d,%d %s%s %f,%f\n",
dgrid3d_row_fineness,
dgrid3d_col_fineness,
reverse_table_lookup(dgrid3d_mode_tbl, dgrid3d_mode),
dgrid3d_kdensity ? " kdensity2d" : "",
dgrid3d_x_scale,
dgrid3d_y_scale );
}
}
/* Dummy variable names */
fprintf(fp, "set dummy %s", set_dummy_var[0]);
for (axis=1; axis<MAX_NUM_VAR; axis++) {
if (*set_dummy_var[axis] == '\0')
break;
fprintf(fp, ", %s", set_dummy_var[axis]);
}
fprintf(fp, "\n");
save_axis_format(fp, FIRST_X_AXIS );
save_axis_format(fp, FIRST_Y_AXIS );
save_axis_format(fp, SECOND_X_AXIS);
save_axis_format(fp, SECOND_Y_AXIS);
save_axis_format(fp, FIRST_Z_AXIS );
save_axis_format(fp, COLOR_AXIS);
save_axis_format(fp, POLAR_AXIS);
fprintf(fp, "set ttics format \"%s\"\n", THETA_AXIS.formatstring);
fprintf(fp, "set timefmt \"%s\"\n", timefmt);
fprintf(fp, "set angles %s\n",
(ang2rad == 1.0) ? "radians" : "degrees");
fprintf(fp,"set tics %s\n", grid_tics_in_front ? "front" : "back");
if (! some_grid_selected())
fputs("unset grid\n", fp);
else {
if (polar_grid_angle) /* set angle already output */
fprintf(fp, "set grid polar %f\n", polar_grid_angle / ang2rad);
else
fputs("set grid nopolar\n", fp);
#define SAVE_GRID(axis) \
fprintf(fp, " %s%stics %sm%stics", \
axis_array[axis].gridmajor ? "" : "no", \
axis_name(axis), \
axis_array[axis].gridminor ? "" : "no", \
axis_name(axis));
fputs("set grid", fp);
SAVE_GRID(FIRST_X_AXIS);
SAVE_GRID(FIRST_Y_AXIS);
SAVE_GRID(FIRST_Z_AXIS);
SAVE_GRID(POLAR_AXIS);
fputs(" \\\n", fp);
SAVE_GRID(SECOND_X_AXIS);
SAVE_GRID(SECOND_Y_AXIS);
SAVE_GRID(COLOR_AXIS);
fputs("\n", fp);
#undef SAVE_GRID
fprintf(fp, "set grid %s ", (grid_layer==-1) ? "layerdefault" : ((grid_layer==0) ? "back" : "front"));
save_linetype(fp, &grid_lp, FALSE);
fprintf(fp, ", ");
save_linetype(fp, &mgrid_lp, FALSE);
fputc('\n', fp);
}
fprintf(fp, "%sset raxis\n", raxis ? "" : "un");
/* Theta axis origin and direction */
fprintf(fp, "set theta %s %s\n",
theta_direction > 0 ? "counterclockwise" : "clockwise",
theta_origin == 180 ? "left" : theta_origin == 90 ? "top" :
theta_origin == -90 ? "bottom" : "right");
/* Save parallel axis state */
save_style_parallel(fp);
fprintf(fp, "set key title \"%s\"", conv_text(key->title.text));
if (key->title.font)
fprintf(fp, " font \"%s\" ", key->title.font);
save_justification(key->title.pos, fp);
fputs("\n", fp);
fputs("set key ", fp);
switch (key->region) {
case GPKEY_AUTO_INTERIOR_LRTBC:
fputs(key->fixed ? "fixed" : "inside", fp);
break;
case GPKEY_AUTO_EXTERIOR_LRTBC:
fputs("outside", fp);
break;
case GPKEY_AUTO_EXTERIOR_MARGIN:
switch (key->margin) {
case GPKEY_TMARGIN:
fputs("tmargin", fp);
break;
case GPKEY_BMARGIN:
fputs("bmargin", fp);
break;
case GPKEY_LMARGIN:
fputs("lmargin", fp);
break;
case GPKEY_RMARGIN:
fputs("rmargin", fp);
break;
}
break;
case GPKEY_USER_PLACEMENT:
fputs("at ", fp);
save_position(fp, &key->user_pos, 2, FALSE);
break;
}
if (!(key->region == GPKEY_AUTO_EXTERIOR_MARGIN
&& (key->margin == GPKEY_LMARGIN || key->margin == GPKEY_RMARGIN))) {
save_justification(key->hpos, fp);
}
if (!(key->region == GPKEY_AUTO_EXTERIOR_MARGIN
&& (key->margin == GPKEY_TMARGIN || key->margin == GPKEY_BMARGIN))) {
switch (key->vpos) {
case JUST_TOP:
fputs(" top", fp);
break;
case JUST_BOT:
fputs(" bottom", fp);
break;
case JUST_CENTRE:
fputs(" center", fp);
break;
}
}
fprintf(fp, " %s %s %sreverse %senhanced %s ",
key->stack_dir == GPKEY_VERTICAL ? "vertical" : "horizontal",
key->just == GPKEY_LEFT ? "Left" : "Right",
key->reverse ? "" : "no",
key->enhanced ? "" : "no",
key->auto_titles == COLUMNHEAD_KEYTITLES ? "autotitle columnhead"
: key->auto_titles == FILENAME_KEYTITLES ? "autotitle"
: "noautotitle" );
if (key->box.l_type > LT_NODRAW) {
fputs("box", fp);
save_linetype(fp, &(key->box), FALSE);
} else
fputs("nobox", fp);
/* These are for the key entries, not the key title */
if (key->font)
fprintf(fp, " font \"%s\"", key->font);
if (key->textcolor.type != TC_LT || key->textcolor.lt != LT_BLACK)
save_textcolor(fp, &key->textcolor);
/* Put less common options on separate lines */
fprintf(fp, "\nset key %sinvert samplen %g spacing %g width %g height %g ",
key->invert ? "" : "no",
key->swidth, key->vert_factor, key->width_fix, key->height_fix);
fprintf(fp, "\nset key maxcolumns %d maxrows %d",key->maxcols,key->maxrows);
fputc('\n', fp);
fprintf(fp, "set key %sopaque\n", key->front ? "" : "no");
if (!(key->visible))
fputs("unset key\n", fp);
fputs("unset label\n", fp);
for (this_label = first_label; this_label != NULL;
this_label = this_label->next) {
fprintf(fp, "set label %d \"%s\" at ",
this_label->tag,
conv_text(this_label->text));
save_position(fp, &this_label->place, 3, FALSE);
if (this_label->hypertext)
fprintf(fp, " hypertext");
save_justification(this_label->pos, fp);
if (this_label->rotate)
fprintf(fp, " rotate by %d", this_label->rotate);
else
fprintf(fp, " norotate");
if (this_label->font != NULL)
fprintf(fp, " font \"%s\"", this_label->font);
fprintf(fp, " %s", (this_label->layer==0) ? "back" : "front");
if (this_label->noenhanced)
fprintf(fp, " noenhanced");
save_textcolor(fp, &(this_label->textcolor));
if ((this_label->lp_properties.flags & LP_SHOW_POINTS) == 0)
fprintf(fp, " nopoint");
else {
fprintf(fp, " point");
save_linetype(fp, &(this_label->lp_properties), TRUE);
}
save_position(fp, &this_label->offset, 3, TRUE);
#ifdef EAM_BOXED_TEXT
if (this_label->boxed)
fprintf(fp," boxed ");
#endif
fputc('\n', fp);
}
fputs("unset arrow\n", fp);
for (this_arrow = first_arrow; this_arrow != NULL;
this_arrow = this_arrow->next) {
fprintf(fp, "set arrow %d from ", this_arrow->tag);
save_position(fp, &this_arrow->start, 3, FALSE);
if (this_arrow->type == arrow_end_absolute) {
fputs(" to ", fp);
save_position(fp, &this_arrow->end, 3, FALSE);
} else if (this_arrow->type == arrow_end_absolute) {
fputs(" rto ", fp);
save_position(fp, &this_arrow->end, 3, FALSE);
} else { /* type arrow_end_oriented */
struct position *e = &this_arrow->end;
fputs(" length ", fp);
fprintf(fp, "%s%g", e->scalex == first_axes ? "" : coord_msg[e->scalex], e->x);
fprintf(fp, " angle %g", this_arrow->angle);
}
fprintf(fp, " %s %s %s",
arrow_head_names[this_arrow->arrow_properties.head],
(this_arrow->arrow_properties.layer==0) ? "back" : "front",
(this_arrow->arrow_properties.headfill==AS_FILLED) ? "filled" :
(this_arrow->arrow_properties.headfill==AS_EMPTY) ? "empty" :
(this_arrow->arrow_properties.headfill==AS_NOBORDER) ? "noborder" :
"nofilled");
save_linetype(fp, &(this_arrow->arrow_properties.lp_properties), FALSE);
if (this_arrow->arrow_properties.head_length > 0) {
fprintf(fp, " size %s %.3f,%.3f,%.3f",
coord_msg[this_arrow->arrow_properties.head_lengthunit],
this_arrow->arrow_properties.head_length,
this_arrow->arrow_properties.head_angle,
this_arrow->arrow_properties.head_backangle);
}
fprintf(fp, "\n");
}
#if TRUE || defined(BACKWARDS_COMPATIBLE)
fprintf(fp, "set style increment %s\n", prefer_line_styles ? "userstyles" : "default");
#endif
fputs("unset style line\n", fp);
for (this_linestyle = first_linestyle; this_linestyle != NULL;
this_linestyle = this_linestyle->next) {
fprintf(fp, "set style line %d ", this_linestyle->tag);
save_linetype(fp, &(this_linestyle->lp_properties), TRUE);
fprintf(fp, "\n");
}
/* TODO save "set linetype" as well, or instead */
fputs("unset style arrow\n", fp);
for (this_arrowstyle = first_arrowstyle; this_arrowstyle != NULL;
this_arrowstyle = this_arrowstyle->next) {
fprintf(fp, "set style arrow %d", this_arrowstyle->tag);
fprintf(fp, " %s %s %s",
arrow_head_names[this_arrowstyle->arrow_properties.head],
(this_arrowstyle->arrow_properties.layer==0)?"back":"front",
(this_arrowstyle->arrow_properties.headfill==AS_FILLED)?"filled":
(this_arrowstyle->arrow_properties.headfill==AS_EMPTY)?"empty":
(this_arrowstyle->arrow_properties.headfill==AS_NOBORDER)?"noborder":
"nofilled");
save_linetype(fp, &(this_arrowstyle->arrow_properties.lp_properties), FALSE);
if (this_arrowstyle->arrow_properties.head_length > 0) {
fprintf(fp, " size %s %.3f,%.3f,%.3f",
coord_msg[this_arrowstyle->arrow_properties.head_lengthunit],
this_arrowstyle->arrow_properties.head_length,
this_arrowstyle->arrow_properties.head_angle,
this_arrowstyle->arrow_properties.head_backangle);
if (this_arrowstyle->arrow_properties.head_fixedsize) {
fputs(" ", fp);
fputs(" fixed", fp);
}
}
fprintf(fp, "\n");
}
fprintf(fp, "set style histogram ");
save_histogram_opts(fp);
#ifdef EAM_OBJECTS
fprintf(fp, "unset object\n");
save_object(fp, 0);
#endif
#ifdef EAM_BOXED_TEXT
fprintf(fp, "set style textbox");
save_style_textbox(fp);
#endif
save_offsets(fp, "set offsets");
/* FIXME */
fprintf(fp, "\
set pointsize %g\n\
set pointintervalbox %g\n\
set encoding %s\n\
%sset polar\n\
%sset parametric\n",
pointsize, pointintervalbox,
encoding_names[encoding],
(polar) ? "" : "un",
(parametric) ? "" : "un");
if (numeric_locale)
fprintf(fp, "set decimalsign locale \"%s\"\n", numeric_locale);
if (decimalsign != NULL)
fprintf(fp, "set decimalsign '%s'\n", decimalsign);
if (!numeric_locale && !decimalsign)
fprintf(fp, "unset decimalsign\n");
fprintf(fp, "%sset micro\n", use_micro ? "" : "un");
fprintf(fp, "%sset minussign\n", use_minus_sign ? "" : "un");
fputs("set view ", fp);
if (splot_map == TRUE)
fprintf(fp, "map scale %g", mapview_scale);
else {
fprintf(fp, "%g, %g, %g, %g",
surface_rot_x, surface_rot_z, surface_scale, surface_zscale);
fprintf(fp, "\nset view azimuth %g", azimuth);
}
if (aspect_ratio_3D)
fprintf(fp, "\nset view %s", aspect_ratio_3D == 2 ? "equal xy" :
aspect_ratio_3D == 3 ? "equal xyz": "");
fprintf(fp, "\nset rgbmax %g", rgbmax);
fprintf(fp, "\n\
set samples %d, %d\n\
set isosamples %d, %d\n\
%sset surface %s",
samples_1, samples_2,
iso_samples_1, iso_samples_2,
(draw_surface) ? "" : "un",
(implicit_surface) ? "" : "explicit");
fprintf(fp, "\n\
%sset contour", (draw_contour) ? "" : "un");
switch (draw_contour) {
case CONTOUR_NONE:
fputc('\n', fp);
break;
case CONTOUR_BASE:
fputs(" base\n", fp);
break;
case CONTOUR_SRF:
fputs(" surface\n", fp);
break;
case CONTOUR_BOTH:
fputs(" both\n", fp);
break;
}
/* Contour label options */
fprintf(fp, "set cntrlabel %s format '%s' font '%s' start %d interval %d\n",
clabel_onecolor ? "onecolor" : "", contour_format,
clabel_font ? clabel_font : "",
clabel_start, clabel_interval);
fputs("set mapping ", fp);
switch (mapping3d) {
case MAP3D_SPHERICAL:
fputs("spherical\n", fp);
break;
case MAP3D_CYLINDRICAL:
fputs("cylindrical\n", fp);
break;
case MAP3D_CARTESIAN:
default:
fputs("cartesian\n", fp);
break;
}
if (missing_val != NULL)
fprintf(fp, "set datafile missing '%s'\n", missing_val);
if (df_separators)
fprintf(fp, "set datafile separator \"%s\"\n",df_separators);
else
fprintf(fp, "set datafile separator whitespace\n");
if (strcmp(df_commentschars, DEFAULT_COMMENTS_CHARS))
fprintf(fp, "set datafile commentschars '%s'\n", df_commentschars);
if (df_fortran_constants)
fprintf(fp, "set datafile fortran\n");
if (df_nofpe_trap)
fprintf(fp, "set datafile nofpe_trap\n");
save_hidden3doptions(fp);
fprintf(fp, "set cntrparam order %d\n", contour_order);
fputs("set cntrparam ", fp);
switch (contour_kind) {
case CONTOUR_KIND_LINEAR:
fputs("linear\n", fp);
break;
case CONTOUR_KIND_CUBIC_SPL:
fputs("cubicspline\n", fp);
break;
case CONTOUR_KIND_BSPLINE:
fputs("bspline\n", fp);
break;
}
fputs("set cntrparam levels ", fp);
switch (contour_levels_kind) {
case LEVELS_AUTO:
fprintf(fp, "auto %d\n", contour_levels);
break;
case LEVELS_INCREMENTAL:
fprintf(fp, "incremental %g,%g,%g\n",
contour_levels_list[0], contour_levels_list[1],
contour_levels_list[0] + contour_levels_list[1] * contour_levels);
break;
case LEVELS_DISCRETE:
{
int i;
fprintf(fp, "discrete %g", contour_levels_list[0]);
for (i = 1; i < contour_levels; i++)
fprintf(fp, ",%g ", contour_levels_list[i]);
fputc('\n', fp);
}
}
fprintf(fp, "\
set cntrparam points %d\n\
set size ratio %g %g,%g\n\
set origin %g,%g\n",
contour_pts,
aspect_ratio, xsize, ysize,
xoffset, yoffset);
fprintf(fp, "set style data ");
save_data_func_style(fp,"data",data_style);
fprintf(fp, "set style function ");
save_data_func_style(fp,"function",func_style);
save_zeroaxis(fp, FIRST_X_AXIS);
save_zeroaxis(fp, FIRST_Y_AXIS);
save_zeroaxis(fp, FIRST_Z_AXIS);
save_zeroaxis(fp, SECOND_X_AXIS);
save_zeroaxis(fp, SECOND_Y_AXIS);
if (xyplane.absolute)
fprintf(fp, "set xyplane at %g\n", xyplane.z);
else
fprintf(fp, "set xyplane relative %g\n", xyplane.z);
{
int i;
fprintf(fp, "set tics scale ");
for (i=0; i<MAX_TICLEVEL; i++)
fprintf(fp, " %g%c", ticscale[i], i<MAX_TICLEVEL-1 ? ',' : '\n');
}
save_mtics(fp, &axis_array[FIRST_X_AXIS]);
save_mtics(fp, &axis_array[FIRST_Y_AXIS]);
save_mtics(fp, &axis_array[FIRST_Z_AXIS]);
save_mtics(fp, &axis_array[SECOND_X_AXIS]);
save_mtics(fp, &axis_array[SECOND_Y_AXIS]);
save_mtics(fp, &axis_array[COLOR_AXIS]);
save_mtics(fp, &R_AXIS);
save_mtics(fp, &THETA_AXIS);
save_tics(fp, &axis_array[FIRST_X_AXIS]);
save_tics(fp, &axis_array[FIRST_Y_AXIS]);
save_tics(fp, &axis_array[FIRST_Z_AXIS]);
save_tics(fp, &axis_array[SECOND_X_AXIS]);
save_tics(fp, &axis_array[SECOND_Y_AXIS]);
save_tics(fp, &axis_array[COLOR_AXIS]);
save_tics(fp, &R_AXIS);
save_tics(fp, &THETA_AXIS);
for (axis=0; axis<num_parallel_axes; axis++)
save_tics(fp, ¶llel_axis[axis]);
#define SAVE_AXISLABEL_OR_TITLE(name,suffix,lab) \
{ \
fprintf(fp, "set %s%s \"%s\" ", \
name, suffix, lab.text ? conv_text(lab.text) : ""); \
fprintf(fp, "\nset %s%s ", name, suffix); \
save_position(fp, &(lab.offset), 3, TRUE); \
fprintf(fp, " font \"%s\"", lab.font ? conv_text(lab.font) : "");\
save_textcolor(fp, &(lab.textcolor)); \
if (lab.tag == ROTATE_IN_3D_LABEL_TAG) \
fprintf(fp, " rotate parallel"); \
else if (lab.rotate == TEXT_VERTICAL) \
fprintf(fp, " rotate"); \
else if (lab.rotate) \
fprintf(fp, " rotate by %d", lab.rotate); \
else \
fprintf(fp, " norotate"); \
fprintf(fp, "%s\n", (lab.noenhanced) ? " noenhanced" : ""); \
}
SAVE_AXISLABEL_OR_TITLE("", "title", title);
fprintf(fp, "set timestamp %s \n", timelabel_bottom ? "bottom" : "top");
SAVE_AXISLABEL_OR_TITLE("", "timestamp", timelabel);
save_prange(fp, axis_array + T_AXIS);
save_prange(fp, axis_array + U_AXIS);
save_prange(fp, axis_array + V_AXIS);
#define SAVE_AXISLABEL(axis) \
SAVE_AXISLABEL_OR_TITLE(axis_name(axis),"label", \
axis_array[axis].label)
SAVE_AXISLABEL(FIRST_X_AXIS);
SAVE_AXISLABEL(SECOND_X_AXIS);
save_prange(fp, axis_array + FIRST_X_AXIS);
save_prange(fp, axis_array + SECOND_X_AXIS);
SAVE_AXISLABEL(FIRST_Y_AXIS);
SAVE_AXISLABEL(SECOND_Y_AXIS);
save_prange(fp, axis_array + FIRST_Y_AXIS);
save_prange(fp, axis_array + SECOND_Y_AXIS);
SAVE_AXISLABEL(FIRST_Z_AXIS);
save_prange(fp, axis_array + FIRST_Z_AXIS);
SAVE_AXISLABEL(COLOR_AXIS);
save_prange(fp, axis_array + COLOR_AXIS);
SAVE_AXISLABEL(POLAR_AXIS);
save_prange(fp, axis_array + POLAR_AXIS);
for (axis=0; axis<num_parallel_axes; axis++)
save_prange(fp, ¶llel_axis[axis]);
#undef SAVE_AXISLABEL
#undef SAVE_AXISLABEL_OR_TITLE
fputs("unset logscale\n", fp);
for (axis = 0; axis < NUMBER_OF_MAIN_VISIBLE_AXES; axis++) {
if (axis_array[axis].log)
fprintf(fp, "set logscale %s %g\n", axis_name(axis),
axis_array[axis].base);
else
save_nonlinear(fp, &axis_array[axis]);
}
/* These will only print something if the axis is, in fact, linked */
save_link(fp, axis_array + SECOND_X_AXIS);
save_link(fp, axis_array + SECOND_Y_AXIS);
save_jitter(fp);
fprintf(fp, "set zero %g\n", zero);
fprintf(fp, "set lmargin %s %g\n",
lmargin.scalex == screen ? "at screen" : "", lmargin.x);
fprintf(fp, "set bmargin %s %g\n",
bmargin.scalex == screen ? "at screen" : "", bmargin.x);
fprintf(fp, "set rmargin %s %g\n",
rmargin.scalex == screen ? "at screen" : "", rmargin.x);
fprintf(fp, "set tmargin %s %g\n",
tmargin.scalex == screen ? "at screen" : "", tmargin.x);
fprintf(fp, "set locale \"%s\"\n", get_time_locale());
/* pm3d options */
fputs("set pm3d ", fp);
fputs((PM3D_IMPLICIT == pm3d.implicit ? "implicit" : "explicit"), fp);
fprintf(fp, " at %s\n", pm3d.where);
fputs("set pm3d ", fp);
switch (pm3d.direction) {
case PM3D_SCANS_AUTOMATIC: fputs("scansautomatic\n", fp); break;
case PM3D_SCANS_FORWARD: fputs("scansforward\n", fp); break;
case PM3D_SCANS_BACKWARD: fputs("scansbackward\n", fp); break;
case PM3D_DEPTH: fputs("depthorder\n", fp); break;
}
fprintf(fp, "set pm3d interpolate %d,%d", pm3d.interp_i, pm3d.interp_j);
fputs(" flush ", fp);
switch (pm3d.flush) {
case PM3D_FLUSH_CENTER: fputs("center", fp); break;
case PM3D_FLUSH_BEGIN: fputs("begin", fp); break;
case PM3D_FLUSH_END: fputs("end", fp); break;
}
fputs((pm3d.ftriangles ? " " : " no"), fp);
fputs("ftriangles", fp);
if (pm3d.border.l_type == LT_NODRAW) {
fprintf(fp," noborder");
} else {
fprintf(fp," border");
save_linetype(fp, &(pm3d.border), FALSE);
}
fputs(" corners2color ", fp);
switch (pm3d.which_corner_color) {
case PM3D_WHICHCORNER_MEAN: fputs("mean", fp); break;
case PM3D_WHICHCORNER_GEOMEAN: fputs("geomean", fp); break;
case PM3D_WHICHCORNER_HARMEAN: fputs("harmean", fp); break;
case PM3D_WHICHCORNER_MEDIAN: fputs("median", fp); break;
case PM3D_WHICHCORNER_MIN: fputs("min", fp); break;
case PM3D_WHICHCORNER_MAX: fputs("max", fp); break;
case PM3D_WHICHCORNER_RMS: fputs("rms", fp); break;
default: /* PM3D_WHICHCORNER_C1 ... _C4 */
fprintf(fp, "c%i", pm3d.which_corner_color - PM3D_WHICHCORNER_C1 + 1);
}
fputs("\n", fp);
if (pm3d_shade.strength <= 0)
fputs("set pm3d nolighting\n",fp);
else
fprintf(fp, "set pm3d lighting primary %g specular %g\n", pm3d_shade.strength, pm3d_shade.spec);
/*
* Save palette information
*/
fprintf( fp, "set palette %s %s maxcolors %d ",
sm_palette.positive==SMPAL_POSITIVE ? "positive" : "negative",
sm_palette.ps_allcF ? "ps_allcF" : "nops_allcF",
sm_palette.use_maxcolors);
fprintf( fp, "gamma %g ", sm_palette.gamma );
if (sm_palette.colorMode == SMPAL_COLOR_MODE_GRAY) {
fputs( "gray\n", fp );
}
else {
fputs( "color model ", fp );
switch( sm_palette.cmodel ) {
default:
case C_MODEL_RGB: fputs( "RGB ", fp ); break;
case C_MODEL_HSV: fputs( "HSV ", fp ); break;
case C_MODEL_CMY: fputs( "CMY ", fp ); break;
case C_MODEL_YIQ: fputs( "YIQ ", fp ); break;
case C_MODEL_XYZ: fputs( "XYZ ", fp ); break;
}
fputs( "\nset palette ", fp );
switch( sm_palette.colorMode ) {
default:
case SMPAL_COLOR_MODE_RGB:
fprintf( fp, "rgbformulae %d, %d, %d\n", sm_palette.formulaR,
sm_palette.formulaG, sm_palette.formulaB );
break;
case SMPAL_COLOR_MODE_GRADIENT: {
int i=0;
fprintf( fp, "defined (" );
for (i=0; i<sm_palette.gradient_num; i++) {
fprintf( fp, " %.4g %.4g %.4g %.4g", sm_palette.gradient[i].pos,
sm_palette.gradient[i].col.r, sm_palette.gradient[i].col.g,
sm_palette.gradient[i].col.b );
if (i<sm_palette.gradient_num-1) {
fputs( ",", fp);
if (i==2 || i%4==2) fputs( "\\\n ", fp );
}
}
fputs( " )\n", fp );
break;
}
case SMPAL_COLOR_MODE_FUNCTIONS:
fprintf( fp, "functions %s, %s, %s\n", sm_palette.Afunc.definition,
sm_palette.Bfunc.definition, sm_palette.Cfunc.definition );
break;
case SMPAL_COLOR_MODE_CUBEHELIX:
fprintf( fp, "cubehelix start %.2g cycles %.2g saturation %.2g\n",
sm_palette.cubehelix_start, sm_palette.cubehelix_cycles,
sm_palette.cubehelix_saturation);
break;
}
}
/*
* Save colorbox info
*/
if (color_box.where != SMCOLOR_BOX_NO)
fprintf(fp,"set colorbox %s\n", color_box.where==SMCOLOR_BOX_DEFAULT ? "default" : "user");
fprintf(fp, "set colorbox %sal origin ", color_box.rotation == 'v' ? "vertic" : "horizont");
save_position(fp, &color_box.origin, 2, FALSE);
fputs(" size ", fp);
save_position(fp, &color_box.size, 2, FALSE);
fprintf(fp, " %s ", color_box.layer == LAYER_FRONT ? "front" : "back");
fprintf(fp, " %sinvert ", color_box.invert ? "" : "no");
if (color_box.border == 0) fputs("noborder", fp);
else if (color_box.border_lt_tag < 0) fputs("bdefault", fp);
else fprintf(fp, "border %d", color_box.border_lt_tag);
if (color_box.where == SMCOLOR_BOX_NO) fputs("\nunset colorbox\n", fp);
else fputs("\n", fp);
fprintf(fp, "set style boxplot %s %s %5.2f %soutliers pt %d separation %g labels %s %ssorted\n",
boxplot_opts.plotstyle == FINANCEBARS ? "financebars" : "candles",
boxplot_opts.limit_type == 1 ? "fraction" : "range",
boxplot_opts.limit_value,
boxplot_opts.outliers ? "" : "no",
boxplot_opts.pointtype+1,
boxplot_opts.separation,
(boxplot_opts.labels == BOXPLOT_FACTOR_LABELS_X) ? "x" :
(boxplot_opts.labels == BOXPLOT_FACTOR_LABELS_X2) ? "x2" :
(boxplot_opts.labels == BOXPLOT_FACTOR_LABELS_AUTO) ? "auto" :"off",
boxplot_opts.sort_factors ? "" : "un");
fputs("set loadpath ", fp);
{
char *s;
while ((s = save_loadpath()) != NULL)