Can a Matlab GUI (created in Guide) appear in or in front of a Psychtoolbox window? - matlab

I'm using psychtoolbox 3 with Matlab 2019b on a Mac running OSX 10.12.
I'm presenting static image stimuli using psychtoolbox (PTB) and would like to have a floating audio player gui object that I created using guide to appear on the screen as well. Importantly, the audio player has its own functions (slider bar to fastFWD and rewind the audio and a play/pause button) and I need to preserve the button's functionality. Rather than attempting to recreate the the player and buttons etc. within PTB, is it possible to display the gui above the window's screen content?
I've seen other threads about displaying a figure within a PTB window, but this was for graph rather than a gui. I don't believe PTB retains the functionality of the buttons when displaying the figure. I've also considered making the window smaller than the full screen in order to display the figure on the side, but I'd prefer to remain full screen if at all possible.
So to summarize, is there a way for a figure window appear in front of the PTB window? Alternatively, can a PTB window appear within a figure window (i.e., within the axes of a gui created in guide?
Thank you!

Unfortunately I don't believe what you want - to have a full screen Psychtoolbox window as well as a MATLAB GUI .fig as an overlay - is possible. Even if the Psychtoolbox window is less than full screen, you can't give the MATLAB .fig focus and have it overlay the Psychtoolbox window, it will be placed underneath the Psychtoolbox window. You also won't be able to plot the Psychtoolbox window inside of a MATLAB GUI window. What I think your options are:
Make the Psychtoolbox window less than full screen, place the player GUI next to it.
Use a secondary monitor to host the MATLAB GUI, so the Psychtoolbox screen can be full size on the main monitor.

Related

Is there a way to hide window while game is starting in Bevy?

When running game in Bevy: At startup, I see a big window with white rectangle in it. After a few seconds my WindowDescriptor kicks in, and the window is resized to the dimensions that I want.
Is there a way to hide the window during the loading process, so I don't see the white rectangle? Or some other way to have my own loading screen?
I see this issue on the breakout example in Bevy. I am running in Windows10 OS.

MATLAB GUI is cropped when save

I have a problem with the size of MATLAB GUI, I'm using GUIDE to design a large GUI, therefore I changed the size to 1600*1200 by dragging the canvas, but when I save it, the size is automatically changed to around 1360*760, the objects are resized automatically but wrongly, some of them are cropped and some are moved out of the canvas, as shown in the picture. this is happening whether the the GUI is set as resizable or not.
This is how it looks before saving:
This is how it looks when clicking save:
I'm using the GUI with a 1080p monitor, is there a way to fix the size of the GUI to 1920*1080 and stop it from shrinking when save? if no, is there a way to make it resize properly when save?

GUI Layout Toolbox - Strange display with card panel object

Context
Using the GUI Layout toolbox I have created an interface which basically is divided in two parts:
A toolbar area where the user selects the way he want to see data
A preview area to display data upon selected mode in the toolbar
For the preview area I used a uietxras.CardPanel object to switch between the view modes.
Problem
After some investigations, I discovered that if I display things in 3D (or 2D) in one of the preview card using surf (or pcolor) then it alters the display in the second card. If I display data in 1D only using plot commands I have not issue!
The issue I have when using pcolor/surf in one of the preview card:
Titles and labels seem to overlay in Preview 1
Axis borders are not displayed correctly in preview 2
Legend borders (when displayed) are altered also
If I only use plot commands in both preview modes I have no issue at all and cards are switching nicely.
Test case
My real code is really long, I have thus reduced it to the minimum so you can reproduce the issue:
https://gist.github.com/CitizenInsane/54f3c1eba2293d0e5264#file-guilayoutbug-m
Simply run the code and check the checkbox "Do 3D plot in preview 1" to see the issue happening when switching between the two preview modes:
Notes
As far I know, I'm using latest version of the GUI Layout toolbox (1.17).
I'm using R2013b for Matlab
I came across this issue as well. I'm afraid I never quite worked out what the cause was exactly, and it didn't appear in a very consistent way. The issue seems to be that plots on non-selected cards are not hidden properly, and get overlaid just behind and around the edges of the plots on the selected card.
I would encourage you to raise the issue with the authors of GUI Layout Toolbox via the comments on the toolbox's page at MATLAB Central, as I do think it's a bug.
Nevertheless, the reason I never followed it up myself is that I found a fairly straightforward workaround, which may also work for you. Each time the selected card is changed, I ran a simple function that deleted all children of all cards, and then re-plotted whatever I wanted on the selected card. It seemed a bit annoying to have to do that, but it worked, and removed any of the display issues you've come across.
Ok got it, the issue has nothing to do with CardPanel themselves, it is linked to the renderer of the figure.
Trying simple code below:
figure(42);
subplot(1,2,1);
plot(rand(1,12));
subplot(1,2,2);
peaks;
shading flat;
If the figure's renderer is set to 'OpenGL' (the default) ==> there are some glitches:
If the figure's renderer is set to 'zbuffer' ==> there is no glitch:
Setting the renderer to 'zbuffer' fixes the problem.
NB: Maybe OpenGL rendering can be fixed by fine tuning graphic card acceleration settings, but I don't know ... I issued opengl software and opengl hardware commands in Matlab and software rendering is worst than hardware rendering on my machine.
EDIT: Side notes
Transparency effects are only available if the renderer is set to 'openGL'. It is thus not possible to visualize at the same time both 1D and transparent-3D data without glitches (at least with hg version 1 in R2013b).
HG2 has no issue:

Matlab GUI: how to add docked figure group?

I would like to be able to add a figure container to a matlab gui...
In core matlab, with a docked window style you can have a large number of plots stacked one behind the other, all within a figure container with a tabbed list along the side of the container that you can simply click to bring a particular figure to the front.
Is there a way to have this sort of figure container in a matlab gui?
Use Ben Tordoff's GUI Layout Toolbox. It contains functionality for tabbed panels and dockable/undockable panels that can contain figures, and many other capabilities that you'll find very useful if you are creating GUIs in MATLAB.
You will need to organize your GUI code slightly differently, but it's not hard to learn and there are great examples in the documentation.
It's not really possible to do what you're describing with just regular MATLAB: figures will just dock into the main MATLAB desktop, not into your GUI specifically. The best way (without GUI Layout Toolbox) would probably be to fake a row of tabs using buttons next to each other, with callbacks on the buttons that deleted/hid one plot and drew/revealed another. There is a function uitab that does tabs, but before R2014b it's undocumented, and it's a bit of a pain anyway. Better all round to use GUI Layout Toolbox.
If you're open to play around with undocumented features, this can be done using the java objects behind the matlab figures, e.g. using a little tool from the fileexchange.
This will create a new dock group, just like MATLAB's container for figures, editor etc.

Matlab: How to stop a spinning plot programmatically when the camera is in orbit mode

To see what I mean excatly please:
Run the code below
figure
plot(peaks)
cameratoolbar('SetMode','orbit');
cameratoolbar('Show');
Move mouse onto the plot. Hold down the left click, move the mouse to left ot right then release the click. You'll see the plot start sniping for ever.
Now if you click on the red, stop sign button it stops from spinning. However I would like to programmatically stop the spinning plot. Any thoughts?
Opening cameratoolbar in the editor reveals that orbiting is accomplished by setting the figure's WindowButton* callbacks temporarily to nested/sub functions within cameratoolbar.
Judging from the 1-minute diagonal read-through I did, the camera orbit itself is accomplished by calling a pan/zoom function orbitPangca, which recursively calls cameratoolbar. This recursion loop is controlled by flags which are toggled by the callbacks from the toolbar buttons. These flags alter the behaviour of each iteration in the recursion loop.
If this is indeed the case, it would imply that Matlab is not accepting commands from any source you have programmatic control over, while the plot is orbiting. It'll only respond to the button presses. This means that if you want to stop the motion programmatically, you'd have to hack cameratoolbar to allow for this - not the most portable option.
Another idea that just popped to mind, is figuring out which WindowButton* callback is used for the orbit, and define your own function there. You might just be lucky enough that the MathWorks implemented cameratoolbar such that both callbacks are called each iteration, which would give you programatic control over the flags. But -- you'd have to test this yourself.