NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/matlab_cen/labcont2.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 %
2 % LABCONT  -  label contours drawn with LCONTOUR2
3 %
4 %             LABCONT labels contours on the current axes that have been
5 %             previously drawn with LCONTOUR2.  Start up LABCONT by
6 %             typing "labcont" at the MATLAB prompt (>>).  Then,
7 %             click on the contour to label with the left mouse-button.
8 %             Continue clicking with the left mouse-button button until
9 %             all the labels have been added, then press the right
10 %             mouse-button in the current axes to stop LABCONT.  If
11 %             an output argument was supplied to LABCONT, the handles
12 %             to the text objects pointing to the labels is returned
13 %             to the MATLAB workspace.
14 %
15 % Written by : Brian O. Blanton, March 96
16 %
17
18 function h=labcont2
19
20 if nargin~=0
21    error('labcont2 takes 0 input arguments')
22 elseif nargin~=0 & nargout~=1
23    error('LABCONT2 takes 0 or 1 output arguments.')
24 end
25
26 %
27 % save the current value of the current figure's WindowButtonDownFcn,
28 % WindowButtonMotionFcn, and WindowButtonUpFcn
29 %
30 WindowButtonDownFcn=get(gcf,'WindowButtonDownFcn');
31 WindowButtonMotionFcn=get(gcf,'WindowButtonMotionFcn');
32 WindowButtonUpFcn=get(gcf,'WindowButtonUpFcn');
33 set(gcf,'WindowButtonDownFcn','');
34 set(gcf,'WindowButtonMotionFcn','');
35 set(gcf,'WindowButtonUpFcn','');
36
37
38 npts=0;
39 disp('Click on contour with left mouse-button, right button to end')
40
41 while 1
42    waitforbuttonpress;
43    seltype=get(gcf,'SelectionType');
44    if ~strcmp(seltype,'normal')break,end
45
46    target=gco;
47    if ~strcmp(get(target,'Tag'),'contour')
48       disp('Target NOT a contour from LCONTOUR2 or ISOPHASE')
49    else
50       npts=npts+1;
51       val=get(target,'UserData');
52       pt=gcp;
53       ht(npts)=text(pt(2),pt(4),num2str(val),...
54                    'HorizontalAlignment','Center','FontSize',10);
55       textlen=get(ht(npts),'Extent');
56       jx1=textlen(1);
57       jy1=textlen(2);
58       jx2=textlen(1)+textlen(3);
59       jy2=textlen(2)+textlen(4);
60       delete(ht(npts))
61       fill([jx1 jx2 jx2 jx1],[jy1 jy1 jy2 jy2],'w','Edgecolor','w')
62       ht(npts)=text(pt(2),pt(4),num2str(val),...
63                    'HorizontalAlignment','Center','FontSize',10);
64       set(ht(npts),'color','k')
65    end
66 end
67
68 if nargout==1
69    h=ht;
70 end
71
72 %
73 % return the saved values of the current figure's WindowButtonDownFcn,
74 % WindowButtonMotionFcn, and WindowButtonUpFcn to the current figure
75 %
76 set(gcf,'WindowButtonDownFcn',WindowButtonDownFcn);
77 set(gcf,'WindowButtonMotionFcn',WindowButtonMotionFcn);
78 set(gcf,'WindowButtonUpFcn',WindowButtonUpFcn);
79
80 %
81 %        Brian O. Blanton
82 %        Curr. in Marine Science
83 %        15-1A Venable Hall
84 %        CB# 3300
85 %        Uni. of North Carolina
86 %        Chapel Hill, NC
87 %                 27599-3300
88 %
89 %        919-962-4466
90 %        blanton@marine.unc.edu
91 %
92
Note: See TracBrowser for help on using the browser.