Double clicking on axes

I am designing a GUI that requires toggles for axes equal, grid on/off, etc. These toggles work perfectly until the user double clicks on the axes, then they are overridden. Almost every other built-in function like this has some documentation available on how to control it, but I cannot find any documentation on this function.
If anybody could point me to a resource or tell me how to get into this function, it would be greatly appreciated! I do not necessarily want to stop the function, but rather control it to turn the toggles on/off or even read the status of the toggles and keep them consistent.
Any help is greatly appreciated! ~Josh

1 Comment

i need a code for signal value selection when i click on signal it give me selection part of signal in axes gui

Sign in to comment.

Answers (4)

Walter Roberson
Walter Roberson on 10 May 2011

0 votes

How do you control which axes are affected by the toggles?

1 Comment

Josh
Josh on 10 May 2011
The GUI is a single set of axes that the user selects which data to plot on x, y and z axes, then can change the axis mode (equal, tight, etc), grid on/off, etc. Since there is just one set of axes, it is easy to modify these properties. The problem is the double click function overrides them, and the users are getting annoyed to have to uncheck then recheck the toggles each time.

Sign in to comment.

Matt Fig
Matt Fig on 10 May 2011
It works fine here. How are you doing things differently than this? I can double-click all I want on the axes and the toggles still work...
function [] = GUI_axes()
% Problem with double-clicking on axes de-activating toggle callbacks?
S.fh = figure('units','pixels',...
'position',[200 200 200 200],...
'menubar','none',...
'numbertitle','off',...
'name','GUI_axes',...
'resize','off');
S.ax = axes('units','pixels',...
'position',[30 70 160 120],...
'fontsize',8,...
'nextplot','replacechildren');
S.tb = uicontrol('style','toggle',...
'units','pixels',...
'position',[10 10 80 20],...
'call',{@tb_cb,S},...
'string','Square');
S.tb(2) = uicontrol('style','toggle',...
'units','pixels',...
'position',[100 10 80 20],...
'call',{@tb_cb,S},...
'string','Grid');
function [] = tb_cb(varargin)
% Callback for toggles.
if isequal(varargin{1},S.tb(1))
if get(S.tb(1),'value')
axis(S.ax,'square')
else
axis(S.ax,'normal')
end
else
if get(S.tb(2),'value')
grid(S.ax,'on')
else
grid(S.ax,'off')
end
end
end
end

9 Comments

