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 |
|
---|
40 | % --- Executes just before translate_points is made visible.
|
---|
41 | function translate_points_OpeningFcn(hObject, eventdata, handles,input_shift)
|
---|
42 | % This function has no output args, see OutputFcn.
|
---|
43 |
|
---|
44 | % Choose default command line output for translate_points
|
---|
45 | handles.output = 'Cancel';
|
---|
46 |
|
---|
47 | % Update handles structure
|
---|
48 | guidata(hObject, handles);
|
---|
49 | testNo=0;
|
---|
50 | testCancel=1;
|
---|
51 | testinputstring=0;
|
---|
52 | icontype='quest';%default question icon (text input asked)
|
---|
53 |
|
---|
54 | % Determine the position of the dialog - centered on the screen
|
---|
55 | FigPos=get(0,'DefaultFigurePosition');
|
---|
56 | OldUnits = get(hObject, 'Units');
|
---|
57 | set(hObject, 'Units', 'pixels');
|
---|
58 | OldPos = get(hObject,'Position');
|
---|
59 | FigWidth = OldPos(3);
|
---|
60 | FigHeight = OldPos(4);
|
---|
61 | ScreenUnits=get(0,'Units');
|
---|
62 | set(0,'Units','pixels');
|
---|
63 | ScreenSize=get(0,'ScreenSize');
|
---|
64 | set(0,'Units',ScreenUnits);
|
---|
65 |
|
---|
66 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
---|
67 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
---|
68 | FigPos(3:4)=[FigWidth FigHeight];
|
---|
69 | set(hObject, 'Position', FigPos);
|
---|
70 | set(hObject, 'Units', OldUnits);
|
---|
71 |
|
---|
72 | % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
|
---|
73 | load dialogicons.mat
|
---|
74 | eval(['IconData=' icontype 'IconData;'])
|
---|
75 | eval(['IconCMap=' icontype 'IconMap;'])
|
---|
76 | questIconMap(256,:) = get(handles.figure1, 'Color');
|
---|
77 | Img=image(IconData, 'Parent', handles.axes1);
|
---|
78 | set(handles.figure1, 'Colormap', IconCMap);
|
---|
79 | set(handles.axes1, ...
|
---|
80 | 'Visible', 'off', ...
|
---|
81 | 'YDir' , 'reverse' , ...
|
---|
82 | 'XLim' , get(Img,'XData'), ...
|
---|
83 | 'YLim' , get(Img,'YData') ...
|
---|
84 | );
|
---|
85 |
|
---|
86 | if exist('input_shift','var') && ~isempty(input_shift)
|
---|
87 | set(handles.x_shift,'String',num2str(input_shift(1)));
|
---|
88 | if numel(input_shift)>=2
|
---|
89 | set(handles.y_shift,'String',num2str(input_shift(2)));
|
---|
90 | end
|
---|
91 | if numel(input_shift)>=3
|
---|
92 | set(handles.z_shift,'String',num2str(input_shift(3)));
|
---|
93 | end
|
---|
94 | end
|
---|
95 |
|
---|
96 | set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
|
---|
97 | % UIWAIT makes translate_points wait for user response (see UIRESUME)
|
---|
98 | uiwait(handles.figure1);
|
---|
99 |
|
---|
100 |
|
---|
101 | % --- Outputs from this function are returned to the command line.
|
---|
102 | function varargout = translate_points_OutputFcn(hObject, eventdata, handles)
|
---|
103 |
|
---|
104 | % Get default command line output from handles structure
|
---|
105 | varargout{1}=[0 0 0];%default
|
---|
106 | if ~isequal(handles.output,'Cancel')
|
---|
107 | x_shift=str2num(get(handles.x_shift,'String'));
|
---|
108 | y_shift=str2num(get(handles.y_shift,'String'));
|
---|
109 | z_shift=str2num(get(handles.z_shift,'String'));
|
---|
110 | if ~isempty(x_shift)
|
---|
111 | varargout{1}(1)=x_shift;
|
---|
112 | end
|
---|
113 | if ~isempty(y_shift)
|
---|
114 | varargout{1}(2)=y_shift;
|
---|
115 | end
|
---|
116 | if ~isempty(z_shift)
|
---|
117 | varargout{1}(3)=z_shift;
|
---|
118 | end
|
---|
119 | end
|
---|
120 | % The figure can be deleted now
|
---|
121 | delete(handles.figure1);
|
---|
122 |
|
---|
123 | % --- Executes on button press in OK.
|
---|
124 | function OK_Callback(hObject, eventdata, handles)
|
---|
125 | handles.output = get(hObject,'String');
|
---|
126 | guidata(hObject, handles);% Update handles structure
|
---|
127 | uiresume(handles.figure1);
|
---|
128 |
|
---|
129 | % --- Executes on button press in Cancel.
|
---|
130 | function Cancel_Callback(hObject, eventdata, handles)
|
---|
131 | handles.output = get(hObject,'String');
|
---|
132 | guidata(hObject, handles); % Update handles structure
|
---|
133 | uiresume(handles.figure1);
|
---|
134 |
|
---|
135 | % --- Executes when user attempts to close figure1.
|
---|
136 | function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
---|
137 | if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
|
---|
138 | % The GUI is still in UIWAIT, us UIRESUME
|
---|
139 | uiresume(handles.figure1);
|
---|
140 | else
|
---|
141 | % The GUI is no longer waiting, just close it
|
---|
142 | delete(handles.figure1);
|
---|
143 | end
|
---|
144 |
|
---|
145 | % --- Executes on key press over figure1 with no controls selected.
|
---|
146 | function figure1_KeyPressFcn(hObject, eventdata, handles)
|
---|
147 | % Check for "enter" or "escape"
|
---|
148 | if isequal(get(hObject,'CurrentKey'),'escape')
|
---|
149 | % User said no by hitting escape
|
---|
150 | handles.output = 'Cancel';
|
---|
151 |
|
---|
152 | % Update handles structure
|
---|
153 | guidata(hObject, handles);
|
---|
154 |
|
---|
155 | uiresume(handles.figure1);
|
---|
156 | end
|
---|
157 | if isequal(get(hObject,'CurrentKey'),'return')
|
---|
158 | uiresume(handles.figure1);
|
---|
159 | end
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|