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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
2 ##
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
3 ## This file is part of Octave.
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
4 ##
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
8 ## your option) any later version.
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
9 ##
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
13 ## General Public License for more details.
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
14 ##
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
18
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
19 ## -*- texinfo -*-
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
20 ## @deftypefn {Function File} {[@var{x}, @var{y}, @var{buttons}] =} __fltk_ginput__ (@var{f}, @var{n})
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
21 ## Undocumented internal function.
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
22 ## @end deftypefn
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
23
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
24 ## This is ginput.m implementation for fltk.
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
25
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
26 function [x, y, button] = __fltk_ginput__ (f, n = -1)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
27
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
28 if (isempty (get (f, "currentaxes")))
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
29 error ("ginput: must have at least one axes");
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
30 endif
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
34
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
35 unwind_protect
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
36
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
37 orig_windowbuttondownfcn = get (f, "windowbuttondownfcn");
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
38 set (f, "windowbuttondownfcn", @ginput_windowbuttondownfcn);
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
39
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
40 orig_ginput_keypressfcn = get (f, "keypressfcn");
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
47 sleep (0.01);
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
52 unwind_protect_cleanup
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
53 set (f, "windowbuttondownfcn", orig_windowbuttondownfcn);
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
54 set (f, "keypressfcn", orig_ginput_keypressfcn);
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
55 end_unwind_protect
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
56
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
57 endfunction
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
65 n = 0;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
71 n += 1;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
77 endfunction
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
78
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
79 function ginput_windowbuttondownfcn (src, data)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
83 endfunction
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
84
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
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
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
93 endif
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
94 endfunction
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
95