https://github.com/mattools/genericdialog
A generic dialog for Matlab, mimicking ImageJ's functionalities
https://github.com/mattools/genericdialog
Last synced: 7 months ago
JSON representation
A generic dialog for Matlab, mimicking ImageJ's functionalities
- Host: GitHub
- URL: https://github.com/mattools/genericdialog
- Owner: mattools
- License: bsd-2-clause
- Created: 2018-03-29T08:42:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-02T12:21:55.000Z (almost 3 years ago)
- Last Synced: 2025-06-21T16:48:23.736Z (11 months ago)
- Language: MATLAB
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# GenericDialog
A simple generic dialog for Matlab, to quickly prompt a set of parameters.
The design is based on the "GenericDialog" class from the ImageJ software, and mimics its functionalities.
The implementation is based on the [GUILayout Toolbox](https://fr.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox),
making the dialog easily resizable.
## Example
```matlab
% create a new dialog, and populate it with some fields
% each option is defined by a name, a default value, and optionnal settings
gd = GenericDialog('Create Image');
addTextField(gd, 'Name: ', 'New Image');
addNumericField(gd, 'Width: ', 320, 0);
addNumericField(gd, 'Height: ', 200, 0);
addChoice(gd, 'Type: ', {'uint8', 'uint16', 'double'}, 'uint8');
addCheckBox(gd, 'Display', true);
% display the dialog, and wait for user input
showDialog(gd);
% check if ok or canceled was clicked
if wasCanceled(gd)
return;
end
% retrieve the user inputs
name = getNextString(gd);
width = getNextNumber(gd);
height = getNextNumber(gd);
type = getNextString(gd);
display = getNextBoolean(gd);
% Create a new image based on user inputs, and display it if requested
img = zeros([height width], type);
if display
imshow(img);
title(name);
end
```