Josh
Josh on 10 May 2011
I need the toolbars to be enabled so the user can pan, zoom, rotate, and use the data cursor. I modified your code to allow this and broke it. The grid toggle stays on, but the axes square does not.
Thanks for your help! Keep suggesting ideas please!
function [] = GUI_axes()
% Problem with double-clicking on axes de-activating toggle callbacks?
S.fh = figure('units','pixels',...
'position',[200 200 200 200],...
'menubar','figure',...
'toolbar','figure',...
'numbertitle','off',...
'name','GUI_axes',...
'resize','on');
S.ax = axes('units','pixels',...
'position',[30 70 160 120],...
'fontsize',8,...
'nextplot','replacechildren');
S.tb = uicontrol('style','toggle',...
'units','pixels',...
'position',[10 10 80 20],...
'call',{@tb_cb,S},...
'string','Square');
S.tb(2) = uicontrol('style','toggle',...
'units','pixels',...
'position',[100 10 80 20],...
'call',{@tb_cb,S},...
'string','Grid');
function [] = tb_cb(varargin)
% Callback for toggles.
if isequal(varargin{1},S.tb(1))
if get(S.tb(1),'value')
axis(S.ax,'square')
else
axis(S.ax,'normal')
end
else
if get(S.tb(2),'value')
grid(S.ax,'on')
else
grid(S.ax,'off')
end
end
end
end
Matt Fig
Matt Fig on 10 May 2011
Still works here. Just so when we are clear, is this the problem you are seeing?
1. Call GUI_axes (your modified version)
2. Toggle the Square button.
3. Double-click in the axes
4. Now toggling the Square button has no effect.
If that is not it, please write it out like that so that we can follow along. Also, what version are you using?
Josh
Josh on 10 May 2011
Not quite. The problem goes like this:
1. Call GUI_axes
2. Rotate the axes to a 3D view (can also do view(3))
3. Apply the Square button
4. Double-click on the axes
5. Now the axes are back to how they originally were (perhaps with grid on now) independent of what the Square button says
6. To get the Square button to work again, I click it twice (uncheck then check)
The problem isn't that the button *stop* working, its that their current state is not applied after double clicking (except for grid and hold on/off).
Does this help?
Josh
Josh on 10 May 2011
Edit that...
If you click the square button before you rotate, it will work properly. If you
1. rotate
2. grid on
3. square on
4. double click
then the axes return to a 2D view with axes equal, not square. It is an order of operations thing I guess, I didn't realize this before. Now it makes me even more curious to know when the state is captured for the double-click function...
Josh
Josh on 10 May 2011
Yes, I believe the figure captures the current [Az,El] as well as the axis scaling when specific things occur, such as a resizing of the window, interactive pan/zoom/rotate, etc. Then when the user double-clicks, it refreshes these properties to the stored values.
When I start in view(3) mode, the double-click returns the axes to a 3D view. If I turn Square on before I rotate or resize the window, it returns to the square scaling. So now that I know this, is there a way to apply the toggles to the stored states? i.e. when you resize the window, for example, the current states are stored somewhere, can we then access and modify these captured states?
Matt Fig
Matt Fig on 10 May 2011
It looks like this stuff is used in the rotaButtonDownFcn function within rotate3d.m. You might be able to access the data by using the handle returned from calling ROATATE3D, though you still have the problem of figuring out how to know the user has pressed the button....
To get this to work smoothly, you would probably need to use techniques similar to what I used for zoom mode when I wanted my own keyboard input; see
http://www.mathworks.com/matlabcentral/newsreader/view_thread/141886
Josh
Josh on 11 May 2011
This is getting me a little bit closer... now I know how to see the listeners that turn on when pan/zoom/rotate are on. Here is what I get when I make a simple plot of 50 random points:
>> Figure_Data = uigetmodemanager(fig);
>> Figure_Data.get
CurrentMode: [1x1 uitools.uimode]
Blocking: 0
>> Figure_Data.CurrentMode.get
WindowButtonDownFcn: {2x1 cell}
WindowButtonUpFcn: []
WindowButtonMotionFcn: {2x1 cell}
WindowKeyPressFcn: []
WindowKeyReleaseFcn: []
WindowScrollWheelFcn: {2x1 cell}
KeyReleaseFcn: []
WindowButtonMotionFcnInterrupt: 0
UIControlInterrupt: 0
KeyPressFcn: {2x1 cell}
ModeStartFcn: {2x1 cell}
ModeStopFcn: {2x1 cell}
ShowContextMenu: 1
Name: 'Exploration.Zoom'
IsOneShot: 0
UseContextMenu: 'on'
FigureHandle: [1x1 figure]
ButtonDownFilter: []
UIContextMenu: []
ModeStateData: [1x1 struct]
>> Figure_Data.CurrentMode.WindowButtonDownFcn
ans =
[function_handle]
[1x1 uitools.uimode]
>> Figure_Data.CurrentMode.WindowButtonMotionFcn
ans =
@localMotionFcn
[1x1 uitools.uimode]
>> Figure_Data.CurrentMode.WindowScrollWheelFcn
ans =
@localButtonWheelFcn
[1x1 uitools.uimode]
>> Figure_Data.CurrentMode.KeyPressFcn
ans =
@localKeyPressFcn
[1x1 uitools.uimode]
>> Figure_Data.CurrentMode.ModeStartFcn
ans =
@localStartZoom
[1x1 uitools.uimode]
>> Figure_Data.CurrentMode.ModeStopFcn
ans =
@localStopZoom
[1x1 uitools.uimode]
>> Figure_Data.CurrentMode.FigureHandle
ans =
figure
>> Figure_Data.CurrentMode.ModeStateData
ans =
Constraint: 'none'
Direction: 'out'
Target: []
MaxViewAngle: 75
LineHandles: []
CurrentAxes: 170.0083
MousePoint: []
CameraViewAngle: []
CustomContextMenu: []
DoRightClick: 'off'
target: [1x1 figure]
I went into all of the options to show what they had one level down. Beyond this first level we are just chasing our tail, getting the exact same menus again and again.
So, anybody have an idea where to look for the double click function? I see the WindowButtonDownFcn, but this didn't have the double click inside.
Thanks for all your guys' suggestions!
Double click of the axes is perhaps being handled by the axes ButtonDownFcn .
Double-click does not have a special handler, not at the MATLAB level: the button down function checks SelectionType .
Question: could you perhaps simply turn HitTest off on the axes ??

Sign in to comment.

tasadduq  hussain
tasadduq hussain on 24 May 2015

0 votes

i need a code for axes gui... when i click on axes the signal that on axes, this show a part of selection where i click on signal
tasadduq  hussain
tasadduq hussain on 24 May 2015

0 votes

i need a code for axes mouse move over and selection of signals

Products

Asked:

on 10 May 2011

Commented:

on 24 May 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!