source: trunk/src/create_grid.m @ 38

Last change on this file since 38 was 38, checked in by sommeria, 15 years ago

field transforms put in subdir transform_field. cleaning of obsolete functions

File size: 6.8 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)
37%------------------------------------------------------------------------
38% This function has no output args, see OutputFcn.
39
40% Choose default command line output for create_grid
41handles.output = 'Cancel';
42
43% Update handles structure
44guidata(hObject, handles);
45testNo=0;
46testCancel=1;
47testinputstring=0;
48icontype='quest';%default question icon (text input asked)
49
50% Determine the position of the dialog - centered on the screen
51FigPos=get(0,'DefaultFigurePosition');
52OldUnits = get(hObject, 'Units');
53set(hObject, 'Units', 'pixels');
54OldPos = get(hObject,'Position');
55FigWidth = OldPos(3);
56FigHeight = OldPos(4);
57ScreenUnits=get(0,'Units');
58set(0,'Units','pixels');
59ScreenSize=get(0,'ScreenSize');
60set(0,'Units',ScreenUnits);
61
62FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
63FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
64FigPos(3:4)=[FigWidth FigHeight];
65set(hObject, 'Position', FigPos);
66set(hObject, 'Units', OldUnits);
67
68% Show a question icon from dialogicons.mat - variables questIconData and questIconMap
69load dialogicons.mat
70eval(['IconData=' icontype 'IconData;'])
71eval(['IconCMap=' icontype 'IconMap;'])
72questIconMap(256,:) = get(handles.figure1, 'Color');
73Img=image(IconData, 'Parent', handles.axes1);
74set(handles.figure1, 'Colormap', IconCMap);
75set(handles.axes1, ...
76    'Visible', 'off', ...
77    'YDir'   , 'reverse'       , ...
78    'XLim'   , get(Img,'XData'), ...
79    'YLim'   , get(Img,'YData')  ...
80    );
81
82if 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 
104end
105
106set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
107% UIWAIT makes create_grid wait for user response (see UIRESUME)
108uiwait(handles.figure1);
109
110%------------------------------------------------------------------------
111% --- Outputs from this function are returned to the command line.
112function varargout = create_grid_OutputFcn(hObject, eventdata, handles)
113%------------------------------------------------------------------------
114% Get default command line output from handles structure
115varargout{1}=[0 0 0];%default
116if ~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
143end
144% The figure can be deleted now
145delete(handles.figure1);
146
147%------------------------------------------------------------------------
148% --- Executes on button press in OK.
149function OK_Callback(hObject, eventdata, handles)
150%------------------------------------------------------------------------
151handles.output = get(hObject,'String');
152guidata(hObject, handles);% Update handles structure
153uiresume(handles.figure1);
154
155%------------------------------------------------------------------------
156% --- Executes on button press in Cancel.
157function Cancel_Callback(hObject, eventdata, handles)
158%------------------------------------------------------------------------
159handles.output = get(hObject,'String');
160guidata(hObject, handles); % Update handles structure
161uiresume(handles.figure1);
162
163%------------------------------------------------------------------------
164% --- Executes when user attempts to close figure1.
165function figure1_CloseRequestFcn(hObject, eventdata, handles)
166%------------------------------------------------------------------------
167if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
168    % The GUI is still in UIWAIT, us UIRESUME
169    uiresume(handles.figure1);
170else
171    % The GUI is no longer waiting, just close it
172    delete(handles.figure1);
173end
174
175%------------------------------------------------------------------------
176% --- Executes on key press over figure1 with no controls selected.
177function figure1_KeyPressFcn(hObject, eventdata, handles)
178%------------------------------------------------------------------------
179% Check for "enter" or "escape"
180if 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);
188end
189if isequal(get(hObject,'CurrentKey'),'return')
190    uiresume(handles.figure1);
191end   
192
193
194
195
196
Note: See TracBrowser for help on using the repository browser.