Viewer3d fullscreen position command not working?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lars Nelson
el 9 de Mayo de 2023
Comentada: Lars Nelson
el 11 de Mayo de 2023
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?
2 comentarios
Respuesta aceptada
Simon Chan
el 11 de Mayo de 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].
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1380074/image.jpeg)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1380079/image.jpeg)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1380084/image.jpeg)
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop uifigure-Based Apps 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!