Mercurial > hg > octave-avbm
changeset 13801:195ff3561152
allow figure handles to be non-integers
* graphics.h.in, graphics.cc (gh_manager::get_handle,
make_graphics_object, gh_manager::make_graphics_handle,
gh_manager::do_make_graphics_handle): New arg to determine
whether to generate integer-valued figure handle. Change all
callers.
* graphics.h.in (gh_manager::handle_list, gh_manager::do_handle_list,
gh_manager::figure_handle_list, gh_manager::do_figure_handle_list):
New arg to determine whether to show hidden handles. Change all
callers.
* graphics.cc (F__go_figure__): If specified handle is Inf, use
non-integer handle. Call gh_manager::push_figure here.
(F__go_handles__): New arg to control display of hidden handles. Pass
flag to gh_manager::handle_list.
(F__go_figure_handles__): Likewise, pass flag to
gh_manager::figure_handle_list.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 03 Nov 2011 05:01:52 -0400 |
parents | 5acb5c25e4ae |
children | 630d3c80b541 |
files | src/graphics.cc src/graphics.h.in |
diffstat | 2 files changed, 100 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2108,11 +2108,11 @@ } graphics_handle -gh_manager::get_handle (const std::string& go_name) +gh_manager::get_handle (bool integer_figure_handle) { graphics_handle retval; - if (go_name == "figure") + if (integer_figure_handle) { // Figure handles are positive integers corresponding to the // figure number. @@ -3849,7 +3849,8 @@ if (v.is_string ()) { - val = gh_manager::make_graphics_handle ("text", __myhandle__, false); + val = gh_manager::make_graphics_handle ("text", __myhandle__, + false, false); xset (val, "string", v); } @@ -4049,10 +4050,17 @@ delete_children (true); - xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); - ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); - zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); - title = gh_manager::make_graphics_handle ("text", __myhandle__, false); + xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, + false, false); + + ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, + false, false); + + zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, + false, false); + + title = gh_manager::make_graphics_handle ("text", __myhandle__, + false, false); xset (xlabel.handle_value (), "handlevisibility", "off"); xset (ylabel.handle_value (), "handlevisibility", "off"); @@ -4122,7 +4130,8 @@ if (! is_beingdeleted ()) { - hp = gh_manager::make_graphics_handle ("text", __myhandle__, false); + hp = gh_manager::make_graphics_handle ("text", __myhandle__, + false, false); xset (hp.handle_value (), "handlevisibility", "off"); @@ -7281,10 +7290,12 @@ graphics_handle gh_manager::do_make_graphics_handle (const std::string& go_name, - const graphics_handle& p, bool do_createfcn, + const graphics_handle& p, + bool integer_figure_handle, + bool do_createfcn, bool do_notify_toolkit) { - graphics_handle h = get_handle (go_name); + graphics_handle h = get_handle (integer_figure_handle); base_graphics_object *go = 0; @@ -8206,6 +8217,7 @@ static octave_value make_graphics_object (const std::string& go_name, + bool integer_figure_handle, const octave_value_list& args) { octave_value retval; @@ -8245,7 +8257,9 @@ if (parent.ok ()) { graphics_handle h - = gh_manager::make_graphics_handle (go_name, parent, false, false); + = gh_manager::make_graphics_handle (go_name, parent, + integer_figure_handle, + false, false); if (! error_state) { @@ -8301,18 +8315,19 @@ { graphics_handle h = octave_NaN; - if (xisnan (val)) - h = gh_manager::make_graphics_handle ("figure", 0, false, - false); + if (xisnan (val) || xisinf (val)) + h = gh_manager::make_graphics_handle ("figure", 0, + xisnan (val), + false, false); else if (val > 0 && D_NINT (val) == val) h = gh_manager::make_figure_handle (val, false); - else - error ("__go_figure__: invalid figure number"); if (! error_state && h.ok ()) { adopt (0, h); + gh_manager::push_figure (h); + xset (h, args.splice (0, 1)); xcreatefcn (h); xinitialize (h); @@ -8338,7 +8353,7 @@ octave_value retval; \ \ if (args.length () > 0) \ - retval = make_graphics_object (#TYPE, args); \ + retval = make_graphics_object (#TYPE, false, args); \ else \ print_usage (); \ \ @@ -8663,26 +8678,36 @@ return retval; } -DEFUN (__go_handles__, , , +DEFUN (__go_handles__, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} __go_handles__ ()\n\ +@deftypefn {Built-in Function} {} __go_handles__ (@var{show_hidden})\n\ Undocumented internal function.\n\ @end deftypefn") { gh_manager::auto_lock guard; - return octave_value (gh_manager::handle_list ()); -} - -DEFUN (__go_figure_handles__, , , + bool show_hidden = false; + + if (args.length () > 0) + show_hidden = args(0).bool_value (); + + return octave_value (gh_manager::handle_list (show_hidden)); +} + +DEFUN (__go_figure_handles__, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ +@deftypefn {Built-in Function} {} __go_figure_handles__ (@var{show_hidden})\n\ Undocumented internal function.\n\ @end deftypefn") { gh_manager::auto_lock guard; - return octave_value (gh_manager::figure_handle_list ()); + bool show_hidden = false; + + if (args.length () > 0) + show_hidden = args(0).bool_value (); + + return octave_value (gh_manager::figure_handle_list (show_hidden)); } DEFUN (__go_execute_callback__, args, , @@ -8817,7 +8842,7 @@ if (args.length () == 0 || args.length () == 1) { - Matrix hlist = gh_manager::figure_handle_list (); + Matrix hlist = gh_manager::figure_handle_list (true); for (int i = 0; ! error_state && i < hlist.length (); i++) {
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -3528,10 +3528,10 @@ radio_property zlimmode al , "{auto}|manual" radio_property climmode al , "{auto}|manual" radio_property alimmode , "{auto}|manual" - handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false) - handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false) - handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false) - handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false) + handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) + handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) + handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) + handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) bool_property xgrid , "off" bool_property ygrid , "off" bool_property zgrid , "off" @@ -5176,12 +5176,15 @@ static graphics_handle make_graphics_handle (const std::string& go_name, - const graphics_handle& parent, bool do_createfcn = true, + const graphics_handle& parent, + bool integer_figure_handle = false, + bool do_createfcn = true, bool do_notify_toolkit = true) { return instance_ok () - ? instance->do_make_graphics_handle (go_name, parent, do_createfcn, - do_notify_toolkit) + ? instance->do_make_graphics_handle (go_name, parent, + integer_figure_handle, + do_createfcn, do_notify_toolkit) : graphics_handle (); } @@ -5211,9 +5214,10 @@ ? instance->do_current_figure () : graphics_handle (); } - static Matrix handle_list (void) + static Matrix handle_list (bool show_hidden = false) { - return instance_ok () ? instance->do_handle_list () : Matrix (); + return instance_ok () + ? instance->do_handle_list (show_hidden) : Matrix (); } static void lock (void) @@ -5236,9 +5240,10 @@ instance->do_unlock (); } - static Matrix figure_handle_list (void) + static Matrix figure_handle_list (bool show_hidden = false) { - return instance_ok () ? instance->do_figure_handle_list () : Matrix (); + return instance_ok () + ? instance->do_figure_handle_list (show_hidden) : Matrix (); } static void execute_listener (const graphics_handle& h, @@ -5381,7 +5386,7 @@ // A flag telling whether event processing must be constantly on. int event_processing; - graphics_handle get_handle (const std::string& go_name); + graphics_handle get_handle (bool integer_figure_handle); void do_free (const graphics_handle& h); @@ -5400,34 +5405,48 @@ } graphics_handle do_make_graphics_handle (const std::string& go_name, - const graphics_handle& p, bool do_createfcn, + const graphics_handle& p, + bool integer_figure_handle, + bool do_createfcn, bool do_notify_toolkit); graphics_handle do_make_figure_handle (double val, bool do_notify_toolkit); - Matrix do_handle_list (void) + Matrix do_handle_list (bool show_hidden) { Matrix retval (1, handle_map.size ()); + octave_idx_type i = 0; for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) { graphics_handle h = p->first; - retval(i++) = h.value (); + + if (show_hidden || is_handle_visible (h)) + retval(i++) = h.value (); } + + retval.resize (1, i); + return retval; } - Matrix do_figure_handle_list (void) + Matrix do_figure_handle_list (bool show_hidden) { Matrix retval (1, figure_list.size ()); + octave_idx_type i = 0; for (const_figure_list_iterator p = figure_list.begin (); p != figure_list.end (); p++) { graphics_handle h = *p; - retval(i++) = h.value (); + + if (show_hidden || is_handle_visible (h)) + retval(i++) = h.value (); } + + retval.resize (1, i); + return retval; } @@ -5437,7 +5456,19 @@ graphics_handle do_current_figure (void) const { - return figure_list.empty () ? graphics_handle () : figure_list.front (); + graphics_handle retval; + + for (const_figure_list_iterator p = figure_list.begin (); + p != figure_list.end (); + p++) + { + graphics_handle h = *p; + + if (is_handle_visible (h)) + retval = h; + } + + return retval; } void do_lock (void) { graphics_lock.lock (); }