source: trunk/src/translate_points.m @ 876

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