-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaprint.m
2926 lines (2725 loc) · 97.9 KB
/
laprint.m
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
function laprint(figno,filename,varargin)
%LAPRINT prints a figure for inclusion in LaTeX documents.
% LaPrint creates an eps-file and a tex-file. The tex-file contains
% the annotation of the figure such as titles, labels and texts. The
% eps-file contains the non-text part of the figure as well as the
% position of the text-objects. The packages 'graphicx' (or 'epsfig')
% and 'psfrag' (and possibly ''color'') are required for the LaTeX
% run. A postscript driver like 'dvips' is required for printing.
%
% Usage: >> laprint
%
% This opens a graphical user interface window, to control the
% various settings. It includes a help facility. Just try it.
%
% As an alternative to the GUI you can call laprint from the command
% line with various extra input arguments. These arguments are
% explained in the help window of the GUI, which can be also be
% opened using the command
% >> laprint helpwindow
%
% There is an Users Guide available at
% http://www.uni-kassel.de/fb16/rat/matlab/laprint/laprintdoc.ps
% (c) Arno Linnemann. All rights reserved.
% The author of this program assumes no responsibility for any errors
% or omissions. In no event shall he be liable for damages arising out of
% any use of the software. Redistribution of the unchanged file is allowed.
% Distribution of changed versions is allowed provided the file is renamed
% and the source and authorship of the original version is acknowledged in
% the modified file.
% Please report bugs, suggestions and comments to:
% Arno Linnemann
% Control and Automation
% Department of Electrical and Computer Engineering
% University of Kassel
% 34109 Kassel
% Germany
% mailto:[email protected]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% Initialize
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
laprintident = '3.16 (13.9.2004)';
vers = version;
vers = eval(vers(1:3));
if vers < 6.1
error('Sorry. Matlab 6.1 or above is required.')
end
hf=131;
hhf=132;
% no output
if nargout
error('No output argument, please.')
end
inter=get(0,'defaulttextinterpreter');
if ~strcmp(inter,'none')
warning('LaPrint:general',['It is recommended to switch off the '...
'text interpreter\nbefore creating a figure to be saved '...
'with LaPrint. Use the command\n',...
' >> set(0,''defaulttextinterpreter'',''none'').'])
end
if nargin==0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% GUI
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try
delete(hf)
end
try
delete(hhf)
end
%---------------------------------
% open window
%---------------------------------
hf = figure(hf);
clf reset;
set(hf,'NumberTitle','off',...
'Name','LaPrint (LaTeX Print)',...
'Units','points',...
'CloseRequestFcn','laprint(''quit'');',...
'menubar','none')
h = uicontrol('Parent',hf,'Units','points');
fsize = get(h,'Fontsize');
delete(h)
posf = get(hf,'Position');
figheight = 10*fsize;
figwidth = 32*fsize;
posf = [ posf(1) posf(2)+posf(4)-figheight figwidth figheight];
set(hf,'Position',posf)
uicontrol('Parent',hf,'style','frame','Units','points',...
'Position',[0 0 figwidth figheight])
curh = figheight-0*fsize;
LAPRINTHAN=struct('figno',{0},'filename',{0},...
'keepfontprops',{0},'asonscreen',{0},'keepticklabels',{0},...
'mathticklabels',{0},'head',{0},'extrapicture',{0},...
'verbose',{0},'figcopy',{0},'package_epsfig',{0},...
'package_graphicx',{0},'color',{0},'createview',{0},...
'processview',{0});
%---------------------------------
% figure no.
%---------------------------------
loch = 1.7*fsize;
curh = curh-loch-1.5*fsize;
h = uicontrol('Parent',hf,...
'style','text',...
'Units','points',...
'Position',[1*fsize curh 18*fsize loch],...
'HorizontalAlignment','left',...
'string','Number of Figure to be saved:');
h = uicontrol('Parent',hf,...
'style','edit',...
'Units','points',...
'Position',[19*fsize curh 12*fsize loch],...
'HorizontalAlignment','left',...
'BackgroundColor',[1 1 1],...
'Callback','laprint(''figno'');');
LAPRINTHAN.figno = h;
%---------------------------------
% filename
%---------------------------------
loch = 1.7*fsize;
curh = curh-loch-1*fsize;
h = uicontrol('Parent',hf,...
'style','text',...
'Units','points',...
'Position',[1*fsize curh 18*fsize loch],...
'HorizontalAlignment','left',...
'string','Basename of Files to be Created:');
h = uicontrol('Parent',hf,...
'style','edit',...
'Units','points',...
'Position',[19*fsize curh 12*fsize loch],...
'HorizontalAlignment','left',...
'BackgroundColor',[1 1 1],...
'Callback','laprint(''filename'');');
LAPRINTHAN.filename = h;
%---------------------------------
% save, quit
%---------------------------------
loch = 2*fsize;
curh = curh-loch-1*fsize;
h = uicontrol('Parent',hf,...
'Style','pushbutton',...
'Units','Points',...
'Position',[19*fsize curh 5*fsize loch],...
'HorizontalAlignment','center',...
'String','Go !',...
'Callback','laprint(''save'');');
h = uicontrol('Parent',hf,...
'Style','pushbutton',...
'Units','Points',...
'Position',[26*fsize curh 5*fsize loch],...
'HorizontalAlignment','center',...
'String','Quit',...
'Callback','laprint(''quit'');');
%---------------------------------
% options uimenue
%---------------------------------
hm1 = uimenu('label','Options');
uimenu(hm1,...
'label','Sizes and Scalings ...',...
'callback','laprint(''size'')');
LAPRINTHAN.keepfontprops = uimenu(hm1,...
'label','Translate Matlab Font Properties to LaTeX',...
'callback','laprint(''keepfontprops'')');
LAPRINTHAN.asonscreen = uimenu(hm1,...
'label','Print Limits and Ticks as on Screen',...
'separator','on',...
'callback','laprint(''asonscreen'')');
LAPRINTHAN.keepticklabels = uimenu(hm1,...
'label','Keep Tick Labels within eps File',...
'callback','laprint(''keepticklabels'')');
LAPRINTHAN.mathticklabels = uimenu(hm1,...
'label','Set Tick Labels in LaTeX Math Mode',...
'callback','laprint(''mathticklabels'')');
LAPRINTHAN.head = uimenu(hm1,...
'label','Equip the tex File with a Head',...
'separator','on',...
'callback','laprint(''head'')');
uimenu(hm1,...
'label','Comment in the Head of the tex File ...',...
'callback','laprint(''comment'')');
uimenu(hm1,...
'label','Place a LaTeX Caption in the tex File ...',...
'callback','laprint(''caption'')');
LAPRINTHAN.extrapicture = uimenu(hm1,...
'label','Place an Extra Picture in each Axes',...
'callback','laprint(''extrapicture'')');
uimenu(hm1,...
'label','Length of psfrag Replacement Strings ...',...
'callback','laprint(''nzeros'')');
LAPRINTHAN.verbose = uimenu(hm1,...
'label','Call LaPrint in Verbose Mode',...
'separator','on',...
'callback','laprint(''verbose'')');
LAPRINTHAN.figcopy = uimenu(hm1,...
'label','Copy Figure and Modify that Copy',...
'callback','laprint(''figcopy'')');
uimenu(hm1,...
'label','Matlab Print Command ...',...
'separator','on',...
'callback','laprint(''printcmd'')');
h=uimenu(hm1,...
'separator','on',...
'label','LaTeX Graphics Package');
LAPRINTHAN.package_graphicx = uimenu(h,...
'label','graphicx',...
'callback','laprint(''package_graphicx'')');
LAPRINTHAN.package_epsfig = uimenu(h,...
'label','epsfig',...
'callback','laprint(''package_epsfig'')');
LAPRINTHAN.color = uimenu(hm1,...
'label','Use LaTeX ''color'' Package',...
'callback','laprint(''color'')');
h = uimenu(hm1,...
'label','View File ...',...
'separator','on');
LAPRINTHAN.createview = uimenu(h,...
'label','Create a View File',...
'callback','laprint(''createview'')');
uimenu(h,...
'label','Name of the View File ...',...
'callback','laprint(''viewfilename'')');
LAPRINTHAN.processview = uimenu(h,...
'label','Process the View File',...
'separator','on',...
'callback','laprint(''processview'')');
uimenu(h,...
'label','Executables for Processing View File...',...
'callback','laprint(''cmdsview'')');
%---------------------------------
% Preferences uimenue
%---------------------------------
hm3=uimenu('label','Preferences');
uimenu(hm3,...
'label','Get Preferences',...
'callback','laprint(''getpref'')')
uimenu(hm3,...
'label','Set Preferences to Current Settings',...
'callback','laprint(''setpref'')')
uimenu(hm3,...
'label','Remove Preferences',...
'callback','laprint(''rmpref'')')
uimenu(hm3,...
'label','Save Current Settings to a File ...',...
'separator','on',...
'callback','laprint(''savepref'')')
uimenu(hm3,...
'label','Load Settings from a File ...',...
'callback','laprint(''loadpref'')')
uimenu(hm3,...
'label','Get Factory Defaults',...
'separator','on',...
'callback','laprint(''factory'')')
%---------------------------------
% Help uimenue
%---------------------------------
hm2=uimenu('label','Help');
uimenu(hm2,...
'label',['LaPrint Online Help ...'],...
'callback','laprint(''helpwindow'')');
uimenu(hm2,...
'label','Get the LaPrint Users Guide',...
'callback',['web www.uni-kassel.de/fb16/rat/matlab',...
'/laprint/laprintdoc.ps -browser'])
uimenu(hm2,...
'label',['Look for a newer version of LaPrint ' ...
'(Matlab Central File Exchange)...'],...
'callback',['web http://www.mathworks.de/matlabcentral/',...
'fileexchange/loadFile.do?objectId=4638',...
'&objectType=file -browser'])
uimenu(hm2,...
'label','Version and Author ...',...
'callback','laprint(''whois'')')
%---------------------------------
% make hf invisible
%---------------------------------
set(hf,'HandleVisibility','callback')
%---------------------------------
% get settings
%---------------------------------
LAPRINTOPT = prefsettings;
if isempty(LAPRINTOPT)
LAPRINTOPT = factorysettings;
end
%---------------------------------
% get figure
%---------------------------------
gcfig=gcf;
if gcfig == hf
allfigs = findobj('type','figure');
allfigs = allfigs(find(allfigs~=hf));
if length(allfigs)
figno = allfigs(1);
else
figure(1)
figno=1;
end
else
figno=gcfig;
end
LAPRINTOPT.figno = figno;
%---------------------------------
% update
%---------------------------------
updategui(LAPRINTHAN,LAPRINTOPT)
sethf(hf,LAPRINTHAN,LAPRINTOPT)
figure(hf)
%---------------------------------
% done
%---------------------------------
return
end % if nargin==0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% callback calls ('factory' and 'getprefs' also
%%%% used from command line)
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isa(figno,'char')
switch figno
case 'figno'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
LAPRINTOPT.figno=eval(get(LAPRINTHAN.figno,'string'));
figure(LAPRINTOPT.figno)
figure(hf)
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'filename'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
LAPRINTOPT.filename=get(LAPRINTHAN.filename,'string');
[texfullnameext,texbasenameext,texbasename,texdirname] = ...
getfilenames(LAPRINTOPT.filename,'tex',0);
[epsfullnameext,epsbasenameext,epsbasename,epsdirname] = ...
getfilenames(LAPRINTOPT.filename,'eps',0);
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'save'
% lapcmd = [ 'laprint(' int2str(LAPRINTOPT.figno) ...
% ', ''' LAPRINTOPT.filename ''''...
% ', ''options'', LAPRINTOPT)'];
lapcmd = 'laprint({})';
eval(lapcmd)
case 'quit'
delete(hf)
try
delete(hhf)
end
case 'size'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
answer = inputdlg({['Please enter the width (in centimeters) ',...
'of the graphics in the LaTeX document (The height ',...
'will be computed such that the aspect ratio of the ',...
'figure on screen is retained.) :'],...
['Please enter the factor by which the size of the '...
'graphics in the LaTeX document differs from the size of the '...
'Postscipt graphics ( Explaination: A factor <1 scales ',...
'the picture down. This means that lines become thinner ',...
'and fonts become smaller. ) :'],...
['Please specify if you want to scale the fonts along with ',...
'the graphics (enter ''on'' or ''off'') : '] },...
'LaPrint Settings',1,{num2str(LAPRINTOPT.width),...
num2str(LAPRINTOPT.factor),...
valueyn(LAPRINTOPT.scalefonts)},'on');
if length(answer)
LAPRINTOPT.width=eval(answer{1});
LAPRINTOPT.factor = eval(answer{2});
LAPRINTOPT.scalefonts = value01(answer{3});
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'keepfontprops'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.keepfontprops==1
LAPRINTOPT.keepfontprops=0;
set(LAPRINTHAN.keepfontprops,'check','off')
else
LAPRINTOPT.keepfontprops=1;
set(LAPRINTHAN.keepfontprops,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'asonscreen'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.asonscreen==1
LAPRINTOPT.asonscreen=0;
set(LAPRINTHAN.asonscreen,'check','off')
else
LAPRINTOPT.asonscreen=1;
set(LAPRINTHAN.asonscreen,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'keepticklabels'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.keepticklabels==1
LAPRINTOPT.keepticklabels=0;
set(LAPRINTHAN.keepticklabels,'check','off')
else
LAPRINTOPT.keepticklabels=1;
set(LAPRINTHAN.keepticklabels,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'mathticklabels'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.mathticklabels==1
LAPRINTOPT.mathticklabels=0;
set(LAPRINTHAN.mathticklabels,'check','off')
else
LAPRINTOPT.mathticklabels=1;
set(LAPRINTHAN.mathticklabels,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'head'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.head==1
LAPRINTOPT.head=0;
set(LAPRINTHAN.head,'check','off')
else
LAPRINTOPT.head=1;
set(LAPRINTHAN.head,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'comment'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
answer = inputdlg({['Please enter a describing comment to '...
'be placed into the head of the tex file:']},...
'LaPrint Settings',1,{LAPRINTOPT.comment},'on');
if length(answer)
LAPRINTOPT.comment = answer{1};
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'caption'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
answer = inputdlg(['If the following text is nonempty, ' ...
'then it will be placed as a \caption{} into the tex '...
'file along with \label{fig:' LAPRINTOPT.filename '}. '...
'Please enter the caption text:'],...
'LaPrint Settings',1,{LAPRINTOPT.caption},'on');
if length(answer)
LAPRINTOPT.caption = answer{1};
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'extrapicture'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.extrapicture==1
LAPRINTOPT.extrapicture=0;
set(LAPRINTHAN.extrapicture,'check','off')
else
LAPRINTOPT.extrapicture=1;
set(LAPRINTHAN.extrapicture,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'nzeros'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
answer = inputdlg({['Please enter length of the psfrag replacement '...
'strings (must be >= 3) :']},...
'LaPrint Settings',1,{num2str(LAPRINTOPT.nzeros)},'on');
if length(answer)
LAPRINTOPT.nzeros = max(eval(answer{1}),3);
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'verbose'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.verbose==1
LAPRINTOPT.verbose=0;
set(LAPRINTHAN.verbose,'check','off')
else
LAPRINTOPT.verbose=1;
set(LAPRINTHAN.verbose,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'figcopy'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.figcopy==1
LAPRINTOPT.figcopy=0;
set(LAPRINTHAN.figcopy,'check','off')
else
LAPRINTOPT.figcopy=1;
set(LAPRINTHAN.figcopy,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'printcmd'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
answer = inputdlg({['Please enter the Matlab command '...
'to be used for printing the eps file '...
'(LaPrint will internally replace <figurenumber> by the '...
'number of the figure <filename.eps> by the ' ...
'eps-filename and <filename> '...
'by the basename of the file, respectively). You can add options '...
'here (like ''-loose'') or use a different program '...
'for printing (like ''exportfig'') :']},...
'LaPrint Settings',1,{LAPRINTOPT.printcmd},'on');
if length(answer)
LAPRINTOPT.printcmd = answer{1};
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'package_epsfig'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
LAPRINTOPT.package='epsfig';
set(LAPRINTHAN.package_epsfig,'check','on')
set(LAPRINTHAN.package_graphicx,'check','off')
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'package_graphicx'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
LAPRINTOPT.package='graphicx';
set(LAPRINTHAN.package_epsfig,'check','off')
set(LAPRINTHAN.package_graphicx,'check','on')
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'color'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.color==1
LAPRINTOPT.color=0;
set(LAPRINTHAN.color,'check','off')
else
LAPRINTOPT.color=1;
set(LAPRINTHAN.color,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'createview'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.createview==1
LAPRINTOPT.createview=0;
LAPRINTOPT.processview=0;
set(LAPRINTHAN.createview,'check','off')
set(LAPRINTHAN.processview,'check','off')
else
LAPRINTOPT.createview=1;
set(LAPRINTHAN.createview,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'viewfilename'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
trydlg=1;
txt=['Please enter the name of the '...
'viewfile (without extension .tex) : '];
txt2='';
while trydlg
answer = inputdlg({[txt txt2]},...
'LaPrint Settings',1,{LAPRINTOPT.viewfilename},'on');
if length(answer)
if strcmp(answer{1},LAPRINTOPT.filename)
txt2=['The name must be different from the name of the '...
'graphics file):'];
else
trydlg=0;
LAPRINTOPT.viewfilename = answer{1};
[viewfullnameext,viewbasenameext,viewbasename,viewdirname] = ...
getfilenames(LAPRINTOPT.viewfilename,'tex',0);
end
else
trydlg=0;
end
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'processview'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
if LAPRINTOPT.processview==1
LAPRINTOPT.processview=0;
set(LAPRINTHAN.processview,'check','off')
else
LAPRINTOPT.processview=1;
set(LAPRINTHAN.processview,'check','on')
LAPRINTOPT.createview=1;
set(LAPRINTHAN.createview,'check','on')
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'cmdsview'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
answer = inputdlg({...
['Please enter up to 8 commands to process the view-file. ',...
'Leave any of the fields empty, if you have ',...
'less than 8 commands. ',...
'In any of the following commands, LaPrint internally '...
'replaces the tag <viewfile> by the name of the viewfile ',...
'and the tag <filename> by the basename specified in the ',...
'main LaPrint Window. ',...
'At minimum you should enter the commands for the LaTeX ',...
'compilation and for the dvi-to-postscript conversion ',...
'here. See the LaPrint Online-Help for futher ',...
'suggestions. ',...
'Please enter the 1st command:'],...
'Please enter the 2nd command:',...
'Please enter the 3rd command:',...
'Please enter the 4th command:',...
'Please enter the 5th command:',...
'Please enter the 6th command:',...
'Please enter the 7th command:',...
'Please enter the 8th command:'},...
'LaPrint Settings',1,{LAPRINTOPT.cmd1,...
LAPRINTOPT.cmd2,LAPRINTOPT.cmd3,...
LAPRINTOPT.cmd4,LAPRINTOPT.cmd5,LAPRINTOPT.cmd6,...
LAPRINTOPT.cmd7,LAPRINTOPT.cmd8},'on');
if length(answer)==8
LAPRINTOPT.cmd1=answer{1};
LAPRINTOPT.cmd2=answer{2};
LAPRINTOPT.cmd3=answer{3};
LAPRINTOPT.cmd4=answer{4};
LAPRINTOPT.cmd5=answer{5};
LAPRINTOPT.cmd6=answer{6};
LAPRINTOPT.cmd7=answer{7};
LAPRINTOPT.cmd8=answer{8};
end
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'getpref'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
out = prefsettings;
if ~isempty(out)
oldfigno = LAPRINTOPT.figno; % keep this!
LAPRINTOPT = out;
LAPRINTOPT.figno = oldfigno;
else
errordlg('No LaPrint preferences available.')
end
updategui(LAPRINTHAN,LAPRINTOPT);
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'setpref'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
setpref('LaPrint','LAPRINTOPT',LAPRINTOPT);
case 'rmpref'
if ispref('LaPrint')
rmpref('LaPrint');
else
errordlg('Preference does not exist.')
end
case 'savepref'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
txt = 'Save preferences file ';
[preffile,prefpath]=uiputfile('laprint.mat',txt);
save([prefpath preffile],'LAPRINTOPT');
case 'loadpref'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
txt = ['Load preferences file '...
'(must be previously created by LaPrint)'];
[preffile,prefpath]=uigetfile('laprint.mat',txt);
if ~isequal(preffile,0) & ~isequal(prefpath,0)
oldfigno = LAPRINTOPT.figno; % keep this!
load([prefpath preffile]); % hope file contains correct
LAPRINTOPT.figno = oldfigno; % LAPRINTOPT
updategui(LAPRINTHAN,LAPRINTOPT);
sethf(hf,LAPRINTHAN,LAPRINTOPT);
end
case 'factory'
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
out = factorysettings;
if ~isempty(out)
oldfigno = LAPRINTOPT.figno; % keep this!
LAPRINTOPT = out;
LAPRINTOPT.figno = oldfigno;
else
errordlg('No LaPrint preferences available.')
end
updategui(LAPRINTHAN,LAPRINTOPT);
sethf(hf,LAPRINTHAN,LAPRINTOPT);
case 'helpwindow'
hhf=figure(hhf);
set(hhf,'Name','LaPrint Online Help',...
'Numbertitle','off',...
'menubar','none',...
'HandleVisibility','callback',...
'resize','on',...
'ResizeFcn','laprint(''helpwindow'');');
hht=uicontrol('Parent',hhf,...
'style','listbox',...
'units','normalized',...
'position',[0.005 0.005 0.9 0.99],...
'BackgroundColor','w',...
'Fontsize',12,...
'foregroundcolor','k',...
'FontName','FixedWidth',...
'HorizontalAlignment','left');
[txt,hhtpos]=textwrap(hht,helptext);
set(hht,'string',txt)
set(hht,'position',[0.005 0.005 0.99 0.99])
set(hht,'HandleVisibility','callback')
case 'whois'
msgbox({['This is LaPrint, Version ' laprintident],...
'',...
'To blame for LaPrint:',...
'Arno Linnemann','Control and Automation',...
'Department of Electrical and Computer Engineering',...
'University of Kassel',...
'34109 Kassel',...
'Germany',...
'mailto:[email protected]'},...
'LaPrint Info')
otherwise
error('unknown callback option')
end
return
end % if isa(figno,'char')
% nargin >=1 and ~isa(figno,'char')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% PART 1 of advanced usage:
%%%% Check inputs and initialize
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isa(figno,'cell') % called from GUI (all set)
[LAPRINTHAN,LAPRINTOPT]=gethf(hf);
figno=LAPRINTOPT.figno;
filename=LAPRINTOPT.filename;
else % advanced usage
% get settings
LAPRINTOPT = prefsettings;
if isempty(LAPRINTOPT)
LAPRINTOPT = factorysettings;
end
% modify prefs
if ~isa(figno,'double')
figno
error('This is not a figure handle.')
end
if ~any(get(0,'children')==figno)
figno
error('This is not a figure handle.')
end
LAPRINTOPT.figno = figno;
if nargin>1
if ~isa(filename,'char')
filename
error('This is not a file name.')
end
LAPRINTOPT.filename=filename;
end
end
% read and check command line options
try % try old usage (Version 2.03)
if nargin <=2
error('lets take new usage')
end
% 2.03 defaults
width = 12;
factor = 0.8;
scalefonts = 1;
keepfontprops = 0;
asonscreen = 0;
keepticklabels = 0;
mathticklabels = 0;
head = 1;
comment = '';
caption = '';
extrapicture = 1;
nzeros = 5;
verbose = 0;
figcopy = 1;
printcmd = ['print(''-f<figurenumber>'',' ...
'''-deps'',''<filename.eps>'')'];
package = 'epsfig';
color = 0;
createview = 0;
viewfilename = [filename '_'];
processview = 0;
cmd1 = '';
cmd2 = '';
cmd3 = '';
cmd4 = '';
cmd5 = '';
cmd6 = '';
cmd7 = '';
cmd8 = '';
for i=1:nargin-2
if ~isa(varargin{i},'char')
error('Options must be character arrays.')
end
oriopt=varargin{i}(:)';
opt=[ lower(strrep(oriopt,' ','')) ' ' ];
if strcmp(opt(1:7),'verbose')
verbose=1;
elseif strcmp(opt(1:10),'asonscreen')
asonscreen=1;
elseif strcmp(opt(1:14),'keepticklabels')
keepticklabels=1;
elseif strcmp(opt(1:14),'mathticklabels')
mathticklabels=1;
elseif strcmp(opt(1:13),'keepfontprops')
keepfontprops=1;
elseif strcmp(opt(1:14),'noextrapicture')
extrapicture=0;
elseif strcmp(opt(1:14),'noextrapicture')
extrapicture=0;
elseif strcmp(opt(1:5),'loose')
printcmd = ['print(''-f<figurenumber>'',' ...
'''-deps'',''-loose'',''<filename.eps>'')'];
elseif strcmp(opt(1:9),'nofigcopy')
figcopy=0;
elseif strcmp(opt(1:12),'noscalefonts')
scalefonts=0;
elseif strcmp(opt(1:6),'nohead')
head=0;
elseif strcmp(opt(1:7),'caption')
eqpos=findstr(oriopt,'=');
if isempty(eqpos)
caption='Matlab Figure';
else
caption=oriopt(eqpos+1:length(oriopt));
end
elseif strcmp(opt(1:8),'comment=')
eqpos=findstr(oriopt,'=');
comment=oriopt(eqpos(1)+1:length(oriopt));
elseif strcmp(opt(1:9),'viewfile=')
createview=1;
eqpos=findstr(oriopt,'=');
viewfilename=oriopt(eqpos(1)+1:length(oriopt));
elseif strcmp(opt(1:6),'width=')
eval([ opt ';' ]);
elseif strcmp(opt(1:7),'factor=')
eval([ opt ';' ]);
else
error([ 'Option ' varargin{i} ' not recognized.'])
end
end
warning('LaPrint:general',['You are using the old LaPrint '...
'syntax. This syntax might not be supported in '...
'future releases of LaPrint.'])
catch % old usage doesn't work, take new one
% restore preferences / factory defaults
width = LAPRINTOPT.width;
factor = LAPRINTOPT.factor;
scalefonts = LAPRINTOPT.scalefonts;
keepfontprops = LAPRINTOPT.keepfontprops;
asonscreen = LAPRINTOPT.asonscreen;
keepticklabels = LAPRINTOPT.keepticklabels;
mathticklabels = LAPRINTOPT.mathticklabels;
head = LAPRINTOPT.head;
comment = LAPRINTOPT.comment;
caption = LAPRINTOPT.caption;
extrapicture = LAPRINTOPT.extrapicture;
nzeros = LAPRINTOPT.nzeros;
verbose = LAPRINTOPT.verbose;
figcopy = LAPRINTOPT.figcopy;
printcmd = LAPRINTOPT.printcmd;
package = LAPRINTOPT.package;
color = LAPRINTOPT.color;
createview = LAPRINTOPT.createview;
viewfilename = LAPRINTOPT.viewfilename;
processview = LAPRINTOPT.processview;
cmd1 = LAPRINTOPT.cmd1;
cmd2 = LAPRINTOPT.cmd2;
cmd3 = LAPRINTOPT.cmd3;
cmd4 = LAPRINTOPT.cmd4;
cmd5 = LAPRINTOPT.cmd5;
cmd6 = LAPRINTOPT.cmd6;
cmd7 = LAPRINTOPT.cmd7;
cmd8 = LAPRINTOPT.cmd8;
if nargin > 2
if rem(nargin,2)
error('Option names/values must appear in pairs.')
end
for i=1:2:nargin-2
if ~isa(varargin{i},'char')
error('Option name must be a character array.')
end
opt = lower(strrep(varargin{i}(:)',' ',''));
val = varargin{i+1}(:)';
switch opt
case 'options'
if isa(val,'char')
if strcmp(val,'factory')
val = factorysettings;
else
load(val)
val = LAPRINTOPT;
end
end
if ~isa(val,'struct')
error('Value of options must be a structure array.')
end
% no error checking here!
width = val.width;
factor = val.factor;
scalefonts = val.scalefonts;
keepfontprops = val.keepfontprops;
asonscreen = val.asonscreen;
keepticklabels = val.keepticklabels;
mathticklabels = val.mathticklabels;
head = val.head;
comment = val.comment;
caption = val.caption;
extrapicture = val.extrapicture;
nzeros = val.nzeros;
verbose = val.verbose;
figcopy = val.figcopy;
printcmd = val.printcmd;
package = val.package;
color = val.color;
createview = val.createview;
viewfilename = val.viewfilename;
processview = val.processview;
cmd1 = val.cmd1;
cmd2 = val.cmd2;
cmd3 = val.cmd3;
cmd4 = val.cmd4;
cmd5 = val.cmd5;
cmd6 = val.cmd6;
cmd7 = val.cmd7;
cmd8 = val.cmd8;
case 'width'
if ~isa(val,'double')
error('Value of width must be a double.')
end
width = val;
case 'factor'
if ~isa(val,'double')
error('Value of factor must be a double.')
end
factor=val;
case 'scalefonts'
scalefonts = value01(val,opt);
case 'keepfontprops'
keepfontprops = value01(val,opt);
case 'asonscreen'
asonscreen = value01(val,opt);
case 'keepticklabels'
keepticklabels = value01(val,opt);
case 'mathticklabels'
mathticklabels = value01(val,opt) ;