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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2004 - INRIA - Serge Steer
// Copyright (C) 2004-2006 - INRIA - Fabrice Leray
// Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
// Copyright (C) 2010 - DIGITEO - Manuel Juliachs
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
function h=%h_load(fd)
global init_immediate_drawing
init_immediate_drawing = 0;
version=mget(4,"uc",fd)
// saving/loading character with 'c' is actually quite buggy
characterFormat = "uc";
stringFormat = "il";
immediate_drawing="";
h=[];
if is_higher_than([3 1 0 1]) then // case 3 1 0 2 and after
hsize = mget(2,characterFormat,fd)
for i=1:hsize(1)
for j=1:hsize(2)
[htmp,immediate_drawing] = load_graphichandle(fd)
h = [h htmp];
end
end
else
[h,immediate_drawing] = load_graphichandle(fd) // a single handle only can be loaded before 3 1 0 2
end
f=gcf();
f.immediate_drawing = immediate_drawing;
clearglobal init_immediate_drawing
clear init_immediate_drawing
endfunction
function [h,immediate_drawing] = load_graphichandle(fd)
global init_immediate_drawing
typ=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))
if typ<>"Figure"
f=gcf();
if init_immediate_drawing == 0
immediate_drawing = f.immediate_drawing;
f.immediate_drawing ="off";
init_immediate_drawing = 1;
end
end
// mprintf('----------------------------- %s ----------------------\n',typ)
// Determines whether %h_load has been called by the xload macro
// in which case xload_mode is set to true
[lnums, fnames] = where();
ind = grep(fnames, "xload");
xload_mode = (ind ~= []);
select typ
case "Figure"
if xload_mode then
h=gcf()
visible=toggle(mget(1,characterFormat,fd)); // visible
figure_position=mget(2,"sl",fd); // figure_position
figure_size=mget(2,"sl",fd); // figure_size
axes_size=mget(2,"sl",fd); //axes_size
if ( is_higher_than([4 1 2 0]) ) then
viewport = mget(2,"sl",fd) ; // viewport
if is_higher_than([5 4 0 0]) then
info_message = ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) ; // info_message
else
info_message = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // info_message
end
tag = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // tag
end
auto_resize=toggle(mget(1,characterFormat,fd)); // auto_resize
if is_higher_than([5 4 0 0]) then
figure_name=ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) // figure_name
else
figure_name=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // figure_name
end
figure_id=mget(1,"sl",fd); // figure_id
h.color_map=matrix(mget(mget(1,"il",fd),"dl",fd),-1,3) // color_map
if ~is_higher_than([5 4 0 1]) then
pixmap=toggle(mget(1,characterFormat,fd)); // pixmap, removed from V5.5.0 on
end
pixel_drawing_mode=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // pixel_drawing_mode
if (is_higher_than([5 1 0 0])) then
anti_aliasing=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // anti_aliasing
end
immediate_drawing=toggle(mget(1,characterFormat,fd));// immediate drawing // init. global variable immediate_drawing
h.immediate_drawing = "off"; // set it to 'off' to pass useless redraw due to several 'set' calls
h.background=mget(1,"il",fd) // background
rotation_style=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // rotation_style
else
visible=toggle(mget(1,characterFormat,fd)); // visible
figure_position=mget(2,"sl",fd); // figure_position
// if figure is iconified in old scilab version, its position is -32000, -32000]
figure_position = max(figure_position, [0,0]);
figure_size=mget(2,"sl",fd); // figure_size
axes_size=mget(2,"sl",fd); // axes_size
if ( is_higher_than([4 1 2 0]) ) then
viewport = mget(2,"sl",fd) ; // viewport
if is_higher_than([5 4 0 0]) then
info_message = ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) ; // info_message
else
info_message = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // info_message
end
tag = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // tag
end
auto_resize=toggle(mget(1,characterFormat,fd)); // auto_resize
if is_higher_than([5 4 0 0]) then
figure_name=ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) // figure_name
else
figure_name=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // figure_name
end
figure_id=mget(1,"sl",fd); // figure_id
// create the figure
h=scf(figure_id);
h.visible=visible; // can be set now as we act on immediate_drawing everywhere else F.Leray 18.02.05
h.figure_position=figure_position
// set auto_resize first otherwise viewport modification may not have any effect.
h.auto_resize = auto_resize;
h.figure_size = figure_size;
// set axes_size last because it's more important than figure_size
h.axes_size = axes_size;
if ( is_higher_than([4 1 2 0]) ) then
h.viewport = viewport;
h.info_message = info_message ;
h.tag = tag ;
end
h.figure_name=figure_name
h.color_map=matrix(mget(mget(1,"il",fd),"dl",fd),-1,3) // color_map
if ~is_higher_than([5 4 0 1]) then
pixmap=toggle(mget(1,characterFormat,fd)); // pixmap, removed from V5.5.0 on
end
h.pixel_drawing_mode=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // pixel_drawing_mode
if (is_higher_than([5 1 0 0])) then
h.anti_aliasing=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // anti_aliasing
end
immediate_drawing=toggle(mget(1,characterFormat,fd)); // immediate_drawing // init. global variable immediate_drawing
h.immediate_drawing = "off"; // set it to 'off' to pass useless redraw due to several 'set' calls
h.background=mget(1,"il",fd); // background
h.rotation_style = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // rotation_style
end
if ( is_higher_than([4 1 2 0]) ) then
h.event_handler = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // event_handler
h.event_handler_enable = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // event_handler_enable
end
if ( is_higher_than([5 2 0 0]) ) then // Added in 5.4.0 version
h.resizefcn = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // resizefcn
h.closerequestfcn = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // closerequestfcn
end
// children
n_axes=mget(1,"il",fd);
if n_axes==1 then
load_graphichandle(fd)
else
load_graphichandle(fd);
for k=2:n_axes
xsetech(wrect=[0 0 .1 .1])
load_graphichandle(fd)
end
end
load_user_data(fd); // user_data
case "Axes"
// Hack to determine whether %h_load has been called by the %h_copy macro
// in which case a new Axes object is created
[lnums, fnames]=where();
ind=grep(fnames, "%h_copy");
if(ind<>[]) then
newaxes();
end;
a=gca() ;
titl=a.title ;
x_label=a.x_label ;
y_label=a.y_label ;
set(a,"visible" , toggle(mget(1,characterFormat,fd))) // visible
if and(version==[3 0 0 0]) then // axes_visible
axes_visible= toggle(mget(1,characterFormat,fd));
axes_visible=emptystr(1,3)+axes_visible
else
axes_visible= toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)) ;
end
if is_higher_than( [3 1 0 1] ) then // axes_reverse
axes_reverse = toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)) ;
end
set(a,"axes_visible", axes_visible)
set(a,"axes_reverse", axes_reverse)
set(a,"grid" , mget(mget(1,characterFormat,fd),"il",fd)) //grid
if (is_higher_than([5 0 3 0])) then
set(a,"grid_position",ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))); // grid_position
else
set(a,"grid_position","background"); // grid_position
end
set(a,"x_location" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // x_location
set(a,"y_location" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // y_location
view = ascii(mget(2,characterFormat,fd)); // view
// title
set(titl,"visible" , toggle(mget(1,characterFormat,fd))) // title.visible
if is_higher_than( [4 1 2 0] ) then
set(titl, "text", load_text_matrix( fd ) ) ;
else
set(titl,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text
end
if is_higher_than([4 1 2 0]) then
set(titl,"font_foreground", mget(1,"il",fd)); // title.font_foreground
set(titl,"fractional_font", toggle(mget(1,characterFormat,fd))); //title.fractional_font
end
set(titl,"foreground", mget(1,"il",fd)); // title.foreground
if is_higher_than([3 1 0 0]) then
set(titl,"background" , mget(1,"il",fd)); // title.background
set(titl,"fill_mode" , toggle(mget(1,characterFormat,fd))); //title.fill_mode
end
set(titl,"font_style" , mget(1,characterFormat,fd)); // title.font_style
set(titl,"font_size" , mget(1,characterFormat,fd)); // title.font_size
if is_higher_than([3 1 0 0]) then
auto_rotation = toggle(mget(1,characterFormat,fd)) ; // title.auto_rotation
set(titl,"font_angle" , mget(1,"dl",fd)); // title.font_angle
auto_position = toggle(mget(1,characterFormat,fd)) ; // title.auto_position
set(titl,"position" , mget(2,"dl",fd)); // title.position
set( titl, "auto_rotation", auto_rotation ) ;
set( titl, "auto_position", auto_position ) ;
end
// x_label
set(x_label,"visible" , toggle(mget(1,characterFormat,fd))) // x_label.visible
if is_higher_than( [4 1 2 0] ) then
set(x_label, "text", load_text_matrix( fd ) ) ;
else
set(x_label,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text
end
if is_higher_than([4 1 2 0]) then
set(x_label,"font_foreground", mget(1,"il",fd)); // x_label.font_foreground
set(x_label,"fractional_font", toggle(mget(1,characterFormat,fd))); //x_label.fractional_font
end
set(x_label,"foreground", mget(1,"il",fd)); // x_label.foreground
if is_higher_than([3 0 0 0]) then
set(x_label,"background" , mget(1,"il",fd)); // x_label.background
set(x_label,"fill_mode" , toggle(mget(1,characterFormat,fd))); // x_label.fill_mode
end
set(x_label,"font_style" , mget(1,characterFormat,fd)); // x_label.font_style
set(x_label,"font_size" , mget(1,characterFormat,fd)); // x_label.font_size
if is_higher_than([3 0 0 0]) then
auto_rotation = toggle(mget(1,characterFormat,fd)) ; // x_label.auto_rotation
set(x_label,"font_angle" , mget(1,"dl",fd)); // x_label.font_angle
auto_position = toggle(mget(1,characterFormat,fd)) ; // x_label.auto_position
set( x_label,"position" , mget(2,"dl",fd)); // x_label.position
set( x_label, "auto_rotation", auto_rotation ) ;
set( x_label, "auto_position", auto_position ) ;
end
// y_label
set(y_label,"visible" , toggle(mget(1,characterFormat,fd)))
if is_higher_than( [4 1 2 0] ) then
set(y_label, "text", load_text_matrix( fd ) ) ;
else
set(y_label,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text
end
if is_higher_than([4 1 2 0]) then
set(y_label,"font_foreground", mget(1,"il",fd)); // y_label.font_foreground
set(y_label,"fractional_font", toggle(mget(1,characterFormat,fd))); //y_label.fractional_font
end
set(y_label,"foreground" , mget(1,"il",fd));
if is_higher_than([3 0 0 0]) then
set(y_label,"background" , mget(1,"il",fd));
set(y_label,"fill_mode" , toggle(mget(1,characterFormat,fd)));
end
set(y_label,"font_style" , mget(1,characterFormat,fd));
set(y_label,"font_size" , mget(1,characterFormat,fd));
if is_higher_than([3 0 0 0]) then
auto_rotation = toggle(mget(1,characterFormat,fd)) ; // y_label.auto_rotation
set(y_label,"font_angle" , mget(1,"dl",fd)); // y_label.font_angle
auto_position = toggle(mget(1,characterFormat,fd)) ; // y_label.auto_position
set( y_label,"position" , mget(2,"dl",fd)); // y_label.position
set( y_label, "auto_rotation", auto_rotation ) ;
set( y_label, "auto_position", auto_position ) ;
end
if view=="3d" then
// z_label
z_label=a.z_label
set(z_label,"visible" , toggle(mget(1,characterFormat,fd)))
if is_higher_than( [4 1 2 0] ) then
set(z_label, "text", load_text_matrix( fd ) ) ;
else
set(z_label,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text
end
if is_higher_than([4 1 2 0]) then
set(z_label,"font_foreground", mget(1,"il",fd)); // z_label.font_foreground
set(z_label,"fractional_font", toggle(mget(1,characterFormat,fd))); //z_label.fractional_font
end
set(z_label,"foreground" , mget(1,"il",fd));
if is_higher_than([3 0 0 0]) then
set(z_label,"background" , mget(1,"il",fd));
set(z_label,"fill_mode" , toggle(mget(1,characterFormat,fd)));
end
set(z_label,"font_style" , mget(1,characterFormat,fd));
set(z_label,"font_size" , mget(1,characterFormat,fd));
if is_higher_than([3 0 0 0]) then
auto_rotation = toggle(mget(1,characterFormat,fd)) ; // z_label.auto_rotation
set(z_label,"font_angle" , mget(1,"dl",fd)); // z_label.font_angle
auto_position = toggle(mget(1,characterFormat,fd)) ; // z_label.auto_position
set( z_label,"position" , mget(2,"dl",fd)); // z_label.position
set( z_label, "auto_rotation", auto_rotation ) ;
set( z_label, "auto_position", auto_position ) ;
end
end
if is_higher_than([3 0 0 0]) then
auto_ticks=toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)); // auto_ticks
ticks=["ticks","locations","labels"]
sz=mget(1,"sl",fd) // x_ticks.locations
if sz>0 then
x_ticks_locations=mget(sz,"dl",fd)'
lz=mget(sz,characterFormat,fd) // x_ticks.label
x_ticks_labels=[];for ks=1:sz,x_ticks_labels(ks)=ascii(mget(lz(ks),characterFormat,fd));end
set(a,"x_ticks",tlist(ticks,x_ticks_locations,x_ticks_labels))
end
sz=mget(1,"sl",fd) // y_ticks.locations
if sz>0 then
y_ticks_locations=mget(sz,"dl",fd)'
lz=mget(sz,characterFormat,fd) // y_ticks.label
y_ticks_labels=[];for ks=1:sz,y_ticks_labels(ks)=ascii(mget(lz(ks),characterFormat,fd));end
set(a,"y_ticks",tlist(ticks,y_ticks_locations,y_ticks_labels))
end
sz=mget(1,"sl",fd) // z_ticks.locations
if sz>0 then
z_ticks_locations=mget(sz,"dl",fd)'
lz=mget(sz,characterFormat,fd) // z_ticks.labels
z_ticks_labels=[];for ks=1:sz,z_ticks_labels(ks)=ascii(mget(lz(ks),characterFormat,fd));end
set(a,"z_ticks",tlist(ticks,z_ticks_locations,z_ticks_labels))
end
set(a,"auto_ticks" , auto_ticks)
end
if is_higher_than([4 1 2 0]) then
// migth be now 'off','hidden_axis','back_half' or 'on'
boxtype = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ;
set( a, "box", boxtype ) // box
set(a,"filled", toggle(mget(1,characterFormat,fd) )); // filled
else
set(a, "box", toggle(mget(1,characterFormat,fd) ) ) // box
end
set(a,"sub_tics" , mget(mget(1,characterFormat,fd),characterFormat,fd)) // sub_tics
if ~(is_higher_than([3 1 0 1]) ) then
mget(1,"il",fd); // tics_color is removed F.Leray 15.03.05
end
set(a,"font_style" , mget(1,characterFormat,fd)); // font_style
set(a,"font_size" , mget(1,characterFormat,fd)); // font_size
set(a,"font_color" , mget(1,"il",fd)); // font_color
if is_higher_than([4 1 2 0]) then
set(a,"fractional_font", toggle(mget(1,characterFormat,fd))); // fractional_font
end
set(a,"isoview" , toggle(mget(1,characterFormat,fd))) // isoview
cube_scaling = toggle(mget(1,characterFormat,fd)) // cube_scaling
rotation_angles = mget(2,"dl",fd); // rotation_angles
if a.view=="2d" then
set(a,"view" , view);
end
if a.view=="3d" then
set(a,"cube_scaling" , cube_scaling)
if view=="3d" then
set(a,"rotation_angles" , rotation_angles)
end
end
if is_higher_than([3 0 0 0]) then // log_flags
log_flags= ascii(mget(3,characterFormat,fd));
else
log_flags= ascii(mget(2,characterFormat,fd));
end
// tight_limits
if is_higher_than([5 5 0 0]) then
tight_limits=toggle(mget(mget(1,characterFormat,fd),characterFormat,fd));
else
tight_limits=toggle(mget(1,characterFormat,fd));
end
set(a,"tight_limits",tight_limits);
data_bounds = matrix(mget(mget(1,characterFormat,fd),"dl",fd),2,-1) // data_bounds
if view=="2d"& a.view=="3d" then
data_bounds(2,3)=0;
end
if xload_mode
// check if a had at least a child previously
// if not the axes is considered unused
// and we don't merge the data_bounds.
if a.children <> [] then
old_bounds=a.data_bounds;
for k=1:size(old_bounds,2)
data_bounds(1,k)=min(data_bounds(1,k),old_bounds(1,k));
data_bounds(2,k)=max(data_bounds(2,k),old_bounds(2,k));
end
end
end
if is_higher_than([3 0 0 0]) then
zoom_box_size = mget(1,characterFormat,fd);
if zoom_box_size<>0 then
set(a,"zoom_box" , mget(zoom_box_size,"dl",fd)) // zoom_box
end
end
if is_higher_than([3 1 0 1]) then
set(a,"margins" , mget(4,"dl",fd)) // margins
end
set(a,"axes_bounds" , mget(4,"dl",fd)) // axes_bounds
set(a,"auto_clear" , toggle(mget(1,characterFormat,fd))) // auto_clear
set(a,"auto_scale" , toggle(mget(1,characterFormat,fd))) // auto_scale
if is_higher_than([4 1 2 0] ) then // 4 0 0 0 and after
set(a,"hidden_axis_color", mget(1,"il",fd)) ; // hidden_axis_color
set(a, "arc_drawing_method", ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))); // arc_drawing_method
else
set(a, "arc_drawing_method", "nurbs"); // default value, real circle
end
set(a,"hiddencolor" , mget(1,"il",fd)), // hidden_color
set(a,"line_mode" , toggle(mget(1,characterFormat,fd))), // line_mode
line_style = mget(1,characterFormat,fd);
if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0
line_style=1;
end
set(a,"line_style" , line_style) // line_style
set(a,"thickness" , mget(1,"sl",fd)), // thickness
set(a,"mark_mode" , toggle(mget(1,characterFormat,fd))), //mark_mode
set(a,"mark_style" , mget(1,characterFormat,fd)) // mark_style
set(a,"mark_size" , mget(1,characterFormat,fd)) // mark_size
if is_higher_than([3 0 0 0]) then
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated" ;
else
msu="point";
end
set(a,"mark_size_unit" , msu)
set(a,"mark_foreground" , mget(1,"il",fd)) ; // mark_foreground
set(a,"mark_background" , mget(1,"il",fd)) ; // mark_background
else
set(a,"mark_size_unit" , "tabulated")
end
set(a,"foreground" , mget(1,"il",fd)), // foreground
set(a,"background" , mget(1,"il",fd)), // background
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then // clip_box
set(a,"clip_box",mget(4,"dl",fd)) ;
end
set(a,"clip_state" ,clip_state);
// children
nbChildren = mget(1,"il",fd) ;
for k = 1 : nbChildren
load_graphichandle(fd) ;
end
//next lines because tools used to rebuild children change the
//data_bounds an axes_visible properties
set(a,"data_bounds" , data_bounds) ;
set(a,"log_flags" , log_flags);
set(a,"axes_visible" , axes_visible) ;
if is_higher_than([4 1 2 0] ) then
set(a, "box", boxtype ) ;
end
h=a;
load_user_data(fd) ; // user_data
global %LEG
if %LEG<>[] then
//get handles from paths
links=get_links_from_path(a,%LEG.paths)
if links<>[] then
L=captions(links,%LEG.text)
L.visible = %LEG.visible
L.font_style = %LEG.font_style
L.font_size = %LEG.font_size
L.font_color = %LEG.font_color
L.fractional_font = %LEG.fractional_font
L.mark_mode = "off";
L.legend_location = %LEG.legend_location
L.position = %LEG.position
L.line_mode = %LEG.line_mode
L.thickness = %LEG.thickness
L.foreground = %LEG.foreground
L.fill_mode = %LEG.fill_mode
L.background = %LEG.background
L.clip_state = %LEG.clip_state
if %LEG.clip_state=="on" then
L.clip_box = %LEG.clip_box
end
L.user_data = %LEG.user_data
else
warning(msprintf(_("%s: Legend does not fit with the current context. Skipped\n"),"load"));
end
end
clearglobal %LEG
case "Polyline"
visible=toggle(mget(1,characterFormat,fd)) // visible
sz=mget(2,"il",fd); // data
data=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
if is_higher_than([3 1 0 0]) then
closed = toggle(mget(1,characterFormat,fd)) // closed
end
line_mode = toggle(mget(1,characterFormat,fd)) // line_mode
if is_higher_than([3 1 0 0]) then
fill_mode = toggle(mget(1,characterFormat,fd)) // fill_mode
end
line_style = mget(1,characterFormat,fd); // line_style
if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0
line_style=1;
end
thickness = mget(1,"sl",fd); // thickness
if is_higher_than([3 1 0 1]) then
arrow_size_factor = mget(1,"sl",fd); // arrow_size_factor
end
polyline_style = mget(1,characterFormat,fd); // polyline_style
if is_higher_than([3 1 0 1] ) then
size_interp_color = mget(1,"sl",fd) ; // interp_color_vector
interp_color_vector = mget( size_interp_color, "dl", fd ) ;
interp_color_mode = toggle( mget( 1, characterFormat, fd ) ) ; // interp_color_mode
end
mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode
mark_style = mget(1,characterFormat,fd); // mark_style
mark_size = mget(1,characterFormat,fd); // mark_size
msu="tabulated"
if is_higher_than([3 0 0 0]) then
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated" ;
else
msu="point";
end
end
foreground = mget(1,"il",fd); // foreground
if is_higher_than([3 1 0 0]) then
background = mget(1,"il",fd); // background
end
if is_higher_than([3 0 0 0]) then
mark_foreground=mget(1,"il",fd) // mark_foreground
mark_background=mget(1,"il",fd) // mark_background
end
if is_higher_than([5 4 0 1]) then
mark_offset=mget(1,"il",fd) // mark_offset
mark_stride=mget(1,"il",fd) // mark_stride
end
if is_higher_than([3 1 0 0]) then
sz_x_shift=mget(1,"sl",fd) // x_shift
x_shift=mget(sz_x_shift,"dl",fd)'
sz_y_shift=mget(1,"sl",fd) // y_shift
y_shift=mget(sz_y_shift,"dl",fd)'
sz_z_shift=mget(1,"sl",fd) // z_shift
z_shift=mget(sz_z_shift,"dl",fd)'
end
if is_higher_than([3 1 0 1]) then
bar_width = mget( 1, "dl", fd ) ; // bar_width
end
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
clip_box = mget(4,"dl",fd) ; // clip_box
else
clip_box = [] ;
end
// draw the polyline and set properties
xpoly(data(:,1),data(:,2))
//plot2d( data(:,1),data(:,2));
h=get("hdl")
set(h,"data",data)
set(h,"visible",visible)
set(h,"line_mode",line_mode),
set(h,"line_style",line_style)
set(h,"thickness",thickness)
set(h,"arrow_size_factor",arrow_size_factor);
set(h,"polyline_style",max(1,polyline_style)),
set(h,"mark_style",mark_style),
set(h,"mark_size",mark_size),
set(h,"mark_mode",mark_mode),
set(h,"foreground",foreground),
if is_higher_than([3 0 0 0]) then
set(h,"mark_size_unit",msu)
set(h,"mark_foreground",mark_foreground),
set(h,"mark_background",mark_background)
end
if is_higher_than([5 5 0 1]) then
set(h,"mark_offset",mark_offset)
set(h,"mark_stride",mark_stride)
end
if is_higher_than([3 1 0 0]) then
set(h,"background",background)
set(h,"fill_mode",fill_mode)
set(h,"closed",closed);
set(h,"x_shift",x_shift);
set(h,"y_shift",y_shift);
set(h,"z_shift",z_shift);
end
if is_higher_than([3 1 0 1]) then
if interp_color_mode == "on" & interp_color_vector~=[] then
set(h,"interp_color_vector",interp_color_vector);
set(h,"interp_color_mode","on");
else
if interp_color_vector~=[]
h.interp_color_vector = interp_color_vector
end
h.interp_color_mode = interp_color_mode
end
set(h,"bar_width",bar_width);
end
if clip_state =="" then clip_state="clipgrf",end
if clip_state=="on" then set(h,"clip_box",clip_box),end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Datatip"
if is_higher_than([5 4 0 1]) then
visible=toggle(mget(1,characterFormat,fd)) // visible
sz = mget(2,characterFormat,fd)
tip_data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) // data
tip_box_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // box_mode
tip_label_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // label_mode
tip_orientation = mget(1,characterFormat,fd); // orientation
tip_3component = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // z_component
tip_auto_orientation = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // auto_orientation
tip_interp_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // interp_mode
tip_disp_function = load_text_matrix(fd); // display_function
mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode
mark_style = mget(1,characterFormat,fd); // mark_style
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated"
else
msu="point";
end
mark_size = mget(1,characterFormat,fd); // mark_size
mark_foreground=mget(1,"il",fd) // mark_foreground
mark_background=mget(1,"il",fd) // mark_background
tag = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // tag
h=get("hdl");
set(h, "font_foreground", mget(1, "il", fd)); // font_foreground
set(h,"foreground", mget(1,"il",fd)); // foreground
set(h, "background", mget(1, "il", fd)); // background
set(h,"mark_mode",mark_mode); // mark_mode
set(h,"mark_style",mark_style); // mark_style
set(h,"mark_size_unit",msu) // mark_size_unit
set(h,"mark_size",mark_size) // mark_size
set(h,"mark_foreground",mark_foreground) // mark_foreground
set(h,"mark_background",mark_background) // mark_background
load_user_data(fd) // user_data
end
case "Plot3d" then
visible=toggle(mget(1,characterFormat,fd)) // visible
surface_mode = toggle(mget(1,characterFormat,fd)) // surface_mode
foreground = mget(1,"il",fd); // foreground
thickness = mget(1,"sl",fd); // thickness
mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode
mark_style = mget(1,characterFormat,fd); // mark_style
mark_size = mget(1,characterFormat,fd); // mark_size
if is_higher_than([3 0 0 0]) then
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated" ;
else
msu="point";
end
mark_foreground=mget(1,"il",fd) // mark_foreground
mark_background=mget(1,"il",fd) // mark_background
else
msu="tabulated"
end
if is_higher_than([5 1 1 0]) then
color_mode = mget(1,"il",fd); // color_mode
color_flag = mget(1,"il",fd); // color_flag
else
color_mode = mget(1,characterFormat,fd);
color_flag = mget(1,characterFormat,fd);
end
sz=mget(2,"il",fd); // data.x
x=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.y
y=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.z
z=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
if or(color_flag==[2,5]) then
sz=mget(2,"il",fd); // data.color
clr=matrix(mget(prod(sz),"il",fd),sz(1),-1);
end
hiddencolor = mget(1,"il",fd); // hidden_color
// plot3d modify the given rotation angles
// trick to force keeping the good rotation angles F.Leray 18.02.05
// same issue with axes properties... B.Jofret 21.04.09
a=gca();
rotation_angles = a.rotation_angles;
axes_visible = a.axes_visible;
box = a.box;
margins = a.margins;
x_label_visible = a.x_label.visible;
y_label_visible = a.y_label.visible;
z_label_visible = a.z_label.visible;
x_label_text = a.x_label.text;
y_label_text = a.y_label.text;
z_label_text = a.z_label.text;
axes_isoview = a.isoview;
if or(color_flag==[2 5]) then
plot3d1(x,y,list(z,clr))
else
plot3d(x,y,z)
end
// Restore this properties after plot3d.
a.rotation_angles = rotation_angles;
a.axes_visible = axes_visible;
a.box = box;
a.margins = margins;
a.x_label.visible = x_label_visible;
a.y_label.visible = y_label_visible;
a.z_label.visible = z_label_visible;
a.x_label.text = x_label_text;
a.y_label.text = y_label_text;
a.z_label.text = z_label_text;
a.isoview = axes_isoview;
h=gce();
set(h,"visible",visible)
set(h,"surface_mode",surface_mode)
set(h,"thickness",thickness)
set(h,"foreground",foreground),
set(h,"color_mode",color_mode),
set(h,"mark_style",mark_style),
set(h,"mark_size",mark_size),
if is_higher_than([3 0 0 0]) then
set(h,"mark_size_unit",msu),
set(h,"mark_foreground",mark_foreground),
set(h,"mark_background",mark_background)
end
set(h,"mark_mode",mark_mode)
set(h,"color_flag",color_flag),
set(h,"hiddencolor",hiddencolor),
if is_higher_than([4 1 2 0])
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
set(h,"clip_box", mget(4,"dl",fd)) // clip_box
end
set(h,"clip_state",clip_state);
end
load_user_data(fd)
case "Fac3d" then
visible=toggle(mget(1,characterFormat,fd)) // visible
surface_mode = toggle(mget(1,characterFormat,fd)) // surface_mode
foreground = mget(1,"il",fd); // foreground
thickness = mget(1,"sl",fd); // thickness
mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode
mark_style = mget(1,characterFormat,fd); // mark_style
mark_size = mget(1,characterFormat,fd); // mark_size
if is_higher_than([3 0 0 0]) then
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated";
else
msu="point";
end
mark_foreground=mget(1,"il",fd) ; // mark_foreground
mark_background=mget(1,"il",fd) ; // mark_background
end
if is_higher_than([5 1 1 0]) then
color_mode = mget(1,"il",fd); // color_mode
color_flag = mget(1,"il",fd); // color_flag
else
color_mode = mget(1,characterFormat,fd);
color_flag = mget(1,characterFormat,fd);
end
sz=mget(2,"il",fd); // data.x
x=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.y
y=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.z
z=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
if is_higher_than([3 1 0 1]) & color_flag >= 2 then
sz=mget(2,"il",fd); // data.z
clr=matrix(mget(prod(sz),"il",fd),sz(1),-1);
if ascii(mget(1,characterFormat,fd)) == "s" then // cdata_mapping
cdata_mapping = "scaled" ;
else
cdata_mapping = "direct" ;
end
elseif or(color_flag==[2 5]) then
// compatibility with old version
sz=mget(2,"il",fd); // data.z
clr=matrix(mget(prod(sz),"il",fd),sz(1),-1);
end
hiddencolor = mget(1,"il",fd); // hiddencolor
// plot3d modify the given rotation angles
// trick to force keeping the good rotation angles F.Leray 18.02.05
// same issue with axes properties... B.Jofret 21.04.09
// and labels text and isoview
a=gca();
rotation_angles = a.rotation_angles;
axes_visible = a.axes_visible;
box = a.box;
margins = a.margins;
x_label_visible = a.x_label.visible;
y_label_visible = a.y_label.visible;
z_label_visible = a.z_label.visible;
x_label_text = a.x_label.text;
y_label_text = a.y_label.text;
z_label_text = a.z_label.text;
axes_isoview = a.isoview;
if is_higher_than([3 1 0 1]) & color_flag >= 2 then
plot3d1(x,y,list(z,clr))
elseif or(color_flag==[2 5]) then
plot3d1(x,y,list(z,clr))
else
plot3d(x,y,z)
end
// Restore this properties after plot3d.
a.rotation_angles = rotation_angles;
a.axes_visible = axes_visible;
a.box = box;
a.margins = margins;
a.x_label.visible = x_label_visible;
a.y_label.visible = y_label_visible;
a.z_label.visible = z_label_visible;
a.x_label.text = x_label_text;
a.y_label.text = y_label_text;
a.z_label.text = z_label_text;
a.isoview = axes_isoview;
h=gce();
set(h,"visible",visible)
set(h,"surface_mode",surface_mode)
set(h,"thickness",thickness)
set(h,"foreground",foreground),
set(h,"color_mode",color_mode),
set(h,"color_flag",color_flag),
set(h,"hiddencolor",hiddencolor),
set(h,"mark_style",mark_style),
set(h,"mark_size",mark_size),
set(h,"mark_mode",mark_mode)
if is_higher_than([3 0 0 0]) then
set(h,"mark_size_unit",msu),
set(h,"mark_foreground",mark_foreground),
set(h,"mark_background",mark_background)
end
if is_higher_than([3 1 0 1]) & color_flag >= 2 then
set(h,"cdata_mapping",cdata_mapping);
end
if is_higher_than([4 1 2 0])
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
set(h,"clip_box", mget(4,"dl",fd)) // clip_box
end
set(h,"clip_state",clip_state);
end
load_user_data(fd) ; // user_data
case "Compound"
// children
n=mget(1,"il",fd)
H=[]
for k=1:n
htmp = load_graphichandle(fd)
H=[htmp H]
end
h=glue(H)
if is_higher_than([3 1 0 1]) then // visible
h.visible = toggle(mget(1,characterFormat,fd)) ;
end
load_user_data(fd) // user_data
case "Agregation" // for compatibility with old save
// children
n=mget(1,"il",fd)
H=[]
for k=1:n
htmp = load_graphichandle(fd)
H=[htmp H]
end
h=glue(H)
if is_higher_than([3 1 0 1]) then // visible
h.visible = toggle(mget(1,characterFormat,fd)) ;
end
load_user_data(fd) // user_data
case "Rectangle"
visible = toggle(mget(1,characterFormat,fd)) // visible
thickness = mget(1,"sl",fd); // thickness
mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode
mark_style = mget(1,characterFormat,fd); // mark_style
mark_size = mget(1,characterFormat,fd); // mark_size
if is_higher_than([3 0 0 0]) then
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated" ;
else
msu="point";
end
mark_foreground=mget(1,"il",fd) // mark_foreground
mark_background=mget(1,"il",fd) // mark_background
else
msu="tabulated"
end
line_mode = toggle(mget(1,characterFormat,fd)) ; // line_mode
line_style = mget(1,characterFormat,fd); // line_style
if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0
line_style=1;
end
fill_mode = toggle(mget(1,characterFormat,fd)) ; // fill_mode
foreground = mget(1,"il",fd); // foreground
if is_higher_than([3 1 0 1]) then
background = mget(1,"il",fd); // background
end
if (is_higher_than([5 0 3 0])) then
// data size might be 4 or 5
data = mget(mget(1,"il",fd),"dl",fd); // data
else
parentAxes = gca();
if (parentAxes.view == "2d") then
data = mget(4,"dl",fd);
else
data = mget(5,"dl",fd);
end
end
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // clip_stata
if clip_state=="on" then
clip_box = mget(4,"dl",fd) // clip_box
else
clip_box=[]
end
// draw the rectangle
xrect(0,1,1,1); // create the rectangle with dummy values
h=get("hdl")
set(h,"data",data);
set(h,"visible",visible)
set(h,"thickness",thickness)
set(h,"mark_style",mark_style),
set(h,"mark_size",mark_size),
set(h,"mark_size_unit",msu),
if is_higher_than([3 0 0 0]) then
set(h,"mark_foreground",mark_foreground) ;
set(h,"mark_background",mark_background) ;
end
set(h,"mark_mode",mark_mode)
set(h,"line_style",line_style)
set(h,"fill_mode",fill_mode)
set(h,"foreground",foreground) ;
if is_higher_than([3 1 0 1]) then
set(h,"background",background) ;
end
set(h,"line_mode",line_mode)
if clip_state=="on" then set(h,"clip_box",clip_box),end
set(h,"clip_state",clip_state);
load_user_data(fd) ; // user_data
case "Arc"
visible = toggle(mget(1,characterFormat,fd)) // visible
thickness = mget(1,"sl",fd); // thickness
line_style = mget(1,characterFormat,fd); // line_style
if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0
line_style=1;
end
if is_higher_than([3 1 0 1])
line_mode = toggle(mget(1,characterFormat,fd)) ; // line_mode
end
fill_mode = toggle(mget(1,characterFormat,fd)) // fill_mode
foreground = mget(1,"il",fd); // foreground
if is_higher_than([3 1 0 1]) then
background = mget(1,"il",fd) ; // background
end
if (is_higher_than([5 0 3 0])) then
// data size might be 6 or 7
data = mget(mget(1,"il",fd),"dl",fd); // data
else
parentAxes = gca();
if (parentAxes.view == "2d") then
data = mget(6,"dl",fd);
else
data = mget(7,"dl",fd);
end
end
if is_higher_than([4 1 2 0]) then
drawing_method = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // drawing_method
else
drawing_method = "nurbs";
end
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
clip_box = mget(4,"dl",fd) // clip_box
else
clip_box=[]
end
xarc(0,1,1,1,0,360); // create the arc dummy values
h=get("hdl")
if ~is_higher_than([4 1 2 0]) then
// angle wass stored by 64th of degree
data($) = data($) / 64;
data($-1) = data($-1) / 64;
end
set(h,"data",data);
set(h,"visible",visible)
set(h,"thickness",thickness)
set(h,"line_style",line_style)
set(h,"line_mode",line_mode);
set(h,"fill_mode",fill_mode)
set(h,"foreground",foreground) ;
set(h,"background",background) ;
set(h,"arc_drawing_method", drawing_method) ;
if clip_state=="on" then set(h,"clip_box",clip_box),end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Champ"
visible = toggle(mget(1,characterFormat,fd)) // visible
sz=mget(2,"il",fd); // data.x
x=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.y
y=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.fx
fx=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.fy
fy=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
// draw the champ
champ(x,y,fx,fy);
h=gce();
set(h,"visible",visible);
line_style = mget(1,characterFormat,fd);
if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0
line_style=1;
end
set(h,"line_style",line_style); // line_style
set(h,"thickness",mget(1,"sl",fd)) // thickness
set(h,"colored",toggle(mget(1,characterFormat,fd))) // colored
set(h,"arrow_size",mget(1,"dl",fd)) // arrow_size
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
set(h,"clip_box", mget(4,"dl",fd)) // clip_box
end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Segs"
visible = toggle(mget(1,characterFormat,fd)) // visible
sz = mget(2,"il",fd) // data
data = matrix(mget(prod(sz),"dl",fd),sz(1),-1)
// draw the segs
xsegs(data(:,1),data(:,2))
h=gce()
if size(data,2)==3 then
h.data=data
end
set(h,"visible",visible);
set(h,"line_mode" ,toggle(mget(1,characterFormat,fd))) // line_mode
line_style = mget(1,characterFormat,fd);
if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0
line_style=1;
end
set(h,"line_style",line_style); // line_style
set(h,"thickness",mget(1,"sl",fd)) // thickness
set(h,"arrow_size",mget(1,"dl",fd)) // arrow_size
n=mget(1,"il",fd) // segs_color
set(h,"segs_color",mget(n,"il",fd))
// it is needed to set it at the end, ut I don't know why
mark_mode = toggle(mget(1,characterFormat,fd)) ; // mark_mode
set(h,"mark_style" , mget(1,characterFormat,fd)) // mark_style
set(h,"mark_size" , mget(1,characterFormat,fd)) // mark_size
if is_higher_than([3 0 0 0]) then
if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit
msu="tabulated"
else
msu="point";
end
set(h,"mark_size_unit" , msu) ;
set(h,"mark_foreground" , mget(1,"il",fd)) ; // mark_foreground
set(h,"mark_background" , mget(1,"il",fd)) ; // mark_background
else
set(h,"mark_size_unit" , "tabulated") ; // mark_size_unit
end
set(h,"mark_mode", mark_mode ) ;
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
set(h,"clip_box", mget(4,"dl",fd)) // clip_box
end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Grayplot"
visible = toggle(mget(1,characterFormat,fd)) // visible
if is_higher_than([3 0 0 0]) then
sz=mget(2,"il",fd); // data.x
x=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.y
y=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
sz=mget(2,"il",fd); // data.z
z=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
else
sz = mget(2,"il",fd) // data
data = matrix(mget(prod(sz),"dl",fd),sz(1),-1)
end
data_mapping = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // data_mapping
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
clip_box = mget(4,"dl",fd) // clip_box
else
clip_box=[]
end
// draw the grayplot
if is_higher_than([3 0 0 0]) then
grayplot(x,y,z)
else
grayplot(data(2:$,1),data(1,2:$),data(2:$,2:$))
end
h=get("hdl")
set(h,"visible",visible)
set(h,"data_mapping",data_mapping)
if clip_state=="on" then
set(h,"clip_box", clip_box)
end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Matplot"
visible = toggle(mget(1,characterFormat,fd)) // visible
sz=mget(2,"il",fd); // data
data=matrix(mget(prod(sz),"dl",fd),sz(1),-1);
// data_mapping = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
clip_box = mget(4,"dl",fd) // clip_box
else
clip_box=[]
end
// draw the matplot
Matplot(data);
h=get("hdl")
set(h,"visible",visible)
// set(h,"data_mapping",data_mapping)
if clip_state=="on" then
set(h,"clip_box", clip_box)
end
set(h,"clip_state",clip_state);
// user_data
load_user_data(fd)
case "Fec"
visible = toggle(mget(1,characterFormat,fd)) // visible
sz = mget(2,"il",fd) // data
data = matrix(mget(prod(sz),"dl",fd),sz(1),-1)
sz = mget(2,"il",fd) // triangles
triangles = matrix(mget(prod(sz),"dl",fd),sz(1),-1)
z_bounds = mget(2,"dl",fd) // z_bounds
// draw the fec
fec(data(:,1),data(:,2),triangles,data(:,3))
h=unglue(get("hdl"))
set(h,"visible",visible)
set(h,"z_bounds",z_bounds)
if is_higher_than( [5 0 3 0] ) then
set(h,"color_range",mget(2,"dl",fd)); // color_range
set(h,"outside_colors",mget(2,"dl",fd)); // color_range
set(h,"line_mode" ,toggle(mget(1,characterFormat,fd))) // line_mode
set(h,"foreground", mget(1,"il",fd)); // foreground
end
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
set(h,"clip_box", mget(4,"dl",fd)) // clip_box
end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Legend"
if is_higher_than( [5 0 0 0] ) then
global %LEG
%LEG=[];
%LEG.visible = toggle(mget(1,characterFormat,fd)) // visible
%LEG.text = load_text_vector(fd); // text
%LEG.font_style = mget(1,characterFormat,fd); // font_style
%LEG.font_size = mget(1,characterFormat,fd); // font_size
%LEG.font_color = mget(1,"il",fd); // font_size
%LEG.fractional_font = toggle(mget(1,characterFormat,fd)); // fractional_font
nlegends = mget(1,characterFormat,fd);
paths = list()
for kl=1:nlegends
paths($+1) = mget(mget(1,"il",fd),"il",fd);
end
%LEG.paths = paths
%LEG.legend_location = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))
%LEG.position = mget(2,"dl",fd)
%LEG.line_mode = toggle(mget(1,characterFormat,fd))
%LEG.thickness = mget(1,"sl",fd)
%LEG.foreground = mget(1,"il",fd)
%LEG.fill_mode = toggle(mget(1,characterFormat,fd))
%LEG.background = mget(1,"il",fd)
%LEG.clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if %LEG.clip_state=="on" then
%LEG.clip_box = mget(4,"dl",fd); // clip_box
end
%_load(fd,"user_data")
%LEG.user_data = user_data;
else
visible = toggle(mget(1,characterFormat,fd)) // visible
line_mode = toggle(mget(1,characterFormat,fd)) // line_mode
mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode
mark_foreground = mget(1,"il",fd) ; // mark_foreground
mark_background = mget(1,"il",fd) ; // mark_background
//text=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // text
text = load_text_vector(fd); // text
//create the legend
//get the number of lines of the legend
lineFeedPosition = strindex(text,"@")
nbLines = size( lineFeedPosition ) ;
nbLines = nbLines(2) + 1
//create as many curves as lines in the text
nullVector = zeros(1,nbLines);
//draw the legend
plot2d(0,nullVector,leg=text) ;
H=unglue(get("hdl"));
h=H(1);
delete(H(2));
set(h,"visible",visible)
set(h,"line_mode",line_mode);
set(h,"mark_mode",mark_mode);
set(h,"mark_foreground",mark_foreground) ;
set(h,"mark_background",mark_background) ;
set(h,"foreground", mget(1,"il",fd)); // foreground
set(h,"font_style", mget(1,characterFormat,fd)); // font_style
set(h,"font_size" , mget(1,characterFormat,fd)); // font_size
if is_higher_than( [4 1 2 0] ) then
set(h,"fractional_font" , toggle(mget(1,characterFormat,fd))); // fractional_font
end
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
set(h,"clip_box",mget(4,"dl",fd)); // clip_box
end
set(h,"clip_state",clip_state);
end
case "Text"
visible = toggle(mget(1,characterFormat,fd)) // visible
if is_higher_than( [4 1 2 0] ) then
text = load_text_matrix( fd ) ;
else
text = load_text_vector(fd) // text
end
sz = mget(2,characterFormat,fd)
data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) // data
text_box = mget(2,"dl",fd) // text_box
text_box_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // text_box_mode
// draw the text
if text_box_mode == "off" then
xstring(data(1),data(2),text)
else
xstringb(data(1),data(2),text,text_box(1),text_box(2))
end
h=get("hdl");
set(h,"data",data);
set(h,"visible",visible) ;
set(h,"text_box_mode",text_box_mode)
set(h,"foreground" , mget(1,"il",fd)); // foreground
set(h,"font_style" , mget(1,characterFormat,fd)); // font_style
if text_box_mode == "filled" then // font_size
mget(1,characterFormat,fd) ;
else
set(h,"font_size", mget(1,characterFormat,fd));
end
set(h,"font_angle" , mget(1,"dl",fd)); // font_angle
//adding JB Silvy 28/11/05
// box drawing
if is_higher_than([3 1 0 1]) then
set( h, "box" , toggle( mget( 1, characterFormat, fd ) ) ) ; // box
set( h, "line_mode", toggle( mget( 1, characterFormat, fd ) ) ) ; // line_mode
set( h, "fill_mode", toggle( mget( 1, characterFormat, fd ) ) ) ; // fill_mode
set( h, "font_foreground", mget( 1, "il", fd ) ) ; // font_foreground
set( h, "background" , mget( 1, "il", fd ) ) ; // background
end
if is_higher_than( [4 1 2 0] ) then
set( h, "alignment", ascii(mget(mget(1,characterFormat,fd),characterFormat,fd) ) ) ; // alignment
set( h, "fractional_font", toggle( mget( 1, characterFormat, fd ) ) ) ; // fractional_font
end
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state=="on" then
clip_box = mget(4,"dl",fd) // clip_box
set(h,"clip_box",clip_box) ; // clip_box
else
clip_box=[]
end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
case "Axis"
if is_higher_than([3 1 0 0]) then
visible = toggle(mget(1,characterFormat,fd)) // visible
n = mget(1,"il",fd) // tics_direction
tics_direction = ascii(mget(n,characterFormat,fd));
nx = mget(1,"il",fd) // xtics_coord
xtics_coord = mget(nx,"dl",fd)'
ny = mget(1,"il",fd) // ytics_coord
ytics_coord = mget(ny,"dl",fd)'
if tics_direction == "bottom" then axisdir="d";
elseif tics_direction == "top" then axisdir="u";
elseif tics_direction == "left" then axisdir="l";
elseif tics_direction == "right" then axisdir="r";
elseif nx>1 then axisdir="u";
else axisdir="l";
end
drawaxis(x=xtics_coord,y=ytics_coord,dir=axisdir);
h=gce()
h.tics_color = mget(1,"il",fd) // tics_color
h.tics_segment = toggle(mget(1,characterFormat,fd)) // tics_segment
h.tics_style = ascii(mget(1,characterFormat,fd)) // tics_style
h.sub_tics = mget(1,"il",fd) // sub_tics
h.tics_labels = load_text_vector(fd)' // tics_label
labelfontsize = mget(1,"il",fd);
// Bug fix: there was a bug in Scilab <=4.1.2 which used -1 as default value for labels_font_size
// Scilab 5 needs font size to be >= 0 so we change the value to avoid an error message due to a Scilab bug...
if labelfontsize == -1 then
//labelfontsize = 0;
end
h.labels_font_size = labelfontsize // label_font_size
h.labels_font_color= mget(1,"il",fd); // labels_font_color
if is_higher_than([5 4 0 1]) then
h.labels_font_style = mget(1,"il",fd);
end
if is_higher_than( [4 1 2 0] ) then
set( h, "fractional_font", toggle( mget( 1, characterFormat, fd ) ) ) ; // fractional_font
end
// h.tics_style=tics_style // jb Silvy apparently strange
clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state
if clip_state == "on" then
set(h,"clip_box",clip_box)
end
set(h,"clip_state",clip_state);
load_user_data(fd) // user_data
end
case "uimenu"
if is_higher_than( [4 1 2 0] ) then
h = uimenu("parent", gcf());
h.enable = toggle(mget(1,"c",fd)); // Enable
ncolors = mget(1,"il",fd); // Foregroundcolor (size)
h.foregroundcolor = mget(ncolors,"dl",fd); // ForegroundColor (data)
h.label = ascii(mget(mget(1,"c",fd),"c",fd)); // Label
h.visible = toggle(mget(1,"c",fd)); // Visible
if is_higher_than( [5 4 0 0] ) then
h.callback = ascii(mget(mget(1, stringFormat,fd),"c",fd)); // Callback
else
h.callback = ascii(mget(mget(1,"c",fd),"c",fd)); // Callback
end
h.callback_type = mget(1,"il",fd); // Callback Type
h.tag = ascii(mget(mget(1,"c",fd),"c",fd)); // Tag
end
if is_higher_than( [5 1 2 0] ) then // 5.2 and higher
h.checked = toggle(mget(1,"c",fd)); // Checked
end
if is_higher_than( [5 1 1 0] ) then // 5.1.2 and higher
// children
nbChildren = mget(1,"il",fd) ;
for k = 1 : nbChildren
htmp = load_graphichandle(fd) ;
set(htmp, "Parent", h);
end
end
case "uicontextmenu"
h = uicontextmenu();
// children
nbChildren = mget(1,"il",fd) ;
for k = 1 : nbChildren
htmp = load_graphichandle(fd) ;
set(htmp, "Parent", h);
end
case "uicontrol"
if is_higher_than( [4 1 2 0] ) then
uistyle = ascii(mget(mget(1,"c",fd),"c",fd)); // Style
h = uicontrol("parent",gcf(), "style", uistyle);
ncolors = mget(1,"il",fd); // BackgroundColor (size)
h.backgroundcolor = mget(ncolors,"dl",fd); // BackgroundColor (data)
h.enable = toggle(mget(1,"c",fd)); // Enable
h.fontangle = ascii(mget(mget(1,"c",fd),"c",fd)); // FontAngle
h.fontname = ascii(mget(mget(1,"c",fd),"c",fd)); // FontName
fontsize_in_units = mget(1,"dl",fd); // FontSize
h.fontunits = ascii(mget(mget(1,"c",fd),"c",fd)); // FontUnits
h.fontsize = fontsize_in_units; // FontSize written after 'FontUnits' to avoid them to be computed again
h.fontweight = ascii(mget(mget(1,"c",fd),"c",fd)); // FontWeight
ncolors = mget(1,"il",fd); // Foregroundcolor (size)
h.foregroundcolor = mget(ncolors,"dl",fd); // ForegroundColor (data)
h.horizontalalignment = ascii(mget(mget(1,"c",fd),"c",fd)); // HorizontalAlignment
ndata = mget(1,"il",fd); // ListboxTop (size)
h.listboxtop = mget(ndata,"dl",fd); // ListboxTop (data)
h.max = mget(1,"dl",fd); // Max
h.min = mget(1,"dl",fd); // Min
ndata = mget(1,"il",fd); // Position (size)
position_in_units = mget(ndata,"dl",fd); // Position (data)
h.relief = ascii(mget(mget(1,"c",fd),"c",fd)); // Relief
ndata = mget(1,"il",fd); // SliderStep (size)
h.sliderstep = mget(ndata,"dl",fd); // SliderStep (data)
h.string = load_text_matrix(fd) ; // String
if ( is_higher_than([5 2 0 0]) ) then // Added in 5.4.0 version
h.tooltipstring = load_text_matrix(fd) ; // TooltipString
end
h.units = ascii(mget(mget(1,"c",fd),"c",fd)); // Units
h.position = position_in_units; // Position written after 'Units' to avoid them to be computed again
ndata = mget(1,"il",fd); // Value (size)
h.value = mget(ndata,"dl",fd); // Value (data)
h.verticalalignment = ascii(mget(mget(1,"c",fd),"c",fd)); // VerticalAlignment
h.visible = toggle(mget(1,"c",fd)); // Visible
if is_higher_than( [5 4 0 0] ) then
h.callback = ascii(mget(mget(1, stringFormat,fd),"c",fd)); // Callback
else
h.callback = ascii(mget(mget(1,"c",fd),"c",fd)); // Callback
end
h.callback_type = mget(1,"il",fd); // Callback Type
load_user_data(fd); // Userdata
h.tag = ascii(mget(mget(1,"c",fd),"c",fd)); // Tag
end
else
warning("type " +typ+" unhandled");
end
endfunction
function r=toggle(k)
r=emptystr(k)+"on"
r(k==0)="off"
endfunction
function load_user_data(fd)
if is_higher_than([3 1 0 0]) then
h; //make a copy of the calling context h here
%_load(fd,"user_data")
if ~isempty(user_data) then
set(h, "user_data", user_data);
end
end
endfunction
function r=is_higher_than(v)
//check if current version is strictly higher than the given one
r=%f
for k=1:4
if version(k)>v(k) then r=%t,break,end
if version(k)<v(k) then r=%f,break,end
end
endfunction
function text=load_text_vector(fd)
T=mget(mget(1,"il",fd),characterFormat,fd)
newline=[find(T==10) size(T,"*")+1];
text=[]
p=1
for k=1:size(newline,"*")
text=[text;ascii(T(p:newline(k)-1))];
p=newline(k)+1
end
endfunction
// retrieve a string matrix saved by save_text_matrix
function strMat = load_text_matrix( fd )
nbRow = mget( 1, "il", fd ) ;
nbCol = mget( 1, "il", fd ) ;
for i = 1:nbRow
for j = 1:nbCol
if is_higher_than([5 4 0 0]) then
strMat(i,j) = ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) ;
else
strMat(i,j) = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ;
end
end
end
endfunction
function links=get_links_from_path(ax,paths)
// ax is a handle on an axes entity
// paths a list or row vector which gives the set of paths relative to
// the axes
links=[];ok=%t
for p=paths
e=ax;
p(1)=p(1)-1// the caption does not exists yet
for kp=1:size(p,"*"),
if or(e.type==["Axes","Compound"])&p(kp)<=size(e.children,"*") then
e=e.children(p(kp)),
else
ok=%f
break
end
end
if ~ok then break,end
links=[links,e]
end
if ~ok then links=[],end
endfunction
|