1 | %'set_grid':produce grid for PIV with one or two images (stereo case) |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function varargout = set_grid(varargin) |
---|
4 | % associated with the GUI set_grid.fig |
---|
5 | % |
---|
6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
9 | % This file is part of the toolbox UVMAT. |
---|
10 | % |
---|
11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
12 | % it under the terms of the GNU General Public License as published by |
---|
13 | % the Free Software Foundation; either version 2 of the License, or |
---|
14 | % (at your option) any later version. |
---|
15 | % |
---|
16 | % UVMAT is distributed in the hope that it will be useful, |
---|
17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
21 | |
---|
22 | function varargout = set_grid(varargin) |
---|
23 | |
---|
24 | % Last Modified by GUIDE v2.5 04-Feb-2008 16:05:02 |
---|
25 | |
---|
26 | % Begin initialization code - DO NOT EDIT |
---|
27 | gui_Singleton = 1; |
---|
28 | gui_State = struct('gui_Name', mfilename, ... |
---|
29 | 'gui_Singleton', gui_Singleton, ... |
---|
30 | 'gui_OpeningFcn', @set_grid_OpeningFcn, ... |
---|
31 | 'gui_OutputFcn', @set_grid_OutputFcn, ... |
---|
32 | 'gui_LayoutFcn', [] , ... |
---|
33 | 'gui_Callback', []); |
---|
34 | if nargin & isstr(varargin{1}) |
---|
35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
36 | end |
---|
37 | |
---|
38 | if nargout |
---|
39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
40 | else |
---|
41 | gui_mainfcn(gui_State, varargin{:}); |
---|
42 | end |
---|
43 | % End initialization code - DO NOT EDIT |
---|
44 | |
---|
45 | %------------------------------------------------------------------- |
---|
46 | % --- Executes just before set_grid is made visible. |
---|
47 | %INPUT: |
---|
48 | % handles: handles of the set_grid interface elements |
---|
49 | %'IndexObj': index of the object (on the UvData list) that set_grid will modify |
---|
50 | % if =[] or absent: index still undefined (create mode in uvmat) |
---|
51 | % if=0; no associated object (used for series), the button 'PLOT' is then unvisible |
---|
52 | %'data': read from an existing object selected in the interface |
---|
53 | % .TITLE : class of object ('POINTS','LINE',....) |
---|
54 | % .DX,DY,DZ; meshes for regular grids |
---|
55 | % .Coord: object position coordinates |
---|
56 | % .ParentButton: handle of the uicontrol object calling the interface |
---|
57 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
---|
58 | % if =[] or absent, no plot (mask mode in uvmat) |
---|
59 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
---|
60 | function set_grid_OpeningFcn(hObject, eventdata, handles,inputfile) |
---|
61 | |
---|
62 | % Choose default command line output for set_grid |
---|
63 | handles.output = hObject; |
---|
64 | |
---|
65 | % Update handles structure |
---|
66 | guidata(hObject, handles); |
---|
67 | |
---|
68 | %default |
---|
69 | % set(hObject,'Unit','Normalized')% set the unit normalized to the screen size |
---|
70 | % set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the set_grid interface |
---|
71 | set(hObject,'DeleteFcn',@closefcn) |
---|
72 | set(handles.TITLE,'Value',1) |
---|
73 | set(handles.ObjectStyle,'Value',1) |
---|
74 | set(handles.ProjMode,'Value',1) |
---|
75 | set(handles.MenuCoord,'ListboxTop',1) |
---|
76 | set(handles.MenuCoord,'Value',1); |
---|
77 | set(handles.MenuCoord,'String',{'phys';'px'}); |
---|
78 | if exist('inputfile','var')& ~isempty(inputfile) |
---|
79 | set(handles.image_1,'String',inputfile) |
---|
80 | set(handles.image_2,'String',inputfile) |
---|
81 | end |
---|
82 | |
---|
83 | |
---|
84 | % --- Outputs from this function are returned to the command line. |
---|
85 | function varargout = set_grid_OutputFcn(hObject, eventdata, handles) |
---|
86 | % varargout cell array for returning output args (see VARARGOUT); |
---|
87 | % hObject handle to figure |
---|
88 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
89 | % handles structure with handles and user data (see GUIDATA) |
---|
90 | |
---|
91 | % Get default command line output from handles structure |
---|
92 | varargout{1} = handles.output; |
---|
93 | varargout{2}=handles; |
---|
94 | |
---|
95 | % --- Executes on selection change in ObjectStyle. |
---|
96 | function ObjectStyle_Callback(hObject, eventdata, handles) |
---|
97 | |
---|
98 | ProjMode_Callback(hObject, eventdata, handles) |
---|
99 | |
---|
100 | %---------------------------------------------- |
---|
101 | function xObject_Callback(hObject, eventdata, handles) |
---|
102 | |
---|
103 | |
---|
104 | function yObject_Callback(hObject, eventdata, handles) |
---|
105 | |
---|
106 | |
---|
107 | % --- Executes on selection change in zObject. |
---|
108 | function zObject_Callback(hObject, eventdata, handles) |
---|
109 | |
---|
110 | |
---|
111 | %--------------------------------------------------- |
---|
112 | % --- Executes on selection change in ProjMode. |
---|
113 | function ProjMode_Callback(hObject, eventdata, handles) |
---|
114 | menu=get(handles.ProjMode,'String'); |
---|
115 | value=get(handles.ProjMode,'Value'); |
---|
116 | ProjMode=menu{value}; |
---|
117 | menu=get(handles.ObjectStyle,'String'); |
---|
118 | value=get(handles.ObjectStyle,'Value'); |
---|
119 | ObjectStyle=menu{value}; |
---|
120 | test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case |
---|
121 | if isequal(ObjectStyle,'plane')||isequal(ObjectStyle,'volume') |
---|
122 | set(handles.Phi,'Visible','on') |
---|
123 | if test3D%3D case |
---|
124 | set(handles.Theta,'Visible','on') |
---|
125 | set(handles.Psi,'Visible','on') |
---|
126 | end |
---|
127 | set(handles.XMin,'Visible','on') |
---|
128 | set(handles.XMax,'Visible','on') |
---|
129 | set(handles.YMin,'Visible','on') |
---|
130 | set(handles.YMax,'Visible','on') |
---|
131 | if test3D |
---|
132 | set(handles.Theta,'Visible','on') |
---|
133 | set(handles.Psi,'Visible','on') |
---|
134 | set(handles.ZMin,'Visible','on') |
---|
135 | set(handles.ZMax,'Visible','on') |
---|
136 | end |
---|
137 | else |
---|
138 | set(handles.Phi,'Visible','off') |
---|
139 | set(handles.Theta,'Visible','off') |
---|
140 | set(handles.Psi,'Visible','off') |
---|
141 | set(handles.XMin,'Visible','off') |
---|
142 | set(handles.XMax,'Visible','off') |
---|
143 | set(handles.YMin,'Visible','off') |
---|
144 | if isequal(ProjMode,'interp') |
---|
145 | set(handles.YMax,'Visible','off') |
---|
146 | else |
---|
147 | set(handles.YMax,'Visible','on') |
---|
148 | end |
---|
149 | if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse') |
---|
150 | set(handles.XMax,'Visible','on') |
---|
151 | else |
---|
152 | set(handles.XMax,'Visible','off') |
---|
153 | end |
---|
154 | set(handles.ZMin,'Visible','off') |
---|
155 | set(handles.ZMax,'Visible','off') |
---|
156 | end |
---|
157 | if isequal(ProjMode,'projection')|isequal(ProjMode,'inside')|isequal(ProjMode,'outside')|isequal(ObjectStyle,'points') |
---|
158 | set(handles.DX,'Visible','off') |
---|
159 | set(handles.DY,'Visible','off') |
---|
160 | set(handles.DZ,'Visible','off') |
---|
161 | else |
---|
162 | set(handles.DX,'Visible','on') |
---|
163 | set(handles.DY,'Visible','on') |
---|
164 | if test3D%3D case |
---|
165 | set(handles.DZ,'Visible','on') |
---|
166 | end |
---|
167 | end |
---|
168 | |
---|
169 | %--------------------------------------------- |
---|
170 | % --- Executes on selection change in TITLE. |
---|
171 | function TITLE_Callback(hObject, eventdata, handles) |
---|
172 | hsetobject=get(handles.TITLE,'parent'); |
---|
173 | SetData=get(hsetobject,'UserData');%get the hidden interface data |
---|
174 | % function named CALLBACK in UNTITLED.M with the given input arguments. |
---|
175 | menu=get(handles.TITLE,'String'); |
---|
176 | value=get(handles.TITLE,'Value'); |
---|
177 | titl=menu{value}; |
---|
178 | if isequal(titl,'POINTS') |
---|
179 | menu_style={'points'}; |
---|
180 | menu_proj={'projection';'interp';'filter';'none'}; |
---|
181 | elseif isequal(titl,'LINE') |
---|
182 | menu_style={'line';'polyline';'rectangle';'polygon';'ellipse'};%'line' =default |
---|
183 | menu_proj={'projection';'interp';'filter';'none'}; |
---|
184 | elseif isequal(titl,'PATCH') |
---|
185 | menu_style={'rectangle';'polygon';'ellipse'};%'line' =default |
---|
186 | menu_proj={'inside';'outside';'none'}; |
---|
187 | elseif isequal(titl,'PLANE') |
---|
188 | menu_style={'plane'}; |
---|
189 | menu_proj={'projection';'interp'}; |
---|
190 | elseif isequal(titl,'VOLUME') |
---|
191 | menu_style={'volume'}; |
---|
192 | menu_proj={'none'}; |
---|
193 | |
---|
194 | end |
---|
195 | set(handles.ObjectStyle,'String',menu_style) |
---|
196 | set(handles.ObjectStyle,'Value',1) |
---|
197 | set(handles.ProjMode,'String',menu_proj) |
---|
198 | set(handles.ProjMode,'Value',1) |
---|
199 | if isfield(SetData,'ParentButton') |
---|
200 | update_parentbutton(SetData.ParentButton,titl) |
---|
201 | end |
---|
202 | ObjectStyle_Callback(hObject, eventdata, handles) |
---|
203 | |
---|
204 | %----------- |
---|
205 | function update_parentbutton(ParentButton,titl) |
---|
206 | |
---|
207 | if isstruct(ParentButton) |
---|
208 | parentfields=fields(ParentButton); |
---|
209 | for ibutton=1:length(parentfields) |
---|
210 | buttonhandle=eval(['ParentButton.' parentfields{ibutton}]); |
---|
211 | if ishandle(buttonhandle) |
---|
212 | set(buttonhandle,'Value',0) |
---|
213 | set(buttonhandle,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
214 | end |
---|
215 | end |
---|
216 | if isfield(ParentButton,titl) |
---|
217 | buttonhandle=eval(['ParentButton.' titl]); |
---|
218 | if ishandle(buttonhandle) |
---|
219 | set(buttonhandle,'Value',1) |
---|
220 | set(buttonhandle,'BackgroundColor',[1 1 0])%put activated button to yellow |
---|
221 | end |
---|
222 | end |
---|
223 | end |
---|
224 | %------------ |
---|
225 | function Phi_Callback(hObject, eventdata, handles) |
---|
226 | update_slider(hObject, eventdata,handles) |
---|
227 | |
---|
228 | function Theta_Callback(hObject, eventdata, handles) |
---|
229 | update_slider(hObject, eventdata,handles) |
---|
230 | |
---|
231 | function update_slider(hObject, eventdata,handles) |
---|
232 | %rotation angles |
---|
233 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
---|
234 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
---|
235 | |
---|
236 | %components of the unitiy vector normal to the projection plane |
---|
237 | NormVec_X=-sin(Phi)*sin(Theta); |
---|
238 | NormVec_Y=cos(Phi)*sin(Theta); |
---|
239 | NormVec_Z=cos(Theta); |
---|
240 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
241 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
242 | Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z); |
---|
243 | set(handles.z_slider,'Min',min(Z)) |
---|
244 | set(handles.z_slider,'Max',max(Z)) |
---|
245 | ZMax_Callback(hObject, eventdata, handles) |
---|
246 | |
---|
247 | function DX_Callback(hObject, eventdata, handles) |
---|
248 | |
---|
249 | |
---|
250 | function DY_Callback(hObject, eventdata, handles) |
---|
251 | |
---|
252 | |
---|
253 | function DZ_Callback(hObject, eventdata, handles) |
---|
254 | |
---|
255 | |
---|
256 | |
---|
257 | %----------------------------------------------------- |
---|
258 | % --- Executes on button press in import. |
---|
259 | function import_Callback(hObject, eventdata, handles) |
---|
260 | %get the object file |
---|
261 | oldfile=''; |
---|
262 | huvmat=findobj('Tag','uvmat'); |
---|
263 | if isempty(huvmat) |
---|
264 | huvmat=findobj(allchild(0),'Name','series'); |
---|
265 | end |
---|
266 | hchild=get(huvmat,'Children'); |
---|
267 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
268 | oldfile=get(hrootpath,'String'); |
---|
269 | if iscell(oldfile) |
---|
270 | oldfile=oldfile{1}; |
---|
271 | end |
---|
272 | %[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile) |
---|
273 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
274 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
275 | '*.xml', '.xml files '; ... |
---|
276 | '*.mat', '.mat matlab files '}, ... |
---|
277 | 'Pick a file',oldfile); |
---|
278 | fileinput=[PathName FileName];%complete file name |
---|
279 | testblank=findstr(fileinput,' ');%look for blanks |
---|
280 | if ~isempty(testblank) |
---|
281 | errordlg('forbidden input file name: contain blanks') |
---|
282 | return |
---|
283 | end |
---|
284 | sizf=size(fileinput); |
---|
285 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
---|
286 | |
---|
287 | %read the file |
---|
288 | t=xmltree(fileinput); |
---|
289 | s=convert(t); |
---|
290 | %Display title |
---|
291 | title=set_title(s.Style,s.ProjMode);%update the title |
---|
292 | % menu=get(handles.TITLE,'String') |
---|
293 | % for iline=1:length(menu) |
---|
294 | % if isequal(menu{iline},title) |
---|
295 | % set(handles.TITLE,'Value',iline) |
---|
296 | % break |
---|
297 | % end |
---|
298 | % end |
---|
299 | % TITLE_Callback(hObject, eventdata, handles) |
---|
300 | % teststyle=0; |
---|
301 | % if isfield(s,'Style') |
---|
302 | % menu=get(handles.ObjectStyle,'String'); |
---|
303 | % for iline=1:length(menu) |
---|
304 | % if isequal(menu{iline},s.Style) |
---|
305 | % set(handles.ObjectStyle,'Value',iline) |
---|
306 | % teststyle=1; |
---|
307 | % break |
---|
308 | % end |
---|
309 | % end |
---|
310 | % end |
---|
311 | % if teststyle==0; |
---|
312 | % s.Style='points'; |
---|
313 | % set(handles.ObjectStyle,'Value',1); %default (points) |
---|
314 | % end |
---|
315 | testmode=0; |
---|
316 | if isfield(s,'ProjMode') |
---|
317 | menu=get(handles.ProjMode,'String'); |
---|
318 | for iline=1:length(menu) |
---|
319 | if isequal(menu{iline},s.ProjMode) |
---|
320 | set(handles.ProjMode,'Value',iline) |
---|
321 | testmode=1; |
---|
322 | break |
---|
323 | end |
---|
324 | end |
---|
325 | end |
---|
326 | |
---|
327 | ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes |
---|
328 | if isfield(s,'CoordType') |
---|
329 | if isequal(s.CoordType,'phys') |
---|
330 | set(handles.MenuCoord,'Value',1) |
---|
331 | elseif isequal(s.CoordType,'px') |
---|
332 | set(handles.MenuCoord,'Value',2) |
---|
333 | else |
---|
334 | warndlg('unknown CoordType (px or phys) in set_grid.m') |
---|
335 | end |
---|
336 | end |
---|
337 | if isfield(s,'XMax') |
---|
338 | set(handles.XMax,'String',s.XMax) |
---|
339 | end |
---|
340 | if isfield(s,'XMin') |
---|
341 | set(handles.XMin,'String',s.XMin) |
---|
342 | end |
---|
343 | if isfield(s,'YMax') |
---|
344 | set(handles.YMax,'String',s.YMax) |
---|
345 | end |
---|
346 | if isfield(s,'YMin') |
---|
347 | set(handles.YMin,'String',s.YMin) |
---|
348 | end |
---|
349 | if isfield(s,'DX') |
---|
350 | set(handles.DX,'String',s.DX) |
---|
351 | end |
---|
352 | if isfield(s,'DY') |
---|
353 | set(handles.DY,'String',s.DY) |
---|
354 | end |
---|
355 | if ~isfield(s,'Coord') |
---|
356 | XObject='0';%default |
---|
357 | YObject='0'; |
---|
358 | elseif ischar(s.Coord) |
---|
359 | line=str2num(s.Coord); |
---|
360 | XObject=num2str(line(1)); |
---|
361 | YObject=num2str(line(2)); |
---|
362 | else |
---|
363 | for i=1:length(s.Coord) |
---|
364 | line=str2num(s.Coord{i}); |
---|
365 | XObject{i}=num2str(line(1)); |
---|
366 | YObject{i}=num2str(line(2)); |
---|
367 | end |
---|
368 | end |
---|
369 | set(handles.XObject,'String',XObject) |
---|
370 | set(handles.YObject,'String',YObject) |
---|
371 | %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_grid_Opening |
---|
372 | |
---|
373 | %---------------------------------------------------- |
---|
374 | % executed when closing: set the parent interface button to value 0 |
---|
375 | function closefcn(gcbo,eventdata) |
---|
376 | huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle |
---|
377 | parent_button=findobj(huvmat,'Tag','grid'); |
---|
378 | if ~isempty(parent_button) |
---|
379 | set(parent_button,'Value',0)%put unactivated buttons to green |
---|
380 | tag=get(parent_button,'Tag'); |
---|
381 | if isequal(tag,'edit') |
---|
382 | set(parent_button,'BackgroundColor',[0.7 0.7 0.7]); |
---|
383 | else |
---|
384 | set(parent_button,'BackgroundColor',[0 1 0]); |
---|
385 | end |
---|
386 | end |
---|
387 | |
---|
388 | %----------------------------------------------------------------------- |
---|
389 | % --- Executes on button press in edit: PLOT the defined object and its projected field |
---|
390 | function edit_Callback(hObject, eventdata, handles) |
---|
391 | hsetobject=get(hObject,'parent'); |
---|
392 | SetData=get(hsetobject,'UserData');%get the hidden interface data |
---|
393 | %IndexObj=SetData.IndexObj%index of the current projection object in the list of projection objects (UvData.ProjObject) |
---|
394 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
395 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
396 | if isfield(UvData,'CuurentObjectIndex') |
---|
397 | IndexObj=UvData.CurrentObjectIndex; |
---|
398 | else |
---|
399 | IndexObj=[]; |
---|
400 | end |
---|
401 | ObjectData=read_set_grid(handles);%read the interface input parameters defining the object |
---|
402 | [UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles); |
---|
403 | uvmat('write_plot_param',PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object |
---|
404 | SetData.IndexObj=IndexObj; |
---|
405 | set(gcbf,'UserData',SetData)%update object index in the set_grid interface |
---|
406 | set(huvmat,'UserData',UvData)%update the data in the uvmat interface |
---|
407 | |
---|
408 | |
---|
409 | % --- Executes on button press in MenuCoord. |
---|
410 | function MenuCoord_Callback(hObject, eventdata, handles) |
---|
411 | |
---|
412 | |
---|
413 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
414 | % --- Executes on button press in delete. |
---|
415 | function delete_Callback(hObject, eventdata, handles) |
---|
416 | |
---|
417 | %SetData=get(gcbf,'UserData');%get the interface data |
---|
418 | %IndexObj=SetData.IndexObj; |
---|
419 | huvmat=findobj('Name','uvmat');%find the current uvmat interface handle |
---|
420 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
421 | if isfield(UvData,'CurrentObjectIndex') |
---|
422 | IndexObj=UvData.CurrentObjectIndex; |
---|
423 | else |
---|
424 | IndexObj=[]; |
---|
425 | end |
---|
426 | delete_object(IndexObj); |
---|
427 | |
---|
428 | %---------------------------------------------------- |
---|
429 | function YMin_Callback(hObject, eventdata, handles) |
---|
430 | % hObject handle to YMin (see GCBO) |
---|
431 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
432 | % handles structure with handles and user data (see GUIDATA) |
---|
433 | |
---|
434 | % Hints: get(hObject,'String') returns contents of YMin as text |
---|
435 | % str2double(get(hObject,'String')) returns contents of YMin as a double |
---|
436 | |
---|
437 | |
---|
438 | function ZMin_Callback(hObject, eventdata, handles) |
---|
439 | |
---|
440 | |
---|
441 | function ZMax_Callback(hObject, eventdata, handles) |
---|
442 | DZ=str2num(get(handles.ZMax,'String')); |
---|
443 | ZMin=get(handles.z_slider,'Min'); |
---|
444 | ZMax=get(handles.z_slider,'Max'); |
---|
445 | rel_step(1)=DZ/(ZMax-ZMin); |
---|
446 | rel_step(2)=0.2; |
---|
447 | set(handles.z_slider,'SliderStep',rel_step) |
---|
448 | |
---|
449 | function YMax_Callback(hObject, eventdata, handles) |
---|
450 | |
---|
451 | |
---|
452 | function XMin_Callback(hObject, eventdata, handles) |
---|
453 | |
---|
454 | |
---|
455 | function XMax_Callback(hObject, eventdata, handles) |
---|
456 | |
---|
457 | |
---|
458 | % ------------------------------------------------------ |
---|
459 | function save_Callback(hObject, eventdata, handles) |
---|
460 | % ------------------------------------------------------ |
---|
461 | Object=read_set_object(handles);%read the set_grid interface; |
---|
462 | DX=Object.DX; |
---|
463 | DY=Object.DY; |
---|
464 | RangeX=Object.RangeX; |
---|
465 | RangeY=Object.RangeY; |
---|
466 | array_realx=[RangeX(2):DX:RangeX(1)]; |
---|
467 | array_realy=[RangeY(2):DY:RangeY(1)]; |
---|
468 | nx_patch=length(array_realx); |
---|
469 | ny_patch=length(array_realy); |
---|
470 | [grid_realx,grid_realy]=meshgrid(array_realx,array_realy); |
---|
471 | grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1); |
---|
472 | grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1); |
---|
473 | grid_real(:,3)=zeros(nx_patch*ny_patch,1); |
---|
474 | |
---|
475 | imageA=get(handles.image_1,'String'); |
---|
476 | imageB=get(handles.image_2,'String'); |
---|
477 | testB=1; |
---|
478 | if isempty(imageA) | isequal(imageA,'') |
---|
479 | if isempty(imageB) | isequal(imageB,'') |
---|
480 | warndlg_uvmat('at least one image file name must be introduced','ERROR') |
---|
481 | else |
---|
482 | imageA=imageB; |
---|
483 | testB=0; |
---|
484 | end |
---|
485 | end |
---|
486 | if isempty(imageB) || isequal(imageB,'') || isequal(imageA,imageB) |
---|
487 | testB=0; |
---|
488 | end |
---|
489 | |
---|
490 | testexist=exist(imageA,'file'); |
---|
491 | if isequal(testexist,0) |
---|
492 | msgbox_uvmat('ERROR',['input image file' imageA 'does not exist']) |
---|
493 | return |
---|
494 | end |
---|
495 | [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageA); |
---|
496 | form=imformats(ext([2:end])); |
---|
497 | if isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
498 | msgbox_uvmat('ERROR',['error in read_image.m: ' imageA ' is not an image name recognized by Matlab ']) |
---|
499 | return |
---|
500 | end |
---|
501 | fileAxml=[fullfile(Pathsub,RootFile) '.xml']; |
---|
502 | [XmlDataA,error]=imadoc2struct(fileAxml); |
---|
503 | if isfield(XmlDataA,'GeometryCalib') |
---|
504 | tsaiA=XmlDataA.GeometryCalib; |
---|
505 | else |
---|
506 | msgbox_uvmat('WARNING','no geometric calibration available for image A') |
---|
507 | tsaiA=[]; |
---|
508 | end |
---|
509 | [grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2),0); |
---|
510 | A=imread(imageA); |
---|
511 | siz=size(A); |
---|
512 | npxA=siz(2); |
---|
513 | npyA=siz(1); |
---|
514 | |
---|
515 | flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA; |
---|
516 | |
---|
517 | if testB |
---|
518 | testexist=exist(imageB,'file'); |
---|
519 | if isequal(testexist,0) |
---|
520 | warndlg_uvmat(['input image file' imageB 'does not exist'],'ERROR') |
---|
521 | return |
---|
522 | end |
---|
523 | [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageB); |
---|
524 | form=imformats(ext([2:end])); |
---|
525 | if isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
526 | warndlg_uvmat(['error in read_image.m: ' imageB ' is not an image name recognized by Matlab '],'ERROR') |
---|
527 | return |
---|
528 | end |
---|
529 | fileBxml=[fullfile(Pathsub,RootFile) '.xml']; |
---|
530 | [XmlDataB,error]=imadoc2struct(fileBxml); |
---|
531 | if isfield(XmlDataB,'GeometryCalib') |
---|
532 | tsaiB=XmlDataB.GeometryCalib; |
---|
533 | else |
---|
534 | warndlg_uvmat('no geometric calibration available for image B','WARNING') |
---|
535 | tsaiB=[]; |
---|
536 | end |
---|
537 | %[error,Heading,nom_type_read,ext_ima_read,time,TimeUnit,mode,NbSlice,... |
---|
538 | % npxB,npyB,tsaiB]=read_imadoc(fileBxml,0); |
---|
539 | [grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2),0); |
---|
540 | % if isempty(npxB)|isempty(npyB) |
---|
541 | B=imread(imageB); |
---|
542 | siz=size(B); |
---|
543 | npxB=siz(2); |
---|
544 | npyB=siz(1); |
---|
545 | % end |
---|
546 | flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB; |
---|
547 | end |
---|
548 | if testB |
---|
549 | ind_good=find(flagA==1&flagB==1); |
---|
550 | XimaB=grid_imaB(ind_good,1); |
---|
551 | YimaB=grid_imaB(ind_good,2); |
---|
552 | else |
---|
553 | ind_good=find(flagA==1); |
---|
554 | end |
---|
555 | XimaA=grid_imaA(ind_good,1); |
---|
556 | YimaA=grid_imaA(ind_good,2); |
---|
557 | |
---|
558 | grid_real_x=grid_real(ind_good,1); |
---|
559 | grid_real_y=grid_real(ind_good,2); |
---|
560 | nx_patch_new=length(grid_real_x); |
---|
561 | grid_real2(:,1)=grid_real_x; |
---|
562 | grid_real2(:,2)=grid_real_y; |
---|
563 | grid_real2(:,3)=zeros(nx_patch_new,1); |
---|
564 | [grid_pix_A(:,1),grid_pix_A(:,2)]=px_XYZ(tsaiA,grid_real2(:,1),grid_real2(:,2)); |
---|
565 | if testB |
---|
566 | [grid_pix_B(:,1),grid_pix_B(:,2)]=px_XYZ(tsaiB,grid_real2(:,1),grid_real2(:,2)); |
---|
567 | end |
---|
568 | |
---|
569 | %ECRIRE FICHIERS |
---|
570 | nbpointsA=size(grid_pix_A); |
---|
571 | XA=grid_pix_A(:,1); |
---|
572 | YA=grid_pix_A(:,2); |
---|
573 | unitcolumn=32*ones(size(XA)); |
---|
574 | Xchar=num2str(XA); |
---|
575 | blanc=char(unitcolumn); |
---|
576 | Ychar=num2str(YA); |
---|
577 | tete=['1 ' num2str(nbpointsA(1))]; |
---|
578 | txt=[Xchar blanc Ychar]; |
---|
579 | textgrid={tete;txt}; |
---|
580 | textout=char(textgrid); |
---|
581 | Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridA.grid')); |
---|
582 | % Answer = inputdlg('grid file name (*.grid)',' ',1,{fullfile(Pathsub,'gridA.grid')},'on'); |
---|
583 | dlmwrite(Answer,textout,''); |
---|
584 | msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); |
---|
585 | if testB |
---|
586 | nbpointsB=size(grid_pix_B); |
---|
587 | XB=grid_pix_B(:,1); |
---|
588 | YB=grid_pix_B(:,2); |
---|
589 | unitcolumn=32*ones(size(XB)); |
---|
590 | Xchar=num2str(XB); |
---|
591 | blanc=char(unitcolumn); |
---|
592 | Ychar=num2str(YB); |
---|
593 | tete=['1 ' num2str(nbpointsB(1))]; |
---|
594 | txt=[Xchar blanc Ychar]; |
---|
595 | textgrid={tete;txt}; |
---|
596 | textout=char(textgrid); |
---|
597 | Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridB.grid')); |
---|
598 | dlmwrite(Answer,textout,''); |
---|
599 | msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); |
---|
600 | end |
---|
601 | |
---|
602 | |
---|
603 | %------------------------------------------------ |
---|
604 | function TITLE=set_title(Style,ProjMode) |
---|
605 | %------------------------------------------------ |
---|
606 | if isequal(Style,'points') |
---|
607 | TITLE='POINTS'; |
---|
608 | elseif isequal(Style,'line')|isequal(Style,'polyline') |
---|
609 | TITLE='LINE'; |
---|
610 | elseif isequal(Style,'plane') |
---|
611 | TITLE='PLANE'; |
---|
612 | elseif isequal(Style,'volume') |
---|
613 | TITLE='VOLUME'; |
---|
614 | elseif isequal(Style,'polygon')|isequal(Style,'rectangle')|isequal(Style,'ellipse') |
---|
615 | if isequal(ProjMode,'inside')|isequal(ProjMode,'outside') |
---|
616 | TITLE='PATCH'; |
---|
617 | else |
---|
618 | TITLE='LINE'; |
---|
619 | end |
---|
620 | end |
---|
621 | |
---|
622 | |
---|
623 | % --- Executes on slider movement. |
---|
624 | function z_slider_Callback(hObject, eventdata, handles) |
---|
625 | %A ADAPTER |
---|
626 | Z_value=get(handles.z_slider,'Value'); |
---|
627 | |
---|
628 | %rotation angles |
---|
629 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
---|
630 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
---|
631 | |
---|
632 | %components of the unity vector normal to the projection plane |
---|
633 | NormVec_X=-sin(Phi)*sin(Theta); |
---|
634 | NormVec_Y=cos(Phi)*sin(Theta); |
---|
635 | NormVec_Z=cos(Theta); |
---|
636 | |
---|
637 | %set new plane position and update graph |
---|
638 | set(handles.XObject,'String',num2str(NormVec_X*Z_value)) |
---|
639 | set(handles.YObject,'String',num2str(NormVec_Y*Z_value)) |
---|
640 | set(handles.ZObject,'String',num2str(NormVec_Z*Z_value)) |
---|
641 | edit_Callback(hObject, eventdata, handles) |
---|
642 | |
---|
643 | |
---|
644 | |
---|
645 | function XObject_Callback(hObject, eventdata, handles) |
---|
646 | |
---|
647 | |
---|
648 | function YObject_Callback(hObject, eventdata, handles) |
---|
649 | |
---|
650 | |
---|
651 | |
---|
652 | |
---|
653 | function ZObject_Callback(hObject, eventdata, handles) |
---|
654 | |
---|
655 | |
---|
656 | function image_2_Callback(hObject, eventdata, handles) |
---|
657 | % hObject handle to image_2 (see GCBO) |
---|
658 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
659 | % handles structure with handles and user data (see GUIDATA) |
---|
660 | |
---|
661 | % Hints: get(hObject,'String') returns contents of image_2 as text |
---|
662 | % str2double(get(hObject,'String')) returns contents of image_2 as a double |
---|
663 | |
---|
664 | |
---|
665 | |
---|
666 | function image_1_Callback(hObject, eventdata, handles) |
---|
667 | % hObject handle to image_1 (see GCBO) |
---|
668 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
669 | % handles structure with handles and user data (see GUIDATA) |
---|
670 | |
---|
671 | % Hints: get(hObject,'String') returns contents of image_1 as text |
---|
672 | % str2double(get(hObject,'String')) returns contents of image_1 as a double |
---|
673 | |
---|
674 | |
---|
675 | % --- Executes on button press in HELP. |
---|
676 | function HELP_Callback(hObject, eventdata, handles) |
---|
677 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
678 | pathelp=fileparts(path_to_uvmat); |
---|
679 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
680 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
681 | else |
---|
682 | web([helpfile '#set_grid']) |
---|
683 | end |
---|
684 | |
---|