source: trunk/src/rotate_points.m @ 575

Last change on this file since 575 was 356, checked in by sommeria, 9 years ago

civ updated with new functions for opening files, consistently with uvmat
Bugs to be expected (use previous version then)

File size: 5.1 KB
Line 
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
13function varargout = rotate_points(varargin)
14
15% Begin initialization code - DO NOT EDIT
16gui_Singleton = 1;
17gui_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',   []);
23if nargin && ischar(varargin{1})
24    gui_State.gui_Callback = str2func(varargin{1});
25end
26
27if nargout
28    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
29else
30    gui_mainfcn(gui_State, varargin{:});
31end
32% End initialization code - DO NOT EDIT
33
34% --- Executes just before rotate_points is made visible.
35function 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
39handles.output = 'Cancel';
40
41% Update handles structure
42guidata(hObject, handles);
43testNo=0;
44testCancel=1;
45testinputstring=0;
46icontype='quest';%default question icon (text input asked)
47
48% Determine the position of the dialog - centered on the screen
49FigPos=get(0,'DefaultFigurePosition');
50OldUnits = get(hObject, 'Units');
51set(hObject, 'Units', 'pixels');
52OldPos = get(hObject,'Position');
53FigWidth = OldPos(3);
54FigHeight = OldPos(4);
55ScreenUnits=get(0,'Units');
56set(0,'Units','pixels');
57ScreenSize=get(0,'ScreenSize');
58set(0,'Units',ScreenUnits);
59
60FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
61FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
62FigPos(3:4)=[FigWidth FigHeight];
63set(hObject, 'Position', FigPos);
64set(hObject, 'Units', OldUnits);
65
66% Show a question icon from dialogicons.mat - variables questIconData and questIconMap
67load dialogicons.mat
68eval(['IconData=' icontype 'IconData;'])
69eval(['IconCMap=' icontype 'IconMap;'])
70questIconMap(256,:) = get(handles.figure1, 'Color');
71Img=image(IconData, 'Parent', handles.axes1);
72set(handles.figure1, 'Colormap', IconCMap);
73set(handles.axes1, ...
74    'Visible', 'off', ...
75    'YDir'   , 'reverse'       , ...
76    'XLim'   , get(Img,'XData'), ...
77    'YLim'   , get(Img,'YData')  ...
78    );
79
80if 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
88end
89
90set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
91% UIWAIT makes rotate_points wait for user response (see UIRESUME)
92uiwait(handles.figure1);
93
94
95% --- Outputs from this function are returned to the command line.
96function varargout = rotate_points_OutputFcn(hObject, eventdata, handles)
97
98% Get default command line output from handles structure
99varargout{1}=[0 0 0];%default
100if ~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
113end
114% The figure can be deleted now
115delete(handles.figure1);
116
117% --- Executes on button press in OK.
118function OK_Callback(hObject, eventdata, handles)
119handles.output = get(hObject,'String');
120guidata(hObject, handles);% Update handles structure
121uiresume(handles.figure1);
122
123% --- Executes on button press in Cancel.
124function Cancel_Callback(hObject, eventdata, handles)
125handles.output = get(hObject,'String');
126%handles.output = 'Cancel'
127guidata(hObject, handles); % Update handles structure
128% Use UIRESUME instead of delete because the OutputFcn needs
129% to get the updated handles structure.
130uiresume(handles.figure1);
131
132% --- Executes when user attempts to close figure1.
133function figure1_CloseRequestFcn(hObject, eventdata, handles)
134if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
135    % The GUI is still in UIWAIT, us UIRESUME
136    uiresume(handles.figure1);
137else
138    % The GUI is no longer waiting, just close it
139    delete(handles.figure1);
140end
141
142% --- Executes on key press over figure1 with no controls selected.
143function figure1_KeyPressFcn(hObject, eventdata, handles)
144% Check for "enter" or "escape"
145if 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);
153end
154if isequal(get(hObject,'CurrentKey'),'return')
155    uiresume(handles.figure1);
156end   
157
158
159
160
161
Note: See TracBrowser for help on using the repository browser.