Programmatic UI Toolbar Issues/Questions: rotate3d does not refresh until un-clicked + others

2 Ansichten (letzte 30 Tage)
I am including my MWE below (requires GUI layout toolbox). I have a programmatic UI that will do a scatter3 plot in one section. I have included the figure toolbar so that I might be able to zoom and rotate the scatter plot. This lead to several questions, of which I have found only partial answers in the documentation/forums. I am asking them all here since the same MWE should function for all questions.
1) When I use the rotate3d tool from the menu bar, and then rotate my plot, the plot disappears and does not refresh. It will reappear once I have deselected the rotate3d uitoggle. Why? How can I avoid this? It really ruins the usefulness of rotating my scatter plot. Note that this still happens when accessing rotate3d programmatically: e.g. rotate3d(gui.ViewAxes), so building my own custom toolbar will not fix this.
Now, the plot also disappears when I hit the colorbar button, and reappears when deselected. Which leads to the next two questions:
(2) I want to eliminate a bunch of the buttons from the toolbar but keep zoom, pan, and rotate3d. This is simple in GUIDE, but I wish to do it programmatically. Is the only way really to either A) build an entire custom toolbar or B) go through the whole findall/delete procedure for every unwanted button?
(3) The toolbar really should be attached to the plot axes, not the full figure. I know I have read some Jan Simon responses that this is not possible, though there are some FEX workarounds. However, I may wind up with multiple axes on the same UI which I want to save as e.g. .png files independently. The save pushbutton currently saves the entire figure. I would nominally want a save button for each individual axes. I do not like the idea of opening a new figure for every single axes if the controls and both axes are closely related.
Please, no responses suggesting I go back to GUIDE.
Thanks!
MWE below.
function gui = guiTest
gui = struct();
% Initialize Window
scrsz = get(groot,'ScreenSize');
gui.Window = figure( ...
'Name', 'A Test Window', ...
'NumberTitle', 'off', ...
'MenuBar', 'none', ...
'Toolbar', 'Figure', ...
'HandleVisibility', 'off',...
'OuterPosition', [3*scrsz(4)/4 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2]);
% Create Main Layout
mainLayout = uiextras.HBoxFlex(...
'Parent',gui.Window,...
'Spacing',3);
% Left Side Control Panel
controlPanel = uiextras.BoxPanel(...
'Parent',mainLayout,...
'Title','Controls go here');
% Right Side Plotting
gui.ViewPanel = uiextras.BoxPanel(...
'Parent', mainLayout,...
'Title','Axes Panel Name');
% Relative sizes of main layout sections
set(mainLayout, 'Sizes', [-1 -2]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Right Side Plotting %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gui.ViewAxes = axes(...
'Parent',gui.ViewPanel);
X = rand(100,1); Y = rand(100,1); Z = rand(100,1);
scatter3(X,Y,Z,'Parent',gui.ViewAxes); axis(gui.ViewAxes, 'equal');
end
  1 Kommentar
D. Plotnick
D. Plotnick am 30 Mär. 2016
Note, Robert helpfully reminded me to switch my 'HandleVisibility' back to 'on' regarding some other issues I had been having with this MWE. That does not solve the rotate3d issue.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

D. Plotnick
D. Plotnick am 31 Mär. 2016
Bearbeitet: D. Plotnick am 31 Mär. 2016
Ok, so I have a kludged together solution that I am going with for now. If anyone else has a better idea, please let me know.
The issue is the azimuth/elevation numeric readout. In a vanilla Matlab figure it displays as a tiny bar in the bottom left hand corner of the plot, and only while the mouse is depressed. It creates the Az/El indicator using a uicontrol, which the GUI Layout Toolbox interprets as I should have expected. Using BoxPanel as I did above, rotate3d superposes the numeric readout on top of the actual scatterplot.
This can be solved by saving a custom rotate3d tool that simply comments out line 456 of the original; 'localCreateAzElIndicator'. I may modify it further in future so that it appears parented to the axes, not to the figure, but this method works fine for now.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by