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 | %=======================================================================
|
---|
14 | % Copyright 2008-2015, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
|
---|
15 | % http://www.legi.grenoble-inp.fr
|
---|
16 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
|
---|
17 | %
|
---|
18 | % This file is part of the toolbox UVMAT.
|
---|
19 | %
|
---|
20 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
21 | % it under the terms of the GNU General Public License as published
|
---|
22 | % by the Free Software Foundation; either version 2 of the license,
|
---|
23 | % or (at your option) any later version.
|
---|
24 | %
|
---|
25 | % UVMAT is distributed in the hope that it will be useful,
|
---|
26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
28 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
29 | %=======================================================================
|
---|
30 |
|
---|
31 | function varargout = rotate_points(varargin)
|
---|
32 |
|
---|
33 | % Begin initialization code - DO NOT EDIT
|
---|
34 | gui_Singleton = 1;
|
---|
35 | gui_State = struct('gui_Name', mfilename, ...
|
---|
36 | 'gui_Singleton', gui_Singleton, ...
|
---|
37 | 'gui_OpeningFcn', @rotate_points_OpeningFcn, ...
|
---|
38 | 'gui_OutputFcn', @rotate_points_OutputFcn, ...
|
---|
39 | 'gui_LayoutFcn', [] , ...
|
---|
40 | 'gui_Callback', []);
|
---|
41 | if nargin && ischar(varargin{1})
|
---|
42 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
43 | end
|
---|
44 |
|
---|
45 | if nargout
|
---|
46 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
---|
47 | else
|
---|
48 | gui_mainfcn(gui_State, varargin{:});
|
---|
49 | end
|
---|
50 | % End initialization code - DO NOT EDIT
|
---|
51 |
|
---|
52 | % --- Executes just before rotate_points is made visible.
|
---|
53 | function rotate_points_OpeningFcn(hObject, eventdata, handles,input_shift)
|
---|
54 | % This function has no output args, see OutputFcn.
|
---|
55 |
|
---|
56 | % Choose default command line output for rotate_points
|
---|
57 | handles.output = 'Cancel';
|
---|
58 |
|
---|
59 | % Update handles structure
|
---|
60 | guidata(hObject, handles);
|
---|
61 | testNo=0;
|
---|
62 | testCancel=1;
|
---|
63 | testinputstring=0;
|
---|
64 | icontype='quest';%default question icon (text input asked)
|
---|
65 |
|
---|
66 | % Determine the position of the dialog - centered on the screen
|
---|
67 | FigPos=get(0,'DefaultFigurePosition');
|
---|
68 | OldUnits = get(hObject, 'Units');
|
---|
69 | set(hObject, 'Units', 'pixels');
|
---|
70 | OldPos = get(hObject,'Position');
|
---|
71 | FigWidth = OldPos(3);
|
---|
72 | FigHeight = OldPos(4);
|
---|
73 | ScreenUnits=get(0,'Units');
|
---|
74 | set(0,'Units','pixels');
|
---|
75 | ScreenSize=get(0,'ScreenSize');
|
---|
76 | set(0,'Units',ScreenUnits);
|
---|
77 |
|
---|
78 | FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
---|
79 | FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
---|
80 | FigPos(3:4)=[FigWidth FigHeight];
|
---|
81 | set(hObject, 'Position', FigPos);
|
---|
82 | set(hObject, 'Units', OldUnits);
|
---|
83 |
|
---|
84 | % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
|
---|
85 | load dialogicons.mat
|
---|
86 | eval(['IconData=' icontype 'IconData;'])
|
---|
87 | eval(['IconCMap=' icontype 'IconMap;'])
|
---|
88 | questIconMap(256,:) = get(handles.figure1, 'Color');
|
---|
89 | Img=image(IconData, 'Parent', handles.axes1);
|
---|
90 | set(handles.figure1, 'Colormap', IconCMap);
|
---|
91 | set(handles.axes1, ...
|
---|
92 | 'Visible', 'off', ...
|
---|
93 | 'YDir' , 'reverse' , ...
|
---|
94 | 'XLim' , get(Img,'XData'), ...
|
---|
95 | 'YLim' , get(Img,'YData') ...
|
---|
96 | );
|
---|
97 |
|
---|
98 | if exist('input_shift','var') && ~isempty(input_shift)
|
---|
99 | set(handles.Phi,'String',num2str(input_shift(1)));
|
---|
100 | if numel(input_shift)>=2
|
---|
101 | set(handles.x_0,'String',num2str(input_shift(2)));
|
---|
102 | end
|
---|
103 | if numel(input_shift)>=3
|
---|
104 | set(handles.y_0,'String',num2str(input_shift(3)));
|
---|
105 | end
|
---|
106 | end
|
---|
107 |
|
---|
108 | set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
|
---|
109 | % UIWAIT makes rotate_points wait for user response (see UIRESUME)
|
---|
110 | uiwait(handles.figure1);
|
---|
111 |
|
---|
112 |
|
---|
113 | % --- Outputs from this function are returned to the command line.
|
---|
114 | function varargout = rotate_points_OutputFcn(hObject, eventdata, handles)
|
---|
115 |
|
---|
116 | % Get default command line output from handles structure
|
---|
117 | varargout{1}=[0 0 0];%default
|
---|
118 | if ~isequal(handles.output,'Cancel')
|
---|
119 | x_shift=str2num(get(handles.Phi,'String'));
|
---|
120 | y_shift=str2num(get(handles.x_0,'String'));
|
---|
121 | z_shift=str2num(get(handles.y_0,'String'));
|
---|
122 | if ~isempty(x_shift)
|
---|
123 | varargout{1}(1)=x_shift;
|
---|
124 | end
|
---|
125 | if ~isempty(y_shift)
|
---|
126 | varargout{1}(2)=y_shift;
|
---|
127 | end
|
---|
128 | if ~isempty(z_shift)
|
---|
129 | varargout{1}(3)=z_shift;
|
---|
130 | end
|
---|
131 | end
|
---|
132 | % The figure can be deleted now
|
---|
133 | delete(handles.figure1);
|
---|
134 |
|
---|
135 | % --- Executes on button press in OK.
|
---|
136 | function OK_Callback(hObject, eventdata, handles)
|
---|
137 | handles.output = get(hObject,'String');
|
---|
138 | guidata(hObject, handles);% Update handles structure
|
---|
139 | uiresume(handles.figure1);
|
---|
140 |
|
---|
141 | % --- Executes on button press in Cancel.
|
---|
142 | function Cancel_Callback(hObject, eventdata, handles)
|
---|
143 | handles.output = get(hObject,'String');
|
---|
144 | %handles.output = 'Cancel'
|
---|
145 | guidata(hObject, handles); % Update handles structure
|
---|
146 | % Use UIRESUME instead of delete because the OutputFcn needs
|
---|
147 | % to get the updated handles structure.
|
---|
148 | uiresume(handles.figure1);
|
---|
149 |
|
---|
150 | % --- Executes when user attempts to close figure1.
|
---|
151 | function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
---|
152 | if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
|
---|
153 | % The GUI is still in UIWAIT, us UIRESUME
|
---|
154 | uiresume(handles.figure1);
|
---|
155 | else
|
---|
156 | % The GUI is no longer waiting, just close it
|
---|
157 | delete(handles.figure1);
|
---|
158 | end
|
---|
159 |
|
---|
160 | % --- Executes on key press over figure1 with no controls selected.
|
---|
161 | function figure1_KeyPressFcn(hObject, eventdata, handles)
|
---|
162 | % Check for "enter" or "escape"
|
---|
163 | if isequal(get(hObject,'CurrentKey'),'escape')
|
---|
164 | % User said no by hitting escape
|
---|
165 | handles.output = 'Cancel';
|
---|
166 |
|
---|
167 | % Update handles structure
|
---|
168 | guidata(hObject, handles);
|
---|
169 |
|
---|
170 | uiresume(handles.figure1);
|
---|
171 | end
|
---|
172 | if isequal(get(hObject,'CurrentKey'),'return')
|
---|
173 | uiresume(handles.figure1);
|
---|
174 | end
|
---|
175 |
|
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|