Mercurial > octave
annotate doc/interpreter/interpimages.m @ 21226:a55b8ece1ecd
reorganize octave_config_info again
* build-env-features.sh: Don't include ENABLE_ items in the output.
* toplev.cc (find_config_info): New static function.
(Foctave_config_info): Put Octave configuration info in the main
struct. Put the build system features and build environment info in
substructures. Allow searching of all elements by keyword.
* __have_feature__.m, doc/interpreter/testfun.txi:
Fix name of build features substructure element.
* geometryimages.m, interpimages.m, plotimages.m, sparseimages.m,
splineimages.m: Use __have_feature__ to check for OSMESA.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Feb 2016 23:14:56 -0500 |
parents | e5f78891ad9e |
children | 782ecfde4859 |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19593
diff
changeset
|
1 ## Copyright (C) 2007-2015 David Bateman |
7018 | 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 | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
19 function interpimages (d, nm, typ) |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
20 set_graphics_toolkit (); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
21 set_print_size (); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
22 hide_output (); |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
23 outfile = fullfile (d, [nm "." typ]); |
7257 | 24 if (strcmp (typ, "png")) |
25 set (0, "defaulttextfontname", "*"); | |
26 endif | |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
27 if (strcmp (typ, "eps")) |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
28 d_typ = "-depsc2"; |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
29 else |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
30 d_typ = ["-d", typ]; |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
31 endif |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
32 |
7262 | 33 if (strcmp (typ, "txt")) |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
34 image_as_txt (d, nm); |
7262 | 35 elseif (strcmp (nm, "interpft")) |
6721 | 36 t = 0 : 0.3 : pi; dt = t(2)-t(1); |
37 n = length (t); k = 100; | |
38 ti = t(1) + [0 : k-1]*dt*n/k; | |
39 y = sin (4*t + 0.3) .* cos (3*t - 0.1); | |
40 yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
41 plot (ti, yp, "g", ti, interp1 (t, y, ti, "spline"), "b", ... |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
42 ti, interpft (y, k), "c", t, y, "r+"); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
43 legend ("sin(4t+0.3)cos(3t-0.1)", "spline", "interpft", "data"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
44 print (outfile, d_typ); |
6721 | 45 elseif (strcmp (nm, "interpn")) |
46 x = y = z = -1:1; | |
47 f = @(x,y,z) x.^2 - y - z.^2; | |
48 [xx, yy, zz] = meshgrid (x, y, z); | |
49 v = f (xx,yy,zz); | |
50 xi = yi = zi = -1:0.1:1; | |
51 [xxi, yyi, zzi] = ndgrid (xi, yi, zi); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
52 vi = interpn (x, y, z, v, xxi, yyi, zzi, "spline"); |
6723 | 53 mesh (zi, yi, squeeze (vi(1,:,:))); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
54 print (outfile, d_typ); |
6743 | 55 elseif (strcmp (nm, "interpderiv1")) |
56 t = -2:2; | |
57 dt = 1; | |
58 ti =-2:0.025:2; | |
59 dti = 0.025; | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
60 y = sign (t); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
61 ys = interp1 (t,y,ti,"spline"); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
62 yp = interp1 (t,y,ti,"pchip"); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
63 plot (ti, ys,"r-", ti, yp,"g-"); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
64 legend ("spline","pchip", 4); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
65 print (outfile, d_typ); |
6743 | 66 elseif (strcmp (nm, "interpderiv2")) |
67 t = -2:2; | |
68 dt = 1; | |
69 ti =-2:0.025:2; | |
70 dti = 0.025; | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
71 y = sign (t); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
72 ddys = diff (diff (interp1 (t,y,ti,"spline"))./dti)./dti; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
73 ddyp = diff (diff (interp1 (t,y,ti,"pchip"))./dti)./dti; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
74 plot (ti(2:end-1),ddys,"r*", ti(2:end-1),ddyp,"g+"); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
75 legend ("spline", "pchip"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
76 print (outfile, d_typ); |
6721 | 77 endif |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
78 hide_output (); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
79 endfunction |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
80 |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
81 ## This function no longer sets the graphics toolkit; That is now done |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
82 ## automatically by C++ code which will ordinarily choose 'qt', but might |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
83 ## choose gnuplot on older systems. Only a complete lack of plotting is a |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
84 ## problem. |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
85 function set_graphics_toolkit () |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
86 if (isempty (available_graphics_toolkits ())) |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
87 error ("no graphics toolkit available for plotting"); |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
20885
diff
changeset
|
88 elseif (! strcmp ("gnuplot", graphics_toolkit ()) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
20885
diff
changeset
|
89 && ! __have_feature__ ("OSMESA")) |
20885
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20335
diff
changeset
|
90 if (! any (strcmp ("gnuplot", available_graphics_toolkits ()))) |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20335
diff
changeset
|
91 error ("no graphics toolkit available for offscreen plotting"); |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20335
diff
changeset
|
92 else |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20335
diff
changeset
|
93 graphics_toolkit ("gnuplot"); |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20335
diff
changeset
|
94 endif |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
95 endif |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
96 endfunction |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
97 |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
98 function set_print_size () |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
99 image_size = [5.0, 3.5]; # in inches, 16:9 format |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
100 border = 0; # For postscript use 50/72 |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
101 set (0, "defaultfigurepapertype", "<custom>"); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
102 set (0, "defaultfigurepaperorientation", "landscape"); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
103 set (0, "defaultfigurepapersize", image_size + 2*border); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
104 set (0, "defaultfigurepaperposition", [border, border, image_size]); |
6721 | 105 endfunction |
106 | |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
107 ## Use this function before plotting commands and after every call to print |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
108 ## since print() resets output to stdout (unfortunately, gnuplot can't pop |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
109 ## output as it can the terminal type). |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
110 function hide_output () |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
111 hf = figure (1, "visible", "off"); |
6721 | 112 endfunction |
7262 | 113 |
114 ## generate something for the texinfo @image command to process | |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
115 function image_as_txt (d, nm) |
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
116 fid = fopen (fullfile (d, [nm ".txt"]), "wt"); |
7262 | 117 fputs (fid, "\n"); |
118 fputs (fid, "+---------------------------------+\n"); | |
119 fputs (fid, "| Image unavailable in text mode. |\n"); | |
120 fputs (fid, "+---------------------------------+\n"); | |
121 fclose (fid); | |
122 endfunction | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
123 |