Clear Filters
Clear Filters

access impoint in one axis while in rotate3d mode for another axis in the same figure

1 view (last 30 days)
Here's a simplified version of my problem:
Suppose I have one figure with two axes:
f = figure;
s1 = subplot(2,1,1,'Parent',f);
s2 = subplot(2,1,2,'Parent',f);
I want to plot a three-dimensional surface in the first axis, and I want to place an impoint object in the second axis:
[X,Y,Z] = peaks(25);
sf = surf(s1,X,Y,Z);
p = impoint(s2,0.5,0.5);
Now I want the axis s1 to be in rotate3d mode so I can view the surface from any angle:
rotate3d(s1);
But I'd like to be able to drag the impoint in s2 without needing to turn off the rotate3d mode. Unfortunately, rotate3d mode appears to disable the impoint.
For user-defined figure-wide callbacks, it looks like going into rotate3d mode makes those callbacks inaccessible, but there is a work-around for that.
Is there a similar work-around to allow me to drag the impoint in s2 without turning off the rotate3d mode?
Thanks!
Steven

Accepted Answer

Steven Lulich
Steven Lulich on 14 Jun 2016
I figured it out! My solution makes use of the ButtonDownFilter property of the figure's mode object which is returned when entering the rotate3d mode. Here is the code:
f = figure;
s1 = subplot(2,1,1,'Parent',f);
s2 = subplot(2,1,2,'Parent',f);
[X,Y,Z] = peaks(25);
sf = surf(s1,X,Y,Z);
p = impoint(s2,0.5,0.5);
h = rotate3d(s1);
h.ButtonDownFilter = @turnOffRotate3d;
h.Enable = 'on';
s1.ButtonDownFcn = 'rotate3d(gca);'
The function turnOffRotate3d.m is defined as follows:
function [flag] = turnOffRotate3d(obj,event_obj)
% If the tag of the object is 'impoint', then return true
objTag = obj.Tag;
if strcmpi(objTag,'impoint')
flag = true;
else
flag = false;
end;
With this solution, clicking on the s1 axis turns on rotate3d mode, while clicking on the impoint turns rotate3d mode off.
This solution is basically a version of the documentation Example 4 from help rotate3d;

More Answers (0)

Categories

Find more on Visual Exploration 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!