1 | %'set_object': GUI to edit a projection object |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function hset_object= set_object(data, PlotHandles,ZBounds) |
---|
4 | % associated with the GUI set_object.fig |
---|
5 | % |
---|
6 | % OUTPUT: |
---|
7 | % hset_object: handle of the GUI figure |
---|
8 | % |
---|
9 | % INPUT:u |
---|
10 | % data: structure describing the object properties |
---|
11 | % .Style=... |
---|
12 | % .ProjMode |
---|
13 | % .CoordType: 'phys' or 'px' |
---|
14 | % .num_DX,.num_DY,.num_DZ : mesh along each dirction |
---|
15 | % .RangeX, RangeY |
---|
16 | % .Coord(j,i), i=1, 2, 3, components x, y, z of j=1...n position(s) characterizing the object components |
---|
17 | % PlotHandles: handles for projection plots NO MORE USED |
---|
18 | % Zbounds: bounds on Z ( 3D case) |
---|
19 | |
---|
20 | %======================================================================= |
---|
21 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
22 | % http://www.legi.grenoble-inp.fr |
---|
23 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr |
---|
24 | % |
---|
25 | % This file is part of the toolbox UVMAT. |
---|
26 | % |
---|
27 | % UVMAT is free software; you can redistribute it and/or modify |
---|
28 | % it under the terms of the GNU General Public License as published |
---|
29 | % by the Free Software Foundation; either version 2 of the license, |
---|
30 | % or (at your option) any later version. |
---|
31 | % |
---|
32 | % UVMAT is distributed in the hope that it will be useful, |
---|
33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
35 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
36 | %======================================================================= |
---|
37 | |
---|
38 | function varargout = set_object(varargin) |
---|
39 | |
---|
40 | % Last Modified by GUIDE v2.5 01-Apr-2020 22:25:49 |
---|
41 | |
---|
42 | % Begin initialization code - DO NOT REFRESH |
---|
43 | gui_Singleton = 1; |
---|
44 | gui_State = struct('gui_Name', mfilename, ... |
---|
45 | 'gui_Singleton', gui_Singleton, ... |
---|
46 | 'gui_OpeningFcn', @set_object_OpeningFcn, ... |
---|
47 | 'gui_OutputFcn', @set_object_OutputFcn, ... |
---|
48 | 'gui_LayoutFcn', [] , ... |
---|
49 | 'gui_Callback', []); |
---|
50 | if nargin & ischar(varargin{1}) |
---|
51 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
52 | end |
---|
53 | |
---|
54 | if nargout |
---|
55 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
56 | else |
---|
57 | gui_mainfcn(gui_State, varargin{:}); |
---|
58 | end |
---|
59 | % End initialization code - DO NOT REFRESH |
---|
60 | %------------------------------------------------------------------------ |
---|
61 | %------------------------------------------------------------------------ |
---|
62 | % --- Executes just before set_object is made visible. |
---|
63 | %INPUT: |
---|
64 | % handles: handles of the set_object interface elements |
---|
65 | %'IndexObj': NON USED ANYMORE (To suppress) index of the object (on the UvData list) that set_object will modify |
---|
66 | % if =[] or absent: index still undefined (create mode in uvmat) |
---|
67 | % if=0; no associated object (used for series), the button 'REFRESH' is then unvisible |
---|
68 | %'data': read from an existing object selected in the interface |
---|
69 | % .Name : class of object ('POINTS','LINE',....) |
---|
70 | % .num_DX,num_DY,num_DZ; meshes for regular grids |
---|
71 | % .Coord: object position coordinates |
---|
72 | % .ParentButton: handle of the uicontrol object calling the interface |
---|
73 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
---|
74 | % if =[] or absent, no refresh (mask mode in uvmat) |
---|
75 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
---|
76 | function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds) |
---|
77 | %------------------------------------------------------------------- |
---|
78 | % Choose default command line output for set_object |
---|
79 | handles.output = hObject; |
---|
80 | % Update handles structure |
---|
81 | guidata(hObject, handles); |
---|
82 | |
---|
83 | %% position |
---|
84 | set(0,'Unit','pixels') |
---|
85 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
86 | PosGUI=get(handles.set_object,'Position');% fig width in pixels |
---|
87 | Width=PosGUI(3);%width of the gui set_object in pixels |
---|
88 | Height=PosGUI(4); |
---|
89 | Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 |
---|
90 | Bottom=ScreenSize(4)-Height-40; %put fig at top right |
---|
91 | set(handles.set_object,'Unit','pixels') |
---|
92 | set(handles.set_object,'Position',[Left Bottom Width Height]) |
---|
93 | |
---|
94 | %default |
---|
95 | if ~exist('ZBounds','var') |
---|
96 | ZBounds=0; %default |
---|
97 | end |
---|
98 | test3D=(ZBounds~=0); % =1 for 3D fleds |
---|
99 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
100 | set(hObject,'DeleteFcn',{@closefcn}) |
---|
101 | |
---|
102 | % fill the interface as set in the input data: |
---|
103 | if exist('data','var') |
---|
104 | if isfield(data,'Coord') |
---|
105 | set(handles.Coord,'Data',data.Coord) |
---|
106 | if size(data.Coord,2)==3 |
---|
107 | set(handles.z_slider,'Visible','on') |
---|
108 | end |
---|
109 | else |
---|
110 | set(handles.z_slider,'Visible','off') |
---|
111 | end |
---|
112 | if isfield(data,'TypeMenu') |
---|
113 | set(handles.Type,'String',data.TypeMenu) |
---|
114 | end |
---|
115 | if isfield(data,'ProjModeMenu') |
---|
116 | set(handles.ProjMode,'UserData',data.ProjModeMenu)% data.ProjModeMenu as default menu (used in Type_Callback) |
---|
117 | end |
---|
118 | errormsg=fill_GUI(data,handles.set_object); |
---|
119 | if ~isempty(errormsg) |
---|
120 | msgbox_uvmat('ERROR','bad data input in set_object') |
---|
121 | return |
---|
122 | end |
---|
123 | Type_Callback(hObject, eventdata, handles)% update the GUI set_object depending on the object type |
---|
124 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
125 | if isfield(data,'RangeZ') |
---|
126 | set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3)) |
---|
127 | if length(ZBounds) >= 2 |
---|
128 | DZ=max(data.RangeZ);%slider step |
---|
129 | if ~isnan(ZBounds(1)) && ZBounds(2)~=ZBounds(1) |
---|
130 | rel_step(1)=min(DZ/(ZBounds(2)-ZBounds(1)),0.2);%must be smaller than 1 |
---|
131 | rel_step(2)=0.1; |
---|
132 | set(handles.z_slider,'Visible','on') |
---|
133 | set(handles.z_slider,'Min',ZBounds(1)) |
---|
134 | set(handles.z_slider,'Max',ZBounds(2)) |
---|
135 | set(handles.z_slider,'SliderStep',rel_step) |
---|
136 | set(handles.z_slider,'Value',(ZBounds(1)+ZBounds(2))/2) |
---|
137 | end |
---|
138 | end |
---|
139 | end |
---|
140 | if isfield(data,'RangeX') |
---|
141 | if ischar(data.RangeX) |
---|
142 | data.RangeX=str2num(data.RangeX); |
---|
143 | end |
---|
144 | set(handles.num_RangeX_2,'String',num2str(max(data.RangeX),3)) |
---|
145 | set(handles.num_RangeX_1,'String',num2str(min(data.RangeX),3)) |
---|
146 | end |
---|
147 | if isfield(data,'RangeY')&& ~strcmp(data.Type,'plane_z')%TODO: generalise |
---|
148 | if ischar(data.RangeY) |
---|
149 | data.RangeY=str2num(data.RangeY); |
---|
150 | end |
---|
151 | set(handles.num_RangeY_2,'String',num2str(max(data.RangeY),3)) |
---|
152 | set(handles.num_RangeY_1,'String',num2str(min(data.RangeY),3)) |
---|
153 | end |
---|
154 | if isfield(data,'RangeZ')%&& ~strcmp(data.Type,'plane_z')%TODO: generalise |
---|
155 | if ischar(data.RangeZ) |
---|
156 | data.RangeZ=str2num(data.RangeZ); |
---|
157 | end |
---|
158 | set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3)) |
---|
159 | if numel(data.RangeZ)>=2 |
---|
160 | set(handles.num_RangeZ_1,'String',num2str(min(data.RangeZ),3)) |
---|
161 | end |
---|
162 | end |
---|
163 | if ~(isfield(data,'Angle') && size(data.Angle,2)==3) |
---|
164 | data.Angle=[0 0 0]; |
---|
165 | end |
---|
166 | set(handles.num_Angle_1,'String',num2str(data.Angle(1))) |
---|
167 | set(handles.num_Angle_2,'String',num2str(data.Angle(2))) |
---|
168 | set(handles.num_Angle_3,'String',num2str(data.Angle(3))) |
---|
169 | if test3D |
---|
170 | set(handles.num_Angle_1,'Visible','on') |
---|
171 | set(handles.num_Angle_2,'Visible','on') |
---|
172 | end |
---|
173 | end |
---|
174 | set(get(handles.set_object,'children'),'enable','off') |
---|
175 | set(handles.SAVE,'enable','on') |
---|
176 | |
---|
177 | |
---|
178 | %------------------------------------------------------------------------ |
---|
179 | % --- Outputs from this function are returned to the command line. |
---|
180 | function varargout = set_object_OutputFcn(hObject, eventdata, handles) |
---|
181 | %------------------------------------------------------------------------ |
---|
182 | % Get default command line output from handles structure |
---|
183 | varargout{1} = handles.output; |
---|
184 | varargout{2}=handles; |
---|
185 | |
---|
186 | %------------------------------------------------------------------------ |
---|
187 | % executed when closing the GUI set_object |
---|
188 | function closefcn(gcbo,eventdata) |
---|
189 | %------------------------------------------------------------------------ |
---|
190 | huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle |
---|
191 | if ~isempty(huvmat) |
---|
192 | hhuvmat=guidata(huvmat); |
---|
193 | set(hhuvmat.CheckViewObject,'value',0)% |
---|
194 | set(hhuvmat.CheckEditObject,'Value',0)% desactivate the edit option |
---|
195 | % deselect the object in ListObject when view_field is closed |
---|
196 | if isempty(findobj(allchild(0),'Tag','view_field')) |
---|
197 | ObjIndex=get(hhuvmat.ListObject,'Value'); |
---|
198 | ObjIndex=ObjIndex(1);%keep only the first object selected |
---|
199 | set(hhuvmat.ListObject,'Value',ObjIndex) |
---|
200 | % draw all object colors in blue (unselected) in uvmat |
---|
201 | hother=[findobj(hhuvmat.PlotAxes,'Tag','proj_object');findobj(hhuvmat.PlotAxes,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
202 | for iobj=1:length(hother) |
---|
203 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
204 | set(hother(iobj),'EdgeColor','b') |
---|
205 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
206 | set(hother(iobj),'FaceColor','b') |
---|
207 | end |
---|
208 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
209 | Acolor=get(hother(iobj),'CData'); |
---|
210 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
211 | set(hother(iobj),'CData',Acolor); |
---|
212 | else |
---|
213 | set(hother(iobj),'Color','b') |
---|
214 | end |
---|
215 | set(hother(iobj),'Selected','off') |
---|
216 | end |
---|
217 | end |
---|
218 | end |
---|
219 | hseries=findobj(allchild(0),'Name','series');%find the current series interface handle |
---|
220 | if ~isempty(hseries) |
---|
221 | hhseries=guidata(hseries); |
---|
222 | set(hhseries.EditObject,'Value',0) |
---|
223 | end |
---|
224 | |
---|
225 | |
---|
226 | %------------------------------------------------------------------------ |
---|
227 | % --- Executes on selection change in Type. |
---|
228 | function Type_Callback(hObject, eventdata, handles) |
---|
229 | %------------------------------------------------------------------------ |
---|
230 | |
---|
231 | ListType=get(handles.Type,'String'); |
---|
232 | Type=ListType{get(handles.Type,'Value')}; |
---|
233 | % make correspondance between different object styles |
---|
234 | Coord=get(handles.Coord,'Data'); |
---|
235 | |
---|
236 | %% set the number of lines in the Coord table depending on object type |
---|
237 | switch Type |
---|
238 | case {'line'} |
---|
239 | if size(Coord,1)<2 |
---|
240 | if isequal(size(Coord,2),3) |
---|
241 | Coord=[Coord; 0 0 0];%add a line for edition (3D case) |
---|
242 | else |
---|
243 | Coord=[Coord; 0 0]; %add a line for edition (2D case) |
---|
244 | end |
---|
245 | else |
---|
246 | Coord=Coord(1:2,:); |
---|
247 | end |
---|
248 | case {'rectangle','ellipse','plane','volume'} |
---|
249 | if ~isempty(Coord) |
---|
250 | Coord=Coord(1,:); |
---|
251 | end |
---|
252 | end |
---|
253 | set(handles.Coord,'Data',Coord) |
---|
254 | |
---|
255 | %% set the projection menu and the corresponding options |
---|
256 | if isempty(get(handles.ProjMode,'UserData')) |
---|
257 | switch Type |
---|
258 | case 'polyline' |
---|
259 | menu_proj={'interp_lin';'interp_tps';'none'}; |
---|
260 | case {'polygon','rectangle','ellipse'} |
---|
261 | menu_proj={'inside';'outside';'mask_inside';'mask_outside';'interp_lin';'interp_tps';'none'}; |
---|
262 | case 'volume' |
---|
263 | menu_proj={'interp_lin';'none'}; |
---|
264 | otherwise |
---|
265 | menu_proj={'projection';'interp_lin';'interp_tps';'none'};%default |
---|
266 | end |
---|
267 | else |
---|
268 | menu_proj=get(handles.ProjMode,'UserData'); |
---|
269 | end |
---|
270 | ProjModeList=get(handles.ProjMode,'String'); |
---|
271 | menu_index=find(strcmp(ProjModeList{get(handles.ProjMode,'Value')},menu_proj)); |
---|
272 | if isempty(menu_index) |
---|
273 | menu_index=1;% |
---|
274 | end |
---|
275 | set(handles.ProjMode,'Value',menu_index);% value index must not exceed the menu length |
---|
276 | set(handles.ProjMode,'String',menu_proj) |
---|
277 | ProjMode_Callback(hObject, eventdata, handles) |
---|
278 | |
---|
279 | %------------------------------------------------------------------------ |
---|
280 | % --- Executes on selection change in ProjMode. |
---|
281 | %------------------------------------------------------------------------ |
---|
282 | function ProjMode_Callback(hObject, eventdata, handles) |
---|
283 | |
---|
284 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
285 | menu=get(handles.ProjMode,'String'); |
---|
286 | value=get(handles.ProjMode,'Value'); |
---|
287 | ProjMode=menu{value}; |
---|
288 | menu=get(handles.Type,'String'); |
---|
289 | value=get(handles.Type,'Value'); |
---|
290 | ObjectStyle=menu{value}; |
---|
291 | |
---|
292 | %default setting |
---|
293 | % set(handles.num_Angle_1,'Visible','off') |
---|
294 | % set(handles.num_Angle_2,'Visible','off') |
---|
295 | % set(handles.num_Angle_3,'Visible','off') |
---|
296 | set(handles.num_RangeX_1,'Visible','off') |
---|
297 | set(handles.num_RangeY_1,'Visible','off') |
---|
298 | |
---|
299 | set(handles.num_RangeZ_1,'Visible','off') |
---|
300 | set(handles.num_RangeZ_2,'Visible','off') |
---|
301 | set(handles.num_DX,'Visible','off') |
---|
302 | set(handles.num_DY,'Visible','off') |
---|
303 | set(handles.num_DZ,'Visible','off') |
---|
304 | %default |
---|
305 | set(handles.num_RangeX_2,'Visible','off') |
---|
306 | set(handles.num_RangeY_2,'Visible','off') |
---|
307 | switch ObjectStyle |
---|
308 | case 'points' |
---|
309 | set(handles.num_RangeInterp,'TooltipString','num_RangeY_2: range of projection around each point') |
---|
310 | % set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points') |
---|
311 | % set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points') |
---|
312 | % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points') |
---|
313 | case {'line','polyline','polygon'} |
---|
314 | set(handles.num_RangeX_2,'Visible','off') |
---|
315 | set(handles.num_RangeY_2,'Visible','off') |
---|
316 | %set(handles.num_RangeY_2,'TooltipString','num_RangeY_2: range of projection around the line') |
---|
317 | set(handles.Coord,'TooltipString','Coord: table of x,y, z coordinates defining the line') |
---|
318 | % set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') |
---|
319 | % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line') |
---|
320 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
321 | set(handles.num_DX,'Visible','on') |
---|
322 | set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line') |
---|
323 | set(handles.num_RangeInterp,'Visible','on') |
---|
324 | end |
---|
325 | case {'rectangle','ellipse'} |
---|
326 | set(handles.num_RangeX_2,'Visible','on') |
---|
327 | set(handles.num_RangeY_2,'Visible','on') |
---|
328 | set(handles.num_RangeX_2,'TooltipString',['num_RangeX_2: half length of the ' ObjectStyle]) |
---|
329 | set(handles.num_RangeY_2,'TooltipString',['num_RangeY_2: half width of the ' ObjectStyle]) |
---|
330 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
331 | set(handles.num_DX,'Visible','on') |
---|
332 | set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line') |
---|
333 | set(handles.num_RangeInterp,'Visible','on') |
---|
334 | end |
---|
335 | case {'plane'} |
---|
336 | set(handles.num_Angle_3,'Visible','on') |
---|
337 | set(handles.num_RangeX_1,'Visible','on') |
---|
338 | set(handles.num_RangeX_2,'Visible','on') |
---|
339 | set(handles.num_RangeY_1,'Visible','on') |
---|
340 | set(handles.num_RangeY_2,'Visible','on') |
---|
341 | set(handles.num_RangeZ_2,'TooltipString','num_ZMax: range of projection normal to the plane') |
---|
342 | % if test3D |
---|
343 | % set(handles.num_Angle_2,'Visible','on') |
---|
344 | % set(handles.num_Angle_1,'Visible','on') |
---|
345 | % %set(handles.num_Angle_1,'String','90') |
---|
346 | % %set(handles.Coord,'Data',[0 0 0]) |
---|
347 | % set(handles.num_RangeZ_2,'Visible','on') |
---|
348 | % end |
---|
349 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
350 | set(handles.num_DX,'Visible','on') |
---|
351 | set(handles.num_DY,'Visible','on') |
---|
352 | set(handles.num_RangeInterp,'Visible','on') |
---|
353 | else |
---|
354 | set(handles.num_DX,'Visible','off') |
---|
355 | set(handles.num_DY,'Visible','off') |
---|
356 | end |
---|
357 | % if isequal(ProjMode,'interp_lin') |
---|
358 | % set(handles.num_DZ,'Visible','on') |
---|
359 | % end |
---|
360 | case {'volume'} |
---|
361 | set(handles.num_RangeX_1,'Visible','on') |
---|
362 | set(handles.num_RangeX_2,'Visible','on') |
---|
363 | set(handles.num_RangeY_1,'Visible','on') |
---|
364 | set(handles.num_RangeY_2,'Visible','on') |
---|
365 | % set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) |
---|
366 | % set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) |
---|
367 | set(handles.num_Angle_1,'Visible','on') |
---|
368 | set(handles.num_Angle_2,'Visible','on') |
---|
369 | %set(handles.num_Angle_3,'Visible','on') |
---|
370 | set(handles.num_RangeZ_1,'Visible','on') |
---|
371 | set(handles.num_RangeZ_2,'Visible','on') |
---|
372 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
373 | set(handles.num_DX,'Visible','on') |
---|
374 | set(handles.num_DY,'Visible','on') |
---|
375 | set(handles.num_DZ,'Visible','on') |
---|
376 | else |
---|
377 | set(handles.num_DX,'Visible','off') |
---|
378 | set(handles.num_DY,'Visible','off') |
---|
379 | set(handles.num_DZ,'Visible','off') |
---|
380 | end |
---|
381 | end |
---|
382 | % set default values read in the plot of uvmat to initiate the mesh |
---|
383 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
384 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
385 | if ~isempty(huvmat) |
---|
386 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
387 | if isempty(str2num(get(handles.num_DX,'String')))||isempty(str2num(get(handles.num_DY,'String'))); |
---|
388 | if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) |
---|
389 | set(handles.num_DX,'String',num2str(UvData.Field.CoordMesh)) |
---|
390 | set(handles.num_DY,'String',num2str(UvData.Field.CoordMesh)) |
---|
391 | set(handles.num_RangeX_1,'String',num2str(UvData.Field.XMin)) |
---|
392 | set(handles.num_RangeX_2,'String',num2str(UvData.Field.XMax)) |
---|
393 | set(handles.num_RangeY_1,'String',num2str(UvData.Field.YMin)) |
---|
394 | set(handles.num_RangeY_2,'String',num2str(UvData.Field.YMax)) |
---|
395 | end |
---|
396 | if isempty(get(handles.CoordUnit,'String'))&& isfield(UvData.Field,'CoordUnit') |
---|
397 | set(handles.CoordUnit,'String',UvData.Field.CoordUnit) |
---|
398 | end |
---|
399 | end |
---|
400 | end |
---|
401 | if isempty(str2num(get(handles.num_RangeInterp,'String'))) && isfield(UvData,'Field') |
---|
402 | set(handles.num_RangeInterp,'String',num2str(3*UvData.Field.CoordMesh))% default interpolationlength= 3 meshes |
---|
403 | end |
---|
404 | end |
---|
405 | |
---|
406 | %------------------------------------------------------------------------ |
---|
407 | |
---|
408 | %------------------------------------------------------------------------ |
---|
409 | function num_Angle_1_Callback(hObject, eventdata, handles) |
---|
410 | update_slider(hObject, eventdata,handles) |
---|
411 | %------------------------------------------------------------------------ |
---|
412 | %------------------------------------------------------------------------ |
---|
413 | function num_Angle_2_Callback(hObject, eventdata, handles) |
---|
414 | update_slider(hObject, eventdata,handles) |
---|
415 | %------------------------------------------------------------------------ |
---|
416 | function update_slider(hObject, eventdata,handles) |
---|
417 | %rotation angles |
---|
418 | PlaneAngle(1)=str2num(get(handles.num_Angle_1,'String'));%first angle in degrees |
---|
419 | PlaneAngle(2)=str2num(get(handles.num_Angle_2,'String'));%second angle in degrees |
---|
420 | %PlaneAngle(3)=str2num(get(handles.num_Angle_3,'String'));%second angle in degrees |
---|
421 | % om=norm(PlaneAngle);%norm of rotation angle in radians |
---|
422 | % OmAxis=PlaneAngle/om; %unit vector marking the rotation axis |
---|
423 | cos_om1=cos(pi*PlaneAngle(1)/180); |
---|
424 | sin_om1=sin(pi*PlaneAngle(1)/180); |
---|
425 | cos_om2=cos(pi*PlaneAngle(2)/180); |
---|
426 | sin_om2=sin(pi*PlaneAngle(2)/180); |
---|
427 | %components of the unity vector norm_plane normal to the projection plane |
---|
428 | % norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; |
---|
429 | % norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; |
---|
430 | % norm_plane(3)=OmAxis(3)*coeff+cos_om; |
---|
431 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
432 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
433 | if isfield(UvData,'X') && isfield(UvData,'Y') && isfield(UvData,'Z') |
---|
434 | Z=sin_om2*(cos_om1*(UvData.X)+sin_om1*(UvData.Y))+cos_om2*(UvData.Z); |
---|
435 | set(handles.z_slider,'Min',min(Z)) |
---|
436 | set(handles.z_slider,'Max',max(Z)) |
---|
437 | ZMax_Callback(hObject, eventdata, handles) |
---|
438 | end |
---|
439 | %------------------------------------------------------------------------ |
---|
440 | function num_DX_Callback(hObject, eventdata, handles) |
---|
441 | %------------------------------------------------------------------------ |
---|
442 | %------------------------------------------------------------------------ |
---|
443 | function num_DY_Callback(hObject, eventdata, handles) |
---|
444 | %------------------------------------------------------------------------ |
---|
445 | %------------------------------------------------------------------------ |
---|
446 | function num_DZ_Callback(hObject, eventdata, handles) |
---|
447 | %------------------------------------------------------------------------ |
---|
448 | |
---|
449 | |
---|
450 | %------------------------------------------------------------------------ |
---|
451 | % --- Executes on button press in REFRESH: refresh the current object , refresh the object and its projected field |
---|
452 | %------------------------------------------------------------------------ |
---|
453 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
454 | |
---|
455 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% indicate activation of REFRESH |
---|
456 | drawnow |
---|
457 | |
---|
458 | %% update the object in the GUI series if relevant |
---|
459 | if strcmp(get(handles.set_object,'Name'),'edit_object_series') |
---|
460 | hseries=findobj(allchild(0),'Tag','series'); |
---|
461 | if ~isempty(hseries) |
---|
462 | SeriesData=get(hseries,'UserData'); |
---|
463 | SeriesData.ProjObject=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object |
---|
464 | set(hseries,'UserData',SeriesData); |
---|
465 | end |
---|
466 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
467 | return |
---|
468 | end |
---|
469 | |
---|
470 | %% read the object parameters in the GUI set_object |
---|
471 | ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object |
---|
472 | if isfield(ObjectData,'CoordLine')% remove CoordLine (not used as object feature) |
---|
473 | ObjectData=rmfield(ObjectData,'CoordLine'); |
---|
474 | end |
---|
475 | if iscell(ObjectData.Coord)%check for empty line |
---|
476 | ObjectData.Coord=[0 0 0]; |
---|
477 | hhset_object=guidata(handles.set_object); |
---|
478 | set(hhset_object.Coord,'Data',ObjectData.Coord) |
---|
479 | end |
---|
480 | checknan=isnan(sum(ObjectData.Coord,2));%check for NaN lines |
---|
481 | if ~isempty(checknan) |
---|
482 | ObjectData.Coord(checknan,:)=[];%remove the NaN lines |
---|
483 | end |
---|
484 | ObjectName=ObjectData.Name;%name of the current object defined in set_object |
---|
485 | if isempty(ObjectName) |
---|
486 | ObjectName=ObjectData.Type;% name the object by the object type type by default |
---|
487 | end |
---|
488 | |
---|
489 | %% read the current object selection in the GUI uvmat |
---|
490 | huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle |
---|
491 | UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat |
---|
492 | hhuvmat=guidata(huvmat);%handles of the objects children of the GUI uvmat |
---|
493 | ListObject=get(hhuvmat.ListObject,'String');% list of objects displayed in uvmat |
---|
494 | |
---|
495 | if isequal(get(hhuvmat.CheckEditObject,'Value'),0) %we append a new object |
---|
496 | ListObject=[ListObject;{''}]; |
---|
497 | IndexObj=length(ListObject); |
---|
498 | set(hhuvmat.ListObject,'String',ListObject) |
---|
499 | set(hhuvmat.ListObject,'Value',IndexObj) |
---|
500 | UvData.ProjObject{IndexObj}=[]; %create a new empty object |
---|
501 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; % axes for plot_object |
---|
502 | UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
503 | else |
---|
504 | IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat |
---|
505 | end |
---|
506 | |
---|
507 | %set or modify(edit mode) the name of the currently selected object |
---|
508 | detectname=1; |
---|
509 | ObjectNameNew=ObjectName; |
---|
510 | vers=0;% index of the name |
---|
511 | ListOther=ListObject; |
---|
512 | ListOther(IndexObj)=[]; |
---|
513 | while ~isempty(detectname) |
---|
514 | detectname=find(strcmp(ObjectNameNew,ListOther),1);%test the existence of the proposed name in the list |
---|
515 | if detectname% if the object name already exists |
---|
516 | indstr=regexp(ObjectNameNew,'\D');%indices of non number characters |
---|
517 | if indstr(end)<length(ObjectNameNew) %object name ends by a number |
---|
518 | vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; |
---|
519 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; |
---|
520 | else |
---|
521 | vers=vers+1; |
---|
522 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; |
---|
523 | end |
---|
524 | end |
---|
525 | end |
---|
526 | ObjectName=ObjectNameNew; |
---|
527 | set(handles.Name,'String',ObjectName)% display the default name in set_object |
---|
528 | ListObject{IndexObj}=ObjectName; |
---|
529 | set(hhuvmat.ListObject,'String',ListObject);%complement the object list |
---|
530 | set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list |
---|
531 | set(hhuvmat.CheckViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object |
---|
532 | check_handle=isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')... |
---|
533 | && ~isempty(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat); |
---|
534 | if check_handle |
---|
535 | obj_handle=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
536 | end |
---|
537 | UvData.ProjObject{IndexObj}=ObjectData;%record the current object properties in uvmat |
---|
538 | if check_handle |
---|
539 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid |
---|
540 | else |
---|
541 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt |
---|
542 | end |
---|
543 | |
---|
544 | %% refresh the field projected on the object |
---|
545 | hview_field=[];%default |
---|
546 | IndexObj_1=get(hhuvmat.ListObject_1,'Value'); |
---|
547 | if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none') |
---|
548 | PlotType='text'; |
---|
549 | else |
---|
550 | % create tps coeff if needed for ProjMode 'interp_tps' |
---|
551 | if strcmp(ObjectData.ProjMode,'interp_tps')&&~isfield(UvData.Field,'Coord_tps') |
---|
552 | %UvData.Field=calc_tps(UvData.Field,1); |
---|
553 | [UvData.Field,errormsg]=tps_coeff_field(UvData.Field,1); |
---|
554 | if ~isempty(errormsg) |
---|
555 | msgbox_uvmat('ERROR', ['set_object/tps_coeff_field/' errormsg]) |
---|
556 | set(handles.REFRESH,'enable','on') |
---|
557 | return |
---|
558 | end |
---|
559 | end |
---|
560 | [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current field of uvmat on ObjectData |
---|
561 | if ~isempty(errormsg) |
---|
562 | msgbox_uvmat('ERROR', ['set_object/proj_field/' errormsg]) |
---|
563 | set(handles.REFRESH,'enable','on') |
---|
564 | return |
---|
565 | end |
---|
566 | if isequal(IndexObj_1,IndexObj) % if the projection is in uvmat |
---|
567 | PlotType=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(get(hhuvmat.PlotAxes,'parent')));%update the current uvmat plot |
---|
568 | else % if the projection is in view_field |
---|
569 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
570 | if isempty(hview_field) |
---|
571 | hview_field=view_field(ProjData); %open the view_field GUI for plot |
---|
572 | else |
---|
573 | hhview_field=guidata(hview_field); |
---|
574 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing plot in view_field |
---|
575 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
576 | if ~isempty(errormsg) |
---|
577 | msgbox_uvmat('ERROR',errormsg) |
---|
578 | return |
---|
579 | end |
---|
580 | % write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
581 | end |
---|
582 | haxes=findobj(hview_field,'tag','axes3'); |
---|
583 | Data=get(hview_field,'UserData'); |
---|
584 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
585 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
586 | pos_table=get(h_TableDisplay,'Position'); |
---|
587 | pos=get(hview_field,'Position'); |
---|
588 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
589 | drawnow |
---|
590 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
591 | else |
---|
592 | set(hview_field,'Position',Data.GUISize) |
---|
593 | end |
---|
594 | end |
---|
595 | end |
---|
596 | |
---|
597 | %% update the object refresh |
---|
598 | %hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
599 | % if we are editing the object used for projection in uvmat |
---|
600 | if isequal(IndexObj_1,IndexObj) |
---|
601 | %update the representation of the current object for projection field represented in view_field |
---|
602 | for iobj=1:numel(UvData.ProjObject) |
---|
603 | UvData.ProjObject{iobj}.DisplayHandle.uvmat=... |
---|
604 | plot_object(UvData.ProjObject{iobj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{iobj}.DisplayHandle.uvmat,'b'); |
---|
605 | end |
---|
606 | else % we are editing the object used for projection field represented in view_field |
---|
607 | %update the representation of the current object in uvmat |
---|
608 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=... |
---|
609 | plot_object(UvData.ProjObject{IndexObj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'m'); |
---|
610 | %indicate the object index in the user data of the object refresh (needed for further mouse editing) |
---|
611 | ObjectInfo=get(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData'); |
---|
612 | ObjectInfo.IndexObj=IndexObj; |
---|
613 | set(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo) |
---|
614 | % update the representation of all objects in view_field |
---|
615 | for iobj=1:numel(UvData.ProjObject) |
---|
616 | if isfield(UvData.ProjObject{iobj},'DisplayHandle') && isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field') |
---|
617 | UvData.ProjObject{iobj}.DisplayHandle.view_field=... |
---|
618 | plot_object(UvData.ProjObject{iobj},UvData.ProjObject{iobj},UvData.ProjObject{iobj}.DisplayHandle.view_field,'b'); |
---|
619 | end |
---|
620 | end |
---|
621 | end |
---|
622 | set(huvmat,'UserData',UvData) |
---|
623 | |
---|
624 | %% update the GUI uvmat |
---|
625 | set(hhuvmat.CheckEditObject,'Value',1) % set uvmat to object edit mode to allow further object update |
---|
626 | set(hhuvmat.CheckViewField,'Value',1) |
---|
627 | |
---|
628 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
629 | set(handles.num_RangeY_2,'BackgroundColor',[1 1 1]) |
---|
630 | |
---|
631 | % --- Executes on button press in DisplayCoord. |
---|
632 | function DisplayCoord_Callback(hObject, eventdata, handles) |
---|
633 | global Coord |
---|
634 | Coord=get(handles.Coord,'Data'); |
---|
635 | evalin('base','global Coord')%make Coord global in the workspace |
---|
636 | display('object coordinates:') |
---|
637 | evalin('base','Coord') %display Coord in the workspace |
---|
638 | commandwindow; %brings the Matlab command window to the front |
---|
639 | |
---|
640 | %---------------------------------------------------- |
---|
641 | function num_RangeY_1_Callback(hObject, eventdata, handles) |
---|
642 | %------------------------------------------------------------------------ |
---|
643 | |
---|
644 | function num_RangeZ_1_Callback(hObject, eventdata, handles) |
---|
645 | %------------------------------------------------------------------------ |
---|
646 | |
---|
647 | function num_RangeZ_2_Callback(hObject, eventdata, handles) |
---|
648 | DZ=str2num(get(handles.num_RangeZ_2,'String')); |
---|
649 | ZMin=get(handles.z_slider,'Min'); |
---|
650 | ZMax=get(handles.z_slider,'Max'); |
---|
651 | if ~isequal(ZMax-ZMin,0) |
---|
652 | rel_step(1)=DZ/(ZMax-ZMin); |
---|
653 | rel_step(2)=0.2; |
---|
654 | set(handles.z_slider,'SliderStep',rel_step) |
---|
655 | end |
---|
656 | %------------------------------------------------------------------------ |
---|
657 | function num_RangeY_2_Callback(hObject, eventdata, handles) |
---|
658 | %------------------------------------------------------------------------ |
---|
659 | |
---|
660 | function num_RangeX_1_Callback(hObject, eventdata, handles) |
---|
661 | %------------------------------------------------------------------------ |
---|
662 | |
---|
663 | function num_RangeX_2_Callback(hObject, eventdata, handles) |
---|
664 | |
---|
665 | %------------------------------------------------------------------------ |
---|
666 | %------------------------------------------------------------------------ |
---|
667 | function SAVE_Callback(hObject, eventdata, handles) |
---|
668 | % ------------------------------------------------------ |
---|
669 | Object=read_GUI(handles.set_object); |
---|
670 | if isfield(Object,'CoordLine')% remove CoordLine (not used as object feature) |
---|
671 | Object=rmfield(Object,'CoordLine'); |
---|
672 | end |
---|
673 | huvmat=findobj('Tag','uvmat'); |
---|
674 | if isempty(huvmat) |
---|
675 | huvmat=findobj(allchild(0),'Name','series'); |
---|
676 | end |
---|
677 | hchild=get(huvmat,'Children'); |
---|
678 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
679 | if isempty(hrootpath) |
---|
680 | RootPath=''; |
---|
681 | else |
---|
682 | RootPath=get(hrootpath,'String'); |
---|
683 | if iscell(RootPath) |
---|
684 | RootPath=RootPath{1}; |
---|
685 | end |
---|
686 | end |
---|
687 | title={'object name'}; |
---|
688 | dir_save=uigetfile_uvmat('select the folder for the new xml object file:',RootPath,'uigetdir'); |
---|
689 | if ~isempty(dir_save) |
---|
690 | ObjectName=get(handles.Name,'String'); |
---|
691 | if ~isempty(ObjectName)&&~strcmp(ObjectName,'') |
---|
692 | def=[ObjectName '.xml']; |
---|
693 | else |
---|
694 | def=[Object.Style '.xml']; |
---|
695 | end |
---|
696 | displ_txt={['save object in' dir_save]; 'with file name (.xml):'};%default display |
---|
697 | menu=get(handles.ProjMode,'String'); |
---|
698 | value=get(handles.ProjMode,'Value'); |
---|
699 | ProjMode=menu{value}; |
---|
700 | if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside') |
---|
701 | displ_txt=[displ_txt; '(note: to create a mask image, use ''Tools/make mask'' on the upper bar menu of uvmat)']; |
---|
702 | end |
---|
703 | answer=msgbox_uvmat('INPUT_TXT',displ_txt,def); |
---|
704 | if ischar(answer) |
---|
705 | FullName=fullfile(dir_save,answer); |
---|
706 | t=struct2xml(Object); |
---|
707 | t=set(t,1,'name','ProjObject'); |
---|
708 | try |
---|
709 | save(t,FullName) |
---|
710 | msgbox_uvmat('CONFIRMATION',[FullName ' saved']) |
---|
711 | catch ME |
---|
712 | msgbox_uvmat('ERROR',ME.message) |
---|
713 | end |
---|
714 | end |
---|
715 | end |
---|
716 | |
---|
717 | %------------------------------------------------------------------------ |
---|
718 | % --- Executes on slider movement. |
---|
719 | function z_slider_Callback(hObject, eventdata, handles) |
---|
720 | %--------------------------------------------------------- |
---|
721 | Z_value=get(handles.z_slider,'Value'); |
---|
722 | %rotation angles |
---|
723 | PlaneAngle=[0 0]; |
---|
724 | norm_plane=[0 0 1]; |
---|
725 | cos_om=1; |
---|
726 | sin_om=0; |
---|
727 | |
---|
728 | PlaneAngle(1)=str2double(get(handles.num_Angle_1,'String'));%first angle in degrees |
---|
729 | PlaneAngle(2)=str2double(get(handles.num_Angle_2,'String'));%second angle in degrees |
---|
730 | %PlaneAngle(3)=str2double(get(handles.num_Angle_3,'String'));%second angle in degrees |
---|
731 | PlaneAngle=(pi/180)*PlaneAngle; |
---|
732 | M2=[cos(PlaneAngle(2)) sin(PlaneAngle(2)) 0;-sin(PlaneAngle(2)) cos(PlaneAngle(2)) 0;0 0 1]; |
---|
733 | M1=[1 0 0;0 cos(PlaneAngle(1)) sin(PlaneAngle(1));0 -sin(PlaneAngle(1)) cos(PlaneAngle(1))]; |
---|
734 | M=M1*M2; |
---|
735 | norm_plane=M*[0 0 1]'; |
---|
736 | |
---|
737 | % om=norm(PlaneAngle);%norm of rotation angle in radians |
---|
738 | % if isequal(om,0) |
---|
739 | % norm_plane=[0 0 1]; |
---|
740 | % else |
---|
741 | % OmAxis=PlaneAngle/om; %unit vector marking the rotation axis |
---|
742 | % cos_om=cos(om); |
---|
743 | % sin_om=sin(om); |
---|
744 | % coeff=OmAxis(3)*(1-cos_om); |
---|
745 | % %components of the unity vector norm_plane normal to the projection plane |
---|
746 | % norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; |
---|
747 | % norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; |
---|
748 | % norm_plane(3)=OmAxis(3)*coeff+cos_om; |
---|
749 | % end |
---|
750 | Coord=get(handles.Coord,'Data'); |
---|
751 | Coord(3)=Z_value; |
---|
752 | set(handles.Coord,'Data',Coord) |
---|
753 | |
---|
754 | % update graph |
---|
755 | REFRESH_Callback(hObject, eventdata, handles) |
---|
756 | |
---|
757 | %------------------------------------------------------------------------ |
---|
758 | % --- Executes on button press in HELP. |
---|
759 | function HELP_Callback(hObject, eventdata, handles) |
---|
760 | %------------------------------------------------------------------------ |
---|
761 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#ProjObject') |
---|
762 | |
---|
763 | %------------------------------------------------------------------------ |
---|
764 | % --- Executes when selected cell(s) is changed in ListCoord. |
---|
765 | %------------------------------------------------------------------------ |
---|
766 | function Coord_CellSelectionCallback(hObject, eventdata, handles) |
---|
767 | if ~isempty(eventdata.Indices) |
---|
768 | iline=eventdata.Indices(1);% selected line number |
---|
769 | set(handles.CoordLine,'String',num2str(iline)) |
---|
770 | end |
---|
771 | |
---|
772 | |
---|
773 | % function num_Angle_3_Callback(hObject, eventdata, handles) |
---|
774 | % |
---|
775 | % %------------------------------------------------------------------------ |
---|
776 | % % --- Executes on key press with selection of a uicontrol |
---|
777 | % %------------------------------------------------------------------------ |
---|
778 | % function KeyPressFcn(hObject, eventdata, handles) |
---|
779 | % set(handles.REFRESH,'BackgroundColor',[1 0 1])% se REFRESH to magenta color, indicates that refresh needs to be done |
---|
780 | % if strcmp(get(hObject,'Tag'),'num_Angle_3') |
---|
781 | % set(handles.num_RangeX_1,'String','') |
---|
782 | % set(handles.num_RangeX_2,'String','') |
---|
783 | % set(handles.num_RangeY_1,'String','') |
---|
784 | % set(handles.num_RangeY_2,'String','') |
---|
785 | % end |
---|
786 | |
---|
787 | %------------------------------------------------------------------------ |
---|
788 | % --- Executes on key press with focus on Coord and none of its controls. |
---|
789 | %------------------------------------------------------------------------ |
---|
790 | function Coord_KeyPressFcn(hObject, eventdata, handles) |
---|
791 | |
---|
792 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
793 | xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character |
---|
794 | if ismember(xx,[127 31])% delete, or downward |
---|
795 | Coord=get(handles.Coord,'Data'); |
---|
796 | iline=str2double(get(handles.CoordLine,'String')); |
---|
797 | if isequal(xx, 31) |
---|
798 | if isequal(iline,size(Coord,1))% arrow downward |
---|
799 | Coord=[Coord;zeros(1,size(Coord,2))]; |
---|
800 | end |
---|
801 | else |
---|
802 | Coord(iline,:)=[];% suppress the current line |
---|
803 | end |
---|
804 | set(handles.Coord,'Data',Coord); |
---|
805 | end |
---|
806 | |
---|
807 | %------------------------------------------------------------------------ |
---|
808 | % --- Executes on button press in clear_line. |
---|
809 | %------------------------------------------------------------------------ |
---|
810 | function clear_line_Callback(hObject, eventdata, handles) |
---|
811 | |
---|
812 | Coord=get(handles.Coord,'Data'); |
---|
813 | iline=str2double(get(handles.CoordLine,'String')); |
---|
814 | if isempty(iline) |
---|
815 | msgbox_uvmat('WARNING','no line suppressed, select a line in the table') |
---|
816 | else |
---|
817 | Coord(iline,:)=[]; |
---|
818 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
819 | set(handles.Coord,'Data',Coord); |
---|
820 | set(handles.CoordLine,'String','') |
---|
821 | REFRESH_Callback(hObject,eventdata,handles) |
---|
822 | end |
---|
823 | |
---|
824 | |
---|
825 | function num_RangeInterp_Callback(hObject, eventdata, handles) |
---|
826 | |
---|
827 | |
---|
828 | % --- Executes on key press with focus on num_RangeX_2 and none of its controls. |
---|
829 | function suggest_refresh(hObject, eventdata, handles) |
---|
830 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
831 | |
---|
832 | |
---|
833 | function num_Angle_3_Callback(hObject, eventdata, handles) |
---|