comparison 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
comparison
equal deleted inserted replaced
19902:c7c50030e76c 19903:781adfc2958c
25 ## Author: Kai Habel 25 ## Author: Kai Habel
26 26
27 function __add_default_menu__ (fig) 27 function __add_default_menu__ (fig)
28 28
29 ## Only FLTK toolkit currently provides menubar 29 ## Only FLTK toolkit currently provides menubar
30 if (! strcmp (get (fig, "__graphics_toolkit__"), "fltk")) 30 tk = get (fig, "__graphics_toolkit__");
31 if (! any (strcmp (tk, {"fltk", "qt"})))
31 return; 32 return;
32 endif 33 endif
33 34
34 obj = findall (fig, "-depth", 1, "tag", "__default_menu__", "label", "&File"); 35 obj = findall (fig, "-depth", 1, "tag", "__default_menu__", "label", "&File");
35 if (isempty (obj)) 36 if (isempty (obj))
43 "tag", "__default_menu__"); 44 "tag", "__default_menu__");
44 uimenu (__e, "label", "Toggle &grid on all axes", "tag", "toggle", "callback", @grid_cb); 45 uimenu (__e, "label", "Toggle &grid on all axes", "tag", "toggle", "callback", @grid_cb);
45 uimenu (__e, "label", "Show grid on all axes", "tag", "on", "callback", @grid_cb); 46 uimenu (__e, "label", "Show grid on all axes", "tag", "on", "callback", @grid_cb);
46 uimenu (__e, "label", "Hide grid on all axes", "tag", "off", "callback", @grid_cb); 47 uimenu (__e, "label", "Hide grid on all axes", "tag", "off", "callback", @grid_cb);
47 uimenu (__e, "label", "Auto&scale all axes", "callback", @autoscale_cb); 48 uimenu (__e, "label", "Auto&scale all axes", "callback", @autoscale_cb);
49
48 gm = uimenu (__e, "label", "GUI &Mode (on all axes)"); 50 gm = uimenu (__e, "label", "GUI &Mode (on all axes)");
49 uimenu (gm, "label", "Pan x and y", "tag", "pan_on", "callback", @guimode_cb); 51 uimenu (gm, "label", "Pan x and y", "tag", "pan_on", "callback", @guimode_cb);
50 uimenu (gm, "label", "Pan x only", "tag", "pan_xon", "callback", @guimode_cb); 52 uimenu (gm, "label", "Pan x only", "tag", "pan_xon", "callback", @guimode_cb);
51 uimenu (gm, "label", "Pan y only", "tag", "pan_yon", "callback", @guimode_cb); 53 uimenu (gm, "label", "Pan y only", "tag", "pan_yon", "callback", @guimode_cb);
52 uimenu (gm, "label", "Disable pan and rotate", "tag", "no_pan_rotate", "callback", @guimode_cb); 54 uimenu (gm, "label", "Disable pan and rotate", "tag", "no_pan_rotate", "callback", @guimode_cb);
83 set (gcbf, "filename", fname) 85 set (gcbf, "filename", fname)
84 saveas (caller, fname); 86 saveas (caller, fname);
85 endif 87 endif
86 endfunction 88 endfunction
87 89
88 90 function [hax, fig] = __get_axes__ (h)
89 function hax = __get_axes__ (h)
90 ## Get parent figure 91 ## Get parent figure
91 fig = ancestor (h, "figure"); 92 fig = ancestor (h, "figure");
92 93
93 ## Find all axes which aren't legends 94 ## Find all axes which aren't legends
94 hax = findobj (fig, "type", "axes", "-not", "tag", "legend"); 95 hax = findobj (fig, "type", "axes", "-not", "tag", "legend");
111 arrayfun (@(h) axis (h, "auto"), hax) 112 arrayfun (@(h) axis (h, "auto"), hax)
112 drawnow (); 113 drawnow ();
113 endfunction 114 endfunction
114 115
115 function guimode_cb (h, e) 116 function guimode_cb (h, e)
116 hax = __get_axes__ (h); 117 [hax, fig] = __get_axes__ (h);
117 id = get (h, "tag"); 118 id = get (h, "tag");
118 switch (id) 119 switch (id)
119 case "pan_on" 120 case "pan_on"
120 arrayfun (@(h) pan (h, "on"), hax) 121 arrayfun (@(h) pan (fig, "on"), hax)
121 case "pan_xon" 122 case "pan_xon"
122 arrayfun (@(h) pan (h, "xon"), hax) 123 arrayfun (@(h) pan (fig, "xon"), hax)
123 case "pan_yon" 124 case "pan_yon"
124 arrayfun (@(h) pan (h, "yon"), hax) 125 arrayfun (@(h) pan (fig, "yon"), hax)
125 case "rotate3d" 126 case "rotate3d"
126 arrayfun (@(h) rotate3d (h, "on"), hax) 127 arrayfun (@(h) rotate3d (fig, "on"), hax)
127 case "no_pan_rotate" 128 case "no_pan_rotate"
128 arrayfun (@(h) pan (h, "off"), hax) 129 arrayfun (@(h) pan (fig, "off"), hax)
129 arrayfun (@(h) rotate3d (h, "off"), hax) 130 arrayfun (@(h) rotate3d (fig, "off"), hax)
130 case "zoom_on" 131 case "zoom_on"
131 arrayfun (@(h) set (h, "mouse_wheel_zoom", 0.05), hax); 132 arrayfun (@(tax) set (tax, "mousewheelzoom", 0.05), hax);
132 case "zoom_off" 133 case "zoom_off"
133 arrayfun (@(h) set (h, "mouse_wheel_zoom", 0.0), hax); 134 arrayfun (@(tax) set (tax, "mousewheelzoom", 0.0), hax);
134 endswitch 135 endswitch
135 endfunction 136 endfunction