Mercurial > octave
annotate doc/interpreter/interpimages.m @ 31751:e863066429f1
assume QOffscreenSurface is available
QOffscreenSurface was introduced in Qt 5.1.
* acinclude.m4 (OCTAVE_CHECK_QT_OPENGL_OFFSCREEN_OK): Delete.
(OCTAVE_CHECK_QT_VERSION): Delete use.
* configure.ac, geometryimages.m, interpimages.m, module.mk,
plotimages.m, sparseimages.m, splineimages.m, GLCanvas.cc, GLCanvas.h,
getframe.m, __check_rendering_capability__.m, copyobj.m, hgsave.m,
jupyter-notebook.tst, publish.tst: Eliminate checks for Qt
OffscreenSurface feature. Assume it is always available.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Jan 2023 13:11:02 -0500 |
parents | 597f3ee61a48 |
children | 2e484f9f1f18 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3 ## Copyright (C) 2007-2023 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27847
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7018 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7018 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7018 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7018 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
21 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7018 | 25 |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
26 function interpimages (d, nm, typ) |
28620
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
27 |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
28 if (strcmp (typ, "txt")) |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
29 image_as_txt (d, nm); |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
30 return; |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
31 endif |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
32 |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
33 set_graphics_toolkit (); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
34 set_print_size (); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
35 hide_output (); |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
36 outfile = fullfile (d, [nm "." typ]); |
7257 | 37 if (strcmp (typ, "png")) |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
38 set (groot, "defaulttextfontname", "*"); |
7257 | 39 endif |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
40 if (strcmp (typ, "eps")) |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
41 d_typ = "-depsc2"; |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
42 else |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
43 d_typ = ["-d", typ]; |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
44 endif |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
45 |
28620
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
46 if (strcmp (nm, "interpft")) |
6721 | 47 t = 0 : 0.3 : pi; dt = t(2)-t(1); |
48 n = length (t); k = 100; | |
49 ti = t(1) + [0 : k-1]*dt*n/k; | |
50 y = sin (4*t + 0.3) .* cos (3*t - 0.1); | |
51 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
|
52 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
|
53 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
|
54 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
|
55 print (outfile, d_typ); |
6721 | 56 elseif (strcmp (nm, "interpn")) |
57 x = y = z = -1:1; | |
58 f = @(x,y,z) x.^2 - y - z.^2; | |
59 [xx, yy, zz] = meshgrid (x, y, z); | |
60 v = f (xx,yy,zz); | |
61 xi = yi = zi = -1:0.1:1; | |
62 [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
|
63 vi = interpn (x, y, z, v, xxi, yyi, zzi, "spline"); |
6723 | 64 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
|
65 print (outfile, d_typ); |
6743 | 66 elseif (strcmp (nm, "interpderiv1")) |
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 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
|
73 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
|
74 plot (ti, ys,"r-", ti, yp,"g-"); |
26362
e3dfcfc8bd6c
interpimages.m: Replace deprecated use of numeric position argument to legend.
Rik <rik@octave.org>
parents:
25998
diff
changeset
|
75 legend ("spline","pchip", "location", "southeast"); |
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); |
6743 | 77 elseif (strcmp (nm, "interpderiv2")) |
78 t = -2:2; | |
79 dt = 1; | |
80 ti =-2:0.025:2; | |
81 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
|
82 y = sign (t); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 legend ("spline", "pchip"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
87 print (outfile, d_typ); |
6721 | 88 endif |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
89 hide_output (); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
90 endfunction |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
91 |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
92 ## 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
|
93 ## 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
|
94 ## 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
|
95 ## problem. |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
96 function set_graphics_toolkit () |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
97 if (isempty (available_graphics_toolkits ())) |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
98 error ("no graphics toolkit available for plotting"); |
31751
e863066429f1
assume QOffscreenSurface is available
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
99 elseif (strcmp ("qt", graphics_toolkit ())) |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
100 ## Use qt with QOffscreenSurface for plot |
27847
56d94f86a659
Don't test presence of OSMESA which will always fail (bug #57424)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
101 elseif (! strcmp ("gnuplot", graphics_toolkit ())) |
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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 endif |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
107 endif |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
108 endfunction |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
109 |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
110 function set_print_size () |
25998
8d2b3e3ff182
print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25428
diff
changeset
|
111 image_size = [5.0, 3.5]; # in inches, 16:9 format |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
112 border = 0; # For postscript use 50/72 |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
113 set (groot, "defaultfigurepapertype", "<custom>"); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
114 set (groot, "defaultfigurepaperorientation", "landscape"); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
115 set (groot, "defaultfigurepapersize", image_size + 2*border); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
116 set (groot, "defaultfigurepaperposition", [border, border, image_size]); |
22037
782ecfde4859
doc: Create images for manual with legends that don't extend out of axes box.
Rik <rik@octave.org>
parents:
21226
diff
changeset
|
117 ## FIXME: Required until listener for legend exists (bug #39697) |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
118 set (groot, "defaultfigureposition", [ 72*[border, border, image_size] ]); |
6721 | 119 endfunction |
120 | |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
121 ## 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
|
122 ## 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
|
123 ## 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
|
124 function hide_output () |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
125 hf = figure (1, "visible", "off"); |
6721 | 126 endfunction |
7262 | 127 |
128 ## 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
|
129 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
|
130 fid = fopen (fullfile (d, [nm ".txt"]), "wt"); |
7262 | 131 fputs (fid, "\n"); |
132 fputs (fid, "+---------------------------------+\n"); | |
133 fputs (fid, "| Image unavailable in text mode. |\n"); | |
134 fputs (fid, "+---------------------------------+\n"); | |
135 fclose (fid); | |
136 endfunction |