source: trunk/src/create_grid.m @ 37

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

create_grid.fig ,
uvmat_doc and all the included files added

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