changeset 25802:b785394f10d0

shg.m: Don't create a figure if none exists. * shg.m: Redo docstring. Use the "currentfigure" of the root object, rather than gcf, to get the current figure so as not to create one if one does not exist. Change the "visible" attribute of the figure to "on" unconditionally. * figure.m: Add shg to list of @seealso links in docstring. Use figure handle 'f' rather than gcf when calling __show_figure__ since it is already known.
author Rik <rik@octave.org>
date Wed, 15 Aug 2018 14:13:28 -0700
parents 95eb72d50fb0
children 23483673ba43
files scripts/plot/util/figure.m scripts/plot/util/shg.m
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/figure.m	Wed Aug 15 13:21:37 2018 -0700
+++ b/scripts/plot/util/figure.m	Wed Aug 15 14:13:28 2018 -0700
@@ -39,7 +39,7 @@
 ##
 ## Programming Note: The full list of properties is documented at
 ## @ref{Figure Properties,,Figure Properties}.
-## @seealso{axes, gcf, clf, close}
+## @seealso{axes, gcf, shg, clf, close}
 ## @end deftypefn
 
 ## Author: jwe, Bill Denney
@@ -109,7 +109,7 @@
   if (! init_new_figure && ! any (strcmpi (varargin(1:2:end), "visible")
                                   && strcmpi (varargin(2:2:end), "off")))
     set (f, "visible", "on");
-    __show_figure__ (gcf ());
+    __show_figure__ (f);
   endif
 
   if (nargout > 0)
--- a/scripts/plot/util/shg.m	Wed Aug 15 13:21:37 2018 -0700
+++ b/scripts/plot/util/shg.m	Wed Aug 15 14:13:28 2018 -0700
@@ -20,8 +20,12 @@
 ## @deftypefn {} {} shg
 ## Show the graph window.
 ##
-## Currently, this is the same as executing @code{drawnow}.
-## @seealso{drawnow, figure}
+## This function makes the current figure visible, and places it on top of
+## of all other plot windows.
+##
+## Programming Note: @code{shg} is equivalent to @code{figure (gcf)} assuming
+## that a current figure exists.
+## @seealso{figure, drawnow, gcf}
 ## @end deftypefn
 
 ## Author: jwe
@@ -32,6 +36,10 @@
     warning ("shg: ignoring extra arguments");
   endif
 
-  __show_figure__ (gcf ());
+  hf = get (0, "currentfigure");
+  if (! isempty (hf))
+    set (hf, "visible", "on");
+    __show_figure__ (hf));
+  endif
 
 endfunction