summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/ginput3.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/ginput3.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/ginput3.m216
1 files changed, 216 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/ginput3.m b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/ginput3.m
new file mode 100755
index 0000000..56fe496
--- /dev/null
+++ b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/ginput3.m
@@ -0,0 +1,216 @@
1function [out1,out2,out3] = ginput2(arg1)
2%GINPUT Graphical input from mouse.
3% [X,Y] = GINPUT(N) gets N points from the current axes and returns
4% the X- and Y-coordinates in length N vectors X and Y. The cursor
5% can be positioned using a mouse (or by using the Arrow Keys on some
6% systems). Data points are entered by pressing a mouse button
7% or any key on the keyboard except carriage return, which terminates
8% the input before N points are entered.
9%
10% [X,Y] = GINPUT gathers an unlimited number of points until the
11% return key is pressed.
12%
13% [X,Y,BUTTON] = GINPUT(N) returns a third result, BUTTON, that
14% contains a vector of integers specifying which mouse button was
15% used (1,2,3 from left) or ASCII numbers if a key on the keyboard
16% was used.
17
18% Copyright (c) 1984-96 by The MathWorks, Inc.
19% $Revision: 5.18 $ $Date: 1996/11/10 17:48:08 $
20
21% Fixed version by Jean-Yves Bouguet to have a cross instead of 2 lines
22% More visible for images
23
24P = NaN*ones(16,16);
25P(1:15,1:15) = 2*ones(15,15);
26P(2:14,2:14) = ones(13,13);
27P(3:13,3:13) = NaN*ones(11,11);
28P(6:10,6:10) = 2*ones(5,5);
29P(7:9,7:9) = 1*ones(3,3);
30
31out1 = []; out2 = []; out3 = []; y = [];
32c = computer;
33if ~strcmp(c(1:2),'PC') & ~strcmp(c(1:2),'MA')
34 tp = get(0,'TerminalProtocol');
35else
36 tp = 'micro';
37end
38
39if ~strcmp(tp,'none') & ~strcmp(tp,'x') & ~strcmp(tp,'micro'),
40 if nargout == 1,
41 if nargin == 1,
42 eval('out1 = trmginput(arg1);');
43 else
44 eval('out1 = trmginput;');
45 end
46 elseif nargout == 2 | nargout == 0,
47 if nargin == 1,
48 eval('[out1,out2] = trmginput(arg1);');
49 else
50 eval('[out1,out2] = trmginput;');
51 end
52 if nargout == 0
53 out1 = [ out1 out2 ];
54 end
55 elseif nargout == 3,
56 if nargin == 1,
57 eval('[out1,out2,out3] = trmginput(arg1);');
58 else
59 eval('[out1,out2,out3] = trmginput;');
60 end
61 end
62else
63
64 fig = gcf;
65 figure(gcf);
66
67 if nargin == 0
68 how_many = -1;
69 b = [];
70 else
71 how_many = arg1;
72 b = [];
73 if isstr(how_many) ...
74 | size(how_many,1) ~= 1 | size(how_many,2) ~= 1 ...
75 | ~(fix(how_many) == how_many) ...
76 | how_many < 0
77 error('Requires a positive integer.')
78 end
79 if how_many == 0
80 ptr_fig = 0;
81 while(ptr_fig ~= fig)
82 ptr_fig = get(0,'PointerWindow');
83 end
84 scrn_pt = get(0,'PointerLocation');
85 loc = get(fig,'Position');
86 pt = [scrn_pt(1) - loc(1), scrn_pt(2) - loc(2)];
87 out1 = pt(1); y = pt(2);
88 elseif how_many < 0
89 error('Argument must be a positive integer.')
90 end
91 end
92
93pointer = get(gcf,'pointer');
94
95set(gcf,'Pointer','custom','PointerShapeCData',P,'PointerShapeHotSpot',[8,8]);
96%set(gcf,'pointer','crosshair');
97 fig_units = get(fig,'units');
98 char = 0;
99
100 while how_many ~= 0
101 % Use no-side effect WAITFORBUTTONPRESS
102 waserr = 0;
103 eval('keydown = wfbp;', 'waserr = 1;');
104 if(waserr == 1)
105 if(ishandle(fig))
106 set(fig,'pointer',pointer,'units',fig_units);
107 error('Interrupted');
108 else
109 error('Interrupted by figure deletion');
110 end
111 end
112
113 ptr_fig = get(0,'CurrentFigure');
114 if(ptr_fig == fig)
115 if keydown
116 char = get(fig, 'CurrentCharacter');
117 button = abs(get(fig, 'CurrentCharacter'));
118 scrn_pt = get(0, 'PointerLocation');
119 set(fig,'units','pixels')
120 loc = get(fig, 'Position');
121 pt = [scrn_pt(1) - loc(1), scrn_pt(2) - loc(2)];
122 set(fig,'CurrentPoint',pt);
123 else
124 button = get(fig, 'SelectionType');
125 if strcmp(button,'open')
126 button = b(length(b));
127 elseif strcmp(button,'normal')
128 button = 1;
129 elseif strcmp(button,'extend')
130 button = 2;
131 elseif strcmp(button,'alt')
132 button = 3;
133 else
134 error('Invalid mouse selection.')
135 end
136 end
137 pt = get(gca, 'CurrentPoint');
138
139 how_many = how_many - 1;
140
141 if(char == 13) % & how_many ~= 0)
142 % if the return key was pressed, char will == 13,
143 % and that's our signal to break out of here whether
144 % or not we have collected all the requested data
145 % points.
146 % If this was an early breakout, don't include
147 % the <Return> key info in the return arrays.
148 % We will no longer count it if it's the last input.
149 break;
150 end
151
152 out1 = [out1;pt(1,1)];
153 y = [y;pt(1,2)];
154 b = [b;button];
155 end
156 end
157
158 set(fig,'pointer',pointer,'units',fig_units);
159
160 if nargout > 1
161 out2 = y;
162 if nargout > 2
163 out3 = b;
164 end
165 else
166 out1 = [out1 y];
167 end
168
169end
170
171%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172function key = wfbp
173%WFBP Replacement for WAITFORBUTTONPRESS that has no side effects.
174
175% Remove figure button functions
176fprops = {'windowbuttonupfcn','buttondownfcn', ...
177 'windowbuttondownfcn','windowbuttonmotionfcn'};
178fig = gcf;
179fvals = get(fig,fprops);
180set(fig,fprops,{'','','',''})
181
182% Remove all other buttondown functions
183ax = findobj(fig,'type','axes');
184if isempty(ax)
185 ch = {};
186else
187 ch = get(ax,{'Children'});
188end
189for i=1:length(ch),
190 ch{i} = ch{i}(:)';
191end
192h = [ax(:)',ch{:}];
193vals = get(h,{'buttondownfcn'});
194mt = repmat({''},size(vals));
195set(h,{'buttondownfcn'},mt);
196
197% Now wait for that buttonpress, and check for error conditions
198waserr = 0;
199eval(['if nargout==0,', ...
200 ' waitforbuttonpress,', ...
201 'else,', ...
202 ' keydown = waitforbuttonpress;',...
203 'end' ], 'waserr = 1;');
204
205% Put everything back
206if(ishandle(fig))
207 set(fig,fprops,fvals)
208 set(h,{'buttondownfcn'},vals)
209end
210
211if(waserr == 1)
212 error('Interrupted');
213end
214
215if nargout>0, key = keydown; end
216%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%