Update cursor after disabling rotate3d
4 views (last 30 days)
Show older comments
Im am facing a small, but annoying issue using App Designer. I have an UIaxes with some plotted data. Since i was not happy with the default toolbar, i reengineered the functionalities i needed (datatips, rotate3d and home view) and assigned them to buttons respectively state buttons. When i click the button to enable rotation (using rotate3d(ax,'on') in the buttons callback function) the functionality is correctly enabled. When i wait some seconnds an then move the mouse cursor onto the plot area, it switches to the rotate symbol as it should. But when i move the mouse cursor quickly onto the plot area after activating the button and let it sit there, it stays an arrow and just changes to the rotate symbol when moved again. Same happens when disabling. When disabling by button, waiting and then hovering to the plot area it works fine and the cursor is displayed as arrow. When moved quickly, it stays the rotatesymbol.
Is there any way to programmatically force the cursor to update after usingrotate3d(ax,'on' / 'off')? I tried many combinations of drawnow, figure(), axes(), ().Pointer = 'arrow' and so on but everything gets ignored when entering or leaving the rotate3d modus.
Regards,
Matthias
3 Comments
Adam Danz
on 10 Oct 2024
It's difficult to troubleshoot without seeing the behavior and seeing any customizations done to interactions. I recommend contacting tech support and include instructions how to reproduce the problem
Answers (2)
Rahul
on 14 Oct 2024
I understand that while trying to build an App Designer app you require to plot something on an axis and then enable rotation of the axis using 'rotate3d' function as well as disable it when rotation is not required. As per my understanding from your description, when you are trying to set the rotation, then there is some discrepancy about when the rotation symbol is displayed and when the cursor is displayed symbolizing 'rotation' property being 'on' or 'off'.
I have tried to create a simple App Designer app where using an axis I am plotting a 3d parabolic using the 'surf' function which is added to the callback function of a Push Button called 'PlotButton' like this:
function PlotButtonPushed(app, event)
[X, Y] = meshgrid(-5:0.5:5, -5:0.5:5);
Z = X.^2 + Y.^2;
surf(app.UIAxes, X, Y, Z);
disableDefaultInteractivity(app.UIAxes);
% Here the 'disableDefaultInteractivity' function disables any default interactivity set to the axis.
app.RotateButton.Enable = "on";
% This is to enable another State Button 'RotateButton' to enable and disable rotation of the axis.
% The 'Enable' property of the 'RotateButton' is initially set to 'off'
end
Now, when I click the 'RotateButton', I have linked it with a callback function 'RotateButtonValueChanged'. This callback function looks like:
function RotateButtonValueChanged(app, event)
value = app.RotateButton.Value;
if(value == 1)
rotate3d(app.UIAxes, 'on');
else
rotate3d(app.UIAxes, 'off');
end
end
- When the 'RotateButton' is in the pressed state, the rotation of the axis gets enabled properly with only the 'rotate' cursor symbol being shown while hovering the plot/axis.
- When the 'RotateButton' is NOT in the pressed state, the rotation of the axis gets disabled properly with only the normal cursor symbol being shown while hovering the plot/axis.
- An interesting observation is that, the axis also offers a UI feature to set the rotation directly like this:
- Whenever this icon is in pressed state, the 'rotation' property of the axis is enabled and when it is not in pressed state, it is disabled. So this is another way of adjusting rotation of the axis. It works in a similar fashion as the 'rotate3d' function linked to the callback of 'RotateButton'.
I am attaching a video GIF as well as the '.mlapp' file for your reference.
You can refer to the following MathWorks documentations to know more:
'disableDefaultInteractivity': https://www.mathworks.com/help/releases/R2024a/matlab/ref/disabledefaultinteractivity.html
'rotate3d': https://www.mathworks.com/help/releases/R2024a/matlab/ref/matlab.graphics.interaction.internal.rotate3d.html
Hope this helps! Thanks.
0 Comments
See Also
Categories
Find more on Plot Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!