/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_misc/gcmfaces_caption.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_misc/gcmfaces_caption.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations) (download)
Mon Mar 14 15:56:49 2016 UTC (9 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.2: +34 -27 lines
- diags_display.m: set addToTex=1 but fileTex='' to go through write2tex
  but simply to add figure captions (when using diags_display directly).
- write2tex.m: add call to gcmfaces_caption (also when fileTex='') and
  save figures (atfter print to eps and activation of caption).
- gcmfaces_caption.m: output captionHandle; include 'Children' in
  visibility switch; rename temporary variables as gfCapTmp and gfCapTmppp;
  revise uipanel aspect and position.

1 gforget 1.3 function [captionHandle]=gcmfaces_caption(myCaption);
2     % [captionHandle]=GCMFACES_CAPTION(myCaption) adds an editable
3 gforget 1.1 % caption to the current figure and menu buttons
4     % to show or hide it, or return its handle.
5 gforget 1.2 %
6     % Notes:
7     % 1) the added menu functionalities only support one
8     % caption per figure.
9     % 2) the added menu functionalities operate with two
10 gforget 1.3 % temporary variables (gfCapTmp, gfCapTmppp) that get
11 gforget 1.2 % deleted after each callback.
12 gforget 1.1
13     gcmfaces_global;
14    
15     %the on/off button callback in text form
16     capOnOff=[...
17 gforget 1.3 'gfCapTmp.h=findall(gcf,''type'',''uipanel'');' ...
18     'gfCapTmp.nh=length(gfCapTmp.h);' ...
19     'gfCapTmp.captionHandle=[];' ...
20     'for gfCapTmppp=1:length(gfCapTmp.h);' ...
21     ' gfCapTmp.tag=get(gfCapTmp.h(gfCapTmppp),''Tag'');' ...
22     ' if ~isempty(strfind(gfCapTmp.tag,''gfCap''));' ...
23     ' gfCapTmp.captionHandle=gfCapTmp.h(gfCapTmppp);' ...
24 gforget 1.1 ' end;' ...
25     'end;' ...
26 gforget 1.3 'gfCapTmp.tmp1=get(gfCapTmp.captionHandle,''Visible'');' ...
27     'if strcmp(gfCapTmp.tmp1,''on'');' ...
28     ' gfCapTmp.tmp1=''off'';' ...
29 gforget 1.1 'else;' ...
30 gforget 1.3 ' gfCapTmp.tmp1=''on''; ' ...
31 gforget 1.1 'end;' ...
32 gforget 1.3 'set(gfCapTmp.captionHandle,''Visible'',gfCapTmp.tmp1);' ...
33     'set(get(gfCapTmp.captionHandle,''Children''),''Visible'',gfCapTmp.tmp1);'...
34     'clear gfCapTmp gfCapTmppp;' ...
35 gforget 1.1 ];
36    
37     capHandle=[...
38 gforget 1.3 'gfCapTmp.h=findall(gcf,''type'',''uipanel'');' ...
39     'gfCapTmp.nh=length(gfCapTmp.h);' ...
40 gforget 1.1 'captionHandle=[];' ...
41 gforget 1.3 'for gfCapTmppp=1:length(gfCapTmp.h);' ...
42     ' gfCapTmp.tag=get(gfCapTmp.h(gfCapTmppp),''Tag'');' ...
43     ' if ~isempty(strfind(gfCapTmp.tag,''gfCap''));' ...
44     ' captionHandle=gfCapTmp.h(gfCapTmppp);' ...
45 gforget 1.1 ' end;' ...
46     'end;' ...
47 gforget 1.3 'clear gfCapTmp gfCapTmppp;' ...
48 gforget 1.1 'evalin(''base'',''captionHandle'');' ...
49     ];
50    
51     %use call back for example:
52     if isempty(who('myCaption'));
53     myCaption='';
54     %use call back for example:
55     %myCaption=['example: ' capOnOff];
56     end;
57    
58     %create and tag panel:
59 gforget 1.3 %hp = uipanel('Title','Caption','FontSize',12,...
60     hp = uipanel('FontSize',12,...
61 gforget 1.1 'BackgroundColor','white',...
62 gforget 1.3 'Position',[.2 0.05 .6 .1]);
63 gforget 1.1 set(hp,'Tag','gfCap');
64    
65     %add the caption text in panel:
66 gforget 1.3 txt = uicontrol('Parent',hp,'Style', 'edit',...
67     'BackgroundColor','white','FontSize',12,...
68     'Max',2,'Min',0, 'String', ['Caption: ' myCaption]);
69     set(txt,'units','normalized');
70 gforget 1.1 set(txt,'Position',[0.05 0.1 0.9 0.8])
71    
72     %add menu button:
73     mn=uimenu('Label','Caption');
74     uimenu(mn,'Label','Hide/Show','Callback',capOnOff);
75     uimenu(mn,'Label','captionHandle','Callback',capHandle);
76    
77 gforget 1.3 %output caption handle:
78     captionHandle=hp;
79    

  ViewVC Help
Powered by ViewVC 1.1.22