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: |
---|
10 | % data: structure describing the object properties |
---|
11 | % .Style=... |
---|
12 | % .ProjMode |
---|
13 | % .CoordType: 'phys' or 'px' |
---|
14 | % .DX,.DY,.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 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
21 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
23 | % This file is part of the toolbox UVMAT. |
---|
24 | % |
---|
25 | % UVMAT is free software; you can redistribute it and/or modify |
---|
26 | % it under the terms of the GNU General Public License as published by |
---|
27 | % the Free Software Foundation; either version 2 of the License, or |
---|
28 | % (at your option) any later version. |
---|
29 | % |
---|
30 | % UVMAT is distributed in the hope that it will be useful, |
---|
31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
33 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
34 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
35 | |
---|
36 | function varargout = set_object(varargin) |
---|
37 | |
---|
38 | % Last Modified by GUIDE v2.5 24-Nov-2008 14:29:06 |
---|
39 | |
---|
40 | % Begin initialization code - DO NOT PLOT |
---|
41 | gui_Singleton = 1; |
---|
42 | gui_State = struct('gui_Name', mfilename, ... |
---|
43 | 'gui_Singleton', gui_Singleton, ... |
---|
44 | 'gui_OpeningFcn', @set_object_OpeningFcn, ... |
---|
45 | 'gui_OutputFcn', @set_object_OutputFcn, ... |
---|
46 | 'gui_LayoutFcn', [] , ... |
---|
47 | 'gui_Callback', []); |
---|
48 | if nargin & ischar(varargin{1}) |
---|
49 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
50 | end |
---|
51 | |
---|
52 | if nargout |
---|
53 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
54 | else |
---|
55 | gui_mainfcn(gui_State, varargin{:}); |
---|
56 | end |
---|
57 | % End initialization code - DO NOT PLOT |
---|
58 | %------------------------------------------------------------------------ |
---|
59 | %------------------------------------------------------------------------ |
---|
60 | % --- Executes just before set_object is made visible. |
---|
61 | %INPUT: |
---|
62 | % handles: handles of the set_object interface elements |
---|
63 | %'IndexObj': NON USED ANYMORE (To suppress) index of the object (on the UvData list) that set_object will modify |
---|
64 | % if =[] or absent: index still undefined (create mode in uvmat) |
---|
65 | % if=0; no associated object (used for series), the button 'PLOT' is then unvisible |
---|
66 | %'data': read from an existing object selected in the interface |
---|
67 | % .TITLE : class of object ('POINTS','LINE',....) |
---|
68 | % .DX,DY,DZ; meshes for regular grids |
---|
69 | % .Coord: object position coordinates |
---|
70 | % .ParentButton: handle of the uicontrol object calling the interface |
---|
71 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
---|
72 | % if =[] or absent, no plot (mask mode in uvmat) |
---|
73 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
---|
74 | function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds) |
---|
75 | %------------------------------------------------------------------- |
---|
76 | % Choose default command line output for set_object |
---|
77 | handles.output = hObject; |
---|
78 | % Update handles structure |
---|
79 | guidata(hObject, handles); |
---|
80 | |
---|
81 | %default |
---|
82 | if ~exist('ZBound','var') |
---|
83 | ZBound=0; %default |
---|
84 | end |
---|
85 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front) |
---|
86 | %set(handles.MenuCoord,'ListboxTop',1) |
---|
87 | % if ~exist('PlotHandles','var') |
---|
88 | % PlotHandles=[]; |
---|
89 | % end |
---|
90 | enable_plot=0;%default: does not allow plot of object and projection |
---|
91 | % SetData.PlotHandles=PlotHandles; |
---|
92 | % set(hObject,'UserData',SetData) |
---|
93 | |
---|
94 | % fill the interface as set in the input data: |
---|
95 | if exist('data','var') |
---|
96 | if isfield(data,'enable_plot') |
---|
97 | enable_plot=data.enable_plot;%test to desable button PLOT (display mode) |
---|
98 | end |
---|
99 | if isfield(data,'Name') |
---|
100 | set(handles.TITLE,'String',data.Name) |
---|
101 | % set(hObject,'name',data.Name) |
---|
102 | end |
---|
103 | if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case |
---|
104 | set(handles.ZObject,'Visible','off') |
---|
105 | set(handles.z_slider,'Visible','off') |
---|
106 | else |
---|
107 | set(handles.ZObject,'Visible','on') |
---|
108 | set(handles.z_slider,'Visible','on') |
---|
109 | if isfield(data,'Coord') && size(data.Coord,2)==3 |
---|
110 | set(handles.ZObject,'String',num2str(data.Coord(1,3),4)) |
---|
111 | end |
---|
112 | end |
---|
113 | if isfield(data,'StyleMenu') |
---|
114 | set(handles.ObjectStyle,'String',data.StyleMenu); |
---|
115 | end |
---|
116 | if isfield(data,'Style') |
---|
117 | menu=get(handles.ObjectStyle,'String'); |
---|
118 | for iline=1:length(menu) |
---|
119 | if isequal(menu{iline},data.Style) |
---|
120 | set(handles.ObjectStyle,'Value',iline) |
---|
121 | break |
---|
122 | end |
---|
123 | end |
---|
124 | end |
---|
125 | ObjectStyle_Callback(hObject, eventdata, handles) |
---|
126 | if isfield(data,'ProjMenu') |
---|
127 | set(handles.ProjMode,'String',data.ProjMenu); |
---|
128 | end |
---|
129 | if isfield(data,'ProjMode') |
---|
130 | menu=get(handles.ProjMode,'String'); |
---|
131 | for iline=1:length(menu) |
---|
132 | if isequal(menu{iline},data.ProjMode) |
---|
133 | set(handles.ProjMode,'Value',iline) |
---|
134 | break |
---|
135 | end |
---|
136 | end |
---|
137 | end |
---|
138 | ProjMode_Callback(hObject, eventdata, handles) |
---|
139 | if isfield(data,'Coord') |
---|
140 | if ischar(data.Coord) |
---|
141 | data.Coord=str2num(data.Coord); |
---|
142 | elseif iscell(data.Coord) |
---|
143 | CoordCell=data.Coord; |
---|
144 | data.Coord=zeros(numel(CoordCell),3); |
---|
145 | data.Coord(:,3)=zeros(numel(CoordCell),1); % z component set to 0 by default |
---|
146 | for iline=1:numel(CoordCell) |
---|
147 | line_vec=str2num(CoordCell{iline}); |
---|
148 | if numel(line_vec)==2 |
---|
149 | data.Coord(iline,1:2)=str2num(CoordCell{iline}); |
---|
150 | else |
---|
151 | data.Coord(iline,:)=str2num(CoordCell{iline}); |
---|
152 | end |
---|
153 | end |
---|
154 | end |
---|
155 | if size(data.Coord,2)>=2 |
---|
156 | sizcoord=size(data.Coord); |
---|
157 | for i=1:sizcoord(1) |
---|
158 | XObject{i}=num2str(data.Coord(i,1),4); |
---|
159 | YObject{i}=num2str(data.Coord(i,2),4); |
---|
160 | end |
---|
161 | set(handles.XObject,'String',XObject) |
---|
162 | set(handles.YObject,'String',YObject) |
---|
163 | if sizcoord(2)>3 |
---|
164 | for i=1:sizcoord(1) |
---|
165 | ZObject{i}=num2str(data.Coord(i,3),4); |
---|
166 | end |
---|
167 | set(handles.ZObject,'String',ZObject) |
---|
168 | end |
---|
169 | end |
---|
170 | end |
---|
171 | if isfield(data,'DX') |
---|
172 | if ~ischar(handles.DX) |
---|
173 | data.DX=num2str(data.DX,3); |
---|
174 | end |
---|
175 | set(handles.DX,'String',data.DX) |
---|
176 | end |
---|
177 | if isfield(data,'DY') |
---|
178 | if ~ischar(handles.DY) |
---|
179 | data.DY=num2str(data.DY,3); |
---|
180 | end |
---|
181 | set(handles.DY,'String',data.DX) |
---|
182 | end |
---|
183 | if isfield(data,'RangeZ') && length(ZBounds) >= 2 |
---|
184 | set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) |
---|
185 | DZ=max(data.RangeZ);%slider step |
---|
186 | if ZBounds(2)~=ZBounds(1) |
---|
187 | rel_step(1)=min(DZ/(ZBounds(2)-ZBounds(1)),0.2);%must be smaller than 1 |
---|
188 | rel_step(2)=0.1; |
---|
189 | set(handles.z_slider,'Visible','on') |
---|
190 | set(handles.z_slider,'Min',ZBounds(1)) |
---|
191 | set(handles.z_slider,'Max',ZBounds(2)) |
---|
192 | set(handles.z_slider,'SliderStep',rel_step) |
---|
193 | set(handles.z_slider,'Value',(ZBounds(1)+ZBounds(2))/2) |
---|
194 | end |
---|
195 | end |
---|
196 | if isfield(data,'RangeX') |
---|
197 | if ischar(data.RangeX) |
---|
198 | data.RangeX=str2num(data.RangeX); |
---|
199 | end |
---|
200 | set(handles.XMax,'String',num2str(max(data.RangeX),3)) |
---|
201 | set(handles.XMin,'String',num2str(min(data.RangeX),3)) |
---|
202 | end |
---|
203 | if isfield(data,'RangeY') |
---|
204 | if ischar(data.RangeY) |
---|
205 | data.RangeY=str2num(data.RangeY); |
---|
206 | end |
---|
207 | set(handles.YMax,'String',num2str(max(data.RangeY),3)) |
---|
208 | set(handles.YMin,'String',num2str(min(data.RangeY),3)) |
---|
209 | end |
---|
210 | if isfield(data,'RangeZ') |
---|
211 | if ischar(data.RangeZ) |
---|
212 | data.RangeZ=str2num(data.RangeZ); |
---|
213 | end |
---|
214 | set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) |
---|
215 | if numel(data.RangeZ)>=2 |
---|
216 | set(handles.ZMin,'String',num2str(min(data.RangeZ),3)) |
---|
217 | end |
---|
218 | end |
---|
219 | if isfield(data,'Phi') |
---|
220 | if ~ischar(handles.Phi) |
---|
221 | data.DY=num2str(data.Phi,3); |
---|
222 | end |
---|
223 | set(handles.Phi,'String',data.Phi) |
---|
224 | end |
---|
225 | if isfield(data,'Theta') |
---|
226 | if ~ischar(handles.Theta) |
---|
227 | data.DY=num2str(data.Theta,3); |
---|
228 | end |
---|
229 | set(handles.Theta,'String',data.Theta) |
---|
230 | end |
---|
231 | if isfield(data,'Psi') |
---|
232 | if ~ischar(handles.Psi) |
---|
233 | data.DY=num2str(data.Psi,3); |
---|
234 | end |
---|
235 | set(handles.Psi,'String',data.Psi) |
---|
236 | end |
---|
237 | if isfield(data,'DZ') |
---|
238 | if ~ischar(handles.DZ) |
---|
239 | data.DY=num2str(data.DZ,3); |
---|
240 | end |
---|
241 | set(handles.DZ,'String',data.DZ) |
---|
242 | end |
---|
243 | if isfield(data,'CoordUnit') |
---|
244 | set(handles.CoordUnit,'String',data.CoordUnit) |
---|
245 | end |
---|
246 | % if isfield(data,'CoordType')&& isequal(data.CoordType,'px') |
---|
247 | % % if isequal(data.CoordType,'phys') |
---|
248 | % % set(handles.MenuCoord,'Value',1) |
---|
249 | % % elseif isequal(data.CoordType,'px') |
---|
250 | % set(handles.MenuCoord,'Value',2) |
---|
251 | % % end |
---|
252 | % end |
---|
253 | end |
---|
254 | if enable_plot |
---|
255 | set(handles.PLOT,'enable','on') |
---|
256 | else |
---|
257 | set(handles.PLOT,'enable','off') |
---|
258 | end |
---|
259 | huvmat=findobj(allchild(0),'tag','uvmat'); |
---|
260 | UvData=get(huvmat,'UserData'); |
---|
261 | pos_uvmat=get(huvmat,'Position'); |
---|
262 | %position the set_object GUI with respect to uvmat |
---|
263 | if isfield(UvData,'SetObjectOrigin') |
---|
264 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); |
---|
265 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); |
---|
266 | set(hObject,'Position',pos_set_object) |
---|
267 | end |
---|
268 | |
---|
269 | % --- Outputs from this function are returned to the command line. |
---|
270 | function varargout = set_object_OutputFcn(hObject, eventdata, handles) |
---|
271 | % varargout cell array for returning output args (see VARARGOUT); |
---|
272 | % hObject handle to figure |
---|
273 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
274 | % handles structure with handles and user data (see GUIDATA) |
---|
275 | |
---|
276 | % Get default command line output from handles structure |
---|
277 | varargout{1} = handles.output; |
---|
278 | varargout{2}=handles; |
---|
279 | |
---|
280 | %------------------------------------------------------------------------ |
---|
281 | % --- Executes on selection change in ObjectStyle. |
---|
282 | function ObjectStyle_Callback(hObject, eventdata, handles) |
---|
283 | style_prev=get(handles.ObjectStyle,'UserData');%previous object style |
---|
284 | str=get(handles.ObjectStyle,'String'); |
---|
285 | val=get(handles.ObjectStyle,'Value'); |
---|
286 | style=str{val}; |
---|
287 | % make correspondance between different object styles |
---|
288 | % if ~isequal(str{val},style_prev) |
---|
289 | Xcolumn=get(handles.XObject,'String'); |
---|
290 | Ycolumn=get(handles.YObject,'String'); |
---|
291 | if ischar(Xcolumn) |
---|
292 | sizchar=size(Xcolumn); |
---|
293 | for icol=1:sizchar(1) |
---|
294 | Xcolumn_cell{icol}=Xcolumn(icol,:); |
---|
295 | end |
---|
296 | Xcolumn=Xcolumn_cell; |
---|
297 | end |
---|
298 | if ischar(Ycolumn) |
---|
299 | sizchar=size(Ycolumn); |
---|
300 | for icol=1:sizchar(1) |
---|
301 | Ycolumn_cell{icol}=Ycolumn(icol,:); |
---|
302 | end |
---|
303 | Ycolumn=Ycolumn_cell; |
---|
304 | end |
---|
305 | Zcolumn={};%default |
---|
306 | z_new={}; |
---|
307 | if isequal(get(handles.ZObject,'Visible'),'on') |
---|
308 | data.NbDim=3; %test 3D object |
---|
309 | Zcolumn=get(handles.ZObject,'String'); |
---|
310 | if ischar(Zcolumn) |
---|
311 | Zcolumn={Zcolumn}; |
---|
312 | end |
---|
313 | end |
---|
314 | x_new{1}=Xcolumn{1}; |
---|
315 | y_new{1}=Ycolumn{1}; |
---|
316 | if ~isempty(Zcolumn) |
---|
317 | z_new{1}=Zcolumn{1}; |
---|
318 | end |
---|
319 | if isequal(style,'line') |
---|
320 | if strcmp(style_prev,'rectangle')||strcmp(style_prev,'ellipse') |
---|
321 | XMax=get(handles.XMax,'String'); |
---|
322 | YMax=get(handles.YMax,'String'); |
---|
323 | x_new{2}=num2str(XMax,4); |
---|
324 | y_new{2}=num2str(YMax,4); |
---|
325 | set(handles.XObject,'String',x_new) |
---|
326 | set(handles.YObject,'String',y_new) |
---|
327 | set(handles.ZObject,'String',z_new) |
---|
328 | end |
---|
329 | elseif isequal(style,'polyline') |
---|
330 | elseif strcmp(style,'rectangle')|| strcmp(style,'ellipse') |
---|
331 | set(handles.XObject,'String',x_new) |
---|
332 | set(handles.YObject,'String',y_new) |
---|
333 | set(handles.ZObject,'String',z_new) |
---|
334 | end |
---|
335 | % end |
---|
336 | switch style |
---|
337 | case {'points','line','polyline','plane'} |
---|
338 | menu_proj={'projection';'interp';'filter';'none'}; |
---|
339 | case {'polygon','rectangle','ellipse'} |
---|
340 | menu_proj={'inside';'outside';'mask_inside';'mask_outside'}; |
---|
341 | case 'volume' |
---|
342 | menu_proj={'interp';'none'}; |
---|
343 | end |
---|
344 | proj_index=get(handles.ProjMode,'Value'); |
---|
345 | if proj_index<numel(menu_proj) |
---|
346 | set(handles.ProjMode,'Value',1);% value index must not exceed the menu length |
---|
347 | end |
---|
348 | set(handles.ProjMode,'String',menu_proj) |
---|
349 | ProjMode_Callback(hObject, eventdata, handles) |
---|
350 | %store the current option |
---|
351 | str=get(handles.ObjectStyle,'String'); |
---|
352 | val=get(handles.ObjectStyle,'Value'); |
---|
353 | set(handles.ObjectStyle,'UserData',style) |
---|
354 | |
---|
355 | %------------------------------------------------------------------------ |
---|
356 | function xObject_Callback(hObject, eventdata, handles) |
---|
357 | |
---|
358 | %------------------------------------------------------------------------ |
---|
359 | function yObject_Callback(hObject, eventdata, handles) |
---|
360 | |
---|
361 | %------------------------------------------------------------------------ |
---|
362 | % --- Executes on selection change in zObject. |
---|
363 | function zObject_Callback(hObject, eventdata, handles) |
---|
364 | %------------------------------------------------------------------------ |
---|
365 | |
---|
366 | %------------------------------------------------------------------------ |
---|
367 | % --- Executes on selection change in ProjMode. |
---|
368 | function ProjMode_Callback(hObject, eventdata, handles) |
---|
369 | menu=get(handles.ProjMode,'String'); |
---|
370 | value=get(handles.ProjMode,'Value'); |
---|
371 | ProjMode=menu{value}; |
---|
372 | menu=get(handles.ObjectStyle,'String'); |
---|
373 | value=get(handles.ObjectStyle,'Value'); |
---|
374 | ObjectStyle=menu{value}; |
---|
375 | test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case |
---|
376 | |
---|
377 | %default setting |
---|
378 | set(handles.Phi,'Visible','off') |
---|
379 | set(handles.Theta,'Visible','off') |
---|
380 | set(handles.Psi,'Visible','off') |
---|
381 | set(handles.XMin,'Visible','off') |
---|
382 | set(handles.XMax,'Visible','off') |
---|
383 | set(handles.YMin,'Visible','off') |
---|
384 | if isequal(ProjMode,'interp') |
---|
385 | set(handles.YMax,'Visible','off') |
---|
386 | else |
---|
387 | set(handles.YMax,'Visible','on') |
---|
388 | end |
---|
389 | if strcmp(ObjectStyle,'rectangle')||strcmp(ObjectStyle,'ellipse') |
---|
390 | set(handles.XMax,'Visible','on') |
---|
391 | else |
---|
392 | set(handles.XMax,'Visible','off') |
---|
393 | end |
---|
394 | set(handles.ZMin,'Visible','off') |
---|
395 | set(handles.ZMax,'Visible','off') |
---|
396 | set(handles.DX,'Visible','off') |
---|
397 | set(handles.DY,'Visible','off') |
---|
398 | set(handles.DZ,'Visible','off') |
---|
399 | |
---|
400 | switch ObjectStyle |
---|
401 | case 'points' |
---|
402 | set(handles.YMax,'TooltipString','YMax: range of averaging around each point') |
---|
403 | set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points') |
---|
404 | set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points') |
---|
405 | set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points') |
---|
406 | case {'line','polyline','polygon'} |
---|
407 | set(handles.YMax,'TooltipString','YMax: range of averaging around the line') |
---|
408 | set(handles.XObject,'TooltipString','XObject: set of x coordinates defining the line') |
---|
409 | set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') |
---|
410 | set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line') |
---|
411 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
---|
412 | set(handles.DX,'Visible','on') |
---|
413 | set(handles.DX,'TooltipString','DX: mesh for the interpolated field along the line') |
---|
414 | end |
---|
415 | case {'rectangle','ellipse'} |
---|
416 | set(handles.XMax,'TooltipString',['XMax: half length of the ' ObjectStyle]) |
---|
417 | set(handles.YMax,'TooltipString',['YMax: half width of the ' ObjectStyle]) |
---|
418 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the ' ObjectStyle ' centre']) |
---|
419 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the ' ObjectStyle ' centre']) |
---|
420 | case {'plane'} |
---|
421 | set(handles.Phi,'Visible','on') |
---|
422 | set(handles.XMin,'Visible','on') |
---|
423 | set(handles.XMax,'Visible','on') |
---|
424 | set(handles.YMin,'Visible','on') |
---|
425 | set(handles.YMax,'Visible','on') |
---|
426 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) |
---|
427 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) |
---|
428 | set(handles.ZMax,'TooltipString',['ZMax: range of projection normal to the plane']) |
---|
429 | if test3D |
---|
430 | set(handles.Theta,'Visible','on') |
---|
431 | set(handles.Psi,'Visible','on') |
---|
432 | set(handles.ZMax,'Visible','on') |
---|
433 | end |
---|
434 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
---|
435 | set(handles.DX,'Visible','on') |
---|
436 | set(handles.DY,'Visible','on') |
---|
437 | else |
---|
438 | set(handles.DX,'Visible','off') |
---|
439 | set(handles.DY,'Visible','off') |
---|
440 | end |
---|
441 | if isequal(ObjectStyle,'volume') && isequal(ProjMode,'interp') |
---|
442 | set(handles.DZ,'Visible','on') |
---|
443 | end |
---|
444 | case {'volume'} |
---|
445 | set(handles.Phi,'Visible','on') |
---|
446 | set(handles.XMin,'Visible','on') |
---|
447 | set(handles.XMax,'Visible','on') |
---|
448 | set(handles.YMin,'Visible','on') |
---|
449 | set(handles.YMax,'Visible','on') |
---|
450 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) |
---|
451 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) |
---|
452 | if test3D |
---|
453 | set(handles.Theta,'Visible','on') |
---|
454 | set(handles.Psi,'Visible','on') |
---|
455 | set(handles.ZMin,'Visible','on') |
---|
456 | set(handles.ZMax,'Visible','on') |
---|
457 | end |
---|
458 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
---|
459 | set(handles.DX,'Visible','on') |
---|
460 | set(handles.DY,'Visible','on') |
---|
461 | else |
---|
462 | set(handles.DX,'Visible','off') |
---|
463 | set(handles.DY,'Visible','off') |
---|
464 | end |
---|
465 | if isequal(ObjectStyle,'volume') && isequal(ProjMode,'interp') |
---|
466 | set(handles.DZ,'Visible','on') |
---|
467 | end |
---|
468 | end |
---|
469 | %------------------------------------------------------------------------ |
---|
470 | |
---|
471 | %------------------------------------------------------------------------ |
---|
472 | function Phi_Callback(hObject, eventdata, handles) |
---|
473 | update_slider(hObject, eventdata,handles) |
---|
474 | %------------------------------------------------------------------------ |
---|
475 | %------------------------------------------------------------------------ |
---|
476 | function Theta_Callback(hObject, eventdata, handles) |
---|
477 | update_slider(hObject, eventdata,handles) |
---|
478 | %------------------------------------------------------------------------ |
---|
479 | function update_slider(hObject, eventdata,handles) |
---|
480 | %rotation angles |
---|
481 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
---|
482 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
---|
483 | |
---|
484 | %components of the unitiy vector normal to the projection plane |
---|
485 | NormVec_X=-sin(Phi)*sin(Theta); |
---|
486 | NormVec_Y=cos(Phi)*sin(Theta); |
---|
487 | NormVec_Z=cos(Theta); |
---|
488 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
489 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
490 | if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z') |
---|
491 | Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z); |
---|
492 | set(handles.z_slider,'Min',min(Z)) |
---|
493 | set(handles.z_slider,'Max',max(Z)) |
---|
494 | ZMax_Callback(hObject, eventdata, handles) |
---|
495 | end |
---|
496 | %------------------------------------------------------------------------ |
---|
497 | function DX_Callback(hObject, eventdata, handles) |
---|
498 | %------------------------------------------------------------------------ |
---|
499 | %------------------------------------------------------------------------ |
---|
500 | function DY_Callback(hObject, eventdata, handles) |
---|
501 | %------------------------------------------------------------------------ |
---|
502 | %------------------------------------------------------------------------ |
---|
503 | function DZ_Callback(hObject, eventdata, handles) |
---|
504 | %------------------------------------------------------------------------ |
---|
505 | |
---|
506 | %------------------------------------------------------------------------ |
---|
507 | %----------------------------------------------------- |
---|
508 | % --- Executes on button press in OPEN: DESACTIVATED use uvmat browser |
---|
509 | function OPEN_Callback(hObject, eventdata, handles) |
---|
510 | %get the object file |
---|
511 | oldfile=' '; |
---|
512 | huvmat=findobj('Tag','uvmat'); |
---|
513 | hchild=get(huvmat,'Children'); |
---|
514 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
515 | if ~isempty(hrootpath) |
---|
516 | oldfile=get(hrootpath,'String'); |
---|
517 | if iscell(oldfile) |
---|
518 | oldfile=oldfile{1}; |
---|
519 | end |
---|
520 | end |
---|
521 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
522 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
523 | '*.xml', '.xml files '; ... |
---|
524 | '*.mat', '.mat matlab files '}, ... |
---|
525 | 'Pick a file',oldfile); |
---|
526 | fileinput=[PathName FileName];%complete file name |
---|
527 | testblank=findstr(fileinput,' ');%look for blanks |
---|
528 | if ~isempty(testblank) |
---|
529 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks') |
---|
530 | return |
---|
531 | end |
---|
532 | sizf=size(fileinput); |
---|
533 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
534 | |
---|
535 | %read the file |
---|
536 | t=xmltree(fileinput); |
---|
537 | s=convert(t); |
---|
538 | if ~isfield(s,'Style') |
---|
539 | s.Style='points'; |
---|
540 | end |
---|
541 | if ~isfield(s,'ProjMode') |
---|
542 | s.ProjMode='none'; |
---|
543 | end |
---|
544 | %Display title |
---|
545 | % title=set_title(s.Style,s.ProjMode);%update the title |
---|
546 | % if ~isempty(huvmat) |
---|
547 | % hhuvmat=guidata(huvmat); |
---|
548 | % end |
---|
549 | % menu=get(handles.TITLE,'String'); |
---|
550 | % for iline=1:length(menu) |
---|
551 | % if isequal(menu{iline},title) |
---|
552 | % set(handles.TITLE,'Value',iline) |
---|
553 | % break |
---|
554 | % end |
---|
555 | % end |
---|
556 | %TITLE_Callback(hObject, eventdata, handles) |
---|
557 | teststyle=0; |
---|
558 | |
---|
559 | switch s.Style |
---|
560 | case {'points','line','polyline','plane'} |
---|
561 | menu_proj={'projection';'interp';'filter';'none'}; |
---|
562 | case {'polygon','rectangle','ellipse'} |
---|
563 | menu_proj={'inside';'outside';'mask_inside';'mask_outside'}; |
---|
564 | case 'volume' |
---|
565 | menu_proj={'none'}; |
---|
566 | end |
---|
567 | set(handles.ObjectStyle,'String',menu_proj) |
---|
568 | menu=get(handles.ObjectStyle,'String'); |
---|
569 | for iline=1:length(menu) |
---|
570 | if isequal(menu{iline},s.Style) |
---|
571 | set(handles.ObjectStyle,'Value',iline) |
---|
572 | teststyle=1; |
---|
573 | break |
---|
574 | end |
---|
575 | end |
---|
576 | testmode=0; |
---|
577 | %menu=get(handles.ProjMode,'String'); |
---|
578 | for iline=1:length(menu_proj) |
---|
579 | if isequal(menu_proj{iline},s.ProjMode) |
---|
580 | set(handles.ProjMode,'Value',iline) |
---|
581 | testmode=1; |
---|
582 | break |
---|
583 | end |
---|
584 | end |
---|
585 | |
---|
586 | ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes |
---|
587 | % if isfield(s,'CoordType') |
---|
588 | % if isequal(s.CoordType,'phys') |
---|
589 | % set(handles.MenuCoord,'Value',1) |
---|
590 | % elseif isequal(s.CoordType,'px') |
---|
591 | % set(handles.MenuCoord,'Value',2) |
---|
592 | % else |
---|
593 | % warndlg('unknown CoordType (px or phys) in set_object.m') |
---|
594 | % end |
---|
595 | % end |
---|
596 | if isfield(s,'XMax') |
---|
597 | set(handles.XMax,'String',s.XMax) |
---|
598 | end |
---|
599 | if isfield(s,'XMin') |
---|
600 | set(handles.XMin,'String',s.XMin) |
---|
601 | end |
---|
602 | if isfield(s,'YMax') |
---|
603 | set(handles.YMax,'String',s.YMax) |
---|
604 | end |
---|
605 | if isfield(s,'YMin') |
---|
606 | set(handles.YMin,'String',s.YMin) |
---|
607 | end |
---|
608 | Range=0; |
---|
609 | if isfield(s,'Range') |
---|
610 | if ischar(s.Range) |
---|
611 | Range=str2num(s.Range); |
---|
612 | else |
---|
613 | Range(1,:)=str2num(s.Range{1}); |
---|
614 | Range(2,:)=str2num(s.Range{2}); |
---|
615 | end |
---|
616 | end |
---|
617 | if size(Range,2)>=3 |
---|
618 | if size(Range,1)>=2 |
---|
619 | set(handles.ZMin,'String',num2str(Range(2,3),3)) |
---|
620 | end |
---|
621 | if size(Range,1)>=2 |
---|
622 | set(handles.ZMax,'String',num2str(Range(1,3),3)) |
---|
623 | end |
---|
624 | end |
---|
625 | if size(Range,2)>=2 |
---|
626 | if size(Range,1)>=2 |
---|
627 | set(handles.YMin,'String',num2str(Range(2,2),3)) |
---|
628 | end |
---|
629 | if size(Range,1)>=2 |
---|
630 | set(handles.YMax,'String',num2str(Range(1,2),3)) |
---|
631 | end |
---|
632 | end |
---|
633 | if size(Range,2)>=1 |
---|
634 | if size(Range,1)>=2 |
---|
635 | set(handles.XMin,'String',num2str(Range(2,1),3)) |
---|
636 | end |
---|
637 | if size(Range,1)>=2 |
---|
638 | set(handles.XMax,'String',num2str(Range(1,1),3)) |
---|
639 | end |
---|
640 | end |
---|
641 | if isfield(s,'RangeX') & ischar(s.RangeX) |
---|
642 | RangeX=str2num(s.RangeX); |
---|
643 | set(handles.XMax,'String',num2str(max(RangeX),3)) |
---|
644 | set(handles.XMin,'String',num2str(min(RangeX),3)) |
---|
645 | end |
---|
646 | |
---|
647 | if isfield(s,'RangeY') |
---|
648 | if ischar(s.RangeY) |
---|
649 | RangeY=str2num(s.RangeY); |
---|
650 | set(handles.YMax,'String',num2str(max(RangeY),3)) |
---|
651 | set(handles.YMin,'String',num2str(min(RangeY),3)) |
---|
652 | end |
---|
653 | end |
---|
654 | if isfield(s,'RangeZ') |
---|
655 | if ischar(s.RangeZ) |
---|
656 | RangeZ=str2num(s.RangeZ); |
---|
657 | set(handles.ZMax,'String',num2str(max(RangeZ),3)) |
---|
658 | set(handles.ZMin,'String',num2str(min(RangeZ),3)) |
---|
659 | end |
---|
660 | end |
---|
661 | if isfield(s,'Phi') |
---|
662 | set(handles.Phi,'String',s.Phi) |
---|
663 | end |
---|
664 | if isfield(s,'Theta') |
---|
665 | set(handles.Theta,'String',s.Theta) |
---|
666 | end |
---|
667 | if isfield(s,'Psi') |
---|
668 | set(handles.Psi,'String',s.Psi) |
---|
669 | end |
---|
670 | |
---|
671 | if isfield(s,'DX') |
---|
672 | set(handles.DX,'String',s.DX) |
---|
673 | end |
---|
674 | if isfield(s,'DY') |
---|
675 | set(handles.DY,'String',s.DY) |
---|
676 | end |
---|
677 | if ~isfield(s,'Coord') |
---|
678 | XObject='0';%default |
---|
679 | YObject='0'; |
---|
680 | elseif ischar(s.Coord) |
---|
681 | line=str2num(s.Coord); |
---|
682 | XObject=num2str(line(1),4); |
---|
683 | YObject=num2str(line(2),4); |
---|
684 | else |
---|
685 | for i=1:length(s.Coord) |
---|
686 | line=str2num(s.Coord{i}); |
---|
687 | XObject{i}=num2str(line(1),4); |
---|
688 | YObject{i}=num2str(line(2),4); |
---|
689 | end |
---|
690 | end |
---|
691 | set(handles.XObject,'String',XObject) |
---|
692 | set(handles.YObject,'String',YObject) |
---|
693 | %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening |
---|
694 | %------------------------------------------------------------------------ |
---|
695 | %---------------------------------------------------- |
---|
696 | % executed when closing: set the parent interface button to value 0 |
---|
697 | function closefcn(gcbo,eventdata,parent_button) |
---|
698 | |
---|
699 | huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle |
---|
700 | if ~isempty(huvmat) |
---|
701 | hhuvmat=guidata(huvmat); |
---|
702 | % set(hhuvmat.create,'Value',0) |
---|
703 | % set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
704 | % set(hhuvmat.LINE,'Value',0) |
---|
705 | % set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
706 | % set(hhuvmat.PATCH,'Value',0) |
---|
707 | % set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
708 | % set(hhuvmat.PLANE,'Value',0) |
---|
709 | % set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
710 | % set(hhuvmat.VOLUME,'Value',0) |
---|
711 | % set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
712 | set(hhuvmat.edit,'Value',0) |
---|
713 | set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree |
---|
714 | end |
---|
715 | hseries=findobj(allchild(0),'Name','series');%find the current series interface handle |
---|
716 | if ~isempty(hseries) |
---|
717 | hhseries=guidata(hseries); |
---|
718 | set(hhseries.GetObject,'Value',0) |
---|
719 | set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
720 | end |
---|
721 | |
---|
722 | %------------------------------------------------------------------------ |
---|
723 | % --- Executes on button press in PLOT: PLOT the defined object and its projected field |
---|
724 | function PLOT_Callback(hObject, eventdata, handles) |
---|
725 | |
---|
726 | %% reading the object parameters on the GUI uvmat |
---|
727 | huvmat=findobj('tag','uvmat');%find the current uvmat interface handle |
---|
728 | UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat |
---|
729 | hhuvmat=guidata(huvmat);%handles in the uvmat GUI |
---|
730 | ObjectName=get(handles.TITLE,'String');%name of the current object |
---|
731 | ListObject=get(hhuvmat.list_object_1,'String');%position in the objet list |
---|
732 | IndexObj_1=get(hhuvmat.list_object_1,'Value'); |
---|
733 | if isequal(get(hhuvmat.list_object_2,'Visible'),'on') |
---|
734 | IndexObj_2=get(hhuvmat.list_object_2,'Value'); |
---|
735 | else |
---|
736 | IndexObj_2=[]; |
---|
737 | end |
---|
738 | testnew=0; |
---|
739 | PlotHandles=get_plot_handles(hhuvmat); |
---|
740 | projview='view_field';%default |
---|
741 | if strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame |
---|
742 | % ObjectData.HandlesDisplay=hhuvmat.axes3; |
---|
743 | % Object_set{iobj}.DisplayHandle_view_field |
---|
744 | IndexObj=IndexObj_1; |
---|
745 | projview='uvmat'; |
---|
746 | plotaxes=hhuvmat.axes3;%handle of axes3 in view_field |
---|
747 | elseif ~isempty(IndexObj_2) && IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field |
---|
748 | IndexObj=IndexObj_2; |
---|
749 | % projview='view_field'; |
---|
750 | else %new object |
---|
751 | testnew=1; |
---|
752 | IndexObj=numel(ListObject)+1; |
---|
753 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
754 | if ~isempty(hview_field) |
---|
755 | PlotHandles=guidata(hview_field); |
---|
756 | plotaxes=PlotHandles.axes3;%handle of axes3 in view_field |
---|
757 | % ObjectData.HandlesDisplay=PlotHandles.axes3;%handle of axes3 in view_field |
---|
758 | end |
---|
759 | end |
---|
760 | if strcmp(projview,'view_field') |
---|
761 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
762 | if isempty(hview_field) |
---|
763 | hview_field=view_field; |
---|
764 | end |
---|
765 | PlotHandles=guidata(hview_field); |
---|
766 | plotaxes=PlotHandles.axes3;%handle of axes3 in view_field |
---|
767 | end |
---|
768 | ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object |
---|
769 | |
---|
770 | %% naming the object |
---|
771 | if length(ObjectName)<1% name of object not defined in set_object |
---|
772 | ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name |
---|
773 | elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created) |
---|
774 | detectname=1; |
---|
775 | ObjectNameNew=ObjectName; |
---|
776 | vers=0; |
---|
777 | while detectname==1 |
---|
778 | detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list |
---|
779 | if detectname% if the object name already exists |
---|
780 | indstr=regexp(ObjectNameNew,'\D'); |
---|
781 | if indstr(end)<length(ObjectNameNew) %object name ends by a number |
---|
782 | vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; |
---|
783 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; |
---|
784 | else |
---|
785 | vers=vers+1; |
---|
786 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; |
---|
787 | end |
---|
788 | end |
---|
789 | end |
---|
790 | ObjectName=ObjectNameNew; |
---|
791 | end |
---|
792 | ListObject{IndexObj,1}=ObjectName; |
---|
793 | set(hhuvmat.list_object_1,'String',ListObject) |
---|
794 | set(hhuvmat.list_object_2,'String',[ListObject;{'...'}]) |
---|
795 | |
---|
796 | %% update the object plot and projection field |
---|
797 | if testnew |
---|
798 | set(hhuvmat.list_object_2,'Value',IndexObj) |
---|
799 | ObjectData.DisplayHandle_uvmat=hhuvmat.axes3; |
---|
800 | ObjectData.DisplayHandle_view_field=[]; |
---|
801 | elseif ~isfield(UvData.Object{IndexObj},'DisplayHandle_uvmat')% save the previous object graph handles |
---|
802 | ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat; |
---|
803 | ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field; |
---|
804 | else |
---|
805 | ObjectData.DisplayHandle_uvmat=hhuvmat.axes3; |
---|
806 | ObjectData.DisplayHandle_view_field=[]; |
---|
807 | end |
---|
808 | UvData.Object{IndexObj}=ObjectData;%update the current object properties |
---|
809 | UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2); |
---|
810 | |
---|
811 | %% plot the field projected on the object and store it the corresponding figue |
---|
812 | get(plotaxes,'tag') |
---|
813 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
814 | [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot |
---|
815 | if strcmp(projview,'view_field') |
---|
816 | ViewFieldData=get(hview_field,'UserData'); |
---|
817 | ViewFieldData.axes3=ObjectData; |
---|
818 | set(hview_field,'UserData',ViewFieldData) |
---|
819 | else |
---|
820 | UvData.axes3=ObjectData; |
---|
821 | end |
---|
822 | |
---|
823 | %% update the GUI uvmat |
---|
824 | hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI |
---|
825 | set(hhuvmat.MenuEditObject,'enable','on') |
---|
826 | set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update |
---|
827 | set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow |
---|
828 | %UvData.MouseAction='edit_object'; % set the edit button to 'on' |
---|
829 | set(huvmat,'UserData',UvData) |
---|
830 | %------------------------------------------------------------------------ |
---|
831 | % --- Executes on button press in MenuCoord. |
---|
832 | function MenuCoord_Callback(hObject, eventdata, handles) |
---|
833 | %------------------------------------------------------------------------ |
---|
834 | %---------------------------------------------------- |
---|
835 | function YMin_Callback(hObject, eventdata, handles) |
---|
836 | %------------------------------------------------------------------------ |
---|
837 | |
---|
838 | function ZMin_Callback(hObject, eventdata, handles) |
---|
839 | %------------------------------------------------------------------------ |
---|
840 | |
---|
841 | function ZMax_Callback(hObject, eventdata, handles) |
---|
842 | DZ=str2num(get(handles.ZMax,'String')); |
---|
843 | ZMin=get(handles.z_slider,'Min'); |
---|
844 | ZMax=get(handles.z_slider,'Max'); |
---|
845 | if ~isequal(ZMax-ZMin,0) |
---|
846 | rel_step(1)=DZ/(ZMax-ZMin); |
---|
847 | rel_step(2)=0.2; |
---|
848 | set(handles.z_slider,'SliderStep',rel_step) |
---|
849 | end |
---|
850 | %------------------------------------------------------------------------ |
---|
851 | function YMax_Callback(hObject, eventdata, handles) |
---|
852 | %------------------------------------------------------------------------ |
---|
853 | |
---|
854 | function XMin_Callback(hObject, eventdata, handles) |
---|
855 | %------------------------------------------------------------------------ |
---|
856 | |
---|
857 | function XMax_Callback(hObject, eventdata, handles) |
---|
858 | %------------------------------------------------------------------------ |
---|
859 | %------------------------------------------------------------------------ |
---|
860 | function SAVE_Callback(hObject, eventdata, handles) |
---|
861 | % ------------------------------------------------------ |
---|
862 | Object=read_set_object(handles); |
---|
863 | huvmat=findobj('Tag','uvmat'); |
---|
864 | % UvData=get(huvmat,'UserData'); |
---|
865 | if isempty(huvmat) |
---|
866 | huvmat=findobj(allchild(0),'Name','series'); |
---|
867 | end |
---|
868 | hchild=get(huvmat,'Children'); |
---|
869 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
870 | if isempty(hrootpath) |
---|
871 | RootPath=''; |
---|
872 | else |
---|
873 | RootPath=get(hrootpath,'String'); |
---|
874 | if iscell(RootPath) |
---|
875 | RootPath=RootPath{1}; |
---|
876 | end |
---|
877 | end |
---|
878 | title={'object name'}; |
---|
879 | dir_save=uigetdir(RootPath); |
---|
880 | ObjectName=get(handles.TITLE,'String'); |
---|
881 | if ~isempty(ObjectName)&&~strcmp(ObjectName,'') |
---|
882 | def={fullfile(dir_save,[ObjectName '.xml'])}; |
---|
883 | else |
---|
884 | def={fullfile(dir_save,[Object.Style '.xml'])}; |
---|
885 | end |
---|
886 | displ_txt='save object as an .xml file';%default display |
---|
887 | menu=get(handles.ProjMode,'String'); |
---|
888 | value=get(handles.ProjMode,'Value'); |
---|
889 | ProjMode=menu{value}; |
---|
890 | if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside') |
---|
891 | displ_txt='save mask contour as an .xml file: to create a mask image, use save_mask on the GUI uvmat (lower right)'; |
---|
892 | end |
---|
893 | answer=msgbox_uvmat('INPUT_TXT','save object as an .xml file',def); |
---|
894 | if ~isempty(answer) |
---|
895 | t=struct2xml(Object); |
---|
896 | save(t,answer{1}) |
---|
897 | end |
---|
898 | msgbox_uvmat('CONFIRMATION',[answer{1} ' saved']) |
---|
899 | %------------------------------------------------------------------------ |
---|
900 | %------------------------------------------------------------------------ |
---|
901 | % --- Executes on slider movement. |
---|
902 | function z_slider_Callback(hObject, eventdata, handles) |
---|
903 | %--------------------------------------------------------- |
---|
904 | %A ADAPTER |
---|
905 | Z_value=get(handles.z_slider,'Value'); |
---|
906 | |
---|
907 | %rotation angles |
---|
908 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
---|
909 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
---|
910 | |
---|
911 | %components of the unity vector normal to the projection plane |
---|
912 | NormVec_X=-sin(Phi)*sin(Theta); |
---|
913 | NormVec_Y=cos(Phi)*sin(Theta); |
---|
914 | NormVec_Z=cos(Theta); |
---|
915 | |
---|
916 | %set new plane position and update graph |
---|
917 | set(handles.XObject,'String',num2str(NormVec_X*Z_value,4)) |
---|
918 | set(handles.YObject,'String',num2str(NormVec_Y*Z_value,4)) |
---|
919 | set(handles.ZObject,'String',num2str(NormVec_Z*Z_value,4)) |
---|
920 | PLOT_Callback(hObject, eventdata, handles) |
---|
921 | %------------------------------------------------------------------------ |
---|
922 | %------------------------------------------------------------------------ |
---|
923 | % --- Executes on button press in HELP. |
---|
924 | function HELP_Callback(hObject, eventdata, handles) |
---|
925 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
926 | pathelp=fileparts(path_to_uvmat); |
---|
927 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
928 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
929 | else |
---|
930 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
931 | web([helpfile '#set_object']) |
---|
932 | end |
---|
933 | %------------------------------------------------------------------------ |
---|
934 | |
---|
935 | |
---|