source: trunk/src/rotate_points.m @ 1062

Last change on this file since 1062 was 1061, checked in by g7moreau, 6 years ago
  • Update copyright to year 2019
File size: 6.0 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
13%=======================================================================
14% Copyright 2008-2019, LEGI UMR 5519 / CNRS UGA 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
31function varargout = rotate_points(varargin)
32
33% Begin initialization code - DO NOT EDIT
34gui_Singleton = 1;
35gui_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',   []);
41if nargin && ischar(varargin{1})
42    gui_State.gui_Callback = str2func(varargin{1});
43end
44
45if nargout
46    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
47else
48    gui_mainfcn(gui_State, varargin{:});
49end
50% End initialization code - DO NOT EDIT
51
52% --- Executes just before rotate_points is made visible.
53function 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
57handles.output = 'Cancel';
58
59% Update handles structure
60guidata(hObject, handles);
61testNo=0;
62testCancel=1;
63testinputstring=0;
64icontype='quest';%default question icon (text input asked)
65
66% Determine the position of the dialog - centered on the screen
67FigPos=get(0,'DefaultFigurePosition');
68OldUnits = get(hObject, 'Units');
69set(hObject, 'Units', 'pixels');
70OldPos = get(hObject,'Position');
71FigWidth = OldPos(3);
72FigHeight = OldPos(4);
73ScreenUnits=get(0,'Units');
74set(0,'Units','pixels');
75ScreenSize=get(0,'ScreenSize');
76set(0,'Units',ScreenUnits);
77
78FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
79FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
80FigPos(3:4)=[FigWidth FigHeight];
81set(hObject, 'Position', FigPos);
82set(hObject, 'Units', OldUnits);
83
84% Show a question icon from dialogicons.mat - variables questIconData and questIconMap
85load dialogicons.mat
86eval(['IconData=' icontype 'IconData;'])
87eval(['IconCMap=' icontype 'IconMap;'])
88questIconMap(256,:) = get(handles.figure1, 'Color');
89Img=image(IconData, 'Parent', handles.axes1);
90set(handles.figure1, 'Colormap', IconCMap);
91set(handles.axes1, ...
92    'Visible', 'off', ...
93    'YDir'   , 'reverse'       , ...
94    'XLim'   , get(Img,'XData'), ...
95    'YLim'   , get(Img,'YData')  ...
96    );
97
98if 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
106end
107
108set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
109% UIWAIT makes rotate_points wait for user response (see UIRESUME)
110uiwait(handles.figure1);
111
112
113% --- Outputs from this function are returned to the command line.
114function varargout = rotate_points_OutputFcn(hObject, eventdata, handles)
115
116% Get default command line output from handles structure
117varargout{1}=[0 0 0];%default
118if ~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
131end
132% The figure can be deleted now
133delete(handles.figure1);
134
135% --- Executes on button press in OK.
136function OK_Callback(hObject, eventdata, handles)
137handles.output = get(hObject,'String');
138guidata(hObject, handles);% Update handles structure
139uiresume(handles.figure1);
140
141% --- Executes on button press in Cancel.
142function Cancel_Callback(hObject, eventdata, handles)
143handles.output = get(hObject,'String');
144%handles.output = 'Cancel'
145guidata(hObject, handles); % Update handles structure
146% Use UIRESUME instead of delete because the OutputFcn needs
147% to get the updated handles structure.
148uiresume(handles.figure1);
149
150% --- Executes when user attempts to close figure1.
151function figure1_CloseRequestFcn(hObject, eventdata, handles)
152if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
153    % The GUI is still in UIWAIT, us UIRESUME
154    uiresume(handles.figure1);
155else
156    % The GUI is no longer waiting, just close it
157    delete(handles.figure1);
158end
159
160% --- Executes on key press over figure1 with no controls selected.
161function figure1_KeyPressFcn(hObject, eventdata, handles)
162% Check for "enter" or "escape"
163if 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);
171end
172if isequal(get(hObject,'CurrentKey'),'return')
173    uiresume(handles.figure1);
174end   
175
176
177
178
179
Note: See TracBrowser for help on using the repository browser.