source: trunk/src/create_grid.m @ 88

Last change on this file since 88 was 88, checked in by sommeria, 14 years ago

plot_field: test for multicomponent image (-> errormsg)
creat_grid: possibility of changing the figure name (for detect_grid)
geometry_calib: detect_grid improved (range of search adjusted from grid mesh)

bug repaired in translate points

uvmat: bug repair: dela with the case with several get_field GUI opened

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