annotate scripts/plot/util/zoom.m @ 20368:7503499a252b stable

doc: Update docstrings to have one sentence summary as first line. Update scripts in audio, elfun, general, geometry, and image directories. * scripts/audio/@audioplayer/__get_properties__.m, scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m, scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m, scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m, scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m, scripts/audio/@audiorecorder/audiorecorder.m, scripts/audio/@audiorecorder/get.m, scripts/audio/@audiorecorder/getaudiodata.m, scripts/audio/@audiorecorder/getplayer.m, scripts/audio/@audiorecorder/isrecording.m, scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m, scripts/audio/@audiorecorder/recordblocking.m, scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m, scripts/audio/@audiorecorder/subsasgn.m, scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m, scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m, scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m, scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m, scripts/general/accumarray.m, scripts/general/accumdim.m, scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m, scripts/general/blkdiag.m, scripts/general/cart2pol.m, scripts/general/cart2sph.m, scripts/general/cell2mat.m, scripts/general/celldisp.m, scripts/general/chop.m, scripts/general/circshift.m, scripts/general/common_size.m, scripts/general/cplxpair.m, scripts/general/cumtrapz.m, scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m, scripts/general/display.m, scripts/general/divergence.m, scripts/general/fieldnames.m, scripts/general/flip.m, scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m, scripts/general/gradient.m, scripts/general/interp3.m, scripts/general/interpft.m, scripts/general/interpn.m, scripts/general/loadobj.m, scripts/general/logspace.m, scripts/general/methods.m, scripts/general/nargchk.m, scripts/general/narginchk.m, scripts/general/nargoutchk.m, scripts/general/nextpow2.m, scripts/general/nthargout.m, scripts/general/num2str.m, scripts/general/pol2cart.m, scripts/general/polyarea.m, scripts/general/postpad.m, scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m, scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m, scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m, scripts/general/shiftdim.m, scripts/general/sortrows.m, scripts/general/sph2cart.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/trapz.m, scripts/general/triplequad.m, scripts/geometry/delaunayn.m, scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m, scripts/geometry/rectint.m, scripts/geometry/tsearchn.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/help/__unimplemented__.m, scripts/help/doc.m, scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m, scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m, scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m, scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m, scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m, scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m, scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m, scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m, scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m, scripts/image/white.m, scripts/image/winter.m: Update docstrings to have one sentence summary as first line. Re-structure to have line lengths <= 80 chars.
author Rik <rik@octave.org>
date Sun, 03 May 2015 09:36:20 -0700
parents 065ccb9a1324
children 777f26aa8e3e
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})
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
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
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
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
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
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 ##
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
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
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
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
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
68 if (nargs == 1 && nargout > 0 && isfigure (varargin{1}))
19281
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
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
72 hfig = NaN;
19281
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)
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
88 zm = get (hfig, "__zoom_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
89 if (strcmp (zm.Enable, "on"))
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
90 zm.Enable = "off";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
91 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
92 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
93 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
94 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
95 update_mouse_mode (hfig, zm.Enable);
19281
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;
19417
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
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: 19344
diff changeset
101 case 2
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
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: 19344
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: 19344
diff changeset
104 case 1
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
105 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
106 otherwise
ec037d41da06 zoom: allow x, y, and z axes to be zoomed independently
John W. Eaton <jwe@octave.org>
parents: 19344
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: 19344
diff changeset
108 endswitch
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
109 if (xfactor < 0 || yfactor < 0)
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 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
111 elseif (xfactor == 1 && yfactor == 1)
19281
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))
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
116 if (xfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
117 if (yfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
118 mode = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
119 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
120 mode = "horizontal";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
121 endif
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
122 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
123 if (yfactor != 1)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
124 mode = "vertical";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
125 endif
19281
8a6f87637c16 hg new function, zoom
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 endif
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
127 __zoom__ (cax, mode, factor);
19281
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"}
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
132 zm = get (hfig, "__zoom_mode__");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
133 switch (arg)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
134 case {"on", "off"}
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
135 zm.Enable = arg;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
136 zm.Motion = "both";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
137 case "xon"
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
138 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
139 zm.Motion = "horizontal";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
140 case "yon"
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
141 zm.Enable = "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
142 zm.Motion = "vertical";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
143 endswitch
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
144 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
145 update_mouse_mode (hfig, arg);
19281
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))
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
149 __zoom__ (cax, "out");
19281
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))
19864
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19502
diff changeset
154 __zoom__ (cax, "reset");
19281
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
19502
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
165
20097
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
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: 20038
diff changeset
167 if (strcmp (arg, "off"))
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
168 set (hfig, "__mouse_mode__", "none");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
169 else
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
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: 20038
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: 20038
diff changeset
172 ## "off"?
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
173 pan ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
174 rotate3d ("off");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
175 set (hfig, "__mouse_mode__", "zoom");
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
176 endif
e1d7bd38b82b make pan, rotate3d, and zoom properly toggle state
John W. Eaton <jwe@octave.org>
parents: 20038
diff changeset
177 endfunction
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
178
20141
065ccb9a1324 zoom.m: Use two newlines to separate endfunction from start of demo block.
Rik <rik@octave.org>
parents: 20097
diff changeset
179
19502
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
180 %!demo
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
181 %! clf;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
182 %! sombrero ();
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
183 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
184 %! %% zoom in by a factor of 2
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
185 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
186 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
187 %! %% return to original zoom level
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
188 %! zoom out;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
189 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
190 %! %% zoom in by a factor of 2
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
191 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
192 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
193 %! %% 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
194 %! %% and zoom in some more
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
195 %! zoom reset;
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
196 %! zoom (2);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
197 %! pause (1);
8e1883060940 * zoom.m: Improve documentation. New demo.
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
198 %! %% 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
199 %! zoom out;
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 20000
diff changeset
200