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