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

root/gliderproc/trunk/MATLAB/opnml/basics/stretchcircle.m

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

Initial import of Stark code.

Line 
1 function line_coords=stretchline(action)
2 % STRETCHLINE creates a line and stretches it following the mouse
3 %
4 % TO USE: set(gcf,'WindowButtonDownFcn','stretchline')
5 %
6 % Written by: Brian Blanton (Dec 98)
7
8 if nargin==0  % Button pushed, initialize
9
10   % Get the current WindowButton*Fcn's, and store globally
11   % for return
12   global WindowButtonDownFcn WindowButtonMotionFcn WindowButtonUpFcn
13   WindowButtonDownFcn = get(gcf,'WindowButtonDownFcn');
14   WindowButtonMotionFcn = get(gcf,'WindowButtonMotionFcn');
15   WindowButtonUpFcn = get(gcf,'WindowButtonUpFcn');
16
17 % Delete any previous text and lines from stretchline
18   delete(findobj(gca,'Tag','Box Lines For stretchline'))
19   delete(findobj(gca,'Tag','Text1 For stretchline'))
20   delete(findobj(gca,'Tag','Text2 For stretchline'))
21
22   % Determine the location of the mouse and create the XData,
23   % YData, and ZData for the line coords.
24   currrentpoint = get(gca,'CurrentPoint');
25   xpos = [currrentpoint(1) currrentpoint(1)];
26   ypos = [currrentpoint(3) currrentpoint(3)];
27   zpos = [0 0];
28  
29   % Add some text that displays the current point
30   tp1 = text(currrentpoint(1),currrentpoint(3),...
31         sprintf('(%8.3f,%8.3f)',currrentpoint(1),currrentpoint(3)), ...
32        'Tag','Text1 For stretchline','HorizontalAlignment','center');
33
34   % Create the initial line object
35   hs = line('XData',xpos,'YData',ypos,'ZData',zpos, ...
36        'Color','r','EraseMode','xor', ...
37        'LineStyle','--','Tag','Box Lines For stretchline','LineWidth',2);
38
39   % Add some text that displays the current point
40   tp2 = text(currrentpoint(1),currrentpoint(3),...
41         sprintf('(%8.3,%8.3f)',currrentpoint(1),currrentpoint(3)), ...
42        'EraseMode','xor','Tag','Text2 For stretchline','HorizontalAlignment','center');
43
44   % Set the WindowButtonMotionFcn WindowButtonUpFcn
45   set(gcf,'WindowButtonMotionFcn','stretchline move', ...
46           'WindowButtonUpFcn','stretchline up')
47
48 elseif strcmp(action,'move');  % Mouse moved
49
50   % Get the location of the mouse
51   currrentpoint = get(gca,'CurrentPoint');
52  
53   % Find the handle to the surface plot and text object
54   hs = findobj(gca,'Type','line','Tag','Box Lines For stretchline');
55   tp2 = findobj(gca,'Type','text','Tag','Text2 For stretchline');
56
57   % Update the locations of the line plot and text object #2
58   xpos = get(hs,'XData');
59   ypos = get(hs,'YData');
60   xpos(2) = [currrentpoint(1)];
61   ypos(2) = [currrentpoint(3)];
62   set(hs,'XData',xpos,'YData',ypos)
63   set(tp2,'Position',[currrentpoint(1) currrentpoint(3) 0],...
64           'String',sprintf('(%8.3f,%8.3f)',currrentpoint(1),currrentpoint(3)));
65
66 elseif strcmp(action,'up')   
67 %%%%
68 %%%% Mouse button released
69 %%%
70    % Set the WindowButtonDownFcn WindowButtonMotionFcn, and
71    % WindowButtonUpFcn to original values.
72    global WindowButtonDownFcn WindowButtonMotionFcn WindowButtonUpFcn
73    set(gcf,'WindowButtonDownFcn',WindowButtonDownFcn, ...
74            'WindowButtonMotionFcn',WindowButtonMotionFcn, ...
75            'WindowButtonUpFcn',WindowButtonUpFcn)
76    clear global WindowButtonDownFcn WindowButtonMotionFcn WindowButtonUpFcn
77
78 end 
79
80 %set(gcf,'WindowButtonDownFcn','', ...
81 %          'WindowButtonMotionFcn','', ...
82 %          'WindowButtonUpFcn','')
Note: See TracBrowser for help on using the browser.