annotate scripts/plot/util/zoom.m @ 20407:2283dd03bf50

ginput.m: Don't hang if window is close while fcn active (bug #44897). * ginput.m: Change closerequestfcn for figure to point to ginput_closerequestfcn. * ginput.m (ginput_closerequestfcn): New callback routine. Stops collecting data for ginput. Calls original closerequestfcn to shutdown window.
author Rik <rik@octave.org>
date Fri, 15 May 2015 16:51:57 -0700
parents 777f26aa8e3e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19898
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19864
diff changeset
1 ## Copyright (C) 2014-2015 John W. Eaton
19281
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 -*-
20000
ca7599ae464d doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents: 19898
diff changeset
20 ## @deftypefn {Command} {} zoom
ca7599ae464d doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents: 19898
diff changeset
21 ## @deftypefnx {Command} {} zoom (@var{factor})
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
22 ## @deftypefnx {Command} {} zoom on
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
23 ## @deftypefnx {Command} {} zoom off
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
24 ## @deftypefnx {Command} {} zoom xon
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
25 ## @deftypefnx {Command} {} zoom yon
19281
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
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
28 ## @deftypefnx {Command} {} zoom (@var{hfig}, @var{option})
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
29 ## Zoom the current axes object or control the interactive zoom mode of a
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
30 ## figure in the GUI.
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 ##
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
32 ## Given a numeric argument greater than zero, zoom by the given factor. If
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
33 ## the zoom factor is greater than one, zoom in on the plot. If the factor
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
34 ## is less than one, zoom out. If the zoom factor is a two- or three-element
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
35 ## vector, then the elements specify the zoom factors for the x, y, and z
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
36 ## axes respectively.
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 ##
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
38 ## Given the option @qcode{"on"} or @qcode{"off"}, set the interactive zoom
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
39 ## mode on or off.
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
40 ##
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
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: 19502
diff changeset
42 ##
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
43 ## Given the option @qcode{"xon"} or @qcode{"yon"}, enable zoom mode for the
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
44 ## x or y-axis only.
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
45 ##
19281
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 ##
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
48 ## Given the option @qcode{"reset"}, store the current zoom setting so that
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
49 ## @code{zoom out} will return to this zoom level.
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 ##
20383
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20141
diff changeset
51 ## 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: 20141
diff changeset
52 ## figure rather than the current figure as returned by @code{gcf}.
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
53 ##
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 ## @seealso{pan, rotate3d}
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 ## @end deftypefn
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 ## Eventually we need to also support these features:
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 ## @deftypefnx {Command} {zoom_object_handle =} zoom (@var{hfig})
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 function zoom (varargin)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 nargs = nargin;
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 if (nargs > 2)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 print_usage ();
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
67 if (nargs == 1 && nargout > 0 && isfigure (varargin{1}))
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 error ("zoom_object_handle = zoom (hfig): not implemented");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
71 hfig = NaN;
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 if (nargs == 2)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 hfig = varargin{1};
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 if (isfigure (hfig))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 varargin(1) = [];
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 nargs--;
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 else
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 error ("zoom: expecting figure handle as first argument");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 endif
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
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 if (isnan (hfig))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 hfig = gcf ();
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 if (nargs == 0)
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
87 zm = get (hfig, "__zoom_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
88 if (strcmp (zm.Enable, "on"))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
89 zm.Enable = "off";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
90 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
91 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
92 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
93 set (hfig, "__zoom_mode__", zm);
20097
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
94 update_mouse_mode (hfig, zm.Enable);
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 elseif (nargs == 1)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 arg = varargin{1};
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 if (isnumeric (arg))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 factor = arg;
19417
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
99 switch (numel (factor))
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
100 case 2
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
101 xfactor = factor(1);
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
102 yfactor = factor(2);
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
103 case 1
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
104 xfactor = yfactor = factor;
19417
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
105 otherwise
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
106 error ("zoom: invalid factor");
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
diff changeset
107 endswitch
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
108 if (xfactor < 0 || yfactor < 0)
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 error ("zoom: factor must be greater than 1");
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
110 elseif (xfactor == 1 && yfactor == 1)
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 return;
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 cax = get (hfig, "currentaxes");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 if (! isempty (cax))
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
115 if (xfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
116 if (yfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
117 mode = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
118 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
119 mode = "horizontal";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
120 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
121 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
122 if (yfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
123 mode = "vertical";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
124 endif
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 endif
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
126 __zoom__ (cax, mode, factor);
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 elseif (ischar (arg))
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 switch (arg)
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 case {"on", "off", "xon", "yon"}
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
131 zm = get (hfig, "__zoom_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
132 switch (arg)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
133 case {"on", "off"}
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
134 zm.Enable = arg;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
135 zm.Motion = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
136 case "xon"
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
137 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
138 zm.Motion = "horizontal";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
139 case "yon"
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
140 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
141 zm.Motion = "vertical";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
142 endswitch
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
143 set (hfig, "__zoom_mode__", zm);
20097
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
144 update_mouse_mode (hfig, arg);
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 case "out"
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 cax = get (hfig, "currentaxes");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 if (! isempty (cax))
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
148 __zoom__ (cax, "out");
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 case "reset"
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 cax = get (hfig, "currentaxes");
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 if (! isempty (cax))
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
153 __zoom__ (cax, "reset");
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 endif
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 otherwise
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 error ("zoom: unrecognized option '%s'", arg);
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 endswitch
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 else
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 error ("zoom: wrong type argument '%s'", class (arg));
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 endif
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
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 endfunction
19502
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
164
20097
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
165 function update_mouse_mode (hfig, arg)
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
166 if (strcmp (arg, "off"))
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
167 set (hfig, "__mouse_mode__", "none");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
168 else
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
169 ## 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: 20038
diff changeset
170 ## 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: 20038
diff changeset
171 ## "off"?
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
172 pan ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
173 rotate3d ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
174 set (hfig, "__mouse_mode__", "zoom");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
175 endif
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
176 endfunction
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
177
20141
065ccb9a1324 zoom.m: Use two newlines to separate endfunction from start of demo block.
Rik <rik@octave.org>
parents: 20097
diff changeset
178
19502
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
179 %!demo
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
180 %! clf;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
181 %! sombrero ();
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
182 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
183 %! %% zoom in by a factor of 2
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
184 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
185 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
186 %! %% return to original zoom level
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
187 %! zoom out;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
188 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
189 %! %% zoom in by a factor of 2
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
190 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
191 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
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: 19417
diff changeset
193 %! %% and zoom in some more
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
194 %! zoom reset;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
195 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
196 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
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: 19417
diff changeset
198 %! zoom out;
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
199