Mercurial > hg > octave-nkf
annotate scripts/plot/comet3.m @ 15137:16a6b0a6855d gui
GUI: support for octave arguments and integrate with run-octave.
* src/octave.h (octave_initialize_interpreter, octave_execute_interpreter):
New functions.
(octave_cmdline_argc, octave_cmdline_argv, octave_embedded): New variables.
* src/octave.cc (octave_cmdline_argc, octave_cmdline_argv, octave_embedded):
New variables.
(octave_initialize_interpreter, octave_execute_interpreter): New functions.
(octave_main): Rewrite using them.
* run-octave.in (octave_executable): New variable.
(-gui): New option flag.
* gui/src/octave-adapter/octave-main-thread.cc (octave_main_thread::run):
Use octave_execute_interpreter.
* gui/src/octave-gui.cc (dissociate_terminal): New function.
(main): Use it. Also use octave_initialize_interpreter.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Aug 2012 16:15:58 -0400 |
parents | 5d3a684236b0 |
children | 64e7bb01fce2 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
1 ## Copyright (C) 2010-2012 Ben Abbott and John W. Eaton |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
11382 | 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 -*- | |
20 ## @deftypefn {Function File} {} comet3 (@var{z}) | |
21 ## @deftypefnx {Function File} {} comet3 (@var{x}, @var{y}, @var{z}, @var{p}) | |
22 ## @deftypefnx {Function File} {} comet3 (@var{ax}, @dots{}) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
23 ## Produce a simple comet style animation along the trajectory provided by |
11382 | 24 ## the input coordinate vectors (@var{x}, @var{y}), where @var{x} will default |
25 ## to the indices of @var{y}. | |
26 ## | |
27 ## The speed of the comet may be controlled by @var{p}, which represents the | |
28 ## time which passes as the animation passes from one point to the next. The | |
29 ## default for @var{p} is 0.1 seconds. | |
30 ## | |
31 ## If @var{ax} is specified the animation is produced in that axis rather than | |
32 ## the @code{gca}. | |
33 ## @end deftypefn | |
34 | |
35 ## Author: jwe | |
36 ## Created: 2010-12-17 | |
37 | |
38 function comet3 (varargin) | |
39 | |
40 [h, varargin, nargin] = __plt_get_axis_arg__ ("comet3", varargin{:}); | |
41 | |
42 if (nargin == 0 || nargin == 2 || nargin > 4) | |
43 print_usage (); | |
44 elseif (nargin == 1) | |
45 z = varargin{1}; | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
46 x = y = 1:numel (z); |
11382 | 47 p = 0.1; |
48 elseif (nargin == 3) | |
49 x = varargin{1}; | |
50 y = varargin{2}; | |
51 z = varargin{3}; | |
52 p = 0.1; | |
53 elseif (nargin == 4) | |
54 x = varargin{1}; | |
55 y = varargin{2}; | |
56 z = varargin{3}; | |
57 p = varargin{4}; | |
58 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
59 |
11382 | 60 oldh = gca (); |
61 unwind_protect | |
62 axes (h); | |
63 newplot (); | |
64 theaxis = [min(x), max(x), min(y), max(y), min(z), max(z)]; | |
65 num = numel (y); | |
66 dn = round (num/10); | |
67 for n = 1:(num+dn); | |
68 m = n - dn; | |
69 m = max ([m, 1]); | |
70 k = min ([n, num]); | |
71 h = plot3 (x(1:m), y(1:m), z(1:m), "r", x(m:k), y(m:k), z(m:k), "g", | |
72 x(k), y(k), z(k), "ob"); | |
73 axis (theaxis); | |
74 drawnow (); | |
75 pause (p); | |
76 endfor | |
77 unwind_protect_cleanup | |
78 axes (oldh); | |
79 end_unwind_protect | |
80 | |
81 endfunction | |
82 | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
83 |
11382 | 84 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
85 %! clf; |
11382 | 86 %! t = 0:pi/20:5*pi; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
87 %! comet3 (cos (t), sin (t), t, 0.01); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
88 |