-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo_GenericDialog.m
54 lines (47 loc) · 1.2 KB
/
demo_GenericDialog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%DEMO_GENERICDIALOG Demo script for the GenericDialog class.
%
% output = go(input)
%
% Example
% go
%
% See also
%
%
% ------
% Author: David Legland
% e-mail: [email protected]
% Created: 2011-10-18, using Matlab 7.9.0.529 (R2009b)
% Copyright 2011 INRA - Cepia Software Platform.
% clean up
close all
clear classes %#ok<CLCLS>
% Creates a new dialog, and populate it with some fields.
% Each option is defined by a name, a default value, and optionnally some
% 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 options given by user
name = gd.getNextString();
disp(name);
width = getNextNumber(gd);
height = getNextNumber(gd);
disp([width height]);
type = getNextString(gd);
displayFlag = getNextBoolean(gd);
% Create a new image, and display if requested
img = zeros([height width], type);
if displayFlag
imshow(img);
title(name);
end