Mercurial > hg > octave-nkf
annotate scripts/plot/util/zoom.m @ 20000:ca7599ae464d
doc: Grammarcheck documentation ahead of 4.0 release.
* plot.txi, data.cc, graphics.cc, ordschur.cc, __ilu__.cc, __osmesa_print__.cc,
audiodevinfo.cc, soundsc.m, interp2.m, interp3.m, interpn.m, annotation.m,
zoom.m: Grammarcheck documentation ahead of 4.0 release.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 20 Feb 2015 14:26:36 -0800 |
parents | 4197fc428c7d |
children | 9fc020886ae9 |
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 | 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 -*- | |
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 | 26 ## @deftypefnx {Command} {} zoom out |
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}) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
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:
19502
diff
changeset
|
30 ## a figure in the GUI. |
19281 | 31 ## |
32 ## Given a numeric argument greater than zero, zoom by the given factor. | |
33 ## If the zoom factor is greater than one, zoom in on the plot. If the | |
19417
ec037d41da06
zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents:
19344
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:
19344
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:
19344
diff
changeset
|
36 ## the x, y, and z axes respectively. |
19281 | 37 ## |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
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:
19502
diff
changeset
|
39 ## zoom mode on or off. |
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 ## |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
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:
19502
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:
19502
diff
changeset
|
45 ## |
19281 | 46 ## Given the option @qcode{"out"}, zoom to the initial zoom setting. |
47 ## | |
19502
8e1883060940
* zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents:
19417
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:
19417
diff
changeset
|
49 ## that @code{zoom out} will return to this zoom level. |
19281 | 50 ## |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
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:
19502
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:
19502
diff
changeset
|
53 ## @code{gcf}. |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
54 ## |
19281 | 55 ## @seealso{pan, rotate3d} |
56 ## @end deftypefn | |
57 | |
58 ## Eventually we need to also support these features: | |
59 ## @deftypefnx {Command} {zoom_object_handle =} zoom (@var{hfig}) | |
60 | |
61 function zoom (varargin) | |
62 | |
63 hfig = NaN; | |
64 | |
65 nargs = nargin; | |
66 | |
67 if (nargs > 2) | |
68 print_usage (); | |
69 endif | |
70 | |
19417
ec037d41da06
zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents:
19344
diff
changeset
|
71 if (nargin == 1 && nargout > 0 && isfigure (varargin{1})) |
19281 | 72 error ("zoom_object_handle = zoom (hfig): not implemented"); |
73 endif | |
74 | |
75 if (nargs == 2) | |
76 hfig = varargin{1}; | |
77 if (isfigure (hfig)) | |
78 varargin(1) = []; | |
79 nargs--; | |
80 else | |
81 error ("zoom: expecting figure handle as first argument"); | |
82 endif | |
83 endif | |
84 | |
85 if (isnan (hfig)) | |
86 hfig = gcf (); | |
87 endif | |
88 | |
89 if (nargs == 0) | |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
90 zm = get (hfig, "__zoom_mode__"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
91 if (strcmp (zm.Enable, "on")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
92 zm.Enable = "off"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
93 else |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
94 zm.Enable = "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
95 endif |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
96 set (hfig, "__zoom_mode__", zm); |
19281 | 97 elseif (nargs == 1) |
98 arg = varargin{1}; | |
99 if (isnumeric (arg)) | |
100 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
|
101 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
|
102 case 2 |
ec037d41da06
zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents:
19344
diff
changeset
|
103 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
|
104 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
|
105 case 1 |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
106 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
|
107 otherwise |
ec037d41da06
zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents:
19344
diff
changeset
|
108 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
|
109 endswitch |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
110 if (xfactor < 0 || yfactor < 0) |
19281 | 111 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
|
112 elseif (xfactor == 1 && yfactor == 1) |
19281 | 113 return; |
114 endif | |
115 cax = get (hfig, "currentaxes"); | |
116 if (! isempty (cax)) | |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
117 if (xfactor != 1) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
118 if (yfactor != 1) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
119 mode = "both"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
120 else |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
121 mode = "horizontal"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
122 endif |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
123 else |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
124 if (yfactor != 1) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
125 mode = "vertical"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
126 endif |
19281 | 127 endif |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
128 __zoom__ (cax, mode, factor); |
19281 | 129 endif |
130 elseif (ischar (arg)) | |
131 switch (arg) | |
132 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
|
133 zm = get (hfig, "__zoom_mode__"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
134 switch (arg) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
135 case {"on", "off"} |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
136 zm.Enable = arg; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
137 zm.Motion = "both"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
138 case "xon" |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
139 zm.Enable = "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
140 zm.Motion = "horizontal"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
141 case "yon" |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
142 zm.Enable = "on"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
143 zm.Motion = "vertical"; |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
144 endswitch |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
145 set (hfig, "__zoom_mode__", zm); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
146 if (strcmp (arg, "off")) |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
147 set (hfig, "__mouse_mode__", "none"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
148 else |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
149 ## FIXME: Is there a better way other than calling these |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
150 ## functions to set the other mouse mode Enable fields to |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
151 ## "off"? |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
152 pan ("off"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
153 rotate3d ("off"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
154 set (hfig, "__mouse_mode__", "zoom"); |
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
155 endif |
19281 | 156 |
157 case "out" | |
158 cax = get (hfig, "currentaxes"); | |
159 if (! isempty (cax)) | |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
160 __zoom__ (cax, "out"); |
19281 | 161 endif |
162 | |
163 case "reset" | |
164 cax = get (hfig, "currentaxes"); | |
165 if (! isempty (cax)) | |
19864
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19502
diff
changeset
|
166 __zoom__ (cax, "reset"); |
19281 | 167 endif |
168 | |
169 otherwise | |
170 error ("zoom: unrecognized option '%s'", arg); | |
171 endswitch | |
172 else | |
173 error ("zoom: wrong type argument '%s'", class (arg)); | |
174 endif | |
175 endif | |
176 | |
177 endfunction | |
19502
8e1883060940
* zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents:
19417
diff
changeset
|
178 |
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; |