Mercurial > hg > octave-nkf
annotate scripts/plot/__fltk_ginput__.m @ 11575:d6619410e79c
Spellcheck documentation before 3.4 release.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 19 Jan 2011 21:16:13 -0800 |
parents | fd0a3ac60b0e |
children | c792872f8942 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2010-2011 Shai Ayal |
10517 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} __fltk_ginput__ (@var{f}, @var{n}) | |
21 ## Undocumented internal function. | |
22 ## @end deftypefn | |
23 | |
24 ## This is ginput.m implementation for fltk. | |
25 | |
26 function [x, y, button] = __fltk_ginput__ (f, n = -1) | |
27 | |
28 if (isempty (get (f, "currentaxes"))) | |
29 error ("ginput: must have at least one axes"); | |
30 endif | |
31 | |
11194
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
32 x = y = button = []; |
10517 | 33 ginput_aggregator (0, 0, 0); |
34 | |
35 unwind_protect | |
36 | |
37 orig_windowbuttondownfcn = get (f, "windowbuttondownfcn"); | |
38 set (f, "windowbuttondownfcn", @ginput_windowbuttondownfcn); | |
39 | |
40 orig_ginput_keypressfcn = get (f, "keypressfcn"); | |
41 set (f, "keypressfcn", @ginput_keypressfcn); | |
42 | |
43 while (true) | |
44 __fltk_redraw__ (); | |
45 | |
46 ## release CPU | |
47 sleep (0.01); | |
48 | |
49 [x, y, n0] = ginput_aggregator (-1, 0, 0); | |
11092
8b9aeb20c03c
__fltk_ginput__.m: use || instead of | in IF condition
John W. Eaton <jwe@octave.org>
parents:
10517
diff
changeset
|
50 if (n0 == n || n0 < 0) |
10517 | 51 break; |
52 endif | |
53 endwhile | |
54 | |
55 ## FIXME -- got to get the buttons somehow | |
56 button = ones (size (x)); | |
57 unwind_protect_cleanup | |
58 set (f, "windowbuttondownfcn", orig_windowbuttondownfcn); | |
59 set (f, "keypressfcn", orig_ginput_keypressfcn); | |
60 end_unwind_protect | |
61 | |
62 endfunction | |
63 | |
64 function [x, y, n] = ginput_aggregator (mode , xn, yn) | |
11194
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
65 persistent x y n; |
10517 | 66 |
11194
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
67 if (mode == 0) |
10517 | 68 x = []; |
69 y = []; | |
70 n = 0; | |
71 elseif (mode == 1) | |
11194
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
72 x = [x; xn]; |
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
73 y = [y; yn]; |
10517 | 74 n += 1; |
75 elseif (mode == 2) | |
11194
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
76 n = -1; |
10517 | 77 endif |
78 endfunction | |
79 | |
80 function ginput_windowbuttondownfcn (src, data) | |
81 point = get (get (src,"currentaxes"), "currentpoint"); | |
82 ginput_aggregator (1, point(1,1), point(2,1)); | |
83 endfunction | |
84 | |
85 function ginput_keypressfcn (src, evt) | |
11194
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
86 if (evt.Key == 10) # linefeed character |
b8585f8e11d5
__fltk_ginput__.m: Use semicolons to prevent internal function evaluations being output to screen.
Rik <octave@nomad.inbox5.com>
parents:
11092
diff
changeset
|
87 ginput_aggregator (2, 0, 0); |
10517 | 88 endif |
89 endfunction | |
90 |