1 | %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function huvmat=uvmat(input) |
---|
4 | % |
---|
5 | %OUTPUT |
---|
6 | % huvmat=current handles of the GUI uvmat.fig |
---|
7 | %% |
---|
8 | % |
---|
9 | %INPUT: |
---|
10 | % input: input file name (if character chain), or input image matrix to |
---|
11 | % visualize, or Matlab structure representing netcdf fieldname (with fieldname |
---|
12 | % ListVarName....) |
---|
13 | % |
---|
14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr. |
---|
16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
17 | % This open is part of the toolbox UVMAT. |
---|
18 | % |
---|
19 | % UVMAT is free software; you can redistribute it and/or modify |
---|
20 | % it under the terms of the GNU General Public License as published by |
---|
21 | % the Free Software Foundation; either version 2 of the License, or |
---|
22 | % (at your option) any later version. |
---|
23 | % |
---|
24 | % UVMAT is distributed in the hope that it will be useful, |
---|
25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details. |
---|
28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
29 | % |
---|
30 | % Information stored on the interface:(use 'Export/field in workspace' in |
---|
31 | % the menu bar of uvmat to retrieve it) |
---|
32 | % .OpenParam: structure containing parameters defined when uvmat is opened |
---|
33 | % .PosColorbar: position (1x4 vector)of the colorbar (relative to the fig uvmat) |
---|
34 | % .PosSetObject: position of set_object |
---|
35 | % .PosGeometryCalib: size of set_object |
---|
36 | % .NbBuiltin: nbre of functions always displayed in transform_fct menu |
---|
37 | % .Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default |
---|
38 | % .NewSeries: =0/1 flag telling whether a new field series has been opened |
---|
39 | % .FileName_1: name of the current second field (used to detect a constant field during file scanning) |
---|
40 | % .FileType: current file type, as defined by the fct get_file_type.m) |
---|
41 | % .i1_series,.i2_series,.j1_series,.j1_series: series of i1,i2,j1,j2 indices detected in the input dir,set by the fct find_file_series |
---|
42 | % .MovieObject: current movie object |
---|
43 | % .TimeUnit: unit for time |
---|
44 | % .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fieldname (containing timing and geometry calibration) |
---|
45 | % .Field: cell array of 1 or 2 structures representing the current input field(s) |
---|
46 | % .PlotAxes: field structure representing the current field plotted on the main axes (used for mouse operations) |
---|
47 | % .HistoAxes: idem for histogram axes |
---|
48 | |
---|
49 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%: |
---|
50 | % |
---|
51 | % |
---|
52 | % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 |
---|
53 | % (second field), or by the stored file name .FileName_1, or as an input of uvmat. |
---|
54 | % 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes |
---|
55 | % 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) |
---|
56 | % 4) Then fieldname are opened and visualised by the main sub-function 'uvmat/refresh_field.m' |
---|
57 | % The function first reads the name of the input file(s) (one or two) from the edit boxes of the GUI |
---|
58 | % It then reads the input file(s) with the function read_field.m and perform the following list of operations: |
---|
59 | % |
---|
60 | % %%%%%%%% structure of uvmat/refresh_field.m %%%%%%%% |
---|
61 | % |
---|
62 | % Main input open second input open_1 |
---|
63 | % | | |
---|
64 | % read_field.m read_field.m |
---|
65 | % | | |
---|
66 | % Field{1} Field{2} |
---|
67 | % | | |
---|
68 | % --->transform fct<--- transform (e.g. phys.m) and combine input fieldname |
---|
69 | % | |
---|
70 | % (calc_tps.m) calculate tps coefficients (for filter projection or spatial derivatives). |
---|
71 | % | |
---|
72 | % UvData.Field-------------->histogram |
---|
73 | % _____________|____________ |
---|
74 | % | | |
---|
75 | % proj_field.m proj_field.m project the field on the projection objects (use calc_field.m) |
---|
76 | % | | |
---|
77 | % UvData.PlotAxes ViewData.PlotAxes (on view_field) |
---|
78 | % | | |
---|
79 | % plot_field.m (uvmat) plot_field.m (view_field) plot the projected fieldname |
---|
80 | % |
---|
81 | % |
---|
82 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% |
---|
83 | % scalars are displayed either as an image or countour plot, either as a color of |
---|
84 | % velocity vectors. The scalar values in the first case is represented by |
---|
85 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X |
---|
86 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and |
---|
87 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar |
---|
88 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the |
---|
89 | % coordinates of the four image corners. The scalar name is represented by |
---|
90 | % the strings .AName and/or .CName. |
---|
91 | % If the scalar exists in an input open (image or scalar stored under its |
---|
92 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. |
---|
93 | % Else only its name AName is recorded in Field{i}, and its field is then calculated |
---|
94 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object |
---|
95 | |
---|
96 | % Properties attached to plotting figures (standard Matlab properties): |
---|
97 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes'); |
---|
98 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned |
---|
99 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned |
---|
100 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure |
---|
101 | % 'KeyPressFcn': function called by pressing a key on the key board |
---|
102 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure |
---|
103 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure |
---|
104 | |
---|
105 | % Properties attached to plotting axes: |
---|
106 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. |
---|
107 | % AxeData:=get(gca,'UserData'); |
---|
108 | % AxeData.Drawing = create: create a new object |
---|
109 | % = deform: modify an existing object by moving its defining create |
---|
110 | % = off: no current drawing action |
---|
111 | % = translate: translate an existing object |
---|
112 | % = calibration: move a calibration point |
---|
113 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) |
---|
114 | % .CurrentOrigin: Origin of a curently drawn edit_object |
---|
115 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
116 | % .CurrentObject: handle of the currently drawn edit_object |
---|
117 | % .CurrentRectZoom: current rectangle used for CheckZoom |
---|
118 | |
---|
119 | % Properties attached to projection objects (create, menuline, menuplane...): |
---|
120 | % 'Tag'='proj_object': for all projection objects |
---|
121 | % ObjectData.Type=...: style of projection object: |
---|
122 | % .ProjMode |
---|
123 | % .Coord: defines the position of the object |
---|
124 | % .XMin,YMin.... |
---|
125 | % .XMax,YMax.... |
---|
126 | % .DX,DY,DZ |
---|
127 | % .Phi, .Theta, .Psi : Euler angles |
---|
128 | % .X,.Y,.U,.V.... : field data projected on the object |
---|
129 | % .IndexObj: index in the list of UvData.Object |
---|
130 | %during plotting |
---|
131 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object |
---|
132 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes |
---|
133 | % To each projection object #iobj, corresponds an axis |
---|
134 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the |
---|
135 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field; |
---|
136 | |
---|
137 | %------------------------------------------------------------------------ |
---|
138 | %------------------------------------------------------------------------ |
---|
139 | % I - MAIN FUNCTION uvmat |
---|
140 | %------------------------------------------------------------------------ |
---|
141 | %------------------------------------------------------------------------ |
---|
142 | function varargout = uvmat(varargin) |
---|
143 | |
---|
144 | % Begin initialization code - DO NOT EDIT |
---|
145 | gui_Singleton = 1; |
---|
146 | gui_State = struct('gui_Name', mfilename, ... |
---|
147 | 'gui_Singleton', gui_Singleton, ... |
---|
148 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ... |
---|
149 | 'gui_OutputFcn', @uvmat_OutputFcn, ... |
---|
150 | 'gui_LayoutFcn', [], ... |
---|
151 | 'gui_Callback', []); |
---|
152 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
153 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
154 | end |
---|
155 | |
---|
156 | if nargout |
---|
157 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:}); |
---|
158 | else |
---|
159 | gui_mainfcn(gui_State, varargin{:}); |
---|
160 | end |
---|
161 | % End initialization code - DO NOT EDIT |
---|
162 | |
---|
163 | %------------------------------------------------------------------------ |
---|
164 | % --- Executes just before the GUI uvmat is made visible. |
---|
165 | function uvmat_OpeningFcn(hObject, eventdata, handles, input ) |
---|
166 | %------------------------------------------------------------------------ |
---|
167 | |
---|
168 | %% Choose default command menuline output for uvmat (standard GUI) |
---|
169 | handles.output = hObject; |
---|
170 | |
---|
171 | %% Update handles structure (standard GUI) |
---|
172 | guidata(hObject, handles); |
---|
173 | |
---|
174 | %% add the path to uvmat (useful if uvmat has been opened in the working directory and a working directory change occured) |
---|
175 | path_uvmat=fileparts(which('uvmat')); |
---|
176 | |
---|
177 | %% set the position of colorbar and ancillary GUIs: |
---|
178 | set(hObject,'Units','Normalized') |
---|
179 | movegui(hObject,'center') |
---|
180 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445]; |
---|
181 | UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object |
---|
182 | UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib (TO IMPROVE) |
---|
183 | % UvData.OpenParam.CalSize=[0.28 1]; |
---|
184 | % UvData.PlotAxes=[];%initiate the record of plotted field |
---|
185 | % UvData.axes2=[]; |
---|
186 | % UvData.axes1=[]; |
---|
187 | AxeData.LimEditBox=1; %initialise AxeData |
---|
188 | set(handles.PlotAxes,'UserData',AxeData) |
---|
189 | |
---|
190 | %% set functions for the mouse and keyboard |
---|
191 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
192 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
193 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
194 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
195 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
196 | |
---|
197 | %% initialisation |
---|
198 | % set(handles.ListObject,'Value',1)% default: empty projection objectproj_field |
---|
199 | % set(handles.ListObject,'String',{''}) |
---|
200 | % set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field |
---|
201 | % set(handles.ListObject_1,'String',{''}) |
---|
202 | set(handles.FieldName,'Value',1) |
---|
203 | set(handles.FieldName,'string',{''}) |
---|
204 | UvData.Object={[]}; |
---|
205 | |
---|
206 | %% TRANSFORM menu: builtin fcts |
---|
207 | transform_menu={'';'sub_field';'phys';'phys_polar'}; |
---|
208 | UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions |
---|
209 | transform_path=fullfile(path_uvmat,'transform_field'); |
---|
210 | path_list{1}=''; |
---|
211 | for ilist=2:UvData.OpenParam.NbBuiltin |
---|
212 | path_list{ilist}=transform_path; % set transform_path to the path_list |
---|
213 | end |
---|
214 | |
---|
215 | %% load the list of previously browsed files in menus Open, Open_1 and transform_fct |
---|
216 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
217 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
218 | if exist(profil_perso,'file') |
---|
219 | h=load (profil_perso); |
---|
220 | if isfield(h,'MenuFile')% load the menu of previously opened files |
---|
221 | for ifile=1:min(length(h.MenuFile),5) |
---|
222 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
223 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
224 | end |
---|
225 | end |
---|
226 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
227 | for ilist=1:length(h.transform_fct); |
---|
228 | if exist(h.transform_fct{ilist},'file') |
---|
229 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
230 | transform_menu=[transform_menu; {file}]; |
---|
231 | path_list=[path_list; {path}]; |
---|
232 | end |
---|
233 | end |
---|
234 | end |
---|
235 | end |
---|
236 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
237 | set(handles.transform_fct,'String',transform_menu)% display the menu of transform fcts |
---|
238 | set(handles.transform_fct,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
239 | set(handles.path_transform,'String','') |
---|
240 | set(handles.path_transform,'UserData',[]) |
---|
241 | |
---|
242 | %% case of an input argument for uvmat |
---|
243 | testinputfield=0; |
---|
244 | inputfile=[]; |
---|
245 | Field=[]; |
---|
246 | if exist('input','var') |
---|
247 | if ishandle(handles.UVMAT_title) |
---|
248 | delete(handles.UVMAT_title) |
---|
249 | end |
---|
250 | if isstruct(input) |
---|
251 | if isfield(input,'InputFile') |
---|
252 | inputfile=input.InputFile; |
---|
253 | end |
---|
254 | if isfield(input,'TimeIndex') |
---|
255 | set(handles.i1,num2str(input.TimeIndex)) |
---|
256 | end |
---|
257 | if isfield(input,'FieldsString') |
---|
258 | UvData.FieldsString=input.FieldsString; |
---|
259 | end |
---|
260 | elseif ischar(input)% file name introduced as input |
---|
261 | inputfile=input; |
---|
262 | elseif isnumeric(input)%simple matrix introduced as input |
---|
263 | sizinput=size(input); |
---|
264 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
265 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
266 | return |
---|
267 | end |
---|
268 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
269 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
270 | UvData.Field.A=input; |
---|
271 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
272 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
273 | testinputfield=1; |
---|
274 | end |
---|
275 | else |
---|
276 | %% check the path and date of modification of all functions in uvmat |
---|
277 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
278 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
279 | date_str=['last modification: ' date_str]; |
---|
280 | if ishandle(handles.UVMAT_title) |
---|
281 | set(handles.UVMAT_title,'String',... |
---|
282 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
283 | {'GNU General Public License'};... |
---|
284 | {path_to_uvmat};... |
---|
285 | {date_str};... |
---|
286 | infomsg]); |
---|
287 | end |
---|
288 | end |
---|
289 | set(handles.uvmat,'UserData',UvData) |
---|
290 | if ~isempty(inputfile) |
---|
291 | %%%%% display the input field %%%%%%% |
---|
292 | display_file_name(handles,inputfile) |
---|
293 | %%%%%%% |
---|
294 | testinputfield=1; |
---|
295 | end |
---|
296 | |
---|
297 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
298 | |
---|
299 | %------------------------------------------------------------------------ |
---|
300 | % --- Outputs from this function are returned to the command menuline. |
---|
301 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
302 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
303 | |
---|
304 | %------------------------------------------------------------------------ |
---|
305 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
306 | function closefcn(gcbo,eventdata) |
---|
307 | %------------------------------------------------------------------------ |
---|
308 | hh=findobj(allchild(0),'tag','view_field'); |
---|
309 | if ~isempty(hh) |
---|
310 | delete(hh) |
---|
311 | end |
---|
312 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
313 | if ~isempty(hh) |
---|
314 | delete(hh) |
---|
315 | end |
---|
316 | hh=findobj(allchild(0),'tag','set_object'); |
---|
317 | if ~isempty(hh) |
---|
318 | hhh=findobj(hh,'tag','PLOT'); |
---|
319 | set(hhh,'enable','off') |
---|
320 | end |
---|
321 | |
---|
322 | %------------------------------------------------------------------------ |
---|
323 | %------------------------------------------------------------------------ |
---|
324 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
325 | % automatically sets the global properties when the rootfile name is introduced |
---|
326 | % then activate the view-field action if selected |
---|
327 | % it is activated either by clicking on the RootPath window or by the |
---|
328 | % browser |
---|
329 | %------------------------------------------------------------------------ |
---|
330 | %------------------------------------------------------------------------ |
---|
331 | % --- Executes on the menu Open/Browse... |
---|
332 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
333 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
334 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
335 | %oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
336 | oldfile=fullfile(RootPath,SubDir); |
---|
337 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
338 | dir_perso=prefdir; |
---|
339 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
340 | if exist(profil_perso,'file') |
---|
341 | h=load (profil_perso); |
---|
342 | if isfield(h,'MenuFile_1') |
---|
343 | oldfile=h.MenuFile_1; |
---|
344 | end |
---|
345 | end |
---|
346 | end |
---|
347 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile); |
---|
348 | fileinput=[PathName FileName];%complete file name |
---|
349 | if ~exist(fileinput,'file') |
---|
350 | return %abandon if the browser is cancelled |
---|
351 | end |
---|
352 | |
---|
353 | %% display the selected field and related information |
---|
354 | display_file_name( handles,fileinput) |
---|
355 | |
---|
356 | % ----------------------------------------------------------------------- |
---|
357 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
358 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
359 | %------------------------------------------------------------------------ |
---|
360 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
361 | display_file_name( handles,fileinput) |
---|
362 | |
---|
363 | % ----------------------------------------------------------------------- |
---|
364 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
365 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
366 | %------------------------------------------------------------------------ |
---|
367 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
368 | display_file_name(handles,fileinput) |
---|
369 | |
---|
370 | % ----------------------------------------------------------------------- |
---|
371 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
372 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
373 | %------------------------------------------------------------------------ |
---|
374 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
375 | display_file_name(handles,fileinput) |
---|
376 | |
---|
377 | % ----------------------------------------------------------------------- |
---|
378 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
379 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
380 | %------------------------------------------------------------------------ |
---|
381 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
382 | display_file_name(handles,fileinput) |
---|
383 | |
---|
384 | % ----------------------------------------------------------------------- |
---|
385 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
386 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
387 | %------------------------------------------------------------------------ |
---|
388 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
389 | display_file_name(handles,fileinput) |
---|
390 | |
---|
391 | %------------------------------------------------------------------------ |
---|
392 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
393 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
394 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
395 | %------------------------------------------------------------------------ |
---|
396 | RootPath=get(handles.RootPath,'String'); |
---|
397 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); |
---|
398 | fileinput_1=[PathName FileName];%complete file name |
---|
399 | if ~exist(fileinput_1,'file') |
---|
400 | return %abandon of the browser is cancelled |
---|
401 | end |
---|
402 | |
---|
403 | % refresh the current displayed field |
---|
404 | set(handles.SubField,'Value',1) |
---|
405 | display_file_name(handles,fileinput_1,2) |
---|
406 | |
---|
407 | %update list of recent files in the menubar |
---|
408 | MenuFile_1=fileinput_1; |
---|
409 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
410 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
411 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
412 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
413 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
414 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
415 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
416 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
417 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
418 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
419 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
420 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
421 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
422 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
423 | dir_perso=prefdir; |
---|
424 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
425 | if exist(profil_perso,'file') |
---|
426 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
427 | else |
---|
428 | txt=ver('MATLAB'); |
---|
429 | Release=txt.Release; |
---|
430 | relnumb=str2double(Release(3:4)); |
---|
431 | if relnumb >= 14 |
---|
432 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
433 | else |
---|
434 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
435 | end |
---|
436 | end |
---|
437 | |
---|
438 | % ----------------------------------------------------------------------- |
---|
439 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
440 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
441 | % ----------------------------------------------------------------------- |
---|
442 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
443 | set(handles.SubField,'Value',1) |
---|
444 | display_file_name(handles,fileinput_1,2) |
---|
445 | |
---|
446 | % ----------------------------------------------------------------------- |
---|
447 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
448 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
449 | % ----------------------------------------------------------------------- |
---|
450 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
451 | set(handles.SubField,'Value',1) |
---|
452 | display_file_name(handles,fileinput_1,2) |
---|
453 | |
---|
454 | % ----------------------------------------------------------------------- |
---|
455 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
456 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
457 | % ----------------------------------------------------------------------- |
---|
458 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
459 | set(handles.SubField,'Value',1) |
---|
460 | display_file_name(handles,fileinput_1,2) |
---|
461 | |
---|
462 | % ----------------------------------------------------------------------- |
---|
463 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
464 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
465 | % ----------------------------------------------------------------------- |
---|
466 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
467 | set(handles.SubField,'Value',1) |
---|
468 | display_file_name(handles,fileinput_1,2) |
---|
469 | |
---|
470 | % ----------------------------------------------------------------------- |
---|
471 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
472 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
473 | % ----------------------------------------------------------------------- |
---|
474 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
475 | set(handles.SubField,'Value',1) |
---|
476 | display_file_name(handles,fileinput_1,2) |
---|
477 | |
---|
478 | %------------------------------------------------------------------------ |
---|
479 | % --- Called by action in RootPath edit box |
---|
480 | function RootPath_Callback(hObject,eventdata,handles) |
---|
481 | %------------------------------------------------------------------------ |
---|
482 | % read the current input file name: |
---|
483 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
484 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
485 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
486 | return |
---|
487 | end |
---|
488 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
489 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
490 | % initiate the input file series and refresh the current field view: |
---|
491 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); |
---|
492 | |
---|
493 | %----------------------------------------------------------------------- |
---|
494 | % --- Called by action in RootPath_1 edit box |
---|
495 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
496 | % ----------------------------------------------------------------------- |
---|
497 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
498 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
499 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
500 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
501 | return |
---|
502 | end |
---|
503 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
504 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
505 | % initiate the input file series and refresh the current field view: |
---|
506 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
507 | |
---|
508 | %------------------------------------------------------------------------ |
---|
509 | % --- Called by action in RootFile edit box |
---|
510 | function SubDir_Callback(hObject, eventdata, handles) |
---|
511 | %------------------------------------------------------------------------ |
---|
512 | %refresh the menu of input fieldname |
---|
513 | Fields_Callback(hObject, eventdata, handles); |
---|
514 | % refresh the current field view |
---|
515 | run0_Callback(hObject, eventdata, handles); |
---|
516 | |
---|
517 | %------------------------------------------------------------------------ |
---|
518 | % --- Called by action in RootFile edit box |
---|
519 | function RootFile_Callback(hObject, eventdata, handles) |
---|
520 | %------------------------------------------------------------------------ |
---|
521 | RootPath_Callback(hObject,eventdata,handles) |
---|
522 | |
---|
523 | %----------------------------------------------------------------------- |
---|
524 | % --- Called by action in RootFile_1 edit box |
---|
525 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
526 | % ----------------------------------------------------------------------- |
---|
527 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
528 | |
---|
529 | %------------------------------------------------------------------------ |
---|
530 | % --- Called by action in FileIndex edit box |
---|
531 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
532 | %------------------------------------------------------------------------ |
---|
533 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
534 | set(handles.i1,'String',num2str(i1)); |
---|
535 | set(handles.i2,'String',num2str(i2)); |
---|
536 | set(handles.j1,'String',num2str(j1)); |
---|
537 | set(handles.j2,'String',num2str(j2)); |
---|
538 | |
---|
539 | % refresh the current field view |
---|
540 | run0_Callback(hObject, eventdata, handles) |
---|
541 | |
---|
542 | %------------------------------------------------------------------------ |
---|
543 | % --- Called by action in FileIndex_1 edit box |
---|
544 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
545 | %------------------------------------------------------------------------ |
---|
546 | run0_Callback(hObject, eventdata, handles) |
---|
547 | |
---|
548 | %------------------------------------------------------------------------ |
---|
549 | % --- Called by action in NomType edit box |
---|
550 | function NomType_Callback(hObject, eventdata, handles) |
---|
551 | %------------------------------------------------------------------------ |
---|
552 | i1=str2num(get(handles.i1,'String')); |
---|
553 | i2=str2num(get(handles.i2,'String')); |
---|
554 | j1=str2num(get(handles.j1,'String')); |
---|
555 | j2=str2num(get(handles.j2,'String')); |
---|
556 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
557 | set(handles.FileIndex,'String',FileIndex) |
---|
558 | % refresh the current settings and refresh the field view |
---|
559 | RootPath_Callback(hObject,eventdata,handles) |
---|
560 | |
---|
561 | %------------------------------------------------------------------------ |
---|
562 | % --- Called by action in NomType edit box |
---|
563 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
564 | %------------------------------------------------------------------------ |
---|
565 | i1=str2num(get(handles.i1,'String')); |
---|
566 | i2=str2num(get(handles.i2,'String')); |
---|
567 | j1=str2num(get(handles.j1,'String')); |
---|
568 | j2=str2num(get(handles.j2,'String')); |
---|
569 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
570 | set(handles.FileIndex_1,'String',FileIndex) |
---|
571 | % refresh the current settings and refresh the field view |
---|
572 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
573 | |
---|
574 | %------------------------------------------------------------------------ |
---|
575 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
576 | function display_file_name(handles,fileinput,index) |
---|
577 | %------------------------------------------------------------------------ |
---|
578 | %% look for the input file existence |
---|
579 | if ~exist(fileinput,'file') |
---|
580 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
581 | return |
---|
582 | end |
---|
583 | |
---|
584 | %% set the mouse pointer to 'watch' |
---|
585 | set(handles.uvmat,'Pointer','watch') |
---|
586 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
587 | drawnow |
---|
588 | |
---|
589 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
590 | if ~exist('index','var') |
---|
591 | index=1; |
---|
592 | end |
---|
593 | if index==1 |
---|
594 | handles_RootPath=handles.RootPath; |
---|
595 | handles_SubDir=handles.SubDir; |
---|
596 | handles_RootFile=handles.RootFile; |
---|
597 | handles_FileIndex=handles.FileIndex; |
---|
598 | handles_NomType=handles.NomType; |
---|
599 | handles_FileExt=handles.FileExt; |
---|
600 | elseif index==2 |
---|
601 | handles_RootPath=handles.RootPath_1; |
---|
602 | handles_SubDir=handles.SubDir_1; |
---|
603 | handles_RootFile=handles.RootFile_1; |
---|
604 | handles_FileIndex=handles.FileIndex_1; |
---|
605 | handles_NomType=handles.NomType_1; |
---|
606 | handles_FileExt=handles.FileExt_1; |
---|
607 | set(handles.RootPath_1,'Visible','on') |
---|
608 | set(handles.RootFile_1,'Visible','on') |
---|
609 | set(handles.SubDir_1,'Visible','on'); |
---|
610 | set(handles.FileIndex_1,'Visible','on'); |
---|
611 | set(handles.FileExt_1,'Visible','on'); |
---|
612 | set(handles.NomType_1,'Visible','on'); |
---|
613 | end |
---|
614 | |
---|
615 | %% detect root name, nomenclature and indices in the input file name: |
---|
616 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
617 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
618 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
619 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
620 | |
---|
621 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
622 | switch FileType |
---|
623 | case '' |
---|
624 | msgbox_uvmat('ERROR','invalid input file type') |
---|
625 | case 'txt' |
---|
626 | edit(fileinput) |
---|
627 | case 'figure' %display matlab figure |
---|
628 | hfig=open(fileinput); |
---|
629 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
630 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
631 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
632 | case 'xml' % edit xml files |
---|
633 | t=xmltree(fileinput); |
---|
634 | % the xml file marks a project or project link, open datatree_browser |
---|
635 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
636 | datatree_browser(fileinput) |
---|
637 | else % other xml file, open the xml editor |
---|
638 | editxml(fileinput); |
---|
639 | end |
---|
640 | case 'xls'% Excel file opended by editxml |
---|
641 | editxml(fileinput); |
---|
642 | otherwise |
---|
643 | set(handles_RootPath,'String',RootPath); |
---|
644 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
645 | set(handles_SubDir,'String',['/' SubDir]); |
---|
646 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
647 | indices=fileinput(length(rootname)+1:end); |
---|
648 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
649 | set(handles_FileIndex,'String',indices); |
---|
650 | set(handles_NomType,'String',NomType); |
---|
651 | set(handles_FileExt,'String',FileExt); |
---|
652 | if index==1 |
---|
653 | % fill file index counters if the first file series is opened |
---|
654 | set(handles.i1,'String',num2str(i1)); |
---|
655 | set(handles.i2,'String',num2str(i2)); |
---|
656 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
657 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
658 | else %read the current field index to synchronise with the first series |
---|
659 | i1_s=str2num(get(handles.i1,'String')); |
---|
660 | i2_0=str2num(get(handles.i2,'String')); |
---|
661 | if ~isempty(i2_0) |
---|
662 | i2_s=i2_0; |
---|
663 | else |
---|
664 | i2_s=i2; |
---|
665 | end |
---|
666 | j1_0=stra2num(get(handles.j1,'String')); |
---|
667 | if ~isempty(j1_0) |
---|
668 | j1_s=j1_0; |
---|
669 | else |
---|
670 | j1_s=j1; |
---|
671 | end |
---|
672 | j2_0=stra2num(get(handles.j2,'String')); |
---|
673 | if ~isempty(j2_0) |
---|
674 | j2_s=j2_0; |
---|
675 | else |
---|
676 | j2_s=j2; |
---|
677 | end |
---|
678 | end |
---|
679 | |
---|
680 | % synchronise indices of the second input file if it exists |
---|
681 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
682 | Input=read_GUI(handles.InputFile); |
---|
683 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
684 | Input.RootPath_1=Input.RootPath; |
---|
685 | end |
---|
686 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
687 | Input.SubDir_1=Input.SubDir; |
---|
688 | end |
---|
689 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
690 | Input.RootFile_1=Input.RootFile; |
---|
691 | end |
---|
692 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
693 | Input.FileExt_1=Input.FileExt; |
---|
694 | end |
---|
695 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
696 | Input.NomType_1=Input.NomType; |
---|
697 | end |
---|
698 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
699 | FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
700 | if exist(FileName_1,'file') |
---|
701 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
702 | else |
---|
703 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
704 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
705 | end |
---|
706 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
707 | end |
---|
708 | |
---|
709 | %enable other menus |
---|
710 | set(handles.MenuOpen_1,'Enable','on') |
---|
711 | set(handles.MenuFile_1_1,'Enable','on') |
---|
712 | set(handles.MenuFile_2_1,'Enable','on') |
---|
713 | set(handles.MenuFile_3_1,'Enable','on') |
---|
714 | set(handles.MenuFile_4_1,'Enable','on') |
---|
715 | set(handles.MenuFile_5_1,'Enable','on') |
---|
716 | set(handles.MenuExport,'Enable','on') |
---|
717 | set(handles.MenuExportFigure,'Enable','on') |
---|
718 | set(handles.MenuExportMovie,'Enable','on') |
---|
719 | set(handles.MenuTools,'Enable','on') |
---|
720 | |
---|
721 | % initiate input file series and refresh the current field view: |
---|
722 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
723 | |
---|
724 | end |
---|
725 | |
---|
726 | %% update list of recent files in the menubar and save it for future opening |
---|
727 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
728 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
729 | str_find=strcmp(fileinput,MenuFile); |
---|
730 | if isempty(find(str_find,1)) |
---|
731 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
732 | end |
---|
733 | for ifile=1:min(length(MenuFile),5) |
---|
734 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
735 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});']) |
---|
736 | end |
---|
737 | dir_perso=prefdir; |
---|
738 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
739 | if exist(profil_perso,'file') |
---|
740 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
741 | else |
---|
742 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
743 | end |
---|
744 | |
---|
745 | %% set back the mouse pointer to arrow |
---|
746 | set(handles.uvmat,'Pointer','arrow') |
---|
747 | |
---|
748 | |
---|
749 | %------------------------------------------------------------------------ |
---|
750 | % --- Update information about a new field series (indices to scan, timing, |
---|
751 | % calibration from an xml file, then refresh current plots |
---|
752 | |
---|
753 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
754 | %------------------------------------------------------------------------ |
---|
755 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
756 | if ~exist('index','var') |
---|
757 | index=1; |
---|
758 | end |
---|
759 | if index==1 |
---|
760 | handles_RootPath=handles.RootPath; |
---|
761 | handles_Fields=handles.FieldName; |
---|
762 | elseif index==2 |
---|
763 | handles_RootPath=handles.RootPath_1; |
---|
764 | handles_Fields=handles.FieldName_1; |
---|
765 | end |
---|
766 | |
---|
767 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
768 | drawnow |
---|
769 | set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening |
---|
770 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
771 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
772 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
773 | UvData.FileType{index}=FileType; |
---|
774 | UvData.i1_series{index}=i1_series; |
---|
775 | UvData.i2_series{index}=i2_series; |
---|
776 | UvData.j1_series{index}=j1_series; |
---|
777 | UvData.j2_series{index}=j2_series; |
---|
778 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
779 | if index==1 |
---|
780 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
781 | else |
---|
782 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
783 | end |
---|
784 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
785 | FileBase=fullfile(RootPath,RootFile); |
---|
786 | if ~exist(FileName,'file') |
---|
787 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
788 | return |
---|
789 | end |
---|
790 | |
---|
791 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
792 | XmlData.Time=[];%default |
---|
793 | XmlData.GeometryCalib=[];%default |
---|
794 | TimeUnit='';%default |
---|
795 | Time=[]; |
---|
796 | testima=0; %test for image input |
---|
797 | imainfo=[]; |
---|
798 | ColorType='falsecolor'; %default |
---|
799 | hhh=[]; |
---|
800 | UvData.MovieObject{index}=VideoObject; |
---|
801 | if ~isempty(VideoObject) |
---|
802 | imainfo=get(VideoObject); |
---|
803 | testima=1; |
---|
804 | TimeUnit='s'; |
---|
805 | if isempty(j1_series); %frame index along i |
---|
806 | Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
807 | else |
---|
808 | Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
809 | end |
---|
810 | %nbfield=imainfo.NumberOfFrames; |
---|
811 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
812 | ColorType='truecolor'; |
---|
813 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
814 | testima=1; |
---|
815 | if ~isequal(SubDir,'') |
---|
816 | RootFile=get(handles.RootFile,'String'); |
---|
817 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
818 | else |
---|
819 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
820 | end |
---|
821 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
822 | if length(imainfo) >1 %case of image with multiple frames |
---|
823 | % nbfield=length(imainfo); |
---|
824 | % nbfield_j=1; |
---|
825 | end |
---|
826 | end |
---|
827 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
828 | if length(imainfo)>1 |
---|
829 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
830 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
831 | else |
---|
832 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
833 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
834 | end |
---|
835 | else |
---|
836 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
837 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
838 | end |
---|
839 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
840 | |
---|
841 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
842 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
843 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
844 | warntext='';%default warning message |
---|
845 | NbSlice=1;%default |
---|
846 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
847 | if ~isempty(XmlFileName) |
---|
848 | set(handles.view_xml,'Visible','on') |
---|
849 | set(handles.view_xml,'BackgroundColor',[1 1 0]) |
---|
850 | set(handles.view_xml,'String','view .xml') |
---|
851 | drawnow |
---|
852 | [XmlDataRead,warntext]=imadoc2struct(XmlFileName); |
---|
853 | if ~isempty(warntext) |
---|
854 | msgbox_uvmat('WARNING',warntext) |
---|
855 | end |
---|
856 | if isempty(XmlDataRead) |
---|
857 | set(handles.view_xml,'Visible','off') |
---|
858 | else |
---|
859 | set(handles.view_xml,'String',['view ' DocExt]) |
---|
860 | XmlData=XmlDataRead; |
---|
861 | if isfield(XmlData,'TimeUnit') |
---|
862 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
863 | TimeUnit=XmlData.TimeUnit; |
---|
864 | end |
---|
865 | end |
---|
866 | set(handles.view_xml,'BackgroundColor',[1 1 1]) |
---|
867 | drawnow |
---|
868 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
869 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
870 | set (handles.num_NbSlice,'String','volume') |
---|
871 | end |
---|
872 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
873 | if ~isempty(hgeometry_calib) |
---|
874 | GUserData=get(hgeometry_calib,'UserData'); |
---|
875 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
876 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
877 | if strcmp(answer,'Yes') |
---|
878 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
879 | end |
---|
880 | end |
---|
881 | end |
---|
882 | end |
---|
883 | end |
---|
884 | end |
---|
885 | if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) |
---|
886 | XmlData.Time=Time; %time set by video |
---|
887 | end |
---|
888 | |
---|
889 | %% store last index in handles.lat_i and .last_j |
---|
890 | nbfield=max(max(max(i2_series))); |
---|
891 | if isempty(nbfield) |
---|
892 | nbfield=max(max(max(i1_series))); |
---|
893 | end |
---|
894 | nbfield_j=max(max(max(j2_series))); |
---|
895 | if isempty(nbfield_j) |
---|
896 | nbfield_j=max(max(max(j2_series))); |
---|
897 | end |
---|
898 | if ~isempty(XmlData.Time) |
---|
899 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
900 | if isequal(size(XmlData.Time,1),1) |
---|
901 | NomType=get(handles.NomType,'String'); |
---|
902 | XmlData.Time=(XmlData.Time)'; |
---|
903 | end |
---|
904 | end |
---|
905 | last_i_cell=get(handles.last_i,'String'); |
---|
906 | if isempty(nbfield) |
---|
907 | last_i_cell{1}=''; |
---|
908 | else |
---|
909 | last_i_cell{1}=num2str(nbfield); |
---|
910 | end |
---|
911 | set(handles.last_i,'String',last_i_cell) |
---|
912 | last_j_cell=get(handles.last_j,'String'); |
---|
913 | if isempty(nbfield_j) |
---|
914 | last_j_cell{1}=''; |
---|
915 | else |
---|
916 | last_j_cell{1}=num2str(nbfield_j); |
---|
917 | end |
---|
918 | set(handles.last_j,'String',last_j_cell); |
---|
919 | |
---|
920 | %% store geometric calibration in UvData |
---|
921 | if isfield(XmlData,'GeometryCalib') |
---|
922 | GeometryCalib=XmlData.GeometryCalib; |
---|
923 | if isempty(GeometryCalib) |
---|
924 | set(handles.pxcm,'String','') |
---|
925 | set(handles.pycm,'String','') |
---|
926 | set(handles.transform_fct,'Value',1); % no transform by default |
---|
927 | else |
---|
928 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
929 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
930 | set(handles.pxcm,'String','var') |
---|
931 | set(handles.pycm,'String','var') |
---|
932 | elseif isfield(GeometryCalib,'fx_fy') |
---|
933 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
934 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
935 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
936 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
937 | end |
---|
938 | if ~get(handles.CheckFixLimits,'Value') |
---|
939 | set(handles.transform_fct,'Value',3); % phys transform by default if fixedLimits is off |
---|
940 | end |
---|
941 | if isfield(GeometryCalib,'SliceCoord') |
---|
942 | siz=size(GeometryCalib.SliceCoord); |
---|
943 | if siz(1)>1 |
---|
944 | NbSlice=siz(1); |
---|
945 | set(handles.slices,'Visible','on') |
---|
946 | set(handles.slices,'Value',1) |
---|
947 | end |
---|
948 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
949 | set(handles.num_NbSlice,'String','volume') |
---|
950 | else |
---|
951 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
952 | end |
---|
953 | slices_Callback([],[], handles) |
---|
954 | end |
---|
955 | end |
---|
956 | end |
---|
957 | |
---|
958 | %% update the data attached to the uvmat interface |
---|
959 | if ~isempty(TimeUnit) |
---|
960 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
961 | end |
---|
962 | UvData.TimeUnit=TimeUnit; |
---|
963 | UvData.XmlData{index}=XmlData; |
---|
964 | UvData.NewSeries=1; |
---|
965 | % UvData.MovieObject=MovieObject; |
---|
966 | |
---|
967 | %display warning message |
---|
968 | if ~isequal(warntext,'') |
---|
969 | msgbox_uvmat('WARNING',warntext); |
---|
970 | end |
---|
971 | |
---|
972 | %% set default options in menu 'FieldName' |
---|
973 | switch FileType |
---|
974 | case {'civx','civdata'} |
---|
975 | [FieldList,ColorList]=calc_field; |
---|
976 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
977 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
978 | set(handles.ColorScalar,'Value',1) |
---|
979 | set(handles.ColorScalar,'String',ColorList) |
---|
980 | set(handles.Vectors,'Visible','on') |
---|
981 | set(handles.Coord_x,'Value',1); |
---|
982 | set(handles.Coord_x,'String',{'X'}); |
---|
983 | set(handles.Coord_y,'Value',1); |
---|
984 | set(handles.Coord_y,'String',{'Y'}); |
---|
985 | case 'netcdf' |
---|
986 | set(handles_Fields,'Value',1) |
---|
987 | set(handles_Fields,'String',{'get_field...'}) |
---|
988 | hget_field=get_field(FileName); |
---|
989 | hhget_field=guidata(hget_field); |
---|
990 | get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
991 | otherwise |
---|
992 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
993 | set(handles_Fields,'String',{'image'}) |
---|
994 | set(handles.Coord_x,'Value',1); |
---|
995 | set(handles.Coord_x,'String',{'AX'}); |
---|
996 | set(handles.Coord_y,'Value',1); |
---|
997 | set(handles.Coord_y,'String',{'AY'}); |
---|
998 | end |
---|
999 | set(handles.uvmat,'UserData',UvData) |
---|
1000 | |
---|
1001 | %% set index navigation options and refresh plots |
---|
1002 | scan_option='i';%default |
---|
1003 | state_j='off'; %default |
---|
1004 | if index==2 |
---|
1005 | if get(handles.scan_j,'Value') |
---|
1006 | scan_option='j'; %keep the scan option for the second file series |
---|
1007 | end |
---|
1008 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
1009 | state_j='on'; |
---|
1010 | end |
---|
1011 | end |
---|
1012 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
1013 | if ~isempty(j1_series) |
---|
1014 | state_j='on'; |
---|
1015 | if index==1 |
---|
1016 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
1017 | scan_option='j'; %scan j indext |
---|
1018 | end |
---|
1019 | end |
---|
1020 | end |
---|
1021 | if isequal(scan_option,'i') |
---|
1022 | diff_ref_i=diff(ref_i,1); |
---|
1023 | if isempty(diff_ref_i) |
---|
1024 | diff_ref_i=1; |
---|
1025 | end |
---|
1026 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
1027 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
1028 | end |
---|
1029 | set(handles.scan_i,'Value',1) |
---|
1030 | scan_i_Callback([],[], handles); |
---|
1031 | else |
---|
1032 | diff_ref_j=diff(ref_j); |
---|
1033 | if isempty(diff_ref_j) |
---|
1034 | diff_ref_j=1; |
---|
1035 | end |
---|
1036 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
1037 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
1038 | end |
---|
1039 | set(handles.scan_j,'Value',1) |
---|
1040 | scan_j_Callback([],[], handles); |
---|
1041 | end |
---|
1042 | set(handles.scan_j,'Visible',state_j) |
---|
1043 | set(handles.j1,'Visible',state_j) |
---|
1044 | set(handles.j2,'Visible',state_j) |
---|
1045 | set(handles.last_j,'Visible',state_j); |
---|
1046 | set(handles.frame_j,'Visible',state_j); |
---|
1047 | set(handles.j_text,'Visible',state_j); |
---|
1048 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
1049 | set(handles.CheckFixPair,'Visible','on') |
---|
1050 | elseif index==1 |
---|
1051 | set(handles.CheckFixPair,'Visible','off') |
---|
1052 | end |
---|
1053 | |
---|
1054 | %% apply the effect of the transform fct and view the field |
---|
1055 | transform=get(handles.path_transform,'UserData'); |
---|
1056 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
1057 | set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
1058 | end |
---|
1059 | transform_fct_Callback([],[],handles) |
---|
1060 | mask_test=get(handles.CheckMask,'value'); |
---|
1061 | if mask_test |
---|
1062 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1063 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
1064 | delete(MaskData.maskhandle) %delete old mask |
---|
1065 | end |
---|
1066 | CheckMask_Callback([],[],handles) |
---|
1067 | end |
---|
1068 | |
---|
1069 | %------------------------------------------------------------------------ |
---|
1070 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
1071 | function scan_i_Callback(hObject, eventdata, handles) |
---|
1072 | %------------------------------------------------------------------------ |
---|
1073 | if get(handles.scan_i,'Value')==1 |
---|
1074 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
1075 | set(handles.scan_j,'Value',0) |
---|
1076 | else |
---|
1077 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1078 | set(handles.scan_j,'Value',1) |
---|
1079 | end |
---|
1080 | scan_j_Callback(hObject, eventdata, handles) |
---|
1081 | |
---|
1082 | %------------------------------------------------------------------------ |
---|
1083 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
1084 | function scan_j_Callback(hObject, eventdata, handles) |
---|
1085 | %------------------------------------------------------------------------ |
---|
1086 | if get(handles.scan_j,'Value')==1 |
---|
1087 | set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
1088 | set(handles.scan_i,'Value',0) |
---|
1089 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1090 | % NomType=get(handles.NomType,'String'); |
---|
1091 | % switch NomType |
---|
1092 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
1093 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
1094 | % otherwise |
---|
1095 | % set(handles.CheckFixPair,'Visible','off') |
---|
1096 | % end |
---|
1097 | else |
---|
1098 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1099 | set(handles.scan_i,'Value',1) |
---|
1100 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
1101 | set(handles.CheckFixPair,'Visible','off') |
---|
1102 | end |
---|
1103 | |
---|
1104 | %------------------------------------------------------------------------ |
---|
1105 | function i1_Callback(hObject, eventdata, handles) |
---|
1106 | %------------------------------------------------------------------------ |
---|
1107 | update_ij(handles,1) |
---|
1108 | |
---|
1109 | %------------------------------------------------------------------------ |
---|
1110 | function i2_Callback(hObject, eventdata, handles) |
---|
1111 | %------------------------------------------------------------------------ |
---|
1112 | update_ij(handles,2) |
---|
1113 | |
---|
1114 | %------------------------------------------------------------------------ |
---|
1115 | function j1_Callback(hObject, eventdata, handles) |
---|
1116 | %------------------------------------------------------------------------ |
---|
1117 | update_ij(handles,3) |
---|
1118 | |
---|
1119 | %------------------------------------------------------------------------ |
---|
1120 | function j2_Callback(hObject, eventdata, handles) |
---|
1121 | %------------------------------------------------------------------------ |
---|
1122 | update_ij(handles,4) |
---|
1123 | |
---|
1124 | %------------------------------------------------------------------------ |
---|
1125 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
1126 | function update_ij(handles,index_rank) |
---|
1127 | NomType=get(handles.NomType,'String'); |
---|
1128 | indices=get(handles.FileIndex,'String'); |
---|
1129 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
1130 | switch index_rank |
---|
1131 | case 1 |
---|
1132 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
1133 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1134 | case 2 |
---|
1135 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
1136 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1137 | case 3 |
---|
1138 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
1139 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1140 | case 4 |
---|
1141 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
1142 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1143 | end |
---|
1144 | set(handles.FileIndex,'String',indices) |
---|
1145 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1146 | % update the second index if relevant |
---|
1147 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
1148 | NomType_1=get(handles.NomType_1,'String'); |
---|
1149 | indices_1=get(handles.FileIndex_1,'String'); |
---|
1150 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(indices_1);% the indices for the second series taken from FileIndex_1 |
---|
1151 | switch index_rank |
---|
1152 | case 1 |
---|
1153 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
1154 | case 2 |
---|
1155 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
1156 | case 3 |
---|
1157 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
1158 | case 4 |
---|
1159 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
1160 | end |
---|
1161 | set(handles.FileIndex_1,'String',indices_1) |
---|
1162 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
1163 | end |
---|
1164 | |
---|
1165 | %------------------------------------------------------------------------ |
---|
1166 | |
---|
1167 | %------------------------------------------------------------------------ |
---|
1168 | function slices_Callback(hObject, eventdata, handles) |
---|
1169 | %------------------------------------------------------------------------ |
---|
1170 | if get(handles.slices,'Value')==1 |
---|
1171 | set(handles.slices,'BackgroundColor',[1 1 0]) |
---|
1172 | set(handles.num_NbSlice,'Visible','on') |
---|
1173 | set(handles.z_text,'Visible','on') |
---|
1174 | set(handles.z_index,'Visible','on') |
---|
1175 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
1176 | else |
---|
1177 | set(handles.num_NbSlice,'Visible','off') |
---|
1178 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1179 | set(handles.z_text,'Visible','off') |
---|
1180 | set(handles.z_index,'Visible','off') |
---|
1181 | set(handles.masklevel,'Value',1) |
---|
1182 | set(handles.masklevel,'String',{'1'}) |
---|
1183 | end |
---|
1184 | |
---|
1185 | %------------------------------------------------------------------------ |
---|
1186 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
1187 | %------------------------------------------------------------------------ |
---|
1188 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
1189 | if isequal(nb_slice_str,'volume') |
---|
1190 | num=stra2num(get(handles.j1,'String')); |
---|
1191 | last_j=get(handles.last_j,'String'); |
---|
1192 | nbslice=str2double(last_j{1}); |
---|
1193 | else |
---|
1194 | num=str2double(get(handles.i1,'String')); |
---|
1195 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
1196 | end |
---|
1197 | z=mod(num-1,nbslice)+1; |
---|
1198 | set(handles.z_index,'String',num2str(z)) |
---|
1199 | for ilist=1:nbslice |
---|
1200 | list_index{ilist,1}=num2str(ilist); |
---|
1201 | end |
---|
1202 | set(handles.masklevel,'String',list_index) |
---|
1203 | set(handles.masklevel,'Value',z) |
---|
1204 | |
---|
1205 | %------------------------------------------------------------------------ |
---|
1206 | % --- Executes on button press in view_xml. |
---|
1207 | function view_xml_Callback(hObject, eventdata, handles) |
---|
1208 | %------------------------------------------------------------------------ |
---|
1209 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1210 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1211 | FileBase=fullfile(RootPath,RootFile); |
---|
1212 | option=get(handles.view_xml,'String'); |
---|
1213 | if isequal(option,'view .xml') |
---|
1214 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
1215 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
1216 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
1217 | end |
---|
1218 | heditxml=editxml(FileXml); |
---|
1219 | end |
---|
1220 | |
---|
1221 | %------------------------------------------------------------------------ |
---|
1222 | % --- Executes on button press in CheckMask. |
---|
1223 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1224 | %------------------------------------------------------------------------ |
---|
1225 | %case of view mask selection |
---|
1226 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1227 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1228 | FileBase=fullfile(RootPath,RootFile); |
---|
1229 | num_i1=stra2num(get(handles.i1,'String')); |
---|
1230 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1231 | currentdir=pwd; |
---|
1232 | cd(RootPath); |
---|
1233 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
1234 | cd(currentdir);%come back to the working directory |
---|
1235 | mdetect=0; |
---|
1236 | if ~isempty(maskfiles) |
---|
1237 | for ilist=1:length(maskfiles) |
---|
1238 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
1239 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
1240 | [tild,Name]=fileparts(maskname); |
---|
1241 | Namedouble=double(Name); |
---|
1242 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1243 | ind_mask=findstr('mask',Name); |
---|
1244 | i=ind_mask-1; |
---|
1245 | while val(i)==0 && i>0 |
---|
1246 | i=i-1; |
---|
1247 | end |
---|
1248 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
1249 | if ~isempty(nbmask_str) |
---|
1250 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
1251 | end |
---|
1252 | end |
---|
1253 | if isequal(min(nbslice),max(nbslice)) |
---|
1254 | nbslice=nbslice(1); |
---|
1255 | else |
---|
1256 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
1257 | return |
---|
1258 | end |
---|
1259 | if ~isempty(nbslice) && Name(i)=='_' |
---|
1260 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
1261 | Mask.NbSlice=nbslice; |
---|
1262 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
1263 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
1264 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
1265 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
1266 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
1267 | mdetect=exist(maskname,'file'); |
---|
1268 | if mdetect |
---|
1269 | set(handles.num_NbSlice,'String',Name(i+1:ind_mask-1)); |
---|
1270 | set(handles.num_NbSlice,'BackgroundColor',[1 1 0]) |
---|
1271 | set(handles.CheckMask,'UserData',Mask); |
---|
1272 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
1273 | if nbslice > 1 |
---|
1274 | set(handles.slices,'value',1) |
---|
1275 | slices_Callback(hObject, eventdata, handles) |
---|
1276 | end |
---|
1277 | end |
---|
1278 | end |
---|
1279 | end |
---|
1280 | errormsg=[];%default |
---|
1281 | if mdetect==0 |
---|
1282 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1283 | {'*.png', ' (*.png)'; |
---|
1284 | '*.png', '.png files '; ... |
---|
1285 | '*.*', 'All Files (*.*)'}, ... |
---|
1286 | 'Pick a mask file *.png',FileBase); |
---|
1287 | maskname=fullfile(PathName,FileName); |
---|
1288 | if ~exist(maskname,'file') |
---|
1289 | errormsg='no file browsed'; |
---|
1290 | end |
---|
1291 | [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
1292 | Mask.Base=fullfile(RootDir,SubDir,RootFile); |
---|
1293 | Mask.NbSlice=1; |
---|
1294 | set(handles.CheckMask,'UserData',Mask); |
---|
1295 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
1296 | end |
---|
1297 | if isempty(errormsg) |
---|
1298 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
1299 | end |
---|
1300 | if ~isempty(errormsg) |
---|
1301 | set(handles.CheckMask,'Value',0) |
---|
1302 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1303 | end |
---|
1304 | else % desactivate mask display |
---|
1305 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1306 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
1307 | delete(MaskData.maskhandle) |
---|
1308 | end |
---|
1309 | set(handles.CheckMask,'UserData',[]) |
---|
1310 | UvData=get(handles.uvmat,'UserData'); |
---|
1311 | if isfield(UvData,'MaskName') |
---|
1312 | UvData=rmfield(UvData,'MaskName'); |
---|
1313 | set(handles.uvmat,'UserData',UvData) |
---|
1314 | end |
---|
1315 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1316 | end |
---|
1317 | |
---|
1318 | %------------------------------------------------------------------------ |
---|
1319 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
1320 | %------------------------------------------------------------------------ |
---|
1321 | errormsg=[];%default |
---|
1322 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1323 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
1324 | uistack(MaskData.maskhandle,'top'); |
---|
1325 | end |
---|
1326 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
1327 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
1328 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
1329 | UvData=get(handles.uvmat,'UserData'); |
---|
1330 | %update mask image if the mask is new |
---|
1331 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
1332 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
1333 | set(handles.uvmat,'UserData',UvData); |
---|
1334 | if ~exist(MaskName,'file') |
---|
1335 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
1336 | delete(MaskData.maskhandle) |
---|
1337 | end |
---|
1338 | else |
---|
1339 | %read mask image |
---|
1340 | Mask.AName='image'; |
---|
1341 | Mask.A=imread(MaskName); |
---|
1342 | npxy=size(Mask.A); |
---|
1343 | test_error=0; |
---|
1344 | if length(npxy)>2 |
---|
1345 | errormsg=[MaskName ' is not a grey scale image']; |
---|
1346 | return |
---|
1347 | elseif ~isa(Mask.A,'uint8') |
---|
1348 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
1349 | return |
---|
1350 | end |
---|
1351 | Mask.AX=[0.5 npxy(2)-0.5]; |
---|
1352 | Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
1353 | Mask.CoordUnit='pixel'; |
---|
1354 | if isequal(get(handles.slices,'Value'),1) |
---|
1355 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
1356 | num_i1=str2num(get(handles.i1,'String')); |
---|
1357 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
1358 | end |
---|
1359 | %px to phys or other transform on field |
---|
1360 | menu_transform=get(handles.transform_fct,'String'); |
---|
1361 | choice_value=get(handles.transform_fct,'Value'); |
---|
1362 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
1363 | transform_list=get(handles.transform_fct,'UserData'); |
---|
1364 | transform=transform_list{choice_value}; |
---|
1365 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
1366 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
1367 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
1368 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
1369 | end |
---|
1370 | end |
---|
1371 | flagmask=Mask.A < 200; |
---|
1372 | |
---|
1373 | %make brown color image |
---|
1374 | imflag(:,:,1)=0.9*flagmask; |
---|
1375 | imflag(:,:,2)=0.7*flagmask; |
---|
1376 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
1377 | |
---|
1378 | %update mask image |
---|
1379 | hmask=[]; %default |
---|
1380 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
1381 | hmask=MaskData.maskhandle; |
---|
1382 | end |
---|
1383 | if ~isempty(hmask) |
---|
1384 | set(hmask,'CData',imflag) |
---|
1385 | set(hmask,'AlphaData',flagmask*0.6) |
---|
1386 | set(hmask,'XData',Mask.AX); |
---|
1387 | set(hmask,'YData',Mask.AY); |
---|
1388 | % uistack(hmask,'top') |
---|
1389 | else |
---|
1390 | axes(handles.PlotAxes) |
---|
1391 | hold on |
---|
1392 | size(flagmask) |
---|
1393 | % MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask); |
---|
1394 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
1395 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask) |
---|
1396 | set(handles.CheckMask,'UserData',MaskData) |
---|
1397 | end |
---|
1398 | end |
---|
1399 | end |
---|
1400 | |
---|
1401 | %------------------------------------------------------------------------ |
---|
1402 | %------------------------------------------------------------------------ |
---|
1403 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
1404 | %------------------------------------------------------------------------ |
---|
1405 | |
---|
1406 | %------------------------------------------------------------------------ |
---|
1407 | % --- Executes on button press in runplus: make one step forward and call |
---|
1408 | % --- run0. The step forward is along the fieldname series 1 or 2 depending on |
---|
1409 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
1410 | function runplus_Callback(hObject, eventdata, handles) |
---|
1411 | %------------------------------------------------------------------------ |
---|
1412 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1413 | drawnow |
---|
1414 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
1415 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1416 | % if isnan(increment) |
---|
1417 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
1418 | % increment=1; |
---|
1419 | % end |
---|
1420 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1421 | if ~isempty(errormsg) |
---|
1422 | msgbox_uvmat('ERROR',errormsg); |
---|
1423 | end |
---|
1424 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
1425 | |
---|
1426 | %------------------------------------------------------------------------ |
---|
1427 | % --- Executes on button press in runmin: make one step backward and call |
---|
1428 | % --- run0. The step backward is along the fieldname series 1 or 2 depending on |
---|
1429 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
1430 | function runmin_Callback(hObject, eventdata, handles) |
---|
1431 | %------------------------------------------------------------------------ |
---|
1432 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1433 | drawnow |
---|
1434 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1435 | % if isnan(increment) |
---|
1436 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
1437 | % increment=1; |
---|
1438 | % end |
---|
1439 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1440 | if ~isempty(errormsg) |
---|
1441 | msgbox_uvmat('ERROR',errormsg); |
---|
1442 | end |
---|
1443 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
1444 | |
---|
1445 | %------------------------------------------------------------------------ |
---|
1446 | % -- Executes on button press in Movie: make a series of +> steps |
---|
1447 | function Movie_Callback(hObject, eventdata, handles) |
---|
1448 | %------------------------------------------------------------------------ |
---|
1449 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1450 | drawnow |
---|
1451 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1452 | % if isnan(increment) |
---|
1453 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
1454 | % increment=1; |
---|
1455 | % end |
---|
1456 | set(handles.STOP,'Visible','on') |
---|
1457 | set(handles.speed,'Visible','on') |
---|
1458 | set(handles.speed_txt,'Visible','on') |
---|
1459 | set(handles.Movie,'BusyAction','queue') |
---|
1460 | UvData=get(handles.uvmat,'UserData'); |
---|
1461 | |
---|
1462 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
1463 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1464 | if ~isempty(errormsg) |
---|
1465 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1466 | return |
---|
1467 | end |
---|
1468 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
1469 | end |
---|
1470 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
1471 | UvData.aviobj=close(UvData.aviobj); |
---|
1472 | set(handles.uvmat,'UserData',UvData); |
---|
1473 | end |
---|
1474 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1475 | |
---|
1476 | %------------------------------------------------------------------------ |
---|
1477 | % -- Executes on button press in Movie: make a series of <- steps |
---|
1478 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
1479 | %------------------------------------------------------------------------ |
---|
1480 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1481 | drawnow |
---|
1482 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1483 | set(handles.STOP,'Visible','on') |
---|
1484 | set(handles.speed,'Visible','on') |
---|
1485 | set(handles.speed_txt,'Visible','on') |
---|
1486 | set(handles.MovieBackward,'BusyAction','queue') |
---|
1487 | UvData=get(handles.uvmat,'UserData'); |
---|
1488 | |
---|
1489 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
1490 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1491 | if ~isempty(errormsg) |
---|
1492 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1493 | return |
---|
1494 | end |
---|
1495 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
1496 | end |
---|
1497 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
1498 | UvData.aviobj=close(UvData.aviobj); |
---|
1499 | set(handles.uvmat,'UserData',UvData); |
---|
1500 | end |
---|
1501 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1502 | |
---|
1503 | %------------------------------------------------------------------------ |
---|
1504 | function STOP_Callback(hObject, eventdata, handles) |
---|
1505 | %------------------------------------------------------------------------ |
---|
1506 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
1507 | set(handles.movie_pair,'value',0) |
---|
1508 | set(handles.Movie,'BusyAction','Cancel') |
---|
1509 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
1510 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
1511 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1512 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1513 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1514 | |
---|
1515 | %------------------------------------------------------------------------ |
---|
1516 | % --- function activated by runplus and run minus |
---|
1517 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
1518 | %------------------------------------------------------------------------ |
---|
1519 | errormsg='';%default |
---|
1520 | %% check for movie pair status |
---|
1521 | movie_status=get(handles.movie_pair,'Value'); |
---|
1522 | if isequal(movie_status,1) |
---|
1523 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
1524 | end |
---|
1525 | |
---|
1526 | %% read the current input file name(s) and field indices |
---|
1527 | InputFile=read_GUI(handles.InputFile); |
---|
1528 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
1529 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
1530 | FileExt=InputFile.FileExt; |
---|
1531 | NomType=get(handles.NomType,'String'); |
---|
1532 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
1533 | i2=[];%default |
---|
1534 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
1535 | i2=str2num(get(handles.i2,'String')); |
---|
1536 | end |
---|
1537 | j1=[]; |
---|
1538 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
1539 | j1=stra2num(get(handles.j1,'String')); |
---|
1540 | end |
---|
1541 | j2=j1; |
---|
1542 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
1543 | j2=stra2num(get(handles.j2,'String')); |
---|
1544 | end |
---|
1545 | sub_value= get(handles.SubField,'Value'); |
---|
1546 | if sub_value % a second input file has been entered |
---|
1547 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
1548 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1 |
---|
1549 | else |
---|
1550 | filename_1=[]; |
---|
1551 | end |
---|
1552 | |
---|
1553 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
1554 | if isempty(increment) |
---|
1555 | set(handles.CheckFixPair,'Value',0) |
---|
1556 | end |
---|
1557 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
1558 | |
---|
1559 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
1560 | if CheckFixPair |
---|
1561 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1562 | i1=i1+increment; |
---|
1563 | i2=i2+increment; |
---|
1564 | if sub_value |
---|
1565 | i1_1=i1_1+increment; |
---|
1566 | i2_1=i2_1+increment; |
---|
1567 | end |
---|
1568 | |
---|
1569 | else % case of scanning along index j (burst numbers) |
---|
1570 | j1=j1+increment; |
---|
1571 | j2=j2+increment; |
---|
1572 | if sub_value |
---|
1573 | j1_1=j1_1+increment; |
---|
1574 | j2_1=j2_1+increment; |
---|
1575 | end |
---|
1576 | end |
---|
1577 | |
---|
1578 | % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used |
---|
1579 | else |
---|
1580 | UvData=get(handles.uvmat,'UserData'); |
---|
1581 | ref_i=i1; |
---|
1582 | if ~isempty(i2) |
---|
1583 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
1584 | end |
---|
1585 | ref_j=1; |
---|
1586 | if ~isempty(j1) |
---|
1587 | ref_j=j1; |
---|
1588 | if ~isempty(j2) |
---|
1589 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
1590 | end |
---|
1591 | end |
---|
1592 | if ~isempty(increment) |
---|
1593 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1594 | ref_i=ref_i+increment;% increment the current reference index i |
---|
1595 | else % case of scanning along index j (burst numbers) |
---|
1596 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
1597 | end |
---|
1598 | else % free increment |
---|
1599 | runaction=get(gcbo,'tag'); |
---|
1600 | if strcmp(runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated |
---|
1601 | step=1; |
---|
1602 | else |
---|
1603 | step=-1; |
---|
1604 | end |
---|
1605 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1606 | ref_i=ref_i+step; |
---|
1607 | while ref_i>=0 && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
1608 | ref_i=ref_i+step; |
---|
1609 | end |
---|
1610 | else % case of scanning along index j (burst numbers) |
---|
1611 | ref_j=ref_j+step; |
---|
1612 | while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
1613 | ref_j=ref_j+step; |
---|
1614 | end |
---|
1615 | end |
---|
1616 | end |
---|
1617 | if ref_i<0 |
---|
1618 | errormsg='minimum i index reached'; |
---|
1619 | elseif ref_j<0 |
---|
1620 | errormsg='minimum j index reached'; |
---|
1621 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
1622 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
1623 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
1624 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
1625 | end |
---|
1626 | if ~isempty(errormsg),return,end |
---|
1627 | siz=size(UvData.i1_series{1}); |
---|
1628 | ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1); |
---|
1629 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
1630 | ref_indices=ref_indices(i1_subseries>0); |
---|
1631 | if isempty(ref_indices)% case of pairs (free index i) |
---|
1632 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
1633 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
1634 | ref_indices=ref_indices(i1_subseries>0); |
---|
1635 | end |
---|
1636 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
1637 | end |
---|
1638 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
1639 | if ~isempty(UvData.i2_series{1}) |
---|
1640 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
1641 | end |
---|
1642 | if ~isempty(UvData.j1_series{1}) |
---|
1643 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
1644 | end |
---|
1645 | if ~isempty(UvData.j2_series{1}) |
---|
1646 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
1647 | end |
---|
1648 | |
---|
1649 | % case of a second file series |
---|
1650 | if sub_value |
---|
1651 | ref_i_1=i1_1; |
---|
1652 | if ~isempty(i2_1) |
---|
1653 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
1654 | end |
---|
1655 | ref_j_1=1; |
---|
1656 | if ~isempty(j1_1) |
---|
1657 | ref_j_1=j1_1; |
---|
1658 | if ~isempty(j2_1) |
---|
1659 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
1660 | end |
---|
1661 | end |
---|
1662 | if ~isempty(increment) |
---|
1663 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1664 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
1665 | else % case of scanning along index j (burst numbers) |
---|
1666 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
1667 | end |
---|
1668 | else % free increment, synchronise the ref indices with the first series |
---|
1669 | ref_i_1=ref_i; |
---|
1670 | ref_j_1=ref_j; |
---|
1671 | end |
---|
1672 | if numel(UvData.i1_series)==1 |
---|
1673 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
1674 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
1675 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
1676 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
1677 | end |
---|
1678 | if ref_i_1<0 |
---|
1679 | errormsg='minimum i index reached'; |
---|
1680 | elseif ref_j_1<0 |
---|
1681 | errormsg='minimum j index reached'; |
---|
1682 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
1683 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
1684 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
1685 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
1686 | end |
---|
1687 | if ~isempty(errormsg),return,end |
---|
1688 | siz=size(UvData.i1_series{2}); |
---|
1689 | ref_indices=ref_i_1*siz(1)*siz(2)+ref_j_1*siz(1)+1:ref_i_1*siz(1)*siz(2)+(ref_j_1+1)*siz(1); |
---|
1690 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
1691 | ref_indices=ref_indices(i1_subseries>0); |
---|
1692 | if isempty(ref_indices)% case of pairs (free index i) |
---|
1693 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
1694 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
1695 | ref_indices=ref_indices(i1_subseries>0); |
---|
1696 | end |
---|
1697 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
1698 | if ~isempty(UvData.i2_series{2}) |
---|
1699 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
1700 | end |
---|
1701 | if ~isempty(UvData.j1_series{2}) |
---|
1702 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
1703 | end |
---|
1704 | if ~isempty(UvData.j2_series{2}) |
---|
1705 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
1706 | end |
---|
1707 | else% the second series (if needed) is the same file as the first |
---|
1708 | i1_1=i1; |
---|
1709 | i2_1=i2; |
---|
1710 | j1_1=j1; |
---|
1711 | j2_1=j2; |
---|
1712 | end |
---|
1713 | end |
---|
1714 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
1715 | if sub_value |
---|
1716 | filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
1717 | end |
---|
1718 | |
---|
1719 | %% refresh plots |
---|
1720 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
1721 | |
---|
1722 | %% update the index counters if the index move is successfull |
---|
1723 | if isempty(errormsg) |
---|
1724 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
1725 | if isequal(i2,i1) |
---|
1726 | set(handles.i2,'String',''); |
---|
1727 | else |
---|
1728 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
1729 | end |
---|
1730 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
1731 | if isequal(j2,j1) |
---|
1732 | set(handles.j2,'String',''); |
---|
1733 | else |
---|
1734 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
1735 | end |
---|
1736 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
1737 | set(handles.FileIndex,'String',indices); |
---|
1738 | if ~isempty(filename_1) |
---|
1739 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
1740 | set(handles.FileIndex_1,'String',indices_1); |
---|
1741 | end |
---|
1742 | if isequal(movie_status,1) |
---|
1743 | set(handles.movie_pair,'Value',1) |
---|
1744 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
1745 | end |
---|
1746 | end |
---|
1747 | |
---|
1748 | %------------------------------------------------------------------------ |
---|
1749 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
1750 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
1751 | %------------------------------------------------------------------------ |
---|
1752 | %% stop movie action if the movie_pair button is off |
---|
1753 | if ~get(handles.movie_pair,'value') |
---|
1754 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
1755 | set(handles.i2,'String','') |
---|
1756 | set(handles.j2,'String','') |
---|
1757 | return |
---|
1758 | else |
---|
1759 | set(handles.movie_pair,'BusyAction','queue') |
---|
1760 | end |
---|
1761 | |
---|
1762 | %% initialisation |
---|
1763 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1764 | drawnow |
---|
1765 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
1766 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
1767 | FieldName=list_fields{index_fields}; % selected field |
---|
1768 | UvData=get(handles.uvmat,'UserData'); |
---|
1769 | if isequal(FieldName,'image') |
---|
1770 | index=1; |
---|
1771 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
1772 | NomType=get(handles.NomType,'String'); |
---|
1773 | else |
---|
1774 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
1775 | index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
1776 | FieldName=list_fields{index_fields}; % selected field |
---|
1777 | if isequal(FieldName,'image') |
---|
1778 | index=2; |
---|
1779 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
1780 | else |
---|
1781 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
1782 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1783 | set(handles.movie_pair,'Value',0) |
---|
1784 | return |
---|
1785 | end |
---|
1786 | end |
---|
1787 | num_i1=str2num(get(handles.i1,'String')); |
---|
1788 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1789 | num_i2=str2num(get(handles.i2,'String')); |
---|
1790 | num_j2=stra2num(get(handles.j2,'String')); |
---|
1791 | if isempty(num_j2) |
---|
1792 | if isempty(num_i2) |
---|
1793 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
1794 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1795 | set(handles.movie_pair,'Value',0) |
---|
1796 | return |
---|
1797 | else |
---|
1798 | num_j2=num_j1;%repeat the index i1 by default |
---|
1799 | end |
---|
1800 | end |
---|
1801 | if isempty(num_i2) |
---|
1802 | num_i2=num_i1;%repeat the index i1 by default |
---|
1803 | end |
---|
1804 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
1805 | if strcmp(NomType,'*') |
---|
1806 | num_frame=num_i2; |
---|
1807 | else |
---|
1808 | num_frame=num_j2; |
---|
1809 | end |
---|
1810 | if ~exist(imaname_1,'file') |
---|
1811 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
1812 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1813 | set(handles.movie_pair,'Value',0) |
---|
1814 | return |
---|
1815 | end |
---|
1816 | |
---|
1817 | %% get the first image |
---|
1818 | %Field.AName='image'; |
---|
1819 | if index==1 |
---|
1820 | Field_a=UvData.Field;% movie on the second field |
---|
1821 | else |
---|
1822 | Field_a=UvData.Field_1;% movie on the first field |
---|
1823 | end |
---|
1824 | |
---|
1825 | %% read the second image |
---|
1826 | MovieObject=[]; |
---|
1827 | if numel(UvData.MovieObject)>=index |
---|
1828 | MovieObject=UvData.MovieObject{index}; |
---|
1829 | end |
---|
1830 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame) |
---|
1831 | % Field_b.AX=Field_a.AX; |
---|
1832 | % Field_b.AY=Field_a.AY; |
---|
1833 | % % z index |
---|
1834 | % nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
1835 | % if ~isempty(nbslice) |
---|
1836 | % Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
1837 | % end |
---|
1838 | % Field_b.CoordUnit='pixel'; |
---|
1839 | % |
---|
1840 | % %% determine the input file type |
---|
1841 | % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
1842 | % FileType='movie'; |
---|
1843 | % elseif isequal(lower(Ext),'.avi') |
---|
1844 | % FileType='avi'; |
---|
1845 | % elseif isequal(lower(Ext),'.vol') |
---|
1846 | % FileType='vol'; |
---|
1847 | % else |
---|
1848 | % form=imformats(Ext(2:end)); |
---|
1849 | % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
1850 | % if isequal(NomType,'*'); |
---|
1851 | % FileType='multimage'; |
---|
1852 | % else |
---|
1853 | % FileType='image'; |
---|
1854 | % end |
---|
1855 | % end |
---|
1856 | % end |
---|
1857 | % switch FileType |
---|
1858 | % case 'movie' |
---|
1859 | % if test_1 |
---|
1860 | % Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
1861 | % else |
---|
1862 | % Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
1863 | % end |
---|
1864 | % case 'avi' |
---|
1865 | % mov=aviread(imaname_1,num_i2); |
---|
1866 | % Field_b.A=frame2im(mov(1)); |
---|
1867 | % case 'vol' |
---|
1868 | % Field_b.A=imread(imaname_1); |
---|
1869 | % case 'multimage' |
---|
1870 | % Field_b.A=imread(imaname_1,num_i2); |
---|
1871 | % case 'image' |
---|
1872 | % Field_b.A=imread(imaname_1); |
---|
1873 | % end |
---|
1874 | % if get(handles.slices,'Value') |
---|
1875 | % Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
1876 | % end |
---|
1877 | |
---|
1878 | %px to phys or other transform on field |
---|
1879 | % menu_transform=get(handles.transform_fct,'String'); |
---|
1880 | % choice_value=get(handles.transform_fct,'Value'); |
---|
1881 | % transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
1882 | % transform_list=get(handles.transform_fct,'UserData'); |
---|
1883 | transform=get(handles.path_transform,'UserData'); |
---|
1884 | if ~isempty(transform) |
---|
1885 | if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
1886 | if index==2 |
---|
1887 | Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform |
---|
1888 | end |
---|
1889 | Field_b=transform(Field_b,UvData.XmlData{index}); |
---|
1890 | end |
---|
1891 | end |
---|
1892 | |
---|
1893 | % make movie until movie speed is set to 0 or STOP is activated |
---|
1894 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
1895 | set(handles.STOP,'Visible','on') |
---|
1896 | set(handles.speed,'Visible','on') |
---|
1897 | set(handles.speed_txt,'Visible','on') |
---|
1898 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
1899 | % read and plot the series of images in non erase mode |
---|
1900 | set(hima,'CData',Field_b.A); |
---|
1901 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
1902 | set(hima,'CData',Field_a.A); |
---|
1903 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
1904 | end |
---|
1905 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1906 | set(handles.movie_pair,'Value',0) |
---|
1907 | |
---|
1908 | %------------------------------------------------------------------------ |
---|
1909 | % --- Executes on button press in run0. |
---|
1910 | function run0_Callback(hObject, eventdata, handles) |
---|
1911 | %------------------------------------------------------------------------ |
---|
1912 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1913 | drawnow |
---|
1914 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
1915 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
1916 | filename_1='';%default |
---|
1917 | FileIndex_1=''; |
---|
1918 | if get(handles.SubField,'Value') |
---|
1919 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
1920 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
1921 | end |
---|
1922 | num_i1=stra2num(get(handles.i1,'String')); |
---|
1923 | num_i2=stra2num(get(handles.i2,'String')); |
---|
1924 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1925 | num_j2=stra2num(get(handles.j2,'String')); |
---|
1926 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1); |
---|
1927 | |
---|
1928 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
1929 | |
---|
1930 | if ~isempty(errormsg) |
---|
1931 | msgbox_uvmat('ERROR',errormsg); |
---|
1932 | else |
---|
1933 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
1934 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
1935 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
1936 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
1937 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
1938 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
1939 | end |
---|
1940 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
1941 | |
---|
1942 | |
---|
1943 | %------------------------------------------------------------------------ |
---|
1944 | % --- read the input files and refresh all the plots, including projection. |
---|
1945 | % OUTPUT: |
---|
1946 | % errormsg: error message char string =[] by default |
---|
1947 | % INPUT: |
---|
1948 | % filename: first input file (=[] in the absence of input file) |
---|
1949 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
1950 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
1951 | % Field: structure describing an optional input field (then replace the input file) |
---|
1952 | |
---|
1953 | function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1) |
---|
1954 | %------------------------------------------------------------------------ |
---|
1955 | |
---|
1956 | %% initialisation |
---|
1957 | abstime=[]; |
---|
1958 | abstime_1=[]; |
---|
1959 | dt=[]; |
---|
1960 | if ~exist('Field','var') |
---|
1961 | Field={}; |
---|
1962 | end |
---|
1963 | UvData=get(handles.uvmat,'UserData'); |
---|
1964 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
1965 | delete(handles.UVMAT_title) |
---|
1966 | end |
---|
1967 | |
---|
1968 | %% determine the main input file information for action |
---|
1969 | if ~exist(FileName,'file') |
---|
1970 | errormsg=['input file ' FileName ' does not exist']; |
---|
1971 | return |
---|
1972 | end |
---|
1973 | NomType=get(handles.NomType,'String'); |
---|
1974 | NomType_1=''; |
---|
1975 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
1976 | NomType_1=get(handles.NomType_1,'String'); |
---|
1977 | end |
---|
1978 | %update the z position index |
---|
1979 | nbslice_str=get(handles.num_NbSlice,'String'); |
---|
1980 | if isequal(nbslice_str,'volume')%NOT USED |
---|
1981 | z_index=num_j1; |
---|
1982 | set(handles.z_index,'String',num2str(z_index)) |
---|
1983 | else |
---|
1984 | nbslice=str2num(nbslice_str); |
---|
1985 | z_index=mod(num_i1-1,nbslice)+1; |
---|
1986 | set(handles.z_index,'String',num2str(z_index)) |
---|
1987 | end |
---|
1988 | % refresh menu for save_mask if relevant |
---|
1989 | masknumber=get(handles.masklevel,'String'); |
---|
1990 | if length(masknumber)>=z_index |
---|
1991 | set(handles.masklevel,'Value',z_index) |
---|
1992 | end |
---|
1993 | |
---|
1994 | %% test for need of tps |
---|
1995 | check_proj_tps=0; |
---|
1996 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
1997 | for iobj=1:numel(UvData.Object) |
---|
1998 | if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter') |
---|
1999 | check_proj_tps=1; |
---|
2000 | break |
---|
2001 | end |
---|
2002 | end |
---|
2003 | end |
---|
2004 | |
---|
2005 | %% read the first input field |
---|
2006 | ParamIn.ColorVar='';%default variable name for vector color |
---|
2007 | frame_index=1;%default |
---|
2008 | FieldName='';%default |
---|
2009 | VelType='';%default |
---|
2010 | switch UvData.FileType{1} |
---|
2011 | case {'civx','civdata','netcdf'}; |
---|
2012 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
2013 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
2014 | if ~strcmp(FieldName,'get_field...') |
---|
2015 | if get(handles.FixVelType,'Value') |
---|
2016 | VelTypeList=get(handles.VelType,'String'); |
---|
2017 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
2018 | end |
---|
2019 | end |
---|
2020 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
2021 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
2022 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
2023 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
2024 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
2025 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
2026 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
2027 | end |
---|
2028 | end |
---|
2029 | case {'video','mmreader'} |
---|
2030 | ParamIn=UvData.MovieObject{1}; |
---|
2031 | if ~strcmp(NomType,'*') |
---|
2032 | frame_index=num_j1;%frame index for movies or multimage |
---|
2033 | else |
---|
2034 | frame_index=num_i1; |
---|
2035 | end |
---|
2036 | case 'multimage' |
---|
2037 | if ~strcmp(NomType,'*') |
---|
2038 | frame_index=num_j1;%frame index for movies or multimage |
---|
2039 | else |
---|
2040 | frame_index=num_i1; |
---|
2041 | end |
---|
2042 | case 'vol' %TODO: update |
---|
2043 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
2044 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
2045 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
2046 | else |
---|
2047 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
2048 | return |
---|
2049 | end |
---|
2050 | end |
---|
2051 | if isstruct (ParamIn) |
---|
2052 | ParamIn.FieldName=FieldName; |
---|
2053 | ParamIn.VelType=VelType; |
---|
2054 | XNameMenu=get(handles.Coord_x,'String'); |
---|
2055 | ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); |
---|
2056 | YNameMenu=get(handles.Coord_y,'String'); |
---|
2057 | ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value')); |
---|
2058 | end |
---|
2059 | check_tps = 0; |
---|
2060 | if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
2061 | check_tps=1;%tps needed to get the requested field |
---|
2062 | end |
---|
2063 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
2064 | if ~isempty(errormsg) |
---|
2065 | errormsg=['uvmat/refresh_field/read_field: ' FileName ': ' errormsg]; |
---|
2066 | return |
---|
2067 | end |
---|
2068 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
2069 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
2070 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
2071 | end |
---|
2072 | if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field |
---|
2073 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
2074 | end |
---|
2075 | if isfield(ParamOut,'TimeValue') |
---|
2076 | Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field |
---|
2077 | end |
---|
2078 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
2079 | % end |
---|
2080 | |
---|
2081 | %% choose and read a second field FileName_1 if defined |
---|
2082 | VelType_1=[];%default |
---|
2083 | FieldName_1=[]; |
---|
2084 | ParamIn_1=[]; |
---|
2085 | ParamOut_1=[]; |
---|
2086 | frame_index_1=1; |
---|
2087 | if ~isempty(FileName_1) |
---|
2088 | if ~exist(FileName_1,'file') |
---|
2089 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
2090 | return |
---|
2091 | end |
---|
2092 | Name=FileName_1; |
---|
2093 | switch UvData.FileType{2} |
---|
2094 | case {'civx','civdata','netcdf'}; |
---|
2095 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
2096 | if ischar(list_fields),list_fields={list_fields};end |
---|
2097 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
2098 | if ~strcmp(FieldName,'get_field...') |
---|
2099 | if get(handles.FixVelType,'Value') |
---|
2100 | VelTypeList=get(handles.VelType_1,'String'); |
---|
2101 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
2102 | end |
---|
2103 | end |
---|
2104 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
2105 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
2106 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
2107 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
2108 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
2109 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
2110 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
2111 | end |
---|
2112 | end |
---|
2113 | case {'video','mmreader'} |
---|
2114 | ParamIn_1=UvData.MovieObject{2}; |
---|
2115 | if ~strcmp(NomType_1,'*') |
---|
2116 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
2117 | else |
---|
2118 | frame_index_1=i1_1; |
---|
2119 | end |
---|
2120 | case 'multimage' |
---|
2121 | if ~strcmp(NomType_1,'*') |
---|
2122 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
2123 | else |
---|
2124 | frame_index_1=i1_1; |
---|
2125 | end |
---|
2126 | case 'vol' %TODO: update |
---|
2127 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
2128 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
2129 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
2130 | else |
---|
2131 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
2132 | return |
---|
2133 | end |
---|
2134 | end |
---|
2135 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
2136 | NomType_1=get(handles.NomType_1,'String'); |
---|
2137 | else |
---|
2138 | NomType_1=get(handles.NomType,'String'); |
---|
2139 | end |
---|
2140 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
2141 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
2142 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1); |
---|
2143 | end |
---|
2144 | if test_keepdata_1 |
---|
2145 | Field{2}=UvData.Field_1;% keep the stored field |
---|
2146 | ParamOut_1=UvData.ParamOut_1; |
---|
2147 | else |
---|
2148 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
2149 | ParamIn_1.FieldName=FieldName_1; |
---|
2150 | ParamIn_1.VelType=VelType_1; |
---|
2151 | ParamIn_1.GUIName='get_field_1'; |
---|
2152 | end |
---|
2153 | [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
2154 | if ~isempty(errormsg) |
---|
2155 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
2156 | return |
---|
2157 | end |
---|
2158 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
2159 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
2160 | if ~check_proj_tps |
---|
2161 | % Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
2162 | end |
---|
2163 | end |
---|
2164 | end |
---|
2165 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
2166 | end |
---|
2167 | |
---|
2168 | %% update uvmat interface |
---|
2169 | if isfield(ParamOut,'Npx') |
---|
2170 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
2171 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
2172 | elseif isfield(ParamOut_1,'Npx') |
---|
2173 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
2174 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
2175 | end |
---|
2176 | |
---|
2177 | %% update the display menu for the first velocity type (first menuline) |
---|
2178 | test_veltype=0; |
---|
2179 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
2180 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
2181 | test_veltype=1; |
---|
2182 | set(handles.VelType,'Visible','on') |
---|
2183 | set(handles.VelType_1,'Visible','on') |
---|
2184 | set(handles.FixVelType,'Visible','on') |
---|
2185 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
2186 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
2187 | index_val=find(index_menu,1); |
---|
2188 | if isempty(index_val) |
---|
2189 | index_val=1; |
---|
2190 | end |
---|
2191 | set(handles.VelType,'Value',index_val) |
---|
2192 | if ~get(handles.SubField,'value') |
---|
2193 | set(handles.VelType,'String',menu) |
---|
2194 | set(handles.VelType_1,'Value',1) |
---|
2195 | set(handles.VelType_1,'String',[{''};menu]) |
---|
2196 | end |
---|
2197 | else |
---|
2198 | set(handles.VelType,'Visible','off') |
---|
2199 | end |
---|
2200 | % display the FieldName menu from the input file and pick the selected one: |
---|
2201 | % if isstruct(ParamOut) |
---|
2202 | % field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
2203 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
2204 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
2205 | % end |
---|
2206 | |
---|
2207 | %% update the display menu for the second velocity type (second menuline) |
---|
2208 | test_veltype_1=0; |
---|
2209 | if isempty(FileName_1) |
---|
2210 | % set(handles.FieldName_1,'Value',1); %update the field menu |
---|
2211 | % if isstruct(ParamOut) |
---|
2212 | % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
2213 | % end |
---|
2214 | elseif ~test_keepdata_1 |
---|
2215 | if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
2216 | set(handles.VelType_1,'Visible','off') |
---|
2217 | else |
---|
2218 | test_veltype_1=1; |
---|
2219 | set(handles.VelType_1,'Visible','on') |
---|
2220 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
2221 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
2222 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
2223 | set(handles.VelType_1,'String',[{''};menu]) |
---|
2224 | end |
---|
2225 | % update the second field menu: the same quantity |
---|
2226 | if isstruct(ParamOut_1) |
---|
2227 | set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu |
---|
2228 | % display the FieldName menu from the input file and pick the selected one: |
---|
2229 | field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
2230 | set(handles.FieldName_1,'Value',find(field_index,1)+1) |
---|
2231 | end |
---|
2232 | |
---|
2233 | end |
---|
2234 | if test_veltype||test_veltype_1 |
---|
2235 | set(handles.FixVelType,'Visible','on') |
---|
2236 | else |
---|
2237 | set(handles.FixVelType,'Visible','off') |
---|
2238 | end |
---|
2239 | |
---|
2240 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
2241 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
2242 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
2243 | |
---|
2244 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
2245 | if ~isfield(UvData,'NewSeries') |
---|
2246 | UvData.NewSeries=1; |
---|
2247 | end |
---|
2248 | %put W as background image by default if NbDim=2: |
---|
2249 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
2250 | set(handles.SubField,'Value',1); |
---|
2251 | set(handles.RootPath_1,'String','"') |
---|
2252 | set(handles.RootFile_1,'String','"') |
---|
2253 | set(handles.SubDir_1,'String','"'); |
---|
2254 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
2255 | set(handles.FileIndex_1,'String',indices) |
---|
2256 | set(handles.FileExt_1,'String','"'); |
---|
2257 | set(handles.FieldName_1,'Visible','on'); |
---|
2258 | set(handles.FieldName_1,'Visible','on'); |
---|
2259 | set(handles.RootPath_1,'Visible','on') |
---|
2260 | set(handles.RootFile_1,'Visible','on') |
---|
2261 | set(handles.SubDir_1,'Visible','on'); |
---|
2262 | set(handles.FileIndex_1,'Visible','on'); |
---|
2263 | set(handles.FileExt_1,'Visible','on'); |
---|
2264 | set(handles.FieldName_1,'Visible','on'); |
---|
2265 | Field{1}.AName='w'; |
---|
2266 | end |
---|
2267 | |
---|
2268 | %% display time |
---|
2269 | testimedoc=0; |
---|
2270 | TimeUnit=''; |
---|
2271 | if isfield(Field{1},'Time') |
---|
2272 | abstime=Field{1}.Time;%time read from the netcdf input file |
---|
2273 | end |
---|
2274 | if numel(Field)==2 && isfield(Field{2},'Time') |
---|
2275 | abstime_1=Field{2}.Time;%time read from the netcdf input file |
---|
2276 | end |
---|
2277 | if isfield(Field{1},'Dt') |
---|
2278 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
2279 | if isfield(Field{1},'TimeUnit') |
---|
2280 | TimeUnit=Field{1}.TimeUnit; |
---|
2281 | end |
---|
2282 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
2283 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
2284 | if isfield(Field{2},'TimeUnit') |
---|
2285 | TimeUnit=Field{2}.TimeUnit; |
---|
2286 | end |
---|
2287 | end |
---|
2288 | % time from xml file overset previous result |
---|
2289 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
2290 | if isempty(num_i2)||isnan(num_i2) |
---|
2291 | num_i2=num_i1; |
---|
2292 | end |
---|
2293 | if isempty(num_j1)||isnan(num_j1) |
---|
2294 | num_j1=1; |
---|
2295 | end |
---|
2296 | if isempty(num_j2)||isnan(num_j2) |
---|
2297 | num_j2=num_j1; |
---|
2298 | end |
---|
2299 | siz=size(UvData.XmlData{1}.Time); |
---|
2300 | if ~isempty(num_i1)&& ~isempty(num_i2)&&siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
2301 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
2302 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1)); |
---|
2303 | Field{1}.Dt=dt; |
---|
2304 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
2305 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
2306 | end |
---|
2307 | end |
---|
2308 | if numel(UvData.XmlData)==2 |
---|
2309 | if isempty(i2_1) |
---|
2310 | i2_1=num_i1; |
---|
2311 | end |
---|
2312 | if isempty(j1_1) |
---|
2313 | j1_1=1; |
---|
2314 | end |
---|
2315 | if isempty(j2_1) |
---|
2316 | j2_1=j1_1; |
---|
2317 | end |
---|
2318 | siz=size(UvData.XmlData{2}.Time); |
---|
2319 | if ~isempty(i1_1) && siz(1)>=max(i1_1,i2_1) && siz(2)>=max(j1_1,j2_1) |
---|
2320 | abstime_1=(UvData.XmlData{2}.Time(i1_1,j1_1)+UvData.XmlData{2}.Time(i2_1,j2_1))/2;%overset the time read from files |
---|
2321 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1,j2_1)-UvData.XmlData{2}.Time(i1_1,j1_1)); |
---|
2322 | end |
---|
2323 | end |
---|
2324 | end |
---|
2325 | if ~isequal(numel(abstime),1) |
---|
2326 | abstime=[]; |
---|
2327 | end |
---|
2328 | if ~isequal(numel(abstime_1),1) |
---|
2329 | abstime_1=[]; |
---|
2330 | end |
---|
2331 | set(handles.abs_time,'String',num2str(abstime,5)) |
---|
2332 | set(handles.abs_time_1,'String',num2str(abstime_1,5)) |
---|
2333 | if isempty(dt)||isequal(dt,0) |
---|
2334 | set(handles.Dt_txt,'String','') |
---|
2335 | else |
---|
2336 | if isempty(TimeUnit) |
---|
2337 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
2338 | else |
---|
2339 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
2340 | end |
---|
2341 | end |
---|
2342 | |
---|
2343 | |
---|
2344 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
2345 | UvData.FileName_1=FileName_1; |
---|
2346 | UvData.ParamOut_1=ParamOut_1; |
---|
2347 | if numel(Field)==2 |
---|
2348 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
2349 | end |
---|
2350 | |
---|
2351 | %% apply coordinate transform or other user fct |
---|
2352 | transform=get(handles.path_transform,'UserData'); |
---|
2353 | if isempty(transform) |
---|
2354 | UvData.Field=Field{1}; |
---|
2355 | else |
---|
2356 | XmlData=[];%default |
---|
2357 | XmlData_1=[];%default |
---|
2358 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
2359 | XmlData=UvData.XmlData{1}; |
---|
2360 | if numel(UvData.XmlData)==2 |
---|
2361 | XmlData_1=UvData.XmlData{2}; |
---|
2362 | end |
---|
2363 | end |
---|
2364 | transform=get(handles.path_transform,'UserData'); |
---|
2365 | switch nargin(transform) |
---|
2366 | case 4 |
---|
2367 | if length(Field)==2 |
---|
2368 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
2369 | else |
---|
2370 | UvData.Field=transform(Field{1},XmlData); |
---|
2371 | end |
---|
2372 | case 3 |
---|
2373 | if length(Field)==2 |
---|
2374 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
2375 | else |
---|
2376 | UvData.Field=transform(Field{1},XmlData); |
---|
2377 | end |
---|
2378 | case 2 |
---|
2379 | UvData.Field=transform(Field{1},XmlData); |
---|
2380 | case 1 |
---|
2381 | UvData.Field=transform(Field{1}); |
---|
2382 | end |
---|
2383 | end |
---|
2384 | |
---|
2385 | %% calculate tps coefficients if needed |
---|
2386 | UvData.Field=calc_tps(UvData.Field,check_proj_tps); |
---|
2387 | |
---|
2388 | %% analyse input field |
---|
2389 | test_x=0; |
---|
2390 | test_z=0;% test for unstructured z coordinate |
---|
2391 | [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure |
---|
2392 | if ~isempty(errormsg) |
---|
2393 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error |
---|
2394 | return |
---|
2395 | end |
---|
2396 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure |
---|
2397 | if ~isempty(errormsg) |
---|
2398 | errormsg=['error in uvmat/refresh_field/find_field_cells: ' errormsg];% display error |
---|
2399 | return |
---|
2400 | end |
---|
2401 | [NbDim,imax]=max(NbDim);% spatial dimension of the input field |
---|
2402 | if isfield(UvData.Field,'NbDim') |
---|
2403 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates |
---|
2404 | end |
---|
2405 | |
---|
2406 | %% get bounds and mesh (needed for mouse action and to open set_object) |
---|
2407 | if NbDim>1 |
---|
2408 | XName=''; %default |
---|
2409 | YName=''; |
---|
2410 | %unstructured coordinates |
---|
2411 | if ~isempty(VarType{imax}.coord_x)&&~isempty(VarType{imax}.coord_y) |
---|
2412 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; |
---|
2413 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; |
---|
2414 | %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors) |
---|
2415 | test_x=1;%test for unstructured coordinates |
---|
2416 | if ~isempty(VarType{imax}.coord_z) |
---|
2417 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; |
---|
2418 | else |
---|
2419 | NbDim=2; |
---|
2420 | end |
---|
2421 | %structured coordinate |
---|
2422 | elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 |
---|
2423 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; |
---|
2424 | if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0 |
---|
2425 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates |
---|
2426 | end |
---|
2427 | % VarIndex=CellVarIndex{imax}; % list of variable indices |
---|
2428 | DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable |
---|
2429 | nbpoints_x=DimValue(DimIndex(NbDim)); |
---|
2430 | XMax=nbpoints_x;%default |
---|
2431 | XMin=1;%default |
---|
2432 | end |
---|
2433 | |
---|
2434 | if NbDim==3 |
---|
2435 | if ~test_x |
---|
2436 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D |
---|
2437 | end |
---|
2438 | ZMax=max(UvData.Field.(ZName)); |
---|
2439 | ZMin=min(UvData.Field.(ZName)); |
---|
2440 | UvData.Field.ZMax=ZMax; |
---|
2441 | UvData.Field.ZMin=ZMin; |
---|
2442 | test_z=1; |
---|
2443 | if isequal(ZMin,ZMax)%no z dependency |
---|
2444 | NbDim=2; |
---|
2445 | test_z=0; |
---|
2446 | end |
---|
2447 | end |
---|
2448 | if ~isempty (XName) |
---|
2449 | XMax=max(max(UvData.Field.(XName))); |
---|
2450 | XMin=min(min(UvData.Field.(XName))); |
---|
2451 | UvData.Field.NbDim=NbDim; |
---|
2452 | UvData.Field.XMax=XMax; |
---|
2453 | UvData.Field.XMin=XMin; |
---|
2454 | if NbDim >1&& ~isempty(YName) |
---|
2455 | YMax=max(max(UvData.Field.(YName))); |
---|
2456 | YMin=min(min(UvData.Field.(YName))); |
---|
2457 | UvData.Field.YMax=YMax; |
---|
2458 | UvData.Field.YMin=YMin; |
---|
2459 | end |
---|
2460 | nbvec=length(UvData.Field.(XName)); |
---|
2461 | if test_x %unstructured coordinates |
---|
2462 | if test_z |
---|
2463 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector |
---|
2464 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3); |
---|
2465 | else |
---|
2466 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D |
---|
2467 | end |
---|
2468 | end |
---|
2469 | end |
---|
2470 | % case of structured coordinates |
---|
2471 | if ~test_x |
---|
2472 | DX=(XMax-XMin)/(nbpoints_x-1); |
---|
2473 | if NbDim >1 |
---|
2474 | nbpoints_y=DimValue(DimIndex(NbDim-1)); |
---|
2475 | if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index |
---|
2476 | DY=1; |
---|
2477 | UvData.Field.YMax=nbpoints_y; |
---|
2478 | UvData.Field.YMin=1; |
---|
2479 | else |
---|
2480 | DY=(YMax-YMin)/(nbpoints_y-1); |
---|
2481 | end |
---|
2482 | end |
---|
2483 | if NbDim==3 |
---|
2484 | nbpoints_z=DimValue(DimIndex(1)); |
---|
2485 | DZ=(ZMax-ZMin)/(nbpoints_z-1); |
---|
2486 | UvData.Field.Mesh=(DX*DY*DZ)^(1/3); |
---|
2487 | UvData.Field.ZMax=ZMax; |
---|
2488 | UvData.Field.ZMin=ZMin; |
---|
2489 | else |
---|
2490 | UvData.Field.Mesh=DX;%sqrt(DX*DY); |
---|
2491 | end |
---|
2492 | end |
---|
2493 | % adjust the mesh to a value 1, 2 , 5 *10^n |
---|
2494 | ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude |
---|
2495 | if UvData.Field.Mesh/ord>=5 |
---|
2496 | UvData.Field.Mesh=5*ord; |
---|
2497 | elseif UvData.Field.Mesh/ord>=2 |
---|
2498 | UvData.Field.Mesh=2*ord; |
---|
2499 | else |
---|
2500 | UvData.Field.Mesh=ord; |
---|
2501 | end |
---|
2502 | % default projection plane |
---|
2503 | if isempty(UvData.Object{1}) |
---|
2504 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
2505 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
2506 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
2507 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
2508 | end |
---|
2509 | %% 3D case (menuvolume) |
---|
2510 | if NbDim==3% && UvData.NewSeries |
---|
2511 | test_set_object=1; |
---|
2512 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
2513 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
2514 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
2515 | if ~isempty(hset_object) %if set_object is detected |
---|
2516 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
2517 | end |
---|
2518 | if test_set_object% reinitiate the GUI set_object |
---|
2519 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2 |
---|
2520 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects |
---|
2521 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane |
---|
2522 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
2523 | UvData.Object{1}.Angle=[0 0 0]; |
---|
2524 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
2525 | UvData.Object{1}.Name='1-PLANE'; |
---|
2526 | UvData.Object{1}.enable_plot=1; |
---|
2527 | set_object(UvData.Object{1},handles,ZBounds); |
---|
2528 | set(handles.ListObject,'Value',1); |
---|
2529 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
2530 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
2531 | edit_object_Callback([],[], handles) |
---|
2532 | end |
---|
2533 | %multilevel case (single menuplane in a 3D space) |
---|
2534 | elseif isfield(UvData,'Z') |
---|
2535 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
2536 | XmlData=UvData.XmlData{1}; |
---|
2537 | if isfield(XmlData,'PlanePos') |
---|
2538 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
2539 | end |
---|
2540 | if isfield(XmlData,'PlaneAngle') |
---|
2541 | siz=size(XmlData.PlaneAngle); |
---|
2542 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
2543 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
2544 | end |
---|
2545 | elseif isfield(UvData,'ZIndex') |
---|
2546 | UvData.Object{1}.ZObject=UvData.ZIndex; |
---|
2547 | end |
---|
2548 | end |
---|
2549 | end |
---|
2550 | |
---|
2551 | testnewseries=UvData.NewSeries; |
---|
2552 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
2553 | set(handles.uvmat,'UserData',UvData) |
---|
2554 | |
---|
2555 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
2556 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
2557 | % set(handles.num_MinA,'String','0') |
---|
2558 | % set(handles.num_MaxA,'String','255') |
---|
2559 | % end |
---|
2560 | |
---|
2561 | %% usual 1D (x,y) plots |
---|
2562 | if NbDim<=1 |
---|
2563 | set(handles.Objects,'Visible','off') |
---|
2564 | set(handles.ListObject_1_title,'Visible','off') |
---|
2565 | set(handles.ListObject_1,'Visible','off') |
---|
2566 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
2567 | write_plot_param(handles,PlotParamOut) %update the auto plot parameters |
---|
2568 | |
---|
2569 | %% 2D or 3D fieldname are generally projected |
---|
2570 | else |
---|
2571 | set(handles.Objects,'Visible','on') |
---|
2572 | set(handles.ListObject_1_title,'Visible','on') |
---|
2573 | set(handles.ListObject_1,'Visible','on') |
---|
2574 | |
---|
2575 | %% Plot the projections on the selected projection objects |
---|
2576 | % main projection object (uvmat display) |
---|
2577 | list_object=get(handles.ListObject_1,'String'); |
---|
2578 | if isequal(list_object,{''})%refresh list of objects if the menu is empty |
---|
2579 | set(handles.ListObject,'Value',1) |
---|
2580 | set(handles.ListObject,'String',{'plane'}) |
---|
2581 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
2582 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
2583 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
2584 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
2585 | set(handles.ListObject_1,'Value',1) |
---|
2586 | set(handles.ListObject_1,'String',{'plane'}) |
---|
2587 | end |
---|
2588 | IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
2589 | if IndexObj(1)> numel(UvData.Object) |
---|
2590 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
2591 | set(handles.ListObject_1,'Value',1) |
---|
2592 | end |
---|
2593 | IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view |
---|
2594 | if isequal(IndexObj(2),IndexObj(1)) |
---|
2595 | IndexObj(2)=[]; |
---|
2596 | end |
---|
2597 | plot_handles{1}=handles; |
---|
2598 | if isfield(UvData,'plotaxes')%case of movies |
---|
2599 | haxes(1)=UvData.plotaxes; |
---|
2600 | else |
---|
2601 | haxes(1)=handles.PlotAxes; |
---|
2602 | end |
---|
2603 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
2604 | %default settings if vectors not visible |
---|
2605 | if ~isfield(PlotParam{1},'Vectors') |
---|
2606 | PlotParam{1}.Vectors.MaxVec=1; |
---|
2607 | PlotParam{1}.Vectors.MinVec=0; |
---|
2608 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
2609 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
2610 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
2611 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
2612 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
2613 | end |
---|
2614 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
2615 | |
---|
2616 | %% second projection object (view_field display) |
---|
2617 | if length( IndexObj)>=2 |
---|
2618 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
2619 | if ~isempty(view_field_handle) |
---|
2620 | plot_handles{2}=guidata(view_field_handle); |
---|
2621 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
2622 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
2623 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
2624 | end |
---|
2625 | end |
---|
2626 | |
---|
2627 | %% loop on the projection objects: one or two |
---|
2628 | |
---|
2629 | for imap=1:numel(IndexObj) |
---|
2630 | iobj=IndexObj(imap); |
---|
2631 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object |
---|
2632 | if ~isempty(errormsg) |
---|
2633 | return |
---|
2634 | end |
---|
2635 | if testnewseries |
---|
2636 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
2637 | if isfield(ObjectData,'CoordUnit') |
---|
2638 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
2639 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
2640 | end |
---|
2641 | end |
---|
2642 | %use of mask (TODO: check) |
---|
2643 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
2644 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
2645 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
2646 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
2647 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
2648 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
2649 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
2650 | nxy=size(flag_mask); |
---|
2651 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
2652 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
2653 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
2654 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
2655 | %project on the positions of the scalar |
---|
2656 | npxy=size(ObjectData.A); |
---|
2657 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
2658 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
2659 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
2660 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
2661 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
2662 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
2663 | end |
---|
2664 | AClass=class(ObjectData.A); |
---|
2665 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
2666 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
2667 | ind_off=[]; |
---|
2668 | if isfield(ObjectData,'ListVarName') |
---|
2669 | for ilist=1:length(ObjectData.ListVarName) |
---|
2670 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') |
---|
2671 | ind_off=[ind_off ilist]; |
---|
2672 | end |
---|
2673 | end |
---|
2674 | ObjectData.ListVarName(ind_off)=[]; |
---|
2675 | VarDimIndex(ind_off)=[]; |
---|
2676 | ind_off=[]; |
---|
2677 | for ilist=1:length(ListDimName) |
---|
2678 | if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY') |
---|
2679 | ind_off=[ind_off ilist]; |
---|
2680 | end |
---|
2681 | end |
---|
2682 | ListDimName(ind_off)=[]; |
---|
2683 | DimValue(ind_off)=[]; |
---|
2684 | end |
---|
2685 | end |
---|
2686 | if ~isempty(ObjectData) |
---|
2687 | PlotType='none'; %default |
---|
2688 | if imap==2 && isempty(view_field_handle) |
---|
2689 | view_field(ObjectData) |
---|
2690 | else |
---|
2691 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
2692 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters |
---|
2693 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
2694 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
2695 | end |
---|
2696 | end |
---|
2697 | end |
---|
2698 | end |
---|
2699 | |
---|
2700 | %% update the mask |
---|
2701 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
2702 | update_mask(handles,num_i1,num_i2); |
---|
2703 | end |
---|
2704 | |
---|
2705 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
2706 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
2707 | ind_skip=[]; |
---|
2708 | % nb_histo=1; |
---|
2709 | Ustring=''; |
---|
2710 | Vstring=''; |
---|
2711 | % suppress coordinates from the histogram menu |
---|
2712 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
2713 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
2714 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
2715 | switch Role |
---|
2716 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
2717 | ind_skip=[ind_skip ivar]; |
---|
2718 | case {'vector_x'} |
---|
2719 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
2720 | ind_skip=[ind_skip ivar]; |
---|
2721 | case {'vector_y'} |
---|
2722 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
2723 | ind_skip=[ind_skip ivar]; |
---|
2724 | end |
---|
2725 | end |
---|
2726 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
2727 | DimName=''; |
---|
2728 | if ischar(DimCell) |
---|
2729 | DimName=DimCell; |
---|
2730 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
2731 | DimName=DimCell{1}; |
---|
2732 | end |
---|
2733 | if strcmp(DimName,menu_histo{ivar}) |
---|
2734 | ind_skip=[ind_skip ivar]; |
---|
2735 | end |
---|
2736 | end |
---|
2737 | menu_histo(ind_skip)=[];% remove skipped items |
---|
2738 | if ~isempty(Ustring) |
---|
2739 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
2740 | end |
---|
2741 | |
---|
2742 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2743 | % display menus and plot histograms |
---|
2744 | test_v=0; |
---|
2745 | if ~isempty(menu_histo) |
---|
2746 | set(handles.histo1_menu,'Value',1) |
---|
2747 | set(handles.histo1_menu,'String',menu_histo) |
---|
2748 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
2749 | end |
---|
2750 | end |
---|
2751 | |
---|
2752 | %------------------------------------------------------------------------ |
---|
2753 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
2754 | %-------------------------------------------- |
---|
2755 | %plot first histo |
---|
2756 | %huvmat=get(handles.histo1_menu,'parent'); |
---|
2757 | histo_menu=get(handles.histo1_menu,'String'); |
---|
2758 | histo_value=get(handles.histo1_menu,'Value'); |
---|
2759 | FieldName=histo_menu{histo_value}; |
---|
2760 | % update_histo(handles.HistoAxes,handles.uvmat,FieldName) |
---|
2761 | % |
---|
2762 | % %------------------------------------------------------------------------ |
---|
2763 | % function histo2_menu_Callback(hObject, eventdata, handles) |
---|
2764 | % %------------------------------------------------------------------------ |
---|
2765 | % %plot second histo |
---|
2766 | % %huvmat=get(handles.histo2_menu,'parent'); |
---|
2767 | % histo_menu=get(handles.histo2_menu,'String'); |
---|
2768 | % histo_value=get(handles.histo2_menu,'Value'); |
---|
2769 | % FieldName=histo_menu{histo_value}; |
---|
2770 | % update_histo(handles.histo_v,handles.uvmat,FieldName) |
---|
2771 | % |
---|
2772 | % %------------------------------------------------------------------------ |
---|
2773 | % %read the field .Fieldname stored in UvData and plot its histogram |
---|
2774 | % function update_histo(haxes,huvmat,FieldName) |
---|
2775 | %------------------------------------------------------------------------ |
---|
2776 | UvData=get(handles.uvmat,'UserData'); |
---|
2777 | Field=UvData.Field; |
---|
2778 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
2779 | FieldName_2=''; |
---|
2780 | if ~isempty(r) |
---|
2781 | FieldName=r.var1; |
---|
2782 | FieldName_2=r.var2; |
---|
2783 | end |
---|
2784 | if ~isfield(UvData.Field,FieldName) |
---|
2785 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
2786 | return |
---|
2787 | end |
---|
2788 | FieldHisto=Field.(FieldName); |
---|
2789 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
2790 | indsel=find(Field.FF==0);%find values marked as false |
---|
2791 | if ~isempty(indsel) |
---|
2792 | FieldHisto=FieldHisto(indsel); |
---|
2793 | if ~isempty(FieldName_2) |
---|
2794 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
2795 | end |
---|
2796 | end |
---|
2797 | end |
---|
2798 | if isempty(Field) |
---|
2799 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
2800 | else |
---|
2801 | nxy=size(FieldHisto); |
---|
2802 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
2803 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
2804 | if isequal(Amin,Amax) |
---|
2805 | cla(handles.HistoAxes) |
---|
2806 | else |
---|
2807 | Histo.ListVarName={FieldName,'histo'}; |
---|
2808 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
2809 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
2810 | else |
---|
2811 | if numel(nxy)==2 |
---|
2812 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
2813 | else |
---|
2814 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
2815 | end |
---|
2816 | end |
---|
2817 | %unit |
---|
2818 | units=[]; %default |
---|
2819 | for ivar=1:numel(Field.ListVarName) |
---|
2820 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
2821 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
2822 | units=Field.VarAttribute{ivar}.units; |
---|
2823 | break |
---|
2824 | end |
---|
2825 | end |
---|
2826 | end |
---|
2827 | if ~isempty(units) |
---|
2828 | Histo.VarAttribute{1}.units=units; |
---|
2829 | end |
---|
2830 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
2831 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
2832 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
2833 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
2834 | else |
---|
2835 | for col=1:size(FieldHisto,3) |
---|
2836 | B=FieldHisto(:,:,col); |
---|
2837 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
2838 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
2839 | end |
---|
2840 | end |
---|
2841 | plot_field(Histo,handles.HistoAxes); |
---|
2842 | hlegend=legend; |
---|
2843 | if isempty(FieldName_2) |
---|
2844 | set(hlegend,'String',FieldName) |
---|
2845 | else |
---|
2846 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
2847 | end |
---|
2848 | % hh=get(handles.HistoAxes,'children'); |
---|
2849 | % get(hh(1)) |
---|
2850 | % get(hh(2)) |
---|
2851 | end |
---|
2852 | end |
---|
2853 | |
---|
2854 | %------------------------------------------------------------------- |
---|
2855 | % --- translate coordinate to matrix index |
---|
2856 | %------------------------------------------------------------------- |
---|
2857 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
2858 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
2859 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
2860 | |
---|
2861 | |
---|
2862 | %------------------------------------------------------------------- |
---|
2863 | % --- Executes on button press in 'CheckZoom'. |
---|
2864 | %------------------------------------------------------------------- |
---|
2865 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
2866 | |
---|
2867 | if (get(handles.CheckZoom,'Value') == 1); |
---|
2868 | set(handles.CheckZoom,'BackgroundColor',[1 1 0]) |
---|
2869 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
2870 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
2871 | else |
---|
2872 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2873 | end |
---|
2874 | |
---|
2875 | %------------------------------------------------------------------- |
---|
2876 | % --- Executes on button press in 'CheckFixLimits'. |
---|
2877 | %------------------------------------------------------------------- |
---|
2878 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
2879 | test=get(handles.CheckFixLimits,'Value'); |
---|
2880 | if test |
---|
2881 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
2882 | else |
---|
2883 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2884 | update_plot(handles); |
---|
2885 | end |
---|
2886 | |
---|
2887 | %------------------------------------------------------------------- |
---|
2888 | % --- Executes on button press in CheckFixAspectRatio. |
---|
2889 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
2890 | %------------------------------------------------------------------- |
---|
2891 | if get(handles.CheckFixAspectRatio,'Value') |
---|
2892 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0]) |
---|
2893 | update_plot(handles); |
---|
2894 | else |
---|
2895 | set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2896 | update_plot(handles); |
---|
2897 | end |
---|
2898 | |
---|
2899 | %------------------------------------------------------------------- |
---|
2900 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
2901 | %------------------------------------------------------------------- |
---|
2902 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
2903 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow |
---|
2904 | update_plot(handles); |
---|
2905 | %------------------------------------------------------------------- |
---|
2906 | |
---|
2907 | %------------------------------------------------------------------- |
---|
2908 | |
---|
2909 | |
---|
2910 | |
---|
2911 | %------------------------------------------------------------------- |
---|
2912 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
2913 | %------------------------------------------------------------------- |
---|
2914 | function record_Callback(hObject, eventdata, handles) |
---|
2915 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); |
---|
2916 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
2917 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
2918 | %FileName=read_file_boxes(handles); |
---|
2919 | [erread,message]=fileattrib(FileName); |
---|
2920 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
2921 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
2922 | return |
---|
2923 | end |
---|
2924 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
2925 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
2926 | if ~test_civ2 && ~test_civ1 |
---|
2927 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
2928 | end |
---|
2929 | if test_civ2 |
---|
2930 | nbname='nb_vectors2'; |
---|
2931 | flagname='vec2_FixFlag'; |
---|
2932 | attrname='fix2'; |
---|
2933 | end |
---|
2934 | if test_civ1 |
---|
2935 | nbname='nb_vectors'; |
---|
2936 | flagname='vec_FixFlag'; |
---|
2937 | attrname='fix'; |
---|
2938 | end |
---|
2939 | %write fix flags in the netcdf file |
---|
2940 | UvData=get(handles.uvmat,'UserData'); |
---|
2941 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
2942 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library |
---|
2943 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
2944 | netcdf.reDef(nc); |
---|
2945 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); |
---|
2946 | dimid = netcdf.inqDimID(nc,nbname); |
---|
2947 | try |
---|
2948 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
2949 | catch |
---|
2950 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
2951 | end |
---|
2952 | netcdf.endDef(nc); |
---|
2953 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
2954 | netcdf.close(nc); |
---|
2955 | else %old netcdf library |
---|
2956 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
2957 | end |
---|
2958 | |
---|
2959 | %------------------------------------------------------------------- |
---|
2960 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
2961 | %------------------------------------------------------------------- |
---|
2962 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
2963 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
2964 | result=redef(nc); |
---|
2965 | eval(['nc.' attrname '=1;']); |
---|
2966 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
2967 | nb_vectors=size(theDim); |
---|
2968 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
2969 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
2970 | fin=close(nc); |
---|
2971 | |
---|
2972 | %------------------------------------------------------------------- |
---|
2973 | % --- Executes on button press in SubField |
---|
2974 | function SubField_Callback(hObject, eventdata, handles) |
---|
2975 | %------------------------------------------------------------------- |
---|
2976 | UvData=get(handles.uvmat,'UserData'); |
---|
2977 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
2978 | set(handles.RootPath_1,'String','') |
---|
2979 | set(handles.RootFile_1,'String','') |
---|
2980 | set(handles.SubDir_1,'String',''); |
---|
2981 | set(handles.FileIndex_1,'String',''); |
---|
2982 | set(handles.FileExt_1,'String',''); |
---|
2983 | set(handles.RootPath_1,'Visible','off') |
---|
2984 | set(handles.RootFile_1,'Visible','off') |
---|
2985 | set(handles.SubDir_1,'Visible','off'); |
---|
2986 | set(handles.NomType_1,'Visible','off'); |
---|
2987 | set(handles.abs_time_1,'Visible','off') |
---|
2988 | set(handles.FileIndex_1,'Visible','off'); |
---|
2989 | set(handles.FileExt_1,'Visible','off'); |
---|
2990 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
2991 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
2992 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
2993 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
2994 | set(handles.VelType_1,'Visible','off') |
---|
2995 | end |
---|
2996 | if isfield(UvData,'XmlData_1') |
---|
2997 | UvData=rmfield(UvData,'XmlData_1'); |
---|
2998 | end |
---|
2999 | set(handles.uvmat,'UserData',UvData); |
---|
3000 | transform_fct_list=get(handles.transform_fct,'String'); |
---|
3001 | transform_fct=transform_fct_list(get(handles.transform_fct,'Value')); |
---|
3002 | if strcmp(transform_fct,'sub_field') |
---|
3003 | set(handles.transform_fct,'Value',1)%suppress the sub_field transform |
---|
3004 | transform_fct_Callback(hObject, eventdata, handles); |
---|
3005 | else |
---|
3006 | run0_Callback(hObject, eventdata, handles) |
---|
3007 | end |
---|
3008 | else |
---|
3009 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
3010 | end |
---|
3011 | |
---|
3012 | %------------------------------------------------------------------------ |
---|
3013 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
3014 | |
---|
3015 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
3016 | %------------------------------------------------------------------------ |
---|
3017 | InputFile=read_GUI(handles.InputFile); |
---|
3018 | RootPath=InputFile.RootPath; |
---|
3019 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
3020 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
3021 | FileIndices=InputFile.FileIndex; |
---|
3022 | FileExt=InputFile.FileExt; |
---|
3023 | |
---|
3024 | |
---|
3025 | %------------------------------------------------------------------------ |
---|
3026 | % ---- read the data displayed for the second input rootfile windows |
---|
3027 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
3028 | %------------------------------------------------------------------------ |
---|
3029 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
3030 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
3031 | RootPath_1=get(handles.RootPath,'String'); |
---|
3032 | end; |
---|
3033 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
3034 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
3035 | SubDir_1=get(handles.SubDir,'String'); |
---|
3036 | end |
---|
3037 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3038 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
3039 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
3040 | RootFile_1=get(handles.RootFile,'String'); |
---|
3041 | end |
---|
3042 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3043 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
3044 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
3045 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
3046 | end |
---|
3047 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
3048 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
3049 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
3050 | end |
---|
3051 | NomType_1=get(handles.NomType_1,'String'); |
---|
3052 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
3053 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
3054 | end |
---|
3055 | %------------------------------------------------------------------------ |
---|
3056 | % --- Executes on menu selection FieldName |
---|
3057 | function FieldName_Callback(hObject, eventdata, handles) |
---|
3058 | %------------------------------------------------------------------------ |
---|
3059 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
3060 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
3061 | field= list_fields{index_fields(1)}; % selected string |
---|
3062 | if isequal(field,'get_field...') |
---|
3063 | set(handles.FixVelType,'visible','off') |
---|
3064 | set(handles.VelType,'visible','off') |
---|
3065 | set(handles.VelType_1,'visible','off') |
---|
3066 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
3067 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3068 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
3069 | if ~isempty(hget_field) |
---|
3070 | delete(hget_field) |
---|
3071 | end |
---|
3072 | get_field(FileName); |
---|
3073 | return %no further action |
---|
3074 | end |
---|
3075 | |
---|
3076 | UvData=get(handles.uvmat,'UserData'); |
---|
3077 | |
---|
3078 | %read the rootfile input display |
---|
3079 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
3080 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3081 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
3082 | if isequal(field,'image') |
---|
3083 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
3084 | imagename=UvData.Field.Civ2_ImageA; |
---|
3085 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
3086 | imagename=UvData.Field.Civ1_ImageA; |
---|
3087 | else |
---|
3088 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
3089 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
3090 | end |
---|
3091 | if ~exist(imagename,'file') |
---|
3092 | [FileName,PathName] = uigetfile( ... |
---|
3093 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
3094 | '*.jpg',' jpeg image files'; ... |
---|
3095 | '*.png','.png image files'; ... |
---|
3096 | '*.tif','.tif image files'; ... |
---|
3097 | '*.avi;*.AVI','.avi movie files'; ... |
---|
3098 | '*.vol','.volume images (png)'; ... |
---|
3099 | '*.*', 'All Files (*.*)'}, ... |
---|
3100 | 'Pick an image',imagename); |
---|
3101 | imagename=[PathName FileName]; |
---|
3102 | end |
---|
3103 | % display the selected field and related information |
---|
3104 | display_file_name(handles,imagename)%display the image |
---|
3105 | return |
---|
3106 | else |
---|
3107 | ext=get(handles.FileExt,'String'); |
---|
3108 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
3109 | [FileName,PathName] = uigetfile( ... |
---|
3110 | {'*.nc', ' (*.nc)'; |
---|
3111 | '*.nc',' netcdf files'; ... |
---|
3112 | '*.*', 'All Files (*.*)'}, ... |
---|
3113 | 'Pick a netcdf file',FileBase); |
---|
3114 | FullFileName=[PathName FileName]; |
---|
3115 | % display the selected field and related information |
---|
3116 | display_file_name( handles,FullFileName) |
---|
3117 | return |
---|
3118 | end |
---|
3119 | end |
---|
3120 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
3121 | set(handles.FileIndex,'String',indices) |
---|
3122 | % set(handles.NomType,'String',NomType) |
---|
3123 | |
---|
3124 | %common to Fields_1_Callback |
---|
3125 | list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
3126 | field_1=''; |
---|
3127 | if ~isempty(list_fields_1) |
---|
3128 | field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string |
---|
3129 | end |
---|
3130 | if isequal(field,'image')||isequal(field_1,'image') |
---|
3131 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
3132 | set(handles.TitleNpy,'Visible','on') |
---|
3133 | set(handles.num_Npx,'Visible','on') |
---|
3134 | set(handles.num_Npy,'Visible','on') |
---|
3135 | else |
---|
3136 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
3137 | set(handles.TitleNpy,'Visible','off') |
---|
3138 | set(handles.num_Npx,'Visible','off') |
---|
3139 | set(handles.num_Npy,'Visible','off') |
---|
3140 | end |
---|
3141 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
3142 | run0_Callback(hObject, eventdata, handles) |
---|
3143 | end |
---|
3144 | |
---|
3145 | %--------------------------------------------------- |
---|
3146 | % --- Executes on menu selection FieldName |
---|
3147 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
3148 | %------------------------------------------------- |
---|
3149 | %% read input data |
---|
3150 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
3151 | UvData=get(handles.uvmat,'UserData'); |
---|
3152 | if check_new && isfield(UvData,'XmlData') |
---|
3153 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
3154 | end |
---|
3155 | if isfield(UvData,'Field_1') |
---|
3156 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
3157 | end |
---|
3158 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
3159 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
3160 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
3161 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
3162 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
3163 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
3164 | set(handles.SubField,'Value',0) |
---|
3165 | SubField_Callback(hObject, eventdata, handles) |
---|
3166 | return |
---|
3167 | else |
---|
3168 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
3169 | end |
---|
3170 | |
---|
3171 | %% read the rootfile input display |
---|
3172 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
3173 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
3174 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
3175 | switch field_1 |
---|
3176 | case 'get_field...' |
---|
3177 | set_veltype_display(0) % no veltype display |
---|
3178 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
3179 | if ~isempty(hget_field) |
---|
3180 | delete(hget_field) |
---|
3181 | end |
---|
3182 | hget_field=get_field(FileName_1); |
---|
3183 | set(hget_field,'name','get_field_1') |
---|
3184 | hhget_field=guidata(hget_field); |
---|
3185 | set(hhget_field.list_fig,'Value',1) |
---|
3186 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
3187 | if check_new |
---|
3188 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3189 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
3190 | set(handles.uvmat,'UserData',UvData) |
---|
3191 | end |
---|
3192 | case 'image' |
---|
3193 | % get the image name corresponding to the current netcdf name (no unique correspondance) |
---|
3194 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
3195 | imagename=UvData.Field.Civ2_ImageA; |
---|
3196 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
3197 | imagename=UvData.Field.Civ1_ImageA; |
---|
3198 | else |
---|
3199 | SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
3200 | imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); |
---|
3201 | end |
---|
3202 | if ~exist(imagename,'file') % browse for images if it is not found |
---|
3203 | [FileName,PathName] = uigetfile( ... |
---|
3204 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
3205 | '*.jpg',' jpeg image files'; ... |
---|
3206 | '*.png','.png image files'; ... |
---|
3207 | '*.tif','.tif image files'; ... |
---|
3208 | '*.avi;*.AVI','.avi movie files'; ... |
---|
3209 | '*.vol','.volume images (png)'; ... |
---|
3210 | '*.*', 'All Files (*.*)'}, ... |
---|
3211 | 'Pick an image',imagename); |
---|
3212 | imagename=[PathName FileName]; |
---|
3213 | end |
---|
3214 | if ~ischar(imagename)% quit if the browser has been closed |
---|
3215 | set(handles.SubField,'Value',0) |
---|
3216 | else %valid browser input: display the selected image |
---|
3217 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
3218 | set(handles.TitleNpy,'Visible','on') |
---|
3219 | set(handles.num_Npx,'Visible','on') |
---|
3220 | set(handles.num_Npy,'Visible','on') |
---|
3221 | display_file_name(handles,imagename,2)%display the imag |
---|
3222 | end |
---|
3223 | otherwise |
---|
3224 | if check_new |
---|
3225 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3226 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
3227 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
3228 | end |
---|
3229 | if ~isequal(field,'image') |
---|
3230 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
3231 | set(handles.TitleNpy,'Visible','off') |
---|
3232 | set(handles.num_Npx,'Visible','off') |
---|
3233 | set(handles.num_Npy,'Visible','off') |
---|
3234 | end |
---|
3235 | set(handles.uvmat,'UserData',UvData) |
---|
3236 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
3237 | run0_Callback(hObject, eventdata, handles) |
---|
3238 | end |
---|
3239 | end |
---|
3240 | |
---|
3241 | %------------------------------------------------------------------------ |
---|
3242 | % --- set the visibility of relevant velocity type menus: |
---|
3243 | function menu=set_veltype_display(Civ,FileType) |
---|
3244 | %------------------------------------------------------------------------ |
---|
3245 | if ~exist('FileType','var') |
---|
3246 | FileType='civx'; |
---|
3247 | end |
---|
3248 | switch FileType |
---|
3249 | case 'civx' |
---|
3250 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
3251 | if isequal(Civ,0) |
---|
3252 | imax=0; |
---|
3253 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3254 | imax=1; |
---|
3255 | elseif isequal(Civ,3) |
---|
3256 | imax=3; |
---|
3257 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3258 | imax=4; |
---|
3259 | elseif isequal(Civ,6) %patch2 |
---|
3260 | imax=6; |
---|
3261 | end |
---|
3262 | case 'civdata' |
---|
3263 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
3264 | if isequal(Civ,0) |
---|
3265 | imax=0; |
---|
3266 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3267 | imax=1; |
---|
3268 | elseif isequal(Civ,3) |
---|
3269 | imax=2; |
---|
3270 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3271 | imax=3; |
---|
3272 | elseif isequal(Civ,6) %patch2 |
---|
3273 | imax=4; |
---|
3274 | end |
---|
3275 | end |
---|
3276 | menu=menu(1:imax); |
---|
3277 | |
---|
3278 | %------------------------------------------------------------------------ |
---|
3279 | % --- Executes on button press in FixVelType. |
---|
3280 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
3281 | %------------------------------------------------------------------------ |
---|
3282 | % refresh the current plot if the fixed veltype is unselected |
---|
3283 | if ~get(handles.FixVelType,'Value') |
---|
3284 | run0_Callback(hObject, eventdata, handles) |
---|
3285 | end |
---|
3286 | |
---|
3287 | %------------------------------------------------------------------------ |
---|
3288 | % --- Executes on button press in VelType. |
---|
3289 | function VelType_Callback(hObject, eventdata, handles) |
---|
3290 | %------------------------------------------------------------------------ |
---|
3291 | set(handles.FixVelType,'Value',1) |
---|
3292 | run0_Callback(hObject, eventdata, handles) |
---|
3293 | |
---|
3294 | %------------------------------------------------------------------------ |
---|
3295 | % --- Executes on choice selection in VelType_1. |
---|
3296 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
3297 | %------------------------------------------------------------------------ |
---|
3298 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
3299 | UvData=get(handles.uvmat,'UserData'); |
---|
3300 | set(handles.run0,'BackgroundColor',[1 1 0])%paint run0 button in yellow to indicate its activation |
---|
3301 | drawnow |
---|
3302 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
3303 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
3304 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
3305 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
3306 | |
---|
3307 | check_refresh=0; |
---|
3308 | if isempty(InputFile.VelType_1) |
---|
3309 | FileName_1='';% we plot the first input field without the second field |
---|
3310 | set(handles.SubField,'Value',0) |
---|
3311 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current display, removing the second field |
---|
3312 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
3313 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
3314 | check_refresh=1;%will refresh the current display |
---|
3315 | else% we introduce the same file (with a different field) for the second series |
---|
3316 | FileName_1=FileName;% we compare two fields in the same file |
---|
3317 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3318 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
3319 | set(handles.SubField,'Value',1) |
---|
3320 | transform=get(handles.path_transform,'UserData'); |
---|
3321 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
3322 | set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
3323 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current display |
---|
3324 | else |
---|
3325 | check_refresh=1; |
---|
3326 | end |
---|
3327 | end |
---|
3328 | |
---|
3329 | % refresh the current display if it has not been done previously |
---|
3330 | if check_refresh |
---|
3331 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
3332 | set(handles.uvmat,'UserData',UvData) |
---|
3333 | num_i1=stra2num(get(handles.i1,'String')); |
---|
3334 | num_i2=stra2num(get(handles.i2,'String')); |
---|
3335 | num_j1=stra2num(get(handles.j1,'String')); |
---|
3336 | num_j2=stra2num(get(handles.j2,'String')); |
---|
3337 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
3338 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
3339 | if ~isempty(errormsg) |
---|
3340 | msgbox_uvmat('ERROR',errormsg); |
---|
3341 | else |
---|
3342 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
3343 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
3344 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
3345 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
3346 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
3347 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
3348 | end |
---|
3349 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
3350 | end |
---|
3351 | |
---|
3352 | %----------------------------------------------- |
---|
3353 | % --- reset civ buttons |
---|
3354 | function reset_vel_type(handles_civ0,handle1) |
---|
3355 | for ibutton=1:length(handles_civ0) |
---|
3356 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
3357 | set(handles_civ0(ibutton),'Value',0) |
---|
3358 | end |
---|
3359 | if exist('handle1','var')%handles of selected button |
---|
3360 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
3361 | end |
---|
3362 | |
---|
3363 | %------------------------------------------------------- |
---|
3364 | % --- Executes on button press in MENUVOLUME. |
---|
3365 | %------------------------------------------------------- |
---|
3366 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
3367 | %errordlg('command VOL not implemented yet') |
---|
3368 | if ishandle(handles.UVMAT_title) |
---|
3369 | delete(handles.UVMAT_title) |
---|
3370 | end |
---|
3371 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
3372 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
3373 | set(handles.CheckZoom,'Value',0) |
---|
3374 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3375 | set(handles.edit_vect,'Value',0) |
---|
3376 | edit_vect_Callback(hObject, eventdata, handles) |
---|
3377 | set(handles.edit_object,'Value',0) |
---|
3378 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3379 | % set(handles.cal,'Value',0) |
---|
3380 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
3381 | set(handles.edit_vect,'Value',0) |
---|
3382 | edit_vect_Callback(hObject, eventdata, handles) |
---|
3383 | %initiate set_object GUI |
---|
3384 | data.Name='VOLUME'; |
---|
3385 | if isfield(UvData,'CoordType') |
---|
3386 | data.CoordType=UvData.CoordType; |
---|
3387 | end |
---|
3388 | if isfield(UvData.Field,'Mesh')&~isempty(UvData.Field.Mesh) |
---|
3389 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
3390 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
3391 | data.DX=UvData.Field.Mesh; |
---|
3392 | data.DY=UvData.Field.Mesh; |
---|
3393 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
3394 | np=size(UvData.Field.A); |
---|
3395 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
3396 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
3397 | data.RangeY=max(meshx,meshy); |
---|
3398 | data.RangeX=max(meshx,meshy); |
---|
3399 | data.DX=max(meshx,meshy); |
---|
3400 | end |
---|
3401 | data.ParentButton=handles.VOLUME; |
---|
3402 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
3403 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
3404 | % associate the set_object interface handle to the plotting axes |
---|
3405 | set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject) |
---|
3406 | UvData.MouseAction='create_object'; |
---|
3407 | else |
---|
3408 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
3409 | end |
---|
3410 | set(handles.uvmat,'UserData',UvData) |
---|
3411 | |
---|
3412 | %------------------------------------------------------- |
---|
3413 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
3414 | %------------------------------------------------------- |
---|
3415 | % |
---|
3416 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
3417 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
3418 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
3419 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
3420 | if ~test_civ2 && ~test_civ1 |
---|
3421 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
3422 | end |
---|
3423 | set(handles.record,'Visible','on') |
---|
3424 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
3425 | set(handles.edit_object,'Value',0) |
---|
3426 | set(handles.CheckZoom,'Value',0) |
---|
3427 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3428 | % set(handles.create,'Value',0) |
---|
3429 | % set(handles.create,'BackgroundColor',[0 1 0]) |
---|
3430 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3431 | set(gcf,'Pointer','arrow') |
---|
3432 | % UvData.MouseAction='edit_vect'; |
---|
3433 | else |
---|
3434 | set(handles.record,'Visible','off') |
---|
3435 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3436 | end |
---|
3437 | |
---|
3438 | %---------------------------------------------- |
---|
3439 | function save_mask_Callback(hObject, eventdata, handles) |
---|
3440 | %----------------------------------------------------------------------- |
---|
3441 | UvData=get(handles.uvmat,'UserData'); |
---|
3442 | |
---|
3443 | flag=1; |
---|
3444 | npx=size(UvData.Field.A,2); |
---|
3445 | npy=size(UvData.Field.A,1); |
---|
3446 | xi=0.5:npx-0.5; |
---|
3447 | yi=0.5:npy-0.5; |
---|
3448 | [Xi,Yi]=meshgrid(xi,yi); |
---|
3449 | if isfield(UvData,'Object') |
---|
3450 | for iobj=1:length(UvData.Object) |
---|
3451 | ObjectData=UvData.Object{iobj}; |
---|
3452 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
3453 | flagobj=1; |
---|
3454 | testphys=0; %coordinates in pixels by default |
---|
3455 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
3456 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
3457 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
3458 | testphys=1; |
---|
3459 | end |
---|
3460 | end |
---|
3461 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
3462 | if isequal(ObjectData.Type,'polygon') |
---|
3463 | X=ObjectData.Coord(:,1); |
---|
3464 | Y=ObjectData.Coord(:,2); |
---|
3465 | if testphys |
---|
3466 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
3467 | end |
---|
3468 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
3469 | elseif isequal(ObjectData.Type,'ellipse') |
---|
3470 | if testphys |
---|
3471 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
3472 | end |
---|
3473 | RangeX=max(ObjectData.RangeX); |
---|
3474 | RangeY=max(ObjectData.RangeY); |
---|
3475 | X2Max=RangeX*RangeX; |
---|
3476 | Y2Max=RangeY*RangeY; |
---|
3477 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
3478 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
3479 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
3480 | elseif isequal(ObjectData.Type,'rectangle') |
---|
3481 | if testphys |
---|
3482 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
3483 | end |
---|
3484 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
3485 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
3486 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
3487 | end |
---|
3488 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
3489 | flagobj=~flagobj; |
---|
3490 | end |
---|
3491 | flag=flag & flagobj; |
---|
3492 | end |
---|
3493 | end |
---|
3494 | end |
---|
3495 | end |
---|
3496 | % flag=~flag; |
---|
3497 | %mask name |
---|
3498 | RootPath=get(handles.RootPath,'String'); |
---|
3499 | RootFile=get(handles.RootFile,'String'); |
---|
3500 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3501 | filebase=fullfile(RootPath,RootFile); |
---|
3502 | list=get(handles.masklevel,'String'); |
---|
3503 | masknumber=num2str(length(list)); |
---|
3504 | maskindex=get(handles.masklevel,'Value'); |
---|
3505 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
3506 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
3507 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
3508 | imflag=flipdim(imflag,1); |
---|
3509 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
3510 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
3511 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
3512 | |
---|
3513 | %display the mask |
---|
3514 | figure; |
---|
3515 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
3516 | map=[vec' vec' vec']; |
---|
3517 | colormap(map) |
---|
3518 | |
---|
3519 | image(imflag); |
---|
3520 | |
---|
3521 | %------------------------------------------------------------------- |
---|
3522 | %------------------------------------------------------------------- |
---|
3523 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
3524 | |
---|
3525 | %------------------------------------------------------------------ |
---|
3526 | %------------------------------------------------------------- |
---|
3527 | % --- Executes on selection change in transform_fct. |
---|
3528 | |
---|
3529 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
3530 | %------------------------------------------------------------- |
---|
3531 | UvData=get(handles.uvmat,'UserData'); |
---|
3532 | menu=get(handles.transform_fct,'String');refresh |
---|
3533 | ichoice=get(handles.transform_fct,'Value');%item number in the menu |
---|
3534 | transform_name=menu{ichoice};% choice of the transform fct |
---|
3535 | list_path=get(handles.transform_fct,'UserData'); |
---|
3536 | |
---|
3537 | %% add a new item to the menu if the option 'more...' has been selected |
---|
3538 | prev_path=fullfile(get(handles.path_transform,'String')); |
---|
3539 | if ~exist(prev_path,'dir') |
---|
3540 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
3541 | end |
---|
3542 | if strcmp(transform_name,'more...'); |
---|
3543 | [FileName, PathName] = uigetfile( ... |
---|
3544 | {'*.m', ' (*.m)'; |
---|
3545 | '*.m', '.m files '; ... |
---|
3546 | '*.*', 'All Files (*.*)'}, ... |
---|
3547 | 'Pick the transform function', prev_path); |
---|
3548 | path_transform_fct =fullfile(PathName,FileName); |
---|
3549 | if ~exist(path_transform_fct,'file')% cancel has been activated |
---|
3550 | return |
---|
3551 | end |
---|
3552 | if isempty(regexp(FileName,'.m$'))% detect file extension .m |
---|
3553 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
3554 | return |
---|
3555 | else |
---|
3556 | transform_name=regexprep(FileName,'.m',''); |
---|
3557 | end |
---|
3558 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
3559 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
3560 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
3561 | ichoice=numel(menu)-1; |
---|
3562 | end |
---|
3563 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
3564 | set(handles.transform_fct,'String',menu) |
---|
3565 | set(handles.transform_fct,'Value',ichoice) |
---|
3566 | |
---|
3567 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
3568 | dir_perso=prefdir;%personal Matalb directory |
---|
3569 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
3570 | if exist(profil_perso,'file') |
---|
3571 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
3572 | if nb_builtin<numel(list_path) |
---|
3573 | for ilist=nb_builtin+1:numel(list_path) |
---|
3574 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
3575 | end |
---|
3576 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
3577 | end |
---|
3578 | end |
---|
3579 | end |
---|
3580 | |
---|
3581 | %% create the function handle of the selected fct |
---|
3582 | |
---|
3583 | if isempty(list_path{ichoice})% case of no selected fct |
---|
3584 | transform_handle=[]; |
---|
3585 | else |
---|
3586 | if ~exist(list_path{ichoice},'dir') |
---|
3587 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
3588 | return |
---|
3589 | end |
---|
3590 | current_dir=pwd;%current working dir |
---|
3591 | cd(list_path{ichoice}) |
---|
3592 | transform_handle=str2func(transform_name); |
---|
3593 | cd(current_dir) |
---|
3594 | end |
---|
3595 | set(handles.path_transform,'String',list_path{ichoice}) |
---|
3596 | set(handles.path_transform,'UserData',transform_handle) |
---|
3597 | set(handles.transform_fct,'UserData',list_path) |
---|
3598 | |
---|
3599 | %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file |
---|
3600 | if isempty(list_path{ichoice})% case of no selected fct |
---|
3601 | set(handles.transform_fct,'ToolTipString','transform_fct:choose a transform function') |
---|
3602 | else |
---|
3603 | try |
---|
3604 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
3605 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
3606 | fclose(fid) |
---|
3607 | set(handles.transform_fct,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
3608 | end |
---|
3609 | end |
---|
3610 | |
---|
3611 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
3612 | DataOut=[]; |
---|
3613 | CoordUnit=''; |
---|
3614 | CoordUnitPrev=''; |
---|
3615 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
3616 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
3617 | end |
---|
3618 | if ~isempty(list_path{ichoice}) |
---|
3619 | if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
3620 | XmlData=UvData.XmlData{1}; |
---|
3621 | DataOut=feval(transform_handle,'*',XmlData); |
---|
3622 | if isfield(DataOut,'CoordUnit') |
---|
3623 | CoordUnit=DataOut.CoordUnit; |
---|
3624 | end |
---|
3625 | if isfield(DataOut,'InputFieldType') |
---|
3626 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
3627 | end |
---|
3628 | else |
---|
3629 | DataOut=feval(transform_handle,'*'); |
---|
3630 | end |
---|
3631 | end |
---|
3632 | |
---|
3633 | set(handles.CheckFixLimits,'Value',0) |
---|
3634 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3635 | |
---|
3636 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
3637 | if ~strcmp(CoordUnit,CoordUnitPrev) |
---|
3638 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
3639 | for iobj=1:length(hother) |
---|
3640 | delete_object(hother(iobj)) |
---|
3641 | end |
---|
3642 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
3643 | for iobj=1:length(hother) |
---|
3644 | delete_object(hother(iobj)) |
---|
3645 | end |
---|
3646 | hh=findobj('Tag','calib_points'); |
---|
3647 | if ~isempty(hh) |
---|
3648 | delete(hh) |
---|
3649 | end |
---|
3650 | hhh=findobj('Tag','calib_marker'); |
---|
3651 | if ~isempty(hhh) |
---|
3652 | delete(hhh) |
---|
3653 | end |
---|
3654 | % if isfield(UvData,'Object') |
---|
3655 | % UvData.Object=UvData.Object(1); |
---|
3656 | % end |
---|
3657 | set(handles.ListObject,'Value',1) |
---|
3658 | set(handles.ListObject,'String',{''}) |
---|
3659 | set(handles.ListObject_1,'Value',1) |
---|
3660 | set(handles.ListObject_1,'String',{''}) |
---|
3661 | set(handles.ViewObject,'value',0) |
---|
3662 | ViewObject_Callback(hObject, eventdata, handles) |
---|
3663 | set(handles.ViewField,'value',0) |
---|
3664 | ViewField_Callback(hObject, eventdata, handles) |
---|
3665 | set(handles.edit_object,'Value',0) |
---|
3666 | edit_object_Callback(hObject, eventdata, handles) |
---|
3667 | UvData.Object={[]}; |
---|
3668 | end |
---|
3669 | set(handles.uvmat,'UserData',UvData) |
---|
3670 | |
---|
3671 | %% refresh the current plot |
---|
3672 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
3673 | set(handles.SubField,'Value',0) |
---|
3674 | SubField_Callback(hObject, eventdata, handles) |
---|
3675 | else |
---|
3676 | run0_Callback(hObject, eventdata, handles) |
---|
3677 | end |
---|
3678 | |
---|
3679 | %------------------------------------------------ |
---|
3680 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
3681 | %------------------------------------------------- |
---|
3682 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3683 | % Plot coordinates |
---|
3684 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3685 | %------------------------------------------------------------------------ |
---|
3686 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
3687 | %------------------------------------------------------------------------ |
---|
3688 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3689 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3690 | update_plot(handles); |
---|
3691 | |
---|
3692 | %------------------------------------------------------------------------ |
---|
3693 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
3694 | %------------------------------------------------------------------------ |
---|
3695 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3696 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3697 | update_plot(handles); |
---|
3698 | |
---|
3699 | %------------------------------------------------------------------------ |
---|
3700 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
3701 | %------------------------------------------ |
---|
3702 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3703 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3704 | update_plot(handles); |
---|
3705 | |
---|
3706 | %------------------------------------------------------------------------ |
---|
3707 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
3708 | %------------------------------------------------------------------------ |
---|
3709 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3710 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3711 | update_plot(handles); |
---|
3712 | |
---|
3713 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3714 | % Scalar or image representation |
---|
3715 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3716 | %------------------------------------------------------------------------ |
---|
3717 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
3718 | %------------------------------------------ |
---|
3719 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
3720 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3721 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
3722 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
3723 | if MinA>MaxA% switch minA and maxA in case of error |
---|
3724 | MinA_old=MinA; |
---|
3725 | MinA=MaxA; |
---|
3726 | MaxA=MinA_old; |
---|
3727 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
3728 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
3729 | end |
---|
3730 | update_plot(handles); |
---|
3731 | |
---|
3732 | %------------------------------------------------------------------------ |
---|
3733 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
3734 | %------------------------------------------------------------------------ |
---|
3735 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
3736 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3737 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
3738 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
3739 | if MinA>MaxA% switch minA and maxA in case of error |
---|
3740 | MinA_old=MinA; |
---|
3741 | MinA=MaxA; |
---|
3742 | MaxA=MinA_old; |
---|
3743 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
3744 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
3745 | end |
---|
3746 | update_plot(handles); |
---|
3747 | |
---|
3748 | %------------------------------------------------------------------------ |
---|
3749 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
3750 | %------------------------------------------------------------------------ |
---|
3751 | test=get(handles.CheckFixScalar,'Value'); |
---|
3752 | if test |
---|
3753 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3754 | else |
---|
3755 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3756 | update_plot(handles); |
---|
3757 | end |
---|
3758 | |
---|
3759 | %------------------------------------------------------------------- |
---|
3760 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
3761 | %------------------------------------------------------------------- |
---|
3762 | update_plot(handles); |
---|
3763 | |
---|
3764 | %------------------------------------------------------------------- |
---|
3765 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
3766 | update_plot(handles); |
---|
3767 | %------------------------------------------------------------------- |
---|
3768 | |
---|
3769 | %------------------------------------------------------------------- |
---|
3770 | function ListContour_Callback(hObject, eventdata, handles) |
---|
3771 | %------------------------------------------------------------------- |
---|
3772 | val=get(handles.ListContour,'Value'); |
---|
3773 | if val==2 |
---|
3774 | set(handles.interval_txt,'Visible','on') |
---|
3775 | set(handles.num_IncrA,'Visible','on') |
---|
3776 | else |
---|
3777 | set(handles.interval_txt,'Visible','off') |
---|
3778 | set(handles.num_IncrA,'Visible','off') |
---|
3779 | end |
---|
3780 | update_plot(handles); |
---|
3781 | |
---|
3782 | %------------------------------------------------------------------- |
---|
3783 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
3784 | %------------------------------------------------------------------- |
---|
3785 | update_plot(handles); |
---|
3786 | |
---|
3787 | |
---|
3788 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3789 | % Vector representation |
---|
3790 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3791 | %------------------------------------------------------------------- |
---|
3792 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
3793 | %------------------------------------------------------------------- |
---|
3794 | update_plot(handles); |
---|
3795 | |
---|
3796 | %------------------------------------------------------------------- |
---|
3797 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
3798 | %------------------------------------------------------------------- |
---|
3799 | update_plot(handles); |
---|
3800 | |
---|
3801 | %------------------------------------------------------------------- |
---|
3802 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
3803 | %------------------------------------------------------------------- |
---|
3804 | set(handles.CheckFixVectors,'Value',1); |
---|
3805 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
3806 | update_plot(handles); |
---|
3807 | |
---|
3808 | %------------------------------------------------------------------- |
---|
3809 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
3810 | %------------------------------------------------------------------- |
---|
3811 | test=get(handles.CheckFixVectors,'Value'); |
---|
3812 | if test |
---|
3813 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
3814 | else |
---|
3815 | update_plot(handles); |
---|
3816 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
3817 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3818 | end |
---|
3819 | |
---|
3820 | %------------------------------------------------------------------------ |
---|
3821 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
3822 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
3823 | %------------------------------------------------------------------------ |
---|
3824 | update_plot(handles); |
---|
3825 | |
---|
3826 | %------------------------------------------------------------------------ |
---|
3827 | % --- Executes on selection change in ColorCode menu |
---|
3828 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
3829 | %------------------------------------------------------------------------ |
---|
3830 | % edit the choice for color code |
---|
3831 | update_color_code_boxes(handles); |
---|
3832 | update_plot(handles); |
---|
3833 | |
---|
3834 | %------------------------------------------------------------------------ |
---|
3835 | function update_color_code_boxes(handles) |
---|
3836 | %------------------------------------------------------------------------ |
---|
3837 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
3838 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
3839 | enable_slider='off';%default |
---|
3840 | enable_bounds='off';%default |
---|
3841 | enable_scalar='off';%default |
---|
3842 | switch colcode |
---|
3843 | case {'rgb','bgr'} |
---|
3844 | enable_slider='on'; |
---|
3845 | enable_bounds='on'; |
---|
3846 | enable_scalar='on'; |
---|
3847 | case '64 colors' |
---|
3848 | enable_bounds='on'; |
---|
3849 | enable_scalar='on'; |
---|
3850 | end |
---|
3851 | set(handles.Slider1,'Visible',enable_slider) |
---|
3852 | set(handles.Slider2,'Visible', enable_slider) |
---|
3853 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
3854 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
3855 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
3856 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
3857 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
3858 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
3859 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
3860 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
3861 | set_vec_col_bar(handles) |
---|
3862 | |
---|
3863 | %------------------------------------------------------------------ |
---|
3864 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
3865 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
3866 | %------------------------------------------------------------------ |
---|
3867 | % edit the choice for color code |
---|
3868 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
3869 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
3870 | if isequal(col_scalar,'ima_cor') |
---|
3871 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
3872 | ColorCode='rgb'; |
---|
3873 | set(handles.num_MinVec,'String','0') |
---|
3874 | set(handles.num_MaxVec,'String','1') |
---|
3875 | set(handles.num_ColCode1,'String','0.333') |
---|
3876 | set(handles.num_ColCode2,'String','0.666') |
---|
3877 | else |
---|
3878 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
3879 | ColorCode='64 colors'; |
---|
3880 | end |
---|
3881 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
3882 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
3883 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
3884 | |
---|
3885 | update_color_code_boxes(handles); |
---|
3886 | %replot the current graph |
---|
3887 | run0_Callback(hObject, eventdata, handles) |
---|
3888 | |
---|
3889 | %---------------------------------------------------------------- |
---|
3890 | % -- Executes on slider movement to set the color code |
---|
3891 | % |
---|
3892 | function Slider1_Callback(hObject, eventdata, handles) |
---|
3893 | %------------------------------------------------------------------ |
---|
3894 | slider1=get(handles.Slider1,'Value'); |
---|
3895 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
3896 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
3897 | col=min_val+(max_val-min_val)*slider1; |
---|
3898 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
3899 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
3900 | set(handles.Slider2,'Value',col) |
---|
3901 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
3902 | end |
---|
3903 | set_vec_col_bar(handles) |
---|
3904 | update_plot(handles); |
---|
3905 | |
---|
3906 | %---------------------------------------------------------------- |
---|
3907 | % Executes on slider movement to set the color code |
---|
3908 | %---------------------------------------------------------------- |
---|
3909 | function Slider2_Callback(hObject, eventdata, handles) |
---|
3910 | slider2=get(handles.Slider2,'Value'); |
---|
3911 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
3912 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
3913 | col=min_val+(max_val-min_val)*slider2; |
---|
3914 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
3915 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
3916 | set(handles.Slider1,'Value',col) |
---|
3917 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
3918 | end |
---|
3919 | set_vec_col_bar(handles) |
---|
3920 | update_plot(handles); |
---|
3921 | |
---|
3922 | %---------------------------------------------------------------- |
---|
3923 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
3924 | %---------------------------------------------------------------- |
---|
3925 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
3926 | set_vec_col_bar(handles) |
---|
3927 | update_plot(handles); |
---|
3928 | |
---|
3929 | %---------------------------------------------------------------- |
---|
3930 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
3931 | %---------------------------------------------------------------- |
---|
3932 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
3933 | set_vec_col_bar(handles) |
---|
3934 | update_plot(handles); |
---|
3935 | %------------------------------------------------------------------------ |
---|
3936 | %------------------------------------------------------- |
---|
3937 | % --- Executes on button press in CheckFixVecColor. |
---|
3938 | %------------------------------------------------------- |
---|
3939 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
3940 | set_vec_col_bar(handles) |
---|
3941 | |
---|
3942 | %------------------------------------------------------------------------ |
---|
3943 | % --- Executes on button press in CheckFixVecColor. |
---|
3944 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
3945 | %------------------------------------------------------------------------ |
---|
3946 | if ~get(handles.CheckFixVecColor,'Value') |
---|
3947 | update_plot(handles); |
---|
3948 | end |
---|
3949 | |
---|
3950 | %------------------------------------------------------------------------ |
---|
3951 | % --- Executes on selection change in num_MaxVec. |
---|
3952 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
3953 | %------------------------------------------------------------------------ |
---|
3954 | max_vec_Callback(hObject, eventdata, handles) |
---|
3955 | |
---|
3956 | %------------------------------------------------------------------------ |
---|
3957 | % --- Executes on selection change in num_MaxVec. |
---|
3958 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
3959 | %------------------------------------------------------------------------ |
---|
3960 | set(handles.CheckFixVecColor,'Value',1) |
---|
3961 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
3962 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
3963 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
3964 | slider1=get(handles.Slider1,'Value'); |
---|
3965 | slider2=get(handles.Slider2,'Value'); |
---|
3966 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
3967 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
3968 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
3969 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
3970 | update_plot(handles); |
---|
3971 | |
---|
3972 | %------------------------------------------------------------------------ |
---|
3973 | % --- update the display of color code for vectors (on vecColBar) |
---|
3974 | function set_vec_col_bar(handles) |
---|
3975 | %------------------------------------------------------------------------ |
---|
3976 | %get the image of the color display button 'VecColBar' in pixels |
---|
3977 | set(handles.VecColBar,'Unit','pixel'); |
---|
3978 | pos_vert=get(handles.VecColBar,'Position'); |
---|
3979 | set(handles.VecColBar,'Unit','Normalized'); |
---|
3980 | width=ceil(pos_vert(3)); |
---|
3981 | height=ceil(pos_vert(4)); |
---|
3982 | |
---|
3983 | %get slider indications |
---|
3984 | list=get(handles.ColorCode,'String'); |
---|
3985 | ichoice=get(handles.ColorCode,'Value'); |
---|
3986 | colcode.ColorCode=list{ichoice}; |
---|
3987 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
3988 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
3989 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
3990 | if test3color |
---|
3991 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
3992 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
3993 | end |
---|
3994 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
3995 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
3996 | oneheight=ones(1,height); |
---|
3997 | A1=colorlist(col_vec,1)*oneheight; |
---|
3998 | A2=colorlist(col_vec,2)*oneheight; |
---|
3999 | A3=colorlist(col_vec,3)*oneheight; |
---|
4000 | A(:,:,1)=A1'; |
---|
4001 | A(:,:,2)=A2'; |
---|
4002 | A(:,:,3)=A3'; |
---|
4003 | set(handles.VecColBar,'Cdata',A) |
---|
4004 | |
---|
4005 | %------------------------------------------------------------------- |
---|
4006 | function update_plot(handles) |
---|
4007 | %------------------------------------------------------------------- |
---|
4008 | UvData=get(handles.uvmat,'UserData'); |
---|
4009 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
4010 | PlotParam=read_GUI(handles.uvmat); |
---|
4011 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
4012 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
4013 | |
---|
4014 | %------------------------------------------------------------------------ |
---|
4015 | %------------------------------------------------------------------------ |
---|
4016 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
4017 | %------------------------------------------------------------------------ |
---|
4018 | %------------------------------------------------------------------------ |
---|
4019 | |
---|
4020 | % --- Executes on selection change in ListObject_1. |
---|
4021 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
4022 | list_str=get(handles.ListObject,'String'); |
---|
4023 | UvData=get(handles.uvmat,'UserData'); |
---|
4024 | ObjectData=UvData.Object{get(handles.ListObject_1,'Value')}; |
---|
4025 | |
---|
4026 | %% update the projection plot on uvmat |
---|
4027 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
4028 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
4029 | %replot all the objects within the new projected field |
---|
4030 | for IndexObj=1:numel(list_str) |
---|
4031 | hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat; |
---|
4032 | if isempty(hobject) || ~ishandle(hobject) |
---|
4033 | hobject=handles.PlotAxes; |
---|
4034 | end |
---|
4035 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
4036 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
4037 | else |
---|
4038 | objectcolor='b'; |
---|
4039 | end |
---|
4040 | UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
4041 | end |
---|
4042 | set(handles.uvmat,'UserData',UvData) |
---|
4043 | |
---|
4044 | %% display the object parameters if the GUI set_object is already opened |
---|
4045 | if ~get(handles.ViewObject,'Value') |
---|
4046 | ZBounds=0; % default |
---|
4047 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4048 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4049 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4050 | end |
---|
4051 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
4052 | set_object(ObjectData,[],ZBounds); |
---|
4053 | set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
4054 | end |
---|
4055 | |
---|
4056 | % desactivate the edit object mode |
---|
4057 | set(handles.edit_object,'Value',0) |
---|
4058 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4059 | |
---|
4060 | %------------------------------------------------------------------------ |
---|
4061 | % --- Executes on selection change in ListObject. |
---|
4062 | function ListObject_Callback(hObject, eventdata, handles) |
---|
4063 | %------------------------------------------------------------------------ |
---|
4064 | list_str=get(handles.ListObject,'String'); |
---|
4065 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
4066 | |
---|
4067 | %% The object is displayed in set_object if this GUI is already opened |
---|
4068 | UvData=get(handles.uvmat,'UserData'); |
---|
4069 | ObjectData=UvData.Object{IndexObj}; |
---|
4070 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
4071 | if ~isempty(hset_object) |
---|
4072 | ZBounds=0; % default |
---|
4073 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4074 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4075 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4076 | end |
---|
4077 | ObjectData.Name=list_str{IndexObj}; |
---|
4078 | set_object(ObjectData,[],ZBounds); |
---|
4079 | set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
4080 | end |
---|
4081 | |
---|
4082 | %% desactivate the edit object mode |
---|
4083 | set(handles.edit_object,'Value',0) |
---|
4084 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4085 | |
---|
4086 | %% update the plot on view_field if view_field is already openened |
---|
4087 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4088 | if isempty(hview_field) |
---|
4089 | hhview_field.PlotAxes=[]; |
---|
4090 | else |
---|
4091 | Data=get(hview_field,'UserData'); |
---|
4092 | hhview_field=guidata(hview_field); |
---|
4093 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
4094 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interfachhview_fiel |
---|
4095 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
4096 | haxes=findobj(hview_field,'tag','axes3'); |
---|
4097 | pos=get(hview_field,'Position'); |
---|
4098 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
4099 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
4100 | pos_table=get(h_TableDisplay,'Position'); |
---|
4101 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
4102 | drawnow% needed to change position before the next command |
---|
4103 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
4104 | else |
---|
4105 | set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
4106 | end |
---|
4107 | end |
---|
4108 | |
---|
4109 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
4110 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.Object{IndexObj}.DisplayHandle.uvmat) |
---|
4111 | |
---|
4112 | %------------------------------------------------------------------------ |
---|
4113 | %--- update the color representation of objects (indicating the selected ones) |
---|
4114 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
4115 | %------------------------------------------------------------------------ |
---|
4116 | if isempty(axes_view_field)% case with no view_field plot |
---|
4117 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
4118 | else |
---|
4119 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
4120 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
4121 | end |
---|
4122 | for iobj=1:length(hother) |
---|
4123 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
4124 | set(hother(iobj),'EdgeColor','b') |
---|
4125 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
4126 | set(hother(iobj),'FaceColor','b') |
---|
4127 | end |
---|
4128 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
4129 | Acolor=get(hother(iobj),'CData'); |
---|
4130 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
4131 | set(hother(iobj),'CData',Acolor); |
---|
4132 | else |
---|
4133 | set(hother(iobj),'Color','b') |
---|
4134 | end |
---|
4135 | set(hother(iobj),'Selected','off') |
---|
4136 | end |
---|
4137 | if ishandle(DisplayHandle) |
---|
4138 | linetype=get(DisplayHandle,'Type'); |
---|
4139 | if isequal(linetype,'line') |
---|
4140 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
4141 | elseif isequal(linetype,'rectangle') |
---|
4142 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
4143 | elseif isequal(linetype,'patch') |
---|
4144 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
4145 | end |
---|
4146 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
4147 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
4148 | for iobj=1:length(SubObjectData.SubObject) |
---|
4149 | hsub=SubObjectData.SubObject(iobj); |
---|
4150 | if isequal(get(hsub,'Type'),'rectangle') |
---|
4151 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
4152 | elseif isequal(get(hsub,'Type'),'image') |
---|
4153 | Acolor=get(hsub,'CData'); |
---|
4154 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
4155 | set(hsub,'CData',Acolor); |
---|
4156 | else |
---|
4157 | set(hsub,'Color','m') |
---|
4158 | end |
---|
4159 | end |
---|
4160 | end |
---|
4161 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
4162 | set(SubObjectData.DeformPoint,'Color','m') |
---|
4163 | end |
---|
4164 | end |
---|
4165 | |
---|
4166 | %------------------------------------------------------------------- |
---|
4167 | % --- Executes on selection change in edit_object. |
---|
4168 | function edit_object_Callback(hObject, eventdata, handles) |
---|
4169 | %------------------------------------------------------------------- |
---|
4170 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4171 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
4172 | if get(handles.edit_object,'Value') |
---|
4173 | set(handles.edit_object,'BackgroundColor',[1,1,0]) |
---|
4174 | %suppress the other options |
---|
4175 | set(handles.CheckZoom,'Value',0) |
---|
4176 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
4177 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
4178 | if ishandle(hgeometry_calib) |
---|
4179 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
4180 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
4181 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4182 | end |
---|
4183 | set(handles.ViewObject,'value',1) |
---|
4184 | ViewObject_Callback(hObject, eventdata, handles) |
---|
4185 | else % desctivate object edit mode |
---|
4186 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4187 | if ~isempty(hset_object)% open the |
---|
4188 | hhset_object=guidata(hset_object); |
---|
4189 | set(hhset_object.PLOT,'enable','off'); |
---|
4190 | set(get(hset_object,'children'),'enable','inactive') |
---|
4191 | end |
---|
4192 | end |
---|
4193 | |
---|
4194 | |
---|
4195 | %------------------------------------------------------------------------ |
---|
4196 | % --- Executes on button press in ViewObject. |
---|
4197 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
4198 | %------------------------------------------------------------------------ |
---|
4199 | check_view=get(handles.ViewObject,'Value'); |
---|
4200 | |
---|
4201 | if check_view %activate set_object |
---|
4202 | IndexObj=get(handles.ListObject,'Value'); |
---|
4203 | list_object=get(handles.ListObject,'String'); |
---|
4204 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4205 | UvData.Object{IndexObj}.Name=list_object{IndexObj}; |
---|
4206 | if numel(UvData.Object)<IndexObj;% error in UvData |
---|
4207 | msgbox_uvmat('ERROR','invalid object list') |
---|
4208 | return |
---|
4209 | end |
---|
4210 | ZBounds=0; % default |
---|
4211 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4212 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4213 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4214 | end |
---|
4215 | % set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
4216 | data=UvData.Object{IndexObj}; |
---|
4217 | if ~isfield(data,'Type')% default plane |
---|
4218 | data.Type='plane'; |
---|
4219 | end |
---|
4220 | % if isfield(UvData,'Field') |
---|
4221 | % Field=UvData.Field; |
---|
4222 | % if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
4223 | % data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
4224 | % if strcmp(data.Type,'line')||strcmp(data.Type,'polyline') |
---|
4225 | % data.RangeY=UvData.Field.Mesh; |
---|
4226 | % else |
---|
4227 | % data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4228 | % end |
---|
4229 | % data.DX=UvData.Field.Mesh; |
---|
4230 | % data.DY=UvData.Field.Mesh; |
---|
4231 | % end |
---|
4232 | % if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
4233 | % data.Coord=[0 0 0]; %default |
---|
4234 | % end |
---|
4235 | % if isfield(Field,'CoordUnit') |
---|
4236 | % data.CoordUnit=Field.CoordUnit; |
---|
4237 | % end |
---|
4238 | % end |
---|
4239 | hset_object=set_object(data,[],ZBounds); |
---|
4240 | hhset_object=guidata(hset_object); |
---|
4241 | if get(handles.edit_object,'Value')% edit mode |
---|
4242 | set(hhset_object.PLOT,'Enable','on') |
---|
4243 | set(get(hset_object,'children'),'enable','on') |
---|
4244 | else |
---|
4245 | set(hhset_object.PLOT,'Enable','off') |
---|
4246 | set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE |
---|
4247 | set(hhset_object.SAVE,'Enable','on') |
---|
4248 | end |
---|
4249 | else |
---|
4250 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
4251 | if ~isempty(hset_object) |
---|
4252 | delete(hset_object)% delete existing version of set_object |
---|
4253 | end |
---|
4254 | end |
---|
4255 | |
---|
4256 | |
---|
4257 | %------------------------------------------------------------------------ |
---|
4258 | % --- Executes on button press in ViewField. |
---|
4259 | function ViewField_Callback(hObject, eventdata, handles) |
---|
4260 | %------------------------------------------------------------------------ |
---|
4261 | check_view=get(handles.ViewField,'Value'); |
---|
4262 | |
---|
4263 | if check_view |
---|
4264 | IndexObj=get(handles.ListObject,'Value'); |
---|
4265 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4266 | if numel(UvData.Object)<IndexObj(end);% error in UvData |
---|
4267 | msgbox_uvmat('ERROR','invalid object list') |
---|
4268 | return |
---|
4269 | end |
---|
4270 | ZBounds=0; % default |
---|
4271 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4272 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4273 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4274 | end |
---|
4275 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
4276 | if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane |
---|
4277 | UvData.Object{IndexObj(1)}.Type='plane'; |
---|
4278 | end |
---|
4279 | list_object=get(handles.ListObject,'String'); |
---|
4280 | UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
4281 | |
---|
4282 | %% show the projection of the selected object on view_field |
---|
4283 | ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData |
---|
4284 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4285 | if isempty(hview_field) |
---|
4286 | hview_field=view_field; |
---|
4287 | end |
---|
4288 | hhview_field=guidata(hview_field); |
---|
4289 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
4290 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
4291 | haxes=findobj(hview_field,'tag','axes3'); |
---|
4292 | pos=get(hview_field,'Position'); |
---|
4293 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
4294 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
4295 | pos_table=get(h_TableDisplay,'Position'); |
---|
4296 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
4297 | else |
---|
4298 | Data=get(hview_field,'UserData'); |
---|
4299 | set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
4300 | end |
---|
4301 | else |
---|
4302 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4303 | if ~isempty(hview_field) |
---|
4304 | delete(hview_field)% delete existing version of set_object |
---|
4305 | end |
---|
4306 | end |
---|
4307 | |
---|
4308 | |
---|
4309 | %------------------------------------------------------------------------ |
---|
4310 | % --- Executes on button press in delete_object. |
---|
4311 | function delete_object_Callback(hObject, eventdata, handles) |
---|
4312 | %------------------------------------------------------------------------ |
---|
4313 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
4314 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
4315 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
4316 | delete_object(IndexObj) |
---|
4317 | end |
---|
4318 | |
---|
4319 | %------------------------------------------------------------------------ |
---|
4320 | %------------------------------------------------------------------------ |
---|
4321 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
4322 | %------------------------------------------------------------------------ |
---|
4323 | %------------------------------------------------------------------------ |
---|
4324 | |
---|
4325 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4326 | % Export Menu Callbacks |
---|
4327 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4328 | %------------------------------------------------------------------------ |
---|
4329 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
4330 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
4331 | %------------------------------------------------------------------------ |
---|
4332 | global Data_uvmat |
---|
4333 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
4334 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
4335 | display('current field :') |
---|
4336 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
4337 | commandwindow; %brings the Matlab command window to the front |
---|
4338 | |
---|
4339 | %------------------------------------------------------------------------ |
---|
4340 | % --- Executes on button press in Menu/Export/extract figure. |
---|
4341 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
4342 | %------------------------------------------------------------------------ |
---|
4343 | % huvmat=get(handles.MenuExport,'parent'); |
---|
4344 | hfig=figure; |
---|
4345 | copyobj(handles.PlotAxes,hfig); |
---|
4346 | map=colormap(handles.PlotAxes); |
---|
4347 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4348 | colorbar |
---|
4349 | |
---|
4350 | % -------------------------------------------------------------------- |
---|
4351 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
4352 | answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported') |
---|
4353 | if strcmp(answer,'Yes') |
---|
4354 | hchild=get(handles.PlotAxes,'children'); |
---|
4355 | copyobj(hchild,gca); |
---|
4356 | end |
---|
4357 | |
---|
4358 | %------------------------------------------------------------------------ |
---|
4359 | % -------------------------------------------------------------------- |
---|
4360 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
4361 | % -------------------------------------------------------------------- |
---|
4362 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
4363 | huvmat=get(handles.run0,'parent'); |
---|
4364 | UvData=get(huvmat,'UserData'); |
---|
4365 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
4366 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4367 | FileBase=fullfile(RootPath,RootFile); |
---|
4368 | %read the current input file name |
---|
4369 | prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'}; |
---|
4370 | dlg_title = 'select properties of the output avi movie'; |
---|
4371 | num_lines= 1; |
---|
4372 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
4373 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
4374 | aviname=answer{1}; |
---|
4375 | fps=str2double(answer{2}); |
---|
4376 | % check for existing file with output name aviname |
---|
4377 | if exist(aviname,'file') |
---|
4378 | backup=aviname; |
---|
4379 | testexist=2; |
---|
4380 | while testexist==2 |
---|
4381 | backup=[backup '~']; |
---|
4382 | testexist=exist(backup,'file'); |
---|
4383 | end |
---|
4384 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
4385 | if isequal(success,1) |
---|
4386 | delete(aviname)%delete existing file |
---|
4387 | else |
---|
4388 | msgbox_uvmat('ERROR',message) |
---|
4389 | return |
---|
4390 | end |
---|
4391 | end |
---|
4392 | %create avi open |
---|
4393 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
4394 | |
---|
4395 | %display first view for tests |
---|
4396 | newfig=figure; |
---|
4397 | newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure |
---|
4398 | set(newaxes,'Tag','movieaxes') |
---|
4399 | nbpix=[512 384]*str2double(answer{3}); |
---|
4400 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
4401 | set(newaxes,'Position',eval(answer{4})); |
---|
4402 | map=colormap(handles.PlotAxes); |
---|
4403 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4404 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
4405 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
4406 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
4407 | set(huvmat,'UserData',UvData); |
---|
4408 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
4409 | set(handles.STOP,'Visible','on') |
---|
4410 | set(handles.speed,'Visible','on') |
---|
4411 | set(handles.speed_txt,'Visible','on') |
---|
4412 | set(handles.Movie,'BusyAction','queue') |
---|
4413 | |
---|
4414 | %imin=str2double(get(handles.i1,'String')); |
---|
4415 | imax=str2double(answer{5}); |
---|
4416 | % if isfield(UvData,'Time') |
---|
4417 | htitle=get(newaxes,'Title'); |
---|
4418 | xlim=get(newaxes,'XLim'); |
---|
4419 | ylim=get(newaxes,'YLim'); |
---|
4420 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
4421 | time_str=get(handles.abs_time,'String'); |
---|
4422 | set(htitle,'String',['t=' time_str]) |
---|
4423 | set(handles.speed,'Value',1) |
---|
4424 | for i=1:imax |
---|
4425 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
4426 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
4427 | drawnow |
---|
4428 | time_str=get(handles.abs_time,'String'); |
---|
4429 | if ishandle(htitle) |
---|
4430 | set(htitle,'String',['t=' time_str]) |
---|
4431 | end |
---|
4432 | mov=getframe(newfig); |
---|
4433 | aviobj=addframe(aviobj,mov); |
---|
4434 | end |
---|
4435 | end |
---|
4436 | aviobj=close(aviobj); |
---|
4437 | UvData=rmfield(UvData,'plotaxes'); |
---|
4438 | %UvData.Object{1}.plotaxes=handles.PlotAxes; |
---|
4439 | set(huvmat,'UserData',UvData); |
---|
4440 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
4441 | |
---|
4442 | |
---|
4443 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4444 | % Projection Objects Menu Callbacks |
---|
4445 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4446 | |
---|
4447 | % ----------------------------------------------------------------------- |
---|
4448 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
4449 | %------------------------------------------------------------------------ |
---|
4450 | data.Type='points'; |
---|
4451 | data.ProjMode='projection';%default |
---|
4452 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4453 | create_object(data,handles) |
---|
4454 | |
---|
4455 | % ----------------------------------------------------------------------- |
---|
4456 | function Menuline_Callback(hObject, eventdata, handles) |
---|
4457 | %------------------------------------------------------------------------ |
---|
4458 | data.Type='line'; |
---|
4459 | data.ProjMode='projection';%default |
---|
4460 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4461 | create_object(data,handles) |
---|
4462 | |
---|
4463 | %------------------------------------------------------------------------ |
---|
4464 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
4465 | %------------------------------------------------------------------------ |
---|
4466 | data.Type='polyline'; |
---|
4467 | data.ProjMode='projection';%default |
---|
4468 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4469 | create_object(data,handles) |
---|
4470 | |
---|
4471 | %------------------------------------------------------------------------ |
---|
4472 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
4473 | %------------------------------------------------------------------------ |
---|
4474 | data.Type='polygon'; |
---|
4475 | data.ProjMode='inside';%default |
---|
4476 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4477 | create_object(data,handles) |
---|
4478 | |
---|
4479 | %------------------------------------------------------------------------ |
---|
4480 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
4481 | %------------------------------------------------------------------------ |
---|
4482 | data.Type='rectangle'; |
---|
4483 | data.ProjMode='inside';%default |
---|
4484 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4485 | create_object(data,handles) |
---|
4486 | |
---|
4487 | %------------------------------------------------------------------------ |
---|
4488 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
4489 | %------------------------------------------------------------------------ |
---|
4490 | data.Type='ellipse'; |
---|
4491 | data.ProjMode='inside';%default |
---|
4492 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4493 | create_object(data,handles) |
---|
4494 | |
---|
4495 | %------------------------------------------------------------------------ |
---|
4496 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
4497 | %------------------------------------------------------------------------ |
---|
4498 | data.Type='polygon'; |
---|
4499 | data.TypeMenu={'polygon'}; |
---|
4500 | data.ProjMode='mask_inside';%default |
---|
4501 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
4502 | create_object(data,handles) |
---|
4503 | |
---|
4504 | %------------------------------------------------------------------------ |
---|
4505 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
4506 | %------------------------------------------------------------------------ |
---|
4507 | data.Type='plane'; |
---|
4508 | data.ProjMode='projection';%default |
---|
4509 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4510 | create_object(data,handles) |
---|
4511 | |
---|
4512 | %------------------------------------------------------------------------ |
---|
4513 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
4514 | %------------------------------------------------------------------------ |
---|
4515 | data.Type='volume'; |
---|
4516 | data.ProjMode='interp';%default |
---|
4517 | data.ProjModeMenu={}; |
---|
4518 | % set(handles.create,'Visible','on') |
---|
4519 | % set(handles.create,'Value',1) |
---|
4520 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
4521 | create_object(data,handles) |
---|
4522 | |
---|
4523 | %------------------------------------------------------------------------ |
---|
4524 | % --- generic function used for the creation of a projection object |
---|
4525 | function create_object(data,handles) |
---|
4526 | %------------------------------------------------------------------------ |
---|
4527 | % desactivate geometric calibration if opened |
---|
4528 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
4529 | if ishandle(hgeometry_calib) |
---|
4530 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
4531 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
4532 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4533 | end |
---|
4534 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
4535 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4536 | ListObject=get(handles.ListObject,'String'); |
---|
4537 | if ~strcmp(ListObject{end},'') |
---|
4538 | ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object |
---|
4539 | set(handles.ListObject,'String',ListObject) |
---|
4540 | end |
---|
4541 | IndexObj=length(ListObject); |
---|
4542 | set(handles.ListObject,'Value',IndexObj) |
---|
4543 | UvData=get(handles.uvmat,'UserData'); |
---|
4544 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
4545 | UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object |
---|
4546 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
4547 | data.Name=data.Type;% default name=type |
---|
4548 | data.Coord=[0 0]; %default |
---|
4549 | if isfield(UvData,'Field') |
---|
4550 | Field=UvData.Field; |
---|
4551 | if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
4552 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
4553 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points') |
---|
4554 | data.RangeY=UvData.Field.Mesh; |
---|
4555 | else |
---|
4556 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4557 | end |
---|
4558 | data.DX=UvData.Field.Mesh; |
---|
4559 | data.DY=UvData.Field.Mesh; |
---|
4560 | end |
---|
4561 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
4562 | data.Coord=[0 0 0]; %default |
---|
4563 | end |
---|
4564 | if isfield(Field,'CoordUnit') |
---|
4565 | data.CoordUnit=Field.CoordUnit; |
---|
4566 | end |
---|
4567 | end |
---|
4568 | if ishandle(handles.UVMAT_title) |
---|
4569 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered |
---|
4570 | end |
---|
4571 | hset_object=set_object(data,handles);% call the set_object interface |
---|
4572 | hhset_object=guidata(hset_object); |
---|
4573 | hchild=get(hset_object,'children'); |
---|
4574 | set(hchild,'enable','on') |
---|
4575 | set(handles.uvmat,'UserData',UvData) |
---|
4576 | set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse |
---|
4577 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
4578 | set(handles.delete_object,'Visible','on') |
---|
4579 | |
---|
4580 | %------------------------------------------------------------------------ |
---|
4581 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
4582 | %------------------------------------------------------------------------ |
---|
4583 | %get the object file |
---|
4584 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4585 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
4586 | '*.xml', '.xml files '; ... |
---|
4587 | '*.mat', '.mat matlab files '}, ... |
---|
4588 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
4589 | fileinput=[PathName FileName];%complete file name |
---|
4590 | sizf=size(fileinput); |
---|
4591 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
4592 | |
---|
4593 | %read the file |
---|
4594 | [data,heading]=xml2struct(fileinput); |
---|
4595 | if ~strcmp(heading,'ProjObject') |
---|
4596 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
4597 | end |
---|
4598 | [tild,data.Name]=fileparts(FileName);% object name set as file name |
---|
4599 | ListObject=get(handles.ListObject,'String'); |
---|
4600 | if ~strcmp(ListObject{end},'') |
---|
4601 | ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object |
---|
4602 | set(handles.ListObject,'String',ListObject) |
---|
4603 | end |
---|
4604 | IndexObj=length(ListObject); |
---|
4605 | |
---|
4606 | UvData=get(handles.uvmat,'UserData'); |
---|
4607 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
4608 | UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
4609 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
4610 | set(handles.uvmat,'UserData',UvData) |
---|
4611 | set(handles.ListObject,'Value',IndexObj) |
---|
4612 | hset_object=set_object(data);% call the set_object interface |
---|
4613 | set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object |
---|
4614 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
4615 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4616 | set(handles.delete_object,'Visible','on') |
---|
4617 | |
---|
4618 | |
---|
4619 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4620 | % MenuEdit Callbacks |
---|
4621 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4622 | %------------------------------------------------------------------------ |
---|
4623 | function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
4624 | %------------------------------------------------------------------------ |
---|
4625 | set(handles.edit_object,'Value',1) |
---|
4626 | edit_Callback(hObject, eventdata, handles) |
---|
4627 | |
---|
4628 | %------------------------------------------------------------------------ |
---|
4629 | function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
4630 | %------------------------------------------------------------------------ |
---|
4631 | set(handles.edit_vect,'Visible','on') |
---|
4632 | set(handles.edit_vect,'Value',1) |
---|
4633 | edit_vect_Callback(hObject, eventdata, handles) |
---|
4634 | |
---|
4635 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4636 | % MenuTools Callbacks |
---|
4637 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4638 | %------------------------------------------------------------------------ |
---|
4639 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
4640 | %------------------------------------------------------------------------ |
---|
4641 | |
---|
4642 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4643 | |
---|
4644 | %suppress competing options |
---|
4645 | set(handles.CheckZoom,'Value',0) |
---|
4646 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4647 | set(handles.ListObject,'Value',1) |
---|
4648 | % initiate display of GUI geometry_calib |
---|
4649 | data=[]; %default |
---|
4650 | if isfield(UvData,'CoordType') |
---|
4651 | data.CoordType=UvData.CoordType; |
---|
4652 | end |
---|
4653 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4654 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4655 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
4656 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
4657 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.PosGeometryCalib(1)*pos_uvmat(3); |
---|
4658 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.PosGeometryCalib(2)*pos_uvmat(4); |
---|
4659 | pos_cal(3:4)=UvData.OpenParam.PosGeometryCalib(3:4).* pos_uvmat(3:4); |
---|
4660 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
4661 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
4662 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
4663 | |
---|
4664 | %------------------------------------------------------------------------ |
---|
4665 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
4666 | %------------------------------------------------------------------------ |
---|
4667 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4668 | ListObj=UvData.Object; |
---|
4669 | select=zeros(1,numel(ListObj)); |
---|
4670 | for iobj=1:numel(ListObj); |
---|
4671 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
4672 | select(iobj)=1; |
---|
4673 | end |
---|
4674 | end |
---|
4675 | val=find(select); |
---|
4676 | if isempty(val) |
---|
4677 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
4678 | return |
---|
4679 | else |
---|
4680 | % set(handles.ListObject,'Max',2);%allow multiple selection |
---|
4681 | set(handles.ListObject,'Value',val); |
---|
4682 | flag=1; |
---|
4683 | npx=size(UvData.Field.A,2); |
---|
4684 | npy=size(UvData.Field.A,1); |
---|
4685 | xi=0.5:npx-0.5; |
---|
4686 | yi=0.5:npy-0.5; |
---|
4687 | [Xi,Yi]=meshgrid(xi,yi); |
---|
4688 | if isfield(UvData,'Object') |
---|
4689 | for iobj=1:length(UvData.Object) |
---|
4690 | ObjectData=UvData.Object{iobj}; |
---|
4691 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
4692 | flagobj=1; |
---|
4693 | testphys=0; %coordinates in pixels by default |
---|
4694 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
4695 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
4696 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
4697 | testphys=1; |
---|
4698 | end |
---|
4699 | end |
---|
4700 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
4701 | if isequal(ObjectData.Type,'polygon') |
---|
4702 | X=ObjectData.Coord(:,1); |
---|
4703 | Y=ObjectData.Coord(:,2); |
---|
4704 | if testphys |
---|
4705 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
4706 | end |
---|
4707 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
4708 | elseif isequal(ObjectData.Type,'ellipse') |
---|
4709 | if testphys |
---|
4710 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
4711 | end |
---|
4712 | RangeX=max(ObjectData.RangeX); |
---|
4713 | RangeY=max(ObjectData.RangeY); |
---|
4714 | X2Max=RangeX*RangeX; |
---|
4715 | Y2Max=RangeY*RangeY; |
---|
4716 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
4717 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
4718 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
4719 | elseif isequal(ObjectData.Type,'rectangle') |
---|
4720 | if testphys |
---|
4721 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
4722 | end |
---|
4723 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
4724 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
4725 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
4726 | end |
---|
4727 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
4728 | flagobj=~flagobj; |
---|
4729 | end |
---|
4730 | flag=flag & flagobj; |
---|
4731 | end |
---|
4732 | end |
---|
4733 | end |
---|
4734 | end |
---|
4735 | %mask name |
---|
4736 | RootPath=get(handles.RootPath,'String'); |
---|
4737 | SubDir=get(handles.SubDir,'String'); |
---|
4738 | RootFile=get(handles.RootFile,'String'); |
---|
4739 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
4740 | RootFile(1)=[]; |
---|
4741 | end |
---|
4742 | % filebase=fullfile(RootPath,RootFile); |
---|
4743 | list=get(handles.masklevel,'String'); |
---|
4744 | masknumber=num2str(length(list)); |
---|
4745 | maskindex=get(handles.masklevel,'Value'); |
---|
4746 | % mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
4747 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
4748 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
4749 | imflag=flipdim(imflag,1); |
---|
4750 | |
---|
4751 | %display the mask |
---|
4752 | hfigmask=figure; |
---|
4753 | set(hfigmask,'Name','mask image') |
---|
4754 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
4755 | map=[vec' vec' vec']; |
---|
4756 | colormap(map) |
---|
4757 | image(imflag); |
---|
4758 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
4759 | if ~strcmp(answer,'Cancel') |
---|
4760 | mask_dir=fileparts(answer); |
---|
4761 | if ~exist(mask_dir,'dir') |
---|
4762 | [xx,msg1]=mkdir(mask_dir); |
---|
4763 | if ~strcmp(msg1,'') |
---|
4764 | errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation |
---|
4765 | return |
---|
4766 | end |
---|
4767 | end |
---|
4768 | imwrite(imflag,answer,'BitDepth',8); |
---|
4769 | end |
---|
4770 | set(handles.ListObject,'Value',1) |
---|
4771 | end |
---|
4772 | |
---|
4773 | %------------------------------------------------------------------------ |
---|
4774 | %-- open the GUI set_grid.fig to create grid |
---|
4775 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
4776 | %------------------------------------------------------------------------ |
---|
4777 | %suppress the other options if grid is chosen |
---|
4778 | set(handles.edit_vect,'Value',0) |
---|
4779 | edit_vect_Callback(hObject, eventdata, handles) |
---|
4780 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4781 | set(handles.ListObject,'Value',1) |
---|
4782 | |
---|
4783 | %prepare display of the set_grid GUI |
---|
4784 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4785 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4786 | CoordList=get(handles.transform_fct,'String'); |
---|
4787 | val=get(handles.transform_fct,'Value'); |
---|
4788 | set_grid(FileName,CoordList{val});% call the set_object interface |
---|
4789 | |
---|
4790 | |
---|
4791 | %------------------------------------------------------------------------ |
---|
4792 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
4793 | %------------------------------------------------------------------------ |
---|
4794 | set(handles.CheckZoom,'Value',0) |
---|
4795 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
4796 | set(handles.MenuRuler,'checked','on') |
---|
4797 | UvData=get(handles.uvmat,'UserData'); |
---|
4798 | UvData.MouseAction='ruler'; |
---|
4799 | set(handles.uvmat,'UserData',UvData); |
---|
4800 | |
---|
4801 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4802 | % MenuRun Callbacks |
---|
4803 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4804 | |
---|
4805 | %------------------------------------------------------------------------ |
---|
4806 | % open the GUI 'series' |
---|
4807 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
4808 | %------------------------------------------------------------------------ |
---|
4809 | series; %first display of the GUI to fill waiting time |
---|
4810 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4811 | Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name |
---|
4812 | if isequal(get(handles.SubField,'Value'),1) |
---|
4813 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
4814 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
4815 | if ~isequal(FileName_1,Param.FileName) |
---|
4816 | Param.FileName_1=FileName_1;%second input file name if relevant |
---|
4817 | end |
---|
4818 | end |
---|
4819 | Param.NomType=get(handles.NomType,'String'); |
---|
4820 | Param.NomType_1=get(handles.NomType_1,'String'); |
---|
4821 | Param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
4822 | UvData=get(handles.uvmat,'UserData'); |
---|
4823 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
4824 | Param.Time=UvData.XmlData{1}.Time; |
---|
4825 | end |
---|
4826 | if isequal(get(handles.scan_i,'Value'),1) |
---|
4827 | Param.incr_i=str2num(get(handles.num_IndexIncrement,'String')); |
---|
4828 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
4829 | Param.incr_j=str2num(get(handles.num_IndexIncrement,'String')); |
---|
4830 | end |
---|
4831 | |
---|
4832 | %% transfer fields and coordinate names |
---|
4833 | Param.list_fields=get(handles.FieldName,'String');% list menu fields |
---|
4834 | FieldName=Param.list_fields{get(handles.FieldName,'Value')}; |
---|
4835 | ind_image=find(strcmp('image',Param.list_fields)); |
---|
4836 | if ~isempty(ind_image) && numel(Param.list_fields)>1 |
---|
4837 | Param.list_fields(ind_image)=[]; %suppress 'image' option |
---|
4838 | end |
---|
4839 | Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index |
---|
4840 | Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
4841 | if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end |
---|
4842 | FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')}; |
---|
4843 | ind_image=find(strcmp('image',Param.list_fields_1)); |
---|
4844 | if ~isempty(ind_image) && numel(Param.list_fields_1)>1 |
---|
4845 | Param.list_fields_1(ind_image)=[]; %suppress 'image' option |
---|
4846 | end |
---|
4847 | Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index |
---|
4848 | Param.transform_str=get(handles.transform_fct,'String'); |
---|
4849 | Param.transform_val=get(handles.transform_fct,'Value'); |
---|
4850 | Param.Coord_x_str=get(handles.Coord_x,'String'); |
---|
4851 | Param.Coord_x_val=get(handles.Coord_x,'Value'); |
---|
4852 | Param.Coord_y_str=get(handles.Coord_y,'String'); |
---|
4853 | Param.Coord_y_val=get(handles.Coord_y,'Value'); |
---|
4854 | series(Param); %run the series interface |
---|
4855 | |
---|
4856 | %------------------------------------------------------------------------ |
---|
4857 | % -- open the GUI civ.fig for PIV |
---|
4858 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
4859 | %------------------------------------------------------------------------ |
---|
4860 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4861 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4862 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
4863 | |
---|
4864 | % -------------------------------------------------------------------- |
---|
4865 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
4866 | % -------------------------------------------------------------------- |
---|
4867 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
4868 | pathelp=fileparts(path_to_uvmat); |
---|
4869 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
4870 | 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') |
---|
4871 | else |
---|
4872 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
4873 | web(helpfile); |
---|
4874 | end |
---|
4875 | |
---|
4876 | |
---|
4877 | % -------------------------------------------------------------------- |
---|
4878 | function MenuSetProject_Callback(hObject, eventdata, handles) |
---|
4879 | RootPath=get(handles.RootPath,'String'); |
---|
4880 | ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory'); |
---|
4881 | datatree_browser(ProjectDir) |
---|
4882 | |
---|
4883 | |
---|
4884 | % -------------------------------------------------------------------- |
---|
4885 | function MenuBrowseProject_Callback(hObject, eventdata, handles) |
---|
4886 | RootPath=get(handles.RootPath,'String'); |
---|
4887 | ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project directory'); |
---|
4888 | datatree_browser(ProjectDir) |
---|
4889 | |
---|
4890 | |
---|
4891 | % --- Executes on selection change in Coord_y. |
---|
4892 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
4893 | |
---|
4894 | % --- Executes on selection change in Coord_x. |
---|
4895 | function Coord_x_Callback(hObject, eventdata, handles) |
---|