annotate scripts/plot/util/rotate3d.m @ 20602:af5591ef9790 stable

__gnuplot_drawnow__.m: Use "screenpixelsperinch" instead of constant value (bug #46122).
author ederag <edera@gmx.fr>
date Tue, 06 Oct 2015 11:07:10 +0200
parents 777f26aa8e3e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
1 ## Copyright (C) 2014-2015 Andreas Weber
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
2 ##
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
3 ## This file is part of Octave.
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
4 ##
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
8 ## your option) any later version.
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
9 ##
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
13 ## General Public License for more details.
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
14 ##
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
18
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
19 ## -*- texinfo -*-
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
20 ## @deftypefn {Command} {} rotate3d
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
21 ## @deftypefnx {Command} {} rotate3d on
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
22 ## @deftypefnx {Command} {} rotate3d off
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
23 ## @deftypefnx {Function File} {} rotate3d (@var{hfig}, @var{option})
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
24 ## Control the interactive 3-D rotation mode of a figure in the GUI.
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
25 ##
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
26 ## Given the option @qcode{"on"} or @qcode{"off"}, set the interactive
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
27 ## rotate mode on or off.
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
28 ##
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
29 ## With no arguments, toggle the current rotate mode on or off.
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
30 ##
20208
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19923
diff changeset
31 ## If the first argument @var{hfig} is a figure, then operate on the given
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19923
diff changeset
32 ## figure rather than the current figure as returned by @code{gcf}.
19186
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19123
diff changeset
33 ##
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents: 18999
diff changeset
34 ## @seealso{pan, zoom}
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
35 ## @end deftypefn
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
36
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
37 function rotate3d (varargin)
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
38
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
39 hfig = NaN;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
40
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
41 nargs = nargin;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
42
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
43 if (nargs > 2)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
44 print_usage ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
45 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
46
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
47 if (nargin == 1 && nargout > 0 && isfigure (varargin{1}))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
48 error ("rotate_object_handle = rotate3d (hfig): not implemented");
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
49 endif
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
50
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
51 if (nargs == 2)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
52 hfig = varargin{1};
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
53 if (isfigure (hfig))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
54 varargin(1) = [];
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
55 nargs--;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
56 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
57 error ("rotate3d: expecting figure handle as first argument");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
58 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
59 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
60
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
61 if (isnan (hfig))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
62 hfig = gcf ();
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
63 endif
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
64
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
65 if (nargs == 0)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
66 rm = get (hfig, "__rotate_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
67 if (strcmp (rm.Enable, "on"))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
68 rm.Enable = "off";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
69 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
70 rm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
71 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
72 set (hfig, "__rotate_mode__", rm);
19923
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
73 update_mouse_mode (hfig, rm.Enable);
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
74 elseif (nargs == 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
75 arg = varargin{1};
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
76 if (ischar (arg))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
77 switch (arg)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
78 case {"on", "off"}
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
79 rm = get (hfig, "__rotate_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
80 switch (arg)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
81 case {"on", "off"}
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
82 rm.Enable = arg;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
83 rm.Motion = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
84 endswitch
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
85 set (hfig, "__rotate_mode__", rm);
19923
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
86 update_mouse_mode (hfig, arg);
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
87 otherwise
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
88 error ("rotate3d: unrecognized option '%s'", arg);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
89 endswitch
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
90 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
91 error ("rotate3d: wrong type argument '%s'", class (arg));
18999
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
92 endif
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
93 endif
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
94
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
95 endfunction
137d01e7c2d4 New scripts pan.m and rotate3d.m, update __add_default_menu__.m
Andreas Weber <andy.weber.aw@gmail.com>
parents:
diff changeset
96
19923
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
97 function update_mouse_mode (hfig, arg)
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
98 if (strcmp (arg, "off"))
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
99 set (hfig, "__mouse_mode__", "none");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
100 else
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
101 ## FIXME: Is there a better way other than calling these
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
102 ## functions to set the other mouse mode Enable fields to
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
103 ## "off"?
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
104 pan ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
105 zoom ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
106 set (hfig, "__mouse_mode__", "rotate");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
107 endif
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
108 endfunction