[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 |
|
---|
[809] | 12 | %=======================================================================
|
---|
[924] | 13 | % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
---|
[809] | 14 | % http://www.legi.grenoble-inp.fr
|
---|
| 15 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
|
---|
| 16 | %
|
---|
| 17 | % This file is part of the toolbox UVMAT.
|
---|
| 18 | %
|
---|
| 19 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 20 | % it under the terms of the GNU General Public License as published
|
---|
| 21 | % by the Free Software Foundation; either version 2 of the license,
|
---|
| 22 | % or (at your option) any later version.
|
---|
| 23 | %
|
---|
| 24 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 27 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
| 28 | %=======================================================================
|
---|
| 29 |
|
---|
[37] | 30 | function varargout = create_grid(varargin)
|
---|
| 31 |
|
---|
[156] | 32 | % Last Modified by GUIDE v2.5 16-Dec-2010 00:17:20
|
---|
[37] | 33 |
|
---|
| 34 | % Begin initialization code - DO NOT EDIT
|
---|
| 35 | gui_Singleton = 1;
|
---|
| 36 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 37 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 38 | 'gui_OpeningFcn', @create_grid_OpeningFcn, ...
|
---|
| 39 | 'gui_OutputFcn', @create_grid_OutputFcn, ...
|
---|
| 40 | 'gui_LayoutFcn', [] , ...
|
---|
| 41 | 'gui_Callback', []);
|
---|
| 42 | if nargin && ischar(varargin{1})
|
---|
| 43 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 44 | end
|
---|
| 45 |
|
---|
| 46 | if nargout
|
---|
| 47 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
| 48 | else
|
---|
| 49 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 50 | end
|
---|
| 51 | % End initialization code - DO NOT EDIT
|
---|
| 52 |
|
---|
| 53 | %------------------------------------------------------------------------
|
---|
| 54 | % --- Executes just before create_grid is made visible.
|
---|
[88] | 55 | function create_grid_OpeningFcn(hObject, eventdata, handles,input_grid,name)
|
---|
[37] | 56 | %------------------------------------------------------------------------
|
---|
| 57 | % This function has no output args, see OutputFcn.
|
---|
| 58 |
|
---|
| 59 | % Choose default command line output for create_grid
|
---|
| 60 | handles.output = 'Cancel';
|
---|
| 61 |
|
---|
[88] | 62 | if exist('name','var') && ischar(name)
|
---|
| 63 | set(hObject,'name',name)
|
---|
[156] | 64 | if strcmp(name,'detect_grid')
|
---|
| 65 | set(handles.white,'Visible','on')
|
---|
| 66 | set(handles.black,'Visible','on')
|
---|
| 67 | end
|
---|
[88] | 68 | end
|
---|
[37] | 69 | % Update handles structure
|
---|
| 70 | guidata(hObject, handles);
|
---|
| 71 | testNo=0;
|
---|
| 72 | testCancel=1;
|
---|
| 73 | testinputstring=0;
|
---|
| 74 | icontype='quest';%default question icon (text input asked)
|
---|
| 75 |
|
---|
| 76 | % Determine the position of the dialog - centered on the screen
|
---|
| 77 | FigPos=get(0,'DefaultFigurePosition');
|
---|
| 78 | OldUnits = get(hObject, 'Units');
|
---|
| 79 | set(hObject, 'Units', 'pixels');
|
---|
| 80 | OldPos = get(hObject,'Position');
|
---|
| 81 | FigWidth = OldPos(3);
|
---|
| 82 | FigHeight = OldPos(4);
|
---|
| 83 | ScreenUnits=get(0,'Units');
|
---|
| 84 | set(0,'Units','pixels');
|
---|
| 85 | ScreenSize=get(0,'ScreenSize');
|
---|
| 86 | set(0,'Units',ScreenUnits);
|
---|
| 87 |
|
---|
| 88 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
---|
| 89 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
---|
| 90 | FigPos(3:4)=[FigWidth FigHeight];
|
---|
| 91 | set(hObject, 'Position', FigPos);
|
---|
| 92 | set(hObject, 'Units', OldUnits);
|
---|
| 93 |
|
---|
| 94 | % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
|
---|
| 95 | load dialogicons.mat
|
---|
| 96 | eval(['IconData=' icontype 'IconData;'])
|
---|
| 97 | eval(['IconCMap=' icontype 'IconMap;'])
|
---|
| 98 | questIconMap(256,:) = get(handles.figure1, 'Color');
|
---|
| 99 | Img=image(IconData, 'Parent', handles.axes1);
|
---|
| 100 | set(handles.figure1, 'Colormap', IconCMap);
|
---|
| 101 | set(handles.axes1, ...
|
---|
| 102 | 'Visible', 'off', ...
|
---|
| 103 | 'YDir' , 'reverse' , ...
|
---|
| 104 | 'XLim' , get(Img,'XData'), ...
|
---|
| 105 | 'YLim' , get(Img,'YData') ...
|
---|
| 106 | );
|
---|
| 107 |
|
---|
| 108 | if exist('input_grid','var') && ~isempty(input_grid)
|
---|
| 109 | if isfield(input_grid,'x_0')
|
---|
| 110 | set(handles.x_0,'String',num2str(input_grid.x_0));
|
---|
| 111 | end
|
---|
| 112 | if isfield(input_grid,'x_1')
|
---|
| 113 | set(handles.x_1,'String',num2str(input_grid.x_1));
|
---|
| 114 | end
|
---|
| 115 | if isfield(input_grid,'Dx')
|
---|
| 116 | set(handles.Dx,'String',num2str(input_grid.Dx));
|
---|
| 117 | end
|
---|
| 118 | if isfield(input_grid,'y_0')
|
---|
[60] | 119 | set(handles.y_0,'String',num2str(input_grid.y_0));
|
---|
[37] | 120 | end
|
---|
| 121 | if isfield(input_grid,'y_1')
|
---|
[60] | 122 | set(handles.y_1,'String',num2str(input_grid.y_1));
|
---|
[37] | 123 | end
|
---|
| 124 | if isfield(input_grid,'Dy')
|
---|
[60] | 125 | set(handles.Dy,'String',num2str(input_grid.Dy));
|
---|
[37] | 126 | end
|
---|
| 127 | if isfield(input_grid,'z')
|
---|
| 128 | set(handles.z,'String',num2str(input_grid.z));
|
---|
| 129 | end
|
---|
[694] | 130 | if isfield(input_grid,'CheckWhite')
|
---|
| 131 | if input_grid.CheckWhite
|
---|
| 132 | set(handles.white,'Value',1)
|
---|
| 133 | set(handles.black,'Value',0)
|
---|
| 134 | else
|
---|
| 135 | set(handles.white,'Value',0)
|
---|
| 136 | set(handles.black,'Value',1)
|
---|
| 137 | end
|
---|
| 138 | end
|
---|
[37] | 139 | end
|
---|
| 140 |
|
---|
| 141 | set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
|
---|
| 142 | % UIWAIT makes create_grid wait for user response (see UIRESUME)
|
---|
| 143 | uiwait(handles.figure1);
|
---|
| 144 |
|
---|
| 145 | %------------------------------------------------------------------------
|
---|
| 146 | % --- Outputs from this function are returned to the command line.
|
---|
| 147 | function varargout = create_grid_OutputFcn(hObject, eventdata, handles)
|
---|
| 148 | %------------------------------------------------------------------------
|
---|
| 149 | % Get default command line output from handles structure
|
---|
| 150 | varargout{1}=[0 0 0];%default
|
---|
| 151 | if ~isequal(handles.output,'Cancel')
|
---|
[60] | 152 | T.x_0=str2num(get(handles.x_0,'String'));
|
---|
| 153 | T.Dx=str2num(get(handles.Dx,'String'));
|
---|
| 154 | T.x_1=str2num(get(handles.x_1,'String'));
|
---|
| 155 | xarray=[T.x_0:T.Dx:T.x_1];
|
---|
| 156 | T.y_0=str2num(get(handles.y_0,'String'));
|
---|
| 157 | T.Dy=str2num(get(handles.Dy,'String'));
|
---|
| 158 | T.y_1=str2num(get(handles.y_1,'String'));
|
---|
| 159 | yarray=[T.y_0:T.Dy:T.y_1];
|
---|
[37] | 160 | [yarray,xarray]=meshgrid(yarray,xarray);
|
---|
| 161 | xarray=reshape(xarray,numel(xarray),1);
|
---|
| 162 | yarray=reshape(yarray,numel(yarray),1);
|
---|
[60] | 163 | T.z_0=str2num(get(handles.z_0,'String'));
|
---|
| 164 | if isempty(T.z_0)
|
---|
| 165 | T.z_0=0;
|
---|
[37] | 166 | end
|
---|
[60] | 167 | zarray=T.z_0*ones(size(yarray));
|
---|
[37] | 168 | varargout{1}=[xarray yarray zarray];
|
---|
[109] | 169 | varargout{2}=T;
|
---|
[694] | 170 | varargout{3}=get(handles.white,'Value');
|
---|
[37] | 171 | end
|
---|
[109] | 172 |
|
---|
[37] | 173 | % The figure can be deleted now
|
---|
| 174 | delete(handles.figure1);
|
---|
| 175 |
|
---|
| 176 | %------------------------------------------------------------------------
|
---|
| 177 | % --- Executes on button press in OK.
|
---|
| 178 | function OK_Callback(hObject, eventdata, handles)
|
---|
| 179 | %------------------------------------------------------------------------
|
---|
| 180 | handles.output = get(hObject,'String');
|
---|
| 181 | guidata(hObject, handles);% Update handles structure
|
---|
| 182 | uiresume(handles.figure1);
|
---|
| 183 |
|
---|
| 184 | %------------------------------------------------------------------------
|
---|
| 185 | % --- Executes on button press in Cancel.
|
---|
| 186 | function Cancel_Callback(hObject, eventdata, handles)
|
---|
| 187 | %------------------------------------------------------------------------
|
---|
| 188 | handles.output = get(hObject,'String');
|
---|
| 189 | guidata(hObject, handles); % Update handles structure
|
---|
| 190 | uiresume(handles.figure1);
|
---|
| 191 |
|
---|
| 192 | %------------------------------------------------------------------------
|
---|
| 193 | % --- Executes when user attempts to close figure1.
|
---|
| 194 | function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
---|
| 195 | %------------------------------------------------------------------------
|
---|
| 196 | if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
|
---|
| 197 | % The GUI is still in UIWAIT, us UIRESUME
|
---|
| 198 | uiresume(handles.figure1);
|
---|
| 199 | else
|
---|
| 200 | % The GUI is no longer waiting, just close it
|
---|
| 201 | delete(handles.figure1);
|
---|
| 202 | end
|
---|
| 203 |
|
---|
| 204 | %------------------------------------------------------------------------
|
---|
| 205 | % --- Executes on key press over figure1 with no controls selected.
|
---|
| 206 | function figure1_KeyPressFcn(hObject, eventdata, handles)
|
---|
| 207 | %------------------------------------------------------------------------
|
---|
| 208 | % Check for "enter" or "escape"
|
---|
| 209 | if isequal(get(hObject,'CurrentKey'),'escape')
|
---|
| 210 | % User said no by hitting escape
|
---|
| 211 | handles.output = 'Cancel';
|
---|
| 212 |
|
---|
| 213 | % Update handles structure
|
---|
| 214 | guidata(hObject, handles);
|
---|
| 215 |
|
---|
| 216 | uiresume(handles.figure1);
|
---|
| 217 | end
|
---|
| 218 | if isequal(get(hObject,'CurrentKey'),'return')
|
---|
| 219 | uiresume(handles.figure1);
|
---|
| 220 | end
|
---|
| 221 |
|
---|
| 222 |
|
---|
[156] | 223 | % --- Executes on button press in white.
|
---|
| 224 | function white_Callback(hObject, eventdata, handles)
|
---|
| 225 | val=get(handles.white,'Value');
|
---|
| 226 | if val
|
---|
| 227 | set(handles.black,'Value',0)
|
---|
| 228 | else
|
---|
| 229 | set(handles.black,'Value',1)
|
---|
| 230 | end
|
---|
| 231 | % hObject handle to white (see GCBO)
|
---|
| 232 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 233 | % handles structure with handles and user data (see GUIDATA)
|
---|
[37] | 234 |
|
---|
[156] | 235 | % Hint: get(hObject,'Value') returns toggle state of white
|
---|
[37] | 236 |
|
---|
| 237 |
|
---|
[156] | 238 | % --- Executes on button press in black.
|
---|
| 239 | function black_Callback(hObject, eventdata, handles)
|
---|
| 240 | val=get(handles.black,'Value');
|
---|
| 241 | if val
|
---|
| 242 | set(handles.white,'Value',0)
|
---|
| 243 | else
|
---|
| 244 | set(handles.white,'Value',1)
|
---|
| 245 | end
|
---|
| 246 |
|
---|