1 | %'translate_points': associated with GUI translate_points.fig to display translation parameters
|
---|
2 | %------------------------------------------------------------------------
|
---|
3 | % function T=translate_points(Tinput)
|
---|
4 | %------------------------------------------------------------------------
|
---|
5 | % OUTPUT:
|
---|
6 | % T=vector size(1,3), representing the translation components along x,y,z
|
---|
7 |
|
---|
8 | %INPUT:
|
---|
9 | % Tinput: like T, used to prefil the GUI edit boxs
|
---|
10 |
|
---|
11 | function varargout = translate_points(varargin)
|
---|
12 |
|
---|
13 | % Begin initialization code - DO NOT EDIT
|
---|
14 | gui_Singleton = 1;
|
---|
15 | gui_State = struct('gui_Name', mfilename, ...
|
---|
16 | 'gui_Singleton', gui_Singleton, ...
|
---|
17 | 'gui_OpeningFcn', @translate_points_OpeningFcn, ...
|
---|
18 | 'gui_OutputFcn', @translate_points_OutputFcn, ...
|
---|
19 | 'gui_LayoutFcn', [] , ...
|
---|
20 | 'gui_Callback', []);
|
---|
21 | if nargin && ischar(varargin{1})
|
---|
22 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
23 | end
|
---|
24 |
|
---|
25 | if nargout
|
---|
26 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
27 | else
|
---|
28 | gui_mainfcn(gui_State, varargin{:});
|
---|
29 | end
|
---|
30 | % End initialization code - DO NOT EDIT
|
---|
31 |
|
---|
32 |
|
---|
33 | % --- Executes just before translate_points is made visible.
|
---|
34 | function translate_points_OpeningFcn(hObject, eventdata, handles,input_shift)
|
---|
35 | % This function has no output args, see OutputFcn.
|
---|
36 |
|
---|
37 | % Choose default command line output for translate_points
|
---|
38 | handles.output = 'Cancel';
|
---|
39 |
|
---|
40 | % Update handles structure
|
---|
41 | guidata(hObject, handles);
|
---|
42 | testNo=0;
|
---|
43 | testCancel=1;
|
---|
44 | testinputstring=0;
|
---|
45 | icontype='quest';%default question icon (text input asked)
|
---|
46 |
|
---|
47 | % Determine the position of the dialog - centered on the screen
|
---|
48 | FigPos=get(0,'DefaultFigurePosition');
|
---|
49 | OldUnits = get(hObject, 'Units');
|
---|
50 | set(hObject, 'Units', 'pixels');
|
---|
51 | OldPos = get(hObject,'Position');
|
---|
52 | FigWidth = OldPos(3);
|
---|
53 | FigHeight = OldPos(4);
|
---|
54 | ScreenUnits=get(0,'Units');
|
---|
55 | set(0,'Units','pixels');
|
---|
56 | ScreenSize=get(0,'ScreenSize');
|
---|
57 | set(0,'Units',ScreenUnits);
|
---|
58 |
|
---|
59 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
---|
60 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
---|
61 | FigPos(3:4)=[FigWidth FigHeight];
|
---|
62 | set(hObject, 'Position', FigPos);
|
---|
63 | set(hObject, 'Units', OldUnits);
|
---|
64 |
|
---|
65 | % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
|
---|
66 | load dialogicons.mat
|
---|
67 | eval(['IconData=' icontype 'IconData;'])
|
---|
68 | eval(['IconCMap=' icontype 'IconMap;'])
|
---|
69 | questIconMap(256,:) = get(handles.figure1, 'Color');
|
---|
70 | Img=image(IconData, 'Parent', handles.axes1);
|
---|
71 | set(handles.figure1, 'Colormap', IconCMap);
|
---|
72 | set(handles.axes1, ...
|
---|
73 | 'Visible', 'off', ...
|
---|
74 | 'YDir' , 'reverse' , ...
|
---|
75 | 'XLim' , get(Img,'XData'), ...
|
---|
76 | 'YLim' , get(Img,'YData') ...
|
---|
77 | );
|
---|
78 |
|
---|
79 | if exist('input_shift','var') && ~isempty(input_shift)
|
---|
80 | set(handles.x_shift,'String',num2str(input_shift(1)));
|
---|
81 | if numel(input_shift)>=2
|
---|
82 | set(handles.y_shift,'String',num2str(input_shift(2)));
|
---|
83 | end
|
---|
84 | if numel(input_shift)>=3
|
---|
85 | set(handles.z_shift,'String',num2str(input_shift(3)));
|
---|
86 | end
|
---|
87 | end
|
---|
88 |
|
---|
89 | set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
|
---|
90 | % UIWAIT makes translate_points wait for user response (see UIRESUME)
|
---|
91 | uiwait(handles.figure1);
|
---|
92 |
|
---|
93 |
|
---|
94 | % --- Outputs from this function are returned to the command line.
|
---|
95 | function varargout = translate_points_OutputFcn(hObject, eventdata, handles)
|
---|
96 |
|
---|
97 | % Get default command line output from handles structure
|
---|
98 | varargout{1}=[0 0 0];%default
|
---|
99 | if ~isequal(handles.output,'Cancel')
|
---|
100 | x_shift=str2num(get(handles.x_shift,'String'));
|
---|
101 | y_shift=str2num(get(handles.y_shift,'String'));
|
---|
102 | z_shift=str2num(get(handles.z_shift,'String'));
|
---|
103 | if ~isempty(x_shift)
|
---|
104 | varargout{1}(1)=x_shift;
|
---|
105 | end
|
---|
106 | if ~isempty(y_shift)
|
---|
107 | varargout{1}(2)=y_shift;
|
---|
108 | end
|
---|
109 | if ~isempty(z_shift)
|
---|
110 | varargout{1}(3)=z_shift;
|
---|
111 | end
|
---|
112 | end
|
---|
113 | % The figure can be deleted now
|
---|
114 | delete(handles.figure1);
|
---|
115 |
|
---|
116 | % --- Executes on button press in OK.
|
---|
117 | function OK_Callback(hObject, eventdata, handles)
|
---|
118 | handles.output = get(hObject,'String');
|
---|
119 | guidata(hObject, handles);% Update handles structure
|
---|
120 | uiresume(handles.figure1);
|
---|
121 |
|
---|
122 | % --- Executes on button press in Cancel.
|
---|
123 | function Cancel_Callback(hObject, eventdata, handles)
|
---|
124 | handles.output = get(hObject,'String');
|
---|
125 | guidata(hObject, handles); % Update handles structure
|
---|
126 | uiresume(handles.figure1);
|
---|
127 |
|
---|
128 | % --- Executes when user attempts to close figure1.
|
---|
129 | function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
---|
130 | if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
|
---|
131 | % The GUI is still in UIWAIT, us UIRESUME
|
---|
132 | uiresume(handles.figure1);
|
---|
133 | else
|
---|
134 | % The GUI is no longer waiting, just close it
|
---|
135 | delete(handles.figure1);
|
---|
136 | end
|
---|
137 |
|
---|
138 | % --- Executes on key press over figure1 with no controls selected.
|
---|
139 | function figure1_KeyPressFcn(hObject, eventdata, handles)
|
---|
140 | % Check for "enter" or "escape"
|
---|
141 | if isequal(get(hObject,'CurrentKey'),'escape')
|
---|
142 | % User said no by hitting escape
|
---|
143 | handles.output = 'Cancel';
|
---|
144 |
|
---|
145 | % Update handles structure
|
---|
146 | guidata(hObject, handles);
|
---|
147 |
|
---|
148 | uiresume(handles.figure1);
|
---|
149 | end
|
---|
150 | if isequal(get(hObject,'CurrentKey'),'return')
|
---|
151 | uiresume(handles.figure1);
|
---|
152 | end
|
---|
153 |
|
---|
154 |
|
---|
155 |
|
---|