Mercurial > octave-libgccjit
annotate scripts/testfun/private/html_compare_plot_demos.m @ 18964:a0c514c243f6 default tip @
maint: Use Octave coding conventions for %!test in graphics.cc.
* graphics.cc: Use Octave coding conventions for %!test in graphics.cc.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 28 Jul 2014 08:36:39 -0700 |
parents | 87324260043d |
children |
rev | line source |
---|---|
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2010 Ben Abbott |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
2 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
4 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
9 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
14 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
18 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
20 ## @deftypefn {Function File} {} html_compare (@var{toolkits}) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
21 ## @deftypefnx {Function File} {} html_compare (@var{toolkits}, @var{name}, @var{value}, @dots{}) |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
22 ## |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
23 ## Produces an html document to compare the plot demos produced by |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
24 ## @var{toolkits}. |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
25 ## |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
26 ## Valid property names, and their defaults, are: |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
27 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
28 ## @table @samp |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
29 ## @item fmt |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
30 ## @code{"png"} |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
31 ## @item output |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
32 ## @code{"compare_plot_demos.html"} |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
33 ## @item template |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
34 ## @code{"html_plot_demos_template.html"} |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
35 ## @item column_width |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
36 ## @code{600} |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
37 ## @end table |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
38 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
39 ## The template parameter refers to a specially formatted html file |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
40 ## which accompanies this m-file script. |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
41 ## |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
42 ## Additional toolkit description can be added to the column header |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
43 ## with a parameter named equal to the toolkit. For example: |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
44 ## |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
45 ## @example |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
46 ## @group |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
47 ## @code{html_compare_plot_demos ({"gnuplot", "fltk"}, "gnuplot", " 4.6 patchlevel 5")} |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
48 ## @end group |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
49 ## @end example |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
50 ## |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
51 ## @seealso{compare_plot_demos, dump_demos, demo} |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
52 ## @end deftypefn |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
53 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
54 ## Author: Ben Abbott <bpabbott@mac.com> |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
55 |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
56 function html_compare_plot_demos (toolkits, varargin) |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
57 |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
58 ## Set defaults |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
59 in.fmt = "png"; |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
60 in.figfiles = {}; |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
61 in.output= "compare_plot_demos.html"; |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
62 in.template = "html_plot_demos_template.html"; |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
63 in.column_width = 600; |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
64 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
65 ## Parse inputs |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
66 for n = 1:2:numel(varargin) |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
67 in.(lower(varargin{n})) = varargin{n+1}; |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
68 endfor |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
69 |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
70 ## Compile a list of all files for all toolkits |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
71 for t = 1:numel(toolkits) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
72 filter = sprintf ("%s/*.%s", toolkits{t}, in.fmt); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
73 in.figfiles = union (in.figfiles, {dir(filter).name}); |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
74 endfor |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
75 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
76 fid = fopen (which (in.template), "r"); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
77 template = char (fread (fid)) .'; |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
78 fclose (fid); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
79 |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
80 anchor = "<!-- ##ADD TABLE HERE## -->"; |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
81 n = findstr (template, anchor); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
82 header = template(1:n-1); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
83 trailer = template(n+numel(anchor):end); |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
84 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
85 fid = fopen (in.output, "w"); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
86 unwind_protect |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
87 fputs (fid, header); |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
88 fprintf (fid, "<p><b>\nGenerated on %s by %s with GNU Octave %s</p>", |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
89 datestr (now (), 0), mfilename, version); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
90 |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
91 ## Create table header |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
92 fprintf (fid, "<table border='1'><tr>\n"); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
93 for t = 1:numel(toolkits) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
94 ## set default |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
95 column_header = upper (toolkits{t}); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
96 if (isfield (in, toolkits{t})) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
97 column_header = strcat (column_header, in.(toolkits{t})); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
98 endif |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
99 fprintf (fid, '<th>%s <a href="%s/diary.log">diary</a></th>\n', column_header, toolkits{t}); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
100 endfor |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
101 fprintf (fid, "</tr>\n"); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
102 |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
103 for m = 1:numel(in.figfiles) |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
104 [~, file] = fileparts (in.figfiles{m}); |
18925
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
105 fn = strcat (file, ".", in.fmt); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
106 fprintf (fid, "<tr>\n"); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
107 for k = toolkits |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
108 ffn = fullfile (k{:}, fn); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
109 fprintf (fid, " <td>%s<br>", ffn); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
110 if (exist (ffn, "file")) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
111 fprintf (fid, "<img src='%s' style='width: %dpx;'>", ffn, in.column_width); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
112 else |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
113 err_fn = regexprep(ffn, ".png", ".err"); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
114 if (! exist (err_fn, "file")) |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
115 warning("File %s doesn't exist...", err_fn); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
116 else |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
117 err_fid = fopen (err_fn); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
118 msg = char (fread (err_fid))'; |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
119 fclose (err_fid); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
120 fprintf (fid, "%s", strrep (msg, "\n", "<br>")); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
121 endif |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
122 endif |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
123 fprintf (fid, "</td>\n"); |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
124 endfor |
87324260043d
Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18877
diff
changeset
|
125 fprintf (fid, "</tr>\n"); |
18874
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
126 endfor |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
127 fputs (fid, trailer); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
128 unwind_protect_cleanup |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
129 fclose (fid); |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
130 end_unwind_protect |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
131 |
c74673161752
Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
132 endfunction |