annotate scripts/plot/private/__go_draw_figure__.m @ 15467:049e8bbff782

maint: periodic merge of stable to default
author John W. Eaton <jwe@octave.org>
date Mon, 01 Oct 2012 18:30:44 -0400
parents 5d3a684236b0 d174210ce1ec
children abf384f5d243
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12793
diff changeset
1 ## Copyright (C) 2005-2012 John W. Eaton
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
2 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
4 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
9 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
14 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
19 ## -*- texinfo -*-
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
20 ## @deftypefn {Function File} {} __go_draw_figure__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6619
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
22 ## @end deftypefn
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
23
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
24 ## Author: jwe
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
25
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10725
diff changeset
26 function __go_draw_figure__ (h, plot_stream, enhanced, mono)
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
27
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10725
diff changeset
28 if (nargin == 4)
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8224
diff changeset
29 htype = get (h, "type");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8224
diff changeset
30 if (strcmp (htype, "figure"))
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
31 ## Get complete list of children.
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
32 kids = allchild (h);
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
33 nkids = length (kids);
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
34
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
35 if (nkids > 0)
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
36 fputs (plot_stream, "\nreset;\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
37 fputs (plot_stream, "set autoscale keepfix;\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
38 fputs (plot_stream, "set origin 0, 0\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
39 fputs (plot_stream, "set size 1, 1\n");
10119
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
40 bg = get (h, "color");
10136
ee18258bc002 Also treat white figure and axes color properties
David Bateman <dbateman@free.fr>
parents: 10120
diff changeset
41 if (isnumeric (bg))
10119
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
42 fprintf (plot_stream, "set obj 1 rectangle from screen 0,0 to screen 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * bg);
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
43 bg_is_set = true;
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
44 else
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
45 bg_is_set = false;
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
46 endif
14663
161d06a52360 Gnuplot toolkit: Unset color from previous axis.
Ben Abbott <bpabbott@mac.com>
parents: 14415
diff changeset
47 fg_was_set = false;
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
48
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
49 for i = nkids:-1:1
10568
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
50 type = get (kids(i), "type");
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
51 switch (type)
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
52 case "axes"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10913
diff changeset
53 if (strcmpi (get (kids (i), "tag"), "legend"))
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
54 ## This is so ugly. If there was a way of getting
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
55 ## gnuplot to give us the text extents of strings
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
56 ## then we could get rid of this mess.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
57 lh = getfield (get (kids(i), "userdata"), "handle");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
58 if (isscalar (lh))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
59 ## We have a legend with a single parent. It'll be handled
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
60 ## below as a gnuplot key to the axis it corresponds to
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
61 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
62 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
63 ca = lh(1);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
64 ## Rely upon listener to convert axes position
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
65 ## to "normalized" units.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
66 legend_axes_units = get (kids(i), "units");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
67 legend_axes_position = get (kids(i), "position");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
68 legend_axes_outerposition = get (kids(i), "outerposition");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
69 legend_axes_box = get (kids(i), "box");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
70 legend_axes_ylim = get (kids(i), "ylim");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
71 orig_axes_units = get (ca, "units");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
72 hlgnd = get (kids(i));
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
73
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
74 unwind_protect
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
75 set (ca, "units", "normalized");
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
76 set (kids(i), "units", "normalized", "box", "off",
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
77 "ylim", [-2, -1], "position", get (ca(1), "position"),
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
78 "outerposition", get (ca(1), "outerposition"));
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10913
diff changeset
79
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
80 ## Create a new set of lines with the appropriate
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
81 ## displaynames, etc
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
82 toberm = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
83 hobj = get (kids(i), "children");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
84 for j = numel (hobj) : -1 : 1
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
85 if (! strcmp (get (hobj(j), "type"), "text"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
86 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
87 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
88 displayname = get (hobj(j), "string");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
89 ll = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
90 lm = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
91 for k = numel (hobj) : -1 : 1
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
92 if (! strcmp (get (hobj(k), "type"), "line"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
93 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
94 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
95 if (get (hobj(j), "userdata")
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
96 != get (hobj(k), "userdata"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
97 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
98 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
99 if (! strcmp (get (hobj(k), "linestyle"), "none"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
100 ll = hobj(k);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
101 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
102 if (! strcmp (get (hobj(k), "marker"), "none"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
103 lm = hobj(k);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
104 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
105 endfor
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
106
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
107 if (! isempty (ll))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
108 if (!isempty (lm))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
109 toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", get(ll,"linestyle"), "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
110 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
111 toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(ll,"color"), "linestyle", get(ll,"linestyle"), "marker", "none", "displayname", displayname, "parent", kids(i))];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
112 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
113 elseif (! isempty (lm))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
114 toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", "none", "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
115 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
116 endfor
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
117 if (bg_is_set)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
118 fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", 255 * (1 - bg));
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
119 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
120 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono,
11204
d2f3a904ac6b Unset the foreground color for the gnuplot backend earlier (fixes #31533)
David Bateman <dbateman@free.fr>
parents: 11198
diff changeset
121 bg_is_set, false, hlgnd);
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
122 unwind_protect_cleanup
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
123 ## Return axes "units" and "position" back to
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
124 ## their original values.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
125 set (ca, "units", orig_axes_units);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
126 set (kids(i), "units", legend_axes_units,
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
127 "box", legend_axes_box,
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
128 "ylim", legend_axes_ylim,
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
129 "position", legend_axes_position,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
130 "outerposition", legend_axes_outerposition);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
131 delete (toberm);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
132 bg_is_set = false;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
133 end_unwind_protect
10725
3c59ce262c66 Add the whitebg function
David Bateman <dbateman@free.fr>
parents: 10568
diff changeset
134 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
135 else
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
136 ## Rely upon listener to convert axes position
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
137 ## to "normalized" units.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
138 orig_axes_units = get (kids(i), "units");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
139 orig_axes_position = get (kids(i), "position");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
140 unwind_protect
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
141 set (kids(i), "units", "normalized");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
142 fg = get (kids(i), "color");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
143 if (isnumeric (fg) && strcmp (get (kids(i), "visible"), "on"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
144 fprintf (plot_stream, "set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * fg);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
145 fg_is_set = true;
14663
161d06a52360 Gnuplot toolkit: Unset color from previous axis.
Ben Abbott <bpabbott@mac.com>
parents: 14415
diff changeset
146 fg_was_set = true;
161d06a52360 Gnuplot toolkit: Unset color from previous axis.
Ben Abbott <bpabbott@mac.com>
parents: 14415
diff changeset
147 elseif (fg_was_set)
161d06a52360 Gnuplot toolkit: Unset color from previous axis.
Ben Abbott <bpabbott@mac.com>
parents: 14415
diff changeset
148 fprintf (plot_stream, "unset obj 2\n");
161d06a52360 Gnuplot toolkit: Unset color from previous axis.
Ben Abbott <bpabbott@mac.com>
parents: 14415
diff changeset
149 fg_is_set = false;
161d06a52360 Gnuplot toolkit: Unset color from previous axis.
Ben Abbott <bpabbott@mac.com>
parents: 14415
diff changeset
150 fg_was_set = false;
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
151 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
152 fg_is_set = false;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
153 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
154 if (bg_is_set)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
155 fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", 255 * (1 - bg));
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10913
diff changeset
156 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
157 ## Find if this axes has an associated legend axes and pass it
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
158 ## to __go_draw_axes__
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
159 hlegend = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
160 fkids = get (h, "children");
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14663
diff changeset
161 for j = 1 : numel (fkids)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
162 if (ishandle (fkids (j))
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
163 && strcmp (get (fkids (j), "type"), "axes")
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
164 && (strcmp (get (fkids (j), "tag"), "legend")))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
165 udata = get (fkids (j), "userdata");
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14663
diff changeset
166 if (isscalar (udata.handle)
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
167 && ! isempty (intersect (udata.handle, kids (i))))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
168 hlegend = get (fkids (j));
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
169 break;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
170 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
171 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
172 endfor
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
173 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono,
11204
d2f3a904ac6b Unset the foreground color for the gnuplot backend earlier (fixes #31533)
David Bateman <dbateman@free.fr>
parents: 11198
diff changeset
174 bg_is_set, fg_is_set, hlegend);
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
175 unwind_protect_cleanup
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
176 ## Return axes "units" and "position" back to
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
177 ## their original values.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
178 set (kids(i), "units", orig_axes_units);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
179 set (kids(i), "position", orig_axes_position);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
180 bg_is_set = false;
11204
d2f3a904ac6b Unset the foreground color for the gnuplot backend earlier (fixes #31533)
David Bateman <dbateman@free.fr>
parents: 11198
diff changeset
181 fg_is_set = false;
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
182 end_unwind_protect
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
183 endif
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 10995
diff changeset
184 case "uimenu"
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 10995
diff changeset
185 ## ignore uimenu objects
14415
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
186 kids(i) = [];
10568
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
187 otherwise
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
188 error ("__go_draw_figure__: unknown object class, %s", type);
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
189 endswitch
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
190 endfor
14415
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
191 if (isempty (kids))
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
192 fputs (plot_stream, "\nreset; clear;\n");
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
193 fflush (plot_stream);
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
194 else
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
195 fputs (plot_stream, "\nunset multiplot;\n");
eeff2d0a275d The gnuplot toolkit behavior is indepednet of uimenu children (bug # 35393).
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
196 endif
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
197 else
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
198 fputs (plot_stream, "\nreset; clear;\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
199 fflush (plot_stream);
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
200 endif
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
201 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
202 error ("__go_draw_figure__: expecting figure object, found '%s'",
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
203 htype);
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
204 endif
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
205 else
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
206 print_usage ();
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
207 endif
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
208
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
209 endfunction
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
210