Clear Filters
Clear Filters

Viewer3d fullscreen position command not working?

3 views (last 30 days)
I am loading volumetric data in viewer3d using volshow and I cannot get the viewer3d to appear fullscreen without having to click the maximize button myself.
I have tried the following:
viewer = viewer3d; % Create viewer %
res = get(0, 'ScreenSize'); % Obtain screen resolution %
viewer.Position = [0 0 res(3) res(4)]; % Set viewer position to fullscreen %
And the following:
viewer = viewer3d; % Create viewer %
viewer.Units = 'normalized'; % Set dimensional units to [0 1] scale %
viewer.Position = [0 0 1 1]; % Set viewer position to fullscreen %
Both of these, whether I have loaded a volume using volshow or not, do not enlarge the viewer size to fullscreen. If I use either of these commands and then enter:
viewer.Position % Retrieve viewer position %
it will return the position that I specified rather than the default, so it is saving the values I enter and just not appearing fullscreen. If I maximize the viewer myself and then enter the above line of code, it returns the expected dimensions of [0 0 1920 1080]. But, if I enter those manually myself when it is not yet fullscreen, it does not become fullscreen.
Am I just missing something completely or does this functionality not work at all? If it doesn't work, does anyone know of a different way to make the viewer3d appear fullscreen from the start?
Simon Chan
Simon Chan on 10 May 2023
Edited: Simon Chan on 10 May 2023
Most probably it takes a longer time to start the viewer3d. You may try to use drawnow or pause before setting the position of the viewer.
Lars Nelson
Lars Nelson on 10 May 2023
Even when the viewer has been open for some time the command just doesn't do anything.

Sign in to comment.

Accepted Answer

Simon Chan
Simon Chan on 11 May 2023
Sorry that I was only guessed last night and recently tested on my laptop.
The viewer3d object is act as a Children on a figure object. By using the following code, the viewer3d Position does change to its correct position but its Parent, which is the figure object, does not. Hence, you got s smaller viewer since the uifigure is still remains in its default value
uif = uifigure; % Create a uifigure,
% Default uif.Position = [403 146 560 420] on my laptop
viewer = viewer3d(uif); % Create Viewer3d on the uifigure
viewer.Position = [5 5 1300 670]; % Change to a larger screen position, just arbitrary
The Position of the uifigure is still the default smaller one, [403 146 560 420], whereas the viewer Position is following the code which becomes [5 5 1300 670].
Since the constraint is on the uifigure Position, I can think of 2 methods to overcome this issue:
Method 1: Simply change to a larger uif.Position:
uif = uifigure;
viewer = viewer3d(uif);
uif.WindowState = 'Maximized'; % Maximize the uifigure which automatically increase the size of viewer3d
The results shows that both uifigure and viewer3d Positions are larger and actually it covers my entire laptop screen.
The code with a pause is due to the fact that it takes some time to update the properties of both uifigure and viewer3d.
Method 2: Adjust viewer3d Position first and force its parent position to follow.
uif = uifigure;
viewer = viewer3d(uif);
viewer.Position = [5 5 1300 670]; % Adjust position for viewer3d first
viewer.Parent.Position=viewer.Position; % Force its parent uifigure object to follow the same position
The results shows that both uifigure and viewer3d Positions are larger and have the same effect as Method 1
In this case, the properties of both uifigure and viewer3d updates instantaneously and there is no need to add a pause on the code.

More Answers (0)


Find more on Develop uifigure-Based Apps 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!