source: trunk/src/create_grid.m @ 109

Last change on this file since 109 was 109, checked in by sommeria, 10 years ago

merge_proj.m, proj_field.m: bugs repaired merging of images
plot_field.m: minor cleaning
imadoc2struct: introduce the possibility of readying the calibration point coordinates
sub_field.m:bugs repaired
geometry_calib, create_grid: introduction of new calibration methods, improvement of detect_grid

File size: 6.8 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];
138    varargout{2}=T;
139end
140
141% The figure can be deleted now
142delete(handles.figure1);
143
144%------------------------------------------------------------------------
145% --- Executes on button press in OK.
146function OK_Callback(hObject, eventdata, handles)
147%------------------------------------------------------------------------
148handles.output = get(hObject,'String');
149guidata(hObject, handles);% Update handles structure
150uiresume(handles.figure1);
151
152%------------------------------------------------------------------------
153% --- Executes on button press in Cancel.
154function Cancel_Callback(hObject, eventdata, handles)
155%------------------------------------------------------------------------
156handles.output = get(hObject,'String');
157guidata(hObject, handles); % Update handles structure
158uiresume(handles.figure1);
159
160%------------------------------------------------------------------------
161% --- Executes when user attempts to close figure1.
162function figure1_CloseRequestFcn(hObject, eventdata, handles)
163%------------------------------------------------------------------------
164if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
165    % The GUI is still in UIWAIT, us UIRESUME
166    uiresume(handles.figure1);
167else
168    % The GUI is no longer waiting, just close it
169    delete(handles.figure1);
170end
171
172%------------------------------------------------------------------------
173% --- Executes on key press over figure1 with no controls selected.
174function figure1_KeyPressFcn(hObject, eventdata, handles)
175%------------------------------------------------------------------------
176% Check for "enter" or "escape"
177if isequal(get(hObject,'CurrentKey'),'escape')
178    % User said no by hitting escape
179    handles.output = 'Cancel';
180   
181    % Update handles structure
182    guidata(hObject, handles);
183   
184    uiresume(handles.figure1);
185end
186if isequal(get(hObject,'CurrentKey'),'return')
187    uiresume(handles.figure1);
188end   
189
190
191
192
193
Note: See TracBrowser for help on using the repository browser.