Mercurial > octave
annotate doc/interpreter/geometryimages.m @ 20307:c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
* doc/module.mk: New file created from doc/Makefile.am,
doc/doxyhtml/Makefile.am, doc/liboctave/Makefile,
doc/interpreter/Makefile.am, and doc/refcard/Makefile.
* configure.ac (AC_OUTPUT): Don't generate doc/Makefile,
doc/doxyhtml/Makefile, or doc/interpreter/Makefile.
* Makefile.am (.NOTPARALLEL, AUTHORS, BUGS, INSTALL.OCTAVE):
Delete targets.
* config-images.sh, find-docstring-files.sh, geometryimages.m,
graphics_properties.mk, images.awk, interpimages.m, plotimages.m,
sparseimages.m, splineimages.m: Adapt to Makefile changes.
* octave.texi, liboctave.texi: Use unique version file names.
* etc/module.mk: Ensure icons build directory is created.
(etc/icons/octave-logo.ico): Fix file name.
* examples/module.mk (examples_code_SRC): New variable.
* doc/Makefile.am, doc/doxyhtml/Makefile.am,
doc/liboctave/Makefile.am, doc/interpreter/Makefile.am,
doc/refcard/Makefile: Delete.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 03 Jul 2015 19:33:19 -0400 |
parents | 4e15a4c331e7 |
children | d8992a16643c |
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:
20215
diff
changeset
|
19 function geometryimages (d, nm, typ) |
19717
606b05352351
Backout cset 59ad278cfb98, use gnuplot for building doc images.
Rik <rik@octave.org>
parents:
19708
diff
changeset
|
20 graphics_toolkit ("gnuplot"); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
21 set_print_size (); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
22 hide_output (); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
23 outfile = fullfile (d, strcat (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:
16170
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:
8920
diff
changeset
|
32 |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
33 if (! __have_feature__ ("QHULL") |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
34 && any (strcmp (nm, {"voronoi", "griddata", "convhull", "delaunay", ... |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
35 "triplot"}))) |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
36 sombreroimage (nm, typ, d_typ); |
7262 | 37 elseif (strcmp (typ, "txt")) |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
38 image_as_txt (d, nm); |
6855 | 39 elseif (strcmp (nm, "voronoi")) |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
40 rand ("state", 9); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
41 x = rand (10, 1); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
42 y = rand (10, 1); |
6832 | 43 tri = delaunay (x, y); |
44 [vx, vy] = voronoi (x, y, tri); | |
45 triplot (tri, x, y, "b"); | |
46 hold on; | |
47 plot (vx, vy, "r"); | |
48 [r, c] = tri2circ (tri(end,:), x, y); | |
49 pc = [-1:0.01:1]; | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
50 xc = r * sin (pi*pc) + c(1); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
51 yc = r * cos (pi*pc) + c(2); |
6832 | 52 plot (xc, yc, "g-", "LineWidth", 3); |
53 axis([0, 1, 0, 1]); | |
54 legend ("Delaunay Triangulation", "Voronoi Diagram"); | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
55 print (outfile, d_typ); |
6832 | 56 elseif (strcmp (nm, "triplot")) |
57 rand ("state", 2) | |
58 x = rand (20, 1); | |
59 y = rand (20, 1); | |
60 tri = delaunay (x, y); | |
61 triplot (tri, x, y); | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
62 print (outfile, d_typ); |
6832 | 63 elseif (strcmp (nm, "griddata")) |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
64 rand ("state", 1); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
65 x = 2 * rand (1000,1) - 1; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
66 y = 2 * rand (size (x)) - 1; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
67 z = sin (2 * (x.^2 + y.^2)); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
68 [xx,yy] = meshgrid (linspace (-1,1,32)); |
20215
4e15a4c331e7
doc: Fix griddata example to new calling convention
Mike Miller <mtmiller@octave.org>
parents:
19717
diff
changeset
|
69 zz = griddata (x, y, z, xx, yy); |
4e15a4c331e7
doc: Fix griddata example to new calling convention
Mike Miller <mtmiller@octave.org>
parents:
19717
diff
changeset
|
70 mesh (xx, yy, zz); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
71 print (outfile, d_typ); |
6832 | 72 elseif (strcmp (nm, "convhull")) |
73 x = -3:0.05:3; | |
74 y = abs (sin (x)); | |
75 k = convhull (x, y); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
76 plot (x(k),y(k),'r-', x,y,'b+'); |
6832 | 77 axis ([-3.05, 3.05, -0.05, 1.05]); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
78 print (outfile, d_typ); |
6832 | 79 elseif (strcmp (nm, "delaunay")) |
80 rand ("state", 1); | |
6847 | 81 x = rand (1, 10); |
82 y = rand (1, 10); | |
6832 | 83 T = delaunay (x, y); |
84 X = [ x(T(:,1)); x(T(:,2)); x(T(:,3)); x(T(:,1)) ]; | |
85 Y = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ]; | |
86 axis ([0, 1, 0, 1]); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
87 plot (X,Y,"b", x,y,"r*"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
88 print (outfile, d_typ); |
6847 | 89 elseif (strcmp (nm, "inpolygon")) |
90 randn ("state", 2); | |
91 x = randn (100, 1); | |
92 y = randn (100, 1); | |
93 vx = cos (pi * [-1 : 0.1: 1]); | |
94 vy = sin (pi * [-1 : 0.1 : 1]); | |
95 in = inpolygon (x, y, vx, vy); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
96 plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); |
6847 | 97 axis ([-2, 2, -2, 2]); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
98 print (outfile, d_typ); |
6832 | 99 else |
100 error ("unrecognized plot requested"); | |
101 endif | |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
102 hide_output (); |
6832 | 103 endfunction |
104 | |
105 function [r, c] = tri2circ (tri, xx, yy) | |
106 x = xx(tri); | |
107 y = yy(tri); | |
108 m = (y(1:end-1) - y(2:end)) ./ (x(1:end-1) - x(2:end)); | |
109 xc = (prod(m) .* (y(1) - y(end)) + m(end)*(x(1)+x(2)) - m(1)*(x(2)+x(3))) ... | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
110 ./ (2 * (m(end) - m(1))); |
6832 | 111 yc = - (xc - (x(2) + x(3))./2) ./ m(end) + (y(2) + y(3)) / 2; |
112 c = [xc, yc]; | |
113 r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2); | |
114 endfunction | |
115 | |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
116 function set_print_size () |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
117 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:
8920
diff
changeset
|
118 border = 0; # For postscript use 50/72 |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
119 set (0, "defaultfigurepapertype", "<custom>"); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
120 set (0, "defaultfigurepaperorientation", "landscape"); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
121 set (0, "defaultfigurepapersize", image_size + 2*border); |
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
122 set (0, "defaultfigurepaperposition", [border, border, image_size]); |
6832 | 123 endfunction |
124 | |
125 ## Use this function before plotting commands and after every call to | |
126 ## print since print() resets output to stdout (unfortunately, gnpulot | |
127 ## can't pop output as it can the terminal type). | |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
128 function hide_output () |
6832 | 129 f = figure (1); |
130 set (f, "visible", "off"); | |
131 endfunction | |
6855 | 132 |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
133 function sombreroimage (nm, typ, d_typ) |
6855 | 134 if (strcmp (typ, "txt")) |
135 fid = fopen (sprintf ("%s.txt", nm), "wt"); | |
136 fputs (fid, "+-----------------------------+\n"); | |
137 fputs (fid, "| Image unavailable because |\n"); | |
138 fputs (fid, "| of a missing QHULL library. |\n"); | |
139 fputs (fid, "+-----------------------------+\n"); | |
140 fclose (fid); | |
141 return; | |
142 else ## if (!strcmp (typ, "txt")) | |
143 | |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
144 hide_output (); |
6855 | 145 |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
146 [x, y, z] = sombrero (); |
6855 | 147 unwind_protect |
148 mesh (x, y, z); | |
149 title ("Sorry, graphics not available because octave was\\ncompiled without the QHULL library."); | |
150 unwind_protect_cleanup | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
151 print (outfile, d_typ); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
152 hide_output (); |
6855 | 153 end_unwind_protect |
154 endif | |
155 endfunction | |
7262 | 156 |
157 ## generate something for the texinfo @image command to process | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
158 function image_as_txt (d, nm) |
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
20215
diff
changeset
|
159 fid = fopen (fullfile (d, strcat (nm, ".txt")), "wt"); |
7262 | 160 fputs (fid, "\n"); |
161 fputs (fid, "+---------------------------------+\n"); | |
162 fputs (fid, "| Image unavailable in text mode. |\n"); | |
163 fputs (fid, "+---------------------------------+\n"); | |
164 fclose (fid); | |
165 endfunction | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
166 |