comparison scripts/plot/__go_draw_figure__.m @ 10568:046b713d21dc

__go_draw_figure__.m: Hidden axes may have visible children.
author Ben Abbott <bpabbott@mac.com>
date Sun, 25 Apr 2010 10:04:52 -0400
parents 6a2e4e464d38
children 3c59ce262c66
comparison
equal deleted inserted replaced
10567:79410269cd21 10568:046b713d21dc
75 bg_is_set = true; 75 bg_is_set = true;
76 else 76 else
77 bg_is_set = false; 77 bg_is_set = false;
78 endif 78 endif
79 for i = nkids:-1:1 79 for i = nkids:-1:1
80 if (strcmp (get (kids(i), "visible"), "on")) 80 type = get (kids(i), "type");
81 type = get (kids(i), "type"); 81 switch (type)
82 switch (type) 82 case "axes"
83 case "axes" 83 ## Rely upon listener to convert axes position to "normalized" units.
84 ## Rely upon listener to convert axes position to "normalized" units. 84 orig_axes_units = get (kids(i), "units");
85 orig_axes_units = get (kids(i), "units"); 85 orig_axes_position = get (kids(i), "position");
86 orig_axes_position = get (kids(i), "position"); 86 unwind_protect
87 unwind_protect 87 set (kids(i), "units", "normalized");
88 set (kids(i), "units", "normalized"); 88 fg = get (kids(i), "color");
89 fg = get (kids(i), "color"); 89 if (isnumeric (fg) && strcmp (get (kids(i), "visible"), "on"))
90 if (isnumeric (fg)) 90 fprintf (plot_stream, "set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * fg);
91 fprintf (plot_stream, "set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * fg); 91 fg_is_set = true;
92 fg_is_set = true; 92 else
93 else 93 fg_is_set = false;
94 fg_is_set = false; 94 endif
95 endif 95 if (output_to_paper)
96 if (output_to_paper) 96 axes_position_on_page = orig_axes_position .* paper_position([3, 4, 3 ,4]);
97 axes_position_on_page = orig_axes_position .* paper_position([3, 4, 3 ,4]); 97 axes_position_on_page(1:2) = axes_position_on_page(1:2) + paper_position(1:2);
98 axes_position_on_page(1:2) = axes_position_on_page(1:2) + paper_position(1:2); 98 set (kids(i), "position", axes_position_on_page);
99 set (kids(i), "position", axes_position_on_page); 99 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono, implicit_margin, bg_is_set);
100 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono, implicit_margin, bg_is_set); 100 else
101 else 101 ## Return axes "units" and "position" back to their original values.
102 ## Return axes "units" and "position" back to their original values. 102 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono, implicit_margin, bg_is_set);
103 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono, implicit_margin, bg_is_set); 103 endif
104 endif 104 unwind_protect_cleanup
105 unwind_protect_cleanup 105 set (kids(i), "units", orig_axes_units);
106 set (kids(i), "units", orig_axes_units); 106 set (kids(i), "position", orig_axes_position);
107 set (kids(i), "position", orig_axes_position); 107 bg_is_set = false;
108 bg_is_set = false; 108 if (fg_is_set)
109 if (fg_is_set) 109 fputs (plot_stream, "unset obj 2\n");
110 fputs (plot_stream, "unset obj 2\n"); 110 endif
111 endif 111 end_unwind_protect
112 end_unwind_protect 112 otherwise
113 otherwise 113 error ("__go_draw_figure__: unknown object class, %s", type);
114 error ("__go_draw_figure__: unknown object class, %s", type); 114 endswitch
115 endswitch
116 endif
117 endfor 115 endfor
118 fputs (plot_stream, "\nunset multiplot;\n"); 116 fputs (plot_stream, "\nunset multiplot;\n");
119 else 117 else
120 fputs (plot_stream, "\nreset; clear;\n"); 118 fputs (plot_stream, "\nreset; clear;\n");
121 fflush (plot_stream); 119 fflush (plot_stream);