Skip to content

Commit 60c6583

Browse files
authored
Create README.md
1 parent 9d6ffc1 commit 60c6583

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# GenericDialog
2+
A simple generic dialog for Matlab, to quickly prompt a set of parameters.
3+
The design is based on ImageJ's "GenericDialog" class, and mimics its functionalities.
4+
5+
## Example
6+
7+
% create a new dialog, and populate it with some fields
8+
% each option is defined by a name, a default value, and optionnal settings
9+
gd = imagem.gui.GenericDialog('Create Image');
10+
addTextField(gd, 'Name: ', 'New Image');
11+
addNumericField(gd, 'Width: ', 320, 0);
12+
addNumericField(gd, 'Height: ', 200, 0);
13+
addChoice(gd, 'Type: ', {'uint8', 'uint16', 'double'}, 'uint8');
14+
addCheckBox(gd, 'Display', true);
15+
16+
% display the dialog, and wait for user input
17+
showDialog(gd);
18+
% check if ok or canceled was clicked
19+
if wasCanceled(gd)
20+
return;
21+
end
22+
23+
% retrieve the user inputs
24+
name = gd.getNextString();
25+
width = getNextNumber(gd);
26+
height = getNextNumber(gd);
27+
type = getNextString(gd);
28+
display = getNextBoolean(gd);
29+
30+
% Create a new image based on user inputs, and display if requested
31+
img = zeros([height width ], type);
32+
if display
33+
imshow(img);
34+
title(name);
35+
end

0 commit comments

Comments
 (0)