Mercurial > hg > octave-lyh
annotate scripts/plot/private/__fltk_ginput__.m @ 17184:abf384f5d243
maint: Remove unneeded input validation from internal fcns in private/ directories.
* scripts/general/private/__isequal__.m,
scripts/general/private/__splinen__.m,
scripts/image/private/__imwrite__.m,
scripts/image/private/ind2x.m,
scripts/miscellaneous/private/__xzip__.m,
scripts/miscellaneous/private/display_info_file.m,
scripts/pkg/private/describe.m,
scripts/pkg/private/get_forge_pkg.m,
scripts/pkg/private/unload_packages.m,
scripts/plot/private/__actual_axis_position__.m,
scripts/plot/private/__add_datasource__.m,
scripts/plot/private/__clabel__.m,
scripts/plot/private/__errcomm__.m,
scripts/plot/private/__errplot__.m,
scripts/plot/private/__fltk_print__.m,
scripts/plot/private/__gnuplot_get_var__.m,
scripts/plot/private/__go_draw_axes__.m,
scripts/plot/private/__go_draw_figure__.m,
scripts/plot/private/__interp_cube__.m,
scripts/plot/private/__line__.m,
scripts/plot/private/__next_line_color__.m,
scripts/plot/private/__next_line_style__.m,
scripts/plot/private/__plt__.m,
scripts/plot/private/__pltopt__.m,
scripts/signal/private/rectangle_lw.m,
scripts/signal/private/rectangle_sw.m,
scripts/signal/private/triangle_lw.m,
scripts/signal/private/triangle_sw.m,
scripts/sparse/private/__sprand_impl__.m,
scripts/statistics/models/private/logistic_regression_derivatives.m,
scripts/statistics/models/private/logistic_regression_likelihood.m:
Remove unneeded input validation from internal fcns in private/ directories.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 04 Aug 2013 18:13:08 -0700 |
parents | fc3845c63458 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12793
diff
changeset
|
1 ## Copyright (C) 2010-2012 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 = []; |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
33 ginput_accumulator (0, 0, 0, 0); # initialize accumulator |
10517 | 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); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
42 |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
43 do |
10517 | 44 __fltk_redraw__ (); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
45 |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
46 ## Release CPU. |
10517 | 47 sleep (0.01); |
48 | |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
49 [x, y, n0, button] = ginput_accumulator (-1, 0, 0, 0); |
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
50 until (n0 == n || n0 < 0) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 |
10517 | 52 unwind_protect_cleanup |
53 set (f, "windowbuttondownfcn", orig_windowbuttondownfcn); | |
54 set (f, "keypressfcn", orig_ginput_keypressfcn); | |
55 end_unwind_protect | |
56 | |
57 endfunction | |
58 | |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
59 function [x, y, n, button] = ginput_accumulator (mode, xn, yn, btn) |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
60 persistent x y n button; |
10517 | 61 |
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
|
62 if (mode == 0) |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
63 ## Initialize. |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
64 x = y = button = []; |
10517 | 65 n = 0; |
66 elseif (mode == 1) | |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
67 ## Append mouse button or key press. |
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
|
68 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
|
69 y = [y; yn]; |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
70 button = [button; btn]; |
10517 | 71 n += 1; |
72 elseif (mode == 2) | |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
73 ## The end due to Enter. |
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
|
74 n = -1; |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
75 endif |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
76 |
10517 | 77 endfunction |
78 | |
79 function ginput_windowbuttondownfcn (src, data) | |
80 point = get (get (src,"currentaxes"), "currentpoint"); | |
16785
3d981b47be42
Return button information for ginput when using FLTK (bug #32178)
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
81 button = data; |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
82 ginput_accumulator (1, point(1,1), point(2,1), button); |
10517 | 83 endfunction |
84 | |
85 function ginput_keypressfcn (src, evt) | |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
86 point = get (get (src, "currentaxes"), "currentpoint"); |
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
87 key = evt.Key; |
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
88 if (key == 10) |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
89 ## Enter key stops ginput. |
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
90 ginput_accumulator (2, NaN, NaN, NaN); |
12219
17d7834df7b4
__fltk_ginput__.m: return keypress info
Petr Mikulik <mikulik@physics.muni.cz>
parents:
11587
diff
changeset
|
91 else |
16787
2cfd8cd9e1b6
__fltk_ginput__.m: Restructure and clean up code.
Rik <rik@octave.org>
parents:
16785
diff
changeset
|
92 ginput_accumulator (1, point(1,1), point(2,1), key); |
10517 | 93 endif |
94 endfunction | |
95 |