diff scripts/plot/util/private/__add_default_menu__.m @ 19903:781adfc2958c draft nkf

Build qt graphics toolkit menus with uimenu * libgui/graphics/Figure.cc, libgui/graphics/Figure.h: Revert cset 7335cc071ab0 and remove all menu items. * scripts/gui/private/__get_funcname__.m: Fix typo * scripts/plot/util/private/__add_default_menu__.m: Enable uimenu for qt graphics toolkit and fix setting pan/rotate/zoom for qt and fltk
author Stefan Mahr <dac922@gmx.de>
date Fri, 27 Feb 2015 18:36:05 +0100
parents 55a4173f1624
children
line wrap: on
line diff
--- a/scripts/plot/util/private/__add_default_menu__.m	Fri Feb 27 09:44:58 2015 -0500
+++ b/scripts/plot/util/private/__add_default_menu__.m	Fri Feb 27 18:36:05 2015 +0100
@@ -27,7 +27,8 @@
 function __add_default_menu__ (fig)
 
   ## Only FLTK toolkit currently provides menubar
-  if (! strcmp (get (fig, "__graphics_toolkit__"), "fltk"))
+  tk = get (fig, "__graphics_toolkit__");
+  if (! any (strcmp (tk, {"fltk", "qt"})))
     return;
   endif
 
@@ -45,6 +46,7 @@
       uimenu (__e, "label", "Show grid on all axes", "tag", "on", "callback", @grid_cb);
       uimenu (__e, "label", "Hide grid on all axes", "tag", "off", "callback", @grid_cb);
       uimenu (__e, "label", "Auto&scale all axes", "callback", @autoscale_cb);
+
       gm = uimenu (__e, "label", "GUI &Mode (on all axes)");
         uimenu (gm, "label", "Pan x and y", "tag", "pan_on", "callback", @guimode_cb);
         uimenu (gm, "label", "Pan x only", "tag", "pan_xon", "callback", @guimode_cb);
@@ -85,8 +87,7 @@
   endif
 endfunction
 
-
-function hax = __get_axes__ (h)
+function [hax, fig] = __get_axes__ (h)
   ## Get parent figure
   fig = ancestor (h, "figure");
 
@@ -113,23 +114,23 @@
 endfunction
 
 function guimode_cb (h, e)
-  hax = __get_axes__ (h);
+  [hax, fig] = __get_axes__ (h);
   id = get (h, "tag");
   switch (id)
     case "pan_on"
-      arrayfun (@(h) pan (h, "on"), hax)
+      arrayfun (@(h) pan (fig, "on"), hax)
     case "pan_xon"
-      arrayfun (@(h) pan (h, "xon"), hax)
+      arrayfun (@(h) pan (fig, "xon"), hax)
     case "pan_yon"
-      arrayfun (@(h) pan (h, "yon"), hax)
+      arrayfun (@(h) pan (fig, "yon"), hax)
     case "rotate3d"
-      arrayfun (@(h) rotate3d (h, "on"), hax)
+      arrayfun (@(h) rotate3d (fig, "on"), hax)
     case "no_pan_rotate"
-      arrayfun (@(h) pan (h, "off"), hax)
-      arrayfun (@(h) rotate3d (h, "off"), hax)
+      arrayfun (@(h) pan (fig, "off"), hax)
+      arrayfun (@(h) rotate3d (fig, "off"), hax)
     case "zoom_on"
-      arrayfun (@(h) set (h, "mouse_wheel_zoom", 0.05), hax);
+      arrayfun (@(tax) set (tax, "mousewheelzoom", 0.05), hax);
     case "zoom_off"
-      arrayfun (@(h) set (h, "mouse_wheel_zoom", 0.0), hax);
+      arrayfun (@(tax) set (tax, "mousewheelzoom", 0.0), hax);
   endswitch
 endfunction