[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 |
|
---|
| 14 | % Last Modified by GUIDE v2.5 05-Mar-2010 21:57:44
|
---|
| 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)
|
---|
| 46 | end
|
---|
[37] | 47 | % Update handles structure
|
---|
| 48 | guidata(hObject, handles);
|
---|
| 49 | testNo=0;
|
---|
| 50 | testCancel=1;
|
---|
| 51 | testinputstring=0;
|
---|
| 52 | icontype='quest';%default question icon (text input asked)
|
---|
| 53 |
|
---|
| 54 | % Determine the position of the dialog - centered on the screen
|
---|
| 55 | FigPos=get(0,'DefaultFigurePosition');
|
---|
| 56 | OldUnits = get(hObject, 'Units');
|
---|
| 57 | set(hObject, 'Units', 'pixels');
|
---|
| 58 | OldPos = get(hObject,'Position');
|
---|
| 59 | FigWidth = OldPos(3);
|
---|
| 60 | FigHeight = OldPos(4);
|
---|
| 61 | ScreenUnits=get(0,'Units');
|
---|
| 62 | set(0,'Units','pixels');
|
---|
| 63 | ScreenSize=get(0,'ScreenSize');
|
---|
| 64 | set(0,'Units',ScreenUnits);
|
---|
| 65 |
|
---|
| 66 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
---|
| 67 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
---|
| 68 | FigPos(3:4)=[FigWidth FigHeight];
|
---|
| 69 | set(hObject, 'Position', FigPos);
|
---|
| 70 | set(hObject, 'Units', OldUnits);
|
---|
| 71 |
|
---|
| 72 | % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
|
---|
| 73 | load dialogicons.mat
|
---|
| 74 | eval(['IconData=' icontype 'IconData;'])
|
---|
| 75 | eval(['IconCMap=' icontype 'IconMap;'])
|
---|
| 76 | questIconMap(256,:) = get(handles.figure1, 'Color');
|
---|
| 77 | Img=image(IconData, 'Parent', handles.axes1);
|
---|
| 78 | set(handles.figure1, 'Colormap', IconCMap);
|
---|
| 79 | set(handles.axes1, ...
|
---|
| 80 | 'Visible', 'off', ...
|
---|
| 81 | 'YDir' , 'reverse' , ...
|
---|
| 82 | 'XLim' , get(Img,'XData'), ...
|
---|
| 83 | 'YLim' , get(Img,'YData') ...
|
---|
| 84 | );
|
---|
| 85 |
|
---|
| 86 | if 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')
|
---|
[60] | 97 | set(handles.y_0,'String',num2str(input_grid.y_0));
|
---|
[37] | 98 | end
|
---|
| 99 | if isfield(input_grid,'y_1')
|
---|
[60] | 100 | set(handles.y_1,'String',num2str(input_grid.y_1));
|
---|
[37] | 101 | end
|
---|
| 102 | if isfield(input_grid,'Dy')
|
---|
[60] | 103 | set(handles.Dy,'String',num2str(input_grid.Dy));
|
---|
[37] | 104 | end
|
---|
| 105 | if isfield(input_grid,'z')
|
---|
| 106 | set(handles.z,'String',num2str(input_grid.z));
|
---|
| 107 | end
|
---|
| 108 | end
|
---|
| 109 |
|
---|
| 110 | set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
|
---|
| 111 | % UIWAIT makes create_grid wait for user response (see UIRESUME)
|
---|
| 112 | uiwait(handles.figure1);
|
---|
| 113 |
|
---|
| 114 | %------------------------------------------------------------------------
|
---|
| 115 | % --- Outputs from this function are returned to the command line.
|
---|
| 116 | function varargout = create_grid_OutputFcn(hObject, eventdata, handles)
|
---|
| 117 | %------------------------------------------------------------------------
|
---|
| 118 | % Get default command line output from handles structure
|
---|
| 119 | varargout{1}=[0 0 0];%default
|
---|
| 120 | if ~isequal(handles.output,'Cancel')
|
---|
[60] | 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];
|
---|
[37] | 129 | [yarray,xarray]=meshgrid(yarray,xarray);
|
---|
| 130 | xarray=reshape(xarray,numel(xarray),1);
|
---|
| 131 | yarray=reshape(yarray,numel(yarray),1);
|
---|
[60] | 132 | T.z_0=str2num(get(handles.z_0,'String'));
|
---|
| 133 | if isempty(T.z_0)
|
---|
| 134 | T.z_0=0;
|
---|
[37] | 135 | end
|
---|
[60] | 136 | zarray=T.z_0*ones(size(yarray));
|
---|
[37] | 137 | varargout{1}=[xarray yarray zarray];
|
---|
| 138 | end
|
---|
[60] | 139 | varargout{2}=T;
|
---|
[37] | 140 | % The figure can be deleted now
|
---|
| 141 | delete(handles.figure1);
|
---|
| 142 |
|
---|
| 143 | %------------------------------------------------------------------------
|
---|
| 144 | % --- Executes on button press in OK.
|
---|
| 145 | function OK_Callback(hObject, eventdata, handles)
|
---|
| 146 | %------------------------------------------------------------------------
|
---|
| 147 | handles.output = get(hObject,'String');
|
---|
| 148 | guidata(hObject, handles);% Update handles structure
|
---|
| 149 | uiresume(handles.figure1);
|
---|
| 150 |
|
---|
| 151 | %------------------------------------------------------------------------
|
---|
| 152 | % --- Executes on button press in Cancel.
|
---|
| 153 | function Cancel_Callback(hObject, eventdata, handles)
|
---|
| 154 | %------------------------------------------------------------------------
|
---|
| 155 | handles.output = get(hObject,'String');
|
---|
| 156 | guidata(hObject, handles); % Update handles structure
|
---|
| 157 | uiresume(handles.figure1);
|
---|
| 158 |
|
---|
| 159 | %------------------------------------------------------------------------
|
---|
| 160 | % --- Executes when user attempts to close figure1.
|
---|
| 161 | function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
---|
| 162 | %------------------------------------------------------------------------
|
---|
| 163 | if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
|
---|
| 164 | % The GUI is still in UIWAIT, us UIRESUME
|
---|
| 165 | uiresume(handles.figure1);
|
---|
| 166 | else
|
---|
| 167 | % The GUI is no longer waiting, just close it
|
---|
| 168 | delete(handles.figure1);
|
---|
| 169 | end
|
---|
| 170 |
|
---|
| 171 | %------------------------------------------------------------------------
|
---|
| 172 | % --- Executes on key press over figure1 with no controls selected.
|
---|
| 173 | function figure1_KeyPressFcn(hObject, eventdata, handles)
|
---|
| 174 | %------------------------------------------------------------------------
|
---|
| 175 | % Check for "enter" or "escape"
|
---|
| 176 | if 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);
|
---|
| 184 | end
|
---|
| 185 | if isequal(get(hObject,'CurrentKey'),'return')
|
---|
| 186 | uiresume(handles.figure1);
|
---|
| 187 | end
|
---|
| 188 |
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 |
|
---|