annotate scripts/plot/pie.m @ 14014:907d03def9d5

explicitly close figures in clean_up_and_exit instead of using an atexit function * graphics.cc (Fdrawnow): Don't register __go_close_all__ as an atexit function. * __go_close_all__.m: Delete. * plot/module.mk (plot_FCN_FILES): Remove __go_close_all__.m from the list. * graphics.cc (gh_manager::create_instance): Do register cleanup function. * graphics.cc (delete_graphics_objects, delete_graphics_object, close_figure, force_close_figure): New functions. (F__go_delete__): Call delete_graphics_objects to do the work. * graphics.h, graphics.cc (gh_manager::close_all_figures, gh_manager::do_close_all_figures): New functions. * graphics.h.in, graphics.cc (close_all_figures): New function. * toplev.cc (clean_up_and_exit): Call close_all_figures. * graphics.h.in (uitoggletool::~uitoggletool, uipushtool::~uipushtool, uitoolbar::~uitoolbar, uipanel::~uipanel, uicontrol::~uicontrol, uicontextmenu::~uicontextmenu, uimenu::~uimenu, hggroup::~hggroup, surface::~surface, image::~image, text::~text, line::~line, axes::~axes, figure::~figure, root_figure::~root_figure): Don't delete children. * toplev.cc (SAFE_CALL, IGNORE_INTERRUPT): Rename to OCTAVE_SAFE_CALL and OCTAVE_IGNORE_INTERRUPT and move to toplev.h. Temporarily set Vdebug_on_error and Vdebug_on_warning. Reset error_state to zero. Change all callers. * graphics.h.in (base_graphics_toolkit::close): New virtual function. (graphics_toolkit::close, graphics_toolkit::close_all_toolkits): New functions. * graphics.cc (gnuplot_toolkit::close): New function. ): * __init_fltk__.cc (F__init_fltk__): Don't register __remove_fltk__ as an atexit function. (F__remove_fltk__): Move to fltk_toolkit::close.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Dec 2011 06:28:18 -0500
parents 5f0bb45e615c
children 22c50cbad2ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11341
diff changeset
1 ## Copyright (C) 2007-2011 David Bateman
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
2 ##
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
4 ##
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
9 ##
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
14 ##
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
18
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
11341
3c7ba1e3dc21 Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents: 11330
diff changeset
20 ## @deftypefn {Function File} {} pie (@var{x})
3c7ba1e3dc21 Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents: 11330
diff changeset
21 ## @deftypefnx {Function File} {} pie (@var{x}, @var{explode})
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
22 ## @deftypefnx {Function File} {} pie (@dots{}, @var{labels})
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
23 ## @deftypefnx {Function File} {} pie (@var{h}, @dots{});
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
24 ## @deftypefnx {Function File} {@var{h} =} pie (@dots{});
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
25 ## Produce a 2-D pie chart.
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
26 ##
8325
b93ac0586e4b spelling corrections
Brian Gough<bjg@network-theory.co.uk>
parents: 7313
diff changeset
27 ## Called with a single vector argument, produces a pie chart of the
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
28 ## elements in @var{x}, with the size of the slice determined by percentage
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
29 ## size of the values of @var{x}.
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
30 ##
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
31 ## The variable @var{explode} is a vector of the same length as @var{x} that
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
32 ## if non zero 'explodes' the slice from the pie chart.
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
33 ##
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
34 ## If given @var{labels} is a cell array of strings of the same length as
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
35 ## @var{x}, giving the labels of each of the slices of the pie chart.
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
36 ##
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
37 ## The optional return value @var{h} is a list of handles to the patch
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
38 ## and text objects generating the plot.
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
39 ##
11330
4f399d91eb32 add pie3 to plot functions
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
40 ## @seealso{pie3, bar, stem}
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
41 ## @end deftypefn
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
42
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
43 ## Very roughly based on pie.m from octave-forge whose author was
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
44 ## Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de>
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
45
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
46 function retval = pie (varargin)
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
47
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
48 [h, varargin] = __plt_get_axis_arg__ ("pie", varargin{:});
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
49
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
50 if (nargin < 1)
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
51 print_usage ();
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7208
diff changeset
52 else
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
53 oldh = gca ();
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
54 unwind_protect
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
55 axes (h);
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
56 newplot ();
11330
4f399d91eb32 add pie3 to plot functions
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
57 tmp = __pie__ ("pie", h, varargin{:});
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
58 unwind_protect_cleanup
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
59 axes (oldh);
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
60 end_unwind_protect
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
61 endif
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
62
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
63 if (nargout > 0)
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
64 retval = tmp;
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
65 endif
7119
d22ad51b9cf8 [project @ 2007-11-07 21:06:27 by jwe]
jwe
parents: 7118
diff changeset
66
7118
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
67 endfunction
d32f867e4dda [project @ 2007-11-07 20:44:11 by jwe]
jwe
parents:
diff changeset
68
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
69
7120
a2174fb073d4 [project @ 2007-11-07 21:26:43 by jwe]
jwe
parents: 7119
diff changeset
70 %!demo
a2174fb073d4 [project @ 2007-11-07 21:26:43 by jwe]
jwe
parents: 7119
diff changeset
71 %! pie ([3, 2, 1], [0, 0, 1]);
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
72 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
7120
a2174fb073d4 [project @ 2007-11-07 21:26:43 by jwe]
jwe
parents: 7119
diff changeset
73
a2174fb073d4 [project @ 2007-11-07 21:26:43 by jwe]
jwe
parents: 7119
diff changeset
74 %!demo
a2174fb073d4 [project @ 2007-11-07 21:26:43 by jwe]
jwe
parents: 7119
diff changeset
75 %! pie ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"});
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
76 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
7120
a2174fb073d4 [project @ 2007-11-07 21:26:43 by jwe]
jwe
parents: 7119
diff changeset
77 %! axis ([-2,2,-2,2]);
11341
3c7ba1e3dc21 Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents: 11330
diff changeset
78
3c7ba1e3dc21 Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents: 11330
diff changeset
79 %!demo
3c7ba1e3dc21 Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents: 11330
diff changeset
80 %! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"});
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
81 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
11341
3c7ba1e3dc21 Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents: 11330
diff changeset
82 %! axis ([-2,2,-2,2]);
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
83 %! title ("missing slice");
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
84