1 | %'translate_points': associated with GUI translate_points.fig to display message boxes, for error, warning or input calls
|
---|
2 | % translate_points(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 |
|
---|
16 | function varargout = translate_points(varargin)
|
---|
17 |
|
---|
18 | % Last Modified by GUIDE v2.5 05-Jan-2010 19:31:33
|
---|
19 |
|
---|
20 | % Begin initialization code - DO NOT EDIT
|
---|
21 | gui_Singleton = 1;
|
---|
22 | gui_State = struct('gui_Name', mfilename, ...
|
---|
23 | 'gui_Singleton', gui_Singleton, ...
|
---|
24 | 'gui_OpeningFcn', @translate_points_OpeningFcn, ...
|
---|
25 | 'gui_OutputFcn', @translate_points_OutputFcn, ...
|
---|
26 | 'gui_LayoutFcn', [] , ...
|
---|
27 | 'gui_Callback', []);
|
---|
28 | if nargin && ischar(varargin{1})
|
---|
29 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
30 | end
|
---|
31 |
|
---|
32 | if nargout
|
---|
33 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
34 | else
|
---|
35 | gui_mainfcn(gui_State, varargin{:});
|
---|
36 | end
|
---|
37 | % End initialization code - DO NOT EDIT
|
---|
38 |
|
---|
39 | % --- Executes just before translate_points is made visible.
|
---|
40 | function translate_points_OpeningFcn(hObject, eventdata, handles,input_shift)
|
---|
41 | % This function has no output args, see OutputFcn.
|
---|
42 |
|
---|
43 | % Choose default command line output for translate_points
|
---|
44 | handles.output = 'Cancel';
|
---|
45 |
|
---|
46 | % Update handles structure
|
---|
47 | guidata(hObject, handles);
|
---|
48 | testNo=0;
|
---|
49 | testCancel=1;
|
---|
50 | testinputstring=0;
|
---|
51 | icontype='quest';%default question icon (text input asked)
|
---|
52 |
|
---|
53 | % Determine the position of the dialog - centered on the screen
|
---|
54 | FigPos=get(0,'DefaultFigurePosition');
|
---|
55 | OldUnits = get(hObject, 'Units');
|
---|
56 | set(hObject, 'Units', 'pixels');
|
---|
57 | OldPos = get(hObject,'Position');
|
---|
58 | FigWidth = OldPos(3);
|
---|
59 | FigHeight = OldPos(4);
|
---|
60 | ScreenUnits=get(0,'Units');
|
---|
61 | set(0,'Units','pixels');
|
---|
62 | ScreenSize=get(0,'ScreenSize');
|
---|
63 | set(0,'Units',ScreenUnits);
|
---|
64 |
|
---|
65 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
---|
66 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
---|
67 | FigPos(3:4)=[FigWidth FigHeight];
|
---|
68 | set(hObject, 'Position', FigPos);
|
---|
69 | set(hObject, 'Units', OldUnits);
|
---|
70 |
|
---|
71 | % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
|
---|
72 | load dialogicons.mat
|
---|
73 | eval(['IconData=' icontype 'IconData;'])
|
---|
74 | eval(['IconCMap=' icontype 'IconMap;'])
|
---|
75 | questIconMap(256,:) = get(handles.figure1, 'Color');
|
---|
76 | Img=image(IconData, 'Parent', handles.axes1);
|
---|
77 | set(handles.figure1, 'Colormap', IconCMap);
|
---|
78 | set(handles.axes1, ...
|
---|
79 | 'Visible', 'off', ...
|
---|
80 | 'YDir' , 'reverse' , ...
|
---|
81 | 'XLim' , get(Img,'XData'), ...
|
---|
82 | 'YLim' , get(Img,'YData') ...
|
---|
83 | );
|
---|
84 |
|
---|
85 | if exist('input_shift','var') && ~isempty(input_shift)
|
---|
86 | set(handles.x_shift,'String',num2str(input_shift(1)));
|
---|
87 | if numel(input_shift)>=2
|
---|
88 | set(handles.y_shift,'String',num2str(input_shift(2)));
|
---|
89 | end
|
---|
90 | if numel(input_shift)>=3
|
---|
91 | set(handles.z_shift,'String',num2str(input_shift(3)));
|
---|
92 | end
|
---|
93 | end
|
---|
94 |
|
---|
95 | set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
|
---|
96 | % UIWAIT makes translate_points wait for user response (see UIRESUME)
|
---|
97 | uiwait(handles.figure1);
|
---|
98 |
|
---|
99 |
|
---|
100 | % --- Outputs from this function are returned to the command line.
|
---|
101 | function varargout = translate_points_OutputFcn(hObject, eventdata, handles)
|
---|
102 |
|
---|
103 | % Get default command line output from handles structure
|
---|
104 | varargout{1}=[0 0 0];%default
|
---|
105 | if ~isequal(handles.output,'Cancel')
|
---|
106 | x_shift=str2num(get(handles.x_shift,'String'));
|
---|
107 | y_shift=str2num(get(handles.y_shift,'String'));
|
---|
108 | z_shift=str2num(get(handles.z_shift,'String'));
|
---|
109 | if ~isempty(x_shift)
|
---|
110 | varargout{1}(1)=x_shift;
|
---|
111 | end
|
---|
112 | if ~isempty(y_shift)
|
---|
113 | varargout{1}(2)=y_shift;
|
---|
114 | end
|
---|
115 | if ~isempty(z_shift)
|
---|
116 | varargout{1}(3)=z_shift;
|
---|
117 | end
|
---|
118 | end
|
---|
119 | % The figure can be deleted now
|
---|
120 | delete(handles.figure1);
|
---|
121 |
|
---|
122 | % --- Executes on button press in OK.
|
---|
123 | function OK_Callback(hObject, eventdata, handles)
|
---|
124 | handles.output = get(hObject,'String');
|
---|
125 | guidata(hObject, handles);% Update handles structure
|
---|
126 | uiresume(handles.figure1);
|
---|
127 |
|
---|
128 | % --- Executes on button press in Cancel.
|
---|
129 | function Cancel_Callback(hObject, eventdata, handles)
|
---|
130 | handles.output = get(hObject,'String');
|
---|
131 | %handles.output = 'Cancel'
|
---|
132 | guidata(hObject, handles); % Update handles structure
|
---|
133 | % Use UIRESUME instead of delete because the OutputFcn needs
|
---|
134 | % to get the updated handles structure.
|
---|
135 | uiresume(handles.figure1);
|
---|
136 |
|
---|
137 | % --- Executes when user attempts to close figure1.
|
---|
138 | function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
---|
139 | if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
|
---|
140 | % The GUI is still in UIWAIT, us UIRESUME
|
---|
141 | uiresume(handles.figure1);
|
---|
142 | else
|
---|
143 | % The GUI is no longer waiting, just close it
|
---|
144 | delete(handles.figure1);
|
---|
145 | end
|
---|
146 |
|
---|
147 | % --- Executes on key press over figure1 with no controls selected.
|
---|
148 | function figure1_KeyPressFcn(hObject, eventdata, handles)
|
---|
149 | % Check for "enter" or "escape"
|
---|
150 | if isequal(get(hObject,'CurrentKey'),'escape')
|
---|
151 | % User said no by hitting escape
|
---|
152 | handles.output = 'Cancel';
|
---|
153 |
|
---|
154 | % Update handles structure
|
---|
155 | guidata(hObject, handles);
|
---|
156 |
|
---|
157 | uiresume(handles.figure1);
|
---|
158 | end
|
---|
159 | if isequal(get(hObject,'CurrentKey'),'return')
|
---|
160 | uiresume(handles.figure1);
|
---|
161 | end
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 | function edit5_Callback(hObject, eventdata, handles)
|
---|
166 | % hObject handle to edit5 (see GCBO)
|
---|
167 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
168 | % handles structure with handles and user data (see GUIDATA)
|
---|
169 |
|
---|
170 | % Hints: get(hObject,'String') returns contents of edit5 as text
|
---|
171 | % str2double(get(hObject,'String')) returns contents of edit5 as a double
|
---|
172 |
|
---|
173 |
|
---|
174 |
|
---|
175 | function edit6_Callback(hObject, eventdata, handles)
|
---|
176 | % hObject handle to edit6 (see GCBO)
|
---|
177 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
178 | % handles structure with handles and user data (see GUIDATA)
|
---|
179 |
|
---|
180 | % Hints: get(hObject,'String') returns contents of edit6 as text
|
---|
181 | % str2double(get(hObject,'String')) returns contents of edit6 as a
|
---|
182 | % double
|
---|
183 |
|
---|
184 |
|
---|
185 | function edit7_Callback(hObject, eventdata, handles)
|
---|
186 | % hObject handle to edit7 (see GCBO)
|
---|
187 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
188 | % handles structure with handles and user data (see GUIDATA)
|
---|
189 |
|
---|
190 | % Hints: get(hObject,'String') returns contents of edit7 as text
|
---|
191 | % str2double(get(hObject,'String')) returns contents of edit7 as a double
|
---|
192 |
|
---|
193 |
|
---|
194 | function edit8_Callback(hObject, eventdata, handles)
|
---|
195 | % hObject handle to edit8 (see GCBO)
|
---|
196 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
197 | % handles structure with handles and user data (see GUIDATA)
|
---|
198 |
|
---|
199 | % Hints: get(hObject,'String') returns contents of edit8 as text
|
---|
200 | % str2double(get(hObject,'String')) returns contents of edit8 as a double
|
---|
201 |
|
---|
202 |
|
---|