Mercurial > hg > octave-lyh
annotate scripts/plot/__go_draw_figure__.m @ 11191:01ddaedd6ad5
Reverse changeset b1f4bdc276b6. Use all lower case for "uniformoutput" option.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 04 Nov 2010 12:18:08 -0700 |
parents | f0e9befd6a1c |
children | 9f080d23396f |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2005, 2007, 2008, 2009 John W. Eaton |
6405 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6405 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6405 | 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 | 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 | 23 |
24 ## Author: jwe | |
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 | 27 |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10725
diff
changeset
|
28 if (nargin == 4) |
8249 | 29 htype = get (h, "type"); |
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 | 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 |
10473
169be980faf9
__go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents:
10159
diff
changeset
|
47 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
|
48 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
|
49 switch (type) |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
50 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
|
51 if (strcmpi (get (kids (i), "tag"), "legend")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
52 continue; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
53 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
54 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
55 ## Rely upon listener to convert axes position |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
56 ## to "normalized" units. |
10568
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
57 orig_axes_units = get (kids(i), "units"); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
58 orig_axes_position = get (kids(i), "position"); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
59 unwind_protect |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
60 set (kids(i), "units", "normalized"); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
61 fg = get (kids(i), "color"); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
62 if (isnumeric (fg) && strcmp (get (kids(i), "visible"), "on")) |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
63 fprintf (plot_stream, "set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * fg); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
64 fg_is_set = true; |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
65 else |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
66 fg_is_set = false; |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
67 endif |
10725
3c59ce262c66
Add the whitebg function
David Bateman <dbateman@free.fr>
parents:
10568
diff
changeset
|
68 if (bg_is_set) |
3c59ce262c66
Add the whitebg function
David Bateman <dbateman@free.fr>
parents:
10568
diff
changeset
|
69 fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", 255 * (1 - bg)); |
3c59ce262c66
Add the whitebg function
David Bateman <dbateman@free.fr>
parents:
10568
diff
changeset
|
70 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
71 ## Find if this axes has an associated legend axes and pass it |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
72 ## to __go_draw_axes__ |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
73 hlegend = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
74 fkids = get (h, "children"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
75 for j = 1 : numel(fkids) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
76 if (ishandle (fkids (j)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
77 && strcmp (get (fkids (j), "type"), "axes") |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
78 && (strcmp (get (fkids (j), "tag"), "legend"))) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
79 udata = get (fkids (j), "userdata"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
80 if (! isempty (intersect (udata.handle, kids (i)))) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
81 hlegend = fkids (j); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
82 break; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
83 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
84 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
85 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
86 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono, |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
87 bg_is_set, hlegend); |
10913
dd6b90f44ae5
Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents:
10725
diff
changeset
|
88 unwind_protect_cleanup |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
89 ## Return axes "units" and "position" back to |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10913
diff
changeset
|
90 ## their original values. |
10568
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
91 set (kids(i), "units", orig_axes_units); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
92 set (kids(i), "position", orig_axes_position); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
93 bg_is_set = false; |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
94 if (fg_is_set) |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
95 fputs (plot_stream, "unset obj 2\n"); |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
96 endif |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
97 end_unwind_protect |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
10995
diff
changeset
|
98 case "uimenu" |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
10995
diff
changeset
|
99 ## ignore uimenu objects |
10568
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
100 otherwise |
046b713d21dc
__go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
101 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
|
102 endswitch |
10473
169be980faf9
__go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents:
10159
diff
changeset
|
103 endfor |
169be980faf9
__go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents:
10159
diff
changeset
|
104 fputs (plot_stream, "\nunset multiplot;\n"); |
9098
5ecdb3d3568f
Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents:
9062
diff
changeset
|
105 else |
10473
169be980faf9
__go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents:
10159
diff
changeset
|
106 fputs (plot_stream, "\nreset; clear;\n"); |
169be980faf9
__go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents:
10159
diff
changeset
|
107 fflush (plot_stream); |
9098
5ecdb3d3568f
Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents:
9062
diff
changeset
|
108 endif |
6405 | 109 else |
110 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
|
111 htype); |
6405 | 112 endif |
113 else | |
114 print_usage (); | |
115 endif | |
116 | |
117 endfunction | |
118 |