annotate scripts/testfun/private/compare_plot_demos.m @ 20830:b65888ec820e draft default tip gccjit

dmalcom gcc jit import
author Stefan Mahr <dac922@gmx.de>
date Fri, 27 Feb 2015 16:59:36 +0100
parents 9fc020886ae9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
1 ## Copyright (C) 2012 Ben Abbott <bpabbott@mac.com>
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 -*-
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
20 ## @deftypefn {Function File} {} compare_plot_demos ()
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
21 ## @deftypefnx {Function File} {} compare_plot_demos ("toolkits", @{@var{toolkit1}, @var{toolkit2}, @dots{}@})
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
22 ##
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
23 ## Uses @code{dump_demos} and @code{html_compare_plot_demos} to produce an
19115
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
24 ## html comparison of the plot demos for each of Octave's graphics toolkits.
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
25 ##
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
26 ## An m-file named @file{dump_plots.m} will be created in the current working
19344
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19115
diff changeset
27 ## directory. This function will be used to render and save the plot demo
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
28 ## images.
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
29 ##
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
30 ## If they do not already exist, directories for each available graphics
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
31 ## toolkit are created. Each toolkit's directory will be populated with images
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
32 ## of each plot demo in the png format.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
33 ##
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
34 ## Finally, an html document named @file{compare_plot_demos.html} is produced.
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
35 ## This page places each toolkit's images side by side for a convenient
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
36 ## comparison of the results.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
37 ##
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
38 ## If the property @qcode{"toolkits"} is given then compare only the listed
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
39 ## toolkits in the cell string. The list may also include the toolkit
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
40 ## @qcode{"matlab"}.
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
41 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
42 ## @end deftypefn
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
43
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
44 ## Author: Ben Abbott <bpabbott@mac.com>
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
45
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
46 function compare_plot_demos (varargin)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
47
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
48 arg.toolkits = available_graphics_toolkits ();
19087
f9cf5ae6b8a2 Add image directory to plot comparison scripts.
Rik <rik@octave.org>
parents: 19085
diff changeset
49 arg.directories = {"plot/appearance", "plot/draw", "plot/util", "image"};
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
50 arg.fmt = "png";
19115
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
51 arg.fcn_file = "dump_plot_demos.m";
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
52 arg.replace_images = false;
19064
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 for n = 1:2:numel(varargin)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
55 if (! ischar (varargin{n}))
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
56 print_usage ();
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
57 else
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
58 arg.(varargin{n}) = varargin{n+1};
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
59 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
60 endfor
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
61
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
62 if (ischar (arg.toolkits))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
63 arg.toolkits = {arg.toolkits};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
64 elseif (! iscellstr (arg.toolkits))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
65 error ('compare_plot_demos: Invalid value for "toolkits"')
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
66 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
67
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
68 if (ischar (arg.directories))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
69 arg.directories = {arg.directories};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
70 elseif (! iscellstr (arg.directories))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
71 error ('compare_plot_demos: Invalid value for "directory"')
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
72 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
73
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
74 if (! ischar (arg.fmt))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
75 error ('compare_plot_demos: Invalid value for "fmt"')
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
76 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
77
19115
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
78 ## Generate arg.fcn_file for rendering/saving the plot demo images
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
79 dump_demos (arg.directories, arg.fcn_file, arg.fmt);
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
80
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
81 [~, fcn_name] = fileparts (arg.fcn_file);
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
82
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
83 ## Generate the plot demo images for each toolkit
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
84 cwd = pwd ();
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
85 unwind_protect
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
86 addpath (pwd);
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
87 for n = 1:numel (arg.toolkits)
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
88 if (! isdir (fullfile (cwd, arg.toolkits{n})))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
89 mkdir (arg.toolkits{n});
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
90 endif
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
91 cd (arg.toolkits{n});
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
92 if (arg.replace_images && ! isempty (dir (["*." arg.fmt])))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
93 delete (["*." arg.fmt]);
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
94 endif
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
95 if (! strcmp (arg.toolkits{n}, "matlab"))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
96 close all;
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
97 graphics_toolkit (arg.toolkits{n});
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
98 try
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
99 eval (fcn_name);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
100 catch
20038
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19344
diff changeset
101 printf ("Error running plot demos for ""%s"" toolkit\n",
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19344
diff changeset
102 arg.toolkits{n});
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
103 disp (lasterror);
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
104 end_try_catch
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
105 endif
19085
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 19067
diff changeset
106 cd (cwd);
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
107 endfor
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
108 unwind_protect_cleanup
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
109 rmpath (cwd);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
110 end_unwind_protect
19115
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
111 if (! strcmp (arg.toolkits, "matlab"))
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
112 ## Generate the html comparison of the images
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
113 html_compare_plot_demos (arg.toolkits);
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
114 else
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
115 ## We need to run matlab manually before the html page can be created
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
116 printf ('\nNow run %s in Matlab.\nAfter this run html_compare_plot_demos,\n', arg.fcn_file);
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
117 printf ('for example html_compare_plot_demos ({"fltk", "gnuplot", "matlab"}), to create the html page.\n');
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19087
diff changeset
118 endif
19064
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
119 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
120