Mercurial > hg > octave-lyh
annotate scripts/plot/contourc.m @ 16581:fa4a035e0cf4
Add octave_link uiputfile implementation
* libgui/src/dialog.cc, libgui/src/dialog.h
(FileDialog::FileDialog): Change bool multiselect to QString multimode, add mode option of 'create' and set options accordingly.
(QUIWidgetCreator::signal_filedialog): Change bool multiselect to QString multimode.
(QUIWidgetCreator::create_filedialog): Change bool multiselect to QString multimode.
* libgui/src/main-window.cc, libgui/src/main-window.h
(main_window::connect_uiwidget_links): update bool multiselect to QString multimode.
(main_window::handle_create_filedialog): update bool multiselect to QString multimode.
* libgui/src/octave-qt-link.h
(octave_qt_link::do_file_dialog): update bool multiselect to std::string multimode.
* libinterp/interpfcn/octave-link.h
(octave_link::do_file_dialog): update bool multiselect to std::string multimode.
(octave_link::file_dialog): update bool multiselect to std::string multimode.
* scripts/plot/uiputfile.m
(uiputfile): update to call __octave_link_file_dialog__ if octave_link is present.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 28 Apr 2013 17:00:00 -0400 |
parents | c2dbdeaa25df |
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) 2003-2012 Shai Ayal |
6257 | 2 ## |
6440 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6257 | 6 ## under the terms of the GNU General Public License as published by |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6257 | 9 ## |
6440 | 10 ## Octave is distributed in the hope that it will be useful, but |
6257 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6257 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10634
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{c}, @var{lev}] =} contourc (@var{x}, @var{y}, @var{z}, @var{vn}) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
21 ## Compute isolines (contour lines) of the matrix @var{z}. |
6257 | 22 ## Parameters @var{x}, @var{y} and @var{vn} are optional. |
23 ## | |
24 ## The return value @var{lev} is a vector of the contour levels. | |
25 ## The return value @var{c} is a 2 by @var{n} matrix containing the | |
26 ## contour lines in the following format | |
27 ## | |
28 ## @example | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
29 ## @group |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
30 ## @var{c} = [lev1, x1, x2, @dots{}, levn, x1, x2, ... |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
31 ## len1, y1, y2, @dots{}, lenn, y1, y2, @dots{}] |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
32 ## @end group |
6257 | 33 ## @end example |
34 ## | |
35 ## @noindent | |
36 ## in which contour line @var{n} has a level (height) of @var{levn} and | |
37 ## length of @var{lenn}. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
38 ## |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
39 ## If @var{x} and @var{y} are omitted they are taken as the row/column |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
40 ## index of @var{z}. @var{vn} is either a scalar denoting the number of lines |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
41 ## to compute or a vector containing the values of the lines. If only one |
6257 | 42 ## value is wanted, set @code{@var{vn} = [val, val]}; |
43 ## If @var{vn} is omitted it defaults to 10. | |
44 ## | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
45 ## For example: |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
46 ## |
6257 | 47 ## @example |
6592 | 48 ## @group |
49 ## x = 0:2; | |
50 ## y = x; | |
51 ## z = x' * y; | |
52 ## contourc (x, y, z, 2:3) | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
53 ## @result{} 2.0000 2.0000 1.0000 3.0000 1.5000 2.0000 |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 ## 2.0000 1.0000 2.0000 2.0000 2.0000 1.5000 |
6592 | 55 ## @end group |
6257 | 56 ## @end example |
57 ## @seealso{contour} | |
58 ## @end deftypefn | |
59 | |
7327 | 60 ## Author: Shai Ayal <shaiay@users.sourceforge.net> |
6257 | 61 |
8236 | 62 function [cout, lev] = contourc (varargin) |
6257 | 63 |
64 if (nargin == 1) | |
65 vn = 10; | |
66 z = varargin{1}; | |
11499
8f23b6757225
Correction to contourc.m
Michael Godfrey <godfrey@isl.stanford.edu>
parents:
11472
diff
changeset
|
67 [nr, nc] = size (z); |
8f23b6757225
Correction to contourc.m
Michael Godfrey <godfrey@isl.stanford.edu>
parents:
11472
diff
changeset
|
68 x = 1:nc; |
8f23b6757225
Correction to contourc.m
Michael Godfrey <godfrey@isl.stanford.edu>
parents:
11472
diff
changeset
|
69 y = 1:nr; |
6257 | 70 elseif (nargin == 2) |
71 vn = varargin{2}; | |
72 z = varargin{1}; | |
7327 | 73 [nr, nc] = size (z); |
74 x = 1:nc; | |
75 y = 1:nr; | |
6257 | 76 elseif (nargin == 3) |
77 vn = 10; | |
78 x = varargin{1}; | |
79 y = varargin{2}; | |
80 z = varargin{3}; | |
81 elseif (nargin == 4) | |
82 vn = varargin{4}; | |
83 x = varargin{1}; | |
84 y = varargin{2}; | |
85 z = varargin{3}; | |
86 else | |
87 print_usage (); | |
88 endif | |
89 | |
10634
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
9758
diff
changeset
|
90 if (!ismatrix (z) || isvector (z) || isscalar (z)) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
91 error ("contourc: Z argument must be a matrix"); |
10634
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
9758
diff
changeset
|
92 endif |
60542efcfa2c
Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents:
9758
diff
changeset
|
93 |
6257 | 94 if (isscalar (vn)) |
95 vv = linspace (min (z(:)), max (z(:)), vn+2)(2:end-1); | |
96 else | |
97 vv = unique (sort (vn)); | |
98 endif | |
99 | |
7327 | 100 if (isvector (x) && isvector (y)) |
101 c = __contourc__ (x(:)', y(:)', z, vv); | |
102 else | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
103 ## Indexes x,y for the purpose of __contourc__. |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
104 ii = 1:columns (z); |
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
105 jj = 1:rows (z); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
106 |
7327 | 107 ## Now call __contourc__ for the real work... |
108 c = __contourc__ (ii, jj, z, vv); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
109 |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
110 ## Map the contour lines from index space (i,j) back |
7327 | 111 ## to the original grid (x,y) |
112 i = 1; | |
6257 | 113 |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
114 while (i < columns (c)) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
115 clen = c(2, i); |
7327 | 116 ind = i + [1 : clen]; |
6257 | 117 |
7327 | 118 ci = c(1, ind); |
119 cj = c(2,ind); | |
120 | |
121 ## due to rounding errors some elements of ci and cj | |
122 ## can fall out of the range of ii and jj and interp2 would | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
123 ## return NA for those values. |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
124 ## The permitted range is enforced here: |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
125 |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
126 ci = max (ci, 1); ci = min (ci, columns (z)); |
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
127 cj = max (cj, 1); cj = min (cj, rows (z)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
128 |
7327 | 129 c(1, ind) = interp2 (ii, jj, x, ci, cj); |
130 c(2, ind) = interp2 (ii, jj, y, ci, cj); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
131 |
7327 | 132 i = i + clen + 1; |
133 endwhile | |
6257 | 134 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
135 |
8236 | 136 if (nargout > 0) |
137 cout = c; | |
6257 | 138 lev = vv; |
139 endif | |
140 | |
141 endfunction | |
7245 | 142 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
143 |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8325
diff
changeset
|
144 %!test |
7245 | 145 %! x = 0:2; |
146 %! y = x; | |
147 %! z = x' * y; | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8325
diff
changeset
|
148 %! [c_actual, lev_actual]= contourc (x, y, z, 2:3); |
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8325
diff
changeset
|
149 %! c_expected = [2, 1, 1, 2, 2, 3, 1.5, 2; 4, 2, 2, 1, 1, 2, 2, 1.5]; |
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8325
diff
changeset
|
150 %! lev_expected = [2 3]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
151 %! assert (c_actual, c_expected, eps); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
152 %! assert (lev_actual, lev_expected, eps); |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8325
diff
changeset
|
153 |