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