annotate scripts/plot/util/zoom.m @ 19923:e1d7bd38b82b

make pan, rotate3d, and zoom properly toggle state * pan.m (update_mouse_mode): New subfunction. Also set __mouse_mode__ property when toggling state. * rotate3d.m: Likewise. * zoom.m: Likewise.
author John W. Eaton <jwe@octave.org>
date Mon, 02 Mar 2015 21:00:13 -0500
parents 9fc020886ae9
children 065ccb9a1324
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 John W. Eaton
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## your option) any later version.
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## General Public License for more details.
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
19829
ca7599ae464d doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents: 19731
diff changeset
20 ## @deftypefn {Command} {} zoom
ca7599ae464d doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents: 19731
diff changeset
21 ## @deftypefnx {Command} {} zoom (@var{factor})
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
22 ## @deftypefnx {Command} {} zoom on
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
23 ## @deftypefnx {Command} {} zoom off
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
24 ## @deftypefnx {Command} {} zoom xon
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
25 ## @deftypefnx {Command} {} zoom yon
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ## @deftypefnx {Command} {} zoom out
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ## @deftypefnx {Command} {} zoom reset
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
28 ## @deftypefnx {Command} {} zoom (@var{hfig}, @var{option})
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
29 ## Zoom the current axes object or control the interactive zoom mode of
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
30 ## a figure in the GUI.
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 ##
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 ## Given a numeric argument greater than zero, zoom by the given factor.
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 ## If the zoom factor is greater than one, zoom in on the plot. If the
19259
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
34 ## factor is less than one, zoom out. If the zoom factor is a two- or
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
35 ## three-element vector, then the elements specify the zoom factors for
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
36 ## the x, y, and z axes respectively.
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 ##
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
38 ## 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: 19344
diff changeset
39 ## zoom mode on or off.
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
40 ##
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
41 ## With no arguments, toggle the current zoom mode on or off.
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
42 ##
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
43 ## Given the option @qcode{"xon"} or @qcode{"yon"}, enable zoom mode
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
44 ## for the x or y axis only.
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
45 ##
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 ## Given the option @qcode{"out"}, zoom to the initial zoom setting.
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 ##
19344
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
48 ## Given the option @qcode{"reset"}, store the current zoom setting so
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
49 ## that @code{zoom out} will return to this zoom level.
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 ##
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
51 ## If the first argument @var{hfig} is a figure, then operate on
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
52 ## the given figure rather than the current figure as returned by
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
53 ## @code{gcf}.
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
54 ##
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 ## @seealso{pan, rotate3d}
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 ## @end deftypefn
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 ## Eventually we need to also support these features:
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 ## @deftypefnx {Command} {zoom_object_handle =} zoom (@var{hfig})
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 function zoom (varargin)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 nargs = nargin;
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 if (nargs > 2)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 print_usage ();
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
19867
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19829
diff changeset
68 if (nargs == 1 && nargout > 0 && isfigure (varargin{1}))
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 error ("zoom_object_handle = zoom (hfig): not implemented");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
19867
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19829
diff changeset
72 hfig = NaN;
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 if (nargs == 2)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 hfig = varargin{1};
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 if (isfigure (hfig))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 varargin(1) = [];
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 nargs--;
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 else
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 error ("zoom: expecting figure handle as first argument");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 if (isnan (hfig))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 hfig = gcf ();
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 if (nargs == 0)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
88 zm = get (hfig, "__zoom_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
89 if (strcmp (zm.Enable, "on"))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
90 zm.Enable = "off";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
91 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
92 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
93 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
94 set (hfig, "__zoom_mode__", zm);
19923
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
95 update_mouse_mode (hfig, zm.Enable);
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 elseif (nargs == 1)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 arg = varargin{1};
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 if (isnumeric (arg))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 factor = arg;
19259
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
100 switch (numel (factor))
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
101 case 2
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
102 xfactor = factor(1);
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
103 yfactor = factor(2);
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
104 case 1
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
105 xfactor = yfactor = factor;
19259
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
106 otherwise
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
107 error ("zoom: invalid factor");
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19186
diff changeset
108 endswitch
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
109 if (xfactor < 0 || yfactor < 0)
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 error ("zoom: factor must be greater than 1");
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
111 elseif (xfactor == 1 && yfactor == 1)
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 return;
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 cax = get (hfig, "currentaxes");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 if (! isempty (cax))
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
116 if (xfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
117 if (yfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
118 mode = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
119 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
120 mode = "horizontal";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
121 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
122 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
123 if (yfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
124 mode = "vertical";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
125 endif
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 endif
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
127 __zoom__ (cax, mode, factor);
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 elseif (ischar (arg))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 switch (arg)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 case {"on", "off", "xon", "yon"}
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
132 zm = get (hfig, "__zoom_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
133 switch (arg)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
134 case {"on", "off"}
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
135 zm.Enable = arg;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
136 zm.Motion = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
137 case "xon"
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
138 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
139 zm.Motion = "horizontal";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
140 case "yon"
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
141 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
142 zm.Motion = "vertical";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
143 endswitch
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
144 set (hfig, "__zoom_mode__", zm);
19923
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
145 update_mouse_mode (hfig, arg);
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 case "out"
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 cax = get (hfig, "currentaxes");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 if (! isempty (cax))
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
149 __zoom__ (cax, "out");
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 case "reset"
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 cax = get (hfig, "currentaxes");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 if (! isempty (cax))
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
154 __zoom__ (cax, "reset");
19123
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 otherwise
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 error ("zoom: unrecognized option '%s'", arg);
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 endswitch
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 else
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 error ("zoom: wrong type argument '%s'", class (arg));
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 endfunction
19344
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
165
19923
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
166 function update_mouse_mode (hfig, arg)
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
167 if (strcmp (arg, "off"))
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
168 set (hfig, "__mouse_mode__", "none");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
169 else
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
170 ## 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: 19867
diff changeset
171 ## 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: 19867
diff changeset
172 ## "off"?
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
173 pan ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
174 rotate3d ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
175 set (hfig, "__mouse_mode__", "zoom");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
176 endif
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 19867
diff changeset
177 endfunction
19867
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19829
diff changeset
178
19344
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
179 %!demo
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
180 %! clf;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
181 %! sombrero ();
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
182 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
183 %! %% zoom in by a factor of 2
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
184 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
185 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
186 %! %% return to original zoom level
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
187 %! zoom out;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
188 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
189 %! %% zoom in by a factor of 2
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
190 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
191 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
192 %! %% set this zoom level as the "initial zoom level"
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
193 %! %% and zoom in some more
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
194 %! zoom reset;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
195 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
196 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
197 %! %% return to zoom level set by last call to "zoom reset"
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19259
diff changeset
198 %! zoom out;
19867
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19829
diff changeset
199