source: trunk/src/create_grid.m @ 102

Last change on this file since 102 was 89, checked in by sommeria, 14 years ago

many bug corrections and cleaning. Activation of the BW option in uvmat. Improvement of the interaction of get_field with uvmat.

File size: 6.7 KB
Line 
1%'create_grid': called by the GUI geometry_calib to create a physical grid
2%------------------------------------------------------------------------
3% coord=create_grid(input_grid)
4%
5% OUTPUT:
6% coord: matrix (nbpoint, 3) of coordinates for grid points, with columns x,y,z
7%
8% INPUT:
9% input_grid (optional): structure to initiate the GUI with fields .x_0,.Dx,.x_1
10% (defining x coordinates), .y_0,.Dy,.y_1 (defining y coordinates)
11
12function varargout = create_grid(varargin)
13
14% Last Modified by GUIDE v2.5 05-Mar-2010 21:57:44
15
16% Begin initialization code - DO NOT EDIT
17gui_Singleton = 1;
18gui_State = struct('gui_Name',       mfilename, ...
19                   'gui_Singleton',  gui_Singleton, ...
20                   'gui_OpeningFcn', @create_grid_OpeningFcn, ...
21                   'gui_OutputFcn',  @create_grid_OutputFcn, ...
22                   'gui_LayoutFcn',  [] , ...
23                   'gui_Callback',   []);
24if nargin && ischar(varargin{1})
25    gui_State.gui_Callback = str2func(varargin{1});
26end
27
28if nargout
29    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
30else
31    gui_mainfcn(gui_State, varargin{:});
32end
33% End initialization code - DO NOT EDIT
34
35%------------------------------------------------------------------------
36% --- Executes just before create_grid is made visible.
37function create_grid_OpeningFcn(hObject, eventdata, handles,input_grid,name)
38%------------------------------------------------------------------------
39% This function has no output args, see OutputFcn.
40
41% Choose default command line output for create_grid
42handles.output = 'Cancel';
43
44if exist('name','var') && ischar(name)
45    set(hObject,'name',name)
46end
47% Update handles structure
48guidata(hObject, handles);
49testNo=0;
50testCancel=1;
51testinputstring=0;
52icontype='quest';%default question icon (text input asked)
53
54% Determine the position of the dialog - centered on the screen
55FigPos=get(0,'DefaultFigurePosition');
56OldUnits = get(hObject, 'Units');
57set(hObject, 'Units', 'pixels');
58OldPos = get(hObject,'Position');
59FigWidth = OldPos(3);
60FigHeight = OldPos(4);
61ScreenUnits=get(0,'Units');
62set(0,'Units','pixels');
63ScreenSize=get(0,'ScreenSize');
64set(0,'Units',ScreenUnits);
65
66FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
67FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
68FigPos(3:4)=[FigWidth FigHeight];
69set(hObject, 'Position', FigPos);
70set(hObject, 'Units', OldUnits);
71
72% Show a question icon from dialogicons.mat - variables questIconData and questIconMap
73load dialogicons.mat
74eval(['IconData=' icontype 'IconData;'])
75eval(['IconCMap=' icontype 'IconMap;'])
76questIconMap(256,:) = get(handles.figure1, 'Color');
77Img=image(IconData, 'Parent', handles.axes1);
78set(handles.figure1, 'Colormap', IconCMap);
79set(handles.axes1, ...
80    'Visible', 'off', ...
81    'YDir'   , 'reverse'       , ...
82    'XLim'   , get(Img,'XData'), ...
83    'YLim'   , get(Img,'YData')  ...
84    );
85
86if exist('input_grid','var') && ~isempty(input_grid)
87   if isfield(input_grid,'x_0')
88        set(handles.x_0,'String',num2str(input_grid.x_0));
89   end
90   if isfield(input_grid,'x_1')
91        set(handles.x_1,'String',num2str(input_grid.x_1));
92   end
93   if isfield(input_grid,'Dx')
94        set(handles.Dx,'String',num2str(input_grid.Dx));
95   end
96   if isfield(input_grid,'y_0')
97        set(handles.y_0,'String',num2str(input_grid.y_0));
98   end
99   if isfield(input_grid,'y_1')
100        set(handles.y_1,'String',num2str(input_grid.y_1));
101   end
102   if isfield(input_grid,'Dy')
103        set(handles.Dy,'String',num2str(input_grid.Dy));
104   end
105   if isfield(input_grid,'z')
106        set(handles.z,'String',num2str(input_grid.z));
107   end 
108end
109
110set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
111% UIWAIT makes create_grid wait for user response (see UIRESUME)
112uiwait(handles.figure1);
113
114%------------------------------------------------------------------------
115% --- Outputs from this function are returned to the command line.
116function varargout = create_grid_OutputFcn(hObject, eventdata, handles)
117%------------------------------------------------------------------------
118% Get default command line output from handles structure
119varargout{1}=[0 0 0];%default
120if ~isequal(handles.output,'Cancel')
121    T.x_0=str2num(get(handles.x_0,'String'));
122    T.Dx=str2num(get(handles.Dx,'String'));
123    T.x_1=str2num(get(handles.x_1,'String'));
124    xarray=[T.x_0:T.Dx:T.x_1];
125    T.y_0=str2num(get(handles.y_0,'String'));
126    T.Dy=str2num(get(handles.Dy,'String'));
127    T.y_1=str2num(get(handles.y_1,'String'));
128    yarray=[T.y_0:T.Dy:T.y_1];
129    [yarray,xarray]=meshgrid(yarray,xarray);
130    xarray=reshape(xarray,numel(xarray),1);
131    yarray=reshape(yarray,numel(yarray),1);
132    T.z_0=str2num(get(handles.z_0,'String'));
133    if isempty(T.z_0)
134        T.z_0=0;
135    end
136    zarray=T.z_0*ones(size(yarray));
137    varargout{1}=[xarray yarray zarray];
138end
139varargout{2}=T;
140% The figure can be deleted now
141delete(handles.figure1);
142
143%------------------------------------------------------------------------
144% --- Executes on button press in OK.
145function OK_Callback(hObject, eventdata, handles)
146%------------------------------------------------------------------------
147handles.output = get(hObject,'String');
148guidata(hObject, handles);% Update handles structure
149uiresume(handles.figure1);
150
151%------------------------------------------------------------------------
152% --- Executes on button press in Cancel.
153function Cancel_Callback(hObject, eventdata, handles)
154%------------------------------------------------------------------------
155handles.output = get(hObject,'String');
156guidata(hObject, handles); % Update handles structure
157uiresume(handles.figure1);
158
159%------------------------------------------------------------------------
160% --- Executes when user attempts to close figure1.
161function figure1_CloseRequestFcn(hObject, eventdata, handles)
162%------------------------------------------------------------------------
163if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
164    % The GUI is still in UIWAIT, us UIRESUME
165    uiresume(handles.figure1);
166else
167    % The GUI is no longer waiting, just close it
168    delete(handles.figure1);
169end
170
171%------------------------------------------------------------------------
172% --- Executes on key press over figure1 with no controls selected.
173function figure1_KeyPressFcn(hObject, eventdata, handles)
174%------------------------------------------------------------------------
175% Check for "enter" or "escape"
176if isequal(get(hObject,'CurrentKey'),'escape')
177    % User said no by hitting escape
178    handles.output = 'Cancel';
179   
180    % Update handles structure
181    guidata(hObject, handles);
182   
183    uiresume(handles.figure1);
184end
185if isequal(get(hObject,'CurrentKey'),'return')
186    uiresume(handles.figure1);
187end   
188
189
190
191
192
Note: See TracBrowser for help on using the repository browser.