|
1 | | -%GO run script for GenericDialog class |
| 1 | +%DEMO_GENERICDIALOG Demo script for the GenericDialog class. |
2 | 2 | % |
3 | 3 | % output = go(input) |
4 | 4 | % |
|
10 | 10 | % |
11 | 11 | % ------ |
12 | 12 | % Author: David Legland |
13 | | -% e-mail: david.legland@grignon.inra.fr |
| 13 | +% e-mail: david.legland@inrae.fr |
14 | 14 | % Created: 2011-10-18, using Matlab 7.9.0.529 (R2009b) |
15 | 15 | % Copyright 2011 INRA - Cepia Software Platform. |
16 | 16 |
|
17 | 17 | % clean up |
18 | 18 | close all |
19 | 19 | clear classes %#ok<CLCLS> |
20 | 20 |
|
21 | | -% creates a new dialog, and populate it with some fields |
| 21 | +% Creates a new dialog, and populate it with some fields. |
| 22 | +% Each option is defined by a name, a default value, and optionnally some |
| 23 | +% settings. |
22 | 24 | gd = GenericDialog('Create Image'); |
23 | 25 | addTextField(gd, 'Name: ', 'New Image'); |
24 | 26 | addNumericField(gd, 'Width: ', 320, 0); |
25 | 27 | addNumericField(gd, 'Height: ', 200, 0); |
26 | 28 | addChoice(gd, 'Type: ', {'uint8', 'uint16', 'double'}, 'uint8'); |
27 | 29 | addCheckBox(gd, 'Display', true); |
28 | | -% pack(gd); |
29 | 30 |
|
30 | | -% display the dialog, and wait for user |
| 31 | +% display the dialog, and wait for user input |
31 | 32 | showDialog(gd); |
32 | 33 |
|
33 | | -% check if ok or cancel was clicked |
| 34 | +% check if ok or canceled was clicked |
34 | 35 | if wasCanceled(gd) |
35 | 36 | return; |
36 | 37 | end |
37 | 38 |
|
38 | | - |
| 39 | +% retrieve options given by user |
39 | 40 | name = gd.getNextString(); |
40 | 41 | disp(name); |
41 | | - |
42 | 42 | width = getNextNumber(gd); |
43 | 43 | height = getNextNumber(gd); |
44 | 44 | disp([width height]); |
45 | 45 | type = getNextString(gd); |
46 | | -display = getNextBoolean(gd); |
| 46 | +displayFlag = getNextBoolean(gd); |
47 | 47 |
|
48 | | -% Create new image, and display if requested |
49 | | -img = zeros([height width ], type); |
50 | | -if display |
| 48 | +% Create a new image, and display if requested |
| 49 | +img = zeros([height width], type); |
| 50 | +if displayFlag |
51 | 51 | imshow(img); |
52 | 52 | title(name); |
53 | 53 | end |
|
0 commit comments