- when you click on the mouse, you are selecting pan mode. So you have to click again for the callback function in the pan to execute.
- Callbacks are disabled when settings like pan, zoom etc are enabled because they interfere with the callback functions of these modes. That is the reason you couldn't call the callback function more than once.
Change plot interaction mode on the fly
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Graham Rowe
el 18 de Dic. de 2020
Comentada: Prudhvi Peddagoni
el 4 de En. de 2021
I'm trying to change the behavior of the mouse pointer in a 3d axes. When you first open a figure it seems to do something similar to what I want, but not including pan.
What I would like to do:
- Left click and drag will pan
- middle click and drag will rotate
- scroll wheel will zoom in and out
- double click: enables datacursormode (this is a nice to have, but less important that the other stuff)
This is what I've tried to get this to work so far:
fig = figure();
set(fig, 'WindowButtonDownFcn', @interactModeCallback); % should handle the button presses
set(fig, 'WindowScrollWheelFcn', @interactModeCallback); % should handle scroll wheel
ground = 10000*membrane(1,40)-10000; % example plot
surf(linspace(-10000,10000,size(ground,1)),linspace(-10000,10000,size(ground,2)),ground);
function interactModeCallback(src, event)
click_type = get(src,'selectiontype');
even_type = event.EventName;
if strcmp('WindowMousePress', even_type) % Deal with all the click events
if strcmp('normal', click_type) % Left click will pan
disp('pan')
pan on;
elseif strcmp('extend', click_type) % middle click will rotate
disp('rotate3d')
rotate3d on;
elseif strcmp('open', click_type) % double click will select points
disp('datacursormode')
datacursormode on;
end
elseif strcmp('WindowScrollWheel', even_type) % Scrolling will zoom
disp('zoom')
zoom on;
end
end
There are 2 issues I'm running into:
- It takes two button clicks to actually move the plot. i.e. you must click > release > click > drag. I want click > drag
- My callback function is only called once. Once I have clicked I am locked into that mode. I have tried to fix this by adding a corresponding callback function to turn off the interaction mode on WindowButtonUpFnc but it doesn't change anything.
Any help is appreciated.
0 comentarios
Respuesta aceptada
Prudhvi Peddagoni
el 29 de Dic. de 2020
Hi,
Hope this helps.
2 comentarios
Prudhvi Peddagoni
el 4 de En. de 2021
Or you can just use the buttons showed in the image.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/477903/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/477903/image.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!