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